Repository navigation
Conversation
Supervision dropped silently and repeatedly in the primary home because the Stop-owned auto-arm published no evidence of its own existence until after its most expensive gate. Both Claude Stop hooks fire on the same event, so bin/fm-turnend-guard.sh --claude reached its verdict while bin/fm-claude-stop-autoarm.sh was still inside the identity gate, whose ancestry walk forks ps three times per hop over up to sixteen hops and measured 0.9 to 3.5 seconds against a nominal 800 millisecond cooperative window. The guard then printed that no recovery was under way while recovery was under way, and spent a forced continuation on it every turn. The fix is one cause in three parts. The auto-arm now publishes state/.claude-autoarm-claim after its three cheap read-only gates and before the identity gate, carrying its pid and process identity so the guard can trust it exactly as far as it trusts the owner lock. The guard accepts a live identity-matched claim, accepts the arming epoch outcome it previously dropped, and bounds its cooperative wait by elapsed wall clock rather than by a count of fork-heavy passes, which had stretched a nominal 800 milliseconds to 29.8 seconds at a real turn boundary. Two premises in the report were disproven by measurement rather than assumed. The asyncRewake hook does run when its blocking sibling exits 2, firing within about a millisecond of it, and the continuation turn does not start until that outstanding hook completes, so the next turn's start does not race the arm. Regression coverage runs the reproduction as real concurrent processes: a ps shim parks a real auto-arm inside its identity gate and the guard is asked for a verdict with the claim as the only evidence on disk, asserted both ways at the same instant so the claim is the whole difference. Because the verdict ultimately comes from harness-emitted output, the opt-in live guard now runs its whole session behind a slowed pid-query shim and proves from the delay log that the identity gate outlasted the cooperative wait. Two adjacent defects were fixed in passing rather than left silent. The test runner's coverage guard compared LC_ALL=C sorted inventories with a locale-sensitive comm, so it warned and failed on any host whose locale is not C; the live auto-arm regression still asserted that the model types the session start command, which the run-tier SessionStart hook has since made unnecessary, so that test could not pass at all.
The claim-publication fix is a harness-dependent behaviour, so its verdict has to be traceable to commands somebody else can rerun rather than to a session's recollection. This records the dated reproduction under the turn-end guard heading: the two premises measurement disproved, the identity-gate and cooperative-wait timings that opened the visibility window, the four portable regressions with the exact lines they emit against a pre-fix tree, and the opt-in live guard's Claude 2.1.234 result. It also records what did not run here. The repo lint gate exits 127 because actionlint is absent, so only its ShellCheck half is evidence, and the test runner's own suite cannot complete without ruby. Both are host gaps rather than results, and a verification file that stayed silent about them would read as a pass.
The elapsed-time regression added alongside the claim-ordering fix asserted the Stop hook's TOTAL wall clock against a 5 second ceiling, and failed on a loaded host while the behaviour it names was working. Varying only the budget on one fixture showed why. A budget of zero forbids every retry and the hook still spent 4.9 to 5.9 seconds; 800ms spent 6.2 to 7.1 and 3000ms spent 6.7 to 7.4. The wait is a minority of the hook's runtime, and the majority is fixed cost paid whatever the budget is: sourcing its libraries, the primary-scope checks, and on the blocking path the budget accounting and banner. The old assertion therefore measured that fixed cost, so it failed on load rather than on the defect, and its message named a cause that measurement disproves. The regression now differences a real budget against a zero one on the same host, which is exactly what the wait spent, and asserts both runs took the blocking path so the difference cannot be the path. Behind a sleep shim charging 3s per interval a deadline-bounded wait spends one interval (2.3 to 4.3s measured) and the pass-count loop it replaced spends eight (24.8s measured against a pre-fix tree), so the three-interval ceiling separates them by more than a factor of two in both directions. Two things the same measurement showed were corrected rather than softened. The guard's comment and docs/turnend-guard.md claimed the deadline makes the budget "mean what it says on every host"; it bounds the retrying only and is not a promise about how long the Stop hook takes, and one complete evaluation is irreducible because the guard cannot conclude a proof is absent without looking for all of them. The re-evaluation that followed the wait loop was also dead weight: the loop breaks only on the line directly after a failed evaluation, so that call repeated the pass just completed with no sleep in between and paid a second round of the fork-heavy checks and their budget accounting for nothing. The verification record now carries the corrected pre-fix output, the budget sweep behind these claims, and a third field sample from 2026-08-22 at 815 seconds of beacon staleness whose ledger held outcome=arming in the same second the guard declared the home unclaimed. The spread across 297, 390 and 815 seconds rules out a threshold-tuning fix. It also records that bin/fm-lint.sh now completes here at exit 0 with actionlint 1.7.12 present, where the earlier run's exit 127 was a missing tool rather than a result.
An unrelated firstmate home reported the same defect on 2026-08-22 without prompting, which is what establishes it as structural rather than local to one home or to any load condition there. It quoted beacon ages of 168 to 1001 seconds against real ages of 3 to 21 measured immediately afterwards, with the rewake counter advancing across all six firings and no failure marker present, and reached the same mechanism from its own evidence. It also separated this defect from the wake-queue lock deadlock, because nothing deadlocked and recovery always completed on its own. The record now also states the constraint that follows from the cost: a false alarm every time makes a genuine failure indistinguishable from the noise, so the fix must not buy quiet by weakening the predicate. It names the five cases that pin the no-arm no-watcher no-claim stop still blocking loudly.
Supervision dropped silently and repeatedly in the primary home because the Stop-owned auto-arm published no evidence of its own existence until after its most expensive gate. Both Claude Stop hooks fire on the same event, so bin/fm-turnend-guard.sh --claude reached its verdict while bin/fm-claude-stop-autoarm.sh was still inside the identity gate, whose ancestry walk forks ps three times per hop over up to sixteen hops and measured 0.9 to 3.5 seconds against a nominal 800 millisecond cooperative window. The guard then printed that no recovery was under way while recovery was under way, and spent a forced continuation on it every turn. The fix is one cause in three parts. The auto-arm now publishes state/.claude-autoarm-claim after its three cheap read-only gates and before the identity gate, carrying its pid and process identity so the guard can trust it exactly as far as it trusts the owner lock. The guard accepts a live identity-matched claim, accepts the arming epoch outcome it previously dropped, and bounds its cooperative wait by elapsed wall clock rather than by a count of fork-heavy passes, which had stretched a nominal 800 milliseconds to 29.8 seconds at a real turn boundary. Two premises in the report were disproven by measurement rather than assumed. The asyncRewake hook does run when its blocking sibling exits 2, firing within about a millisecond of it, and the continuation turn does not start until that outstanding hook completes, so the next turn's start does not race the arm. Regression coverage runs the reproduction as real concurrent processes: a ps shim parks a real auto-arm inside its identity gate and the guard is asked for a verdict with the claim as the only evidence on disk, asserted both ways at the same instant so the claim is the whole difference. Because the verdict ultimately comes from harness-emitted output, the opt-in live guard now runs its whole session behind a slowed pid-query shim and proves from the delay log that the identity gate outlasted the cooperative wait. Two adjacent defects were fixed in passing rather than left silent. The test runner's coverage guard compared LC_ALL=C sorted inventories with a locale-sensitive comm, so it warned and failed on any host whose locale is not C; the live auto-arm regression still asserted that the model types the session start command, which the run-tier SessionStart hook has since made unnecessary, so that test could not pass at all.
The claim-publication fix is a harness-dependent behaviour, so its verdict has to be traceable to commands somebody else can rerun rather than to a session's recollection. This records the dated reproduction under the turn-end guard heading: the two premises measurement disproved, the identity-gate and cooperative-wait timings that opened the visibility window, the four portable regressions with the exact lines they emit against a pre-fix tree, and the opt-in live guard's Claude 2.1.234 result. It also records what did not run here. The repo lint gate exits 127 because actionlint is absent, so only its ShellCheck half is evidence, and the test runner's own suite cannot complete without ruby. Both are host gaps rather than results, and a verification file that stayed silent about them would read as a pass.
…d elapsed-time wait
…guard block, and stale arming acceptance
…anscript with final guard fix
bde0956 to
d36dd94
Compare
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (4): Last reviewed commit: "merge: supersede the pre-alignment branc..." | Re-trigger Greptile |
|
Two notes for reviewers, both about things that are easy to lose. Which test now covers the genuine-failure case. This branch removes That test was replaced rather than deleted. The competing-session race this branch introduced, and its residual. Publishing the claim before the identity gate meant a session that does not own The residual is deliberate and bounded: an owning session whose lock holder sits deeper than eight hops publishes no early claim and gets a false alarm, never a silent drop. CI status on this PR is not a verdict on this change. The only check present is the Greptile review bot; none of the repository's real suites appear, because this branch is contributed from a fork and fork-branch workflow runs are held pending maintainer approval. A green result here should not be read as the suites having run. The suite evidence in the body above was produced locally and each command is named there. |
Broadening the push trigger to every branch would have started a source-tree suite against the orphan branches the gate publishes test evidence to, which carry no source tree and so could only ever fail. branches-ignore keeps a new branch validated by default and excludes only that namespace.
…ver ran Three pull requests were reported green whose repository suites had never started. Each carried exactly one check, a third-party review bot reporting success, which reads as "1 passed, 0 failed, 1 total" to anything that only tallies conclusions. bin/fm-bearings-snapshot.sh classified that as passing for the same reason: a rollup with nothing red and nothing waiting. bin/fm-ci-checks-lib.sh now owns the rule, structurally rather than by bot name: a GitHub Actions check run records the workflow that produced it, and a check run created by a third-party App has no workflow behind it and so no name. A rollup with no repository-owned check classifies as no-repo-ci, decided ahead of failing and pending so missing suites are never reported as a different problem. bin/fm-pr-ci-verify.sh asks the question directly for one pull request, and resolves the case those three were actually in: it reads the head repository's own workflow runs at the same commit, so a fork run that validated the change counts while GitHub still holds the upstream run. The verdict names which repository the evidence came from, so fork-validated is never reported as the upstream pull request having been checked.
The workflow told a contributor to fork and then aimed everything at the pull request here, leaving no statement that the fork is where the suites actually run. That is what let a held upstream run read as a blocker on knowing whether the change works, when it is only a wait on a maintainer decision. CONTRIBUTING.md now states the split and says why an all-green check list is not evidence anything ran. The generated ship brief and the firstmate contract both require confirming a green claim with bin/fm-pr-ci-verify.sh rather than reading a check total.
…ere sorted in Pre-existing and unrelated to the rest of this branch, reported here rather than left silent. The guard builds every list with LC_ALL=C sort but ran comm under the ambient locale, so on a UTF-8 host comm rejected the C-sorted input as unsorted and the guard failed with a message about sort order rather than about the partition it exists to prove. CI runs under a C locale and never saw it. Verified before and after on the same machine: bin/fm-test-run.sh --check-coverage exited 1 with "comm: file 2 is not in sorted order" under LANG=en_US.UTF-8 and 0 under LC_ALL=C; it now exits 0 under both.
…w produced The bearings fixture rollup carried a bare passing entry with no producer on it, which is what a review bot's check looks like rather than a suite's. Now that the row is classified by whether the repository's own workflows ran, that fixture reads no-repo-ci, which is correct for what it describes and wrong for what the test means. Give it the workflow name a real CI check run carries. Add the bot-only rollup as its own fixture and assert the row reads no-repo-ci and never passing, so the case the classifier exists for is pinned here too.
Self-update reads whatever remote the home calls origin, so a fleet that runs its own suites can update from the fork those runs validated rather than from a repository whose answer it is still waiting on. Nothing in the code has to change for that; the sentence exists because the option is invisible from the outside, and reading origin as a fixed repository is what makes a fork look like a place work goes and never a place work comes from.
The stock-Bash lane pins an exact count so a test cannot quietly stop running. The bot-only rollup case is a new test, so the floor moves with it.
The rollup shape learned to require the full required-suite roster, but the workflow-runs shape - the one that answers "did MY fork validate this commit?" - still granted a passing verdict on the run's own conclusion. That left the false green this change exists to remove alive on the second evidence path: fm-pr-ci-verify.sh reported a commit validated whenever one successful CI run existed at it, without establishing that the required suites were inside that run. Both P1 findings on the pull request named this, at fm-ci-checks-lib.sh lines 73 and 141; the second was already closed for the rollup, this closes the first for the runs. The comment that justified skipping the roster here was wrong. It claimed GitHub cannot conclude a run "success" while a job in it is missing, so the platform already enforced the roster for this shape. GitHub concludes a run success whenever no job in it FAILED, and a job that never ran because it was skipped does not fail: cli/cli run 32701833535 concluded success with one job successful and two skipped. A CI run that lost most of its roster to an if: condition, a matrix that did not expand, a path filter, or a thinner ci.yml on the branch under test therefore still reports success. fm_ci_run_jobs_state takes the jobs of the CI runs alongside the runs and applies the same roster to them, so both shapes now answer the same three outcomes and only one of them authorizes a green claim: the suites ran and passed, the suites ran and did not pass, or the suites cannot be shown to have run. Jobs that cannot be read at all fall in the third, never inheriting the run's verdict. The verifier prints the job roster for every outcome, including the passing one, and names the missing suites when it refuses. Tests use the shapes actually recorded on the two pull requests, covering both polarities of the defect: the bot that PASSED on 2584 with no suite behind it, and the bot that FAILED on 2855 while the run reporting on it read as passed. Neither may classify as passing. Verified against pre-change code, where the new assertions fail and the guard exits 0 reporting "validated" on a fork run whose only job was Lint. CONTRIBUTING.md no longer tells a contributor to treat a fork run's conclusion as the answer, which was the same false green in prose.
fix(bin): refuse false-green CI verdicts when suites never ran
|
Closing this from our side. It mixes changes that are specific to how we run a fork of this project with the general part, so it is not in a shape that is useful to review. If the general half is worth raising we will raise it on its own, described for a reader coming to it cold. Apologies for the noise. |
|
Reopening: closing this was our error. It was closed as part of a batch cleanup of stale pull requests from us, but this one is neither stale nor mixed - it is an active change and the fix in it is general rather than specific to our own setup. The previous comment does not apply to this pull request. Apologies for the noise. |
Arming a merge poll is this repo declaring a pull request a landing path. bin/fm-pr-check.sh now asks the forge whether the viewer can merge into the repository hosting the pull request and refuses when it cannot, naming the fork the work has to land on instead. Mergeability comes from the forge's own viewer permission, never from a repository name, so a second fork or a rename does not rot the guard. bin/fm-pr-merge.sh inherits the refusal because it records through the same script before calling the forge. Raising or pushing a pull request against a read-only upstream is untouched; only treating one as a landing path is refused. The verdict is persisted as pr_landing= and carried by every path that reports a task's pull request: the fleet snapshot and view, the bearings projection, and inactive terminal-outcome reconciliation. Those paths read the record rather than the forge, keeping their documented zero-network contract, and a URL scraped out of a status log reads as unverified. An unchecked pull request therefore cannot reach the captain worded as a merge decision. An unreachable forge refuses to arm rather than arming anyway. The cost is a loud, retryable stop on a poll that was never armed, against silently re-admitting the exact case this guard exists for; it matches the existing missing-glab refusal in the same script. pr_landing= is written before pr= because fm_pr_metadata_identity_parse rejects any unrecognized key that follows pr=, so that parser is unchanged and a forged trailing pr_landing= line still fails closed. GitLab returns an unchecked verdict and is unaffected: a member access level does not by itself decide merge rights when protected-branch merge access is separately configurable, and glab is not installed here to verify against.
…-watch.md GitHub transcript
tests/fm-teardown.test.sh's default and merged-PR gh-axi fakes did not answer the new "api /repos/" landing-permission query fm-pr-check.sh now makes, so every case that reaches it fell through to unreachable. Both fakes answer true: every PR_CHECK call these tests make is against a repository this machine can merge into. The Stock macOS Bash snapshot job pins an exact ok-count per suite so a silently miscounted test never slips through; the landing-guard reporting test added to fm-fleet-snapshot-view.test.sh raised that count from 15 to 16 and the pinned expectation had not caught up.
* fix(bin): record a lock before it becomes visible so a signalled process can hand it back A watcher TERMed inside the arm window left state/.wake-queue.lock and its singleton lock held by a pid that was already gone. Recovering an abandoned lock is not free: the dead-holder steal is roughly 20-30 forks, measured at 3.0s wall for one lock on an unloaded host, so the successor inherited seconds of work before its first beat, missed the same FM_ARM_CONFIRM_TIMEOUT, and abandoned the locks again. That is how one slow arm regenerated itself into a supervision outage that could not clear, observed twice: six consecutive confirmation-timeout cycle exits with beacon_age climbing 162, 175, 443, and again with both locks naming dead pids alongside an owner directory that had survived eleven days. The reported cause was that fm_lock_acquire_wait has no dead-holder steal. It does. The steal lives in fm_lock_try_acquire and is generic to every lock path rather than specific to the singleton watch lock, so fm_lock_acquire_wait inherits it. Both assertions the report asked for pass unchanged against the pre-change library, so they ship here as regression guards and not as proof. The actual defect is an ordering inversion in fm_lock_try_create. The lock became visible on disk at ln -s and carried this process's pid at fm_lock_claim, several forks before _fm_lock_track_held recorded it in memory. Every one of those forks is a signal-delivery point, so a signal landing in that window left a lock held by this process that its own exit sweep could not see. The same inversion around mktemp -d is what leaks the .owner.* directories. Locks and owner directories are now recorded before they are created and forgotten only after they are removed, so the in-memory record stays a superset of what is durably on disk. On the question the report left open, the TERM trap does need to release its locks, and the ordering fix is what makes that possible rather than a substitute for it. Without the trap nothing sweeps at all; without the ordering the sweep saw only about half of what was held, which is why releasing on the trap alone fixed the failure about half the time. Neither the arm confirmation timeout nor the pre-lock startup cost is touched. Both make the window reachable, and shrinking either would have hidden this rather than fixed it. Tests: a signalled watcher must hand back every lock it holds, which passed about half the time before and now passes 12 runs out of 12; and a direct assertion of the ordering invariant, which overrides the two steps that follow each durable write because a timing race cannot check the ordering reliably. Both fail against the pre-change library. Pre-existing and deliberately not addressed here, all three verified against the default branch on the same host. test_lock_single_winner_under_concurrency is a load-sensitive flake on both; interleaved runs put it at 1/10 failures on the default branch against 2/10 here, and it is what aborts that branch's own full-suite run. test_arm_self_eviction_is_loud_without_successor fails 4/4 on the default branch in isolation, and test_signal_catchup_without_running_watcher fails 3/3 on both, its 4s exit budget being shorter than the pre-lock startup this host needs. * no-mistakes(review): placeholder * no-mistakes(document): docs(watcher-continuity): list new lock-handback and ordering tests * no-mistakes: apply CI fixes * chore(tests): drop a temp test runner committed by a pipeline fix round The CI auto-fix round that closed the owner-directory race also committed tests/fm-watcher-lock-skip-flake.test.sh.tmp, a 1358-line scratch copy of tests/fm-watcher-lock.test.sh it had built to skip the known-flaky test_lock_single_winner_under_concurrency while verifying its own change. It is a working artifact, not a test the suite runs or should carry: it duplicates the real file, its name is not picked up as a test, and leaving it in the tree would strand a stale copy that silently drifts from the original. Removing it changes no behavior and no test coverage.
) * feat(bin): add allowance-park detection library (partial: not yet wired in) A worker whose harness refuses a turn on the account allowance keeps a live pane and a live process, so every liveness probe firstmate owns reads healthy and no wake fires. On 2026-08-17 two crewmates parked seconds after launch, their reset passed at 08:30, and nothing surfaced or resumed them until an unrelated wedge timer happened to fire on one of the two panes hours later. This adds bin/fm-allowance-lib.sh, the one owner of that detection, with two independent signals so no single vendor string is load-bearing: - session-record: the harness's own transcript records the refusal as an assistant record carrying isApiErrorMessage with an HTTP 429 status. Structural, and preferred. Reading the LAST conversational record is what makes it current-state rather than history. - pane: the rendered notice matched against a per-harness signature in a bounded tail of the capture, for a worker whose transcript firstmate cannot locate or a harness that reworded its records. Per-harness support is a gate, not a default: only claude has a verified signature, and every other adapter reports not-parked, so firstmate's behaviour for them is unchanged. The library is deliberately kept out of the semantic busy-state contract in bin/fm-busy-lib.sh, which forbids rendered text as a state source; this one can only ever ADD a wake or name a cause. Both signals were verified against real evidence on this machine: 106 refusal records across ~/.claude/projects, all carrying apiErrorStatus 429, with the last-record test separating 27 still-parked transcripts from 28 that resumed after their refusal. PARTIAL WORK, committed so nothing is lost while the account allowance is exhausted. Still to come on this branch: - wiring into bin/fm-watch.sh so a park surfaces immediately as a named wake instead of waiting out a wedge timer, detected independently of the busy verdict; - wiring into bin/fm-crew-state.sh so recovery reads the cause instead of "harness busy"; - the portable regression and the opt-in live guard both required for a harness-dependent check, and the docs/verification/supervision.md entry; - the AGENTS.md state-file line for the new watcher marker. Nothing calls this library yet, so this commit changes no firstmate behaviour. * feat(bin): surface a worker parked on the account allowance A worker whose provider refused the turn on the account allowance keeps a live process, a live endpoint, and a normally rendered pane, so every liveness probe firstmate owns reads it as healthy and no wake fires. On 2026-08-17 two crewmates parked seconds after launch, their reset passed at 08:30, and nothing surfaced them until an unrelated wedge alarm happened to fire on one of the two panes two and a half hours later - and what it said then was "possible wedge", not the cause. Wire bin/fm-allowance-lib.sh into the two places that decide whether a worker needs attention: - bin/fm-watch.sh surfaces the park as a named wake that says what happened and that recovery is a single Enter, once per park episode (state/.allowance-<key> remembers what was already reported, and is dropped as soon as the worker is no longer parked). It runs ahead of the busy gate and independently of the busy verdict, because a refused turn need not close the turn-end hook that would mark the worker idle, in which case the pane reads as provably working indefinitely. It also runs ahead of the secondmate skip, from the structural signal alone, so an idle-by-design mate is covered without reading its pane. - bin/fm-crew-state.sh reports it as the crew's current state ahead of every other source, so recovery reads the cause rather than "harness busy". Detection only. Automatic resume once the reset passes is deliberately not part of this change: a resume that fires at the wrong moment is worse than a notification that reaches firstmate. tests/fm-allowance-park.test.sh pins the classifier and both integration points with real processes and no harness, including that either signal alone carries the verdict; reverting the two wired scripts fails three of its cases. tests/fm-allowance-park-live-e2e.test.sh is the opt-in drift guard over every installed harness, and docs/verification/supervision.md records the dated per-harness evidence and the command that refreshes it. * no-mistakes(review): fix(bin): stop allowance marker clearing on inconclusive empty-tail probe * no-mistakes(document): docs(architecture,scripts): document allowance-park's priority over crew-state and add script inventory row * no-mistakes: apply CI fixes * no-mistakes: apply CI fixes
fix(bin): refuse an unmergeable upstream pull request as a landing path
* fix(bin): read the required suite roster from the repository under test
FM_CI_REQUIRED_SUITES was a constant listing firstmate's own twelve CI job
names, so every other repository failed the completeness test by construction:
there is no roster to drift into on another repo, the roster simply does not
describe it. fm-pr-ci-verify.sh refused four consecutive real pull requests for
this reason, each independently hand-verified green, and fm-bearings-snapshot.sh
read every non-firstmate PR row as incomplete for the same reason.
fm_ci_roster now resolves the roster per repository and the classifiers take it
as an argument. jq refuses to compile a program whose variables are unbound, so
a caller that forgets the roster gets no verdict rather than a silent one, and
an empty roster classifies as incomplete rather than passing every green rollup.
Substitution flagged for review: the brief suggested reading job names from the
target repository's .github/workflows/ci.yml. That file is the definition but
not a roster, because a job name is a template GitHub evaluates ("Behavior
portable serial ${{ matrix.shard }}", or a matrix.include leg's
"${{ matrix.name }}"), so parsing it means reimplementing matrix expansion and
the Actions expression language. One of the three reported repositories needs
exactly that. The roster is therefore read by observation, from the job names of
the newest successful CI run on the branch the change targets, which GitHub has
already expanded exactly. No dependency is added: gh and jq only, both already
required. The cost is up to three GitHub API reads per repository per
verification. FM_CI_REQUIRED_SUITES survives as the documented override for a
change that deliberately adds or removes a CI job.
Verified: the derived roster for x45dev/firstmate is byte-identical to the
constant it replaces, and the three reported repositories plus the fourth field
case (home-fintech#76) now verify green, including workspace-template's six
expanded matrix.include legs.
* test: free the FM_HOME parameterization check from a live forge lookup
Commit 0dd2fc2 added a landing-target guard to bin/fm-pr-check.sh without
updating this pre-existing test, and main has been red since that work merged at
75267ef. The guard resolves whether this machine can merge into the target
repository and refuses to arm unless the verdict is mergeable or unchecked,
failing closed on unreachable by design.
tests/fm-secondmate-safety.test.sh predates that guard. Its FM_HOME
parameterization case calls fm-pr-check.sh with the fixture URL
https://github.com/example/repo/pull/1 purely to prove that FM_HOME scopes data
and state paths. No forge can resolve that repository, so the guard now exits 1
and the assertion fails before reaching the path checks the case exists for. The
test needs a forge stub because its intent is FM_HOME path isolation and never
landing authority, and the guard is behaving exactly as designed, so the test is
what needed changing.
The stub is deliberately the smallest thing that removes the dependency: a
gh-axi on PATH answering the repository permission read with one bare boolean,
the same contract the fake in tests/fm-pr-check-security.test.sh reproduces, via
the PATH="$fakebin:$PATH" convention this file already uses for tmux. The guard
still runs its own resolve path rather than being bypassed, no escape hatch is
added to the library, and the case goes back to asserting path isolation.
Verified: the fixture command exits 1 with the refusal "could not confirm
example/repo is a landing path" without the stub and exits 0 with it, and the
suite is 40/40 with bin/fm-lint.sh clean.
Supervision dropped silently and repeatedly in the primary home because the Stop-owned auto-arm published no evidence of its own existence until after its most expensive gate. Both Claude Stop hooks fire on the same event, so bin/fm-turnend-guard.sh --claude reached its verdict while bin/fm-claude-stop-autoarm.sh was still inside the identity gate, whose ancestry walk forks ps three times per hop over up to sixteen hops and measured 0.9 to 3.5 seconds against a nominal 800 millisecond cooperative window. The guard then printed that no recovery was under way while recovery was under way, and spent a forced continuation on it every turn. The fix is one cause in three parts. The auto-arm now publishes state/.claude-autoarm-claim after its three cheap read-only gates and before the identity gate, carrying its pid and process identity so the guard can trust it exactly as far as it trusts the owner lock. The guard accepts a live identity-matched claim, accepts the arming epoch outcome it previously dropped, and bounds its cooperative wait by elapsed wall clock rather than by a count of fork-heavy passes, which had stretched a nominal 800 milliseconds to 29.8 seconds at a real turn boundary. Two premises in the report were disproven by measurement rather than assumed. The asyncRewake hook does run when its blocking sibling exits 2, firing within about a millisecond of it, and the continuation turn does not start until that outstanding hook completes, so the next turn's start does not race the arm. Regression coverage runs the reproduction as real concurrent processes: a ps shim parks a real auto-arm inside its identity gate and the guard is asked for a verdict with the claim as the only evidence on disk, asserted both ways at the same instant so the claim is the whole difference. Because the verdict ultimately comes from harness-emitted output, the opt-in live guard now runs its whole session behind a slowed pid-query shim and proves from the delay log that the identity gate outlasted the cooperative wait. Two adjacent defects were fixed in passing rather than left silent. The test runner's coverage guard compared LC_ALL=C sorted inventories with a locale-sensitive comm, so it warned and failed on any host whose locale is not C; the live auto-arm regression still asserted that the model types the session start command, which the run-tier SessionStart hook has since made unnecessary, so that test could not pass at all.
The claim-publication fix is a harness-dependent behaviour, so its verdict has to be traceable to commands somebody else can rerun rather than to a session's recollection. This records the dated reproduction under the turn-end guard heading: the two premises measurement disproved, the identity-gate and cooperative-wait timings that opened the visibility window, the four portable regressions with the exact lines they emit against a pre-fix tree, and the opt-in live guard's Claude 2.1.234 result. It also records what did not run here. The repo lint gate exits 127 because actionlint is absent, so only its ShellCheck half is evidence, and the test runner's own suite cannot complete without ruby. Both are host gaps rather than results, and a verification file that stayed silent about them would read as a pass.
The elapsed-time regression added alongside the claim-ordering fix asserted the Stop hook's TOTAL wall clock against a 5 second ceiling, and failed on a loaded host while the behaviour it names was working. Varying only the budget on one fixture showed why. A budget of zero forbids every retry and the hook still spent 4.9 to 5.9 seconds; 800ms spent 6.2 to 7.1 and 3000ms spent 6.7 to 7.4. The wait is a minority of the hook's runtime, and the majority is fixed cost paid whatever the budget is: sourcing its libraries, the primary-scope checks, and on the blocking path the budget accounting and banner. The old assertion therefore measured that fixed cost, so it failed on load rather than on the defect, and its message named a cause that measurement disproves. The regression now differences a real budget against a zero one on the same host, which is exactly what the wait spent, and asserts both runs took the blocking path so the difference cannot be the path. Behind a sleep shim charging 3s per interval a deadline-bounded wait spends one interval (2.3 to 4.3s measured) and the pass-count loop it replaced spends eight (24.8s measured against a pre-fix tree), so the three-interval ceiling separates them by more than a factor of two in both directions. Two things the same measurement showed were corrected rather than softened. The guard's comment and docs/turnend-guard.md claimed the deadline makes the budget "mean what it says on every host"; it bounds the retrying only and is not a promise about how long the Stop hook takes, and one complete evaluation is irreducible because the guard cannot conclude a proof is absent without looking for all of them. The re-evaluation that followed the wait loop was also dead weight: the loop breaks only on the line directly after a failed evaluation, so that call repeated the pass just completed with no sleep in between and paid a second round of the fork-heavy checks and their budget accounting for nothing. The verification record now carries the corrected pre-fix output, the budget sweep behind these claims, and a third field sample from 2026-08-22 at 815 seconds of beacon staleness whose ledger held outcome=arming in the same second the guard declared the home unclaimed. The spread across 297, 390 and 815 seconds rules out a threshold-tuning fix. It also records that bin/fm-lint.sh now completes here at exit 0 with actionlint 1.7.12 present, where the earlier run's exit 127 was a missing tool rather than a result.
An unrelated firstmate home reported the same defect on 2026-08-22 without prompting, which is what establishes it as structural rather than local to one home or to any load condition there. It quoted beacon ages of 168 to 1001 seconds against real ages of 3 to 21 measured immediately afterwards, with the rewake counter advancing across all six firings and no failure marker present, and reached the same mechanism from its own evidence. It also separated this defect from the wake-queue lock deadlock, because nothing deadlocked and recovery always completed on its own. The record now also states the constraint that follows from the cost: a false alarm every time makes a genuine failure indistinguishable from the noise, so the fix must not buy quiet by weakening the predicate. It names the five cases that pin the no-arm no-watcher no-claim stop still blocking loudly.
Supervision dropped silently and repeatedly in the primary home because the Stop-owned auto-arm published no evidence of its own existence until after its most expensive gate. Both Claude Stop hooks fire on the same event, so bin/fm-turnend-guard.sh --claude reached its verdict while bin/fm-claude-stop-autoarm.sh was still inside the identity gate, whose ancestry walk forks ps three times per hop over up to sixteen hops and measured 0.9 to 3.5 seconds against a nominal 800 millisecond cooperative window. The guard then printed that no recovery was under way while recovery was under way, and spent a forced continuation on it every turn. The fix is one cause in three parts. The auto-arm now publishes state/.claude-autoarm-claim after its three cheap read-only gates and before the identity gate, carrying its pid and process identity so the guard can trust it exactly as far as it trusts the owner lock. The guard accepts a live identity-matched claim, accepts the arming epoch outcome it previously dropped, and bounds its cooperative wait by elapsed wall clock rather than by a count of fork-heavy passes, which had stretched a nominal 800 milliseconds to 29.8 seconds at a real turn boundary. Two premises in the report were disproven by measurement rather than assumed. The asyncRewake hook does run when its blocking sibling exits 2, firing within about a millisecond of it, and the continuation turn does not start until that outstanding hook completes, so the next turn's start does not race the arm. Regression coverage runs the reproduction as real concurrent processes: a ps shim parks a real auto-arm inside its identity gate and the guard is asked for a verdict with the claim as the only evidence on disk, asserted both ways at the same instant so the claim is the whole difference. Because the verdict ultimately comes from harness-emitted output, the opt-in live guard now runs its whole session behind a slowed pid-query shim and proves from the delay log that the identity gate outlasted the cooperative wait. Two adjacent defects were fixed in passing rather than left silent. The test runner's coverage guard compared LC_ALL=C sorted inventories with a locale-sensitive comm, so it warned and failed on any host whose locale is not C; the live auto-arm regression still asserted that the model types the session start command, which the run-tier SessionStart hook has since made unnecessary, so that test could not pass at all.
The claim-publication fix is a harness-dependent behaviour, so its verdict has to be traceable to commands somebody else can rerun rather than to a session's recollection. This records the dated reproduction under the turn-end guard heading: the two premises measurement disproved, the identity-gate and cooperative-wait timings that opened the visibility window, the four portable regressions with the exact lines they emit against a pre-fix tree, and the opt-in live guard's Claude 2.1.234 result. It also records what did not run here. The repo lint gate exits 127 because actionlint is absent, so only its ShellCheck half is evidence, and the test runner's own suite cannot complete without ruby. Both are host gaps rather than results, and a verification file that stayed silent about them would read as a pass.
…d elapsed-time wait
…guard block, and stale arming acceptance
…anscript with final guard fix
bin/fm-turnend-guard.sh now sources bin/fm-timing-lib.sh, but the synthetic primary directory that tests/fm-cursor-primary.test.sh builds copies a fixed list of bin scripts that did not include it. The guard died with a no-such-file error inside the fixture, so the duplicate-entry assertion saw output where it expected silence. Add the library to that copy list. It sources nothing further, so one file closes the gap.
…o current main The published branch was built on the pre-alignment base. This branch replays the same fix onto current origin/main and adds the Cursor fixture fix that the published head lacks. The eight files carrying the fix itself are byte-identical between the two lineages; the rest differ only by main having moved forward. Recorded as a merge so the published branch advances without a history rewrite.
|
Want your agent to iterate on Greptile's feedback? Try greploops. |
Intent
Supervision dropped silently and repeatedly in the primary firstmate home, and the turn-end guard blocked a turn on supervision mechanics while supervision was in fact never lost. Diagnose to root cause with an end-to-end reproduction before changing anything, then fix it in the shape the diagnosis supports.
Root cause found and fixed: both Claude Stop hooks fire on the same event, and the Stop-owned auto-arm (bin/fm-claude-stop-autoarm.sh) published no evidence of its own existence until after its identity gate, whose ancestry walk forks ps three times per hop over up to sixteen hops and measured 0.9 to 3.5 seconds against a nominal 800 millisecond cooperative window. The synchronous guard (bin/fm-turnend-guard.sh --claude) therefore reached its verdict while a healthy auto-arm was still starting, announced that no recovery was under way while recovery was under way, and spent a forced continuation every turn. The auto-arm now publishes state/.claude-autoarm-claim after its three cheap read-only gates and before the identity gate, carrying its pid and process identity; the guard accepts a live identity-matched claim, accepts the arming epoch outcome it previously dropped, and bounds its cooperative wait by elapsed wall clock rather than by a count of fork-heavy passes.
Hard constraint the captain restated twice, and the one that must not be traded away: the genuine failure case - no arm, no live watcher, no claim - must still block the turn loudly. A guard that stops crying wolf by no longer being able to bark is a regression, not a fix. The predicate must not be weakened into something that passes when supervision is genuinely absent, and threshold tuning was explicitly ruled out by evidence.
Deliberate decisions a reviewer reading only the diff would not know:
The claim record is a hint and never authority. It is trusted only while its publishing pid is alive and its process identity still matches, the same standard applied to the owner lock, so a dead publisher or a reused pid proves nothing. An auto-arm that cannot publish one still arms, and the guard falls back to the evidence it had before. The claim never advances the block budget, never substitutes for watcher health, and never reaches the failure progression.
The gate reordering in the auto-arm is deliberate and load-bearing: the claim is published after the scope, away-mode and need gates specifically so an idle or away home stays byte-for-byte inert exactly as before.
Two premises in the original report were disproven by measurement rather than assumed, and are recorded as such: the asyncRewake sibling does run when its blocking sibling exits 2, firing within about a millisecond of it, and the continuation turn does not start until that outstanding hook completes, so the next turn's start does not race the arm. The designed gap - a Claude home being unwatched for the duration of every turn - is separate and remains; the reproduction distinguished it from the real defect.
A later measurement corrected part of the first fix rather than softening it. The elapsed-time regression originally asserted the Stop hook's TOTAL wall clock against a 5 second ceiling and failed on a loaded host while the behaviour it named was working. Varying only the budget on one fixture showed why: a budget of zero forbids every retry and the hook still spent 4.9 to 5.9 seconds, so the wait is a minority of the hook's runtime and the majority is fixed cost paid whatever the budget is. The test now differences a real budget against a zero one on the same host, which is exactly what the wait spent, and asserts both runs took the blocking path so the difference cannot be the path. Behind a sleep shim charging 3s per interval a deadline-bounded wait spends one interval (2.3 to 4.3s measured) and the pass-count loop it replaced spends eight (24.8s measured against a pre-fix tree).
Following from that same measurement, two claims were made honest rather than merely softened: the guard comment and docs/turnend-guard.md had said the deadline makes the budget "mean what it says on every host", when it bounds the retrying only and one complete evaluation is irreducible because the guard cannot conclude a proof is absent without looking for all of them. The re-evaluation that followed the wait loop was also removed as dead weight: the loop breaks only on the line directly after a failed evaluation, so that call repeated the pass just completed with no sleep in between and paid a second round of fork-heavy checks and budget accounting for nothing.
The final commit is a merge of the previously pushed head bde09561, chosen by the captain over rebasing. PR 2584 was opened from that head and must stay open; merging makes this head its descendant so the PR updates by fast-forward with nothing forced and nothing discarded, and recovers the pipeline's orphaned document-step commit. That commit's correction to the FM_CLAUDE_AUTOARM_SYNC_WAIT_MS line in docs/configuration.md was reworded rather than replayed, because describing the budget as what the guard "waits" would have reintroduced the overstatement this branch removes everywhere else.
Evidence expectations: because the verdict ultimately comes from harness-emitted output, this ships both a portable regression in tests/ that reproduces the window with real concurrent processes and an opt-in live guard exercising the real harness, per the repo's harness-dependent-checks rule. Verification prose lives in docs/verification/supervision.md and records what did not run as well as what did. An earlier CI run on this branch failed in the portable serial test lane with its auto-fixer blocked three times by a session limit; that is consistent with the old total-runtime assertion failing under CI load, which this change fixes, but it has not been confirmed from the CI log.
Two adjacent defects were fixed in passing rather than left silent: the test runner's coverage guard compared LC_ALL=C sorted inventories with a locale-sensitive comm, and the live auto-arm regression still asserted that the model types the session start command, which the run-tier SessionStart hook has made unnecessary.
Out of scope by explicit instruction: the wake-queue lock dead-holder steal in bin/fm-wake-lib.sh and the detection of workers parked on the account allowance, both owned by other workers. The queued item fm-watch-confirm-window-guard-conflict is the same class (a fixed window measured against unbounded load) but needs its own remedy and must not be absorbed here; the queued item fm-turnend-guard-races-async-arm is this same defect and is resolved by this change.
What Changed
bin/fm-claude-stop-autoarm.shnow publishesstate/.claude-autoarm-claim(pid + process identity) after its scope/away-mode/need gates but before the identity-ancestry walk, so a healthy auto-arm has visible evidence during the 0.9-3.5s the walk takes;bin/fm-turnend-guard.shaccepts a live, identity-matched claim as evidence recovery is under way, falling back to prior evidence when the claim is stale, dead, or absent.bin/fm-turnend-guard.sh's cooperative wait is now bounded by elapsed wall-clock time instead of a fixed pass count, and the dead re-evaluation pass that repeated the just-completed check with no sleep in between was removed;bin/fm-timing-lib.shsupports the elapsed-time bound.bin/fm-test-run.shfixes a locale-sensitivecommcomparison in the coverage guard (nowLC_ALL=C), and the live auto-arm regression test drops an assertion that the model types the session-start command, since the run-tier SessionStart hook makes it unnecessary.tests/fm-turnend-guard.test.sh,tests/fm-claude-stop-autoarm.test.sh, andtests/fm-claude-stop-autoarm-live-e2e.test.shfor the claim-publish ordering, competing-session claim handling, and elapsed-time-bounded wait; documents verification and configuration updates indocs/verification/supervision.md,docs/turnend-guard.md,docs/configuration.md, andAGENTS.md.Risk Assessment
✅ Low: All three previously identified issues (the competing-session claim race, the duplicate guard block, and the over-permissive stale-arming acceptance) were fixed exactly as scoped - a bounded, local ownership pre-check that declines to publish on any inconclusive result, one collapsed duplicate block, and a corrected outcome case with its test properly inverted rather than deleted - with docs and regression tests updated consistently and no new issues introduced.
Testing
Targeted regression tests for both fixes in this change (Claude Stop claim-ordering/elapsed-time wait, and the LC_ALL/comm coverage-guard locale bug) all pass, including the new real-process incident reproductions and the competing-session claim-race guard; the sole failure in tests/fm-test-run.test.sh is a pre-existing, undisclosed-by-this-branch missing-ruby environment gap already called out in the shipped verification doc, and a live run of
bin/fm-test-run.sh --check-coverageon this host's non-C locale directly reproduces the doc's claimed product-level evidence that the coverage guard now works.Evidence: bin/fm-test-run.sh --check-coverage output under live non-C locale
FM_TEST_COVERAGE ok total=154 parallel=24 serial=118 serial_shards=4 herdr=12 locale: LANG=en_US.UTF-8 LC_ALL=<unset>Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
🔧 **Rebase** - 2 issues found → auto-fixed ✅
bin/fm-turnend-guard.sh- merge conflict rebasing onto origin/maindocs/turnend-guard.md- merge conflict rebasing onto origin/main🔧 Fix applied.
✅ Re-checked - no issues remain.
🔧 **Review** - 2 issues found → auto-fixed ✅
bin/fm-claude-stop-autoarm.sh:165- claim_publish() (bin/fm-claude-stop-autoarm.sh:148-166) now runs before the identity gate (bin/fm-claude-stop-autoarm.sh:174-181), and that identity check calls fm_session_lock_owned_by_self(), which itself performs the expensive fm_harness_ancestry_pids() walk (bin/fm-session-lock-lib.sh:163-176, same 3-forks-per-hop/16-hop walk the whole fix is built around). So any Claude Stop-hook firing that passes the home-scoped scope/AFK/need gates - including one from a session that does NOT own state/.lock ('a competing session', explicitly named as a defended-against case in this file's own header comment) - will publish a live, identity-matched claim to the shared $STATE/.claude-autoarm-claim for the full duration of its own identity-gate walk (documented elsewhere in this diff as 0.9-3.5s) before discovering it isn't the owner and exiting 0 (trap releases the claim only then). fm-turnend-guard.sh's autoarm_claim_in_progress() (bin/fm-turnend-guard.sh:276-284) only checks pid liveness + fm_pid_identity match, not ownership of state/.lock - it cannot distinguish this transient competing-session claim from a genuine owning arm. Concrete sequence: two Claude Code processes are open against the same primary checkout (session A owns state/.lock, session B does not); the home genuinely has no watcher, no owner lock, no fresh epoch (a genuine 'no arm, no live watcher, no claim' state for A's turn); session B's own unrelated Stop event fires the autoarm hook concurrently, passes the home-scoped gates, and publishes its own live claim; if session A's turnend-guard evaluates during that window it reads B's claim as 'recovery under way' and allows A's stop silently, with no continuation forced and no banner - even though nothing is actually arming supervision for A's turn. This is the same class of silent-drop-while-reporting-fine failure the branch sets out to fix, just triggered by a second concurrent session rather than gate latency. The user intent's hard constraint ('no arm, no live watcher, no claim - must still block the turn loudly ... must not be weakened into something that passes when supervision is genuinely absent') does not appear to account for this path, since the claim's authenticity is unverified during exactly the window it is now published early to cover. A cheap ownership check isn't obviously available (the whole reason for the walk is that the owning pid can sit at an unknown, per-harness-variable depth in Claude's nested process tree), so this needs the author's judgment on whether the residual race is acceptable (self-bounded to a single missed continuation per coincidental collision) or needs a mitigation.bin/fm-turnend-guard.sh:303- autoarm_owns_recovery() contains two byte-for-byte identicalif autoarm_claim_in_progress; then ... fiblocks back to back (lines 303-306 and 307-310). Tracing the branch history, commits c0216f3 and 61f5f59 ('fix(bin): publish the Claude auto-arm claim before its identity gate') each independently added this same hunk, and both landed in the final tree - almost certainly a rebase/cherry-pick artifact rather than intentional. It's functionally harmless (the second call is idempotent and just re-reads the same claim file), but it's dead duplicate code that should be collapsed to one block.🔧 Fix: Address competing-session claim race, duplicate guard block, and stale arming acceptance
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bash tests/fm-turnend-guard.test.sh— all 70 cases pass, includingtest_hook_claude_mode_early_claim_is_the_whole_difference(real concurrent auto-arm parked inside its identity gate via a ps shim, guard forced-blocks without the claim and allows with it, and the forced-continuation budget does not grow on the claimed run),test_hook_claude_mode_claim_requires_live_matched_publisher(dead-publisher and reused-pid claims are rejected; a live identity-matched claim is accepted),test_hook_claude_mode_dead_arming_epoch_blocks, andtest_hook_claude_mode_wait_is_bounded_by_elapsed_time(differences a real vs zero SYNC_WAIT_MS budget behind a 3s/interval sleep shim and asserts the deadline-bounded wait spends about one interval, not eight)bash tests/fm-claude-stop-autoarm.test.sh— all 31 cases pass, including the two new competing-session claim-race regressions:test_claim_observable_during_identity_walk_when_ownerandtest_competing_session_never_publishes_a_claimbash tests/fm-test-run.test.sh— 16/17 pass includingtest_list_all_exact_suite_coverageandtest_portable_shard_union_and_coverage_guard(both exercise the LC_ALL=Ccommfix); the one failure (test_herdr_ci_family_run_has_a_step_timeout) requiresruby, which is absent on this host and unrelated to this change (confirmed the test function is untouched in the diff, and the same host gap is already recorded in docs/verification/supervision.md)bin/fm-test-run.sh --check-coveragerun directly under this host's live en_US.UTF-8 locale (non-C) — reproduces the exactFM_TEST_COVERAGE ok ...product output recorded as evidence in docs/verification/supervision.md, directly demonstrating the locale-sensitive comm bug is fixed✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.