Skip to content

maintenance: self-heal stale complete/index.md in Lifecycle Drift CI #116

Description

@Jammy2211

Overview

The Lifecycle Drift workflow fails lifecycle.py index --check on every push to main while complete/index.md is stale, emailing the human once per push. Three storms so far (2026-07-24 → PR #97; 2026-07-30 morning → aba2ce5; 2026-07-30 evening → fa35972, ~25 emails in 2h). The fold-into-record --apply pattern cannot cover ad-hoc mutations of complete/ (the third break was a manual git mv of 10 phase prompts after the index regen, in the same commit). With many concurrent agent sessions, prevention alone will keep losing — the check must repair, not alarm.

Plan

  • On push to main, a stale index is repaired in CI: regenerate with index --apply, verify convergence, commit as the github-actions bot, push (rebase-retry against concurrent main advances).
  • The run fails — and emails — only if the repair itself fails (non-convergence or push rejected after retries).
  • Pull-request runs keep the current read-only fail-with-message behaviour.
  • The semantic lifecycle.py check stays a hard fail (state contradictions cannot be auto-fixed).
Detailed implementation plan

Affected Repositories

  • PyAutoMind (primary, only)

Branch Survey

Repository Current Branch Dirty?
./PyAutoMind main clean (in sync with origin/main)

Suggested branch: feature/lifecycle-drift-self-heal

Implementation Steps

  1. .github/workflows/lifecycle_drift.yml:
    • Raise permissions: contents: write (needed for the heal push; checkout's persisted GITHUB_TOKEN credentials are used).
    • Keep the lifecycle check step unchanged (hard fail).
    • Replace the index freshness step with a self-healing script:
      • index --check passes → exit 0.
      • Not a push event → fail with the current "run index --apply" message (PR behaviour unchanged).
      • Else: index --apply, then index --check again — if still drifting, fail (regen does not converge; genuine bug).
      • git config the github-actions[bot] identity, git add complete/index.md, commit "lifecycle: self-heal stale complete/index.md".
      • Push with up to 3 attempts: on rejection, git pull --rebase origin main, re-run index --apply (new records may have landed), git commit --amend --no-edit, re-verify, retry. Exhausted retries → fail.
    • Loop safety: pushes made with the default GITHUB_TOKEN do not trigger new workflow runs, so the heal commit cannot re-trigger; the pre-push convergence check guards regardless.
    • Update the workflow's header comment to describe the self-healing contract.
  2. Validation:
    • bash -n / YAML-lint the workflow locally; workflow_dispatch a green run post-merge.
    • Controlled end-to-end test post-merge: push a deliberately index-stale (but semantically valid) tweak to a completion record directly to main, watch the workflow push a bot heal commit instead of failing, then confirm the next push is green.

Key Files

  • .github/workflows/lifecycle_drift.yml — the only file changed.
  • scripts/lifecycle.py — read-only reference (cmd_index --check/--apply semantics); no changes expected.

Original Prompt

Click to expand starting prompt

Make PyAutoMind's Lifecycle Drift CI self-healing: on index drift, run lifecycle.py index --apply, commit and push the regenerated index as a bot commit (with loop guard), failing/emailing only if the repair push itself fails.

Context: third drift break today (fa35972 — ad-hoc git mv of 10 phase prompts into complete/2026/07/ after record --apply) caused ~25 failure emails 17:35–19:27 UTC; the fold-into-record-apply pattern cannot cover ad-hoc mutations of complete/. Full prompt: active/lifecycle_drift_self_heal.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions