Skip to content

fix(bin): report a dead-agent record once instead of escalating forever - #4775

Merged
kunchenguid merged 6 commits into
kunchenguid:mainfrom
umeranjum17:fm/fm-dead-record-escalation2
Sep 18, 2026
Merged

kunchenguid merged 6 commits into
kunchenguid:mainfrom
umeranjum17:fm/fm-dead-record-escalation2

Conversation

@umeranjum17

@umeranjum17 umeranjum17 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

A record whose agent is gone now reports itself once instead of escalating forever.

Fixes #4722

The problem

The wedge escalation path never asked whether there was still an agent to be wedged. A wedge means something is stuck and might recover, so re-alarming it earns its cost. An agent that is gone never moves again: its pane never churns, the idle timer never resets, and the escalate path clears its own timer and re-arms with nothing bounding the count.

Observed on a live fleet, with numbers:

  • Two finished lanes reached 226 and 203 consecutive escalations, roughly one every FM_STALE_ESCALATE_SECS, indefinitely. Together that is about 400 notifications a day from two lanes with no agent running at all.
  • bin/fm-control.sh <id> exit on one of them answered already-stopped. The agent had been gone for hours. bin/fm-crew-state.sh read failed - run failed. Every alarm after its death was noise.
  • Closing the Herdr pane did not stop it. With the pane genuinely gone and herdr pane read returning pane_not_found, the escalation counter kept climbing, because the poll is driven by the durable record's window= line rather than by the pane.
  • The only thing that stopped it was retiring state/<id>.meta.

The cost is not the repetition itself. It is that ~400 alarms a day from finished lanes drown the alarms that matter, until the supervisor stops reading any of them.

fm_backend_agent_state already separated an agent that is thinking from one that is gone. The escalation path simply never consulted it.

What changed

In the branch that was about to escalate, bin/fm-watch.sh now reads fm_backend_agent_state once. Only its two recovery-grade verdicts count as proof: dead (the endpoint is present with no agent running in it) and missing (the endpoint is authoritatively absent). Such a record is reported once, naming which verdict fired, and is not re-escalated while it stays that way.

The once-marker records the verdict together with the task's per-incarnation busy gen (state/<id>.busy-gen, owned by bin/fm-busy-event.sh), which is re-minted exactly when an agent is armed or relaunched. A successor launched into the same window therefore gets the full alarm back, and its own later death is reported in full. Where no incarnation token is readable the pane hash stands in, because an unreadable token must never mean "report on every threshold" - that would hand back the storm this change exists to close.

The probe runs only inside the at-threshold branch, so it costs at most one backend read per window per FM_STALE_ESCALATE_SECS, the same budget the declared-wait consult and the worktree write probe already take.

What this deliberately does not change

  • A genuinely wedged live agent escalates exactly as before - identical schedule, reason, escalation count, and demand-deep-inspection wording. That path is load-bearing and is untouched.
  • Every verdict short of proof - alive, ambiguous, unreadable, unverified, and a read that failed outright - keeps that same unchanged behaviour. This narrows which panes escalate, never how loudly the ones that still do.
  • Nothing auto-retires and nothing auto-tears-down. Both lanes that produced this behaviour still held unlanded work, and teardown refusing them was correct. Reporting the record once is the whole job; deciding its fate stays with the supervisor.
  • No wedge alarms are silenced or rate-limited in general. The distinction added here is dead versus stuck, not loud versus quiet.

Why this is trustworthy

The fault was reproduced before any code was written - a record pointing at an endpoint that does not exist, driven through the real watcher, with the counter climbing every threshold. That reproduction is the regression test, and it fails without the fix (possible wedge, escalation 1) and passes with it.

tests/fm-watch-triage.test.sh pins both directions, because a bound proved only in the quiet direction is indistinguishable from deleting wedge detection:

  • dead and missing endpoints report once and never advance the escalation count across later thresholds.
  • alive, ambiguous, and unreadable endpoints keep escalating with the identical reason and a climbing count.
  • A successor launched into the same window is reported on its own death, including when no threshold probe ever read it alive in between.
  • A successor whose dead display is byte-identical to the one already reported is still reported. This is the case worth singling out: a dead pane tends to look exactly like the previous dead pane - a bare-shell husk prompt in the same cwd, an empty restored scrollback - so a marker keyed on appearance alone would have swallowed a real, new death. Replacing a noisy failure with a silent one would have been strictly worse than the bug being fixed, since the noisy version at least told the truth 226 times.

Check status

Thirteen of the fourteen checks pass on this exact head.

The fourteenth, Behavior portable serial 1, reported no verdict either way: it was cancelled, not failed. Run 35284949308 is on this head (ae7f3a0), and its concurrency rule cancelled the in-flight run when a newer push superseded it; job id 105415114606 has conclusion cancelled. The immediately preceding run on this branch, 35273818897, completed success with that same job green.

Rerunning it needs admin rights on this repository, which the contributor does not have - single-job rerun, run-level rerun, and workflow dispatch were all refused, and ci.yml declares no workflow_dispatch trigger. A maintainer can clear it in one click by rerunning that job. No no-op commit was pushed to manufacture a fresh run, since that would trade a clearly explained gap for a quietly misleading green.

Known limitation

fm_backend_agent_state reads live rovo-on-herdr panes as dead, which docs/verification/rovo.md already records as a Herdr-side integration gap (Herdr ships no rovo agent detection). This change is a new consumer of that verdict, so a stalled-but-live rovo worker on backend=herdr would get the single dead-record report and then stay quiet rather than escalating as a wedge. That is pre-existing and documented rather than introduced here, and it is left for a deliberate owner-side follow-up instead of being worked around in this change.

Related

Related, and not closed by this change:

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ tests/fm-watch-triage.test.sh:2933 - test_identical_dead_display_of_a_successor_still_reports asserts the outcome (successor death reported, later thresholds silent) but never asserts its stated premise that the dead display is byte-identical across rounds; today that holds only structurally (the capture file is never rewritten), so a future edit rewriting $capture mid-test would silently turn the decision-required byte-identical case into a hash-distinguishable one that passes for the wrong reason. Pin the premise with an observable-state assertion: record $(cat "$state/.hash-$key") after the first death round and assert it is unchanged after the successor's death round, matching the anti-vacuity pattern the ticking-pause test in the same file uses.
✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 1 of 1 scenarios driven live against the product
Scenario Result Live Evidence
Operator runs bin/fm-watch.sh end-to-end against a real tmux backend (isolated socket) with the real crew-state binary and real fm state; the dead-record escalation fix behaves correctly in the li… ✅ pass live Live end-to-end drive of bin/fm-watch.sh against an isolated-socket tmux backend with the real crew-state binary and real fm state, as recorded in this run's testing output
  • bin/fm-watch.sh end-to-end against a real tmux backend on an isolated socket with the real crew-state binary (dead-record escalation path)
⚠️ **Document** - 1 info
  • ℹ️ docs/architecture.md:36 - The new dead-record absorb is one more consumer of fm_backend_agent_state's dead verdict, which docs/verification/rovo.md (lines 206-210) records as reading live rovo-on-herdr panes as dead; a stalled-but-live rovo worker on backend=herdr would therefore get the single dead-record report and then be silenced instead of escalating as a wedge. rovo.md's existing warning already covers 'any recovery path that trusts this classifier', so no edit was made here; if rovo-on-herdr is a supported placement, its one-shot silence is a behavioral consequence worth a deliberate owner-side follow-up in docs/verification/rovo.md or the architecture dead-record contract.
✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…ing forever

The wedge escalation path never asked whether there was still an agent to be
wedged. A wedge is something stuck that might recover, so re-alarming it earns
its cost; an agent that is gone never moves again, its pane never churns, the
idle timer never resets, and the escalate path clears its own timer and re-arms
with nothing bounding the count.

Observed on a live fleet: two finished lanes reached 226 and 203 consecutive
escalations, roughly one every FM_STALE_ESCALATE_SECS, indefinitely - about 400
notifications a day from two lanes with no agent running at all. On one,
fm-control.sh exit answered already-stopped and fm-crew-state.sh read
"failed - run failed". Closing the Herdr pane did not stop it either: with the
pane genuinely gone and herdr pane read returning pane_not_found, the count kept
climbing, because the poll is driven by the record's window= line rather than by
the pane. The cost is not the repetition but that it drowns the alarms that
matter.

fm_backend_agent_state already separates a thinking agent from a gone one at
process level. In the branch that was about to escalate, read it once and treat
only its two recovery-grade verdicts - dead (endpoint present, no agent in it)
and missing (endpoint authoritatively absent) - as proof, reporting that record
once and not re-escalating it while it stays that way. Every other verdict,
including alive, ambiguous, unreadable, unverified, and a read that failed
outright, keeps the identical schedule, reason, and escalation count, so a
genuinely wedged live agent is unaffected. The probe costs at most one backend
read per window per threshold, the same budget the declared-wait consult and the
worktree write probe already take.

The report decides nothing about the record's fate: both lanes still held
unlanded work and teardown refusing them was correct, so retiring, relaunching,
or cleaning up stays with the supervisor. The once-only marker is owned entirely
by that function and is dropped by the same read the moment the endpoint stops
reading gone, so a replacement launched into the same window escalates normally
and its own later death is reported again.

Related, and not closed by this: kunchenguid#4412, kunchenguid#4482, kunchenguid#4316.

Tests drive the real watcher against a record whose endpoint does not exist and
pin both directions: dead and missing report once and never advance the count
across later thresholds, while alive, ambiguous, and unreadable endpoints keep
escalating with the identical reason and a climbing count.
Review of the parent commit found a reachable sequence where a later death in
the same window lost its promised report. The marker was keyed on the verdict
string alone and dropped only when a threshold probe read a non-gone verdict,
but probes run only at thresholds: a replacement launched into the same window
that dies without ever being probed alive - it crashes at startup, or works and
then crashes - was absorbed by the previous death's marker. The pane's first
sight yielded only the generic stale wake and every later threshold matched the
stale marker, so the second death never got the detailed once-report that both
the function's own comment and docs/architecture.md promise.

Record the verdict together with the pane hash it was reported for, and absorb a
repeat only while both still match. A replacement churns the pane, which resets
the stale suppressor, wedge timer, and escalation count while no reset site
touches this marker, so the pane half is what tells the second death apart from
the first. The live-probe drop stays as it was.

Clearing the marker at those reset sites instead would re-open unbounded
re-alarming for a dead pane whose display ever ticks, which is the exact defect
the parent commit exists to close.

The noise bound is unchanged: an unchanged dead pane still absorbs on every
later threshold and never advances the escalation count, and every verdict short
of proof still escalates exactly as before.
@umeranjum17
umeranjum17 force-pushed the fm/fm-dead-record-escalation2 branch from a2b6ca2 to ae7f3a0 Compare September 17, 2026 23:02
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

First look on HEAD ae7f3a0cafd1c991dc4433cf0edf6274de7696ee. Whole thread read (body + pipeline; no prior comments/reviews). Tip vs main 888871de inspected (bin/fm-watch.sh dead-record probe, docs, tests/fm-watch-triage.test.sh). No .github/**.

Author body vs #4722: body explicitly Fixes #4722 and matches issue #4722 (dead/missing agent wedge-escalates forever; closing the pane does not stop it). Sort-hint closesReadyForPr confirmed by body — not title-only.

Attestation: MATCH — body head_sha=ae7f3a0cafd1c991dc4433cf0edf6274de7696ee equals tip. NM raise PASS.

Contract-class: restore — unconfigured watcher already promised wedge escalation for stuck live agents; dead/missing endpoints were wrongly on that ladder with no ceiling. Probe uses existing fm_backend_agent_state recovery-grade dead/missing only; live/ambiguous/unreadable keep identical escalation. Once-marker keyed to busy-gen so a successor death still reports. Nothing auto-retires. Not new-default.

VISION.md (per rule):

  • One captain, one interface: aligns — stops ~400/day corpse alarms drowning real escalations; still reports once with reconcile wording.
  • Authority is explicit and never inferred: aligns — no auto-teardown; supervisor decides fate.
  • Scripts own the mechanics: aligns — scripted agent-state probe at threshold only.
  • A restart is a non-event: aligns — durable once-marker + busy-gen incarnation.
  • Delegation with a spine: aligns — supervision honesty for finished lanes.
  • The fleet outlives any vendor: aligns — uses backend agent-state contract.
  • Scope: aligns — watcher mechanics only.

CI: tip run 35284949308 previously CANCELLED (serial 1 concurrency cancel; other jobs SUCCESS). Maintainer re-queued that run this pass — waiting for full green before auto-merge.
Closes: #4722 (author body).
Outcome: waiting-ci. No Firstmate flag.
Security/product FYI (not a merge gate): new consumer of fm_backend_agent_state dead — rovo-on-herdr already documented as reading live panes as dead (docs/verification/rovo.md); stalled-but-live rovo/herdr would get one-shot silence. Pre-existing classifier gap; left for owner follow-up.

@kunchenguid kunchenguid left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Speaking as Kun's firstmate: approving after tip security review (fork ruleset require_extra_approval_for_unattributed_changes). Tip ae7f3a0 — CI 35284949308 all SUCCESS after maintainer requeue; attestation MATCH; class restore; closes #4722 per author body; no .github/**.

@kunchenguid
kunchenguid merged commit 9bc051f into kunchenguid:main Sep 18, 2026
27 of 28 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @umeranjum17 — really appreciate you taking the time on this.