Skip to content

feat(bin): add a deterministic unchanged-pause absorption rule - #48

Merged
alandomio merged 6 commits into
mainfrom
fm/jev-rule-absorb
Sep 28, 2026
Merged

alandomio merged 6 commits into
mainfrom
fm/jev-rule-absorb

Conversation

@alandomio

@alandomio alandomio commented Sep 28, 2026 •

Copy link
Copy Markdown
Owner

Intent

Add a deterministic (no-model) absorb rule on top of the just-shipped gated Jev wake absorption (PR #47, now on main): the local Jev classifier's shadow report over 1.3 days showed 0 wrongly absorbable but only 6.4% agreement, because nearly all the noise is one well-understood shape - a declared-pause 'stale' recheck on the long cadence, unchanged since the previous recheck (paused Slack gateway tasks, an MR awaiting merge, a tool install) - that the 1.7B model reads as needing attention. Add a rule path that absorbs exactly that shape WITHOUT calling the model. Absorb only when ALL hold: the wake is the watcher's declared-pause long-cadence recheck; the watcher's own structured comparison (not a regex on the reason text) already found nothing changed since the previous recheck; the task's latest status is paused: (never blocked/needs-decision/done/failed, and never a captain-held transfer); the task has no open decision; no new unread status line since the last presentation; no PR/check result, heartbeat, inbox note, Relay or procevent row. Its own config switch (config/absorb-unchanged-pause), off by default, independent of the Jev go-live gate since a fixed rule needs no calibration. Document it next to the Jev section in docs/configuration.md and the AGENTS.md config list. Same 'nothing is lost' contract as the Jev path: absorbed rows go to the durable digest, surfaced with the next real wake or heartbeat; acknowledgement never strands rows; never absorb (surface for real instead) when the digest entry cannot be built or written. Log rule absorptions distinctly (source=rule) so bin/fm-jev.sh report keeps model agreement separate and still measures the model only on what the rule did not take. Keep a safety valve: a paused task absorbed continuously for a long time still surfaces once per day (or at heartbeat), so a forgotten wait is not silent forever. Tests for each refusal (open decision, blocked, changed since last recheck, new status line, non-pause wake, dead agent, captain-held, undigestable) and for digest surfacing. Source comments max 3 lines. Never add an agent co-author trailer. This run's own follow-up: firstmate decided to fix the prior review's still-open source-comment-length finding directly since the pipeline's own fix for it did not land; that fix is already committed (68fcae9) and just needs revalidating.

What Changed

  • bin/fm-watch.sh gets a model-free absorb path, behind its own switch config/absorb-unchanged-pause (off unless the first non-blank line is on, and separate from the Jev go-live gate). It runs before Jev on a due "paused, awaiting external" recheck. It absorbs only when all of these hold:

    • the watcher's structured situation comparison shows nothing changed;
    • the latest status verb is paused and is not captain-relevant;
    • the task is not a secondmate and has no open decision;
    • the agent is not dead;
    • jq is available;
    • the masked digest entry was actually written.

    If any check fails, the recheck goes on to Jev and then to a real surface. A per-window .rule-absorbed-since-<key> marker is the safety valve: once the rule has absorbed a task continuously for FM_PAUSE_REMIND_SECS, it refuses so the task gets one real surface. The marker is cleared whenever the recheck surfaces or pause state is cleared.

  • The absorption digest is shared by both paths:

    • JEV_JQ_MASK/jev_mask moved from bin/fm-jev.sh into bin/fm-jev-lib.sh so the rule masks text with the same filter.
    • Digest entries now carry source: "jev" or source: "rule". bin/fm-wake-drain.sh prints via <source> and falls back to jev when the field is missing, and it prints confidence only when it is a number.
    • _fm_jev_absorb_append now returns nonzero when the digest can't be written, so the rule surfaces the recheck instead of absorbing it.
  • Docs and tests:

    • docs/configuration.md has a new "Deterministic unchanged-pause absorption" section, and AGENTS.md lists the new config file and state marker.
    • New tests in tests/fm-watch-triage.test.sh cover:
      • absorbing an unchanged pause;
      • refusing a changed situation or an open decision;
      • refusing a dead agent or a captain-held task;
      • surfacing when the digest entry can't be built or can't be written;
      • the safety valve resetting.
    • tests/fm-jev.test.sh checks the drain's per-source digest labels.

Risk Assessment

✅ Low: The new rule is off by default. It checks the same eligibility as the Jev absorb path (status file present, not a secondmate, no open decision, last line is paused and not captain-relevant, situation unchanged, agent alive, jq present), and a digest entry that can't be built or written falls through to a real surface. The concerns still open (48h valve cadence, Jev absorbing after the valve trips, gaps in refusal tests) were all declined in earlier rounds.

Testing

68fcae9 only shortens a comment. I confirmed the comment is now 3 lines and the script still parses, then ran the two targeted test files, tests/fm-jev.test.sh and tests/fm-watch-triage.test.sh. Both pass on the target commit, including all 7 new rule tests (absorb, refusals, a digest entry that can't be built or written, the safety valve). I also ran the digest drain by hand: a rule-absorbed recheck showed up tagged "via rule" with no confidence value, next to a Jev row showing its confidence, and a second drain printed nothing. This is a CLI/bash change with no UI, so the evidence is test logs and a CLI transcript, not screenshots. The worktree was left clean.

Evidence: Digest surfacing transcript (rule vs jev rows, shown once)

Source: Digest surfacing transcript (rule vs jev rows, shown once)

ABSORBED (2 wakes absorbed before reaching the queue - masked reason/status kept below): 2026-09-21T14:13:20Z stale task slack-gw via rule: choice absorbable | wake: paused 86400s, awaiting external - declared pause, ... | worker: paused: waiting on MR <url> merge 2026-09-21T14:15:00Z signal task tool-install via jev: choice absorbable (0.97) | wake: status changed | worker: working: installing (second drain: exit 0, no output)

$ cat state/jev/absorbed.jsonl
{"t":1790000000,"kind":"stale","task":"slack-gw","reason":"paused 86400s, awaiting external - declared pause, rechecked on a long cadence not a wedge; confirm the wait still holds","status":"paused: waiting on MR <url> merge","choice":"absorbable","confidence":null,"source":"rule"}
{"t":1790000100,"kind":"signal","task":"tool-install","reason":"status changed","status":"working: installing","choice":"absorbable","confidence":0.97,"source":"jev"}

$ fm_jev_absorb_digest_surface state   # next real wake / heartbeat
ABSORBED (2 wakes absorbed before reaching the queue - masked reason/status kept below):
  2026-09-21T14:13:20Z stale task slack-gw via rule: choice absorbable | wake: paused 86400s, awaiting external - declared pause, rechecked on a long cadence not a wedge; confirm the wait still holds | worker: paused: waiting on MR <url> merge
  2026-09-21T14:15:00Z signal task tool-install via jev: choice absorbable (0.97) | wake: status changed | worker: working: installing

$ fm_jev_absorb_digest_surface state   # second drain: nothing repeats
(exit 0, no output)
Evidence: fm-watch-triage test log (rule tests)

Source: fm-watch-triage test log (rule tests)

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 - 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 67520.1790587705.uBHILr
ok - queue revalidation, proactive output, and marker commit serialize with drain
~/.no-mistakes/worktrees/38493c8a7325/01M3KMZCFN53XXNBVR44B8XQ9Y/bin/fm-push-transition-lib.sh: line 96: echo: write error: Broken pipe
tests/wake-helpers.sh: line 282: 72054 Killed: 9               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: 74166 Killed: 9               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
bash tests/fm-watch-triage.test.sh  66.98s user 160.81s system 45% cpu 8:17.39 total
Evidence: fm-jev test log

Source: fm-jev test 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 - 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
bash tests/fm-jev.test.sh  7.60s user 15.56s system 48% cpu 48.171 total

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.

  • git show 68fcae9: comment-only change, the doc comment on rule_absorb_unchanged_pause goes from 5 lines to 3
  • bash -n bin/fm-watch.sh (parses cleanly after the comment edit)
  • bash tests/fm-jev.test.sh: all pass, including the digest tagging each entry via jev or via rule and an absorbed wake surfacing exactly once
  • bash tests/fm-watch-triage.test.sh: all pass, including the 7 rule tests (absorbs an unchanged recheck as source=rule; refuses a changed situation or open decision; refuses dead-agent and captain-held rechecks; surfaces for real when the digest entry can't be built or written; the safety valve forces a real surface and then resets)
  • Manual: sourced bin/fm-jev-lib.sh and ran fm_jev_absorb_digest_surface on a temp state holding one source=rule row and one source=jev row, then ran it a second time to confirm no row repeats
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Alan Domio added 6 commits September 28, 2026 10:28
config/absorb-unchanged-pause (off by default) absorbs a declared-pause
"stale" recheck the watcher's own comparison already found unchanged,
without calling any classifier: it requires the task has no open decision
and its agent is not dead, and is tried before Jev at the same recheck
point, falling through to Jev then to a real surface exactly as if it were
off. A per-task safety-valve marker (state/.rule-absorbed-since-<key>,
bounded by the existing FM_PAUSE_REMIND_SECS default) forces one real,
human-visible surface after continuous absorption, then resets. Every
absorbed row shares the Jev path's durable digest, tagged source: "rule" so
bin/fm-jev.sh report keeps measuring the model only on what this rule did
not already take; jev-sourced rows are now tagged source: "jev" for the
same reason. JEV_JQ_MASK/jev_mask moved to bin/fm-jev-lib.sh, the one
owner shared by bin/fm-jev.sh and this new rule.
Per accepted intent's source-comment cap; the review pass's fix for this
finding did not land, so applying it directly as a follow-up.
@alandomio
alandomio merged commit 1685d63 into main Sep 28, 2026
14 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