Repository navigation
fix(bin): honour a declared wait before wedge-escalating a quiet pane - #4586
Conversation
wedge_timer_check escalated on elapsed idle time alone. Nothing asked whether the worker had already said why its pane was quiet, so a lane that declared a bounded external wait climbed the escalation ladder for as long as the wait lasted, and past FM_WEDGE_DEMAND_INSPECT_COUNT every repeat carried demand-deep-inspection - which by its own wording forbids re-absorbing on the run-step or pane state, so the supervisor could not use the evidence that was there either. The generated brief promises that declaring `paused:` buys the long recheck cadence instead of a wedge, but the timer was still reachable while that declaration stood: a crew that declares a wait and then has an active run or busy pane attributed to it is handed to the timer as provably-working. The declaration is what the worker said about its own silence, so it now outranks a liveness verdict that only says something is running. The consult runs in the at-threshold branch that was about to escalate, beside the worktree walk already there, and costs one status-line read. Either status-line record defers to the same FM_PAUSE_RESURFACE_SECS recheck the declared-wait absorber already uses, so the wait is still rechecked and cannot rot invisibly. Which verb declared it decides the wording, because the two block on different people: a `paused:` wait is owed by an external dependency and asks the reader to confirm it still holds, while a `captain-held:` transfer is owed by the captain reading the recheck and asks them to answer or release the hold. A hold is not rechecked at all while the away-posture record exists, as on every other captain-held path, and that absorb arms no throttle so the recheck is owed in full on return. A declared clearing time that has already passed stops counting, and a lane that never declared one keeps the identical escalation schedule, reason, count and demand-deep-inspection wording, so detection and its worst-case time are unchanged. The deferral restarts the idle timer rather than cancelling it, so a lane that stops waiting escalates again within one threshold. A lane quiet because its own validation run is parked at a gate awaiting a human decision is deliberately out of scope: reading that state needs a signal carrying who the wait is on and what clears it, rather than one inferred from a parked verdict that also covers gates awaiting the crewmate itself. Tests pin both directions for each case and were each confirmed to fail with the consult removed.
|
Speaking as Kun's firstmate: this is merged. Thank you @aminry — really appreciate you taking the time on this. contract-class: restore — generated brief already promises that a declared VISION (per-rule): One captain/one interface — aligns (fewer false demand-deep-inspection wakes). Authority explicit — aligns (no new autonomy; declaration already captain-facing). Scripts own mechanics — aligns (deterministic status-line consult in fm-watch.sh). Restart non-event — aligns (durable .waiting-* markers). Delegation with a spine — aligns (refusal/recheck path strengthened). Fleet outlives vendor — aligns (status-line contract, not UI pixels). Scope — aligns (supervision honesty, not workshop). |
Intent
The watcher escalates a lane as a possible wedge even when that lane has positively declared a bounded wait that has not elapsed. The escalation then repeats indefinitely, and each one costs a supervising turn.
#3909: a crewmate that declared a bounded external wait still escalates once the pane ages past
FM_STALE_ESCALATE_SECS, reachingdemand-deep-inspectionon a lane that was verifiably working.crew_absorb_classreturnspausedfor a declared wait, and aging appears to escalate without re-consulting that verdict.#2614: the same defect reported from the other side - an idle pane whose latest status line is a declared
paused:wait is still wedge-escalated at the idle threshold, repeatedly and with a monotonically growing escalation count, and once that count is high every escalation carriesdemand-deep-inspection, which by its own wording forces the supervisor to spend a full handling turn on each one. Investigated against current main rather than assumed: its declared-pause-on-an-idle-pane form and its busy-pane form no longer reproduce, and the one form that still reproduces is identical to #3909's, so it is closed by the same change rather than by separate work.Both meet at
wedge_timer_check, which escalates on elapsed idle time without ever consulting the worker's own account of its silence.The goal is that a lane whose own declared wait has not elapsed is rechecked on a long cadence as the declared wait it is, rather than escalated as a suspected wedge. The generated crewmate brief already promises exactly this - that declaring
paused:means the supervisor leaves the idle pane alone and rechecks it on a long cadence instead of treating it as a possible wedge - so this restores behaviour the supervision contract already states rather than adding a new capability, and it applies by default rather than behind a configuration flag. The existing workaround of raisingFM_STALE_ESCALATE_SECSis not a fix: it delays real wedge detection by exactly the same amount for every lane.A lane with no such declaration must keep its current escalation schedule, reasons and wake wording unchanged, so genuine wedge detection is not weakened and its worst-case detection time does not move. Both directions are required as executable tests: the declared-wait lane is rechecked on the long cadence with no escalation counted, and a lane with no declaration still escalates on exactly the unchanged schedule with unchanged wake wording.
The recheck must also name which human the wait is on. A
paused:declaration is owed by an external dependency the worker named, while acaptain-held:transfer is owed by the captain reading the recheck; wording a hold as an external wait points the captain away from the one action that clears it. A hold is not rechecked at all while the away-posture record exists, consistent with every other captain-held path, since nobody is there to answer it.A known bound worth stating rather than hiding: the recheck throttle is scoped to the pane hash, so the long cadence holds for a lane whose pane is genuinely static, while a lane whose display churns (a ticking clock, a token counter) drops the throttle with each new hash and is rechecked once per idle window instead. That lane still loses the escalation ladder and the
demand-deep-inspectionwording, which is the defect being fixed, but it is not the full delivery of a long cadence. The alternative, letting the throttle outlive the hash, trades this for a stale throttle surviving into an unrelated later episode and suppressing that episode's first recheck, which is the worse failure.A lane that is quiet because its own validation run is parked at a gate awaiting a human decision is deliberately out of scope here and keeps the unchanged ladder. Recognising that state correctly needs a signal that carries who the wait is on and what clears it, rather than one inferred from a parked verdict that also covers gates awaiting the crewmate itself; a crewmate that wedges before answering its own gate must remain detectable. That case is left for separate work.
One pre-existing contract case,
test_paused_authoritative_working_preserves_wedge_timer, asserted that a paused status overridden by an authoritative working verdict preserves its wedge timer and escalates. That escalation is the defect #3909 reports, so the case could not survive the fix unchanged. Its wedge-timer-preservation half is retained, its past-threshold half now asserts the bounded recheck, and a lifted-declaration leg was added so the case still proves that escalation resumes once the wait is withdrawn.Closes #3909
Closes #2614
What Changed
wedge_timer_checkinbin/fm-watch.shnow consults the pane's own account of its quiet before escalating: a newwedge_wait_evidencereads the worker's last status line for an unelapsedpaused:declaration or a verifiedcaptain-held:transfer, andwedge_defer_waitroutes that lane to theFM_PAUSE_RESURFACE_SECSrecheck cadence instead of the wedge ladder, leaving the escalation counter untouched. The recheck is aged from the status file mtime and worded by verb, so apaused:wait asks the reader to confirm the external dependency while a hold asks the captain to answer or release it; a hold is absorbed silently and arms no throttle while the away-posture record exists. A lane with no declaration, or one whose declareduntiltime has passed, keeps the unchanged schedule, reason anddemand-deep-inspectionwording..waiting-resurfaced-*throttle marker to the cleanup paths that reset a window's stale bookkeeping (clear_stale_hash_trackinginbin/fm-watch.sh,clear_pause_trackinginbin/fm-supervise-daemon.sh) and to the state-file inventory inAGENTS.md.tests/fm-watch-triage.test.shcovering both directions: a declared wait under a working verdict is rechecked with no escalation counted while an elapsed declaration and an undeclared lane both still reach escalation 3 with thedemand-deep-inspectionwording, and a captain-held lane is rechecked as a hold on the captain, never as an external wait, and not at all while the captain is away. The pre-existingtest_paused_authoritative_working_preserves_wedge_timerkeeps its wedge-timer-preservation half, now asserts the bounded recheck past threshold, and gained a lifted-declaration leg proving escalation resumes.docs/architecture.mdanddocs/configuration.mddescribe the consult, its wording split, and the known pane-hash throttle bound for lanes whose display churns.Risk Assessment
✅ Low: The change is tightly scoped to the one at-threshold branch, leaves undeclared lanes bit-identical in schedule and wording, adds both-direction executable tests, and the only issue found is a comment that overstates an invariant on a deliberate away-mode exception.
Testing
I derived the scenarios from the intent's two required directions (a declared wait must be rechecked rather than escalated; an undeclared lane must keep its exact schedule, reasons and wake wording) plus adversarial probes at every boundary the intent names, then drove all of them against the real watcher process running over real state homes, with only tmux and the crew-state probe faked. Everything the intent promises held live: a declared
paused:wait survives three consecutive thresholds with no wake, nopossible wedgewording and no escalation counted, and once it outlives the cadence it surfaces aswaiting 2003s - declared wait, awaiting external, rechecked on a long cadence not a wedge; confirm the wait still holds, aged from the declaration itself; acaptain-held:lane instead readsawaiting the captain ... answer the held decision or release the hold, and under the away-posture record it prints nothing at all and arms no throttle, so the recheck is owed in full the moment the record is archived, which I confirmed by archiving it and seeing the recheck return immediately. The adversarial legs matter most and all passed: an undeclared lane still climbs escalation 1 to 3 and still carries the demand-deep-inspection sentence verbatim, a declaration whoseuntiltime has already passed still escalates aspossible wedge, escalation 1, and withdrawing a declaration restores escalation on the very next idle window. The regression direction is proved rather than assumed: the identical driver run against the pre-fix base tree fails 19 checks and reproduces the reported defect exactly, wedge-escalating the declared wait up to escalation 4 with the demand-deep-inspection marker, while the two non-regression scenarios behave identically before and after. One honest caveat: the churning-pane probe passes on the base tree too, so it confirms the documented bound holds but is not itself a before/after discriminator. No screenshot or rendered artifact is included because this change has no UI surface - the end-user surface is the wake reason line the watcher prints to the supervising captain, and the CLI transcripts capture that text exactly as the captain receives it.possible wedge, and wrote no .wedge-escalations marker; triage lo…stale: fleet:fm-crew-validate (idle 2s, waiting 2003s - declared wait, awaiting external, rechecked on a long cadence not a wedge; confirm the wait still holds); pub…demand-deep-inspection: same pane has wedge-escalated 3 times in a row - do not re-absorb on the run-step/pane state alone, byte-identi…untilclearing time has already passed stops counting as evidence and keeps the unchanged wedge ladderpaused: waiting on the build queue until <2h in the past>: watcher surfacedpossible wedge, escalation 1, identical to the base tree. Artifact s4-elapsed-until.wake.txtwaiting 2002s - captain-held, awaiting the captain - verified hold transfer ...; answer the held decision or release the hold, with noawaiting external, no `confirm the wait still…never rechecked while the away-posture record exists; after a…possible wedge, nodemand-deep-inspection, no escalation counter. This is the bound the ch…paused:stands, then after the worker appendsworking: the release landed, resuming validationthe next window emitspossible wedge, escalation 1. Arti…Evidence: Live end-to-end transcript at the target commit (8 scenarios, 0 failures)
Source: Live end-to-end transcript at the target commit (8 scenarios, 0 failures)
Evidence: Same driver against the pre-fix base tree bdcacb9 (19 failures - the reported defect reproducing)
Source: Same driver against the pre-fix base tree bdcacb9 (19 failures - the reported defect reproducing)
Evidence: Before/after of the captain-facing wake line for the same declared wait
Evidence: Live driver script (reproducible, takes repo root and output dir)
Source: Live driver script (reproducible, takes repo root and output dir)
Evidence: Daemon reconciliation clearing the wait-recheck throttle (target commit)
Source: Daemon reconciliation clearing the wait-recheck throttle (target commit)
Evidence: Same daemon check against the pre-fix base tree (throttle survives)
Source: Same daemon check against the pre-fix base tree (throttle survives)
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-watch.sh:1037- The new header claims the wait consult and worktree probe run "at most one each per window per STALE_ESCALATE_SECS, never per poll" (and docs/architecture.md:27 repeats it as "never on an ordinary poll"), but the away-silenced captain-held branch of wedge_defer_wait (bin/fm-watch.sh:984-988) returns beforedate +%s > "$since_file"at line 1012, so the wedge timer is never restarted. Concrete sequence: a lane whose last status line iscaptain-held: ...with the away-posture record present crosses STALE_ESCALATE_SECS; on every subsequent pollage >= STALE_ESCALATE_SECSstill holds, so the threshold branch re-runs wedge_wait_evidence (a status-file grep) and appends a triage_log line once per FM_POLL (15s default) for the entire away window, instead of once per 240s. Not resetting the timer is deliberate and correct - it is what makes the recheck owed immediately when the record is archived, which the new test pins - so the remedy is to correct the two comments to state the exception, not to change the code. No wake, escalation count or user-visible behavior is affected; the triage log is size-capped and AGENTS.md marks it as never relied on.✅ **Test** - passed
✅ No issues found.
possible wedge, and wrote no .wedge-escalations marker; triage lo…stale: fleet:fm-crew-validate (idle 2s, waiting 2003s - declared wait, awaiting external, rechecked on a long cadence not a wedge; confirm the wait still holds); pub…demand-deep-inspection: same pane has wedge-escalated 3 times in a row - do not re-absorb on the run-step/pane state alone, byte-identi…untilclearing time has already passed stops counting as evidence and keeps the unchanged wedge ladderpaused: waiting on the build queue until <2h in the past>: watcher surfacedpossible wedge, escalation 1, identical to the base tree. Artifact s4-elapsed-until.wake.txtwaiting 2002s - captain-held, awaiting the captain - verified hold transfer ...; answer the held decision or release the hold, with noawaiting external, no `confirm the wait still…never rechecked while the away-posture record exists; after a…possible wedge, nodemand-deep-inspection, no escalation counter. This is the bound the ch…paused:stands, then after the worker appendsworking: the release landed, resuming validationthe next window emitspossible wedge, escalation 1. Arti…bin/fm-test-run.sh tests/fm-watch-triage.test.sh- 115/115 pass, exit 0 (owning suite for bin/fm-watch.sh; includes the two new casestest_wedge_threshold_defers_to_a_declared_wait_under_a_working_verdictandtest_wedge_threshold_recheck_names_the_captain_for_a_held_lane, and the rewrittentest_paused_authoritative_working_preserves_wedge_timer)bin/fm-test-run.sh tests/fm-daemon.test.sh- 126/126 pass, exit 0 (owning suite for the touched bin/fm-supervise-daemon.sh)Manual live driverlive-wedge-drive.sh- stands up real firstmate state homes and runs the realbin/fm-watch.shprocess through 8 end-to-end scenarios (declared wait, long-cadence recheck, undeclared control ladder, elapseduntil, captain-held recheck, captain-held under the away-posture record and on return, churning pane, withdrawn declaration); 0 of 33 checks failedSame driver re-run against a pre-fix tree extracted from base commitbdcacb9- 19 checks fail, reproducing the reported escalation ladder anddemand-deep-inspectionwording on a declared waitManual live driverlive-daemon-throttle-drive.sh- drives the realreconcile_pause_trackingentry point ofbin/fm-supervise-daemon.shagainst real state; passes on the target and fails on the base treegit status --porcelain- worktree clean, no transient test artifacts left behinddocs/architecture.md:62- Out-of-scope consolidation worth a follow-up: the "Event-driven supervision" section now states the declared-wait-is-not-a-wedge rule twice, ~40 lines apart, for two distinct mechanisms. Lines 20-30 (added by this change) describe the wedge-timer deferral for a live, provably-working pane, while line 62 describes the older pause_state_class absorb for a pane whose agent is confidently dead, using near-identical wording ("re-surfaced only on the longer pause cadence, rather than being treated as a possible wedge"). Read on its own, line 62 reads as though it already covers the case this change fixed. Neither statement is wrong, so nothing here is stale; resolving it means restructuring the section into one declared-wait subsection that distinguishes the live and dead-agent paths, which is beyond this change's scope.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.