feat(consistency): commit the-custodian daily-triage working-memory notes
All checks were successful
CI Smoke / host-smoke (push) Successful in 1s
CI Smoke / container-smoke (push) Successful in 4s

Sweep writeback stages memory/working/daily-triage-*.md on the-custodian
so activity-core hostPath sink notes reach git without a separate sync job.
This commit is contained in:
tegwick 2026-07-07 01:01:26 +02:00
parent 508105a302
commit 5289ba02ae

View file

@ -1479,6 +1479,14 @@ def _patch_task_status_in_file(
return False
def _git_identity_config() -> list[str]:
import os as _os
name = _os.environ.get("GIT_SYNC_USER_NAME", "custodian-sync")
email = _os.environ.get("GIT_SYNC_USER_EMAIL", "custodian-sync@railiance.local")
return ["-c", f"user.name={name}", "-c", f"user.email={email}"]
def _git_commit_writeback(
repo_path: str,
file_path: Path,
@ -1508,7 +1516,7 @@ def _git_commit_writeback(
check=True, capture_output=True, env=sync_env,
)
subprocess.run(
["git", "-C", repo_path, "commit", "-m", msg],
["git", "-C", repo_path, *_git_identity_config(), "commit", "-m", msg],
check=True, capture_output=True, env=sync_env,
)
return True
@ -1529,6 +1537,63 @@ _TASK_STATUS_ICON = {"done": "✓", "cancel": "✗", "progress": "►", "wait":
_OPEN_STATUSES = set(OPEN_TASK_STATUSES)
def _commit_working_memory_notes(repo_slug: str, repo_path: str) -> bool:
"""Stage and commit activity-core daily-triage working-memory notes.
Only the-custodian carries the fleet working-memory sink. Notes are
repo-relative under memory/working/ and are written by activity-core on
Railiance via hostPath into the clone checkout.
"""
if repo_slug != "the-custodian":
return False
wm_dir = Path(repo_path) / "memory" / "working"
if not wm_dir.is_dir():
return False
notes = sorted(wm_dir.glob("daily-triage-*.md"))
if not notes:
return False
import os as _os
sync_env = {**_os.environ, "GIT_CUSTODIAN_SYNC": "1"}
rel_paths = [str(note.relative_to(repo_path)) for note in notes]
try:
subprocess.run(
["git", "-C", repo_path, "add", "--", *rel_paths],
check=True,
capture_output=True,
env=sync_env,
)
staged = subprocess.run(
["git", "-C", repo_path, "diff", "--cached", "--quiet"],
capture_output=True,
env=sync_env,
)
if staged.returncode == 0:
return False
from datetime import date as _date
msg = (
"chore(working-memory): sync daily-triage notes from activity-core "
f"[auto {_date.today().isoformat()}]"
)
subprocess.run(
["git", "-C", repo_path, *_git_identity_config(), "commit", "-m", msg],
check=True,
capture_output=True,
env=sync_env,
)
return True
except subprocess.CalledProcessError as e:
print(
f"WARN: working-memory commit failed: {e.stderr.decode().strip()}",
file=sys.stderr,
)
return False
def _write_custodian_brief(api_base: str, repo_slug: str, repo_path: str) -> bool:
"""Generate .custodian-brief.md at the repo root and git-commit if changed.
@ -2082,6 +2147,11 @@ def fix_repo(
if brief_written:
report.fixes_applied.append("brief: .custodian-brief.md updated")
if repo_path:
wm_committed = _commit_working_memory_notes(repo_slug, repo_path)
if wm_committed:
report.fixes_applied.append("working-memory: daily-triage notes committed")
# Push all commits made this run (writebacks + brief) to close the loop.
# This ensures the next run starts with local == remote, making the
# timer idempotent and preventing commit pile-up.