Skip to content

fix: clean up workers after their pull requests land - #5317

Merged
kunchenguid merged 2 commits into
mainfrom
fm/fm-afk-landed-teardown-gap-r1
Sep 22, 2026
Merged

kunchenguid merged 2 commits into
mainfrom
fm/fm-afk-landed-teardown-gap-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Investigate the away-window transcripts and fix the root cause of this gap: after pull requests landed, the workers were left sitting. Supervision should have closed them. It recorded that nothing needed recovery and stopped. The return also did not close them.

The away window was 2026-09-22T07:28:14Z to 2026-09-22T16:18:35Z. The words were: all no-mistakes workflow changes should merge and complete. The sitting workers were the exemption changes whose pull requests had already merged.

What Changed

  • Direct supervision to tear down workers whose pull requests have landed instead of treating them as recovery no-ops.
  • Add a return-brief section listing live tasks with durable merge markers so cleanup happens after catch-up clears.
  • Add regression coverage and documentation for landed-worker cleanup in both supervision postures.

Risk Assessment

✅ Low: The change is narrowly scoped, preserves teardown safety checks, adds durable merge-marker-based return visibility, and covers the new observable return-brief behavior without introducing a substantiated defect.

Testing

A real isolated away-entry and return cycle used two live Herdr endpoints: the durably merge-marked task appeared as cleanup due, while the done task lacking merge evidence did not; endpoint checks, the targeted return regression, cleanup, and lab teardown all succeeded.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Returning from away mode lists durably merged work whose worker endpoint is still running as cleanup due ✅ pass live The live transcript shows landed-live as a running Herdr pane before return and under Landed, cleanup due in the real return brief.
Return handling does not classify a done worker as landed without durable merge evidence ✅ pass live The live transcript shows unproved-live as a running Herdr pane with done status, while the real return brief omits it from Landed, cleanup due.
Evidence: Live AFK return transcript with endpoint state and return brief

Source: Live AFK return transcript with endpoint state and return brief

Live AFK return validation
Session: fm-lab-afk-return-r3-45092-8421 (isolated named Herdr lab; torn down after capture)

REAL AWAY ENTRY COMMAND
FM_HOME=<isolated-home> FM_STATE_OVERRIDE=<isolated-home>/state bin/fm-afk-launch.sh enter --words 'all no-mistakes workflow changes should merge and complete'
Away posture recorded at 2026-09-22T18:02:39Z: hold-for-return only. No phone channel is configured; anything that needs you waits for your return. Your away instructions are recorded verbatim; the away session will carry them out where it can, and anything it is unsure of, or that needs you, waits for your return. Destructive, irreversible, and security-sensitive actions are never pre-authorizable, whatever the words say. Expected return: not given. Spend cap: 4 concurrent workers.
Away posture (recorded):
  entered: 2026-09-22T18:02:39Z
  expected return: not given
  spend cap: 4 concurrent workers
  reach: hold-for-return only. No phone channel is configured; anything that needs you waits for your return.
  your words (verbatim):
    all no-mistakes workflow changes should merge and complete

LIVE WORKER ENDPOINTS BEFORE RETURN
landed-live pane=w1:p1 process={"shell_pid":45254,"foreground_processes":[{"argv":["/nix/store/s0psayl7zvkvwdcqc8fy1sbv8rlf1yq8-bash-5.3p9/bin/bash","-e","/etc/profiles/per-user/kunchen/bin/manpath"],"argv0":"bash","cmdline":"/nix/store/s0psayl7zvkvwdcqc8fy1sbv8rlf1yq8-bash-5.3p9/bin/bash -e /etc/profiles/per-user/kunchen/bin/manpath","cwd":"~/.no-mistakes/worktrees/016d88035d58/01M351FDMW4618QZPN0N9NYHYV","name":"bash","pid":46259},{"argv":["-zsh"],"argv0":"zsh","cmdline":"-zsh","cwd":"~/.no-mistakes/worktrees/016d88035d58/01M351FDMW4618QZPN0N9NYHYV","name":"zsh","pid":45254}]}
unproved-live pane=w2:p1 process={"shell_pid":45295,"foreground_processes":[{"argv":["-zsh"],"argv0":"zsh","cmdline":"-zsh","cwd":"~/.no-mistakes/worktrees/016d88035d58/01M351FDMW4618QZPN0N9NYHYV","name":"zsh","pid":46304},{"argv":["-zsh"],"argv0":"zsh","cmdline":"-zsh","cwd":"~/.no-mistakes/worktrees/016d88035d58/01M351FDMW4618QZPN0N9NYHYV","name":"zsh","pid":45295}]}

REAL RETURN COMMAND (exit=0)
FM_HOME=<isolated-home> FM_STATE_OVERRIDE=<isolated-home>/state FM_DATA_OVERRIDE=<isolated-home>/data bin/fm-afk-return.sh
fm-afk-launch: away-posture record archived at ~/.no-mistakes/worktrees/016d88035d58/01M351FDMW4618QZPN0N9NYHYV/.live-afk-return-validation/home/state/afk-contracts/1790100159.afk-contract
fm-afk-launch: away mode stopped; no daemon terminal was running, .afk cleared, and the posture record archived
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  2 task(s) in flight, but no live watcher process holds this home lock (last beat: 2s ago).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  repair a missing or failed watcher cycle with the Pi tool fm_watch_arm_pi, or restart Pi with -e ~/.no-mistakes/worktrees/016d88035d58/01M351FDMW4618QZPN0N9NYHYV/.pi/extensions/fm-primary-turnend-guard.ts -e ~/.no-mistakes/worktrees/016d88035d58/01M351FDMW4618QZPN0N9NYHYV/.pi/extensions/fm-primary-pi-watch.ts if the extensions are not loaded.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
=== Return brief (away 2026-09-22T18:02:39Z -> 2026-09-22T18:02:42Z, 3s) ===
Supervisor health:
  - supervision ran through the away window with no detected gap (watcher beat 0s old at return)
Your instructions:
  your words at entry:
    all no-mistakes workflow changes should merge and complete
  the away session took no action under them.
Waiting on you:
  (nothing)
Tried and failed, or could not be fixed:
  (nothing)
Landed, cleanup due:
  - landed-live: https://github.com/example/landed/pull/7 is merged and the worker is still up; close it with bin/fm-teardown.sh landed-live once catch-up clears
Handled while away:
  0 outcome(s) handled by the away session (0 routine, 0 escalated above)
  (no routine outcomes recorded in the store for this window)
Cost: 0 supervision outcome(s) recorded (0 routine, 0 captain); 2 task(s) live at return.
catch-up health: supervision ran through the away window with no detected gap (watcher beat 0s old at return)
catch-up wake: STATUS OUTCOME BACKSTOP (newest captain-facing task event has no covering branch outcome):
catch-up wake: landed-live done [at=1]: PR https://github.com/example/landed/pull/7
catch-up wake: unproved-live done [at=1]: PR https://github.com/example/open/pull/8
fm-afk-return: catch-up clear; ordinary captain work may proceed

LIVE WORKER ENDPOINTS AFTER RETURN BRIEF
landed-live pane=w1:p1 process={"shell_pid":45254,"foreground_processes":[{"argv":["-zsh"],"argv0":"zsh","cmdline":"-zsh","cwd":"~/.no-mistakes/worktrees/016d88035d58/01M351FDMW4618QZPN0N9NYHYV","name":"zsh","pid":45254}]}
unproved-live pane=w2:p1 process={"shell_pid":45295,"foreground_processes":[{"argv":["-zsh"],"argv0":"zsh","cmdline":"-zsh","cwd":"~/.no-mistakes/worktrees/016d88035d58/01M351FDMW4618QZPN0N9NYHYV","name":"zsh","pid":45295}]}

ASSERTIONS
PASS: durably merge-marked live worker appears under Landed, cleanup due.
PASS: done live worker without durable merge evidence is absent from that section.
PASS: return catch-up cleared and both Herdr worker endpoints remained live for ordinary teardown.
- Outcome: 🔧 1 issue found → no changes applied (2) ✅ across 3 runs (42m38s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

🔧 **Test** - 1 issue found → no changes applied (2) ✅
  • ⚠️ live validation verdict: inconclusive (2 of 4 scenarios were driven live against the product); untested: Supervision handles merge-landed wakes as finished lifecycle work instead of reporting nothing to recover, Supervision cannot force teardown when ordinary landed-work proof refuses cleanup
  • Live validation: ⚠️ inconclusive - 2 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Captain returns while a merged PR worker is still live and receives an explicit cleanup-due entry ✅ pass live Live Herdr return transcript shows the landed worker endpoint alive and the return brief instructing bin/fm-teardown.sh landed before catch-up clears.
A merely done worker without durable merge evidence is not misclassified as landed ✅ pass live Live Herdr return transcript shows both endpoints alive but lists only the merge-marked landed worker, not the open control worker.
Supervision handles merge-landed wakes as finished lifecycle work instead of reporting nothing to recover ⏸️ untested no The prior payload established this only through generated protocol inspection and an automated test; it did not drive the scenario against the live product.
Supervision cannot force teardown when ordinary landed-work proof refuses cleanup ⏸️ untested no The prior payload established this only through an automated test; it did not drive the refusal behavior against the live product.
  • bin/fm-test-run.sh tests/fm-afk-return.test.sh tests/fm-branch-supervision.test.sh
  • Isolated Herdr 0.9.0 lab via bin/fm-herdr-lab.sh provision/run/teardown: created two live workers, marked one PR merged, entered away posture, and ran bin/fm-afk-return.sh begin
  • bin/fm-branch-prompt.sh runtime protocol generation, extracting the landed-worker lifecycle instructions
  • Verified the worktree was clean after removing transient live-test data

🔧 No changes applied.
1 warning still open:

  • ⚠️ live validation verdict: inconclusive (2 of 4 scenarios were driven live against the product); untested: Returning from away mode lists durably merged work whose worker is still running as cleanup due, Return handling does not classify a done worker as landed without durable merge evidence
  • Live validation: ⚠️ inconclusive - 2 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Supervision receives a merge-landed wake and closes the finished worker instead of reporting nothing to recover ✅ pass live live-supervision-summary.txt shows the durable merge-landed wake, successful ordinary teardown landed-live complete, and confirmation that both the task record and exact Herdr pane were removed.
Supervision cannot force cleanup when ordinary landed-work proof refuses an apparently landed task with uncommitted work ✅ pass live live-supervision-summary.txt records the exact uncommitted-work refusal and confirms the task record, Herdr pane, and dirty file all remained.
Returning from away mode lists durably merged work whose worker is still running as cleanup due ⏸️ untested no The prior payload established this only through the automated fm-afk-return test, not by driving an actual away-and-return flow against the live product. A live Firstmate away/return session with a…
Return handling does not classify a done worker as landed without durable merge evidence ⏸️ untested no The prior payload established this only through the automated fm-afk-return test, not by driving an actual return flow against the live product. A live Firstmate away/return session with a done but…
  • bin/fm-test-run.sh tests/fm-afk-return.test.sh tests/fm-branch-supervision.test.sh
  • ~/.no-mistakes/evidence/01M351FDMW4618QZPN0N9NYHYV/live-supervision-scenarios.sh
  • Extracted wake, teardown, refusal, state-check, and version evidence into live-supervision-summary.txt using jq, grep, and the scenario assertions.

🔧 No changes applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 2 of 2 scenarios driven live against the product
Scenario Result Live Evidence
Returning from away mode lists durably merged work whose worker endpoint is still running as cleanup due ✅ pass live The live transcript shows landed-live as a running Herdr pane before return and under Landed, cleanup due in the real return brief.
Return handling does not classify a done worker as landed without durable merge evidence ✅ pass live The live transcript shows unproved-live as a running Herdr pane with done status, while the real return brief omits it from Landed, cleanup due.
  • Provisioned, drove, and tore down an isolated named Herdr session through bin/fm-herdr-lab.sh provision|run|teardown.
  • Ran real away entry with isolated FM_HOME: bin/fm-afk-launch.sh enter --words &#39;all no-mistakes workflow changes should merge and complete&#39;.
  • Ran the real return path with isolated state/data: bin/fm-afk-return.sh.
  • Verified both recorded Herdr endpoints were live before and after return using pane process-info --pane &lt;id&gt;.
  • Ran targeted regression test tests/fm-afk-return.test.sh.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…turn

During the 2026-09-22 away window every exemption worker whose pull request
had merged was left sitting for nine hours. The supervision branch received
the stale wake, the merge-landed check, and the hourly inactive-outcome row
for each of them, ran the recovery playbook, found nothing to recover, and
reported "no further action". The branch prompt granted ordinary teardown of
a confirmed-landed task without ever naming the moment or the command, and
the playbook has no landed exit, so the stale path ended at "nothing to
recover". The return brief then listed only blockers, decisions, and the
latest five routine outcomes, so the landed workers stayed invisible after
the captain came back.

- bin/fm-branch-prompt.sh: name the merge-landed wake, and any later stale,
  inactive-outcome, or heartbeat row on a done task with a merged PR, as the
  moment to claim the lease and run bin/fm-teardown.sh with no flags; a
  refusal is reported, never forced or worked around. Add teardown to the
  handling tool list.
- stuck-crewmate-recovery: a landed worker is not a recovery case; point at
  the ordinary teardown owner for each actor.
- bin/fm-afk-return.sh: render a "Landed, cleanup due" section from durable
  records only (a live task record whose recorded PR carries the
  merge-notification marker), between could-not-fix and handled, without
  holding the gate; the afk skill's return step closes each listed task
  through ordinary teardown once the check clears.
- tests: pin the prompt rule in fm-branch-supervision and the brief section
  in fm-afk-return through the real marker writer.
@kunchenguid
kunchenguid merged commit ada21f5 into main Sep 22, 2026
19 checks passed
@kunchenguid
kunchenguid deleted the fm/fm-afk-landed-teardown-gap-r1 branch September 22, 2026 19:02