From 60eeb89f6fdb1358a25f606d243bb83b9553b462 Mon Sep 17 00:00:00 2001 From: tegwick Date: Tue, 7 Jul 2026 01:01:26 +0200 Subject: [PATCH] feat(consistency): commit the-custodian daily-triage working-memory notes Sweep writeback stages memory/working/daily-triage-*.md on the-custodian so activity-core hostPath sink notes reach git without a separate sync job. --- scripts/consistency_check.py | 62 ++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/scripts/consistency_check.py b/scripts/consistency_check.py index 4c9adb1..fdcfdc6 100644 --- a/scripts/consistency_check.py +++ b/scripts/consistency_check.py @@ -1529,6 +1529,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, "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 +2139,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.