From e68559410d1b6ef7a31bab1eb46208170933cc6a Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Fri, 24 Jul 2026 15:32:27 +0100 Subject: [PATCH] fix(mind): lifecycle record --apply auto-regenerates complete/index.md record --apply wrote the completion record but left complete/index.md stale; the separate `index --apply` step (documented in the ship skills) was easy to forget, so the Lifecycle Drift workflow failed on every push to main landing a record and emailed the maintainer. Fold the index regen + git-add into cmd_record's --apply branch so the two can't drift apart. Co-Authored-By: Claude Opus 4.8 --- .../mind/lifecycle_record_auto_index.md | 30 +++++++++++++++++++ scripts/lifecycle.py | 11 +++++++ 2 files changed, 41 insertions(+) create mode 100644 draft/maintenance/mind/lifecycle_record_auto_index.md diff --git a/draft/maintenance/mind/lifecycle_record_auto_index.md b/draft/maintenance/mind/lifecycle_record_auto_index.md new file mode 100644 index 00000000..0a0089bb --- /dev/null +++ b/draft/maintenance/mind/lifecycle_record_auto_index.md @@ -0,0 +1,30 @@ +# lifecycle record auto-index + +Difficulty: trivial +Autonomy: safe +Priority: medium + +## Request (verbatim) + +Make PyAutoMind `scripts/lifecycle.py` `cmd_record` automatically regenerate and +`git add` `complete/index.md` when `--apply` is passed, so the index can never +drift stale after a ship. + +## Root cause + +`record --apply` writes the completion record and stages it, but leaves +`complete/index.md` stale. The separate `index --apply` step is documented in the +ship skills (`ship_library`/`ship_workspace`) but gets forgotten. The **Lifecycle +Drift** workflow (`.github/workflows/lifecycle_drift.yml`) runs `index --check` on +every direct push to `main` that touches `complete/**`; a forgotten regen fails +the run and emails the maintainer on every ship. + +## Fix + +In `cmd_record`, under the `--apply` branch (after the record is written and the +prompt folded), regenerate the index via the existing `_render_index` / +`_existing_curated` helpers, write `complete/index.md`, and `git add` it — the +same effect as `index --apply`, folded into `record` so the two steps can't drift +apart. Behaviour-preserving except `record --apply` now also freshens the index. + +@PyAutoMind diff --git a/scripts/lifecycle.py b/scripts/lifecycle.py index 40176e34..154d6513 100644 --- a/scripts/lifecycle.py +++ b/scripts/lifecycle.py @@ -198,6 +198,17 @@ def cmd_record(args) -> int: capture_output=True, text=True) if r.returncode != 0: prompt.unlink(missing_ok=True) + + # Freshen complete/index.md in the same step so a shipped record never + # leaves it stale — the Lifecycle Drift guard runs `index --check` on every + # push to main touching complete/**, and the separate `index --apply` step + # was easy to forget (failing runs + maintainer emails). Same effect as + # cmd_index --apply, folded in so the two can't drift apart. + INDEX_MD.write_text(_render_index(_existing_curated())) + subprocess.run(["git", "-C", str(ROOT), "add", str(INDEX_MD)], + capture_output=True, text=True) + print(f"index: refreshed {INDEX_MD.relative_to(ROOT)} " + f"({len(_all_records())} records)") return 0