Repository navigation
fix(bin): rework watcher signal triage to decide-first, side-effect-after - #56
Merged
Merged
Conversation
* feat(bin): retire completed PR-check migration machinery Every registered home already carried both completion markers, and no installer still creates pre-migration checks. Remove the one-time migrate script, its bootstrap/watch/teardown/docs surface, and migration-path tests without weakening live check-trust or PR-poll authentication. * no-mistakes(review): Restore live PR-check security coverage * no-mistakes(document): Refresh retired PR-check documentation * no-mistakes(ci): Fixed both failing CI checks. Updated inactive-reconcile setup to use the public status-marking interface, preventing false watcher exits. Made remote-job shutdown deterministic by stopping the complete worker tree before tampering. Verified both affected test suites, repeated inactive reconciliation, shell syntax, and git diff checks
* fix(records): pair backlog transitions with the record that moves Dispatch and completion each moved a task's physical record and its backlog row as two independently timed steps, so a crash or a forgotten follow-up could leave the two disagreeing: a record with no in-flight row, an in-flight row with no owner, or a finished task still shown in flight. Fold each backlog transition into the script that performs the physical change, under the per-task lock it already holds and before it reports success. Dispatch moves the item to In flight after publishing the task record and fails loudly, removing its provisional record, when that transition cannot land. Completion records an authoritative close and performs it before removing the record, so an interrupted cleanup can be finished later, and its closing message now confirms what already happened rather than instructing a future step. Add a same-home reconciliation sweep to session start so a home that was interrupted mid-transition settles its own books on restart, replaying a recorded close and restoring an in-flight row it already owns a worker for. It never reads or writes another home; the fleet snapshot and the cross-home nudge stay as backstops. Close records are validated before they are trusted: the file is read as raw bytes and rejected outright when it carries a NUL or other control byte, every field must be well formed and non-duplicated, the id must match the record it was found under, the data location must resolve inside this home, and each close argument must carry a permitted, well-formed value. Writer and reader share one validator so a record this home publishes always remains replayable, independent of locale. Homes configured for a manual backlog, and homes with no backlog at all, stay exempt and are unaffected. * no-mistakes(review): Remove stale bootstrap migration helper invocation * no-mistakes(review): Preserve pending closes and narrow signal deferral * no-mistakes(review): Record close before destructive teardown * no-mistakes(review): Refuse pending closes before creating resources * no-mistakes(review): Guard relaunches and preserve cleanup warnings * no-mistakes(review): Reject symlinked records and clarify cleanup guidance * no-mistakes(review): Align dispatch eligibility and protect close replay * no-mistakes(review): Unify exact task incarnation parsing * no-mistakes(review): Render resolved configured backlog path * no-mistakes(review): Harden transition path boundaries against symlinks * no-mistakes(review): Validate lifecycle state before resource actions * no-mistakes(review): Enforce transition tooling and continuous state locks * no-mistakes(review): Consolidate same-home lifecycle file boundaries * no-mistakes(review): Enforce canonical lifecycle containment and tooling contracts * no-mistakes(review): Reject final-component lifecycle record symlinks * no-mistakes(document): Document lifecycle record path boundaries * no-mistakes(lint): Quote literal done tokens in atomicity tests * no-mistakes(ci): Fixed all PR-caused CI failures: bootstrap now treats an absent state directory as an empty fresh home while retaining unsafe-state checks; nested remote secondmate retirement accepts records already removed with the retired home; teardown fixtures now provide valid data/manual-backend configuration; and the manual reminder assertion checks the configured absolute backlog path. Verified the reported tests, remote lifecycle E2E, backlog atomicity suite, Bash syntax, diff checks, and ShellCheck. The documented pre-existing captain-hold failure was intentionally untouched * no-mistakes(ci): Fixed Behavior portable serial 3 by adding `od` to the teardown test’s lsof-free PATH fixture. The new close-record validator legitimately requires `od`; its omission caused teardown to fail before process-group cleanup and stall the shard. Verified the full `tests/fm-teardown.test.sh` suite passes, plus Bash syntax, ShellCheck, and `git diff --check` * no-mistakes(ci): Fixed close replay to durably retain incomplete-cleanup evidence before removing task metadata. Subsequent retries now emit the reconciliation warning even after a backlog probe or close failure. Updated the behavioral regression and verified the full atomicity suite under stock macOS Bash 3.2, plus shellcheck and diff checks * fix(records): validate record bytes without an uncurated tool The byte validation added for close records and directory paths shelled out to od. The spawn and teardown lifecycle runs under a curated command set that deliberately excludes it, so on any restricted PATH the check could not run, the data directory read as unresolvable, and dispatch and cleanup refused - wedging the lifecycle rather than protecting it. An earlier attempt made the failing test pass by adding od to that curated set. That fixed the test to agree with the defect and quietly widened the contract the fixture exists to pin, so it is reverted here. Inspect the bytes with perl instead, which is already in the curated set and already used in this repo for the same portability reason. The emitted values are identical to od's, so the rejection semantics are unchanged: NUL and other control bytes are still refused, legitimate paths containing spaces or non-ASCII characters still round-trip, and the check stays independent of the process locale. The restricted-PATH teardown case now passes because the validator no longer needs od, not because the fixture was loosened. * no-mistakes(review): Enforce dispatch eligibility and atomic remote record publication * no-mistakes(document): Document dispatch eligibility and cleanup alerts
* fix(watch): absorb a turn-end whose pane churned since the previous poll The watcher's "absorb a benign turn-end when the crew is provably working" triage was structurally unreachable for any harness whose semantic busy state has no verified source. crew_absorb_class only reports working for an actively running no-mistakes step or an exact busy verdict, and bin/fm-crew-state.sh can only answer unknown for such an adapter, so codex crewmates surfaced a signal wake at every turn boundary with nothing to act on - a full supervisor drain, inspect and acknowledge turn per worker turn, scaling with the number of workers in flight and drowning the wakes that matter in identical noise. Widen the proof rather than bound the wake rate. A wake carrying only bare turn-ended markers is now also benign when the task's pane content changed since the previous poll, compared against the same state/.hash-* marker the staleness backbone already records and already trusts as liveness. That evidence claims no harness semantics, so it fabricates no busy verdict an adapter has not earned, and it needs no adapter cooperation. Absorb stays evidence-driven in both directions. A wake naming any status file keeps the strict proof, every captain-relevant verb still surfaces immediately, and an unresolvable task, a missing prior hash, a failed or empty capture, or an unchanged pane all surface exactly as before. The absorb defers rather than swallows: a crew that has stopped renders nothing further, so its now-static pane surfaces through the staleness backbone within a poll or two. Bounding the surfacing rate instead would have suppressed genuinely stopped workers. The derivation lives with the .hash-* marker format in bin/fm-watch.sh, which owns it, and costs one bounded capture reached only for a no-verb turn-end whose crew is not already provably working. * no-mistakes(review): Captain, guard pane-churn absorption from collisions and secondmates * no-mistakes(review): Captain, make watcher marker identities injective * no-mistakes(review): Captain, isolate ambiguous legacy markers and restore Herdr sourcing * no-mistakes(review): Captain, localize pane-churn collision guard * no-mistakes(review): Captain, reject malformed pane-churn hashes * no-mistakes(document): Document pane-churn turn-end evidence * no-mistakes: apply CI fixes * fix(watch): gate and bound the pane-churn turn-end absorb Make the pane-churn form of positive work evidence opt-in per home and bound how long it may defer one endpoint's bare turn-ends. Absorbing a bare turn-end on pane churn is now reached only when the home creates config/turnend-churn-absorb. The other two proofs read a verdict the harness itself vouches for, while this one infers execution from rendered bytes, so widening the absorb is a home's choice rather than a default every fleet inherits. With the flag absent the predicate returns on its first line and triage is unchanged. Churn and pane staleness read the same pane, so neither can be the other's only backstop. A pane that renders continuously never presents the two consecutive identical hashes the staleness backbone needs, so an unbounded churn absorb left a worker that had genuinely stopped behind such a renderer with no path to surface at all. One endpoint's turn-ends may now ride churn evidence for at most FM_TURNEND_CHURN_ABSORB_SECS, tracked in state/.churn-since-*, after which the wake surfaces and the window restarts. The bound is evaluated before any .stale- state is touched, so a wake that surfaces there leaves the staleness backbone's own classification alone. Covers both with behavioral tests: the same churning fixture that absorbs with the flag surfaces and queues without it, and a spent deferral window surfaces and restarts. The four existing safety guards now run with the flag enabled so they keep proving their specific guard. * no-mistakes(review): Fail closed on invalid churn deferral state * no-mistakes(review): Validate persisted churn deadlines before arithmetic * no-mistakes(review): Make churn deadlines transactional and bounds safe * no-mistakes(review): Compose turn-end evidence per task from one snapshot * no-mistakes(review): Restore strict turn-end fallback guards * no-mistakes(document): Clarify pane-churn supervision documentation * no-mistakes(lint): Fix watcher arithmetic lint issues * no-mistakes: apply CI fixes * no-mistakes(document): Clarify pane-churn fail-closed documentation * fix(bin): prioritize active pipeline-owned crew runs (#3194) * fix(bin): bind the live pipeline-owned run instead of a superseded failed row fm-crew-state.sh bound a superseded FAILED no-mistakes run to a task instead of the LIVE replacement run: the live run's pipeline-owned lane head is not a git object in the task worktree, so head-equality attribution rejected it and the coarse runs-list fallback silently continued past the RUNNING row onto an older failed row whose head equalled the stale worktree HEAD. The home summary then flipped invalid and Bearings hid the home's live work (F10). Attribution precedence now follows the daemon's own identity: - An ACTIVE run for the task's branch binds without head equality while branch_sync.state is pipeline_owned (fm_nm_run_is_pipeline_owned_active); the pipeline owning the branch is itself the attribution. - A genuinely failed run with no later run on the branch still reports failed through the unchanged head-equality path - real failures are not hidden. - In the coarse runs scan, an unresolvable head is unknown attribution and stops the scan (fm_nm_head_resolvable) instead of falling through to an older row; a resolvable-but-mismatched head keeps the historical reused-branch skip. The exemption never applies to a terminal run and requires pipeline_owned specifically, both pinned by negative-control tests. Fixture shape verified against the live incident run's real axi status output. * no-mistakes(document): Updated run-attribution documentation ownership * no-mistakes(review): Captain, make watcher marker identities injective * no-mistakes(review): Captain, localize pane-churn collision guard * no-mistakes(review): Compose turn-end evidence per task from one snapshot * no-mistakes(review): Restore strict turn-end fallback guards * no-mistakes(document): Align pane-churn watcher documentation * no-mistakes(ci): Captain, fixed the flaky cooldown boundary test by freezing its executable clock. The failure reproduced before the fix and passed five consecutive full-suite runs afterward. Extended ShellCheck passed; full lint stopped because actionlint 1.7.12 is not installed --------- Co-authored-by: Kun Chen <[email protected]>
The upstream-sync merge interleaved two mechanisms that both answer "was this status change already delivered?": the local process-event coverage-deferral verdict and upstream's surface evidence. Deciding and side-effecting were interleaved, so a cycle could mark a file surfaced and then absorb it with no queue record, re-read a coverage stamp mid-cycle and flip its own verdict, and advance a .seen marker in a format scan_signals no longer reads back. Compose them in one order instead: - Coverage verdicts are computed once per file per cycle with no side effects, so no append landing mid-cycle can flip a verdict already used. - signal_files_actionable stays a pure predicate and now runs before the away-mode short-circuit, so surface endpoints are classified identically on every path that can enqueue. - Surface evidence is written only for a file this cycle actually enqueues, immediately before its queue record (mark_signal_surfaced). - A .seen marker advances only once that file's own enqueue-or-absorb decision is final, and a .status marker is committed through its owning presentation-marker API rather than as a raw signature. Fixes the flaky failure in tests/fm-watch-arm.test.sh whose successor re-reported an already-delivered signal because its marker was written in the pre-merge raw format.
…orb marker contracts
…onability verdict
…e reported commit
…es; dedupe doc section
… decision Mirror the enqueue branch's decided gating in the benign branch: a procevent-covered file's reported signature now advances only after signal_covered_absorbable rules its absorb, so a refused absorb leaves the file unsuppressed for the next scan instead of silently dropped. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01H244iqDzBHsZ2JgQ7nQnKL
… in watcher triage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Rework the watcher signal-triage block in bin/fm-watch.sh (and signal_files_actionable) to fix a reproduced ordering race that made tests/fm-watch-arm.test.sh's 'handling drain stopped its live successor' scenario fail flakily. Implement the accepted 'decide first, side-effect after' composition of local coverage-deferral absorb semantics with upstream surface-evidence semantics: (1) compute coverage verdicts once per file per cycle with no side effects and a single stamp read; (2) make the actionability probe a pure predicate with mark_surfaced stripped out; (3) write surface evidence via mark_surfaced only for files actually being enqueued, immediately before fm_wake_append; (4) advance .seen/reported markers only after the enqueue-vs-absorb decision for that exact file is final (covered files' reported-marker advance gated on the final absorb decision). Scope is strictly this triage block plus its tests and docs; the rest of upstream-merge commit 9049a19 is untouched. Acceptance evidence already gathered: tests/fm-watch-arm.test.sh and tests/fm-wake-pair-dedup.test.sh each looped >=10x consecutively green (races require looped proof); tests/fm-watch-triage.test.sh's churning-pane failure is confirmed pre-existing on base and tracked separately (out of scope, as are the pre-existing ~250ms test-deadline flake and the unverified pure-contract-unit/unclassified stragglers needing a separate full-suite A/B against 91f80b7). This branch (fm/watch-arm-signal-triage-rework-v3) is a captain-authorized rename of fm/watch-arm-signal-triage-rework at the identical validated head, created solely to sidestep a wedged stale pipeline custody record on the old branch name; the content already passed review in prior runs, and a previously raised arm-test-coverage-claim ask-user finding was approved with no code change. Follows firstmate-coding-guidelines for shared tracked material.
What Changed
bin/fm-watch.shso coverage verdicts are computed once per file per cycle from a single stamp read with no side effects, andsignal_files_actionablebecame a pure predicate (mark_surfacedstripped out); surface evidence is now written only for files actually enqueued, immediately beforefm_wake_append, and.seen/reported markers advance only after that file's enqueue-vs-absorb decision is final — covered files' reported-marker advance gated on the final absorb decision. This removes an ordering race that made the arm test's "handling drain stopped its live successor" scenario fail intermittently.tests/fm-watch-triage.test.shfor the mixed covered-plus-benign scan (no wake, no queue record, classified position committed) and intests/fm-watch-pc02-cadence.test.shfor the byte-scoping predicate; documented the new absorb and byte-scoping invariants indocs/architecture.mdanddocs/verification/process-event-sources.md.Risk Assessment
✅ Low: The change is a well-bounded rewrite of one triage block that matches its authoritative intent point-for-point, keeps absorb decisions byte-scoped and marker advances gated on final decisions, and adds behavioral tests for both the mixed covered/benign scan and the new scoping predicate.
Testing
Exercised the reworked triage at the level an operator sees it: a live fm-watch.sh against a mixed procevent-covered + benign status set produced no wake on stdout, no .wake-queue record, and two separately-reasoned absorb lines in state/.watch-triage.log — and the same scenario fails on the base commit's watcher ('surfaced instead of absorbing'), so the new test is a real before/after regression proof rather than a passing add-on. The ordering race was proven the way a race must be: tests/fm-watch-arm.test.sh ran 10 consecutive times fully green with zero 'not ok' lines across all runs, its successor-drain scenario passing every time. The verdict-extent scoping predicate is covered green by the new unit in fm-watch-pc02-cadence.test.sh (whole file passes). The one gap: tests/fm-wake-pair-dedup.test.sh cannot run on this host — its process-event fixture never captures a result, failing at the first assertion before the watcher starts, identically with the base watcher swapped in and with the sandbox disabled, so it is pre-existing and unrelated to this change but leaves that piece of the cited acceptance evidence unreproduced. No UI surface is involved; the product surface here is a CLI watcher, and it is captured as a transcript artifact. The pre-existing churning-pane triage failure and other out-of-scope flakes named in the intent were not re-litigated.
Evidence: Covered-absorb watcher transcript (no wake, no queue record, separate triage reasons)
Source: Covered-absorb watcher transcript (no wake, no queue record, separate triage reasons)
=== watcher stdout (empty = no wake surfaced to firstmate) === [stdout bytes: 0] === <state>/.wake-queue (durable wake records) === [empty: nothing enqueued] === <state>/.watch-triage.log (operator-facing triage record) === [2026-09-04T08:29:09-0400] absorbed benign signal: <state>/benign.status [2026-09-04T08:29:09-0400] absorbed procevent-covered signal: <state>/covered.statusEvidence: Base-vs-target A/B of the covered-absorb triage behavior
Source: Base-vs-target A/B of the covered-absorb triage behavior
-- BASE be8320bd bin/fm-watch.sh -- ok - a no-verb signal whose crew is provably working is absorbed ... ok - a benignly absorbed .status commits a parseable presentation marker and stops re-signalling not ok - the mixed covered+benign scan surfaced instead of absorbing: signal: .../benign.status .../covered.status -- TARGET 8bc5dbb bin/fm-watch.sh -- ok - a no-verb signal whose crew is provably working is absorbed ... ok - a benignly absorbed .status commits a parseable presentation marker and stops re-signalling ok - a procevent-covered status absorbs beside a benign sibling: no wake, no queue record, markers advanced, absorbs logged under separate reasonsEvidence: fm-watch-arm.test.sh 10x consecutive loop (race proof)
Source: fm-watch-arm.test.sh 10x consecutive loop (race proof)
run 1..10 exit=0 (all green) run 1..10: ok - watch-arm: a wake queued after handling drain is recovered once at successor arm total 'not ok' lines across all 10 runs: 0Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-watch.sh:2168- Benign-branch covered handling is driven off the FM_SIGNAL_SURFACE_ENDPOINTS loop, so a covered file the probe could not classify (status_span_first_actionable_record rc=2, e.g. the log becomes transiently unreadable between the coverage read and the probe) has no endpoint row and is skipped by every pass in that branch: its reported and seen markers stay put and it re-scans on each poll cycle. The enqueue branch at bin/fm-watch.sh:2054 handles the same case (empty endpoint is treated as absorbable, so the reported marker advances and bounds it to one report per file state). Self-healing and wake-free, so no action needed; noting the asymmetry only.tests/fm-wake-pair-dedup.test.sh:66- tests/fm-wake-pair-dedup.test.sh cannot run on this host: its fixture (seed_captured_procevent_result) never captures a process-event result — the detached fm-procevent.sh runner produces no .result, so the suite fails at its first assertion ("the fixture captured no process-event result") in 10/10 attempts. Confirmed pre-existing and unrelated to this change: it fails identically with the base (be8320b) bin/fm-watch.sh swapped in, and the failure happens before the watcher is ever started; fm-procevent.sh, fm-procevent-lib.sh and the test file are unchanged on this branch. The intent cites this suite as looped-green acceptance evidence, so that portion of the evidence could not be reproduced here — the user should decide whether the host's process-event runner environment needs fixing or whether the prior run's evidence stands.bash tests/fm-watch-arm.test.sh— 10 consecutive runs, all green, including the race scenario 'a wake queued after handling drain is recovered once at successor arm' that carries the 'handling drain stopped its live successor' assertionA/B of the new covered-absorb behavior: temp subset runner of tests/fm-watch-triage.test.sh (test_provably_working_signal_absorbed,test_benign_absorb_marker_is_presentation_record,test_covered_status_absorbs_beside_benign_sibling) run against base be8320bd bin/fm-watch.sh (covered test FAILS: 'surfaced instead of absorbing') and against target 8bc5dbb (all pass)bash tests/fm-watch-pc02-cadence.test.sh— full file, green, including the newtest_covered_absorbable_scopes_to_verdict_extentunit covering the verdict-extent byte scopingManual watcher run of the mixed procevent-covered + benign fixture, capturing the real watcher stdout, .wake-queue and state/.watch-triage.log as an operator-visible transcriptbash tests/fm-wake-pair-dedup.test.sh— run alone, 10x looped, with sandbox disabled, and with base bin/fm-watch.sh swapped in: identical fixture failure in every case (pre-existing/environmental)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.