Skip to content

feat: merge upstream first-parent commits through ac0811c (batch 1 of 4) - #173

Merged
sKeLe100 merged 26 commits into
mainfrom
fm/upstream-sync-batch1
Oct 12, 2026
Merged

sKeLe100 merged 26 commits into
mainfrom
fm/upstream-sync-batch1

Conversation

@sKeLe100

@sKeLe100 sKeLe100 commented Oct 12, 2026 •

Copy link
Copy Markdown
Owner

Intent

Bring this fork up to date with upstream in smaller batches. The captain ruled smaller batches on 2026-10-12 after a single large merge failed validation. This task is Batch 1 of 4: true-merge upstream first-parent commits up to and including ac0811c (18 commits), validate, and ship one PR. The captain merges it, not you. Supervision-safety conflicts (bin/fm-classify-lib.sh, bin/fm-teardown.sh, bin/fm-wake-lib.sh, bin/fm-watch.sh) stop for a three-way summary to firstmate rather than being resolved on your own judgment.

What Changed

  • Merges upstream first-parent commits up to and including ac0811c4c820d82009d7a3b8f09555cbf38340c8 (batch 1 of 4). It adds the new helpers bin/fm-pipeline-spend.sh, bin/fm-project-capacity-lib.sh, bin/fm-startup-growth-check.sh and bin/fm-exclude-tools-lib.sh. Teardown now integrates pipeline spend.
  • Updates existing scripts to match: fm-spawn.sh, fm-control.sh, fm-teardown.sh, fm-brief.sh, fm-dod-lib.sh, fm-wake-lib.sh, fm-watch.sh, fm-contributions.sh, fm-composer-lib.sh, fm-timeout-lib.sh, the herdr/tmux backends and the remote-reply and pending-reply paths. Also updates the Pi calm extension and the agent skill docs.
  • Updates the docs (configuration.md, herdr-backend.md, scripts.md, runtime-backends.md and others). Adds new tests for pipeline spend, project capacity and startup growth, and extends the existing tests, including the merge-conflict fixtures for capacity and recovery.

Risk Assessment

Medium: this batch changes orchestration behavior across a true merge of 18 upstream first-parent commits. The supervision-safety resolutions were escalated and explicitly approved before reuse, as recorded below. The configured Test command failed; the disclosed exception rests on nine passing isolated reruns and five already tracked quarantines. The required manual full-suite attempts remain incomplete.

Integration dispositions and validation limits

Pipeline-added documentation commit

The Document step added cec25fe30f662e1d04b909334562a8d601a176b7, which inserts the two missing fm-project-capacity-lib.sh and fm-exclude-tools-lib.sh rows in docs/scripts.md. This is a pipeline-added docs commit outside the merge-plus-labeled-resolution set. Firstmate explicitly accepted it on 2026-10-12 as the smallest downstream correction needed to keep the inventory accurate for the merged scripts. No production regression or pre-existing-failure fix was added.

Supervision-safety

Conflicts in bin/fm-watch.sh, bin/fm-teardown.sh, and bin/fm-spawn.sh were each escalated to firstmate with a three-way summary before resolution.
On 2026-10-12, the captain explicitly approved reusing the recorded 8ceb969c9 resolutions for all three, including the watcher change that preserves the idle-clock seed across a failed capture.
bin/fm-classify-lib.sh and bin/fm-wake-lib.sh had no escalated true conflicts in this batch.
The review finding about commit a37b82cb was dismissed under that existing approval; no additional code change was made.

Validation and limitations

Focused validation passed 24 subjects initially. The two fixture mismatches were reconciled in the labeled conflict-resolution commit 0674e4b1f; both complete subject reruns passed at that head. Lint and documentation-audience checks also passed.

The required full command, bin/fm-test-run.sh --all --exclude-quarantined --pc02-if-idle, was attempted with explicit bounds but did not complete green. The PC02 attempt stopped at the guarded Herdr lab precondition because that host has no running default session. The local attempt passed the corresponding AFK Herdr injection subject, then failed the presentation test at the duplicate-token registered-agent fallback assertion after 722438 ms. That same presentation subject passed in isolation at the submitted head. The full-run failure remains unconfirmed and potentially load-sensitive; it is not reported as passing or as a proven pre-existing failure. Both full attempts were stopped after supervisor disposition, and further manual full-suite retries were explicitly disallowed.

The separately bounded watcher-triage subject reached its 1500-second deadline after 137 passing assertions, including idle-seed preservation across failed capture. The supervisor accepted this specific known slow-subject timeout. No production regression or pre-existing-failure fixes were added to this integration.

The pipeline Test result is recorded separately; the statements above describe the manual evidence and its limits.

All 16 tracked quarantine exclusions reported by the manual full run
FM_TEST_QUARANTINED tests/fm-agy-harness.test.sh signature=a zero model bound disabled the deadline reason=load-flaky timing test: "a zero model bound disabled the deadline (took 25s)" under full-suite load (load5 ~10), passes in isolation (exit=0). Pre-existing on main: data/upstream-sync/triage.md Run 6 owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-backend-herdr.test.sh signature=coreutils: unknown program 'pi' reason=uutils multicall coreutils rejects the agent-named `pi` fake descendant process, so the "live agent-named descendant" assertions read the host as unreadable. Pre-existing on main: data/upstream-sync/triage.md row 5; data/upstream-sync-failure-deep-review/report.md defect 1; PR https://github.com/sKeLe100/firstmate/pull/136 owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-calm-pi-extension.test.sh signature=Chrome or Chromium is required for rendered export DOM assertions reason=Chrome/Chromium is absent from the validation host PATH, so the rendered-export DOM guard fails. Pre-existing on main: data/upstream-sync/triage.md row 7; data/upstream-sync-failure-deep-review/report.md defect 2 owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-composer-codex-idle-live-e2e.test.sh signature=idle screen never classified empty reason=environmental: local codex-cli is 0.155.1, whose idle screen is not classified empty by the detection built for 0.154 (upstream #4532). Pre-existing on main: data/upstream-sync/triage.md Run 3/4/5 owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-procevent-quota.test.sh signature=provider retire targeted the wrong source reason=host-sensitive private-state admission refuses the temporary process-event state root; identical full-script failure on merged, immutable fork base 42a39f46620c95ce7dcd79884bb6b961a6ca7adf and pure upstream f470a01c098c1536d83b802874bd954a2c04b506 on PC02. Evidence: docs/upstream-sync-quarantine-evidence.json owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-procevent.test.sh signature=the listener under test was not reparented away from its session reason=listener reparenting timing flake: the test observes a non-1 ppid under systemd --user subreaper adoption. Pre-existing on main: data/upstream-sync/triage.md row 8; data/upstream-sync-failure-deep-review/report.md defect 3; PR https://github.com/sKeLe100/firstmate/pull/136 owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-public-followup.test.sh signature=a wake whose line could not be written must stay queued reason=host-sensitive unwritable-stdout wake retention: new upstream case fails identically on merged and pure upstream f470a01c098c1536d83b802874bd954a2c04b506 on PC02; immutable fork base 42a39f46620c95ce7dcd79884bb6b961a6ca7adf passes and lacks this case. Firstmate ruling 017 authorizes exclusion. Evidence: docs/upstream-sync-quarantine-evidence.json owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-remote-secondmate-lifecycle-e2e.test.sh signature=remote spawn never reached its blocked inheritance write reason=pre-existing hang: the "remote-reply-ios" terminal-source retire loop never resolves, so the e2e hangs in isolation. Pre-existing on main: data/upstream-sync/triage.md Run 3/4/5 owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-remote-transport-lanes.test.sh signature=concurrent sequence claims were not unique and monotonic reason=concurrency-flaky secondmate test: concurrent sequence claims produce a duplicate value intermittently, even in isolation. Pre-existing on main: data/upstream-sync/triage.md Run 3/5 owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-secondmate-harness.test.sh signature=first config push did not reach pointer delivery reason=load-flaky secondmate test: "first config push did not reach pointer delivery" under full-suite load, passes in isolation (exit=0). Pre-existing on main: data/upstream-sync/triage.md Run 3/5 owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-session-lock-ancestry.test.sh signature=the pty-host was not reparented to init after the daemon ended reason=host-sensitive orphan reparenting: new upstream e2e test_e2e_background_session_keeps_its_lock_across_a_recycled_chain (batch 2, upstream #4894) asserts an orphaned pty-host gets ppid 1, but this host runs systemd --user as a child subreaper, so the orphan is adopted by it instead of init (same class as the fm-procevent entry). Fails identically on pure upstream b8ab7354 on this host; every other case in the script passes. Recorded in data/upstream-sync-b2/triage.md owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-supervision-host.test.sh signature=a routine outcome a drain could not print must follow on the next drain reason=host-sensitive closed-stdout outcome retention: complete script fails identically on merged and pure upstream f470a01c098c1536d83b802874bd954a2c04b506 on PC02; immutable fork base 42a39f46620c95ce7dcd79884bb6b961a6ca7adf has no test. Test and supervision-host owner equal upstream; Firstmate standing ruling 017 authorizes exclusion. Evidence: docs/upstream-sync-quarantine-evidence.json owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-task-delivery.test.sh signature=a ref-format-valid metacharacter prefix should promote safely reason=host-sensitive promotion shell-safety fixture: complete script fails identically on merged and pure upstream f470a01c098c1536d83b802874bd954a2c04b506 on PC02 with private disk TMPDIR; immutable fork base 42a39f46620c95ce7dcd79884bb6b961a6ca7adf passes and lacks the failing case. Promotion owner equals upstream; Firstmate standing ruling 017 authorizes exclusion. Evidence: docs/upstream-sync-quarantine-evidence.json owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-wake-pair-dedup.test.sh signature=no process-event result reason=host-sensitive process-event runner identity confirmation (systemd subreaper reparenting); the fixture registers/reconciles a source through bin/fm-procevent.sh, whose "cannot confirm runner identity" refusal surfaces here as a captured-result miss. Pre-existing on main: data/upstream-sync/triage.md row 6 (base 12901276) owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-wake-queue.test.sh signature=a foreign queue with no progress did not alert reason=load-flaky watcher-wake-lock test: "a foreign queue with no progress did not alert: check: rearm-resurface" under full-suite load, passes in isolation (exit=0). Pre-existing on main: data/upstream-sync/triage.md Run 3/5 owner=sync-preexisting-test-failures
FM_TEST_QUARANTINED tests/fm-watch-triage.test.sh signature=exceeded the per-script bound reason=host-load-sensitive suite exceeds the 900s per-script bound under full-suite load (passes alone at ~924s). Pre-existing on main: data/upstream-sync/triage.md row 4; PR https://github.com/sKeLe100/firstmate/pull/136 owner=sync-preexisting-test-failures
FM_TEST_QUARANTINE_SUMMARY quarantined=16

Pipeline Test exception and isolated triage

Run: 01M4RKP8BSTZ5THK6VZ23PWQTY; branch: fm/upstream-sync-batch1; submitted, pipeline, and isolated-rerun head: 0674e4b1f6686fba92fb82828e422b775c94691d.

The configured command, bin/fm-test-run.sh --changed --exclude-family real-herdr-gated --pc02-if-idle, returned exit 1: 215 subjects, 14 failures, 31 gate skips, 9989516 ms. It fell back from PC02 to PC01 because the pipeline mirror lacks the lane state directory. The configured command did not exclude tracked quarantines; five of its failing subjects are already in tests/fm-test-quarantine.tsv.

Firstmate reported that an unrelated CPU job heavily loaded PC01 during that run and had since been stopped. Under instruction 013, the nine non-quarantined failures were each rerun exactly once, serially, at the unchanged submitted head, using bin/fm-test-run.sh --jobs 1 --per-script-timeout-secs 1500 --json <artifact> tests/<subject>.test.sh. No subject was gate-skipped. A passing isolated rerun is classified as a load flake under that instruction; this does not establish a production cause.

Test Original pipeline command Isolated post-merge result Pre-merge result (0ab2bfddb) Disposition
fm-watch-checkpoint.test.sh Exit 1; 1253 ms Exit 0; 15549 ms Not needed: isolated head passes Load flake (passed in isolation)
fm-turnend-foreign-owner-arm-fix.test.sh Exit 1; 23875 ms Exit 0; 7837 ms Not needed: isolated head passes Load flake (passed in isolation)
fm-watch-triage.test.sh Exit 124; 1500240 ms Not rerun (tracked quarantine) Not rerun (tracked quarantine) Tracked quarantine
fm-remote-secondmate-lifecycle-e2e.test.sh Exit 1; 295227 ms Not rerun (tracked quarantine) Not rerun (tracked quarantine) Tracked quarantine
fm-remote-transport-lanes.test.sh Exit 1; 545 ms Not rerun (tracked quarantine) Not rerun (tracked quarantine) Tracked quarantine
fm-startup-network.test.sh Exit 1; 60670 ms Exit 0; 113455 ms Not needed: isolated head passes Load flake (passed in isolation)
fm-backlog-atomicity.test.sh Exit 1; 444547 ms Exit 0; 326189 ms Not needed: isolated head passes Load flake (passed in isolation)
fm-spawn-pool-base-freshen.test.sh Exit 1; 13331 ms Exit 0; 119362 ms Not needed: isolated head passes Load flake (passed in isolation)
fm-pi-branch-extension.test.sh Exit 1; 37107 ms Exit 0; 120764 ms Not needed: isolated head passes Load flake (passed in isolation)
fm-extension-binding.test.sh Exit 1; 35180 ms Exit 0; 11943 ms Not needed: isolated head passes Load flake (passed in isolation)
fm-procevent.test.sh Exit 1; 574818 ms Not rerun (tracked quarantine) Not rerun (tracked quarantine) Tracked quarantine
fm-contributions.test.sh Exit 1; 309242 ms Exit 0; 184234 ms Not needed: isolated head passes Load flake (passed in isolation)
fm-fleet-snapshot-view.test.sh Exit 1; 287594 ms Exit 0; 113052 ms Not needed: isolated head passes Load flake (passed in isolation)
fm-supervision-host.test.sh Exit 1; 79426 ms Not rerun (tracked quarantine) Not rerun (tracked quarantine) Tracked quarantine

All nine non-quarantined subjects passed in isolation. No pre-merge checkout or reproduction was needed. There were no code changes or fix rounds. Firstmate instruction 013 authorizes proceeding through the Test gate with this evidence disclosed as a Test exception, not a green configured command.

The repeated test-3 ask-user finding concerns the same idle-seed resolution as Review finding review-1. Firstmate instruction 013 confirms the existing 2026-10-12 approval to reuse the recorded 8ceb969c9 resolution. No code change was made for either finding.

The manual full-run Herdr presentation failure remains unconfirmed, as separately recorded; this isolated triage did not rerun that subject or either full suite.

Evidence in this directory: batch1-nm-test-progress.log, batch1-nm-command-summary.txt, batch1-nm-test-gate-status.txt, batch1-isolated-rerun.log, and the batch1-isolated-head-<subject>.log/.json/.exit artifacts. The five tracked quarantine reasons, plus all 16 exclusions reported by the manual full run, are preserved in batch1-pr-validation-appendix.md.

Testing (original pipeline agent evidence)

I did not rerun the configured changed-test command (exit 1), because the full-suite boundary applies and the author's plan says manual full suites are stopped. I ran nine targeted seam suites covering wake-queue, classify, teardown, tmux-submit and watcher recovery, retry and checkpoint. All 267 assertions passed except one watch-checkpoint assertion under concurrent load. That test then passed twice in isolation. I did not run the slow fm-watch-triage suite or the Herdr lab scenarios. The author already disclosed those and the earlier incomplete full runs.

  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Wake-queue, classify and tmux-submit seams behave after the upstream merge ✅ pass live targeted.log
Teardown refuses or completes correctly across endpoint, pool-slot and force cases ✅ pass live targeted.log
Watcher recovery and retry-band suites pass after the merge ✅ pass live targeted.log
Watch lock pid survives the quiet checkpoint timeout ✅ pass live rerun1.log, rerun2.log (failed once under concurrent load in targeted.log, passed twice in isolation)
Idle seed preserved across a failed first capture (a37b82c) in the fm-watch-triage suite ⏸️ untested no fm-watch-triage is known-slow; the author's plan records it hit the 1500s bound and supervisor rulings 008/009 accept that. I did not rerun it in this targeted step. Whether the a37b82c ordering chan…
Real-Herdr lab scenarios ⏸️ untested no The author's plan reports guarded local Herdr runs already done and a PC02 attempt that stopped because PC02 has no running default Herdr session. I did not drive a Herdr lab here.
Evidence: targeted seam run log

Source: targeted seam run log

FM_TEST_HOST_LOAD load5=4.45 cpus=16 jobs=4 per_script_timeout_secs=0 watch_triage_timeout_secs=0 captain_hold_timeout_secs=0
FM_TEST_BEGIN 2026-10-12T20:40:30Z tests/fm-tmux-submit-busy.test.sh family=pure-contract-unit expected_gate_skip=none
ok - fm_tmux_submit_enter_core: busy pane + pending composer returns empty (message queued)
ok - fm_tmux_submit_enter_core: idle pane + pending composer stays pending (genuine swallow preserved)
ok - fm_tmux_submit_enter_core: the Claude background-task exit picker gets no confirming Enter
ok - fm_backend_send_text_submit: a typed message to the exit picker types nothing and sends no Enter
ok - fm_tmux_submit_enter_core: wrapped input retains swallowed-Enter retries
ok - fm_tmux_submit_enter_core: placeholder-like bare input retains swallowed-Enter retries
ok - fm_tmux_submit_enter_core: busy pane clears composer on first Enter - returns empty
ok - fm_tmux_submit_enter_core: idle pane clears composer on first Enter - returns empty as before
ok - fm_tmux_submit_enter_core: busy conversion is limited to proven pending input
ok - fm_tmux_submit_core: failed baseline capture disables busy unknown conversion
ok - fm_tmux_submit_enter_core: pending-unproven retries without busy conversion
ok - fm_tmux_submit_enter_core: unrecognized states skip busy conversion
ok - fm_pane_is_busy: Claude spinner is scoped, multi-frame, and backward-compatible
FM_TEST_END 2026-10-12T20:40:33Z tests/fm-tmux-submit-busy.test.sh exit=0 duration_ms=3224 gate_skip=false
FM_TEST_BEGIN 2026-10-12T20:40:33Z tests/fm-wake-queue.test.sh family=watcher-wake-lock expected_gate_skip=none
FM_TEST_BEGIN 2026-10-12T20:40:33Z tests/fm-watch-recovery-loop.test.sh family=watcher-wake-lock expected_gate_skip=none
FM_TEST_BEGIN 2026-10-12T20:40:33Z tests/fm-watch-checkpoint.test.sh family=watcher-wake-lock expected_gate_skip=none
FM_TEST_BEGIN 2026-10-12T20:40:33Z tests/fm-watch-retry-band.test.sh family=watcher-wake-lock expected_gate_skip=none
not ok - watch lock pid survived quiet checkpoint timeout
FM_TEST_END 2026-10-12T20:40:34Z tests/fm-watch-checkpoint.test.sh exit=1 duration_ms=1134 gate_skip=false
ok - a halt-band task makes an otherwise-quiet heartbeat actionable and is named in the reason
ok - an undrained halt survives a later heartbeat that takes no retry read
ok - an unchanged halt reading stays silent; only a new reading re-surfaces
ok - a non-halt retry band leaves the no-change heartbeat absorbed as before
# all fm-watch-retry-band tests passed
FM_TEST_END 2026-10-12T20:40:45Z tests/fm-watch-retry-band.test.sh exit=0 duration_ms=12013 gate_skip=false
ok - a resurfacing handling successor stays alive and supervises instead of going blind
ok - unacknowledged recovery is announced at most once per generation and the successor stays alive
ok - an undrainable queued wake resurfaces a bounded number of times, escalates once, then stays quiet and live
ok - an acknowledgement, a new wake, or a session restart restores ordinary resurface delivery, but a presentation-only drain does not
FM_TEST_END 2026-10-12T20:41:52Z tests/fm-watch-recovery-loop.test.sh exit=0 duration_ms=79132 gate_skip=false
ok - an abandoned same-process lock hold is reclaimed; a parent's live hold is not
ok - without BASHPID a subshell cannot release or reclaim its parent lock and owns its own hold
ok - bounded acquire hands ownership to the waiting caller after contention
ok - presentation lock waits are bounded and retriable without weakening acknowledgement atomicity
ok - malformed presentation locks report acquire failure instead of contention
tests/wake-helpers.sh: line 319: 2762604 Killed                     PATH="$dir/fakebin:$PATH" FM_FAKE_NOW_FILE="$dir/now" FM_HOME="$dir" FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$dir/state" FM_FAKE_TMUX_WINDOW='firstmate:fm-mate' FM_SECONDMATE_WAKE_STALL_SECS=1 FM_SECONDMATE_LIVENESS_SECS=99999999 FM_POLL=1 FM_SIGNAL_GRACE=0 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 "$WATCH" > "$dir/watch-$leg.out" 2> "$dir/watch-$leg.err"
tests/wake-helpers.sh: line 319: 2763259 Killed                     PATH="$dir/fakebin:$PATH" FM_FAKE_NOW_FILE="$dir/now" FM_HOME="$dir" FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$dir/state" FM_FAKE_TMUX_WINDOW='firstmate:fm-mate' FM_SECONDMATE_WAKE_STALL_SECS=1 FM_SECONDMATE_LIVENESS_SECS=99999999 FM_POLL=1 FM_SIGNAL_GRACE=0 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 "$WATCH" > "$dir/watch-$leg.out" 2> "$dir/watch-$leg.err"
tests/wake-helpers.sh: line 319: 2765487 Killed                     PATH="$dir/fakebin:$PATH" FM_FAKE_NOW_FILE="$dir/now" FM_HOME="$dir" FM_ROOT_OVERRIDE="$ROOT" FM_STATE_OVERRIDE="$dir/state" FM_FAKE_TMUX_WINDOW='firstmate:fm-mate' FM_SECONDMATE_WAKE_STALL_SECS=1 FM_SECONDMATE_LIVENESS_SECS=99999999 FM_POLL=1 FM_SIGNAL_GRACE=0 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 "$WATCH" > "$dir/watch-$leg.out" 2> "$dir/watch-$leg.err"
ok - foreign secondmate queue alerts once per no-progress episode without age-only or cascade noise
ok - declared external-wait pause rows do not feed secondmate wake-loop escalation
ok - a reprovisioned queue generation starts a fresh no-progress interval
ok - an active turn defers the secondmate stall escalation without cancelling it
ok - a long-lived mate mid-turn is not a stall, but a queue frozen past the busy bound still alarms
ok - a proven-idle leftover row is rung so the child home can drain without a parent alarm
ok - TERM stops a watcher blocked in the drain-ring idle capture and runs its cleanup
ok - busy panes defer without a ring and unknown panes keep the parent alarm
ok - a leftover row that survives a proven-idle ring still surfaces as a genuine stall
ok - secondmate stall markers reject symlinks without touching their targets
ok - stall publication acknowledgement closes the pre-marker crash window
ok - empty prefix mate cleanup preserves another mate's stall receipt
ok - self-announced appends suppress only their own bytes and fail toward waking
ok - separate self-announced answers after a fold stay owned; worker decisions and later lines still wake
ok - an unreadable status still reads as unreported, with or without owned growth
ok - a worker resolved in fold lag still wakes after this home's close
ok - owned growth suppresses the wake without hiding the turn-ended annotation
ok - historical annotations replay nothing already announced and keep everything new
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 33 --recovery-generation 2804181.1791837699.toCKKL
ok - concurrent append plus drain preserves durable records through acknowledgement
ok - signal written while no watcher runs is caught on next run
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 2839913.1791837719.OboFDd
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
ok - stale wake is queued before suppressor state is advanced
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 2841939.1791837723.pp7kTg
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
ok - a not-provably-working stale wake is queued before its suppressor is advanced
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 2844007.1791837725.Fc9YI9
WARNING: queued wakes pending - drain them with bin/fm-wake-drain.sh before anything else.
ok - registered custom check output is queued before cadence suppression
ok - concurrent drains replay until one post-handling acknowledgement consumes records
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 4 --recovery-generation 2847221.1791837729.IiCbRJ
ok - drain collapses obvious duplicate heartbeat and signal records
ok - drain asserts watcher liveness: warns on a lapse, stays silent for a live watcher with a fresh beacon
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 8 --recovery-generation 2849249.1791837733.83U4Yc
ok - structural signal enrichment is separate, deduped, home-local, and tier-zero for other wakes


... [13605 bytes truncated] ...

- a parked run the pipeline advanced past the task copy is still concluded from the runs ledger, not orphaned
ok - a ledger row for a different head never authorizes a parked-run abort
ok - a malformed ledger row never authorizes a parked-run abort
ok - an impossible ledger date never authorizes a parked-run abort
ok - a terminal status with a stale gate never reaches ledger cleanup
ok - an advanced head present locally aborts through the strict rule alone - the ledger fallback stays dormant
ok - an unresolvable active row with no same-branch anchor is never concluded (conservative refusal)
ok - an ancestor-only anchor never binds an advanced parked run to this task
ok - a terminal unfetched-head row is stale history and never concludes a run
ok - a terminal newest row anchored at this worktree's head never authorizes an abort
ok - a resolvable diverged newer same-branch row makes every older row stale history; no run is concluded
ok - consecutive unresolvable rows are ambiguous and never conclude a run
ok - a ledger-proven continuation is still left alone while the run is autonomously active
ok - teardown refuses before reap or removal when a task-owned run remains parked
ok - a different run cannot confirm the targeted abort
ok - empty post-abort status is not accepted as confirmation
ok - the CLI's exact run-not-found signal confirms completion
ok - a parked run on another branch is never aborted by this task's teardown (ownership is precise)
ok - a task-owned autonomous running step is left alone rather than aborted
ok - a leaked descendant process rooted under the task's worktree is reaped by teardown, not left surviving
ok - a leaked descendant process rooted under the task's per-task tasktmp is reaped by teardown too
ok - missing lsof falls back to reaping the tmux pane process group
ok - an erroring lsof scan refuses teardown and preserves the task
ok - a reused pid with a different start time is never force-killed
ok - an exec change preserves birth identity and the process is reaped
ok - a process spawned during grace is reaped on a later pass
ok - persistent leaked processes refuse teardown after bounded retries
ok - a process exiting during identity lookup does not block teardown
ok - the run abort and the leaked-process reap both complete before the destructive worktree return
FM_TEST_END 2026-10-12T20:49:09Z tests/fm-teardown.test.sh exit=0 duration_ms=288387 gate_skip=false
FM_TEST_BEGIN 2026-10-12T20:49:09Z tests/fm-classify-corr-token.test.sh family=standalone expected_gate_skip=none
ok - captain regex overrides preserve timed and legacy relevance and event bytes
ok - malformed event times stay ordinary line bytes without hiding the event
ok - malformed event times never open or close a decision
ok - optional event time preserves parsing and legacy unknown time
ok - a correlation token between the verb and the key breaks neither opening nor closing
ok - the token is read through before the key, after it, doubled, bracketed, and unkeyed
ok - the untokened opener/closer pair behaves exactly as before
ok - prose, malformed, wrong-length and unknown name=value tokens stay non-transitions
ok - a token-first line cannot impersonate any opening or closing verb
ok - untokened captain-relevance, pause, terminal-verb and captain-held verdicts are unchanged
ok - captain-relevance, terminal-verb, pause and captain-held all read through the token
ok - the daemon and crew-state verb case arms read through the token
ok - reading through the token does not weaken the reserved-key namespace rule
ok - the cursor-backed fold and the whole-file fold agree on every correlated transition
ok - a cursor persisted under the previous reading is discarded and refolded
ok - both real correlation-token writers produce lines this classifier reads through
FM_TEST_END 2026-10-12T20:49:48Z tests/fm-classify-corr-token.test.sh exit=0 duration_ms=39738 gate_skip=false
FM_TEST_BEGIN 2026-10-12T20:49:48Z tests/fm-teardown-endpoint-safety.test.sh family=backend-dispatch expected_gate_skip=none
ok - fm-teardown: missing, empty, malformed, ambiguous, and task-mismatched endpoints refuse before every mutation or runtime call
ok - fm-teardown: a concurrent lifecycle action refuses before mutation
ok - fm-teardown: non-pool cleanup ignores unrelated task publication locks
ok - fm-teardown: destructive cleanup serializes with metadata writers
ok - cleanup identity: valid tmux, Herdr, Zellij, Orca, and cmux records validate while every empty backend target refuses
ok - cleanup identity: an Orca record's real composite worktree id validates while a separatorless or newline-carrying id refuses
ok - tmux backend: direct empty target returns nonzero without invoking tmux
ok - process cleanup: creation-time PID identity removes only the exact child and preserves the control child
ok - fm-teardown: exact tmux cleanup preserves invalid and prefix-matched neighbors while removing only the recorded target
ok - fm-teardown: a close that genuinely failed refuses and keeps the record naming the surviving endpoint, and the same teardown finishes once the close works
ok - fm-teardown: --force continues past a close it could not make while still reporting it, and the same case refuses without --force
ok - fm-teardown: a close re-read that could not run refuses, while a definitively absent session or server still completes silently
ok - fm-teardown: forced secondmate cleanup still refuses on a child endpoint close that failed
ok - fm-teardown: an Orca close its missing CLI never attempted refuses even under --force, keeping the record naming the terminal
ok - fm-teardown: an already-exited endpoint, and a server that is already gone, still complete cleanup silently
ok - Treehouse locking resolves a bare local origin against its source project, matching the provisioned clone
ok - fm-teardown: a pool slot named by a second task record is never returned, killed, or reset
ok - fm-teardown: a pool slot held by another firstmate home is never returned
ok - fm-teardown: a task that solely holds its slot still returns it
ok - fm-teardown: a pool slot claimed by another task is left alone while the task's own cleanup finishes
ok - fm-teardown: a stale record on a claimed slot retires, then the claimant tears down
ok - fm-teardown: a task's own slot claim, and an unclaimed slot, both still tear down
ok - fm-teardown: an exact recorded endpoint still tears down after changing cwd outside its worktree
ok - Treehouse project locking anchors at the local root for main-home, local-secondmate, and remote-seeded layouts
ok - fm-teardown: a remote-seeded secondmate home returns its own uncontested pool slot
ok - fm-teardown: slot ownership across a remote-seeded home and its local child still refuses
ok - Treehouse project locking still serializes two homes across the remote-seeded boundary
FM_TEST_END 2026-10-12T20:50:51Z tests/fm-teardown-endpoint-safety.test.sh exit=0 duration_ms=62480 gate_skip=false
FM_TEST_SUMMARY total=9 failed=1 skipped_gate=0 duration_ms=621645
FM_TEST_SUMMARY_FAMILY family=backend-dispatch count=1 duration_ms=62480 failed=0
FM_TEST_SUMMARY_FAMILY family=pr-forge count=1 duration_ms=288387 failed=0
FM_TEST_SUMMARY_FAMILY family=pure-contract-unit count=2 duration_ms=8432 failed=0
FM_TEST_SUMMARY_FAMILY family=standalone count=1 duration_ms=39738 failed=0
FM_TEST_SUMMARY_FAMILY family=watcher-wake-lock count=4 duration_ms=314015 failed=1
FM_TEST_SLOWEST rank=1 script=tests/fm-teardown.test.sh duration_ms=288387
FM_TEST_SLOWEST rank=2 script=tests/fm-wake-queue.test.sh duration_ms=221736
FM_TEST_SLOWEST rank=3 script=tests/fm-watch-recovery-loop.test.sh duration_ms=79132
FM_TEST_SLOWEST rank=4 script=tests/fm-teardown-endpoint-safety.test.sh duration_ms=62480
FM_TEST_SLOWEST rank=5 script=tests/fm-classify-corr-token.test.sh duration_ms=39738
FM_TEST_SLOWEST rank=6 script=tests/fm-watch-retry-band.test.sh duration_ms=12013
FM_TEST_SLOWEST rank=7 script=tests/fm-classify-decision-key.test.sh duration_ms=5208
FM_TEST_SLOWEST rank=8 script=tests/fm-tmux-submit-busy.test.sh duration_ms=3224
FM_TEST_SLOWEST rank=9 script=tests/fm-watch-checkpoint.test.sh duration_ms=1134
exit=1
Evidence: checkpoint isolated rerun 1

Source: checkpoint isolated rerun 1

FM_TEST_HOST_LOAD load5=2.27 cpus=16 jobs=1 per_script_timeout_secs=0 watch_triage_timeout_secs=0 captain_hold_timeout_secs=0
FM_TEST_BEGIN 2026-10-12T20:51:01Z tests/fm-watch-checkpoint.test.sh family=watcher-wake-lock expected_gate_skip=none
ok - quiet checkpoint exits 124 with a clean checkpoint line and no live lock
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 3168321.1791838266.ceKYNC
ok - checkpoint passes through a real watcher wake and leaves the queue for drain
ok - checkpoint preserves watcher environment for registered custom checks
ok - checkpoint rejects an existing watcher singleton as unowned
ok - checkpoint: an opted-in home runs the host for the checkpoint's bound, raised only while away
ok - checkpoint: a handed-back wake passes through, and a host stand-down is a failure
ok - checkpoint: a Codex home without config/supervision-host, or with an off file, never runs the host
ok - checkpoint: the real host ends its park at the checkpoint bound as a quiet checkpoint
FM_TEST_END 2026-10-12T20:51:16Z tests/fm-watch-checkpoint.test.sh exit=0 duration_ms=15214 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=15307
FM_TEST_SUMMARY_FAMILY family=watcher-wake-lock count=1 duration_ms=15214 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-watch-checkpoint.test.sh duration_ms=15214
Evidence: checkpoint isolated rerun 2

Source: checkpoint isolated rerun 2

FM_TEST_HOST_LOAD load5=2.34 cpus=16 jobs=1 per_script_timeout_secs=0 watch_triage_timeout_secs=0 captain_hold_timeout_secs=0
FM_TEST_BEGIN 2026-10-12T20:51:16Z tests/fm-watch-checkpoint.test.sh family=watcher-wake-lock expected_gate_skip=none
ok - quiet checkpoint exits 124 with a clean checkpoint line and no live lock
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 3174126.1791838281.ATWYxL
ok - checkpoint passes through a real watcher wake and leaves the queue for drain
ok - checkpoint preserves watcher environment for registered custom checks
ok - checkpoint rejects an existing watcher singleton as unowned
ok - checkpoint: an opted-in home runs the host for the checkpoint's bound, raised only while away
ok - checkpoint: a handed-back wake passes through, and a host stand-down is a failure
ok - checkpoint: a Codex home without config/supervision-host, or with an off file, never runs the host
ok - checkpoint: the real host ends its park at the checkpoint bound as a quiet checkpoint
FM_TEST_END 2026-10-12T20:51:30Z tests/fm-watch-checkpoint.test.sh exit=0 duration_ms=14019 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=14114
FM_TEST_SUMMARY_FAMILY family=watcher-wake-lock count=1 duration_ms=14019 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-watch-checkpoint.test.sh duration_ms=14019
- Outcome: ⚠️ 3 issues (1 error, 1 warning, 1 info) across 1 run (2h58m39s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped

Step was skipped.

⚠️ **Review** - 1 warning
  • ⚠️ bin/fm-watch.sh:3797 - Commit a37b82c ('merge conflict resolution: preserve idle seed across capture failure') edits bin/fm-watch.sh, a named supervision-safety file, on the implementer's own judgment. The intent says conflicts in bin/fm-classify-lib.sh, fm-teardown.sh, fm-wake-lib.sh and fm-watch.sh 'stop for a three-way summary to firstmate rather than being resolved on your own judgment'. The hunk moves first_seen=1; wedge_seed_first_observation &#34;$key&#34; &#34;$task&#34; &amp;&amp; first_seen=0 from before watcher_capture ... || continue to after it (bin/fm-watch.sh ~3797-3800). The seed call is fork-only (upstream ac0811c has no wedge_seed_first_observation). So the hunk is a fork-side behavior change in the watch loop, not an upstream change. Concrete effect: when the first capture of a window fails, the seed is no longer written that cycle and first_seen stays pending. Whether that is correct is a supervision-safety decision. Nothing in the diff shows firstmate's three-way disposition. The merge commit 8356208 also touches fm-classify-lib.sh, fm-teardown.sh, fm-wake-lib.sh and fm-watch.sh, and the PR notes should state whether any of those had true conflicts that were escalated. Supervisor rulings 008/009 accept only the watcher timeout, not this resolution. Remedy: get firstmate's disposition on a37b82c, or revert it to the upstream/fork-original ordering.
⚠️ **Test** - 3 issues (1 error, 1 warning, 1 info)
  • 🚨 configured test command failed with exit code 1
  • ℹ️ tests/fm-watch-checkpoint.test.sh - tests/fm-watch-checkpoint.test.sh failed once ('watch lock pid survived quiet checkpoint timeout') when run concurrently with 8 other watcher/teardown tests, then passed twice in isolation. Consistent with load sensitivity; production cause not established.
  • ⚠️ bin/fm-watch.sh:3797 - Recorded review-1 decision stands: commit a37b82c changes the fm-watch.sh first-capture seed ordering (a supervision-safety file) without a visible firstmate three-way disposition. Not changed here; surfaced for firstmate.
  • Live validation: ✅ go - 4 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Wake-queue, classify and tmux-submit seams behave after the upstream merge ✅ pass live targeted.log
Teardown refuses or completes correctly across endpoint, pool-slot and force cases ✅ pass live targeted.log
Watcher recovery and retry-band suites pass after the merge ✅ pass live targeted.log
Watch lock pid survives the quiet checkpoint timeout ✅ pass live rerun1.log, rerun2.log (failed once under concurrent load in targeted.log, passed twice in isolation)
Idle seed preserved across a failed first capture (a37b82c) in the fm-watch-triage suite ⏸️ untested no fm-watch-triage is known-slow; the author's plan records it hit the 1500s bound and supervisor rulings 008/009 accept that. I did not rerun it in this targeted step. Whether the a37b82c ordering chan…
Real-Herdr lab scenarios ⏸️ untested no The author's plan reports guarded local Herdr runs already done and a PC02 attempt that stopped because PC02 has no running default Herdr session. I did not drive a Herdr lab here.
  • bin/fm-test-run.sh --changed --exclude-family real-herdr-gated --pc02-if-idle
  • bin/fm-test-run.sh tests/fm-wake-queue.test.sh tests/fm-classify-corr-token.test.sh tests/fm-classify-decision-key.test.sh tests/fm-teardown.test.sh tests/fm-teardown-endpoint-safety.test.sh tests/fm-tmux-submit-busy.test.sh tests/fm-watch-recovery-loop.test.sh tests/fm-watch-retry-band.test.sh tests/fm-watch-checkpoint.test.sh (267 ok, 1 not ok)
  • bin/fm-test-run.sh tests/fm-watch-checkpoint.test.sh x2 (both pass)
  • bin/fm-test-run.sh --list --changed --exclude-family real-herdr-gated (inspection only)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

tiago-peixoto and others added 26 commits October 5, 2026 07:26
…t-in (#5354)

* feat(bin): record each task's no-mistakes pipeline spend at cleanup

no-mistakes keeps every pipeline agent invocation's token usage only in its
local agent_invocations records, and cold pipeline agents (review, test,
document) leave no session log, so a task's review-loop cost never reached
Firstmate's records and could not be attributed after cleanup.

bin/fm-pipeline-spend.sh attributes a task's runs by the repository
no-mistakes resolves for the task copy, the task branch, and the branch's
creation (a relaunch mints a new spawn_gen while the branch keeps
validating), then sums every invocation, failed and cancelled included.
Token fields use no-mistakes' per-round deltas so resumed review rounds are
not counted twice, and unrecorded values stay unknown rather than zero.
show prints the record read-only; record appends it once per task
incarnation to data/pipeline-spend.jsonl. Teardown records it for every
ship task it cleans up, before deleting the branch and the task record.

fm_nm_state_db becomes the one owner of where no-mistakes' state database
lives, shared with the capped run-inventory reader.

* no-mistakes(review): Drop spend show command and timeout override

* style(bin): rewrap fm-pipeline-spend header comment

* Make pipeline spend recording opt-in

* feat(bin): record each task's no-mistakes pipeline spend at cleanup

no-mistakes keeps every pipeline agent invocation's token usage only in its
local agent_invocations records, and cold pipeline agents (review, test,
document) leave no session log, so a task's review-loop cost never reached
Firstmate's records and could not be attributed after cleanup.

bin/fm-pipeline-spend.sh attributes a task's runs by the repository
no-mistakes resolves for the task copy, the task branch, and the branch's
creation (a relaunch mints a new spawn_gen while the branch keeps
validating), then sums every invocation, failed and cancelled included.
Token fields use no-mistakes' per-round deltas so resumed review rounds are
not counted twice, and unrecorded values stay unknown rather than zero.
show prints the record read-only; record appends it once per task
incarnation to data/pipeline-spend.jsonl. Teardown records it for every
ship task it cleans up, before deleting the branch and the task record.

fm_nm_state_db becomes the one owner of where no-mistakes' state database
lives, shared with the capped run-inventory reader.

* no-mistakes(review): Drop spend show command and timeout override

* style(bin): rewrap fm-pipeline-spend header comment

* Make pipeline spend recording opt-in

* no-mistakes(document): Note pipeline-spend opt-in gate in teardown comments

* no-mistakes(ci): I fixed all three Greptile findings following your decision. Both test suites pass: tests/fm-teardown.test.sh (105 ok, exit 0) and tests/fm-pipeline-spend.test.sh (8 ok). I didn't run either new test against the old code, so the claim that they fail before the fix is from reading the code, not a run. Nothing was committed or pushed. **ci-1 / ci-2 (bin/fm-teardown.sh):** The rule is that every owned ship task in a home that has opted in gets a durable spend record before its task record is deleted. The `[ -d "$WT" ]` check skipped the recorder when the worktree folder was already gone, so no record was written. I removed that check and kept the other conditions: the task must be a ship task, teardown must own its worktree, and `config/pipeline-spend` must exist. `bin/fm-pipeline-spend.sh` already writes an unavailable-source line when the worktree is missing. The new test `test_teardown_records_unavailable_spend_for_a_gone_worktree` in tests/fm-teardown.test.sh sets up an owned ship task whose worktree is missing, with recording turned on. It checks that teardown succeeds, writes a line with `source=="unavailable"`, `total==null` and a reason saying the task copy is gone, and still removes the task record. Under the old check no ledger would have been written. **ci-3 (bin/fm-nm-run-lib.sh):** When `NM_HOME` and `HOME` were both unset, `fm_nm_state_db` fell back to `${HOME:-}/.no-mistakes`, which resolves to `/.no-mistakes`. It now uses `root=~/.no-mistakes`. Bash expands `~` to the account's home directory even when `HOME` is unset, which matches the previous Python `Path.home()` lookup. The new test `test_state_db_without_nm_home_or_home_uses_the_account_home` in tests/fm-pipeline-spend.test.sh runs the function with both variables unset and compares the result to the home directory from the system's password database. The old code would have returned `/.no-mistakes/state.sqlite`. shellcheck reports nothing new on the changed files. I added one `disable=SC2016` comment in the new test, where the single-quoted `$1` is meant to expand in the child shell
* feat(bin): start tasks from a named base branch

Spawns always reset a task's pooled copy to origin's default branch,
so work that belongs on a feature, integration, or release branch
started from the wrong code and opened its PR against the default.

fm-brief.sh --base-branch records the base in the brief, fm-spawn.sh
resets the copy to origin/<base> and records base_branch= in task
meta, and the worker targets its PR at that branch. Review diffs,
the cleanup content check, and scout promotion read the recorded
base. local-only and Gerrit deliveries refuse a named base.

* no-mistakes(review): Anchor brief base-branch parse on scaffold Setup line

* no-mistakes(review): Require explicit --base-branch on spawn, matching brief lines

* no-mistakes(document): Note base-branch reset in fm-spawn freshness header

* no-mistakes(ci): I fixed all four Greptile findings the way you specified. The affected suites pass locally: fm-brief, fm-dod-lib, fm-spawn-pool-base-freshen, fm-review-diff, fm-teardown and fm-task-delivery. shellcheck on the changed files reports only info-level notes, no warnings or errors. I didn't revert the code to watch each new test fail before the fix. - **ci-1 (brief text blocked or redirected spawns):** In bin/fm-dod-lib.sh, `fm_brief_base_branches` now only accepts a `Base branch: <value>` line that comes directly after the base-variant Setup sentence fm-brief.sh writes. Any other `Base branch:` line is ignored. `--base-branch` is still the only authority, and the existing checks in fm-spawn.sh are unchanged. With the flag, the spawn is refused unless a matching pair exists and no pair names a different branch. Without the flag, it is refused only if such a pair exists. The header comment in fm-spawn.sh is updated to match. - The `brief_with_base` test helper now writes the real two-line pair. - The decoy refusal case now uses a full decoy pair in the captain's intent. - New test `test_prose_base_branch_line_is_ignored`: a brief with no base whose intent quotes `Base branch: release/1.2` spawns normally with no `base_branch=` recorded. A spawn with `--base-branch feature/hub` whose intent names release/1.2 starts from `origin/feature/hub` and records it. - **ci-2 (scout base not checked against the forge):** fm-spawn.sh now looks up the project's registered forge with `bin/fm-project-mode.sh --forge`, like the ship path does, before `fm_base_branch_valid` runs. Previously it passed `none`. New test `test_scout_base_branch_refused_on_gerrit_forge`: a scout with a base on a forge=gerrit project is refused at spawn and no meta file is written. - **ci-3 (base not shell-quoted in worker commands):** `fm_dod_block` now quotes the base with `printf %q` in the `--base` and `--base-branch` arguments, and the branch name in the prose stays readable. The test in fm-brief.test.sh uses the base `release/$HOTFIX` and checks that both direct-PR and no-mistakes briefs render `release/\$HOTFIX` in the commands. - **ci-4 (ambiguous PR sentence):** The direct-PR sentence now reads "open a PR with `gh-axi` that is ready for review, not a draft, against the base branch `X` (`--base X`), not the repository default." A brief with no base renders exactly as before. The existing assertion in fm-brief.test.sh is updated

* no-mistakes(ci): Both real failures on PR 6442 (run 37064756768) come from CI tooling and a Pi version bump, not from the base-branch feature. Fixes for both already exist on upstream main, so I applied those two commits to the working tree with `git cherry-pick --no-commit`. Nothing is committed or pushed, and no feature file changed. - **Lint 2:** ShellCheck ran out of memory on `bin/fm-teardown.sh` (rss about 8 GB, exit 251, "shellcheck: out of memory"). The rule that broke is that the lint gate must finish on any valid shell root without exceeding the runner's memory ceiling. Upstream commit d719ef3 (#6443) fixes this in `bin/fm-lint.sh`: a root that hits the memory ceiling is retried without `--external-sources`. It also updates `tests/fm-lint.test.sh` and `docs/fm-test-portable-shards.md`. - **Behavior portable serial 6:** `tests/fm-calm-pi-extension.test.sh` failed with "grep disappeared from /export calm.html HTML while calm mode was on". Pi 1.0.1 renamed its HTML export renderer lookup, and upstream commit fede619 (#6530) updates the test to accept the new name. This change is test-only. Both commits applied cleanly. The four touched files are `bin/fm-lint.sh`, `docs/fm-test-portable-shards.md`, `tests/fm-lint.test.sh` and `tests/fm-calm-pi-extension.test.sh`. None of them is in the feature diff, so the feature contract is unchanged. **Local checks:** - `tests/fm-lint.test.sh` passes. - `bin/fm-lint.sh` on `bin/fm-teardown.sh`, `bin/fm-spawn.sh` and `bin/fm-dod-lib.sh` exits 0 with full ShellCheck analysis. - `tests/fm-calm-pi-extension.test.sh` exits 0 with 7 ok and 0 not ok. One case skipped because the Pi package isn't installed locally, so the Pi 1.0.1 export path that failed in CI couldn't be reproduced here. CI needs to confirm it. - I didn't reproduce the 8 GB OOM locally. The PR has to be updated through the pipeline with a normal push: no force push, no replacement PR, no merge
…ole (#6647)

* fix(bin): point project workers at the Firstmate skill file

The Skill tool cannot resolve a Firstmate skill from another project's worktree, so the launch role names the readable skill file instead.

* no-mistakes(review): fix(bin): name Firstmate skill file as fallback only
…ne (#6655)

* feat(bin): retire a contribution whose forge object is permanently gone

Add fm-contributions.sh retire <task> <url> <captain|fleet> <reason>,
which records actor, reason and time on the saved record and removes
that task/url pair from known, poll rotation and coverage even while a
backlog link remains. Repeating a retire keeps the first provenance;
an unrecorded pair, unknown actor, empty reason or unacknowledged
pending signal is refused.

* no-mistakes(review): Keep retirement per task when settling final owners

* no-mistakes(ci): Made the three Greptile fixes the captain chose. ci-1, retirement needs the captain's word: `retire` now accepts only the actor `captain`. Any other actor is refused, including `fleet`. I removed `fleet` from the usage line, the script header (`bin/fm-contributions.sh`), the check in `bin/fm-contributions.sh` and the retired-record validation in `bin/fm-contributions.jq`, which now requires `.actor == "captain"`. The script header now says a retirement always records the captain's word, because the script cannot verify who runs it and the authority to retire is the captain's. The Bearings skill line in `.agents/skills/bearings/SKILL.md` now says `retire` records the captain's word. In the tests, a `fleet` retire is now a refusal case and must leave the record unretired. Every other retire call in the tests uses `captain`. The PR description has not been changed yet: the ruling asks for the same captain's-word statement there, and that belongs to the PR phase. ci-2, blank reasons: the reason check is now `[ -n "${5//[[:space:]]/}" ]`, so a reason made only of spaces or tabs is refused. I added a refusal test that passes a space-tab-space reason. The header also lists a blank reason among the refusals. ci-3, the gone-object test: the test forge wrapper has a new `not-found` fault that returns HTTP 404 for every `api repos/o/r/...` read. The happy-path test `test_retire_ends_observation_of_a_gone_contribution` now uses it in place of the 502 `down` fault, so it models a permanently gone repository rather than an outage. Verification: `bash tests/fm-contributions.test.sh` passed with exit 0. The last lines of its output include the three retire tests passing and no failures. `shellcheck` flagged only SC2034 (`FM_WAKE_QUEUE` unused) and SC1091 (an unfollowed source of `bin/fm-path-lib.sh`), neither on a line this round changed
* test: give the remote-reply whole-log recapture a longer wait

* no-mistakes(review): Extend both recapture waits and simplify retry handling
* fix(bin): reopen a pending-reply escalation after its resolve

A retry of an open decision still appends nothing. A later same-kind escalation after a resolved line for that key appends again, so the next loss is visible.

* no-mistakes(ci): Both Greptile findings are fixed in the working tree; the four directly affected test suites pass, and a wider run of related suites had not finished when I returned this result. Invariant: a line already in the status file is recorded, and only a caller with its own evidence of a new episode may append it again. It must hold for every caller of status_event_recorded: the continuity break and the other call in bin/fm-procevent-remote-reply.sh, fm_parent_channel_append_once, and the pending-reply escalation. Changes: - bin/fm-classify-lib.sh: status_event_recorded is back to the idempotent retry check. It returns at the first matching line, and a later resolved line no longer makes that line look new. This fixes ci-1 for every caller and restores the early exit for ci-2, with no separate scan optimization. - bin/fm-pending-reply-lib.sh: _fm_pending_reply_maybe_escalate_locked now owns the reopen. It appends a new blocked line when the record already has an escalated_epoch (it escalated before and was reset) and the keyed decision is no longer open. Otherwise it uses status_event_recorded, so a retry or a resend that leaves the decision open appends nothing. - Comments on status_event_recorded and the pending-reply header describe this scope. Tests: - tests/fm-pending-reply.test.sh: the regression for escalate, operator resolve, second escalate is unchanged and passes. - tests/fm-remote-reply.test.sh: new regression drives the real reader. After an operator resolve of remote-reply-continuity-ios, a repeated handle and ingest of the same break appends nothing and leaves the decision closed. I placed it beside the existing continuity-break test, not in the pending-reply file, because only that file has the reader harness. - tests/fm-classify-corr-token.test.sh and tests/fm-classify-decision-key.test.sh: the cases that expected a blocked line to append again after a resolve now assert it stays recorded. Verification: - fm-classify-decision-key, fm-classify-corr-token, fm-pending-reply and fm-remote-reply test suites all exit 0 with the fix. - With the two bin files reverted to the commit under review, the new continuity regression and the updated parent-publisher case both fail, so they reproduce ci-1. - shellcheck -x on the changed files reports nothing. - Not finished: a background run of every other suite that mentions the parent channel or pending replies had produced no output, pass or fail, when I returned. One known gap: the escalation writes escalated_epoch before phase. If the process dies between those two writes and an operator resolves the key before the next tick, that tick appends a blocked line for the same episode. I left it, because closing it needs new state. Issue 4755 and other escalation behavior are untouched. Nothing is committed
…ker (#6666)

* fix: refuse a confirming Enter on the Claude exit picker

The background-task picker still classifies as pending, so a retried Enter confirms "Exit and stop tasks".
Stop after the Enter that opened it, and raise the existing stale wake with the dialog name.

A non-paused secondmate still skips that wake, so a secondmate parked on the picker still looks idle.
Model-downgrade confirmation, MCP approval, and any other Claude exit confirmation are not covered, because there is no recorded screen for them.

* no-mistakes(review): fix: anchor exit picker match and wake second mates

* fix: refuse a typed submit while the Claude exit picker is open

A pane that already shows the picker must not receive the message or a confirming Enter.
The match requires the recorded heading and footer lines, and it is skipped when no dialog name is being recorded.

* no-mistakes(review): restore watcher to main behaviour, drop dialog wake

* no-mistakes(test): test: align Herdr picker fixtures with the preflight read

* no-mistakes(document): document exit refusal on a recognised dialog

* fix: remove the dialog file when exit runs in a subshell

do_exit is invoked from a command substitution, so the parent cleanup never saw the path it is supposed to delete.

* no-mistakes(review): fix: set the dialog file path after the control lock

* no-mistakes(document): document why the dialog file path follows the lock

* no-mistakes(ci): The exit cleanup in bin/fm-control.sh now deletes the dialog file first and releases the control lock second. The changes are in the worktree and are not committed. Invariant: only the process that holds the control lock for a task may write or delete that task's dialog file ($STATE/<id>.composer-dialog, the file that carries the picker name from the composer read to the Enter checks). The old cleanup released the lock and then deleted the file, so the delete ran outside the lock. Places where this invariant must hold: control_cleanup is the only place that deletes the file, and the single assignment after CONTROL_LOCK_HELD=1 is the only place that names it. do_exit only truncates the file, and it runs while the parent holds the lock. A process that loses the lock never sets the path, so it deletes nothing (earlier fix, unchanged). No sibling site needed a change. Fix: in control_cleanup, the rm of the dialog file moved above the fm_lock_release call, with a two-line comment that gives the reason. No dialog recognition or supervision code changed. Test: added test_exit_removes_the_dialog_file_before_releasing_the_lock in tests/fm-control-relaunch.test.sh. It runs one `fm-control exit` with a recording rm on PATH. The lock release removes paths at or under the control lock with rm, so the recording rm writes whether the dialog file exists at that moment. The test asserts the last record is "absent". It starts no second command. Verification, all run locally: - Before the fix, the new test failed with "the dialog file must be gone when the control lock is released, got: present". - After the fix, tests/fm-control-relaunch.test.sh exits 0 with 75 ok lines and no "not ok" line, including the new test and the existing test that the file is gone after exit and after relaunch. - tests/fm-control.test.sh exits 0 with 44 ok lines. - shellcheck -x on both changed files exits 0 with no output. One thing I noticed and did not change: tests/fm-control-relaunch.test.sh prints 615 "rm: cannot remove ... Permission denied" lines during its temp-directory teardown. The count is the same with my change reverted, so this change does not cause it, and the suite still exits 0. I could not read the Greptile check log (the check run was not found), so I worked from the finding text and the user instructions
* fix: support stock macOS Bash in timeout watchdog

* no-mistakes(ci): Fixed ci-1 in tests/fm-timeout-lib.test.sh: both startup-owner failure paths now kill the bounded command group before killing the watchdog. Fault injection reproduced both leaks before the fix and confirmed cleanup afterward. Bash 3.2 suite, syntax check, ShellCheck, and diff checks passed; GNU timeout coverage skipped because the binary is unavailable. Production code unchanged
…699)

Wrap the cd command in a subshell to comply with the cd-guard policy
that blocks persistent top-level directory changes in the primary
firstmate checkout. The subshell form (cd projects/<name> && ...) is
accepted by the policy as documented in issue #6502.

Fixes #6502
* Add daily startup growth check

* no-mistakes(review): watch printed startup memory, retain growth baselines, drop knobs

* no-mistakes(review): delegate budget verdict, report before publish, pin shim home

* no-mistakes(review): baseline first sightings silently, drop mtime, spare secondmates

* no-mistakes(review): cap the wake line, validate budget verdict fields

* no-mistakes(review): guard record schema, check appends, tighten assertions

* no-mistakes(review): drop arbitrary tracked library, make re-arm idempotent

* no-mistakes(review): correct tracked-set wording, restore shim guards, register artifacts

* no-mistakes(review): exit on signal instead of publishing partial record

* no-mistakes(document): correct startup-growth record removal cost in state registry

* no-mistakes(test): sweep orphaned empty startup-growth temp records on due evaluation

* no-mistakes(document): note watcher need for armed startup growth check

* no-mistakes(ci): Diagnosed "Behavior portable serial 5": the shard failed on tests/fm-contributions.test.sh in test_arm_plumbs_a_configured_budget_into_the_check_shim (inherited mode) with "generated check did not attempt a read" and a missing forge/calls file. Root cause: bin/fm-contributions.sh:379-382 computes DEADLINE=$(date +%s)+BUDGET and then gates each read on DEADLINE-$(date +%s) >= OBSERVATION_RESERVE (= min(BUDGET,15)). At the one-second budget this test uses, that gate demands zero elapsed whole seconds, so a wall-clock second boundary crossing between the two date calls makes the poll loop break before any forge read. The test calls wrap_forge (which installs a fake date reading $FORGE/clock only when that file exists) but never seeded forge/clock, so it ran against the real clock. The repo already documents this exact hazard at tests/fm-contributions.test.sh:675-677 and freezes the clock in every other budget-constrained test: test_budget_exhaustion_keeps_prior_record (both modes), test_genuine_failure_near_deadline_is_unavailable, test_reservation_defers_later_url_when_fifteen_seconds_do_not_remain, test_slow_read_deadline_kill_is_budget_refusal, test_budget_is_cut_down_to_the_watcher_check_bound. test_arm_plumbs was the only omission; its single loop body covers both the configured and inherited modes. The remaining wrap_forge users run the default 20-second budget (5 seconds of slack above the reserve) and are not reachable by this race. Fix (smallest, matching the sibling idiom): added the clock freeze `/bin/date +%s > "$home/forge/clock"` plus a two-line comment inside that test's loop, before the poll. Three added lines in tests/fm-contributions.test.sh; no production code and no other file touched. Verification: reproduced the exact CI failure message by running a scratch copy whose fake date advances one second per read (worst case of the unfrozen clock) - missing forge/calls, "not ok - generated check did not attempt a read". With the fix, the single test passes 10/10 standalone and the full tests/fm-contributions.test.sh passes all 46 assertions with exit 0. tests/fm-startup-growth-check.test.sh still exits 0. bash -n and shellcheck -S warning are clean on the edited file; scratch repro files were removed, leaving only the intended three-line change. Note for the author: this flake is not caused by this branch - tests/fm-contributions.test.sh is untouched by the PR and the race is pre-existing, surfacing only on a loaded runner (the shard's neighbouring assertions show 80+ second gaps). It was fixed because it is genuine nondeterminism with an established in-repo remedy and the check cannot otherwise go green. No work was done on the unselected greptile findings (ci-2..ci-5) or the cancelled "Behavior portable serial 2" check (ci-6)

* no-mistakes(ci): Diagnosed "Behavior portable serial 6": the omitted log section (fetched with gh api) shows the shard failed on tests/fm-calm-pi-extension.test.sh in test_hidden_block_geometry_e2e with "Pi Calm hidden-block geometry E2E did not complete the /reload viewport transition" (exit=1, duration_ms=23437; the family line pure-contract-unit count=3 duration_ms=51193 failed=1 matches devin-harness 3203 + calm-pi 23437 + task-delivery 24553). Root cause: tests/fm-calm-pi-extension.test.sh:2831 wait_for_geometry_transition detected the /reload by SAMPLING a single intermediate frame - it polled tmux capture-pane for Pi's transient "Reloading keybindings, extensions, skills, prompts, themes, and context files..." box and only accepted the rebuilt transcript afterwards (elif gated on saw_transient). Pi shows that box only while the reload runs and replaces it via dismissReloadBox when done, so on a loaded runner the box can live entirely between two polls; saw_transient then stays 0 forever and the 600-attempt wait times out although the reload fully succeeded. Reproduced locally under CPU oversubscription with CI's Pi 1.0.4: 1 failure in 8 runs, diagnostics proving the mechanism ("DIAG: transition timeout saw_transient=0 attempt=600") while the captured viewport already showed the completed reload status row and the intact collapsed transcript. Not a Pi-version regression: 1.0.4's handleReloadCommand and both banner strings are identical to the installed 0.85.1, and shard 6 of the previous pipeline run (job 112490351105) passed this same script on Pi 1.0.4. Invariant violated: a TUI E2E assertion must key off a durable state the UI retains, never off one intermediate frame polling may miss. Sibling enumeration: the helper was defined once and called once; grep for transient/saw_/two-stage waits across tests/, bin/ and .pi/ found no other one-shot-frame wait - every other wait in the file keys off durable text presence/absence or off continuously repeating animation frames (the working-ship motion checks) where sampling eventually connects; no doc or other test referenced the helper. Fix (smallest, one helper): renamed it wait_for_geometry_reload and made it wait for the durable status row Pi appends once the reload completed and the chat was rebuilt ("Reloaded keybindings, extensions, skills, prompts, themes, and context files", a persistent chat child via showStatus, present in both 0.85.1 and 1.0.4) together with CALM_GEOMETRY_FINAL. That marker is absent before the reload and never appears if the reload throws, so the check is strictly stronger than before (a failed reload now fails the test instead of passing on transient-then-final). One file changed: tests/fm-calm-pi-extension.test.sh, 2 hunks, no production code. Verification: deterministic before/after - with polls spaced 0.4s apart (the loaded-runner worst case) the pre-fix helper fails with exactly the CI message and the post-fix helper passes; 12/12 consecutive passes of the isolated test under load with Pi 1.0.4; full file 15/15 ok exit 0 under LANG=C.utf8 (matching the runner locale); bash -n, shellcheck -S warning and bin/fm-lint.sh clean; scratch repro files and the temp Pi 1.0.4 install removed, git status shows only the one intended modification. Notes: (1) the flake is not caused by this branch - that test file is untouched by the PR and the race is pre-existing; fixed because it is genuine nondeterminism and the check cannot otherwise go green. (2) Under far harsher load than CI applies a separate unrelated flake appeared in the same test: Pi's "Warning: tmux extended-keys is off..." row occasionally lands between the collapsed [skill] ahoy row and the final response, making assert_geometry_gap see 5 rows instead of 2. Different cause, never seen in CI, and its plausible remedies would change key delivery for the other TUI tests in the file, so it was left alone rather than growing this fix

---------

Co-authored-by: Quartermaster <[email protected]>
…k (#6708)

* fix: reopen a remote-reply continuity break after repair

A later break for the same route and reason was swallowed after the
operator resolved the first one, because the status line matched for
the life of the log. The continuity ingest now appends again when the
cursor has moved or retirement has reset that episode, and an unchanged
re-read still appends nothing.

status_event_recorded is unchanged. Its other callers are the
pending-reply escalation, which already decides its own episode, the
parent-channel note append, and the remote document transfer note.

* no-mistakes(review): seed continuity episode for already recorded break line

* no-mistakes(document): document when a remote-reply continuity break reopens

* no-mistakes(ci): The adapter now stores the continuity episode record before it appends the `blocked` line, so a failed store appends nothing. The changes are uncommitted in the worktree, in `bin/fm-procevent-remote-reply.sh` and `tests/fm-remote-reply.test.sh`. **Invariant:** a continuity `blocked` line is on the parent status log only when the episode record for that break is already stored. Only the `continuity-broken` branch of `cmd_ingest` appends that line, so the fix is at that one place. **What changed in `cmd_ingest`:** - It decides first whether the break needs a line, then stores the episode record, then appends. - If storing the record fails, it stops with "cannot record continuity episode" and appends nothing. - If the line is already on the log and no episode record exists, it stores the record and does not append. **One addition you did not ask for:** if the append fails after the record is stored, the adapter puts the earlier record back (or deletes the new one when none existed). Without that, the retry would read as the unchanged repeat and append nothing, which is the issue 6701 failure again. **Deviation from your test instruction:** the test does not use `chmod` on the cursor directory. `write_continuity_episode` runs `chmod 700` on that directory before every write, so a read-only directory is made writable again. The test instead makes `mktemp` fail for the episode's temporary file in that directory, the same way the existing receipt-failure test does. **Tests added to `tests/fm-remote-reply.test.sh`:** - Store failure: the second break exits 1, appends no `blocked` line and opens no decision. One retry after storage recovers exits 3 and appends a single line. - Append failure: with the status log read-only, the third break exits 1 and appends nothing. One retry after the log is writable exits 3 and appends a single line. **Verification:** `bash tests/fm-remote-reply.test.sh` ends with "ALL TESTS PASSED" with the fix. Against the script at commit b750c828 the same test file fails at "a continuity break appended its line before its episode was stored". `shellcheck -S warning` reports only an unused loop variable at line 667 of the test file, which this change does not touch. I ran no other test files. The Greptile Review check log could not be retrieved, so I worked from the finding text alone

* fix: record a continuity break's reader position on its status line

A later break at another cursor is then a different line, so the existing
duplicate check appends it and reopens the decision. An unchanged re-read
builds the same line and appends nothing.

* fix: reopen a continuity break after an identical restore

A retirement that puts the same bytes back used to rebuild the recorded line, so the later break stayed closed. The retirement count on that line makes the later break distinct.

* no-mistakes(review): remove continuity match for full-prefix line without retirement count

* no-mistakes(document): clarify what a continuity break status line records

* fix: remove the reply cursor before recording retirement

A stop between those steps must leave the count unchanged, so an unchanged continuity break still builds the same line.
…is retired (#6733)

* fix(control): drop busy_gen when an incarnation is retired

A deliberate exit removed the busy sidecar and left busy_gen in the task record, so the two records disagreed about whether that incarnation was still observable.

* no-mistakes(review): drop GNU-only chmod and unreached sidecar-absent branch

* no-mistakes(review): correct lock comment to name the deadlock

* no-mistakes(ci): The test `test_exit_drops_meta_busy_gen_with_the_sidecar` in tests/fm-control.test.sh now compares the whole task record (the `state/<id>.meta` file), so the Greptile finding is fixed. Invariant: after `exit` retires an incarnation, the task record must equal the record from before `exit` with only the `busy_gen` line removed. This test is the only place in the change that asserts the record survives the rewrite, so it is the only site to fix. The other `busy_gen` tests assert that the line stays, and they do not go through the rewrite. What changed: before `exit`, the test writes the record without its `busy_gen` line to `expected.meta`. After `exit`, the test runs `diff` between that expected copy and the real record, and fails with the diff output if they differ. This one comparison replaces the two earlier checks (no `busy_gen` line left, and the `window` line present), because it covers both. I did not change bin/fm-control.sh or any other file. How I know it works: - I ran `bash tests/fm-control.test.sh`: exit code 0, 45 lines starting with `ok`, no other lines. - I temporarily changed the rewrite in bin/fm-control.sh to also drop the `harness` line. The test then failed with `not ok - exit should drop only busy_gen from the task record:` and the diff `< harness=codex`. The earlier `window`-only check would have passed that rewrite. I restored bin/fm-control.sh afterwards; `git status` shows only tests/fm-control.test.sh modified. - `bash -n` and `shellcheck` on the test file report no new warnings from the edit. The change is not committed; the working tree holds it
* test(secondmate-harness): scope fake ps -codex label for pid 5252 to the liveness probe

Closes #6456

* no-mistakes(ci): Updated the collision test to log and assert that PID 5252 was queried before selecting 4242. Full fm-secondmate harness suite passes

---------

Co-authored-by: YifuGu <[email protected]>
* fix(calm): share the standalone Pi Calm working-ship widget slot

Firstmate Calm and the user-global standalone Pi Calm both install an
animated working-ship widget during agent runs. Each claimed its own Pi
widget key, so a session loading both (the main Firstmate home) rendered
two boats. Pi replaces widgets under one key, so claiming the shared
"calm-working-ship" slot keeps dual-install sessions to a single boat
while a Firstmate-only session is unchanged.

Pins the shared slot contract in the working-ship module test so the key
cannot silently diverge again.

* test(calm): pin the shared working-ship widget key in CI, document dual-install

The key-parity assertion inside the Pi fixture only runs where the
@earendil-works/pi-coding-agent package is installed, so CI never
exercised it. Add a source-level twin that needs nothing but the
tracked file, and note in docs/calm.md that the boat shares the
standalone Pi Calm working-row widget slot.

* no-mistakes(review): Add executable dual-install widget replacement coverage

* no-mistakes(review): Guard shared widget cleanup with disposal ownership

* no-mistakes(document): Document shared Calm working-ship slot behavior

* test(calm): read the standalone Calm slot from its own module

The dual-install check registered both boats itself under the shared
slot, so it could only prove that Pi replaces a widget under one key: it
would still pass if the standalone Pi Calm extension installed its boat
under a different key, which is the two-boat regression the check exists
to prevent.

Read the standalone extension's own working-ship module when it is
installed - FM_STANDALONE_CALM_SHIP, else ~/.pi/agent/extensions/calm -
and drive the check with the key that module exports, so a rename on
either side registers two widgets and fails naming both keys. A pinned
shared-slot contract still covers a machine without the extension, and
the run reports which side it used instead of passing silently over an
absent extension.

Verified: the touched Pi Calm suite passes and reads the installed
standalone extension; with a copy of it whose key is renamed to
calm-working-ship-v2 the suite fails naming the drift.

* no-mistakes(review): Gate stock-row restoration by shared-widget ownership

* no-mistakes(review): Removed redundant widget-key source assertions

* no-mistakes(document): Document shared Calm working-ship widget ownership
* fix(herdr): make exact-resume presentation-lock wait instead of a bounded timeout

The exact-resume path in bin/fm-spawn.sh used the same 50-attempt-then-
give-up lock acquire as the new-task-create path, but the two paths are
not equivalent on contention: a create has no prior state to strand and
can safely fall back to a flat layout, while a resume is recovering a
specific existing identity that a concurrent recovery may legitimately
be holding the lock for. Giving up there does not degrade gracefully,
it hard-fails the resume outright. The suite's own concurrent
cross-home recoveries test already asserts both concurrent recoveries
succeed with a genuine reclaim, and the file's header comment already
(inaccurately) claimed lock contention falls back to the ordinary flat
layout for both paths alike, so the intended contract was always that
recoveries serialize and both succeed, not that either one refuses
under a short bound.

Give spawn_herdr_presentation_order_lock_acquire a wait mode that uses
this file's own established fm_lock_acquire_wait idiom (already used
for its other fleet-shared locks) instead of the bounded loop, and use
it only at the exact-resume call site. The new-task-create call site
is unchanged and keeps its bounded-then-flat-fallback behavior, which
is already covered by its own passing test. Dead-owner PID-liveness
reclaim inside fm_lock_try_acquire still bounds the wait against a
holder that crashed mid-hold.

Adds a deterministic regression test that holds the shared session
lock from an unrelated process for well past the old bound, then
asserts the resume succeeds with a genuine reclaim and took close to
the full hold duration, so a fix that merely widens the bound rather
than genuinely waiting is still caught. The existing concurrent
cross-home recovery test exercises this under real timing but does not
reliably outlast a fixed bound on its own.

Corrects the header comment's claim that create and resume share one
bounded-then-flat-fallback behavior on lock contention; they no longer
do.

* no-mistakes(document): Document Herdr recovery waiting for presentation lock

* no-mistakes(document): Update stale hard-refusal claim in verification log

* no-mistakes(ci): Fixed the Greptile finding on tests/fm-backend-herdr-presentation-e2e.test.sh:1389 by bounding the resume lock-wait regression's spawn_task call. Added an optional 4th `deadline_seconds` arg to the `spawn_task` helper (defaults to empty, so all ~20 other existing call sites are unaffected and unwrapped by `timeout`). The lock-wait test now passes `LOCK_WAIT_HOLD_SECONDS + 60` (90s) as the deadline, and a dedicated check for exit code 124 emits a clear "hung for over Xs instead of waiting out a Ys lock hold" diagnostic before falling through to the existing pass/fail assertions, which are unchanged. No product code was touched. Verified with `bash -n`, `shellcheck -x` (no warnings), a standalone reproduction of the timeout/no-timeout/success paths, the project's `bin/fm-lint.sh --fast` on the file (clean), and the full `tests/fm-lint.test.sh` suite (all 46 assertions pass)

* no-mistakes(ci): Replaced the direct `timeout "$deadline_seconds"` call in `spawn_task()` (tests/fm-backend-herdr-presentation-e2e.test.sh) with the repo's portable bounded-execution helper: sourced `bin/fm-timeout-lib.sh` at the top of the file and changed `deadline_cmd=(timeout "$deadline_seconds")` to `deadline_cmd=(fm_run_timed "$deadline_seconds")`. This removes the GNU/BSD `timeout` dependency that would fail with exit 127 on a stock macOS host without coreutils, while preserving identical semantics (exit 124 on bound-hit, command's own exit otherwise), which the existing `[ "$LOCK_WAIT_STATUS" -eq 124 ]` diagnostic check already relies on. Verified: `bash -n` syntax check, `bin/fm-lint.sh --fast` clean, full `tests/fm-lint.test.sh` suite (46/46 pass), and a standalone repro confirming `fm_run_timed` returns 124 on timeout and 0 on success identically to the prior `timeout` call. No other direct `timeout` calls exist in this file or elsewhere in the PR's diff, so no sibling sites remain

* fix(herdr): gate exact-resume lock wait behind --herdr-resume-lock-wait

Keep refuse-by-default on presentation-order lock contention for Herdr
exact resume. Callers that need concurrent recoveries to serialize must
pass --herdr-resume-lock-wait; unbounded blocking on a third-party session
lock is never the default.

Update docs and the real-Herdr e2e suite so the default path asserts the
refusal and the opt-in path asserts the wait.

* no-mistakes(test): Fix e2e test's lost exit status after if/fi with no else branch

* docs(herdr): stop advertising --herdr-resume-lock-wait on --relaunch

The relaunch path reuses the recorded endpoint and never takes the
presentation-order lock, so the flag is inert there. Drop it from the
--relaunch usage line and state where the flag applies.

* no-mistakes(review): Clarify lock-wait docs; simplify bash-3.2-safe spawn_task helper

* no-mistakes(ci): Fixed ci-1 (Greptile P2). In tests/fm-backend-herdr-presentation-e2e.test.sh, the failure cleanup `cleanup_all` stopped only `LOCK_CONTENTION_OWNER_PID`. It now also stops `LOCK_REFUSE_HOLDER_PID` and `LOCK_WAIT_HOLDER_PID`, the holders of the two new contention cases, so a `fail` before their explicit `wait` no longer leaves them running. Both new PIDs are initialised empty next to the existing one, and each is cleared right after its successful `wait` so cleanup never touches a finished PID. I changed nothing else. `bash -n` passes. The real Herdr e2e run passed both new cases ("default resumed identity refuses session lock contention" and "--herdr-resume-lock-wait waits out session lock contention instead of refusing"). The full run hit my 550s timeout in a later, unrelated case, after the new cases passed
….2 (#6762)

* fix(bin): let TERM stop a watcher blocked in a pane capture on bash 3.2

Stock macOS bash 3.2 holds a HUP or TERM until a running command
substitution's child exits, and the watcher read every pane through
$(fm_backend_capture ...). A blocked backend read therefore held the
watcher's stop for as long as the read lasted, and a stopped watcher left
the hung read orphaned. tests/fm-watch-triage.test.sh
test_term_stops_a_watcher_blocked_inside_a_poll failed on /bin/bash 3.2
for this reason while passing on bash 5.

Pane captures now go through watcher_capture, which runs the read as a
waited background process group recorded like a check's, so the stop is
honored at once and watcher_cleanup stops a read still in flight along
with its per-call output file.

* no-mistakes(review): Run drain-ring idle capture in watcher shell, add regression test

* no-mistakes(document): Document watcher TERM handling for blocked checks and captures

* no-mistakes(test): Silence bash 3.2 setpgid race noise from watcher captures

* fix(bin): verify the capture group and scope the stop claim to pane reads

watcher_capture now confirms its background read leads its own process
group, as run_check_capture already does, so watcher_cleanup never relies
on a group that set -m failed to create. The comment and continuity doc
now say only fm_backend_capture pane reads go through watcher_capture;
agent-state and composer-state reads still run inside command
substitutions.
* feat(spawn): add per-home worker tool exclusions

Add an optional per-home config/crew-exclude-tools file listing tool names to hide from workers, one per line, with blank lines and # comments allowed.
It applies to every ship and scout launch and relaunch in that home, is never inherited by another home, and does not affect secondmate agents.
Pi and pi-signed apply it through --exclude-tools, which also covers MCP tool names.
Any other runtime, and a raw launch command, refuses the launch when the list is non-empty rather than ignoring it.
Malformed entries are refused before provisioning, and before a relaunch stops a running worker.
Exclusions that match no tool in the worker's loaded registry are reported as unverified warnings in its status record instead of refusing the worker.

Closes #6744

* no-mistakes(review): Preserve UTF-8 exclusion paths and verify Pi lifecycle behavior

* no-mistakes(document): Clarify worker tool exclusion documentation

* no-mistakes(ci): Fixed ci-1 in bin/fm-exclude-tools-lib.sh: a failed read now returns an error before printing names, so all shared launch and relaunch callers refuse rather than silently dropping exclusions. Added deterministic regression coverage for a file disappearing after readability checks across Pi/pi-signed ship and scout launches. Reproduced the original failure; verified 83 spawn checks, 77 relaunch checks, direct parser/runtime failure cases, full targeted lint, Bash syntax, and git diff --check. Relaunch tests passed with existing fixture-cleanup permission warnings. ci-2 remains unchanged per the user's decision; the outer executor owns the fresh CI run
…n (#5343)

* refactor(bin): share the local Firstmate home walk from the wake library

Teardown's walk over the root home and its registered local secondmate homes
moves into bin/fm-wake-lib.sh as fm_local_firstmate_state_dirs, next to
fm_firstmate_root_home, so a second consumer can count task records across
this machine's homes without a copy. Teardown keeps its exact refusal wording
through a thin wrapper.

* feat(bin): defer spawns beyond a project's declared machine capacity

A project whose machine-local resource only serves a few workers at once had
no way to tell Firstmate so: every queued item was launched, and the surplus
workers spent full-context turns retrying the resource.

config/project-capacity in the root home now declares how many workers each
named project admits at once on this machine. bin/fm-spawn.sh counts the ship
and scout records on the same project origin across the root and its local
secondmate homes, skipping ones whose ready PR is recorded, while holding the
shared project lock through publication. A spawn with every place held exits 75
before any brief render, endpoint, worktree, record, or backlog move, so the
item stays queued; batches report it as deferred. Undeclared projects keep
today's uncapped dispatch, and an unreadable declaration refuses rather than
guessing the limit.

Refs #4237

* no-mistakes(review): Document that capacity matches the clone directory name

* no-mistakes(document): Rewrap stale fm-wake-lib root-home doc comment

* no-mistakes(review): Dedupe local state dirs by identity to avoid double-counting

* no-mistakes(document): Rewrap fm_local_firstmate_state_dirs error doc comment

* no-mistakes(ci): I fixed all four Greptile findings. All 14 tests in tests/fm-project-capacity.test.sh pass, and shellcheck at warning level is clean on the changed files. Each new test failed against the old code and passes now. - **ci-1 (spaced names):** a declaration line must give a name its capacity whenever the name is a valid clone directory name. `fm_project_capacity_lookup` now trims each line, skips blank lines and lines whose first non-blank character is `#`, and takes the last field as the capacity. Everything before that field is the name, so it may contain spaces. The old error cases still refuse: a single field is rejected, and trailing text leaves a last field that is not an integer. The library header and docs/configuration.md now say a name starting with `#` cannot be declared. New test `test_spaced_project_name_is_declared` declares `my heavy project 1` next to an indented comment line and gets a deferral. - **ci-2 (unreadable records):** the holder count must never silently leave out a holder. `fm_project_capacity_occupants` now refuses when a local home's state directory exists but cannot be read or listed, or when a `.meta` file cannot be read. The error names the path, and `fm-spawn.sh` shows it in its existing refusal message. New test `test_unreadable_holders_refuse_admission` covers an unreadable record in the root home and an unreadable state directory in a registered local secondmate home, then checks that the spawn is admitted once both are readable. The test is skipped when run as root. - **ci-3 (Orca lock):** any spawn that can become a holder for a capped project must take that project's lock. The lookup now also reports whether the declaration caps any project at all, and an Orca spawn takes the per-origin lock whenever it does. This covers every capped same-origin clone. It also covers some cases where no same-origin clone is capped, because a spawn cannot find clones under other directory names without searching for them. With no declaration file, Orca still skips the lock. The comments in the library and in the `fm-spawn.sh` header are updated. The Orca test now clones the origin as `project-2`, which has no declaration, and checks that its Orca spawn refuses while the lock is held and publishes no record. - **ci-4 (worktrees):** `assert_nothing_created` now also compares the project's `git worktree list` from before and after a deferred spawn. Both tests that call it take that snapshot first. Files changed: bin/fm-project-capacity-lib.sh, bin/fm-spawn.sh, docs/configuration.md, tests/fm-project-capacity.test.sh

* fix(bin): declare capacity for a project name that begins with #

A clone directory whose name begins with # was skipped as a comment, so that project stayed uncapped. A line is a declaration when the # is written against the rest of the name and the line ends with a capacity; a # followed by whitespace stays a comment.

* no-mistakes(document): Rewrap project-capacity library header comment

* no-mistakes(ci): Lint 2 fails because this PR's code pushes ShellCheck past its memory cap. ShellCheck ran out of memory analyzing bin/fm-teardown.sh in CI (reason=memory, rc=251, peak about 8.39 GB). On current main the same file passes at about 7.29 GB. **Cause:** the new `fm_local_firstmate_state_dirs` function in bin/fm-wake-lib.sh had a conditional `. fm-secondmate-registry-lib.sh` with a `# shellcheck source=` directive inside the function. ShellCheck followed that source again, inside a function scope, wherever fm-wake-lib.sh is sourced, and bin/fm-teardown.sh is the heaviest root that sources it. Measured locally with `shellcheck --norc --external-sources bin/fm-teardown.sh`: - current main (fd325b1): 7.29 GB - main merged with this PR: 7.86 GB - the same merge without the in-function source: 7.27 GB **Rule this restores:** this change must not make any lint root heavier than it is on main. That function holds the only new nested source in the change. **Fix:** I removed the in-function source, which no caller needs. Both callers already load the registry library at top level before calling the function: - bin/fm-teardown.sh sources it directly. - bin/fm-spawn.sh, the only user of bin/fm-project-capacity-lib.sh, gets it through bin/fm-ff-lib.sh. I also documented the requirement in the function's comment and in the "Requires" note in bin/fm-project-capacity-lib.sh. No behaviour changes. **Verification:** - ShellCheck on head: bin/fm-teardown.sh peaks at 7.12 GB and bin/fm-spawn.sh at 6.68 GB, both with rc=0. bin/fm-wake-lib.sh and bin/fm-project-capacity-lib.sh lint clean. - tests/fm-project-capacity.test.sh, tests/fm-teardown.test.sh (102 ok) and tests/fm-teardown-endpoint-safety.test.sh all pass. Files changed: bin/fm-wake-lib.sh, bin/fm-project-capacity-lib.sh

* fix(bin): release the Herdr session lock when reclaim finishes

A concurrent resume in another home waits five seconds for that lock.
Reclaim is the last presentation change on the recovery path, so holding
the lock through the launch tail made the waiter time out. The contributions
arm check also freezes its one-second clock, the same way the budget tests
do, because an unfrozen clock can tick past before the first forge read.

* no-mistakes(review): Keep Herdr session lock through launch handoff after reclaim

* no-mistakes(review): Skip the spawning task's own record in capacity count

* no-mistakes(review): Restore release test comment above its test

* docs: scope PR-ready re-evaluation to a declared project capacity

A ready pull request frees a place only when that project declares capacity, so the always-loaded backlog contract should re-evaluate on that handoff only in that case.
@sKeLe100
sKeLe100 merged commit 23261b5 into main Oct 12, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants