Skip to content

fix: deliver afk escalations when Herdr is idle - #2

Merged
knowttl merged 1 commit into
mainfrom
fm/fm-afk-wedge-fix-c2
Jul 15, 2026
Merged

knowttl merged 1 commit into
mainfrom
fm/fm-afk-wedge-fix-c2

Conversation

@knowttl

@knowttl knowttl commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Diagnosis

The primary read-only daemon log recorded repeated inject deferred: supervisor pane busy (agent mid-turn) events and a 31,726-second max-defer wedge.

pane_is_busy asked Herdr for native state but then re-scanned scrollback when it reported idle; historical quoted esc to interrupt output therefore made an idle supervisor appear busy indefinitely.

A related tmux submit-verification bug treated Claude’s ❯ plus U+00A0 empty composer as pending because POSIX [:space:] does not trim U+00A0.

Fix

  • Treat a legible Herdr native busy or idle status as conclusive for the supervisor injection guard, while retaining regex fallback for unknown.
  • Keep the confirmed-empty composer guard and type-once, Enter-only submit model unchanged.
  • Add shared U+00A0-aware edge trimming without discarding U+00A0 inside typed text.
  • Record the 2026-07-15 incident and verification in docs/herdr-backend.md.

Tests and verification

Confirmed before this PR:

  • bash tests/fm-composer-lib.test.sh passed.
  • bash tests/fm-daemon.test.sh passed.
  • PATH="$PWD/.tmp-bin:$PATH" bin/fm-lint.sh passed with the repository-pinned ShellCheck 0.11.0 installer.
  • Regression coverage includes native-idle scrollback containing esc to interrupt, a max-defer delivery simulation, and the Claude U+00A0 composer state.

No Herdr session, workspace, or pane lifecycle command was used.

@knowttl
knowttl merged commit 465f68d into main Jul 15, 2026
knowttl added a commit that referenced this pull request Jul 30, 2026
* fix(supervision): stop alarming long in-contract calls as possible wedges

A crewmate blocked on a long foreground call is idle by design: a
`no-mistakes` gate call blocks synchronously against its own
multi-thousand-second allowance, so its pane stays frozen far past the
240s wedge threshold. Both supervisors escalated on that threshold alone,
so every pipeline gate produced a stream of possible-wedge alarms against
healthy workers (three in one day on 2026-07-30, one of them 916s into a
healthy call with a 3000s allowance). A warning that is usually wrong
trains its reader to dismiss the one that is real.

The threshold now selects re-examination, not alarm. On reaching it, the
crew's current state is re-read once per threshold window; a crew still
provably working is deferred for another window, and only a crew that
stops verifying as working - or one that stays idle past the new
FM_WEDGE_WORKING_ESCALATE_SECS allowance (default 3600s) - escalates.
That is the disambiguation a supervisor otherwise had to perform by hand
before believing the alarm.

The real-wedge guarantee is preserved and documented: a crew that goes
quiet surfaces within one threshold window of stopping, and a frozen
pipeline that keeps reporting itself as running surfaces within the
allowance. The deferral trades false alarms for latency, never for
silence, and can be disabled with FM_WEDGE_WORKING_ESCALATE_SECS=0.

bin/fm-classify-lib.sh owns the decision (wedge_escalation_deferred) for
both the always-on watcher and the away-mode daemon; each consumer owns
only its own verification marker, so the crew state is read at most once
per threshold window per pane.

Compatibility review: the changed code makes no harness- or
backend-specific call. It consumes bin/fm-crew-state.sh's verdict, which
already resolves the busy signature per recorded harness (claude, codex,
opencode, pi, pi-signed, grok, kimi) and the endpoint per recorded
backend (tmux, herdr, zellij, orca, cmux) through bin/fm-backend.sh; the
daemon path additionally remains restricted to its existing tmux/herdr
supervisor panes. Codex Desktop is not a spawn backend and has no stale
marker, so it is not applicable here.

Tests: tests/fm-watch-triage.test.sh and tests/fm-daemon.test.sh cover
both directions - repeated threshold windows absorb a live in-contract
call, while a stopped crew and a frozen pipeline past the allowance still
escalate. Each escalation assertion was watched failing against
deliberately broken variants (no ceiling; always-working verdict) before
being kept.

* test(daemon): drop fork-only Herdr native-idle supervisor-guard tests

These two tests assert that the away-mode supervisor guard treats Herdr's
native `agent.get` idle verdict as conclusive and skips the
regex-over-capture corroboration. That short-circuit was a fork-only
change; the implementation it asserted was removed when
bin/fm-supervise-daemon.sh was restored to match upstream exactly
(c4ec3b2), leaving the tests behind and tests/fm-daemon.test.sh
deterministically red on the default branch.

This fork tracks upstream exactly and fork-only customizations are
discarded, so the artifact to remove is the test, not the implementation:
re-adding the short-circuit would recreate the drift the upstream match
deliberately removed. Upstream behavior is unchanged - a non-`busy`
native verdict still corroborates against the recorded harness's rendered
busy signature before the supervisor pane is treated as idle.

The rest of PR #2's away-mode work is untouched and still covered: the
U+00A0 composer classification tests pass, as do the herdr busy-state,
capture-fallback, and inject-dispatch tests.

tests/fm-daemon.test.sh now runs to completion: 100 passing, 0 failing
(previously it aborted at 90 with these 2 failures).

Note for the PR body: this removal and its reason belong on their own
line at merge review.

* no-mistakes(review): Clarify away-mode stale escalation contract

* no-mistakes(document): Align wedge deferral documentation
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