Skip to content

feat(bin): record shadow advisory facts and add the candidate gates scorer - #34

Merged
andrewesweet merged 7 commits into
mainfrom
fm/branch-jev-gates
Sep 19, 2026
Merged

andrewesweet merged 7 commits into
mainfrom
fm/branch-jev-gates

Conversation

@andrewesweet

Copy link
Copy Markdown
Owner

Intent

Add deterministic facts to the supervision-branch mod's Jev shadow advisory records - the wake key, new status bytes per task, pane identity and stale series, pane observation, authoritative PR presence and identity, severity criteria labels, and each record's own candidate Nouls - assembled from state the mod already reads so the request body to the TypeSafe endpoint is unchanged, and add bin/fm-branch-shadow-gates.sh, a sibling scorer that scores six candidate absorb, suppress, and escalate gates over those records against durable ground truth (outcome rows joined by wake key, the wake-drain backstop's surfacing, and derivable main actions), reporting per-wake eligible, unscorable, fired, correct, and wrong split into delay- versus loss-class plus missed, sweeping floors 0.70-0.99 for the lowest floor with zero loss-class wrong fires and the fire rate there, listing disagreements by wake key under -v, and treating records without facts as unscorable for a gate rather than guessed.

What Changed

  • branch.ts now records a facts object with every shadow advisory record in state/branch-mod-shadow.jsonl (wake key, new status bytes per task, pane identity and stale series, pane observation, authoritative PR presence and owner/repo#N identity, severity class labels, and the record's own candidate Nouls), assembled from state the hook already reads; the request body sent to the endpoint is unchanged.
  • bin/fm-branch-shadow-pane.sh additionally prints the task's window and the watcher's stale.series_index / stale.wedge_escalations markers, read read-only from state/.count-<key> and state/.wedge-escalations-<key>, and no longer treats missing tail and observation as empty when stale evidence exists.
  • New bin/fm-branch-shadow-gates.sh [-v] [<shadow-log>] [<outcomes-file>] scores six candidate gates (absorb-no-new-outcome, absorb-routine-working, stale-active-suppress, pr-ready-arm, severity-alert, candidate-order) over full-variant records against outcome rows joined by wake key, the wake-drain backstop's surfacing, and derivable main actions; reports per-wake eligible/unscorable/fired/correct/wrong (delay- vs loss-class)/missed, sweeps floors 0.70-0.99 for the lowest floor with zero loss-class wrong fires, lists disagreements under -v, and treats records without facts as unscorable. Tests added in branch.test.ts and tests/fm-branch-mod-bin.test.sh; docs updated in AGENTS.md, docs/claude-supervision-branch.md, docs/configuration.md, and docs/scripts.md.

Risk Assessment

✅ Low: The final fix round is a bounded scorer change: the byte sum now emits "-" unless every wake task has a numeric entry, and the stale gate is unscorable unless facts.pane equals the window the wake text names; I traced every fixture record through the current gate_apply/gate_fire/loss logic and the updated table, sweep, and -v expectations all follow from the code, the pane and watcher window strings share the same meta-derived source, and no required intent behaviour is removed.

Testing

Ran the targeted bin test (11 checks, incl. the new 21-record gates fixture and pane helper window/stale cases) and the mod's own plugin suite under the installed Claude Code (36 pass, 0 fail, incl. the three new facts tests); then live-drove bin/fm-branch-shadow-gates.sh over a hand-built state directory with real fm-branch-outcome.sh rows and adversarial records (partial bytes object, empty bytes, torn JSON line, non-full/repeat-2 records, stale wake with another task's pane fact), verified --help, and live-drove bin/fm-branch-shadow-pane.sh against a real isolated tmux server with watcher marker files. All live-driven scenarios passed. The mod's facts-recording scenarios ran only under the stubbed plugin-test world and are reported untested. Only finding is stderr noise from the pane helper when markers are absent.

  • Live validation: ✅ go - 9 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Operator runs bin/fm-branch-shadow-gates.sh over a trial log and gets per-gate eligible/unscorable/fired/correct/wrong(delay|loss)/missed, unmatched and torn-down notes, and the 0.70-0.99 floor sweep ✅ pass live gates-fixture-report.md; bash tests/fm-branch-mod-bin.test.sh
Operator runs the scorer with -v and sees disagreements and unscorable records listed by wake key with pane/candidate detail ✅ pass live gates-fixture-report.md, gates-adversarial.txt
Adversarial: record with partial new_status_bytes (a task missing) or {} is unscorable at absorb-no-new-outcome, never summed to zero and fired ✅ pass live gates-adversarial.txt (1700:1 and 1700:6 listed 'missing inputs', only 1700:5 fires)
Adversarial: compound stale wake whose pane fact belongs to another task is unscorable at stale-active-suppress, not judged on the wrong pane ✅ pass live gates-adversarial.txt (1700:4 stale-active-suppress 'missing inputs'); bin test 1700:19 assertion
Adversarial: a torn JSON line, non-full variants and repeat-2 records are skipped without dropping the records after them ✅ pass live gates-adversarial.txt (1700:2 and 1700:3 absent from every table, 1700:5/1700:6 still scored)
Adversarial: record without facts is unscorable for gates that apply and not counted for gates that do not apply (stale, candidate-order) ✅ pass live bin test 1700:13 assertions in bin-test.log
Operator runs --help and sees the full header through 'only the empty tables.' ✅ pass live gates-help.txt
Scorer on an absent shadow log prints only the empty tables and exits 0 ✅ pass live bin test absent-log assertion in bin-test.log
Pane helper on a live tmux window reports window identity, watcher stale series, tail and observation; omits stale when markers absent or garbage; keeps window+stale without a tail ✅ pass live pane-helper-live.txt
Mod records a facts object on every shadow record (wake key, bytes per task, pane, stale series, observation, authoritative PR owner/repo#N, severity classes, per-record candidate Nouls) while the req… ⏸️ untested no Not driven live. Only exercised under claude plugin test, where the Jev endpoint and the evidence/pane subprocesses are stubbed by the plugin test world (36 pass, 0 fail in plugin-test.log). A live…
Mod omits new_status_bytes for a task whose evidence gather failed instead of recording 0 ⏸️ untested no Not driven live. Only exercised under the same stubbed claude plugin test world (plugin-test.log). A live result needs a real supervision home with classifier-shadow=jev and a FM Jev API key, where…
Evidence: Gates scorer fixture report rows (bin test)

Source: Gates scorer fixture report rows (bin test)

# rows of bin/fm-branch-shadow-gates.sh output that tests/fm-branch-mod-bin.test.sh asserted verbatim over its 21-record fixture (grep -Fx echoes each matched line)
| absorb-no-new-outcome | 4 | 16 | 3 | 2 (66.7%) | 0 | 1 | 1 |
| absorb-routine-working | 2 | 18 | 2 | 1 (50.0%) | 0 | 1 | 0 |
| stale-active-suppress | 6 | 2 | 6 | 2 (33.3%) | 3 | 1 | 0 |
| pr-ready-arm | 4 | 16 | 2 | 1 (50.0%) | 1 | 0 | 0 |
| severity-alert | 2 | 18 | 1 | 0 (0.0%) | 1 | 0 | 1 |
| candidate-order | 3 | 0 | 3 | 2 (66.7%) | 0 | 1 | - |
unmatched (no outcome row carries this wake key; never counted as a verdict): 1 record
torn down (a task record is gone, so the merge-poll and stale-repair truth for these wakes is no longer readable): 1 record
| absorb-no-new-outcome | 0.96 | 0 | 0.0% |
| stale-active-suppress | 0.91 | 0 | 0.0% |
| pr-ready-arm | 0.70 | 2 | 50.0% |
| candidate-order | - | - | - |
1700:8	stale-active-suppress	loss	pane=fm-t4 window=1800s
1700:10	stale-active-suppress	delay	pane=fm-t5 window=1800s
1700:17	stale-active-suppress	correct	pane=fm-t7 window=1800s
1700:11	candidate-order	loss	candidates=t1:0.9,t2:0.5 first_reported=t2
1700:12	candidate-order	correct	candidates=t2:0.9,t1:0.5 first_reported=t2
1700:20	stale-active-suppress	delay	pane=fm-t2 window=1800s
ok - the gates scorer scores only full-variant records with facts, joins ground truth from outcomes, backstop surfacing, and derivable main actions, splits wrong fires into delay and loss, and sweeps for the lowest clean floor
Evidence: Gates scorer adversarial live drive (-v)

Source: Gates scorer adversarial live drive (-v)

# shadow log: 1700:1 compound, partial bytes {"t1":0} (t2 absent); 1700:2 torn JSON line; 1700:3 only without_pane_tail + repeat-2 records; 1700:4 stale fm-t3 with pane fact fm-t1; 1700:5 clean zero, noul 0.9; 1700:6 bytes {}
# outcomes: every key routine (1700:2 present so the torn record would count if parsed)
$ bin/fm-branch-shadow-gates.sh -v
\### candidate gates over full-variant shadow records (ground truth: joined branch outcomes, backstop surfacing, and derivable main actions)
| gate | eligible | unscorable | fired | correct | wrong (delay-only) | wrong (loss) | missed (absorbed, gate silent) |
|---|---|---|---|---|---|---|---|
| absorb-no-new-outcome | 1 | 3 | 1 | 1 (100.0%) | 0 | 0 | 0 |
| absorb-routine-working | 0 | 4 | 0 | 0 (0.0%) | 0 | 0 | 0 |
| stale-active-suppress | 0 | 1 | 0 | 0 (0.0%) | 0 | 0 | 0 |
| pr-ready-arm | 0 | 4 | 0 | 0 (0.0%) | 0 | 0 | 0 |
| severity-alert | 0 | 4 | 0 | 0 (0.0%) | 0 | 0 | 0 |
| candidate-order | 0 | 2 | 0 | 0 (0.0%) | 0 | 0 | - |

\### floor sweep 0.70-0.99: lowest floor with zero loss-class wrong fires, and the fire rate there
| gate | lowest clean floor | fires there | fire rate there |
|---|---|---|---|
| absorb-no-new-outcome | 0.70 | 1 | 100.0% |
| absorb-routine-working | - | - | - |
| stale-active-suppress | - | - | - |
| pr-ready-arm | - | - | - |
| severity-alert | - | - | - |
| candidate-order | - | - | - |

# wakeKey	gate	verdict	detail
1700:5	absorb-no-new-outcome	correct	

# wakeKey	gate	record	unscorable-reason
1700:1	absorb-no-new-outcome	0	missing inputs for the gate
1700:4	absorb-no-new-outcome	1	missing inputs for the gate
1700:6	absorb-no-new-outcome	3	missing inputs for the gate
1700:4	candidate-order	1	missing inputs for the gate
1700:1	candidate-order	0	missing inputs for the gate
1700:4	severity-alert	1	missing inputs for the gate
1700:1	severity-alert	0	missing inputs for the gate
1700:6	severity-alert	3	missing inputs for the gate
1700:5	severity-alert	2	missing inputs for the gate
1700:4	stale-active-suppress	1	missing inputs for the gate
1700:6	absorb-routine-working	3	missing inputs for the gate
1700:5	absorb-routine-working	2	missing inputs for the gate
1700:4	absorb-routine-working	1	missing inputs for the gate
1700:1	absorb-routine-working	0	missing inputs for the gate
1700:1	pr-ready-arm	0	missing inputs for the gate
1700:4	pr-ready-arm	1	missing inputs for the gate
1700:5	pr-ready-arm	2	missing inputs for the gate
1700:6	pr-ready-arm	3	missing inputs for the gate
exit=0
Evidence: Pane helper live drive on real tmux

Source: Pane helper live drive on real tmux

$ bin/fm-branch-shadow-pane.sh t9   # real tmux window fm:t9.v1, watcher markers count=3 wedge=1
{"task":"t9","window":"fm:t9.v1","stale":{"series_index":3,"wedge_escalations":1},"observation":{"progressing":true,"busy_source":"tmux"}}

$ bin/fm-branch-shadow-pane.sh t9   # markers removed: stale omitted
bin/fm-branch-shadow-pane.sh: line 83: /tmp/tmp.f6GC9jNUBy/state/.count-fm_t9_v1: No such file or directory
bin/fm-branch-shadow-pane.sh: line 84: /tmp/tmp.f6GC9jNUBy/state/.wedge-escalations-fm_t9_v1: No such file or directory
{"task":"t9","window":"fm:t9.v1","observation":{"progressing":true,"busy_source":"tmux"}}

$ bin/fm-branch-shadow-pane.sh t9   # tmux server gone, busy-state gone, marker back: window+stale survive without tail
bin/fm-branch-shadow-pane.sh: line 84: /tmp/tmp.f6GC9jNUBy/state/.wedge-escalations-fm_t9_v1: No such file or directory
{"task":"t9","window":"fm:t9.v1","stale":{"series_index":2}}

$ bin/fm-branch-shadow-pane.sh t9   # marker garbage "abc": unavailable, never invented
bin/fm-branch-shadow-pane.sh: line 84: /tmp/tmp.f6GC9jNUBy/state/.wedge-escalations-fm_t9_v1: No such file or directory
{"task":"t9","unavailable":"no readable pane evidence"}

$ bin/fm-branch-shadow-pane.sh t9   # plain window fm-t9 on a live isolated tmux server: tail + window + stale + observation
{"task":"t9","window":"fm-t9","stale":{"series_index":3},"tail":"worker line one\nworker line two","observation":{"progressing":true,"busy_source":"tmux"}}
Evidence: Gates scorer --help tail

Source: Gates scorer --help tail

$ bin/fm-branch-shadow-gates.sh --help | tail -5

The logs default to $STATE/branch-mod-shadow.jsonl and
$STATE/branch-outcomes.jsonl; each wake's task records are read from $STATE.
Exit 0 always; the tables are the result, and an absent shadow log prints
only the empty tables.

help lines: 85; header comment lines in file: 85
Evidence: bin test log

Source: bin test log

ok - the evidence bundle presents NEW and HISTORY lines by byte offset and owns the per-task offset file
ok - a captain-facing line covered only by a ROUTINE branch outcome surfaces once on the main drain, only under the mod, even behind a newer routine line, and keyed decisions stay in the fold
ok - only the lines between the previous outcome's endpoint and the routine outcome's endpoint are listed
ok - a routine-covered line omitted by the byte cap is presented on the next drain, and neither a later covered line nor the uncovered newest line acknowledges past it
ok - the scorer labels each record from the status bytes it judged, reports false-routine verdicts as captain misses, and skips a torn line without losing the records after it
ok - the jev helper is off without a key: one unavailable line, exit 0, no network
ok - the jev helper forwards the request and the key reaches curl only on the fd-3 header
ok - an http failure becomes one unavailable record and never a nonzero exit
ok - the pane helper reports only readable evidence and omits every field it cannot read
ok - the shadow scorer joins records to the branch verdict by durable wake key, reports unmatched records separately, skips a torn line in either log, counts unavailable records separately, and scores the repeat control outside the variant rows
| absorb-no-new-outcome | 4 | 16 | 3 | 2 (66.7%) | 0 | 1 | 1 |
| absorb-routine-working | 2 | 18 | 2 | 1 (50.0%) | 0 | 1 | 0 |
| stale-active-suppress | 6 | 2 | 6 | 2 (33.3%) | 3 | 1 | 0 |
| pr-ready-arm | 4 | 16 | 2 | 1 (50.0%) | 1 | 0 | 0 |
| severity-alert | 2 | 18 | 1 | 0 (0.0%) | 1 | 0 | 1 |
| candidate-order | 3 | 0 | 3 | 2 (66.7%) | 0 | 1 | - |
unmatched (no outcome row carries this wake key; never counted as a verdict): 1 record
torn down (a task record is gone, so the merge-poll and stale-repair truth for these wakes is no longer readable): 1 record
| absorb-no-new-outcome | 0.96 | 0 | 0.0% |
| stale-active-suppress | 0.91 | 0 | 0.0% |
| pr-ready-arm | 0.70 | 2 | 50.0% |
| candidate-order | - | - | - |
1700:8	stale-active-suppress	loss	pane=fm-t4 window=1800s
1700:10	stale-active-suppress	delay	pane=fm-t5 window=1800s
1700:17	stale-active-suppress	correct	pane=fm-t7 window=1800s
1700:11	candidate-order	loss	candidates=t1:0.9,t2:0.5 first_reported=t2
1700:12	candidate-order	correct	candidates=t2:0.9,t1:0.5 first_reported=t2
1700:20	stale-active-suppress	delay	pane=fm-t2 window=1800s
ok - the gates scorer scores only full-variant records with facts, joins ground truth from outcomes, backstop surfacing, and derivable main actions, splits wrong fires into delay and loss, and sweeps for the lowest clean floor
Evidence: claude plugin test log

Source: claude plugin test log


tests/branch.test.ts:
(pass) version pin > refuses to load on any other Claude Code version and passes every wake through [109.31ms]
(pass) version pin > loads on the pinned version and registers the report tools [38.41ms]
(pass) version pin > the binary hosting the session decides the pin when PATH claude differs [51.44ms]
(pass) version pin > a refusal records which source decided against the pin [30.18ms]
(pass) version pin > PATH claude decides when the running binary's version is unavailable [32.11ms]
(pass) version pin > without state/.branch-mod-mode the module loads inert and passes every wake through unclassified [36.10ms]
(pass) transcript persistence log > session.start logs the persistence state and its cause [30.09ms]
(pass) transcript persistence log > an inherited CLAUDE_CODE_CHILD_SESSION marker logs persistence off [27.61ms]
(pass) transcript persistence log > CLAUDE_CODE_FORCE_SESSION_PERSISTENCE logs persistence on over the marker [26.99ms]
(pass) classification log > every classifier call appends one record with task, evidence byte offsets, verdict, and model [41.12ms]
(pass) classification log > the classifier model defaults to haiku when config/classifier-model is absent [33.25ms]
(pass) classification log > a captain verdict passes the wake to main and writes a covering captain outcome row [32.45ms]
(pass) classification log > a passed wake main never acknowledged is passed again once the dedupe window has elapsed [40.82ms]
(pass) classification log > a passed row still queued after a restart goes back to main unclassified, even though its line is HISTORY to the classifier now [41.24ms]
(pass) classification log > a stale row keyed by the task's window resolves to the task id for the offset advance and the cover row [41.12ms]
(pass) open-decision fold v8 > a done: line closes an open decision for a ship task, so the stale wake is classified instead of passed [34.03ms]
(pass) open-decision fold v8 > a failed: line closes an open decision for a scout task [35.62ms]
(pass) open-decision fold v8 > a secondmate's done: line cannot close an open decision [28.77ms]
(pass) open-decision fold v8 > continuation prose after a captain-held: line does not un-hold the task (latest event, not last line) [38.37ms]
(pass) open-decision fold v8 > a working: line after a captain-held: line un-holds the task [31.88ms]
(pass) routine wake > a routine verdict grants the wake and spawns the one persistent branch agent [34.02ms]
(pass) routine wake > an unresumable branch agent rotates to a fresh named agent instead of re-sending to the dead one [50.57ms]
(pass) routine wake > a SendMessage denied with the unresumable text also rotates [35.34ms]
(pass) shadow advisory > absent config/classifier-shadow means no shadow helper call and no shadow records [35.22ms]
(pass) shadow advisory > a config naming another model stays off [39.20ms]
(pass) shadow advisory > jev records one row per ablation variant, each with the request bytes and policy floors [39.61ms]
(pass) shadow advisory > fields with no evidence are omitted, never invented: no pane data makes full byte-identical to without_pane_tail [35.66ms]
(pass) shadow advisory > facts ride every record, mirror the assembled state, and per-variant candidates come only from that record's answers [42.81ms]
(pass) shadow advisory > facts stay honest when evidence is missing: no pane, no PR, no noul means absent fields [37.08ms]
(pass) shadow advisory > facts omit new_status_bytes for a task whose evidence gather failed, never a fake zero [33.65ms]
(pass) shadow advisory > prior_outcomes carry provenance: source, same_wake, and already_presented [43.34ms]
(pass) shadow advisory > a compound wake carries one provenance-bearing Noul per candidate; a stale wake carries stale_state [39.07ms]
(pass) shadow advisory > a stale wake carries the stale_state question and never a recovery question [35.73ms]
(pass) shadow advisory > a wake-queue row with a non-numeric epoch is unsafe scope: passed to main untouched, no shadow record, no wake key stamped [53.62ms]
(pass) shadow advisory > an unavailable helper records unavailable per variant and never touches the delivery [35.08ms]
(pass) shadow advisory > every tenth wake repeats the full variant as the raw-call-noise control [44.26ms]

 36 pass
 0 fail
Ran 36 tests across 1 file. [1.65s]
- Outcome: ⚠️ 1 info across 1 run (5m38s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 6 issues found → auto-fixed (5) ✅
  • 🚨 bin/fm-branch-shadow-gates.sh:276 - task_restarted_after never detects a restart in production. bin/fm-busy-event.sh arm mints gen as g&lt;epoch&gt;.&lt;pid&gt;.&lt;random&gt; (line 159), but the scorer rejects any gen matching *[!0-9]*, so every real busy-state record returns 1. wake_stale_repair then only sees teardown, and stale-active-suppress fires over a relaunched worker are counted correct instead of delay, and stale wakes whose repair was a relaunch are never actionable for the absorb gates (loss fires counted as correct). The bin test fixture (tests/fm-branch-mod-bin.test.sh:80) writes a bare-number gen that the real appender never produces, which is why it passes. Fix: extract the epoch with sed -n &#39;s/^g\{0,1\}\([0-9]\{1,\}\)\(\..*\)\{0,1\}$/\1/p&#39; (or awk on ^g?([0-9]+)) and write the fixture in the real g&lt;epoch&gt;.&lt;pid&gt;.&lt;rand&gt; form.
  • 🚨 bin/fm-branch-shadow-gates.sh:383 - severity-alert eligibility requires R_SEVHIT == hit, i.e. the score already fell in a security/privacy/data-loss/credential/publication class. Every full record carries a severity answer, so all records scored 0-2 are counted unscorable ("missing inputs for the gate") rather than eligible-and-silent: the fire rate in the sweep becomes fired/fired, missed can never include a low-scored actionable wake, and the table misreports the gate as having almost no eligible wakes. Eligibility should be R_SEVCLS != &#34;-&#34; (score in range), R_SEVCONF != &#34;-&#34;, and R_SEVANY = any; hit belongs only in gate_fire.
  • ⚠️ bin/fm-branch-shadow-gates.sh:205 - LAST_EP[$task] is only advanced for rows that carry a wakeKey, because the continue on a - wake key (line 201) runs first. Unkeyed rows exist mid-trial (branch.ts:1186 appends a direct pass-to-main captain row with no --wake-key; pre-trial and Pi-branch rows are also unkeyed). Sequence: t1 row A (no key, captain, endpoint 100, span holds needs-decision: x), then row B (key W, routine, endpoint 200). Scorer scans (0,200] for B, finds the already-presented decision line, sets WK_BACKSTOP[W], and every absorb fire on W is scored a loss-class wrong fire. Move prev_ep=${LAST_EP[$task]:-0}; LAST_EP[$task]=$endpoint above the wake-key guard so every row of the task advances the span start.
  • ⚠️ bin/fm-branch-shadow-gates.sh:124 - The record's stale flag uses jq test(&#34;^stale:&#34;), where ^ anchors to start of string, but branch.ts:905 uses /^stale:/m and the wake reason is reasonLines(...).join(&#39;\n&#39;) in queue order (branch.ts:1168). A compound wake signal: ...\nstale: fm-t2 gets a stale_state question and answer in the record but is classed plain here: stale-active-suppress returns not-applicable for it, WK_ISSTALE stays unset so wake_stale_repair is never consulted, and stale_window_loss never sees it as a later stale wake of the pane. Use test(&#34;(^|\n)stale:&#34;).
  • ⚠️ bin/fm-branch-shadow-gates.sh:377 - stale-active-suppress needs two facts the gate_apply check ignores: pane_observation.progressing (gate_fire line 340 requires true) and pane identity (stale_window_loss keys on it). A stale record with facts but no pane observation is counted eligible and, when absorbable, missed, although the gate could never have judged it; and pane_of (line 295) falls back to the first task id when the pane fact is absent, which both guesses an identity and cannot match records of the same pane that do carry fm-&lt;task&gt;. The header (lines 17-19) says a record without the inputs one gate needs is unscorable, never guessed. Require R_PROG != &#34;-&#34; and R_PANE != &#34;-&#34; in gate_apply for this gate and drop the task0 fallback in pane_of.
  • ℹ️ .claude/mods/fm-branch-mod/hooks/branch.ts:725 - paneExtras?.window ?? (st.pane ? String((st.pane as any).task ?? &#39;&#39;) : &#39;&#39;) - the fallback is unreachable: st.pane and paneExtras are set from the same helper line, so whenever st.pane exists paneExtras exists and window is either present or the fallback yields the task id, not a pane identity. facts.pane = paneExtras?.window alone is equivalent and truthful.

🔧 Fix applied.
3 issues (2 warnings, 1 info) still open:

  • ⚠️ bin/fm-branch-shadow-gates.sh:289 - wake_stale_repair treats "task meta and status both gone" as a derivable stale repair, but bin/fm-teardown.sh:936 removes <task>.meta on every ordinary teardown, so at scoring time every stale wake of any task that has since finished normally becomes actionable. Concrete: stale wake W on t7, worker was fine (routine row, no restart, no backstop), t7 completes days later and is torn down; the scorer run afterwards scores an absorb-no-new-outcome fire on W as a loss-class wrong fire, a stale-active-suppress fire on W as delay, any earlier same-pane stale fire within 1800s as loss, and W is never missed. The sweep's "lowest clean floor" therefore drifts upward the longer the scorer runs after the trial, which is the opposite of durable ground truth. The header (line 33) documents this clause, so it is a deliberate heuristic: decide whether teardown should count at all, or only when the busy-state gen shows a relaunch; the smallest remedy is dropping the teardown clause from wake_stale_repair.
  • ⚠️ bin/fm-branch-shadow-gates.sh:201 - For the first outcome row of a task prev_ep is 0, so backstop_span_has_surface scans (0, endpoint] over the whole status log. The real backstop it claims to mirror bounds the span by the wake's receipt offset as well as the previous row's endpoint (bin/fm-classify-lib.sh:1223 [ &#34;$prev&#34; -le &#34;$from&#34; ] || from=$prev, with from = the classifier receipt), so lines the old classifier or Pi path presented before the mod's first row are never re-surfaced there. Concrete: a home enables the branch mod on a live task whose status already holds done: PR ... checks green (presented pre-mod, no outcome row); the first keyed routine row on that task scans from byte 0, finds the line, sets WK_BACKSTOP for that wake, and every absorb fire on it is a loss-class wrong fire that main's backstop would never have surfaced. No durable receipt exists for historical wakes, so the honest choice is either to treat the backstop as unscorable when the task has no earlier row (skip the scan when prev_ep is 0) or to accept the bias; that is a ground-truth policy decision, not a mechanical fix.
  • ℹ️ bin/fm-branch-shadow-gates.sh:33 - The header says stale repair is derived from "a later outcome row for the same task or the task's records gone", but wake_stale_repair derives it from a newer busy-state gen (relaunch) or teardown; no later-outcome-row check exists. Align the header with the code (or vice versa, per the teardown finding) so -v adjudication reads the right rule.

🔧 Fix applied.
6 issues (4 warnings, 2 infos) still open:

  • ⚠️ .claude/mods/fm-branch-mod/hooks/branch.ts:724 - new_status_bytes[task] = Math.max(0, b.to - b.from) records 0 when the evidence gatherer failed: gatherEvidence (branch.ts:585, 588) returns from=-1,to=-1 on a non-zero exit, a 25s timeout, or an unparseable range, and -1 - -1 = 0. The scorer then treats the wake as having zero new status bytes, so absorb-no-new-outcome is eligible and fires whenever the Noul clears the floor, and the fact header's promise ("never an invented value") is broken for exactly the wakes whose evidence is unknown. Concrete: fm-wake-evidence.sh t1 times out; record facts.new_status_bytes.t1 = 0; a routine wake with noul 0.9 counts as a correct absorb. Fix: skip the entry when b.from &lt; 0 || b.to &lt; 0 so the scorer sees - and counts the record unscorable for that gate.
  • ⚠️ bin/fm-branch-shadow-gates.sh:363 - gate_apply checks unavailable and nofacts (lines 363-364) before the per-gate applicability guards that return 2, so a plain wake at stale-active-suppress and a single-task wake at candidate-order are counted unscorable although the gate does not apply to them; stale-ness comes from the record's wake text and the task count from tasks, neither needs facts. In production every unavailable or pre-facts record inflates the stale and ordering gates' unscorable columns by one each. The bin test enshrines it: stale-active-suppress | 5 | 2 and candidate-order | 2 | 1 count the plain single-task nofacts record 1700:13, and the -v assertion at tests/fm-branch-mod-bin.test.sh:172 requires 1700:13 to be listed under stale-active-suppress. Fix: move the R_STALE = stale || return 2 and R_NTASKS -ge 2 || return 2 guards above the avail/facts checks and update those three assertions (stale unscorable 1, candidate-order unscorable 0, drop the 1700:13 stale line).
  • ⚠️ bin/fm-branch-shadow-gates.sh:373 - The stale gate's pane facts belong to tasks[0], not to the window the stale line names: branch.ts:842 calls fm-branch-shadow-pane.sh for a.tasks[0] only, and eligible tasks follow queue-row order, so a compound wake signal: t1.status\nstale: fm-t2 (...) records pane=fm-t1 and fm-t1's progressing flag. gate_fire then fires stale-active-suppress on the wrong pane's progress, and stale_window_loss looks for later stale wakes of fm-t1 instead of fm-t2, so a captain stale on fm-t2 inside the window is never a loss. The watcher's reason is stale: &lt;window&gt; (...) (bin/fm-watch.sh:1143), so the honest guard is mechanical: capture the window after stale: in the REC_ROWS jq and require it to equal R_PANE in gate_apply for stale-active-suppress, else return 1 (unscorable, never guessed).
  • ⚠️ bin/fm-branch-shadow-gates.sh:273 - The two derivable main actions are read from files teardown deletes, so ground truth still drifts with scoring time, now in the opposite direction from the round-2 teardown finding. task_restarted_after reads state/<task>.busy-state, which fm-busy-event.sh retire removes (bin/fm-busy-event.sh:211) during fm-teardown.sh (line 1258); task_poll_armed reads <task>.pr-poll and pr= in <task>.meta, both removed by teardown (lines 936, 1302). Concrete: stale wake W on t5, worker relaunched (gen newer), scorer before teardown scores a stale-active-suppress fire on W as delay and an absorb fire as loss; after t5 is torn down the same records score correct, and W becomes missed for the absorb gates; a pr-ready-arm fire whose only PR truth was the armed poll flips from correct to delay. The sweep's lowest clean floor therefore falls the longer after the trial the scorer runs. No durable launch or poll log exists in the state inventory, so this is a ground-truth policy decision rather than a mechanical fix: either document that the gates scorer is only valid while the trial's tasks are live (and print a note when a wake's task records are gone), or derive these actions from a durable store the intent authorises.
  • ℹ️ bin/fm-branch-shadow-gates.sh:96 - --help prints header lines 2-80, but the header now runs to line 82, so the last two lines of the Usage note ("Exit 0 always; ... only the empty tables.") are cut off. Use 2,82p or stop at the first non-comment line (sed -n &#39;2,/^set -eu/{/^set -eu/!p}&#39;).
  • ℹ️ .claude/mods/fm-branch-mod/hooks/branch.ts:725 - Simplification: the fallback (st.pane ? String((st.pane as any).task ?? &#39;&#39;) : &#39;&#39;) is a second definition of pane identity the intent does not need. fm-branch-shadow-pane.sh always prints window on any non-unavailable line (line 122), so paneExtras.window is present whenever st.pane is; if the fallback were ever reached it would record the task id as facts.pane, which the scorer would then compare against real fm-&lt;task&gt; window names and never match. Remove it: const paneId = paneExtras?.window ?? &#39;&#39;.

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-branch-shadow-gates.sh:335 - The round-4 fix keys the stale gate's identity and loss window on the window named in the wake text (R_STALE), but the fire condition at line 335 still reads R_PROG, which is facts.pane_observation.progressing for tasks[0]'s pane (branch.ts:842 runs fm-branch-shadow-pane.sh for a.tasks[0] only; eligibleTasks follow queue-row order). For a compound wake signal: t1.status\nstale: fm-t2 the record carries fm-t1's progressing flag, so the gate fires (or stays silent) on the wrong pane's evidence and the scorer counts a fire the real gate would never have had grounds for; the fixture record 1700:19 enshrines exactly this (facts.pane fm-t1 + progressing true, stale fm-t2) and the assertion at tests/fm-branch-mod-bin.test.sh:184 requires it to fire. This follows the round-3 user instruction that such a wake "must fire, delay, and take loss on fm-t2's identity", so it is a deliberate-intent question rather than a mechanical fix: the honest guard is to keep the facts.pane column and, in gate_apply for stale-active-suppress, return 1 (unscorable) unless facts.pane equals the named stale window, then change 1700:19's expectation to unscorable (stale row 6 | 2, no loss on 1700:19, 1700:20 stays delay). Please confirm which reading the trial wants.

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-branch-shadow-gates.sh:148 - The round-3 fix omits a failed-gather task from facts.new_status_bytes (branch.ts:724), but the scorer sums whatever entries remain: [($f.new_status_bytes // {})[] | numbers] | add // 0 turns an empty object into "0" ([] | add is null, // 0 makes it 0), so the fake zero the fix was meant to remove reappears at scoring time. Concrete: fm-wake-evidence.sh t1 times out, the record carries new_status_bytes: {} (exactly what the branch.test.ts case asserts), REC_ROWS bytes = 0, gate_apply for absorb-no-new-outcome passes (R_BYTES != &#34;-&#34;), and a noul 0.9 record fires and is scored correct/loss on evidence that was never read. The same happens for a compound wake where t1 gathered 0 bytes and t2's gather failed ({&#34;t1&#34;:0} sums to 0 while t2's bytes are unknown). This contradicts the intent's "treating records without facts as unscorable for a gate rather than guessed". Fix in the jq: emit "-" unless every task in $r.tasks has a numeric entry, e.g. (if ($f.new_status_bytes | type) == &#34;object&#34; and (($r.tasks // []) | length) &gt; 0 and (($r.tasks // []) | all(. as $t | ($f.new_status_bytes[$t] | type) == &#34;number&#34;)) then ([($r.tasks // [])[] as $t | $f.new_status_bytes[$t]] | add | tostring) else &#34;-&#34; end); no existing bin-test expectation changes (no fixture has a partial bytes object), and the branch.test.ts {} assertion stays valid.

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 info
  • ℹ️ bin/fm-branch-shadow-pane.sh:83 - When a watcher marker is absent (the common case for a non-stale task), the shell reports bin/fm-branch-shadow-pane.sh: line 83: .../.count-&lt;key&gt;: No such file or directory (and line 84 for the wedge marker) on stderr, because 2&gt;/dev/null binds to tr while the failing input redirect is evaluated by the shell first. Stdout JSON is unaffected and the mod reads stdout only, so behaviour is correct, but the header promises the helper 'prints nothing' for an absent marker and a human running it by hand sees two spurious errors per call. Fix: guard with [ -f &#34;$STATE/.count-$key&#34; ] &amp;&amp; series=$(tr ... &lt;&#34;$STATE/.count-$key&#34;) or wrap as { tr -d &#39;[:space:]&#39; &lt;&#34;$f&#34;; } 2&gt;/dev/null.
  • Live validation: ✅ go - 9 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Operator runs bin/fm-branch-shadow-gates.sh over a trial log and gets per-gate eligible/unscorable/fired/correct/wrong(delay|loss)/missed, unmatched and torn-down notes, and the 0.70-0.99 floor sweep ✅ pass live gates-fixture-report.md; bash tests/fm-branch-mod-bin.test.sh
Operator runs the scorer with -v and sees disagreements and unscorable records listed by wake key with pane/candidate detail ✅ pass live gates-fixture-report.md, gates-adversarial.txt
Adversarial: record with partial new_status_bytes (a task missing) or {} is unscorable at absorb-no-new-outcome, never summed to zero and fired ✅ pass live gates-adversarial.txt (1700:1 and 1700:6 listed 'missing inputs', only 1700:5 fires)
Adversarial: compound stale wake whose pane fact belongs to another task is unscorable at stale-active-suppress, not judged on the wrong pane ✅ pass live gates-adversarial.txt (1700:4 stale-active-suppress 'missing inputs'); bin test 1700:19 assertion
Adversarial: a torn JSON line, non-full variants and repeat-2 records are skipped without dropping the records after them ✅ pass live gates-adversarial.txt (1700:2 and 1700:3 absent from every table, 1700:5/1700:6 still scored)
Adversarial: record without facts is unscorable for gates that apply and not counted for gates that do not apply (stale, candidate-order) ✅ pass live bin test 1700:13 assertions in bin-test.log
Operator runs --help and sees the full header through 'only the empty tables.' ✅ pass live gates-help.txt
Scorer on an absent shadow log prints only the empty tables and exits 0 ✅ pass live bin test absent-log assertion in bin-test.log
Pane helper on a live tmux window reports window identity, watcher stale series, tail and observation; omits stale when markers absent or garbage; keeps window+stale without a tail ✅ pass live pane-helper-live.txt
Mod records a facts object on every shadow record (wake key, bytes per task, pane, stale series, observation, authoritative PR owner/repo#N, severity classes, per-record candidate Nouls) while the req… ⏸️ untested no Not driven live. Only exercised under claude plugin test, where the Jev endpoint and the evidence/pane subprocesses are stubbed by the plugin test world (36 pass, 0 fail in plugin-test.log). A live…
Mod omits new_status_bytes for a task whose evidence gather failed instead of recording 0 ⏸️ untested no Not driven live. Only exercised under the same stubbed claude plugin test world (plugin-test.log). A live result needs a real supervision home with classifier-shadow=jev and a FM Jev API key, where…
  • bash tests/fm-branch-mod-bin.test.sh (test_gates_scorer_joins_full_records_to_outcomes_facts_and_derivable_actions, test_shadow_pane_helper_reports_only_what_it_can_read and siblings)
  • CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1 claude plugin test .claude/mods/fm-branch-mod (36 pass, 0 fail; facts ride every record / facts stay honest / facts omit failed-gather bytes / compound candidates) — stubbed world, not live
  • Live: FM_STATE_OVERRIDE=&lt;tmp&gt; bin/fm-branch-shadow-gates.sh -v over real fm-branch-outcome.sh append --wake-key rows with partial bytes, empty bytes, torn line, non-full variant, repeat-2, and foreign-pane stale records
  • Live: bin/fm-branch-shadow-gates.sh --help line count equals header comment line count (85)
  • Live: FM_STATE_OVERRIDE=&lt;tmp&gt; bin/fm-branch-shadow-pane.sh t9 against an isolated tmux server (TMUX_TMPDIR) with .count-/.wedge-escalations- markers present, absent, garbage, and with the server killed
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

The Jev shadow trial could only score what the mod recorded: the answer
bytes, with no deterministic snapshot of the state each answer judged.
Every full-variant shadow record now carries a facts object - the wake
key, new status bytes per task, pane identity and stale series, pane
observation, authoritative PR presence and identity, severity criteria
labels, and that record's own candidate Nouls - assembled from state the
mod already read, so the request body is unchanged. The pane helper
reports the window identity and the watcher's stale-series markers when
it can read them, and the mod folds those into facts only.

bin/fm-branch-shadow-gates.sh scores six candidate absorb, suppress, and
escalate gates over those records against durable ground truth: outcome
rows joined by wake key, the wake-drain backstop's surfacing, and
derivable main actions such as a worker restart after a stale wake or a
recorded PR behind a ready phase. Per wake it reports eligible,
unscorable, fired, correct, and wrong split into delay- versus
loss-class, sweeps floors 0.70-0.99 for the lowest clean floor, and
reports unmatched records separately, so the trial can say what each
gate would have done before anyone acts on one.
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