Skip to content

feat(bin): let the local Jev classifier absorb routine wakes behind a go-live gate - #47

Merged
alandomio merged 5 commits into
mainfrom
fm/jev-absorb-junk-wakes
Sep 28, 2026
Merged

alandomio merged 5 commits into
mainfrom
fm/jev-absorb-junk-wakes

Conversation

@alandomio

@alandomio alandomio commented Sep 27, 2026 •

Copy link
Copy Markdown
Owner

Intent

Implement gated wake absorption ("junk cleaning") on top of bin/fm-jev.sh's local shadow classifier. Off by default. Refuses to activate until the shadow report meets go-live criteria (0 wrongly absorbable, >=90% agreement, a minimum sample of ~300 classified wakes, no default confidence threshold below 0.9, calibrated) or an explicit captain override. Strict allowlist: only a routine working/paused signal wake whose crew is not provably working, and a declared-pause recheck; never needs-decision, blocked, done, failed, merge/check results, heartbeats, captain inbox notes, Relay, process-event wakes, secondmate routed replies, or any task with an open decision. Durable digest of every absorbed wake (masked), surfaced with the next real wake or heartbeat, never lost silently. Fall-through to today's behavior on any doubt, timeout, server error, or classifier error, adding no latency beyond the existing per-request classify timeout. Tests for every refusal class and the gate. Docs in docs/configuration.md 'Jev shadow wake triage' and the AGENTS.md config line list. Local Rizzo Flow backend only (never OpenRouter) since absorption changes real behavior. Source comments max 3 lines. Never add an agent co-author trailer.

What Changed

  • bin/fm-jev.sh adds an opt-in wake absorption path that only runs against the local backend. absorb-try decides per wake, and absorb-gate checks that the shadow report shows zero wrongly absorbable wakes, at least 90% agreement, and at least 300 scored wakes. The gate result is cached. Absorption stays off unless config/jev-absorb says on, and it needs either the gate to pass or an override line. config/jev-absorb-threshold defaults to 0.9 and values below that are rejected. A wake is absorbed only when the Rizzo native /v1/decisions answer is ok, absorbable, and at or above the threshold. Anything else falls through to the existing behavior, including an ineligible wake, an unmet gate, a timeout, an error, or a low-confidence answer. status now reports the absorption setting, the threshold, and whether the gate is met.

  • bin/fm-watch.sh calls absorption at exactly two places:

    • a non-afk working/paused signal wake with no captain-relevant verb, whose crew isn't provably working, for a single task
    • a due "paused, awaiting external" stale recheck, skipped when the agent is dead or the task is captain-held

    Everything else always surfaces as before: needs-decision, blocked, done, failed, merge/check results, heartbeats, inbox notes, Relay, process-event wakes, secondmate routed replies, and tasks with an open decision.

  • Each absorbed wake is written, masked, to state/jev/absorbed.jsonl. bin/fm-wake-drain.sh prints that digest on every non-afk drain, so it shows up with the next real wake or heartbeat. The digest is held while away mode is active. New tests in tests/fm-jev.test.sh and tests/fm-watch-triage.test.sh cover each refusal class, the gate, the override, and the digest. docs/configuration.md (a "Gated wake absorption" subsection), docs/scripts.md, and the AGENTS.md config/state entries are updated to match.

Risk Assessment

⚠️ Medium: Absorption is off by default, only runs on the local backend and sends every doubtful path back to surfacing the wake. Both fix rounds check out against the code: the dead-agent guard, per-line digest parsing and holding a partial line, the "scored wakes" docs wording, and holding the digest while away mode is on. The caveats you chose to ignore still apply to go-live behaviour (gate latency and cost, gate rows from both backends, bare turn-end eligibility), so this is safe to merge with follow-ups rather than trivially low risk.

Testing

Both suites passed, 0 failures: the Jev suite and the full watcher-triage suite, which was run in full because its shared helper changed. That covers the new unit tests for gate, refusal and digest behaviour and the real-watcher tests for signal and pause-recheck absorption, the dead-agent guard and the captain-held guard. I also drove the CLI by hand against the real local Rizzo Flow server. Every refusal class fell through with no digest. The real model labelled routine working and paused lines firstmate below 0.9, so nothing was absorbed there, which is the fail-safe outcome. A loopback stub returning Rizzo-format "absorbable" answers showed the full positive path: masked digest written, held during away mode, surfaced once by the next drain and never repeated, and a hung classifier falling through within the per-request timeout. The CLI transcripts and test logs are saved as artifacts. The worktree was left clean.

Evidence: Positive path: absorb-try, masked digest, afk hold, drain surfaces ABSORBED once, hung-server timeout

Source: Positive path: absorb-try, masked digest, afk hold, drain surfaces ABSORBED once, hung-server timeout


$ bin/fm-jev.sh status
Jev shadow triage: on, local backend (config/jev-endpoint = http://127.0.0.1:18918)
load ceiling: 8 (1-minute average)
request timeout: 5s
shadow log: /tmp/fm-jev-absorb-pos.g0s5fB/state/jev/shadow.jsonl
absorption: requested, threshold 0.9
absorption: captain override set - the go-live gate is skipped
[exit 0]

$ bin/fm-jev.sh absorb-try --kind signal --task alpha --reason signal: /tmp/fm-jev-absorb-pos.g0s5fB/state/alpha.status
[exit 0]

$ bin/fm-jev.sh absorb-try --kind stale --task beta --reason stale: test:beta (paused, awaiting external)
[exit 0]

--- request the classifier received (masked, local only):
{"wake_reason": "stale: test:beta (paused, awaiting external)", "worker_last_status": "paused: waiting on upstream release"}

--- durable digest state/jev/absorbed.jsonl:
{"t":1790552407,"kind":"signal","task":"alpha","reason":"signal: <path>","status":"working: compiling step 2 <url> <path>","choice":"absorbable","confidence":0.95}
{"t":1790552407,"kind":"stale","task":"beta","reason":"stale: test:beta (paused, awaiting external)","status":"paused: waiting on upstream release","choice":"absorbable","confidence":0.95}

=== away mode active (.afk): drain holds the digest

$ bin/fm-wake-drain.sh
[exit 0]

=== next real drain (wake or heartbeat) surfaces it

$ bin/fm-wake-drain.sh
ABSORBED (2 wakes, absorbed by the local Jev classifier before reaching the queue - masked reason/status kept below):
  2026-09-27T23:40:07Z signal task alpha: choice absorbable (0.95) | wake: signal: <path> | worker: working: compiling step 2 <url> <path>
  2026-09-27T23:40:07Z stale task beta: choice absorbable (0.95) | wake: stale: test:beta (paused, awaiting external) | worker: paused: waiting on upstream release
[exit 0]

=== a later drain never repeats it

$ bin/fm-wake-drain.sh
[exit 0]

=== hung classifier: accepts, never answers, config/jev-timeout=2

$ bin/fm-jev.sh absorb-try --kind signal --task alpha --reason signal: x
[exit 1]
elapsed: 2.33s (per-request classify timeout 2s)
digest lines still: 2
Evidence: Real Rizzo Flow e2e: off by default, gate NOT met, override, threshold floor, ineligible verbs, OpenRouter refused, classifier down/hung fall-through

Source: Real Rizzo Flow e2e: off by default, gate NOT met, override, threshold floor, ineligible verbs, OpenRouter refused, classifier down/hung fall-through

=== 1. absorption off by default (config/jev-absorb absent)

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh status
Jev shadow triage: on, local backend (config/jev-endpoint = http://127.0.0.1:8017)
load ceiling: 8 (1-minute average)
request timeout: 5s
shadow log: /tmp/fm-jev-absorb-demo.b4TwNH/state/jev/shadow.jsonl
absorption: off (config/jev-absorb is absent or not "on")
[exit 0]

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]
(no digest written)

=== 2. requested (config/jev-absorb=on), no override, no shadow data -> gate NOT met, refuses

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh status
Jev shadow triage: on, local backend (config/jev-endpoint = http://127.0.0.1:8017)
load ceiling: 8 (1-minute average)
request timeout: 5s
shadow log: /tmp/fm-jev-absorb-demo.b4TwNH/state/jev/shadow.jsonl
absorption: requested, threshold 0.9
absorption: go-live gate NOT met - inactive (see: bin/fm-jev.sh absorb-gate)
[exit 0]

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-gate
classified: 0
scored: 0 (minimum 300)
agreement: 0% (0 of 0)
wrongly absorbable: 0
go-live: NOT met
[exit 1]

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]

=== 3. captain override -> gate skipped; real Rizzo Flow classifies; high threshold 0.9 floor applies

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh status
Jev shadow triage: on, local backend (config/jev-endpoint = http://127.0.0.1:8017)
load ceiling: 8 (1-minute average)
request timeout: 5s
shadow log: /tmp/fm-jev-absorb-demo.b4TwNH/state/jev/shadow.jsonl
absorption: requested, threshold 0.9
absorption: captain override set - the go-live gate is skipped
[exit 0]

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]
--- digest (state/jev/absorbed.jsonl):
(empty: real classifier did not answer absorbable >= 0.9)

=== 4. next drain surfaces the digest once; a second drain does not repeat it

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-wake-drain.sh
[exit 0]

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-wake-drain.sh
[exit 0]

=== 5. threshold below the 0.9 floor refuses outright

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh status
Jev shadow triage: on, local backend (config/jev-endpoint = http://127.0.0.1:8017)
load ceiling: 8 (1-minute average)
request timeout: 5s
shadow log: /tmp/fm-jev-absorb-demo.b4TwNH/state/jev/shadow.jsonl
absorption: requested but refused - config/jev-absorb-threshold must be a number at or above 0.9
[exit 0]

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]

=== 6. never-eligible status verbs (override on) -> refuse without dialing

# status: done: shipped PR 12
$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]

# status: needs-decision: pick base branch
$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]

# status: blocked: waiting on creds
$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]

# status: failed: build broke
$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]

=== 7. OpenRouter backend (no jev-endpoint, key present) -> refused even with override

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh status
Jev shadow triage: on, OpenRouter backend (OPENROUTER_API_KEY present in /tmp/fm-jev-absorb-demo.b4TwNH/.env)
spend today: USD 0.000000 of a USD 1 daily cap
request timeout: 5s
shadow log: /tmp/fm-jev-absorb-demo.b4TwNH/state/jev/shadow.jsonl
absorption: requested (config/jev-absorb) but refused - requires the local backend, not openrouter
[exit 0]

$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: /tmp/fm-jev-absorb-demo.b4TwNH/state/task.status
[exit 1]

=== 8. classifier down / hung -> falls through within the per-request timeout

# nothing listening on 127.0.0.1:1
$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: x
[exit 1]
elapsed: 0s

# server accepts but never answers; config/jev-timeout=2
$ ~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-jev.sh absorb-try --kind signal --task task --reason signal: x
[exit 1]
elapsed: 3s
~/.no-mistakes/evidence/01M3JJ086XBMN4XV9A8FMEMZSY/e2e-absorb-demo.sh: line 71: /tmp/fm-jev-absorb-demo.b4TwNH/state/jev/absorbed.jsonl: No such file or directory
--- digest line count after all refusals: 0
Evidence: Drain output surfacing the absorbed-wake digest
$ bin/fm-wake-drain.sh
ABSORBED (2 wakes, absorbed by the local Jev classifier before reaching the queue - masked reason/status kept below):
2026-09-27T23:40:07Z signal task alpha: choice absorbable (0.95) | wake: signal: <path> | worker: working: compiling step 2 <url> <path>
2026-09-27T23:40:07Z stale task beta: choice absorbable (0.95) | wake: stale: test:beta (paused, awaiting external) | worker: paused: waiting on upstream release
[exit 0]

$ bin/fm-wake-drain.sh # next drain: nothing repeated
[exit 0]
Evidence: Demo scripts (reproducible)

Source: Demo scripts (reproducible)

#!/usr/bin/env bash
# Positive path: a loopback stub speaking Rizzo Flow's /v1/decisions shape answers
# "absorbable" at 0.95; absorb-try absorbs, the masked digest is written, the next
# drain surfaces it exactly once. Also times the hung-server fall-through precisely.
set -u
WT=~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY
JEV="$WT/bin/fm-jev.sh"; DRAIN="$WT/bin/fm-wake-drain.sh"
H=$(mktemp -d /tmp/fm-jev-absorb-pos.XXXXXX); mkdir -p "$H/state" "$H/config"
export FM_HOME="$H" FM_STATE_OVERRIDE="$H/state"
run() { printf '\n$ %s\n' "${*/#$WT\//}"; "$@"; printf '[exit %s]\n' "$?"; }
python3 - <<'PY' &
import http.server, json
class H(http.server.BaseHTTPRequestHandler):
    def do_POST(self):
        n=int(self.headers.get('Content-Length',0)); req=json.loads(self.rfile.read(n))
        open('/tmp/fm-jev-absorb-stub-last-request.json','w').write(json.dumps(req))
        b=json.dumps({"answers":{"handling":{"type":"choice","status":"ok","choice":"absorbable","uncertainty":{"top_probability":0.95}}}}).encode()
        self.send_response(200); self.send_header('Content-Type','application/json'); self.send_header('Content-Length',str(len(b))); self.end_headers(); self.wfile.write(b)
    def log_message(self,*a): pass
http.server.HTTPServer(("127.0.0.1",18918),H).serve_forever()
PY
SPID=$!; sleep 0.7
printf 'http://127.0.0.1:18918\n' > "$H/config/jev-endpoint"
printf 'on\noverride\n' > "$H/config/jev-absorb"
printf 'working: compiling step 2 https://internal.example/ci/42 ~/wt/secret\n' > "$H/state/alpha.status"
printf 'paused: waiting on upstream release\n' > "$H/state/beta.status"
run "$JEV" status
run "$JEV" absorb-try --kind signal --task alpha --reason "signal: $H/state/alpha.status"
run "$JEV" absorb-try --kind stale --task beta --reason "stale: test:beta (paused, awaiting external)"
echo; echo "--- request the classifier received (masked, local only):"; cat /tmp/fm-jev-absorb-stub-last-request.json | python3 -c 'import json,sys; print(json.dumps(json.load(sys.stdin)["state"]))'
echo; echo "--- durable digest state/jev/absorbed.jsonl:"; cat "$H/state/jev/absorbed.jsonl"
echo; echo "=== away mode active (.afk): drain holds the digest"
: > "$H/state/.afk"; run "$DRAIN"; rm -f "$H/state/.afk"
echo; echo "=== next real drain (wake or heartbeat) surfaces it"
run "$DRAIN"
echo; echo "=== a later drain never repeats it"
run "$DRAIN"
kill $SPID 2>/dev/null; wait $SPID 2>/dev/null

echo; echo "=== hung classifier: accepts, never answers, config/jev-timeout=2"
python3 - <<'PY' &
import socket,time
s=socket.socket(); s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1); s.bind(("127.0.0.1",18919)); s.listen(5)
c,_=s.accept(); time.sleep(30)
PY
HPID=$!; sleep 0.5
printf 'http://127.0.0.1:18919\n' > "$H/config/jev-endpoint"; printf '2\n' > "$H/config/jev-timeout"
t0=$(python3 -c 'import time;print(time.time())')
run "$JEV" absorb-try --kind signal --task alpha --reason "signal: x"
python3 -c "import time;print('elapsed: %.2fs (per-request classify timeout 2s)'%(time.time()-$t0))"
kill $HPID 2>/dev/null; wait $HPID 2>/dev/null
echo "digest lines still: $(wc -l < "$H/state/jev/absorbed.jsonl" | tr -d ' ')"
rm -rf "$H" /tmp/fm-jev-absorb-stub-last-request.json
Evidence: Demo script against the real local Rizzo Flow server

Source: Demo script against the real local Rizzo Flow server

#!/usr/bin/env bash
# Manual end-to-end demo of gated Jev absorption against the REAL local Rizzo Flow
# server (http://127.0.0.1:8017). Uses a throwaway home under /tmp.
set -u
WT=~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY
JEV="$WT/bin/fm-jev.sh"; DRAIN="$WT/bin/fm-wake-drain.sh"
H=$(mktemp -d /tmp/fm-jev-absorb-demo.XXXXXX); mkdir -p "$H/state" "$H/config"
export FM_HOME="$H" FM_STATE_OVERRIDE="$H/state"
run() { printf '\n$ %s\n' "$*"; "$@"; printf '[exit %s]\n' "$?"; }
printf 'http://127.0.0.1:8017\n' > "$H/config/jev-endpoint"
printf 'working: compiling step 2 of 5, tests next https://internal.example/ci/42 ~/wt/secret\n' > "$H/state/task.status"

echo "=== 1. absorption off by default (config/jev-absorb absent)"
run "$JEV" status
run "$JEV" absorb-try --kind signal --task task --reason "signal: $H/state/task.status"
ls "$H/state/jev/absorbed.jsonl" 2>/dev/null || echo "(no digest written)"

echo; echo "=== 2. requested (config/jev-absorb=on), no override, no shadow data -> gate NOT met, refuses"
printf 'on\n' > "$H/config/jev-absorb"
run "$JEV" status
run "$JEV" absorb-gate
run "$JEV" absorb-try --kind signal --task task --reason "signal: $H/state/task.status"

echo; echo "=== 3. captain override -> gate skipped; real Rizzo Flow classifies; high threshold 0.9 floor applies"
printf 'on\noverride\n' > "$H/config/jev-absorb"
run "$JEV" status
for i in 1 2 3; do
  run "$JEV" absorb-try --kind signal --task task --reason "signal: $H/state/task.status"
done
echo "--- digest (state/jev/absorbed.jsonl):"; cat "$H/state/jev/absorbed.jsonl" 2>/dev/null || echo "(empty: real classifier did not answer absorbable >= 0.9)"

echo; echo "=== 4. next drain surfaces the digest once; a second drain does not repeat it"
run "$DRAIN"
run "$DRAIN"

echo; echo "=== 5. threshold below the 0.9 floor refuses outright"
printf '0.5\n' > "$H/config/jev-absorb-threshold"
run "$JEV" status
run "$JEV" absorb-try --kind signal --task task --reason "signal: $H/state/task.status"
rm -f "$H/config/jev-absorb-threshold"

echo; echo "=== 6. never-eligible status verbs (override on) -> refuse without dialing"
for line in 'done: shipped PR 12' 'needs-decision: pick base branch' 'blocked: waiting on creds' 'failed: build broke'; do
  printf '%s\n' "$line" > "$H/state/task.status"
  printf '\n# status: %s' "$line"
  run "$JEV" absorb-try --kind signal --task task --reason "signal: $H/state/task.status"
done
printf 'working: compiling\n' > "$H/state/task.status"

echo; echo "=== 7. OpenRouter backend (no jev-endpoint, key present) -> refused even with override"
mv "$H/config/jev-endpoint" "$H/config/jev-endpoint.off"
printf 'OPENROUTER_API_KEY=sk-or-demo-not-real\n' > "$H/.env"
run "$JEV" status
run "$JEV" absorb-try --kind signal --task task --reason "signal: $H/state/task.status"
rm -f "$H/.env"; mv "$H/config/jev-endpoint.off" "$H/config/jev-endpoint"

echo; echo "=== 8. classifier down / hung -> falls through within the per-request timeout"
printf 'http://127.0.0.1:1\n' > "$H/config/jev-endpoint"
printf '\n# nothing listening on 127.0.0.1:1'
start=$(date +%s); run "$JEV" absorb-try --kind signal --task task --reason "signal: x"; echo "elapsed: $(( $(date +%s) - start ))s"
python3 - <<'PY' &
import socket,time
s=socket.socket(); s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1); s.bind(("127.0.0.1",18917)); s.listen(5)
c,_=s.accept(); time.sleep(30)
PY
HPID=$!; sleep 0.5
printf 'http://127.0.0.1:18917\n' > "$H/config/jev-endpoint"; printf '2\n' > "$H/config/jev-timeout"
printf '\n# server accepts but never answers; config/jev-timeout=2'
start=$(date +%s); run "$JEV" absorb-try --kind signal --task task --reason "signal: x"; echo "elapsed: $(( $(date +%s) - start ))s"
kill $HPID 2>/dev/null; wait $HPID 2>/dev/null
echo "--- digest line count after all refusals: $(wc -l < "$H/state/jev/absorbed.jsonl" 2>/dev/null || echo 0)"
rm -rf "$H"
Evidence: tests/fm-jev.test.sh output

Source: tests/fm-jev.test.sh output

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 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
Evidence: tests/fm-watch-triage.test.sh output

Source: tests/fm-watch-triage.test.sh output

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 4963.1790552216.IdWFMT
ok - queue revalidation, proactive output, and marker commit serialize with drain
~/.no-mistakes/worktrees/38493c8a7325/01M3JJ086XBMN4XV9A8FMEMZSY/bin/fm-push-transition-lib.sh: line 96: echo: write error: Broken pipe
tests/wake-helpers.sh: line 282:  8552 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:  9471 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

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 10 issues found → auto-fixed (2) ✅
  • 🚨 bin/fm-watch.sh:504 - The new Jev branch in handle_paused_stale can absorb a declared-pause recheck whose agent is dead. The surrounding contract says "A recheck that finds the agent dead is never absorbed, so an exited worker keeps surfacing on every PAUSE_RESURFACE_SECS recheck", and the existing quiet-absorb branch enforces it with case $now_sit in *&#39; agent=dead &#39;*) false. The Jev branch has no such guard. Example: a worker writes paused: waiting on upstream and then its process exits. On the first recheck prev_sit is empty, so the reason sent to the classifier never mentions liveness; on later unchanged rechecks it only says "unchanged since the last recheck". Rizzo answers absorbable at 0.95, so the dead worker is absorbed, the throttle and surfaced markers are re-stamped, and it goes quiet indefinitely, visible only as digest lines. Fix: skip jev_stale_absorbed when now_sit contains ' agent=dead ', and add a watcher test for it.
  • 🚨 bin/fm-jev.sh:976 - This contradicts the intent criterion "Fall-through to today's behavior on any doubt ... adding no latency beyond the existing per-request classify timeout". When absorption is requested without override and the 300s gate cache is missing or stale, jev_absorb_gate_cached runs the whole absorb-gate --json scan synchronously inside fm-watch's loop, bounded only by JEV_ABSORB_GATE_TIMEOUT=10s. That time is added on top of the classify timeout. So an eligible signal or recheck can block the watcher for about 10s plus jev-timeout once every 5 minutes. docs/configuration.md says the opposite. Keeping the wake path at classify-timeout-only would mean moving the gate refresh off that path (for example into the detached observe-drain, with absorb-try only reading the cache and falling through when it is missing). That adds background work, so the remedy needs the author's sign-off.
  • ⚠️ bin/fm-jev.sh:188 - At realistic volume the go-live gate can never be met, so in practice only the captain override activates absorption. JEV_JQ_ROWS joins every presented wake against every event in the whole shadow log (quadratic), and it does this before the 30-day window filter. The shadow log is append-only and never rotated. Measured here: the live ~/firstmate shadow.jsonl (~215 wakes/day) replicated to 30 days (25,860 events, 6,439 wakes) took 157s for fm-jev.sh absorb-gate, against a 10s JEV_ABSORB_GATE_TIMEOUT. After a few days of logging every recompute times out, caches fail, and absorption stays inactive for good (while still paying the 10s stall above). That fails closed, but the measured gate the intent requires stops working. Possible fixes: pre-filter or index events before the join, bound the scanned log, or compute the gate incrementally. Each of these changes how the gate measures, so this needs the author.
  • ⚠️ bin/fm-jev.sh:143 - The intent requires "Source comments max 3 lines." Many new comment blocks are longer. Examples: the new absorption block in the fm-jev.sh header (~33 lines, 143-175), the cmd_absorb_try header (9), jev_dial_local (10), jev_absorb_gate_cached (7), JEV_JQ_ROWS/JEV_JQ_ABSORB_GATE (5 each). In fm-jev-lib.sh: fm_jev_absorb_try (12) and fm_jev_absorb_digest_surface (7). In fm-watch.sh: jev_signal_absorbed (8), jev_stale_absorbed (6), and the inline signal-branch comment (6). The fm-wake-drain.sh digest comment is 5 lines, and the new test-file comments run 5-7 lines.
  • ⚠️ tests/fm-jev.test.sh:614 - The intent requires "Tests for every refusal class and the gate" and names "timeout, server error, or classifier error" as fall-through classes. None of those are tested for absorb-try: no curl timeout (rc 28), non-2xx HTTP, transport error, or unreadable body. Also untested: an invalid (non-loopback) config/jev-endpoint, a blocked: verb, the watcher refusing a batch that coalesces more than one task, the dead-agent recheck, and the real activation path where absorb-try passes via a met gate (jev_absorb_gate_cached and its cache) with no override. Only the override path is ever exercised end to end.
  • ⚠️ bin/fm-jev.sh:886 - JEV_JQ_ABSORB_GATE scores every jev row in the window regardless of which backend produced it, even though absorption only ever acts on the local Rizzo answer. Shadow rows record model ("typesafe/jev-1.13" for OpenRouter, a source/weights/precision string for local). A home that ran OpenRouter shadow for weeks and then set config/jev-endpoint passes the gate on OpenRouter's accuracy, and the local classifier becomes active with no local evidence. Consider restricting the gate to rows whose model is the local backend's.
  • ⚠️ bin/fm-watch.sh:1263 - jev_signal_absorbed accepts a batch made only of &lt;task&gt;.turn-ended with no new status write. absorb-try then judges it on the old last status line (e.g. working: ...). jev_mask turns the file path in the reason into &lt;path&gt;, so the classifier cannot tell a turn end from a status update. The watcher's own triage comment calls absorbing such a turn end "exactly the swallowed-finish this change guards against": for example, a crew that finished through an interactive menu without writing done:. The intent allowlists "a routine working/paused signal wake". Please confirm whether a bare turn-end with a stale working line is meant to be eligible, or whether only a status-file signal should be.
  • ℹ️ bin/fm-jev.sh:262 - The intent lists "calibrated" as a go-live criterion. The implementation only enforces a numeric floor (jev_absorb_threshold_valid, >= 0.9). Nothing checks that the configured threshold is supported by the shadow data at that confidence level; the docs only say it "must be calibrated". Please confirm the floor plus the 0.6-measured wrong count is the intended meaning of "calibrated".
  • ℹ️ bin/fm-jev-lib.sh:135 - fm_jev_absorb_digest_surface pipes raw lines into jq -r and then always advances the cursor to the pre-read size. One malformed or partial line (a truncated write, or a line read mid-append) makes jq stop there. Every later entry in that batch is then not printed, while the header count still includes it and the cursor moves past it, which weakens "never lost silently". Parsing per line (jq -R &#39;fromjson? | ...&#39;) and advancing only to the last complete newline would close this.
  • ℹ️ docs/configuration.md:651 - The docs say the gate needs "a minimum sample of 300 classified wakes", but the gate compares min_sample against scored (classified rows with known ground truth), not classified. That is stricter, which is fine, but the docs should say scored/measured wakes so operators read absorb-gate output correctly.

🔧 Fix: Guard dead-agent rechecks, harden digest parsing, fix gate docs
1 warning still open:

  • ⚠️ bin/fm-jev-lib.sh:126 - This can lose a digest entry silently, against the intent's "surfaced with the next real wake or heartbeat, never lost silently". fm_jev_absorb_digest_surface moves its cursor forward on every fm-wake-drain.sh run, whoever runs it. But bin/fm-supervise-daemon.sh:1292 (handle_durable_wakes, the away-mode sub-supervisor) drains into a temp file, reads only the tab-separated queue rows, and deletes the rest. Failing sequence: in always-on mode Jev absorbs a routine working: signal and appends it to absorbed.jsonl. Before any real wake or heartbeat triggers a drain, the captain goes afk. The daemon's first drain prints the ABSORBED section into $out, where it is thrown away, and the cursor is saved past it. The captain never sees that entry: fm-afk-return.sh's catch-up drain (which does put drain output into its evidence) finds nothing pending. The line is still in absorbed.jsonl on disk, but it is never surfaced. Smallest fix: skip digest surfacing (and leave the cursor alone) while away mode owns triage, e.g. return early when $STATE/.afk exists. fm-afk-return.sh stops afk-launch before its own drain, so the pending entries would then show up in the return catch-up evidence.

🔧 Fix: Hold the absorbed-wake digest while away mode owns drains
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • bash tests/fm-jev.test.sh (whole file, including the 13 new absorb-try / absorb-gate / digest tests)
  • bash tests/fm-watch-triage.test.sh (whole file, because the shared watch_bg helper changed; includes the 5 new real-watcher Jev tests: signal absorbed, off still surfaces, declared-pause recheck absorbed, dead-agent recheck never absorbed, captain-held recheck never absorbed)
  • Manual e2e against the REAL local Rizzo Flow server on 127.0.0.1:8017: e2e-absorb-demo.sh covers fm-jev.sh status, absorb-gate and absorb-try across off / requested-without-gate / override / threshold 0.5 / done, needs-decision, blocked and failed verbs / OpenRouter backend / dead endpoint / hung endpoint
  • Probed the real Rizzo answers for routine working:/paused: lines through a logging curl wrapper. All came back firstmate at 0.66–0.84, so absorb-try correctly fell through
  • Manual positive-path e2e with a loopback stub speaking the Rizzo /v1/decisions shape (absorbable 0.95): e2e-absorb-positive.sh covers signal and stale absorption, the masked request and digest, the .afk drain hold, surfacing on the next fm-wake-drain.sh, no repeat, and a hung-server fall-through timed at 2.33s against a 2s config/jev-timeout
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Alan Domio added 5 commits September 28, 2026 01:07
config/jev-absorb (off by default) lets bin/fm-watch.sh skip queuing, and
waking the supervising session for, a wake at exactly two allowlisted call
sites: a routine working/paused signal whose crew is not provably working,
and a declared-pause recheck. Activation requires the local Rizzo Flow
backend specifically, a calibrated confidence threshold (config/jev-absorb-
threshold, never below 0.9), and either bin/fm-jev.sh's new absorb-gate
(zero wrongly absorbable, >=90% agreement, a minimum sample) or an explicit
captain override; needs-decision, blocked, done, failed, merge/check
results, heartbeats, captain inbox notes, secondmate routed replies, Relay,
process-event wakes, and any task with an open decision are never eligible.
Every absorbed wake is appended, masked, to a durable digest that
bin/fm-wake-drain.sh surfaces on the next real wake or heartbeat, so nothing
is lost silently. Any doubt anywhere in the chain falls through to today's
behavior.
…erial 2": `tests/fm-remote-job.test.sh`, check "the worker kept serving after its state root was deleted". This PR doesn't touch the remote-job code, but the failure comes from a real race in the worker, so it's a code fix, not a rerun. **Cause:** the worker's serve loop refreshes its heartbeat and then calls `fm_remote_job_reap_stale`. That sweep called `fm_remote_job_prepare_state`, which creates any missing state directories. If the state root was moved away in the short gap after the heartbeat write succeeded, the sweep silently recreated it. Every later heartbeat then succeeded, so the worker kept serving an unowned queue with no lock, and the test's 10-second tripwire fired. It only happens when the move lands in that gap, which is why it's intermittent. **Fix (smallest root-cause change):** - `bin/fm-remote-job-lib.sh`: `fm_remote_job_reap_stale` no longer re-prepares the state tree. It sweeps only the jobs directory the worker already prepared at startup, and returns 1 if that directory is missing or a symlink. Its only caller is the worker loop, which ignores the return code (`|| true`). The next heartbeat then fails and the worker exits for its supervisor to restart, which is the intended behaviour. - `bin/fm-remote-job-worker.sh`: updated one comment that said the sweep re-prepares the tree. - `tests/fm-remote-job.test.sh`: added a deterministic regression check. It prepares a state root, moves it away, runs the stale sweep, and asserts the sweep fails and doesn't recreate the root. It lives next to the live-worker tripwire, which only hits the gap occasionally. **Verification:** - `bash tests/fm-remote-job.test.sh` → ALL TESTS PASSED, including the tripwire and the new check. - Running the same steps against the pre-fix lib (`git show HEAD:bin/fm-remote-job-lib.sh`): the sweep returned 0 and recreated the deleted root. With the fix it returns 1 and leaves the root absent, so the new check fails before the fix and passes after. - `tests/fm-remote-job-orphan-reap.test.sh` and `tests/fm-remote-doctor.test.sh` pass. - `shellcheck -x` is clean on all three changed files. **Remaining gap:** a much smaller window of the same kind remains. `fm_remote_job_reap`, which the sweep calls once per stale completed job, still prepares state itself. It only matters when stale completed jobs exist at the moment the root is deleted, and I left it alone to keep the fix narrow
@alandomio
alandomio merged commit 94e29da into main Sep 28, 2026
15 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