Repository navigation
fix(watch): require two quiet signals before a wedge escalation - #107
Merged
Merged
Conversation
An idle terminal pane was treated as proof that a worker had wedged. It is not. A worker doing its real work inside a no-mistakes run renders nothing in its pane for the run's whole duration, and a worker firstmate deliberately stopped on a green PR has no live agent at all. Both shapes escalated through the wedge ladder, and each false alarm cost firstmate a full handling turn: five mid-run workers on 2026-09-01, and three stopped green-PR workers on 2026-09-09 that reached escalation level 3 with a `paused: [key=await-merge]` line sitting at the end of each status log. A pane-idle worker now escalates only when its second signal is quiet too. The measured cause of the 2026-09-09 batch differs from the one the report assumed. Those workers did not read `done`. Reading the live fleet through fm-crew-state.sh, all three reported `state: working · source: run-step · validating (running)`, because a no-mistakes run keeps its ci step running for as long as the PR stays open. pause_state_class honored that verdict ahead of the worker's own declared pause and absorbed the pane as provably-working, which starts the wedge timer. So a `working` verdict now proves only that a run exists, never that it is moving. It outranks a declared pause only while the run's own last activity is still inside the stale window. That activity comes from the active_steps table's last_activity column rather than the run's top-level status: verified against the installed binary, a worker stopped on a green PR reports `status: running` after 15h29m with its last activity "quiet 51m55s ago", so reading the top-level status would mark every such worker permanently active and suppress its escalation forever. An unanswerable probe (no worktree, no no-mistakes, no active_steps table) leaves existing run evidence trusted rather than reading silence as proof the run stopped, which keeps a genuinely frozen run escalating. Three further changes complete the rule: - The declared-pause gate required a confidently `dead` agent, which no unverified backend and no unreadable record can report; both answer `unknown`. Those workers fell through to the wedge ladder despite their own `paused:` line. Only a live agent overrides a declared pause now, since only a live agent could still be silencing a decision gate. - A gone agent whose last status announced a green PR and whose merge watch is armed is a finished worker awaiting its merge, not a wedge. - wedge_timer_check reads pipeline activity at the escalation threshold and restarts the timer instead of escalating when a run is still moving. The read is bounded like every other watcher check, and a task with no delivery mode drives no pipeline and skips it entirely. A genuinely dead worker with no pause, no armed watch, and no live pipeline still escalates exactly as before. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WKCybnU6Sk9XSapj4jsW9D
…d, bound step scan
|
Warning Review limit reachedNext included review available in 59 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (7)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
EvanAgee
added a commit
that referenced
this pull request
Sep 22, 2026
Refs #1 Refs #42 Refs #60 Refs #65 Refs #73 Refs #74 Refs #107 Refs #109 Refs #117 ## What I walked In a throwaway `.scratch-c4-walk/home` and local Git repository: ``` $ FM_HOME=.scratch-c4-walk/home bin/fm-merge-local.sh walk-clean merged fm/walk-clean into local main (aa84759 -> 1b9c678) in /Users/evanagee/.treehouse/firstmate-df5ff1/9/firstmate/.scratch-c4-walk/project $ git -C .scratch-c4-walk/project log -1 --format=%s main clean local landing ``` ``` $ FM_HOME=.scratch-c4-walk/home FM_GH_BIN=.scratch-c4-walk/fake-gh bin/fm-flow.sh walk status matched rulesets: main-protection=1 (rules: pull_request,required_status_checks) review=2 (rules: pull_request) registry posture: [no-mistakes-prod-only +yolo] main-protection ruleset 1 enforcement: active main-protection ruleset gates: pull_request + required_status_checks present review ruleset 2 enforcement: active stored previous posture: <none> verdict: full ``` ``` $ FM_HOME=.scratch-c4-walk/home bin/fm-merge-local.sh walk-outage fm/walk-outage error: task walk-outage is mode=no-mistakes; a PR-bound task lands locally only while GitHub is unreachable (state/.github-down present) merge its PR with bin/fm-pr-merge.sh after approval exit=1 ``` The flow status used a local fake that returned read-only ruleset data. No GitHub request, PR, or push was made. ## Port record The root already had guarded `fm-pr-merge.sh` and `fm-merge-local.sh`, canonical v2 PR poll registration and repair, GitLab merge verification, task control locks, leases, captain holds, and persisted merge authority. During the final rebase, the root also gained the outage landing skill unchanged. I kept those root implementations. The port adds auto-arm, reviewer chase, review-thread gating, issue claims and post-merge closing, GitHub outage landing and return sync, and the project flow switch around them. I dropped the fork's obsolete `captain-merge` token, `fm-pr-check-migrate.sh`, and C3 delivery timing, backfill, and token ledger changes. The root's captain-hold authority and repairable poll publication cover those seams.
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
Fix the watcher's false wedge alarms in bin/fm-watch.sh, which flags a worker as 'possible wedge' and escalates (1, 2, 3, then demand-deep-inspection) whenever its terminal pane is idle for the stale window. Workers doing real work inside a no-mistakes pipeline run are idle in the pane by design, and workers firstmate deliberately stopped on a green PR are idle by design too. Each false alarm costs firstmate a full handling turn. On 2026-09-09 three deliberately stopped workers (fm-control exit, PR green, awaiting the serial merge queue) escalated to level 3 even though their status log ended in a 'paused: [key=await-merge] ...' line; on 2026-09-01 five mid-run workers were flagged the same way while their pipelines were active.
REQUIRED BEHAVIOR - escalation must require BOTH signals quiet, never the pane alone:
DELIBERATE DECISIONS MADE WHILE IMPLEMENTING, all verified against the live fleet and the installed binary on 2026-09-09 - a reviewer reading only the diff would not know these:
(a) The report's stated cause was wrong and the code reflects the measured one. The report said fm-crew-state returned 'done' for those three tasks. Reading the live fleet, all three actually reported 'state: working / source: run-step / validating (running)', because a no-mistakes run keeps its ci step running for as long as the PR stays open. pause_state_class honored that 'working' verdict ahead of the declared pause and absorbed the pane as provably-working, which STARTS THE WEDGE TIMER - that timer is what escalated them. So the fix also had to stop a stale 'working' verdict from beating a declared pause. crew_absorb_class only ever prints working/paused/none, so a 'done' run-step already flattens to 'none'; handling literal done/failed/unknown there would have been dead code.
(b) Pipeline activity is read from the active_steps table's last_activity column, NOT the run's top-level status and not an updated_at field (there is no updated_at in real axi status output). Verified on the installed binary: a worker stopped on a green PR reports 'status: running' after 15h29m with last activity 'quiet 51m55s ago'. Reading top-level status would mark every stopped green-PR worker permanently active and suppress its escalation forever, the opposite of the intended rule.
(c) A 'working' verdict proves a run EXISTS, not that it is MOVING, so it now outranks a declared pause only while that run's own last activity is fresh. This preserves the pre-existing contract that an actively-running pipeline behind a declared pause resumes wedge tracking so a genuinely FROZEN run still escalates (tests/fm-watch-triage.test.sh's test_nonterminal_paused_rechecks_authoritative_state).
(d) The activity probe is three-state on purpose. Exit 2 means 'no answer available' (no worktree, no no-mistakes installed, no active_steps table at all) and a caller holding positive run evidence keeps trusting it, rather than reading an unanswerable probe as proof the run stopped. Only a real negative (an answer with no running/fixing step, or a stale last_activity) overrides. pipeline_recently_active keeps the cheap mode= skip for the escalation gate; pipeline_activity_fresh omits it for callers that already know a run exists, because skipping on a thin meta record would answer 'not moving' for a pipeline that is in fact moving.
(e) The declared-pause gate previously required a confidently 'dead' agent, which no unverified backend (zellij, orca, cmux) and no unreadable meta can ever report - both map to 'unknown' via fm_backend_agent_state. Those workers could never reach paused. The gate now overrides a declared pause only on a confidently 'alive' agent, since only a live agent could still be silencing a decision gate. The secondmate branch keeps its previous behavior via an 'alive' default, because secondmates get no agent read there.
CONSTRAINTS HONORED: never started, stopped, or signaled the live home's watcher, and never ran bin/fm-watch-arm.sh or killed any fm-watch process; all live testing went through a throwaway FM_HOME pointed at a scratch copy of state/, plus the sanctioned bin/fm-watch-checkpoint.sh. Wake queue formats and the ack protocol are unchanged.
TESTS: tests/fm-watch-wedge-two-signal.test.sh is a new colocated table test with 10 cases driving the real sourced watcher through pause_state_class, pipeline_recently_active, and wedge_timer_check (fm-watch.sh's BASH_SOURCE guard returns before the lock and loop). Fixtures use real captured axi status output. Each case was verified NON-VACUOUS by running the suite against the unmodified HEAD watcher: 5 cases fail there and pass after. Two weak cases were deliberately hardened after that check - the declared-pause case now uses backend=zellij so the agent reads 'unknown' (a 'dead' fixture passed before the fix and proved nothing), and the no-mode case asserts a positive control with mode= present so a 'quiet' verdict cannot come from a missing function. Existing tests/fm-watch-triage.test.sh stays green (verified repeatedly, including 3 consecutive clean runs).
DOCS: docs/architecture.md gains the two-signal rule and its corrected liveness and activity wording.
LIVE PROOF (for the PR's 'What I walked' section): running the same live fleet records through the old and new classifier side by side, aos-3475-foreign-chat-toast went from 'working' (which starts the wedge timer) to 'paused', aos-3592-model-pick-race went from 'none' (wedge ladder) to 'paused', and the live-agent worker aos-3379-retry-nested-answers stayed 'none' unchanged. A real throwaway watcher polling those records then produced .paused-rechecked markers for both stopped workers, zero .wedge-escalations files, and only a routine heartbeat in the wake queue.
What Changed
bin/fm-watch.shnow requires two quiet signals before it escalates a wedge. A declaredpaused:orcaptain-heldlast status line beats aworking/terminal verdict from the run-step or pane source unless the agent is confidently alive, and aworkingverdict only outranks a declared pause while that run's ownactive_stepslast_activityis still fresh. At the escalation threshold the watcher makes a boundedno-mistakes axi statusread (newpipeline_recently_active,pipeline_activity_fresh,pipeline_run_is_this_task,pipeline_age_secs) and treats a run with activity inside the stale window as working; the probe skips tasks with nomode=in their meta and returns a distinct "no answer" exit so a missing worktree or missing no-mistakes never reads as a stopped run.pausedwith a "finished worker awaiting merge" reason (finished_awaiting_merge), andabsorbed_awaiting_mergekeeps that pause state across watcher restarts so the long re-surface throttle is not rebuilt each poll. Two new knobs,FM_PIPELINE_ACTIVE_SECSandFM_PIPELINE_CHECK_TIMEOUT, are documented indocs/configuration.mdalongside theFM_FAKE_AXI_STATUStest override.bin/fm-pr-autoarm.shused inline moved tofm_pr_announced_urlinbin/fm-pr-lib.shso the autoarm sweep and the watcher's awaiting-merge check share one owner, andbin/fm-classify-lib.shsplitscrew_absorb_classintocrew_state_linepluscrew_absorb_class_of_lineso a caller needing both the class and the line's fields shells out once.docs/architecture.mdrecords the two-signal rule and the corrected liveness and activity wording;tests/fm-watch-wedge-two-signal.test.shadds a 10-case table test over the real sourced watcher using capturedaxi statusfixtures.Risk Assessment
✅ Low: The change is well-bounded to the watcher's stale-triage path, every required intent behavior is implemented and independently verified in source, the earlier rounds' fixes are genuinely present rather than merely claimed, and the new logic fails conservatively (an unreadable probe returns "no answer" and preserves the prior verdict rather than inventing one).
Testing
Ran the two targeted suites and both pass in full: the new tests/fm-watch-wedge-two-signal.test.sh (24 cases) and the existing tests/fm-watch-triage.test.sh (54 cases). Because unit passes alone are not evidence, I also built a before/after transcript that drives the real bin/fm-watch.sh over four identical fixtures shaped from the two incidents in the report, once against the base watcher and once against the branch watcher. That transcript shows each required behavior as an operator would see it: a worker stopped on a green PR flips from
none(wedge ladder) topaused(long cadence); a mid-run worker whose pipeline moved 12s ago is now read as active where the base watcher had no pipeline probe at all; a finished worker with an armed PR poll is absorbed into a wake that names the awaiting-merge reason with 2 pause markers and 0 wedge escalations, where the base watcher emitted a barestale:wake; and a genuinely wedged worker with no pause, no PR watch, and a pipeline quiet for 51m55s still classifiesnoneon both, confirming the escalation path is intact. Two tests failed on the first combined run and both proved non-actionable: the triage failure reproduces on the base commit a0c5f4c so it predates this change, and the new resurface case passed 3/3 in isolation, making it a timing-sensitive test squeezed under full-suite load rather than a product defect. I removed the temporary driver script and both scratch worktrees; the working tree is clean.Evidence: Before/after: same fixtures through the old and new watcher
Source: Before/after: same fixtures through the old and new watcher
OLD NEW A worker stopped on a green PR, status log endspaused: [key=...]none (wedge ladder) paused (long cadence) B worker mid-run, pipeline last activity 12s ago no pipeline read pipeline ACTIVE at all (the -> escalation function does blocked not exist) C finished worker, green PR, armed merge watch, agent gone bare "stale:" wake absorbed with the surfaced, 0 pause awaiting-merge markers reason, 2 pause markers, 0 wedge escalations D genuinely wedged: no pause, no PR watch, pipeline quiet 51m55s none none (UNCHANGED - still escalates)Evidence: New-watcher behavior transcript (all four required behaviors)
Source: New-watcher behavior transcript (all four required behaviors)
SCENARIO A - worker deliberately stopped on a green PR (2026-09-09 incident) Worker status log: paused: [key=await-merge] PR green, waiting on the serial merge queue Watcher verdict: paused SCENARIO B - worker mid-run inside an active no-mistakes pipeline (2026-09-01 incident) active_steps[1]{step,status,active_for,last_activity,agent_pid,round}: ci,running,33m1s,"12s ago: log: building the new body","77305",starting Watcher verdict: pipeline ACTIVE -> no wedge escalation SCENARIO C - finished worker awaiting merge, driven through the REAL watcher poll What firstmate actually received in the wake queue: 1788972657 1 stale fmtest:fm-am stale: fmtest:fm-am (paused 211114257s, awaiting external - finished worker awaiting merge - PR is green and its merge watch is armed, rechecked on a long cadence not a wedge; confirm the wait still holds) Wedge escalation files created: 0 (0 = never treated as a wedge) Pause markers created: 2 SCENARIO D - genuinely wedged worker: no pause, no PR watch, no pipeline Watcher verdict: pipeline QUIET -> escalation proceeds, exactly as before Classification: none (none = eligible for the wedge ladder)Evidence: Targeted suite results (both suites green)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 5 issues found → auto-fixed (5) ✅
bin/fm-watch.sh:627- Secondmate windows lost their fail-open and are now absorbed aspausedinstead of surfacing. Intent (e) states: "The secondmate branch keeps its previous behavior via an 'alive' default." No such default exists in the code. Theif [ "$(window_kind "$win")" != secondmate ]guard at line 625 skips thefm_backend_agent_aliveread, soagent_aliveremains unset;${agent_alive:-unknown}at line 628 evaluates tounknown, which is notalive, so control falls to the unconditionalprintf 'paused'at line 645. The old code instead ran[ "$class" = none ] && [ "${agent_alive:-unknown}" = dead ] && class=paused, which for an unsetagent_aliveleftclassuntouched and printed it. Verified by probe against a0c5f4c: akind=secondmatetask with statuspaused: [key=await-answer] waiting on captainand crew statestate: unknown · source: none · no current-state source availableclassifiednoneon the old watcher andpausedon the new one. At the secondmate call site (bin/fm-watch.sh:1372)nonerunsclear_pause_trackingwhilepausedrunshandle_paused_stale, so this secondmate is now absorbed on the PAUSE_RESURFACE_SECS cadence rather than having its pause tracking cleared. Fix: setagent_alive=alivein an else branch of the secondmate guard, matching the intent's stated design.bin/fm-watch.sh:486- The pipeline-activity gate suppresses the busy-pane wedge escalation, which the intent scopes only to pane-idle workers. Required behavior 2 reads: "Before any wedge escalation of a pane-idle worker, read the task's pipeline activity." Thepipeline_recently_activecheck was added insidewedge_timer_check, which is shared by the busy path: bin/fm-watch.sh:1472 and bin/fm-watch.sh:1484 call it with labelbusy (no completed turn)afterbusy_turn_over_ageconfirms a genuinely BUSY pane has gone past BUSY_TURN_MAX_SECS with no completed turn. For anymode=no-mistakestask the pipeline is active by definition during validation, so this path can no longer escalate at all. Verified by probe against a0c5f4c: akind=ship,mode=no-mistakestask with a since-file 99999s old and an active_steps row readingci,running,33m1s,"12s ago: ..."queued onepossible wedgewake on the old watcher and zero on the new one via thebusy (no completed turn)label. A worker whose agent is truly spinning inside a live pipeline now never escalates on that path. Fix: gate on the label or pass an explicit flag so only the pane-idle call sites consult the pipeline.bin/fm-watch.sh:616- Aworkingverdict sourced from a busy PANE is now gated on no-mistakes pipeline freshness, which is an unrelated signal.crew_absorb_class(bin/fm-classify-lib.sh:1297) printsworkingfor sourcerun-stepOR sourcepane; the intent's rationale (c) is about run-step only ("A 'working' verdict proves a run EXISTS, not that it is MOVING"), but the condition[ "$class" = working ] && [ "$activity_verdict" -ne 1 ]applies to both. A pane that fm-crew-state reports as exactly busy is direct positive evidence of a rendering agent and does not depend on a no-mistakes run. Verified by probe against a0c5f4c: amode=no-mistakesship with statuspaused: [key=await-x] waiting, a live agent (window present, pane_current_command=claude), crew statestate: working · source: pane · busy pane, and a quiet pipeline (ci,running,15h29m,"quiet 51m55s ago: ...") classifiedworkingon the old watcher andnoneon the new one, so the wake now surfaces to firstmate instead of being absorbed. Fix: apply the freshness gate only when the verdict's source isrun-step.bin/fm-watch.sh:426- The comment above theactive_steps[guard contradicts the code beneath it. It reads "An answer with no active step is a real negative: a terminal, parked, or not-yet-started run cannot be the reason a pane is legitimately quiet", but line 428 returns 2, which the function's own header (lines 410-413) defines as "no answer available" and which callers holding positive run evidence deliberately ignore. The real-negative return is 1 at line 430, for an answer that HAS an active_steps table but no running/fixing row. Behavior matches intent (d); only the comment is wrong, and it sits directly above the line it misdescribes.bin/fm-watch.sh:350-meta_fieldis byte-for-byte the body offm_meta_get(bin/fm-backend.sh:337), which fm-watch.sh already sources: both aregrep "^$key=" "$meta" | tail -1 | cut -d= -f2-. The two call sites can usefm_meta_get "$STATE/$task.meta" modeandfm_meta_get "$STATE/$task.meta" worktreedirectly, dropping the wrapper.fm_meta_getalso adds a[ -f "$meta" ]guard the new copy lacks.🔧 Fix: scope wedge pipeline gate and restore secondmate fail-open
4 issues (1 error, 3 warnings) still open:
bin/fm-watch.sh:583- Required behavior 3 is implemented but unreachable for the workers it targets.finished_awaiting_mergeis called only frompause_state_class, inside the! status_is_paused_or_captain_heldbranch. But adone: PR <url> ...line IS captain-relevant (verified:status_is_captain_relevantreturns true,status_is_paused_or_captain_heldreturns false), so the watcher's stale dispatch routes such a worker to thestale_is_terminalbranch at line 1404, which never callspause_state_class. The other threepause_state_classcall sites are all gated: line 1458/1475 sit inside theelseofstale_is_terminal(so the last line is not captain-relevant there), and lines 1475/1511 are additionally guarded bystatus_is_paused_or_captain_held. Only line 1393 (kind = secondmate) reaches it, and a secondmate is not the green-PR ship worker the criterion describes. Proven by probe: for a ship withdone: PR ... green,f.check.shpresent, and a dead agent,finished_awaiting_mergereturns YES andpause_state_classreturnspaused, yetstale_is_terminalalso returns YES so the watcher takes that branch instead. Intent requires: "A worker whose agent is dead AND whose last status line is 'done: PR <url> ...' with an armed PR watch (state/<id>.check.sh present) is a finished worker awaiting merge, not a wedge: classify it paused with a reason that says so." To make it hold, the check must run at thestale_is_terminaldispatch (before or inside that branch), not only insidepause_state_class.bin/fm-watch.sh:602-pause_state_classnow invokes the expensive crew-state reader twice per call. Line 602 spawns"$FM_CREW_STATE_BIN" "$task"to get the source field, then line 603'screw_absorb_class "$task"spawns"$FM_CREW_STATE_BIN"again internally (bin/fm-classify-lib.sh:1300).fm-crew-state.shis not a cheap read: it shells out to a boundedno-mistakes axi status(bin/fm-crew-state.sh:394) and can make a secondaxi logscall vianm_ci_checks_state. Measured with a counting wrapper around the fake reader: base commit a0c5f4c makes 1 invocation, current HEAD makes 2, for an ordinary ship with a declared pause. This doubles the per-poll subprocess cost on the hot pause path and directly contradicts the prior round's instruction ("read it from the fm-crew-state line the same way crew_absorb_class does, without adding a second fm-crew-state call"). Fix: derive bothclassandcrew_sourcefrom the singlecrew_linealready captured at line 602, inlining crew_absorb_class's mapping, or have the helper return both.bin/fm-watch.sh:641- The new secondmate fail-open branch deletes the recheck marker where the pre-change code wrote it, permanently disabling the cheap pause-cadence short-circuit for paused secondmates. Old code (a0c5f4c) fell through tocase "$class" in paused) date +%s > "$recheck_file"for a secondmate whosecrew_absorb_classreturnspaused. New code at line 641-645 returns early withrm -f "$recheck_file". Verified side by side: withkind=secondmate, apaused:status line,.paused-<key>present, andFM_FAKE_CREW_STATE='state: paused ...', the base commit leaves.paused-rechecked-fmtest_fm-smon disk while HEAD does not; both printpaused. Consequence: the short-circuit at line 589 ([ -e .paused-$key ] && age_of(recheck_file) < STALE_ESCALATE_SECS) can never fire again for that key, becauseage_ofon a missing file returns 999999. Every subsequent poll re-runs the full path, which per the finding above now costs two crew-state subprocesses instead of the intended zero. The verdict stayspaused, so no false alarm results, but the once-per-window cost bound is lost. Fix: in the secondmate branch, preserve the old marker bookkeeping (write the marker when$classispaused, remove it otherwise) rather than unconditionally removing it.bin/fm-watch.sh:425- The active-step row scan can match a row belonging to a different TOON table, reporting a stopped pipeline as active and suppressing a legitimate wedge escalation.grep -A"${PIPELINE_ROWS_MAX:-20}"returns 20 lines after theactive_steps[header regardless of that table's declared row count, and the follow-upgrep -E '^[[:space:]]*[a-z_]+,(running|fixing),'is not anchored to the active_steps table. Concrete reproduction: with outputactive_steps[0]{step,status,active_for,last_activity,agent_pid,round}:followed bygates[2]{gate,status,active_for,last_activity}:and a rowreview,running,5m,"3s ago: reviewing", the pipeline returns thereview,runningrow andpipeline_activity_freshanswers 0 (active) even thoughactive_steps[0]declares zero active steps. Real axi status output does carry sibling tables (fm-crew-state.sh:187 parses afindings[N]{...}table from the same output, and fm-crew-state.sh:191 scans unanchored rows from it). This is the failure direction the change most needs to avoid: a genuinely wedged worker whose pipeline has stopped gets its escalation reset forever. Fix: bound the scan by the row count in theactive_steps[N]header, or stop at the first subsequent line matching another<name>[<n>]{table header.🔧 Fix: reach awaiting-merge case, dedupe crew-state read, bound step scan
4 issues (2 errors, 2 warnings) still open:
bin/fm-watch.sh:418-pipeline_activity_freshtrustsno-mistakes axi statusoutput without verifying the run belongs to this task's branch, so an unrelated crew's active run suppresses a real wedge escalation and re-breaks the case the change targets.no-mistakes axi status --helpdocuments it as "Show the active (or most recent) run" - it is not scoped to the invoking worktree's branch. bin/fm-crew-state.sh:307-313 states this explicitly for the same command: "no-mistakes axi status(bare) reports the active-or-most-recent run for the CURRENT branch when one exists, else falls back to some other branch's run purely as informational display... A crew whose branch genuinely has no run yet therefore sees another branch's answer here." Both other consumers of this command guard against it: fm-crew-state.sh:396-397 requiresrun_branch = CREW_BRANCHplusnm_run_head_matches_worktreebefore setting HAVE_RUN=1, and fm-teardown.sh:1228-1231 requires the same branch andfm_nm_head_matches_worktreebefore acting. bin/fm-watch.sh:418 callsfm_nm_run "$wt" "$PIPELINE_CHECK_TIMEOUT" axi statusand parses the active_steps table with nobranch:/head:check at all. Two concrete reachable failures. (a) Wedge suppression: a genuinely wedged worker W (mode=no-mistakes, its own run finished or never started) has its pane idle past STALE_ESCALATE_SECS, so wedge_timer_check runs with check_pipeline=1 (bin/fm-watch.sh:1465, 1509, 1514). Sibling crew X on the same underlying repo has a live run, so W'saxi statusreturns X's TOON withci,running,2m,"3s ago: ...". pipeline_recently_active returns 0, and bin/fm-watch.sh:503-507 resets$since_fileANDrm -f "$escalation_file", discarding the accumulated escalation count. As long as any sibling run keeps moving, W never reaches escalation 1, let alone FM_WEDGE_DEMAND_INSPECT_COUNT - required behavior 4 ("agent dead, no declared pause, no armed PR watch, no pipeline activity still escalates exactly as today") silently fails. (b) The targeted false alarm returns: a deliberately stopped green-PR worker with apaused: [key=await-merge]line whose crew_absorb_class readsworking/run-stepreaches bin/fm-watch.sh:646. Its own ci step is quiet 51m55s, but the probe reads sibling X's fresh row,activity_verdictis 0 not 1, and pause_state_class returnsworkingat line 650 instead ofpaused- which is precisely what "STARTS THE WEDGE TIMER" per the intent's decision (a). Fix at the shared boundary: extract the branch+head attribution guard already owned by bin/fm-nm-run-lib.sh (fm_nm_field ... branchcompared to the worktree'ssymbolic-ref --short HEAD, plusfm_nm_head_matches_worktree) and require it in pipeline_activity_fresh before parsing active_steps; a non-matching run is "no answer available" (return 2), not evidence of activity.bin/fm-watch.sh:468-finished_awaiting_merge's status matchcase "$last" in done:*PR*)is an unanchored glob over the whole line, so anydone:line containing the substring "PR" anywhere qualifies as "announced a green PR", and a genuinely terminal worker is silently absorbed onto the pause cadence instead of being surfaced to the captain. Verified by running the exact case expression:done: PREPARED the migration but nothing shippedmatches,done: refactored PROVIDER lookupmatches,done: implemented; no PR yetmatches, anddone: PR closed without mergematches. The armed-watch precondition does not rescue these:[ -e "$STATE/$task.check.sh" ]is satisfied by ANY registered custom watcher check, not specifically a PR merge watch - bin/fm-check-register.sh registers arbitrary$STATE/$ID.check.shbytes, and bin/fm-bootstrap.sh:908 armsx-watch.check.shas a plain relay-poll shim. Concrete failure at the dispatch: a worker with meta kind=ship, a registered<id>.check.sh, a dead agent, and last status linedone: refactored PROVIDER lookup and stoppedgoes stale.status_is_captain_relevantreturns 0 for verbdone(bin/fm-classify-lib.sh:128), so the poll enters the stale_is_terminal branch,finished_awaiting_mergeat bin/fm-watch.sh:1439 returns 0, andhandle_paused_staleabsorbs it with the reason "finished worker awaiting merge - PR is green and its merge watch is armed". That worker is not awaiting a merge and has no PR; it is a finished worker that needed the captain, and it now re-surfaces only every PAUSE_RESURFACE_SECS with a reason that is factually wrong. The test at tests/fm-watch-wedge-two-signal.test.sh:225 usesdone: PR https://example.invalid/pull/7 checks greenand its negative at :256 differs only by the armed watch, so neither case can catch this. Fix: anchor the match to a PR announcement rather than a bare substring, e.g. require the tokenPRat a word boundary followed by a URL (case "$last" in done:*[[:space:]]PR[[:space:]]*http*)) or reuse the existing status-line parsing helpers, soPREPARED/PROVIDERand a PR-lessdone:line cannot qualify.bin/fm-watch.sh:431- The awk row-count bound inpipeline_activity_freshdecrementsleftfor every line inside the table region, not only for data rows, so a blank line or any interleaved non-row line exhausts the budget and hides a genuinely running step - reporting a moving pipeline as quiet and letting a mid-run worker escalate as a wedge, the exact 2026-09-01 false alarm this change targets. Verified by running the awk program standalone. Inputactive_steps[2]{step,status}:/lint,done,1m,"1s ago: x"/ (blank line) /ci,running,2m,"3s ago: go"returns NO row: the blank line consumes the second of two slots before the running row is reached. Inputactive_steps[1]{step,status,active_for,last_activity}:/branch: fm/x/ci,running,2m,"3s ago: go"likewise returns nothing, because the scalar line eats the single slot. The same program correctly returns the row when the data rows immediately follow the header with no interleaving, which is why the suite's fixtures (tests/fm-watch-wedge-two-signal.test.sh:186, 209, 361, 380, 409, 458, 509, 534 - all tightly packed single-row tables) all pass and none exercise this shape. Consequence at the call site: pipeline_activity_fresh returns 1 (a hard negative, not the 2 "no answer" state), so wedge_timer_check at bin/fm-watch.sh:503 does not absorb and the worker escalates, and pause_state_class at bin/fm-watch.sh:646-651 treats the run as stopped. Fix: only decrementlefton lines that actually look like table rows (or drop the counter and rely solely on the existing next-table-header terminator at line 437, which already handles the sibling-table case the counter was added for).bin/fm-watch.sh:446-pipeline_activity_freshreturns 1 (a hard "pipeline stopped") rather than 2 ("no answer available") when a running step's last_activity column is present but not in the<age> agoshape, contradicting the three-state contract the function's own header documents and turning an unreadable field into positive evidence that the run halted. The header at bin/fm-watch.sh:405-408 states: "Exit 2 (not 1) means 'no answer available'... A caller that already holds positive run evidence keeps trusting it rather than reading an unanswerable probe as proof the run stopped." But once a running row IS found, every parse failure downstream falls toreturn 1: an empty activity field (line 443), a value with noago(line 447), and an age string with no recognized unit (line 449). Verified by running the extraction logic on plausible rows:ci,running,2m,"just now",1,1returns 1,ci,running,2m,"",1,1returns 1,ci,running,2m,"starting",1,1returns 1, andci,running,2m,-,1,1returns 1. Each of those is a row that positively proves a step isrunning- the strongest available evidence the pipeline exists - yet the probe answers "stopped". Consequence: at bin/fm-watch.sh:646-651 a declared-pause worker whose ci step just started (no elapsed activity to render yet) getsactivity_verdict = 1, so pause_state_class falls through to the paused branch; and more damagingly at bin/fm-watch.sh:503 a mid-run worker whose step reports an unrecognized activity format escalates as a wedge despite a visibly running step.pipeline_age_secsis also loose in the other direction:1msparses as 60 and2moas 120, because only the first character of the unit is read. Fix: when a running/fixing row is found but its activity cannot be parsed, return 2 (unanswerable) rather than 1, so the documented "keeps trusting positive run evidence" rule actually holds; and either reject multi-character units in pipeline_age_secs or document that axi never emits them.🔧 Fix: attribute pipeline runs, require real PR URL, fix table scan
2 warnings still open:
bin/fm-watch.sh:633- Thefinished_awaiting_mergeblock insidepause_state_classis dead code in production, and the unit test covering it asserts a path the real poll never takes.pause_state_classreaches line 633 only whenstatus_is_paused_or_captain_heldis false, andfinished_awaiting_mergeadditionally requires the last status line to begin withdone:. Verified by running the real classifier ondone: PR https://github.com/o/r/pull/1 checks green:status_is_captain_relevantreturns 0 (bin/fm-classify-lib.sh:128) whilestatus_is_paused_or_captain_heldreturns 1. So for any ship worker with adone: PR <url>line,stale_is_terminal(bin/fm-classify-lib.sh:1396-1400) is true and the poll dispatches to bin/fm-watch.sh:1456, where the working duplicate at line 1472 handles it. The non-terminal call sites at bin/fm-watch.sh:1520 and :1537 sit in theelseof that samestale_is_terminaltest, so adone:line cannot arrive there. The call site at :1573 is guarded bystatus_is_paused_or_captain_held, which excludesdone:. The secondmate call site at :1445 is unreachable too: line 1420continues any secondmate whose last line is notpaused:, andfm_pr_autoarm_announce(bin/fm-pr-autoarm.sh:348) skipskind=secondmateso no secondmate ever gets an armed watch. Confirmed empirically: deleting lines 633-636 and running tests/fm-watch-wedge-two-signal.test.sh leavestest_green_pr_awaiting_merge_is_absorbed_by_the_real_poll(the real-poll case, tests/fm-watch-wedge-two-signal.test.sh:253) passing, and onlytest_green_pr_with_armed_watch_is_paused(tests/fm-watch-wedge-two-signal.test.sh:557, which callspause_state_classdirectly) fails. Consequence: that unit test gives false confidence it guards required behavior 3, when the production guarantee rests entirely on bin/fm-watch.sh:1472. Fix: remove the block at :633-636, and drop or retarget the unit test at tests/fm-watch-wedge-two-signal.test.sh:557, keeping the real-poll case as the proof.bin/fm-watch.sh:496-finished_awaiting_mergetreats the presence of anystate/<id>.check.shas an armed PR merge watch, so an unrelated registered custom check plus a done-line that happens to carry exactly one PR URL absorbs a genuinely terminal worker onto the long pause cadence with a factually wrong reason.state/<id>.check.shis the generic custom-watcher-check path, not a PR-watch marker: bin/fm-check-register.sh registers arbitrary bytes under that name for any valid task id, and the watcher's own sweep at bin/fm-watch.sh:1266-1289 explicitly distinguishes the two by callingfm_pr_poll_snapshot_captureand settingis_pr_poll, falling back to a plain custom check when that fails. An actually-armed PR watch writes the<id>.pr-polland<id>.pr-poll-registrationsidecars plus thepr=meta field (bin/fm-pr-check.sh:105-183), and bin/fm-pr-lib.sh:677 already owns the exact predicatefm_pr_poll_artifacts_valid <state> <id> <template>, used by bin/fm-pr-check.sh:156 and bin/fm-pr-check-migrate.sh:93. Concrete failure: a ship worker registers a non-PR custom check (a deploy probe, a fixture watcher) via bin/fm-check-register.sh, later finishes and appendsdone: work complete, superseding https://github.com/o/r/pull/12 - needs a captain call, and its agent exits. Runningfm_pr_announced_urlon that line returns the single URL successfully (verified), the-etest passes on the unrelated check file,finished_awaiting_mergereturns 0, and bin/fm-watch.sh:1472 routes the worker intohandle_paused_stalewith the reason "finished worker awaiting merge - PR is green and its merge watch is armed". That worker has no armed merge watch and needed the captain, but now re-surfaces only once per PAUSE_RESURFACE_SECS behind a wrong reason - a worse failure than the false alarm this change fixes. Fix: replace[ -e "$STATE/$task.check.sh" ]with the existing shared ownerfm_pr_poll_artifacts_valid "$STATE" "$task" "$SCRIPT_DIR/fm-pr-poll.sh"so only a real armed PR poll qualifies. Note the user intent spells this precondition as "state/<id>.check.sh present", so the narrowing is a correctness refinement of the author's stated rule rather than a contradiction of it.🔧 Fix: require genuine PR poll, drop unreachable merge branch
1 error still open:
bin/fm-watch.sh:1415- The new finished-awaiting-merge absorb re-surfaces a wake on EVERY poll instead of once per PAUSE_RESURFACE_SECS, because the poll loop's pause-tracking reset at bin/fm-watch.sh:1415 deletes the throttle marker handle_paused_stale depends on.Mechanism: this worker's last status line is
done: PR <url> checks green, sostatus_is_paused_or_captain_heldis FALSE for it (verified: bin/fm-classify-lib.sh:150-156 matches onlypaused:or the captain-held verb). Line 1415 therefore fires on every poll once.paused-<key>exists, and clear_pause_tracking -> clear_pause_state (bin/fm-watch.sh:617-623, 608-614) removes.paused-<key>AND.paused-resurfaced-<key>. Line 1472's finished_awaiting_merge then returns 0 and handle_paused_stale at line 1479 recomputesrf_agevia age_of on the now-missing marker, which returns 999999, so the[ "$rf_age" -ge "$PAUSE_RESURFACE_SECS" ]guard at line 599 passes again and fm_wake_append + wake fire again.Evidence (real code, no mocked classifier):
paused: [key=await-merge] ...last line fired exactly 1 wake, confirming the throttle works there and is defeated only for the newdone:-line path.stat -f '%i %m'on.paused-<key>showed the inode changing on every poll cycle (MISSING -> inode A -> MISSING -> inode B -> ...), proving clear_pause_tracking deletes and handle_paused_stale recreates it each pass.Impact: the change's stated purpose is to stop each false alarm costing firstmate a full handling turn. For this case it produces one wake per FM_POLL interval, a strictly higher rate than the level-1/2/3 wedge ladder it replaced.
Test gap: neither new test can catch this. test_green_pr_awaiting_merge_is_absorbed_by_the_real_poll (tests/fm-watch-wedge-two-signal.test.sh:309) and test_green_pr_awaiting_merge_absorbed_on_a_repeat_hash (:522) both stop the watcher the moment
.paused-<key>appears, and both leave the status file fresh soage < PAUSE_RESURFACE_SECSand no wake is ever attempted. They assert the absorb happens, never that it stays throttled.Recommended fix at the earliest shared boundary: make the line-1415 guard skip a window that finished_awaiting_merge covers, so
.paused-resurfaced-<key>survives and handle_paused_stale remains the single owner of the re-surface cadence. Add a regression test that polls the same stale hash twice with a status file older than PAUSE_RESURFACE_SECS and asserts exactly one queued stale wake.🔧 Fix: keep awaiting-merge pause state across watcher restarts
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-watch-wedge-two-signal.test.sh- all 24 cases passbin/fm-test-run.sh tests/fm-watch-triage.test.sh- all 54 existing cases passBefore/after behavior transcript: drove the realbin/fm-watch.shover four identical hermetic fixtures under both the base watcher (a0c5f4c) and the branch watcher (7058bab), comparingpause_state_class,pipeline_recently_active, and a live 14s watcher pollRequired behavior 1:pause_state_class fmtest:fm-pm pmon apaused: [key=await-merge]line with a non-alive agent returnspaused(base returnsnone)Required behavior 2:pipeline_recently_activeagainst real-shapeactive_steps[1]{...}rows withlast_activity12s ago returns active; the function does not exist on the base commitRequired behavior 3: live watcher poll over a seeded stale pane with an armed PR poll (arm_pr_pollwriting real pr-poll + pr-poll-registration sidecars) produced a wake readingawaiting external - finished worker awaiting merge - PR is green and its merge watch is armed, 2 pause markers, 0 wedge-escalation filesRequired behavior 4 (regression guard): a worker with no pause, no armed PR watch, and a pipeline quiet 51m55s classifiesnoneandpipeline_recently_activereturns quiet, matching base behavior exactlyFlake triage: rantest_awaiting_merge_absorb_resurfaces_once_the_window_elapsesin isolation 3 consecutive times (3/3 pass) after it failed once in the full suitePre-existing-failure check: ranbin/fm-test-run.sh tests/fm-watch-triage.test.shin a worktree at base commit a0c5f4c and reproduced the samestale suppressor not advanced on absorbfailure there✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix: scope shellcheck PATH disables, drop unused test helper
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.
What I walked
This change has no user interface, so there is nothing to screenshot. The walk below is the equivalent for a watcher script: the real fleet's own task records driven through the classifier, then a real watcher polling them.
Every step ran against a throwaway
FM_HOMEpointed at a scratch copy ofstate/, plus the sanctionedbin/fm-watch-checkpoint.sh. The live home's watcher was never started, stopped, or signaled,bin/fm-watch-arm.shwas never run, and nofm-watchprocess was killed. I confirmed the live watcher stayed healthy throughout (its heartbeat was current at each check).The idle-on-green-PR workers, before and after
Both are real fleet tasks that were deliberately stopped with
fm-control exit, had a green PR, and were waiting on the serial merge queue. Both are the exact 2026-09-09 shape. I ran the same records through the unmodifiedHEADwatcher and the changed one:aos-3475-foreign-chat-toastpaused: [key=await-merge] PR .../3611 green; waiting for the serial merge queueworking(starts the wedge timer)pausedaos-3592-model-pick-racepaused: [key=await-merge] PR .../3616 green; waiting for the serial merge queuenone(wedge ladder)pausedaos-3379-retry-nested-answersworking: custody recovered ...nonenone(unchanged)The third row is the control. A worker with a live agent must keep surfacing for inspection, and it does.
What the measured cause turned out to be
Reading
bin/fm-crew-state.shagainst the live fleet, all three escalated workers reportedstate: working · source: run-step · validating (running), not thedonethe report assumed. A no-mistakes run keeps itscistep running for as long as the PR stays open.pause_state_classhonored thatworkingverdict ahead of the worker's own declared pause and absorbed the pane as provably-working, which starts the wedge timer, and that timer is what escalated them.I confirmed the same thing directly against the installed binary.
aos-3475's run had beenstatus: runningfor 15h29m with its last activityquiet 51m55s ago. That is why the activity signal here is theactive_stepstable'slast_activitycolumn and not the run's top-level status: reading the top-level status would mark every stopped green-PR worker permanently active and suppress its escalation forever, the opposite of the rule this PR adds.A real watcher over the same records
I then pointed a throwaway watcher at those records through
bin/fm-watch-checkpoint.sh, with a shortened stale window so several windows elapsed inside one run. After the run:.paused-rechecked-firstmate_fm-aos-3475-foreign-chat-toastand.paused-rechecked-firstmate_fm-aos-3592-model-pick-racewere both present, so both stopped workers were on the long pause recheck cadence..wedge-escalations-*file existed for any task, so nothing escalated.heartbeatrecord and nostale ... possible wedgerecord.An earlier 70-second run over the same records exited on a heartbeat rather than a wedge, with all three panes confirmed idle (
busy=no) so the pane-idle condition really was exercised.The secondmate and paused cases
kind=secondmatewindow with apaused:line and an idle pane surfaces instead of being absorbed. Review caught that my first version had silently removed this fail-open, so it is now an explicit branch and a test..paused-rechecked-<key>for a secondmate whose crew state readspaused, and it still does. My first fix had deleted it, which would have disabled the cheap pause-cadence short-circuit permanently.tests/fm-watch-triage.test.sh'stest_nonterminal_paused_rechecks_authoritative_statepins. This is why aworkingverdict only outranks a declared pause while that run's own activity is fresh.Tests
tests/fm-watch-wedge-two-signal.test.shhas 24 cases, all green, driving the real sourced watcher rather than asserting anything about implementation source text. I verified the original set was non-vacuous by running it against the unmodifiedHEADwatcher, where 5 cases fail and pass only with the change. Two cases that passed on base and therefore proved nothing were rewritten: the declared-pause case now uses an unverified backend so the agent readsunknown(the real-world shape), and the no-mode case asserts a positive control so a "quiet" verdict cannot come from a missing function.tests/fm-watch-triage.test.shis green, along with the wake-queue, inactive-reconcile, and classify-decision-key suites.bin/fm-lint.shandbin/fm-doc-audience-check.shboth pass.🤖 Generated with Claude Code