Skip to content

fix(bin): stop the watcher hot-looping on a parked idle crew - #1

Merged
staneja15 merged 9 commits into
mainfrom
fm/watcher-paused-idle-loop-p3b
Jul 27, 2026
Merged

staneja15 merged 9 commits into
mainfrom
fm/watcher-paused-idle-loop-p3b

Conversation

@staneja15

Copy link
Copy Markdown
Owner

Intent

Stop firstmate's watcher (bin/fm-watch.sh) hot-looping on a legitimately idle crew pane. Live defect: two crews finished and waiting on a merge each woke firstmate roughly every two minutes with nothing to do.

ROOT CAUSE, correcting the backlog item. The item hypothesised the first-sight stale path in bin/fm-watch-arm.sh, reasoning that because the watcher exits on a wake every re-arm is a fresh first sight. I verified before fixing and that is WRONG: the arm wrapper emits no wake of its own and marker files persist across restarts, so six re-arms against a stable idle pane produce exactly one wake. The real cause is pane-hash churn - .stale- is keyed on the pane hash, and a parked crew's pane keeps re-rendering an elapsed clock or context counter, so every re-render is a genuinely new hash and a real fresh first sight, which both first-sight paths surfaced immediately with no cadence throttle.

DESIGN, deliberate decisions so they are not read as accidents:

  1. A 'parked' concept rather than status_is_paused, because the defect also reproduces on a needs-decision: park. A park is a declared paused: wait, a captain-held transfer, or a captain-relevant status whose delivery is recorded in state/.hb-surfaced-.
  2. The already-delivered qualifier is load-bearing: an UNDELIVERED terminal status still surfaces on first sight, and the heartbeat backstop rechecks the same marker.
  3. park_recheck_due solely owns the bounded cadence and the shared .paused-resurfaced- marker, anchored on the status file mtime not the pane hash.
  4. handle_parked_stale is reachable on the repeat-hash poll, so a park whose pane freezes still reaches its recheck.
  5. park_wedge_check gives a park on an already-delivered captain-relevant status ONE escalation per park spell at FM_STALE_ESCALATE_SECS on its own .park-since- timer, because a crew re-tasked behind that unchanged line writes no new status.
  6. Away-mode triage is untouched: afk_present short-circuits ahead of every park-gate call site.
  7. Deliberately changed: a live-agent crew parked at an external-decision gate no longer emits an immediate bare stale wake, because the declaring status write already surfaces through the signal path - verified empirically.

KNOWN OPEN FINDINGS from the previous review of this identical code, all four already decided FIX by the supervisor and to be fixed in three rounds this run: park-latch-never-released (the fired latch in .park-since- has no release path a re-tasked crew hits, because the busy-pane release needs the 40-line tail byte-identical across two polls while a working TUI churns it every poll, so the one-shot becomes once per watcher lifetime instead of once per park spell - the 2026-07-26 sixteen-hour outage failure reappearing inside its own fix, needing a test proving TWO park spells in one lifetime each escalate); daemon-park-cleanup-unreachable (the .park-since cleanup added to the daemon's clear_pause_tracking cannot be reached for the only state producing that marker); doc-no-verb-path-imprecise (the architecture.md no-verb-signal-path sentence is true only for the paused/captain-held half, since captain-relevant declarations surface via the captain-relevant path); stale-key-duplication (six open-coded window-to-stale-key transforms in two idioms that must stay in lockstep or silently split a window's markers).

This branch is fm/watcher-paused-idle-loop-p3b, a fresh branch at the identical commit as the earlier p3 branch, created only because a cancelled run left custody stranded and both guarded recovery paths refused; no code differs.

SC1010: commit 7ac2112 quotes the 'done' task id in tests/fm-watch-triage.test.sh. Bash already treats it as a literal string in argument position, so it is a parse-clarity fix with zero behaviour change, quoted per shellcheck's own remedy with an explanatory comment and deliberately not suppressed with a disable directive. Shellcheck 0.11.0 is installed and bin/fm-lint.sh passes clean.

Rebased cleanly onto a5fe1bc; the only overlapping file was bin/fm-supervise-daemon.sh where kunchenguid#1066's edits and my .park-since- marker addition both survive. Regression coverage: paused and needs-decision parks each silent across four re-arms of a re-rendering pane; the recheck firing once per window for both verbs labelled a recheck not a wedge; a frozen pane still reaching its recheck; a dead run behind a delivered terminal status escalating; an undelivered needs-decision still surfacing; a genuinely unresponsive pane still reported. 40/40 triage and 99/99 daemon on the rebased base.

Firstmate's own shared tracked material, so repo style applies: one sentence per line in prose, plain dashes, shellcheck-clean bin scripts, tests colocated in tests/.

What Changed

  • bin/fm-watch.sh now gates both first-sight stale paths on a crew_is_parked test instead of treating every pane-hash change as a fresh sighting. A park is a declared paused: wait, a captain-held transfer, or a captain-relevant status whose delivery is already recorded in state/.hb-surfaced-<task>; the vocabulary half lands in bin/fm-classify-lib.sh as status_is_parked so the watcher and the away-mode daemon share it. A parked crew whose pane keeps re-rendering an elapsed clock or context counter no longer surfaces on every re-render, and an undelivered terminal status still surfaces immediately. Deliberate behaviour change: a live-agent crew parked at an external-decision gate no longer emits an immediate bare stale wake, since its declaring status write already surfaces through the signal path.
  • Two bounded safety nets replace the removed immediacy. park_recheck_due solely owns the resurface cadence and the shared .paused-resurfaced-<key> marker, anchored on the status file mtime rather than the pane hash, and handle_parked_stale is reachable on the repeat-hash poll so a park whose pane freezes still reaches its recheck. park_wedge_check gives a park on an already-delivered captain-relevant status one escalation per park spell at FM_STALE_ESCALATE_SECS, on its own .park-since-<key> timer keyed to the status mtime so a re-tasked crew starts a new spell; bin/fm-supervise-daemon.sh clears that marker alongside the other pause tracking. Away-mode triage is untouched — afk_present short-circuits ahead of every park-gate call site.
  • tests/fm-watch-triage.test.sh grows park coverage: silence across re-arms of a re-rendering pane for both paused: and needs-decision: parks, one recheck per window labelled a recheck rather than a wedge, a frozen pane still reaching its recheck, a dead run behind a delivered terminal status escalating, an undelivered needs-decision: still surfacing, a genuinely unresponsive pane still reported, and a regression driving two park spells in one watcher lifetime that each escalate. docs/architecture.md, docs/configuration.md, AGENTS.md, and .agents/skills/afk/SKILL.md document the park markers, cadence, and per-verb signal paths.

Risk Assessment

⚠️ Medium: The round-3 delta is small, correct, and closes both round-2 findings with a genuinely discriminating regression test, but the branch as a whole still reworks ~250 lines of the watcher's wake-triage hot path and carries three deliberately deferred warnings (unreachable daemon cleanup, an imprecise architecture.md sentence, and the duplicated stale-key transform).

Testing

I ran the watcher triage suite (41/41), the daemon suite (99/99) and the adjacent watcher-lock, wake-queue and watch-checkpoint suites (all green), then built CLI transcripts that drive the real bin/fm-watch.sh through re-arms the way fm-watch-arm.sh does: the live defect burns 12 firstmate wakes over six re-arms of two parked crews on base a5fe1bc and zero on this branch, the declaring status still reaches firstmate once through the signal path while only the redundant bare stale wakes disappear, the bounded nets each fire exactly once (recheck labelled a recheck, frozen pane still rechecked, escalation flagged a possible wedge, declared waits never escalating, undelivered and undeclared crews still surfaced immediately), and a before/after comparison against ece9fdc shows the park latch that previously silenced the second park spell forever now yielding one escalation per spell. This is a shell watcher with no rendered surface, so the reviewer-visible evidence is CLI transcripts rather than screenshots; the worktree was left clean and the temporary base checkouts removed.

Evidence: Hot loop before/after: 12 wakes on base a5fe1bc vs 0 on this branch

=== BEFORE (base a5fe1bc, pre-fix watcher) === crew test:fm-merge - declared external wait, agent still alive re-arm 1..6 (pane re-rendered): WOKE -> stale: test:fm-merge (x6) crew test:fm-decision - needs-decision already delivered to firstmate re-arm 1..6 (pane re-rendered): WOKE -> stale: test:fm-decision (x6) TOTAL firstmate wakes across both crews / 6 re-arms each: 12 === AFTER (6b1502d, this branch) === crew test:fm-merge re-arm 1..6: quiet -> absorbed stale (paused, awaiting external, age 5s..31s) crew test:fm-decision re-arm 1..6: quiet -> absorbed stale (parked on needs-decision, age 5s..31s) wake queue firstmate would drain: (empty) TOTAL firstmate wakes across both crews / 6 re-arms each: 0

=== BEFORE (base a5fe1bc, pre-fix watcher) ===
scenario: two crews finished, both waiting on the captain; panes idle but re-rendering
knobs: FM_PAUSE_RESURFACE_SECS=3600 (recheck window), FM_STALE_ESCALATE_SECS=3600

  crew test:fm-merge - declared external wait, agent still alive
  last status line: paused: waiting on the captain to merge the PR
    re-arm 1 (pane re-rendered): WOKE  -> stale: test:fm-merge
    re-arm 2 (pane re-rendered): WOKE  -> stale: test:fm-merge
    re-arm 3 (pane re-rendered): WOKE  -> stale: test:fm-merge
    re-arm 4 (pane re-rendered): WOKE  -> stale: test:fm-merge
    re-arm 5 (pane re-rendered): WOKE  -> stale: test:fm-merge
    re-arm 6 (pane re-rendered): WOKE  -> stale: test:fm-merge
    => firstmate turns burned over 6 re-arms: 6
    => wake queue firstmate would drain:
         stale	stale: test:fm-merge
         stale	stale: test:fm-merge
         stale	stale: test:fm-merge
         stale	stale: test:fm-merge
         stale	stale: test:fm-merge
         stale	stale: test:fm-merge

  crew test:fm-decision - needs-decision already delivered to firstmate
  last status line: needs-decision: ship the fallback or wait for upstream?
    re-arm 1 (pane re-rendered): WOKE  -> stale: test:fm-decision
    re-arm 2 (pane re-rendered): WOKE  -> stale: test:fm-decision
    re-arm 3 (pane re-rendered): WOKE  -> stale: test:fm-decision
    re-arm 4 (pane re-rendered): WOKE  -> stale: test:fm-decision
    re-arm 5 (pane re-rendered): WOKE  -> stale: test:fm-decision
    re-arm 6 (pane re-rendered): WOKE  -> stale: test:fm-decision
    => firstmate turns burned over 6 re-arms: 6
    => wake queue firstmate would drain:
         stale	stale: test:fm-decision
         stale	stale: test:fm-decision
         stale	stale: test:fm-decision
         stale	stale: test:fm-decision
         stale	stale: test:fm-decision
         stale	stale: test:fm-decision

TOTAL firstmate wakes across both crews / 6 re-arms each: 12
Evidence: AFTER transcript (this branch, wake queue empty)
=== AFTER (6b1502d, this branch) ===
scenario: two crews finished, both waiting on the captain; panes idle but re-rendering
knobs: FM_PAUSE_RESURFACE_SECS=3600 (recheck window), FM_STALE_ESCALATE_SECS=3600

  crew test:fm-merge - declared external wait, agent still alive
  last status line: paused: waiting on the captain to merge the PR
    re-arm 1 (pane re-rendered): quiet -> absorbed stale (paused, awaiting external, age 5s): test:fm-merge
    re-arm 2 (pane re-rendered): quiet -> absorbed stale (paused, awaiting external, age 9s): test:fm-merge
    re-arm 3 (pane re-rendered): quiet -> absorbed stale (paused, awaiting external, age 15s): test:fm-merge
    re-arm 4 (pane re-rendered): quiet -> absorbed stale (paused, awaiting external, age 20s): test:fm-merge
    re-arm 5 (pane re-rendered): quiet -> absorbed stale (paused, awaiting external, age 26s): test:fm-merge
    re-arm 6 (pane re-rendered): quiet -> absorbed stale (paused, awaiting external, age 31s): test:fm-merge
    => firstmate turns burned over 6 re-arms: 0
    => wake queue firstmate would drain:
         (empty)

  crew test:fm-decision - needs-decision already delivered to firstmate
  last status line: needs-decision: ship the fallback or wait for upstream?
    re-arm 1 (pane re-rendered): quiet -> absorbed stale (parked on needs-decision, age 5s): test:fm-decision
    re-arm 2 (pane re-rendered): quiet -> absorbed stale (parked on needs-decision, age 10s): test:fm-decision
    re-arm 3 (pane re-rendered): quiet -> absorbed stale (parked on needs-decision, age 15s): test:fm-decision
    re-arm 4 (pane re-rendered): quiet -> absorbed stale (parked on needs-decision, age 20s): test:fm-decision
    re-arm 5 (pane re-rendered): quiet -> absorbed stale (parked on needs-decision, age 26s): test:fm-decision
    re-arm 6 (pane re-rendered): quiet -> absorbed stale (parked on needs-decision, age 31s): test:fm-decision
    => firstmate turns burned over 6 re-arms: 0
    => wake queue firstmate would drain:
         (empty)

TOTAL firstmate wakes across both crews / 6 re-arms each: 0
Evidence: Bounded-silence nets on this branch (recheck, frozen pane, escalation, undelivered, unresponsive)

[recheck] re-arm 1 WOKE stale: test:fm-decision (parked 504s on needs-decision, rechecked on a long cadence not a wedge; confirm the crew is still legitimately waiting) / re-arms 2-3 quiet -> 1 wake [frozen] re-arm 1 WOKE same recheck reason on the repeat-hash path / re-arm 2 quiet -> 1 wake [escalate] re-arm 1 WOKE stale: ... (idle 500s behind an already-delivered needs-decision, possible wedge - the crew may have been re-tasked and stopped since; peek before re-absorbing) / re-arm 2 quiet declared paused, idle 500s past threshold: quiet -> 0 wakes [undelivered] re-arm 1 WOKE stale: test:fm-decision -> 1 wake [unresponsive] re-arm 1 WOKE stale: test:fm-quiet -> 1 wake

=== SAFETY NETS (6b1502d, this branch) ===

[declaration] the crew declaring the wait still reaches firstmate once, through the status signal
    re-arm 1 (status not yet consumed)             WOKE  signal: /tmp/fm-park-nets.cWNwFP/nets-declaration/state/paused.status
    re-arm 2 (declaration already delivered)       quiet
    re-arm 3 (declaration already delivered)       quiet
    => wake queue firstmate would drain:
         signal	signal: /tmp/fm-park-nets.cWNwFP/nets-declaration/state/paused.status
         signal	signal: /tmp/fm-park-nets.cWNwFP/nets-declaration/state/paused.status

[recheck] a park past its window is re-confirmed ONCE, labelled a recheck not a wedge
    re-arm 1 (park 500s old, window 240s)          WOKE  stale: test:fm-decision (parked 504s on needs-decision, rechecked on a long cadence not a wedge; confirm the crew is still legitimately waiting)
    re-arm 2 (still inside the same window)        quiet
    re-arm 3 (still inside the same window)        quiet
    => stale wakes queued: 1

[frozen] a park whose pane STOPS re-rendering still reaches its recheck (repeat-hash path)
    re-arm 1 (pane byte-identical)                 WOKE  stale: test:fm-decision (parked 500s on needs-decision, rechecked on a long cadence not a wedge; confirm the crew is still legitimately waiting)
    re-arm 2 (same window)                         quiet
    => stale wakes queued: 1

[escalate] a dead run behind an ALREADY-DELIVERED needs-decision escalates once; a declared wait never does
    re-arm 1 (idle 500s, threshold 240s)           WOKE  stale: test:fm-decision (idle 500s behind an already-delivered needs-decision, possible wedge - the crew may have been re-tasked and stopped since; peek before re-absorbing)
    re-arm 2 (latched)                             quiet
    => stale wakes queued: 1
    declared paused, idle 500s past threshold      quiet
    => stale wakes queued for the declared wait: 0

[spells] TWO park spells in ONE watcher lifetime must EACH escalate (re-tasked crew writes no new status)
    spell 1: run died behind the park              WOKE  stale: test:fm-decision (idle 501s behind an already-delivered needs-decision, possible wedge - the crew may have been re-tasked and stopped since; peek before re-absorbing)
      latch after spell 1: 1785146699 fired
    re-tasked: pane busy again                     quiet
      latch after the busy pane: (released)
    spell 2: pane settles back to idle             quiet
    spell 2: past due on its own timer             WOKE  stale: test:fm-decision (idle 5s behind an already-delivered needs-decision, possible wedge - the crew may have been re-tasked and stopped since; peek before re-absorbing)
    spell 2: still past due                        quiet
    => stale wakes queued (one escalation per spell = 2): 2

[undelivered] a needs-decision firstmate has NOT been shown still surfaces at once
    re-arm 1 (no .hb-surfaced marker)              WOKE  stale: test:fm-decision
    => stale wakes queued: 1

[unresponsive] a crew that just went quiet with NO declaration still surfaces at once
    re-arm 1 (idle pane, no declaration)           WOKE  stale: test:fm-quiet
    => stale wakes queued: 1
Evidence: Park-latch regression: second park spell silent pre-fix (ece9fdc), escalates once per spell after

=== ece9fdc (before 382af82), re-tasked pane churns every poll === spell 1: WOKE (possible wedge) latch after spell 1: fired re-tasked: pane busy again latch after the busy pane: fired <- never released spell 2: past due on its own timer: quiet spell 2: still past due: quiet => stale wakes queued: 1 === 6b1502d (this branch), same scenario === spell 1: WOKE (possible wedge) latch after spell 1: 1785146699 fired re-tasked: pane busy again latch after the busy pane: (released) spell 2: past due on its own timer: WOKE (possible wedge) spell 2: still past due: quiet => stale wakes queued: 2

=== PARK-LATCH REGRESSION (ece9fdc, before commit 382af82) - re-tasked pane churns every poll ===

[spells] TWO park spells in ONE watcher lifetime must EACH escalate (re-tasked crew writes no new status)
    spell 1: run died behind the park              WOKE  stale: test:fm-decision (idle 500s behind an already-delivered needs-decision, possible wedge - the crew may have been re-tasked and stopped since; peek before re-absorbing)
      latch after spell 1: fired
    re-tasked: pane busy again                     quiet
      latch after the busy pane: fired
    spell 2: pane settles back to idle             quiet
    spell 2: past due on its own timer             quiet
    spell 2: still past due                        quiet
    => stale wakes queued (one escalation per spell = 2): 1
Evidence: Deliberate change: declaration still delivered once, only the redundant stale wakes gone

BASE a5fe1bc: re-arm 1 WOKE signal: .../paused.status ; re-arm 2 WOKE stale: test:fm-paused ; re-arm 3 WOKE stale: test:fm-paused 6b1502d: re-arm 1 WOKE signal: .../paused.status ; re-arm 2 quiet ; re-arm 3 quiet

=== BASE a5fe1bc (pre-fix) - same declaration scenario ===

[declaration] the crew declaring the wait still reaches firstmate once, through the status signal
    re-arm 1 (status not yet consumed)             WOKE  signal: /tmp/fm-park-nets.KX36hm/nets-declaration/state/paused.status
    re-arm 2 (declaration already delivered)       WOKE  stale: test:fm-paused
    re-arm 3 (declaration already delivered)       WOKE  stale: test:fm-paused
    => wake queue firstmate would drain:
         signal	signal: /tmp/fm-park-nets.KX36hm/nets-declaration/state/paused.status
         signal	signal: /tmp/fm-park-nets.KX36hm/nets-declaration/state/paused.status
         stale	stale: test:fm-paused
         stale	stale: test:fm-paused
Evidence: Repro driver: parked-crew hot loop across watcher re-arms
#!/usr/bin/env bash
# park-hotloop-repro.sh <repo-tree> <label>
#
# Replays the live 2026-07-20 defect against a real bin/fm-watch.sh from
# <repo-tree>: two crews that have finished and are waiting on the captain (one
# on a declared `paused:` wait, one on a needs-decision firstmate has already
# been shown), each sitting on an idle pane that keeps re-rendering a context
# counter. Each round is one watcher re-arm, exactly what fm-watch-arm.sh does
# after every wake. "WOKE" means firstmate burned a turn; "quiet" means the
# watcher kept watching with nothing to report.
set -u
TREE=$1; LABEL=$2
ROUNDS=${ROUNDS:-6}

# shellcheck source=/dev/null
. "$TREE/tests/wake-helpers.sh"
# shellcheck source=/dev/null
. "$TREE/bin/fm-classify-lib.sh"
WATCH="$TREE/bin/fm-watch.sh"
TMP_ROOT=$(fm_test_tmproot fm-park-repro)

seen_sig() {
  if [ "$(uname)" = Darwin ]; then stat -f '%z:%Fm' "$1" 2>/dev/null; else stat -c '%s:%Y' "$1" 2>/dev/null; fi
}
wait_live() {
  local pid=$1 limit=${2:-45} i=0
  while [ "$i" -lt "$limit" ]; do
    kill -0 "$pid" 2>/dev/null || return 1
    sleep 0.1; i=$((i + 1))
  done
  return 0
}
reap() { kill "$1" 2>/dev/null || true; wait "$1" 2>/dev/null || true; }

# A crew parked on <status-line>: pane already stably stale, status signal already
# consumed, and (for a captain-relevant line) already recorded as delivered.
make_parked_crew() {  # <case> <task> <window> <status-line>
  local name=$1 task=$2 window=$3 line=$4 dir state key
  dir=$(make_case "$name"); state="$dir/state"
  printf 'window=%s\nkind=ship\nharness=claude\nbackend=tmux\n' "$window" > "$state/$task.meta"
  printf '%s\n' "$line" > "$state/$task.status"
  printf '%s' "$(seen_sig "$state/$task.status")" > "$state/.seen-${task}_status"
  status_is_captain_relevant "$line" && printf '%s' "$line" > "$state/.hb-surfaced-$task"
  printf 'idle parked agent pane\ncontext left: 90%%\n' > "$dir/pane.txt"
  key=$(printf '%s' "$window" | tr ':/.' '___')
  printf '%s' "$(hash_text "$(cat "$dir/pane.txt")")" > "$state/.hash-$key"
  printf '1\n' > "$state/.count-$key"
  printf '%s\n' "$dir"
}

run_crew() {  # <case> <task> <window> <status-line> <crew-state-verdict> <blurb>
  local name=$1 task=$2 window=$3 line=$4 verdict=$5 blurb=$6
  local dir state fakebin out round pid result woke=0
  dir=$(make_parked_crew "$name" "$task" "$window" "$line")
  state="$dir/state"; fakebin="$dir/fakebin"; out="$dir/watch.out"
  printf '\n  crew %s - %s\n' "$window" "$blurb"
  printf '  last status line: %s\n' "$line"
  round=1
  while [ "$round" -le "$ROUNDS" ]; do
    # The idle pane re-renders between re-arms, as a live agent TUI does.
    printf 'idle parked agent pane\ncontext left: %s%%\n' "$((90 - round))" > "$dir/pane.txt"
    : > "$out"
    PATH="$fakebin:$PATH" FM_FAKE_TMUX_WINDOW="$window" FM_FAKE_TMUX_CAPTURE="$dir/pane.txt" \
      FM_FAKE_TMUX_CURRENT_COMMAND=claude \
      FM_STATE_OVERRIDE="$state" FM_CREW_STATE_BIN="$fakebin/fm-crew-state.sh" \
      FM_POLL=1 FM_SIGNAL_GRACE=1 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 \
      env FM_PAUSE_RESURFACE_SECS=3600 FM_STALE_ESCALATE_SECS=3600 \
      "FM_FAKE_CREW_STATE=$verdict" "$WATCH" >> "$out" 2>&1 &
    pid=$!
    if wait_live "$pid" 45; then reap "$pid"; result=quiet; else wait "$pid" 2>/dev/null || true; result=WOKE; fi
    if [ "$result" = WOKE ]; then
      woke=$((woke + 1))
      printf '    re-arm %s (pane re-rendered): WOKE  -> %s\n' "$round" \
        "$(grep -m1 . "$out" 2>/dev/null || echo '(no reason printed)')"
    else
      printf '    re-arm %s (pane re-rendered): quiet -> %s\n' "$round" \
        "$(grep -h 'absorbed stale' "$state/.watch-triage.log" 2>/dev/null | tail -1 | sed 's/^\[[^]]*\] //' || echo 'absorbed')"
    fi
    round=$((round + 1))
  done
  printf '    => firstmate turns burned over %s re-arms: %s\n' "$ROUNDS" "$woke"
  printf '    => wake queue firstmate would drain:\n'
  if [ -s "$state/.wake-queue" ]; then
    awk -F '\t' '{ printf "         %s\t%s\n", $3, $5 }' "$state/.wake-queue"
  else
    printf '         (empty)\n'
  fi
  TOTAL_WOKE=$((TOTAL_WOKE + woke))
}

TOTAL_WOKE=0
printf '=== %s ===\n' "$LABEL"
printf 'scenario: two crews finished, both waiting on the captain; panes idle but re-rendering\n'
printf 'knobs: FM_PAUSE_RESURFACE_SECS=3600 (recheck window), FM_STALE_ESCALATE_SECS=3600\n'
run_crew park-repro-paused paused test:fm-merge \
  'paused: waiting on the captain to merge the PR' \
  'state: paused · source: status-log · waiting on the captain' \
  'declared external wait, agent still alive'
run_crew park-repro-decision decision test:fm-decision \
  'needs-decision: ship the fallback or wait for upstream?' \
  'state: parked · source: run-step · parked at review' \
  'needs-decision already delivered to firstmate'
printf '\nTOTAL firstmate wakes across both crews / %s re-arms each: %s\n' "$ROUNDS" "$TOTAL_WOKE"
Evidence: Repro driver: park safety nets and two-spell escalation
#!/usr/bin/env bash
# park-nets-repro.sh <repo-tree> <label> [scenario...]
#
# The other half of the park change: the silence must be bounded. Drives a real
# bin/fm-watch.sh from <repo-tree> through each safety net and prints exactly what
# firstmate would be told. Scenarios: recheck frozen escalate spells undelivered
# unresponsive (default: all).
set -u
TREE=$1; LABEL=$2; shift 2
WANT=${*:-declaration recheck frozen escalate spells undelivered unresponsive}

# shellcheck source=/dev/null
. "$TREE/tests/wake-helpers.sh"
# shellcheck source=/dev/null
. "$TREE/bin/fm-classify-lib.sh"
WATCH="$TREE/bin/fm-watch.sh"
TMP_ROOT=$(fm_test_tmproot fm-park-nets)

seen_sig() { stat -c '%s:%Y' "$1" 2>/dev/null; }
file_mtime() { stat -c %Y "$1" 2>/dev/null; }
wait_live() {
  local pid=$1 limit=${2:-45} i=0
  while [ "$i" -lt "$limit" ]; do
    kill -0 "$pid" 2>/dev/null || return 1
    sleep 0.1; i=$((i + 1))
  done
  return 0
}
reap() { kill "$1" 2>/dev/null || true; wait "$1" 2>/dev/null || true; }
key_of() { printf '%s' "$1" | tr ':/.' '___'; }

make_parked_crew() {  # <case> <task> <window> <status-line> [deliver:0] [seen:0]
  local name=$1 task=$2 window=$3 line=$4 deliver=${5:-1} seen=${6:-1} dir state key
  dir=$(make_case "$name"); state="$dir/state"
  # Same fake tmux as the suite's, plus one faithful detail the live defect turns
  # on: while $dir/churn exists the pane re-renders an elapsed line on EVERY
  # capture, as a working agent TUI does, so no two polls ever see the same hash.
  cat > "$dir/fakebin/tmux" <<'SH'
#!/usr/bin/env bash
set -u
if [ "${1:-}" = "list-windows" ]; then
  [ -n "${FM_FAKE_TMUX_WINDOW:-}" ] && printf '%s\n' "${FM_FAKE_TMUX_WINDOW#*:}"
  exit 0
fi
if [ "${1:-}" = "capture-pane" ]; then
  if [ -n "${FM_FAKE_TMUX_CAPTURE:-}" ]; then
    cat "$FM_FAKE_TMUX_CAPTURE"
    if [ -n "${FM_FAKE_TMUX_CHURN:-}" ] && [ -f "$FM_FAKE_TMUX_CHURN" ]; then
      printf 'rendered at %s\n' "$(date +%s%N)"
    fi
  fi
  exit 0
fi
if [ "${1:-}" = "display-message" ]; then
  case "$*" in *pane_current_command*) printf '%s\n' "${FM_FAKE_TMUX_CURRENT_COMMAND:-}"; exit 0 ;; esac
fi
exit 1
SH
  chmod +x "$dir/fakebin/tmux"
  printf 'window=%s\nkind=ship\nharness=claude\nbackend=tmux\n' "$window" > "$state/$task.meta"
  printf '%s\n' "$line" > "$state/$task.status"
  [ "$seen" = 1 ] && printf '%s' "$(seen_sig "$state/$task.status")" > "$state/.seen-${task}_status"
  if [ "$deliver" = 1 ] && status_is_captain_relevant "$line"; then
    printf '%s' "$line" > "$state/.hb-surfaced-$task"
  fi
  printf 'idle parked agent pane\ncontext left: 90%%\n' > "$dir/pane.txt"
  key=$(key_of "$window")
  printf '%s' "$(hash_text "$(cat "$dir/pane.txt")")" > "$state/.hash-$key"
  printf '1\n' > "$state/.count-$key"
  printf '%s\n' "$dir"
}

age_status() { touch -m -d "@$(( $(date +%s) - $3 ))" "$1/$2.status"; printf '%s' "$(seen_sig "$1/$2.status")" > "$1/.seen-${2}_status"; }
freeze_pane() { printf '%s' "$(hash_text "$(cat "$1/pane.txt")")" > "$1/state/.stale-$(key_of "$2")"; }
# Seed the park's escalation timer as if the current spell had been idle <secs>.
# The spell-scoped marker ("<status mtime> <started>") only exists in the fixed
# watcher; the earlier one holds a bare epoch, so seed whichever this tree reads.
seed_park_timer() {  # <state> <task> <window> <secs-ago>
  local started=$(( $(date +%s) - $4 ))
  if grep -q 'park_wedge_check() {  # <window> <task>' "$TREE/bin/fm-watch.sh"; then
    printf '%s %s' "$(file_mtime "$1/$2.status")" "$started" > "$1/.park-since-$(key_of "$3")"
  else
    printf '%s' "$started" > "$1/.park-since-$(key_of "$3")"
  fi
}

# One watcher re-arm. mode: churn (pane re-renders), frozen (byte-identical), busy.
cycle() {  # <dir> <window> <mode> <verdict> <resurface> <escalate> <round>
  local dir=$1 window=$2 mode=$3 verdict=$4 rs=$5 esc=$6 round=${7:-0}
  local state="$dir/state" fakebin="$dir/fakebin" out="$dir/watch.out" pid
  case "$mode" in
    churn) printf 'idle parked agent pane\ncontext left: %s%%\n' "$((90 - round))" > "$dir/pane.txt"; rm -f "$dir/churn" ;;
    busy)  printf 'working the re-task\nesc to interrupt · %ss elapsed\n' "$((10 + round))" > "$dir/pane.txt"; : > "$dir/churn" ;;
    frozen) rm -f "$dir/churn" ;;
  esac
  : > "$out"
  PATH="$fakebin:$PATH" FM_FAKE_TMUX_WINDOW="$window" FM_FAKE_TMUX_CAPTURE="$dir/pane.txt" \
    FM_FAKE_TMUX_CURRENT_COMMAND=claude FM_FAKE_TMUX_CHURN="$dir/churn" \
    FM_STATE_OVERRIDE="$state" FM_CREW_STATE_BIN="$fakebin/fm-crew-state.sh" \
    FM_POLL=1 FM_SIGNAL_GRACE=1 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 \
    env FM_PAUSE_RESURFACE_SECS="$rs" FM_STALE_ESCALATE_SECS="$esc" \
    "FM_FAKE_CREW_STATE=$verdict" "$WATCH" >> "$out" 2>&1 &
  pid=$!
  if wait_live "$pid" 45; then
    reap "$pid"
    printf '    %-46s quiet\n' "$8"
  else
    wait "$pid" 2>/dev/null || true
    printf '    %-46s WOKE  %s\n' "$8" "$(grep -m1 . "$out" 2>/dev/null || echo '(no reason)')"
  fi
}

queue_count() { [ -e "$1/.wake-queue" ] && awk -F '\t' -v w="$2" '$3=="stale" && $4==w {n++} END{print n+0}' "$1/.wake-queue" || printf 0; }

printf '=== %s ===\n' "$LABEL"

case " $WANT " in *" declaration "*)
  printf '\n[declaration] the crew declaring the wait still reaches firstmate once, through the status signal\n'
  d=$(make_parked_crew nets-declaration paused test:fm-paused 'paused: waiting at an active external-decision gate' 1 0)
  V='state: paused · source: status-log · waiting on the captain'
  cycle "$d" test:fm-paused churn "$V" 3600 3600 1 're-arm 1 (status not yet consumed)'
  cycle "$d" test:fm-paused churn "$V" 3600 3600 2 're-arm 2 (declaration already delivered)'
  cycle "$d" test:fm-paused churn "$V" 3600 3600 3 're-arm 3 (declaration already delivered)'
  printf '    => wake queue firstmate would drain:\n'
  awk -F '\t' '{printf "         %s\t%s\n", $3, $5}' "$d/state/.wake-queue" 2>/dev/null || printf '         (empty)\n'
esac

case " $WANT " in *" recheck "*)
  printf '\n[recheck] a park past its window is re-confirmed ONCE, labelled a recheck not a wedge\n'
  d=$(make_parked_crew nets-recheck decision test:fm-decision 'needs-decision: ship the fallback or wait for upstream?')
  age_status "$d/state" decision 500
  V='state: parked · source: run-step · parked at review'
  cycle "$d" test:fm-decision churn "$V" 240 240 1 're-arm 1 (park 500s old, window 240s)'
  cycle "$d" test:fm-decision churn "$V" 240 240 2 're-arm 2 (still inside the same window)'
  cycle "$d" test:fm-decision churn "$V" 240 240 3 're-arm 3 (still inside the same window)'
  printf '    => stale wakes queued: %s\n' "$(queue_count "$d/state" test:fm-decision)"
esac

case " $WANT " in *" frozen "*)
  printf '\n[frozen] a park whose pane STOPS re-rendering still reaches its recheck (repeat-hash path)\n'
  d=$(make_parked_crew nets-frozen decision test:fm-decision 'needs-decision: ship the fallback or wait for upstream?')
  freeze_pane "$d" test:fm-decision; age_status "$d/state" decision 500
  V='state: parked · source: run-step · parked at review'
  cycle "$d" test:fm-decision frozen "$V" 240 999999 0 're-arm 1 (pane byte-identical)'
  cycle "$d" test:fm-decision frozen "$V" 240 999999 0 're-arm 2 (same window)'
  printf '    => stale wakes queued: %s\n' "$(queue_count "$d/state" test:fm-decision)"
esac

case " $WANT " in *" escalate "*)
  printf '\n[escalate] a dead run behind an ALREADY-DELIVERED needs-decision escalates once; a declared wait never does\n'
  d=$(make_parked_crew nets-escalate decision test:fm-decision 'needs-decision: ship the fallback or wait for upstream?')
  freeze_pane "$d" test:fm-decision; seed_park_timer "$d/state" decision test:fm-decision 500
  V='state: unknown · source: none · no current-state source available'
  cycle "$d" test:fm-decision frozen "$V" 999999 240 0 're-arm 1 (idle 500s, threshold 240s)'
  cycle "$d" test:fm-decision frozen "$V" 999999 240 0 're-arm 2 (latched)'
  printf '    => stale wakes queued: %s\n' "$(queue_count "$d/state" test:fm-decision)"
  d=$(make_parked_crew nets-escalate-paused paused test:fm-paused 'paused: waiting on the captain to merge the PR')
  freeze_pane "$d" test:fm-paused; seed_park_timer "$d/state" paused test:fm-paused 500
  cycle "$d" test:fm-paused frozen 'state: paused · source: status-log · waiting on the captain' 999999 240 0 \
    'declared paused, idle 500s past threshold'
  printf '    => stale wakes queued for the declared wait: %s\n' "$(queue_count "$d/state" test:fm-paused)"
esac

case " $WANT " in *" spells "*)
  printf '\n[spells] TWO park spells in ONE watcher lifetime must EACH escalate (re-tasked crew writes no new status)\n'
  d=$(make_parked_crew nets-spells decision test:fm-decision 'needs-decision: ship the fallback or wait for upstream?')
  w=test:fm-decision; k=$(key_of "$w")
  freeze_pane "$d" "$w"; seed_park_timer "$d/state" decision "$w" 500
  DEAD='state: unknown · source: none · no current-state source available'
  cycle "$d" "$w" frozen "$DEAD" 999999 240 0 'spell 1: run died behind the park'
  printf '      latch after spell 1: %s\n' "$(cat "$d/state/.park-since-$k" 2>/dev/null || echo '(none)')"
  cycle "$d" "$w" busy 'state: working · source: pane · harness busy' 999999 240 1 're-tasked: pane busy again'
  printf '      latch after the busy pane: %s\n' "$(cat "$d/state/.park-since-$k" 2>/dev/null || echo '(released)')"
  # Spell 2 runs on whatever timer the WATCHER itself keeps: nothing is re-seeded
  # here, so a latch the busy pane failed to release stays spent. The threshold is
  # dropped to 0 to stand in for "spell 2 is already past due" without waiting.
  cycle "$d" "$w" churn "$DEAD" 999999 240 2 'spell 2: pane settles back to idle'
  cycle "$d" "$w" churn "$DEAD" 999999 0 3 'spell 2: past due on its own timer'
  cycle "$d" "$w" churn "$DEAD" 999999 0 4 'spell 2: still past due'
  printf '    => stale wakes queued (one escalation per spell = 2): %s\n' "$(queue_count "$d/state" "$w")"
esac

case " $WANT " in *" undelivered "*)
  printf '\n[undelivered] a needs-decision firstmate has NOT been shown still surfaces at once\n'
  d=$(make_parked_crew nets-undelivered decision test:fm-decision 'needs-decision: ship the fallback or wait for upstream?' 0)
  cycle "$d" test:fm-decision churn 'state: parked · source: run-step · parked at review' 999999 999999 1 \
    're-arm 1 (no .hb-surfaced marker)'
  printf '    => stale wakes queued: %s\n' "$(queue_count "$d/state" test:fm-decision)"
esac

case " $WANT " in *" unresponsive "*)
  printf '\n[unresponsive] a crew that just went quiet with NO declaration still surfaces at once\n'
  d=$(make_parked_crew nets-unresponsive quiet test:fm-quiet 'working: compiling the fallback')
  cycle "$d" test:fm-quiet churn 'state: unknown · source: none · no current-state source available' 999999 999999 1 \
    're-arm 1 (idle pane, no declaration)'
  printf '    => stale wakes queued: %s\n' "$(queue_count "$d/state" test:fm-quiet)"
esac
Evidence: Watch triage suite log (41/41)
ok - signal_reason_is_actionable: benign absorbed, captain verbs and coalesced batches surfaced
ok - stale_is_terminal: terminal status surfaces, non-terminal and no-status are benign
ok - scan_captain_relevant_statuses lists only captain-relevant statuses
ok - classifier primitives: keyed decisions and activity phases, captain relevance, window-to-task, and overrides
ok - crew_is_provably_working: only working+run-step/pane is provable; idle/finished/parked/failed/unknown surface
ok - status_is_paused: only the leading paused verb matches, and paused is not captain-relevant
ok - crew_absorb_class: working/paused/none from one read; crew_is_paused and crew_is_provably_working agree
ok - signal_crew_provably_working: benign only when every referenced crew is provably working
ok - a no-verb signal whose crew is provably working is absorbed (no exit, no queue, suppressor advanced, beacon present)
ok - a bare turn-end whose crew is provably working (busy pane) is absorbed
ok - a bare turn-end whose crew is not provably working is surfaced (the swallowed-finish fix)
ok - a no-verb working: note whose crew is idle with no running pipeline is surfaced
ok - captain-relevant signal is surfaced (queue + exit) and marked surfaced
ok - a stale pane sitting on a terminal status is surfaced (queue + exit)
ok - a stale terminal-looking status is overridden and absorbed while a run is actively working, then wedge-escalated
ok - provably-working non-terminal stale is absorbed on first sight, then wedge-escalated past the threshold
ok - consecutive wedge escalations on the same pane accumulate and demand deep inspection at the threshold
ok - a pane becoming active again resets the consecutive wedge-escalation counter
ok - a not-provably-working non-terminal stale is surfaced immediately (never left to wait out the timer)
ok - a declared pause is absorbed on first sight, then re-surfaced as a recheck past the threshold, never wedge-escalated
ok - exited declared-pause and captain-held panes use bounded pause cadence while a live decision gate declares itself once through the status signal
ok - a parked crew (declared pause or delivered needs-decision) does not wake on first sight and does not hot-loop across re-arms
ok - a park is re-confirmed exactly once per recheck window, labelled a recheck rather than a wedge
ok - the park gate still surfaces an undelivered terminal status and a crew that genuinely stopped responding
ok - a park whose pane stops re-rendering still reaches its bounded recheck on the repeat-poll path
ok - a delivered captain-relevant park escalates once when its run dies, while a declared wait never does
ok - each park spell in one watcher lifetime gets its own escalation, released by a busy pane or a new status event
ok - an overridden terminal stale escalates once on a frozen pane, then hands the window to the park handler
ok - a declared paused secondmate re-surfaces on the bounded normal-mode cadence
ok - a non-paused secondmate retains normal stale suppression
ok - a resumed secondmate clears pause and stale tracking before stale exemption
ok - unchanged stale hashes reclassify when a crew enters or leaves pause
ok - a declared pause is periodically rechecked against authoritative active-run state
ok - a paused status overridden by authoritative working preserves its wedge timer and escalates
ok - matching non-terminal stale suppressors repair missing or corrupt stale-since timers
ok - triage log capping handles wc byte counts with leading spaces
ok - a heartbeat with no captain-relevant change is absorbed and backs off the cadence
ok - heartbeat backstop fail-safe surfaces a captain-relevant status the per-wake path missed
ok - the liveness beacon stays fresh while the watcher absorbs benign wakes (fm-guard never false-alarms)
ok - with .afk present the watcher reverts to one-shot so the daemon owns triage (no double-triage)
ok - AFK changed paused panes hand off plain stale identities for daemon-owned pause triage
- Evidence: Daemon suite log (99/99) (local file: /tmp/no-mistakes-evidence/01KYHCVFCKSYDS2DVBY13BFW0F/daemon-suite.log)
Evidence: Evidence index and re-run instructions
# Evidence: fm/watcher-paused-idle-loop-p3b (parked-crew watcher hot loop)

Transcripts were produced by driving the real `bin/fm-watch.sh` from each tree
through watcher re-arms, exactly as `fm-watch-arm.sh` does after every wake.

- `before-base-a5fe1bc.txt` / `after-6b1502d.txt` - the live defect: two crews
  waiting on the captain, panes re-rendering. 12 firstmate wakes before, 0 after.
- `declaration-before-base.txt` vs the `[declaration]` block of
  `nets-after-6b1502d.txt` - the deliberate change: the declaring status still
  reaches firstmate once through the signal path, and only the redundant bare
  stale wakes are gone.
- `nets-after-6b1502d.txt` - the bounded-silence nets: recheck once per window,
  frozen pane still rechecked, one escalation per park spell, declared waits
  never wedge-escalated, undelivered and undeclared crews still surfaced at once.
- `spells-before-ece9fdc.txt` vs `spells-after-6b1502d.txt` - the
  park-latch-never-released finding: pre-fix the second park spell in one watcher
  lifetime is silent forever; fixed, each spell escalates exactly once.
- `triage-suite.log`, `daemon-suite.log`, `fm-watcher-lock.log`,
  `fm-wake-queue.log`, `fm-watch-checkpoint.log` - suite runs.

To re-run a comparison, export the tree under test and point a driver at it:

    mkdir -p /tmp/fm-base-tree && git archive a5fe1bc | tar -x -C /tmp/fm-base-tree
    bash park-hotloop-repro.sh /tmp/fm-base-tree "BEFORE"
    bash park-nets-repro.sh <repo-root> "AFTER" [scenario...]

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 4 issues found → auto-fixed (2) ✅
  • 🚨 bin/fm-watch.sh:412 - The fired latch park_wedge_check writes into .park-since-&lt;key&gt; has no release path a re-tasked crew reaches, so the escalation is one-shot per watcher lifetime, not per park spell. Trace: crew parks on a delivered needs-decision:, escalates, latches. Firstmate re-tasks it. (a) The busy release at line 1098 requires n &gt;= 2, i.e. three consecutive byte-identical 40-line captures while window_is_busy is true - a working TUI churns its footer every poll, so the hash never repeats and control always lands in the changed-hash branch at line 1103, which deliberately preserves $pkf. (b) The provably-working release at line 1001 requires a stably-stale NEW hash plus crew_is_provably_working, which a churning pane never reaches. (c) The surface release at line 1014 requires the stale path to see the new status while still undelivered, but the signal path surfaces a fresh status first, calls mark_surfaced, and wake exits the process before the stale loop at line 933 runs; the next cycle already sees the status delivered, so crew_is_parked is true and park_wedge_check returns early on fired. Net effect: for park spell 2 onward a re-tasked crew whose run died behind an unchanged delivered terminal line is only caught at the FM_PAUSE_RESURFACE_SECS recheck (3600s default) instead of FM_STALE_ESCALATE_SECS (240s). docs/architecture.md:27 asserts the opposite ("fires at most once per park spell and is released only by evidence the crew resumed"), and no test exercises two park spells in one watcher lifetime - test_delivered_terminal_park_escalates_once_when_its_run_dies only pins the first escalation and the latch holding. Needs a real release condition plus a regression test driving two park spells in one lifetime, each escalating.
  • ⚠️ bin/fm-supervise-daemon.sh:468 - The .park-since-$watcher_key removal added to the daemon's clear_pause_tracking is dead code for the only state that produces the marker. .park-since-&lt;key&gt; is written exclusively by fm-watch.sh's park_wedge_check, which runs only for a captain-relevant status (handle_parked_stale returns early and rm's the file for paused: / captain-held). The daemon reaches clear_pause_tracking only from reconcile_pause_tracking's elif [ -e &#34;$marker&#34; ] || [ -e &#34;$state/.paused-$watcher_key&#34; ] branch, and for a captain-relevant status neither file can exist: pause_marker_record writes .subsuper-paused-&lt;task&gt; only under status_is_paused, and .paused-&lt;watcher_key&gt; is cleared by fm-watch.sh:940 the moment the status stops being paused/captain-held while handle_parked_stale never sets it. Consequence: a fired latch (or a live park timer) survives an away-mode round trip untouched, compounding the latch-release defect above. Either give the daemon a reachable trigger keyed on the captain-relevant park, or drop the unreachable rm and record the ownership.
  • ⚠️ docs/architecture.md:28 - "A park's own declaring status write still surfaces once through the normal-mode no-verb signal path" generalizes to every park, but the no-verb path only covers the paused: / captain-held half. done:, needs-decision:, blocked: and failed: all satisfy status_is_captain_relevant, so their declaring write surfaces through the captain-relevant signal path (and the heartbeat's .hb-surfaced-&lt;task&gt; backstop), not the no-verb path - which is precisely why crew_is_parked needs the delivery marker for that half and not for the other. Split the sentence so each half names its actual delivery path.
  • ⚠️ bin/fm-watch.sh:948 - The window-to-stale-key transform is open-coded eight times in fm-watch.sh across two idioms that must stay in lockstep, and this change adds a site (handle_parked_stale, line 364). printf &#39;%s&#39; &#34;$win&#34; | tr &#39;:/.&#39; &#39;___&#39; at lines 319, 364, 485, 948; the key=${win//:/_}; key=${key//\//_}; key=${key//./_} chain at lines 418-420, 426-428, 439-441, 936-938. Lines 936-938 and 948 recompute the identical value inside the same loop iteration. fm-supervise-daemon.sh:427 already defines _stale_key(); lift it into a shared lib (fm-classify-lib.sh or fm-push-transition-lib.sh) and call it from every site. If the character set ever diverges between the two idioms, a window's .stale-&lt;key&gt; and .park-since-&lt;key&gt; silently point at different keys and both park nets break with no error.

🔧 Fix: scope park escalation latch to its park spell, not the watcher lifetime
2 issues (1 warning, 1 info) still open:

  • ⚠️ tests/fm-watch-triage.test.sh:1159 - The new-status-event half of test_two_park_spells_in_one_lifetime_each_escalate cannot fail on the regression it names. Line 1152 seeds the spent latch as &lt;pre-append mtime&gt; fired; line 1153 appends a new status so the file mtime becomes now. Line 1159 then compares the marker against fired_latch &#34;$state&#34; decision, which evaluates to &lt;post-append mtime&gt; fired - a string the implementation never writes on this path. An implementation that ignored the spell id and carried the spent latch across the status event would leave &lt;pre-append mtime&gt; fired in place, the comparison would be false, and the &amp;&amp; fail would not trigger. Line 1161's seed_park_timer then overwrites the marker with a fresh numeric timer, so the escalation assertion at line 1165 passes regardless. The busy-pane half of the same test does discriminate correctly, so the headline once-per-park-spell requirement is covered; only this release path is untested. Fix: capture the old-spell latch string into a local before deliver_park_status and assert the marker no longer equals it (or assert the marker matches &lt;new mtime&gt; &lt;digits&gt;), and let spell 2's own timer age past the threshold instead of overwriting it.
  • ℹ️ bin/fm-watch.sh:291 - The new park_status_mtime helper's header states "Both park nets are anchored on it", but only park_wedge_check calls it. park_recheck_due (line 313) still open-codes the same stat_mtime &#34;$STATE/$task.status&#34; read, and the two disagree on the unreadable-file fallback: park_status_mtime yields 0 (line 297) while park_recheck_due yields date +%s (line 314). If a status file is momentarily unreadable, park_wedge_check treats the spell as id 0 and rewrites the marker with a restarted timer while park_recheck_due computes PARK_AGE=0 and suppresses the recheck - both fail safe, but the helper's stated single-source invariant is false. Route park_recheck_due through park_status_mtime, or narrow the comment to name only park_wedge_check.

🔧 Fix: discriminate the park-spell release test and share one status-mtime read
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-watch-triage.test.sh (41/41, includes the seven new park cases and the two-park-spell regression test)
  • bash tests/fm-daemon.test.sh (99/99, covers the daemon-side .park-since cleanup edit)
  • bash tests/fm-watcher-lock.test.sh (28/28), bash tests/fm-wake-queue.test.sh (12/12), bash tests/fm-watch-checkpoint.test.sh (4/4)
  • Manual end-to-end hot-loop replay driving the real bin/fm-watch.sh through 6 watcher re-arms for a paused: crew and a delivered needs-decision: crew with a re-rendering pane: bash park-hotloop-repro.sh /tmp/fm-base-tree &#34;BEFORE&#34; vs bash park-hotloop-repro.sh &lt;worktree&gt; &#34;AFTER&#34;
  • Manual safety-net replay bash park-nets-repro.sh &lt;worktree&gt; &#34;SAFETY NETS&#34; covering scenarios declaration / recheck / frozen / escalate / spells / undelivered / unresponsive against the real watcher
  • Manual park-latch regression comparison bash park-nets-repro.sh /tmp/fm-prelatch-tree ... spells (ece9fdc) vs the same scenario on 6b1502d, with the re-tasked pane churning on every poll
  • Manual deliberate-change check bash park-nets-repro.sh /tmp/fm-base-tree ... declaration (base a5fe1bc) vs the [declaration] block on this branch
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

CORRECTION 1 - the recorded hypothesis was wrong. The backlog item
watcher-paused-idle-loop-p3 blamed the first-sight stale path in the arm
wrapper, reasoning that because the watcher exits on a wake, every re-arm is a
fresh first sight. It is not. bin/fm-watch-arm.sh emits no wake of its own; it
only prints the watcher's output. A restart alone does not re-trigger a first
sight either, because .hash-*, .count-* and .stale-* all persist on disk - six
re-arms against a stable idle pane produce one wake, then silence.

The real cause is pane-hash churn. The stale suppressor .stale-<key> is keyed
on the PANE HASH, and a parked crew's pane keeps re-rendering an elapsed clock
or a context counter, so every re-render is a genuinely new hash and therefore a
real fresh first sight. Both first-sight paths then surfaced a bare
`stale: <window>` with no cadence throttle: the non-terminal path because
pause_state_class returns `none` whenever the agent is alive, and the terminal
path because needs-decision: is captain-relevant and the crew is not provably
working. A third site sustained it for paused: the changed-hash branch called
clear_pause_tracking, discarding the recheck throttle on every re-render.

CORRECTION 2 - the continuity-gate recommendation is moot. The item recommends
weighing whether to add bin/fm-send.sh to bin/fm-continuity-pretool-check.sh's
recovery set. That gate no longer exists: it and fm-continuity-command-policy.mjs
were deleted in b05eb24 (kunchenguid#1001, 2026-07-24). docs/watcher-continuity.md now
states that no PreToolUse hook denies fleet commands based on watcher status,
and the surviving policy returns allow for fm-send.sh, fm-peek.sh,
fm-crew-state.sh and fm-session-start.sh. No safety-boundary change is needed.

THE FIX. A crew is PARKED when it has declared where it stopped and firstmate
already knows: a `paused:` external wait, a `captain-held` transfer, or a
captain-relevant status whose delivery is recorded in state/.hb-surfaced-<task>.
Both first-sight surface sites now gate on that, absorbing and re-confirming
once per FM_PAUSE_RESURFACE_SECS, anchored on the crew's own status file so pane
churn cannot reset the cadence. The changed-hash path keeps the park
bookkeeping when the agent is live rather than discarding it.

Detection is not widened by the absorb. The delivery test means an undelivered
done/needs-decision/blocked/failed still surfaces on first sight, and the
heartbeat backstop rechecks the same marker. A crew with no declaration, the
provably-working wedge timer, the escalation counter, secondmate handling and
away-mode triage are all untouched. The one real trade-off: a crew that declares
`paused:` and then genuinely wedges now surfaces at the recheck window rather
than shortly after each pane re-render.
SC1010: in argument position bash already treats the bare word as the literal
string, so this is a parse-clarity fix with no behaviour change. Quoted per
shellcheck's own guidance rather than suppressed with a disable directive.

This is the first finding real shellcheck has ever reported on this branch: the
earlier lint step exited 127 because the binary was absent.
@staneja15
staneja15 merged commit c58ff7e into main Jul 27, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant