Skip to content

feat(bin): add a single-owner absorption veto and an opt-in already-presented stale absorption rule - #51

Merged
alandomio merged 1 commit into
mainfrom
fm/wake-absorb-rules
Sep 30, 2026
Merged

alandomio merged 1 commit into
mainfrom
fm/wake-absorb-rules

Conversation

@alandomio

Copy link
Copy Markdown
Owner

Intent

Firstmate repo (shared tracked material; firstmate-coding-guidelines applies). Implement recommendations 2 and 3 of the Jev miss analysis (data/jev-miss-analysis/report.md). Rule 2: a deterministic, explicit, single-owner, unit-tested veto that runs ahead of any model (Jev absorption) and any existing absorb path (absorb-try, config/absorb-unchanged-pause): never absorb a wake whose latest status line starts with done:, needs-decision:, blocked:, failed:, or resolved:, or whose reason carries the other markers the report lists (merged, heartbeat, check, inactive terminal outcome, open decisions, unread status). Implemented as absorb_vetoed in bin/fm-classify-lib.sh, called by cmd_absorb_try and rule_absorb_unchanged_pause. Rule 3: a new model-free opt-in gate config/absorb-presented-stale (off by default, in the style of config/absorb-unchanged-pause) that absorbs a stale re-surface of a worker parked on an already-presented terminal status (done/failed, or still-open needs-decision/blocked awaiting the captain), when nothing changed since that presentation: proof is the .hb-surfaced- line plus a new .sig companion (status log size:mtime) written by mark_surfaced, so any appended line, even a repeat, defeats it; safety valve re-surfaces once per FM_PAUSE_REMIND_SECS; never absorb when the status log gained any new line. Rule 3 is the only absorber allowed to relax the veto status/open-decision checks (presented mode), and only because it proves them. Document concisely in docs/configuration.md and the AGENTS.md config list, tests colocated (tests/fm-watch-triage.test.sh, tests/fm-jev.test.sh). Keep rule 3 off by default. Do not change Jev model behaviour. Known: tests/fm-watch-triage.test.sh test 'authoritative working state did not start wedge tracking' is a load-only flake (3s budget), unrelated.

What Changed

  • Added absorb_vetoed to bin/fm-classify-lib.sh. It is now the only place that decides a wake must never be absorbed. It vetoes any wake whose latest status line is done:, needs-decision:, blocked:, failed: or resolved:. It also vetoes merge, check and heartbeat reasons, inactive terminal outcomes, open decisions and unread notes. cmd_absorb_try in bin/fm-jev.sh checks it before any other rule and before any model call. The existing config/absorb-unchanged-pause rule checks it too.
  • Added a model-free opt-in gate, config/absorb-presented-stale, in bin/fm-watch.sh. It is off by default. It absorbs a stale re-surface of a worker parked on a terminal or still-open status that the captain has already been shown, as long as nothing changed since then. To prove that, mark_surfaced now also writes a .sig file next to .hb-surfaced-<task> holding the status log's size:mtime. Any appended line changes that signature and defeats the rule, even a repeated line. The wake still re-surfaces once every FM_PAUSE_REMIND_SECS. This is the only absorber allowed to relax the veto's status and open-decision checks.
  • Documented the new gate in docs/configuration.md, the AGENTS.md config list and the absorption-digest comment in bin/fm-wake-drain.sh. Added tests in tests/fm-watch-triage.test.sh and tests/fm-jev.test.sh.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The veto only adds refusals ahead of existing absorbers, and rule 3 is off by default with strict proof checks (the recorded line and a size:mtime signature must both match, plus a FM_PAUSE_REMIND_SECS valve), so a wrong answer can only over-surface a wake, never under-surface one.

Testing

I ran the two colocated test suites (fm-watch-triage and fm-jev) in full. Both exited 0 with no failures, including the known load flake. The new tests check the veto against the terminal-status prefixes and the other listed markers, including open decisions and unread notes. They also check that the unchanged-pause and Jev paths are gated behind the veto, and that the presented-stale rule absorbs only when nothing was appended. That rule stays off by default and keeps surfacing when there are unread notes. This is CLI-only logic, so there is no UI evidence; the TAP logs are recorded as artifacts.

Evidence: fm-watch-triage TAP log

Source: fm-watch-triage TAP log

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 - status_is_nonterminal_progress_verb is the single shared predicate for all three call sites
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, paused is not captain-relevant, and the two declared-wait verbs stay separable
ok - crew_absorb_class: working/paused/none from one read; crew_is_paused and crew_is_provably_working agree
ok - crew_worktree_written_since: real writes are evidence; no worktree, no anchor, quiet trees, .git churn and a mate's own home are not
ok - an empty FM_WORKTREE_WRITE_PRUNE widens the probe to the whole depth-bounded tree instead of disabling it
ok - an empty FM_WORKTREE_WRITE_PRUNE exported into the environment prunes nothing, widening the probe
ok - the worktree write probe is wall-clock bounded, and hitting the bound reads as no write evidence
ok - signal_crew_provably_working: benign only when every referenced crew is provably working
ok - a secondmate's status signal is never absorbed as provably working; crewmates are unaffected
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 - a secondmate's status note surfaces even while its own agent is busy
ok - a self-announced close never wakes its own home, and the next real note still does
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 busy worker below the turn-age bound remains working with no escalation
ok - a busy worker with a stable pane hash still escalates once its completed-turn age reaches the bound
ok - a busy worker whose pane hash changes every poll still escalates once its completed-turn age reaches the bound
ok - touching a busy worker's completed-turn marker resets the age and prevents an old-age escalation
ok - repeated busy turn-age escalations reuse the existing escalation counter and demand deep inspection at the threshold
ok - the production default busy-turn-age bound is 3600s (5min under does not wedge, 66min over does)
ok - a busy pane under a declared pause is rechecked on the long cadence, and lifting the pause restores the wedge escalation
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 still surfaces once
ok - a live agent's declared pause with a churning pane hash uses the bounded recheck cadence, never a bare stale wake
ok - an unchanged declared pause is rechecked once, then absorbed until the reminder ceiling or a change in status, liveness, or pane text
ok - a live agent's pause line takes its one-time surface once, not again after every busy turn
ok - a declared paused secondmate re-surfaces on the bounded normal-mode cadence
ok - a captain-held 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 - a quiet pane writing its own worktree is deferred, while one writing nothing still wedge-escalates on the unchanged schedule
ok - a write deferral re-surfaces once on the bounded pause cadence, so a churning worktree cannot stay invisible
ok - a secondmate's own home supervision churn is not crew write evidence, so a pane recording that home keeps the unchanged escalation schedule
ok - an idle-window timer repair drops a finished write-deferral chain, so the next deferral gets a fresh re-surface window
ok - both first-sight paths through a captain-relevant status drop a finished write-deferral chain with the idle window
ok - triage log capping handles wc byte counts with leading spaces
ok - a captured process-event result wakes a healthy watcher proactively, with no manual drain
ok - an unacknowledged process-event result re-drains until handling is acknowledged
ok - complete process-event queue keys map to distinct seen markers
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 833266.1790720097.hDlaB4
ok - queue revalidation, proactive output, and marker commit serialize with drain
~/.no-mistakes/worktrees/34c874d3722d/01M3QKD9MCJARYAZ1EM9SB295A/bin/fm-push-transition-lib.sh: line 96: echo: write error: Broken pipe
tests/wake-helpers.sh: line 282: 835773 Killed                  PATH="$dir/fakebin:$PATH" FM_HOME="$dir" FM_PROCEVENT_CLAIM_ROOT="$dir/claims" FM_CREW_STATE_BIN="$dir/fakebin/fm-crew-state.sh" FM_POLL=0.2 FM_SIGNAL_GRACE=1 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 "$WATCH" > "$out"
tests/wake-helpers.sh: line 282: 837989 Killed                  PATH="$dir/fakebin:$PATH" FM_HOME="$dir" FM_PROCEVENT_CLAIM_ROOT="$dir/claims" FM_CREW_STATE_BIN="$dir/fakebin/fm-crew-state.sh" FM_POLL=0.2 FM_SIGNAL_GRACE=1 FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 "$WATCH" > "$out"
ok - surfacing failures replay until post-handling acknowledgement
ok - marker failure exits through the shared wake owner, releases its lock, and replays later
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
ok - a routine working: signal the provably-working check would otherwise escalate is absorbed by Jev and recorded in the digest
ok - with config/jev-absorb absent, the same signal surfaces exactly as before
ok - a declared-pause recheck due to re-surface is absorbed by Jev, throttle advanced, recorded in the digest
ok - a dead-agent pause recheck always re-surfaces, never absorbed by Jev
ok - a captain-held recheck always re-surfaces, never absorbed, even with Jev enabled and overridden
ok - the deterministic rule absorbs a fresh unchanged declared-pause recheck and records it in the digest as source=rule
ok - the rule refuses a changed situation and a task with an open decision, surfacing both for real
ok - a dead-agent pause recheck always re-surfaces, never absorbed by the rule
ok - a captain-held recheck always re-surfaces, never absorbed by the rule, even when enabled
ok - the rule surfaces a recheck for real when it cannot record the digest entry
ok - the rule surfaces a recheck for real when it cannot write the digest entry
ok - the rule's own safety valve forces one real surface after continuous absorption, then resets its marker
ok - absorb_vetoed vetoes terminal-status prefixes, open decisions, unread notes, check/heartbeat/merge reasons, and only presented mode relaxes status
ok - the unchanged-pause rule is behind the shared veto
ok - an already-presented terminal status with nothing appended is absorbed and recorded as source=rule
ok - a still-open needs-decision the captain was already shown is absorbed
ok - the presented-stale rule is off by default: the same stale surfaces
ok - the rule never absorbs without a matching, signed surfaced record
ok - any line appended since the presentation defeats the rule, even a repeat of the same text
ok - an unread note or an unbuildable digest entry keeps the presented stale surfacing
ok - the rule's own safety valve forces one real surface after the bound, then resets its marker
EXIT 0
Evidence: fm-jev TAP log

Source: fm-jev TAP log

ok - off by default: an ambient OPENROUTER_API_KEY neither logs nor calls the network
ok - a STATE other than the key home's own state never enables Jev
ok - shadow mode logs presentation, answer and acknowledgement without changing the drain
ok - only the masked reason and last status line are sent; the key stays off argv and disk
ok - config/jev-timeout overrides the 5 second default and invalid values keep it
ok - a timeout skips the wake and pauses Jev until the next day
ok - HTTP errors, transport errors and a missing cost pause Jev until the next day
ok - the daily spend cap stops requests and pauses Jev until the next day
ok - config/jev-endpoint selects the local backend over an OPENROUTER_API_KEY, needs no key, and records the answering model
ok - a native status uncertain/insufficient_evidence answer (null choice) classifies as doubt, never as an error
ok - config/jev-timeout also overrides the local backend's request timeout
ok - the local endpoint and load ceiling are read from the home's own config/, the same place that selected the backend
ok - a whitespace-only config/jev-endpoint does not select the local backend
ok - a local response with no usage.cost classifies normally instead of erroring
ok - a non-loopback or path-carrying config/jev-endpoint is refused, never dialed, and pauses Jev
ok - a 1-minute load average at or above config/jev-max-load skips only that wake; a later reading below it classifies again
ok - a local timeout skips the rest of that drain and an API/transport error only its row, each logged with the reason; the next drain tries again with no day pause, unlike OpenRouter
ok - status names the active backend, its endpoint or spend, and (for local) its load ceiling
ok - the drain returns immediately while a slow Jev request runs detached
ok - hooks record steers, decisions and how a turn ended, never its text
ok - only sends firstmate itself makes count as steers; FM_JEV_OBSERVE=0 senders record nothing
ok - the report credits named actions to their task's open wakes across drains and shares the rest
ok - unacknowledged and pre-window wakes stay open, so their steers never spill onto unrelated wakes
ok - the report computes agreement, wrongly absorbable wakes, go-live criteria and doubtful cases
ok - absorption off by default: no network call, no digest, absorb-try refuses
ok - absorption refuses any backend but local, even when requested
ok - requested absorption without a met gate or an override never dials the classifier
ok - a captain override skips the go-live gate and records a masked digest entry
ok - config/jev-absorb-threshold below 0.9 refuses absorption outright
ok - any doubt or below-threshold confidence falls through without a digest entry
ok - a task with an open decision is never absorbed
ok - a secondmate's status signal is never absorbed
ok - only a working:/paused: verb is ever eligible for absorption
ok - the deterministic veto refuses terminal statuses, check/heartbeat/merge reasons, and unread notes before any model call
ok - absorb-gate reports classified/scored/agreement/wrongly-absorbable and the sample-gated go-live verdict
ok - an absorbed wake surfaces exactly once with the next drain and never repeats
ok - the drain tags each digest entry via jev or via rule, defaulting to jev when the field is absent
ok - the digest is held while away mode drains and surfaces with the first drain after return
ok - a malformed digest line never hides later entries, and a partial line waits until complete
EXIT 0

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-watch-triage.test.sh: covers the absorb_vetoed prefixes and markers, the presented-mode relaxation, the unchanged-pause rule behind the veto, presented-stale absorption with source=rule, off by default, and an unread note keeping the stale surfacing
  • bash tests/fm-jev.test.sh: the deterministic veto refuses terminal statuses, check, heartbeat and merge reasons, and unread notes before any model call
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…resented stale absorption rule

absorb_vetoed (bin/fm-classify-lib.sh) is now asked first by Jev absorb-try,
the unchanged-pause rule, and the new config/absorb-presented-stale rule:
terminal status prefixes, open decisions, unread notes, and check/heartbeat/
merge reasons are never absorbed. The new rule absorbs a stale re-surface of a
worker parked on a terminal status already surfaced with nothing appended
since, bounded by FM_PAUSE_REMIND_SECS, off by default.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@alandomio
alandomio merged commit 7151856 into main Sep 30, 2026
24 of 25 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