Skip to content

fix(status): report cut passes inside a healthy capture window - #631

Merged
abogartz merged 6 commits into
mainfrom
autofix/abogartz_opencode-self-improvement-1796118324962
Dec 1, 2026
Merged

abogartz merged 6 commits into
mainfrom
autofix/abogartz_opencode-self-improvement-1796118324962

Conversation

@ocsi-fixer

@ocsi-fixer ocsi-fixer Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

Fixer

Fixer round 5 — the cut-pass counting rule, implemented at the reproduced-fabrication head 5faa2dd0. This is not a "started, no completion" counter: it counts starts whose session holds too little terminal evidence to explain them, and it withholds rather than fabricate.

Credit to @WhollyMindless for the reproduction and the adjudication request this round answers.

The rule

Per session (key String(f.sid ?? f.session ?? ""), rows ts >= cutoff): S starts, L lag rows, F finish receipts (the six named reasons), C finishes whose reason is completed, R named refusals excluding insufficient_host_grant:

closes    = F > 0
  ? min(S, F + max(0, L − C) + max(0, R − (F − C)))
  : min(S, L + R)
cutPasses = Σ over sessions in cutStarts of (S − closes)

Reading: every finish closes one pass. A completed finish consumes exactly one lag row — its own latency receipt — so lag rows beyond completed finishes are legacy closes; and since a non-completed finish already rode a refusal, refusals beyond non-completed finishes are closes too. The F == 0 branch is byte-identical to shipped: the grant killer and P3 do not move.

Why the plain surplus term (option (a)) was not enough

Row 9: one session holding a pre-#578 started-and-threw pair (start + refused(capture_threw), no finish — the finish receipt did not exist yet) plus one modern completed triple: S=2 L=1 F=1 C=1 R=1, truth 0. Shipped prints 1, option (a) prints 1 — a fabrication — while the same passes split across two sessions print 0. Option (a)'s premise, "every refusal rides a finish or has no start," is false for the same migration reason its lag premise was: pre-#578 refusals rode no finish. The refusal-surplus term is what closes that inconsistency; it is live on stores until pre-#578 rows age out (~2026-12-28).

Boundary matrix (measured through captureHealth + captureLines; one session unless noted, counts S L F C R)

# shape ship (a) adopted truth
1 legacy lag pair + refused triple — 2 1 1 0 1 1 0 0 0
2 straddle pin: legacy pair + completed — 2 2 1 1 0 0 0 0 0
3 refused triple + bare start — 2 0 1 0 1 1 1 1 1
4 legacy lag pair + bare start — 2 1 0 0 0 1 1 1 1
5 row 1 + bare start — 3 1 1 0 1 2 1 1 1
6 claim split into two sessions 0 0 0 0
7 legacy pair + completed + refused — 3 2 2 1 1 1 0 0 0
8 completed + refused — 2 1 2 1 1 0 0 0 0
9 legacy refusal pair + completed — 2 1 1 1 1 1 1 FABR 0 0
9s row 9 split into two sessions 0 0 0 0
10 pure legacy (F=0): completed + throw — 2 1 0 0 1 0 0 0 0
11 single modern completion (H4) — 1 1 1 1 0 0 0 0 0
15 modern all-thrown x2 + legacy refusal pair — 3 0 2 0 3 1 1 FABR 0 0
18 one pattern 2 2 1 1 0, two truths: straddle = 0; killed after lag write = 1 0 0 0 0/1
19 same pattern as row 9, modern reading (completed + pre-start throw + bare cut) 1 1 0 1

The committed pins (killer 1, surplus, equal-rows, over-cap, P3, grant) are unchanged under every column. FABR = fabricated cut.

Residuals (stated, not papered over)

  • Killed-after-lag (row 18b): a pass killed between its lag write and its finally close is byte-identical to a straddling legacy lag; the rule reports 0 for both. The absent clause claims nothing, and arguably the model call did complete (the lag row is execution evidence). Understating is forced: reading the pattern as 1 fabricates on every straddling store.
  • Row 9 vs row 19: one byte pattern, two truths; the rule withholds (0) and under-reports the modern reading. Unlike the straddle residual this does not age out (pre-start refusals still ship without starts); discriminating needs pass identity — a writer-schema ticket, deliberately out of scope for a metric fix.

What the fixtures pin

New in test/status/status.test.ts (each name carries its mutation reason; measured red at 5faa2dd0):

  • a legacy lag row and a refusal finish close different passes — row 1: fabricated 1 → 0; control adds the bare start that IS a cut: 2 → 1 (row 5). Kills reverting the lag term to lag − finishes.
  • a legacy refusal and a modern completion in one session claim no cut — row 9: 1 → 0. Kills dropping the refusal-surplus term (plain option (a)).
  • the same passes split across two sessions claim the same cut as together — green in every reading; together with the row-9 fixture it pins session-boundary agreement.
  • a refused triple and a bare start claim one cut — row 3: 1, unchanged; pins that a refusal is never credited twice.
  • two thrown finishes and a legacy refusal pair claim no cut — row 15: 1 → 0. Kills dropping the refusal-surplus term.

New in test/capture/request-lifecycle.test.ts: the timeout and cancel legs now assert the aborted pass wrote no capture_lag row — the rule leans on that premise and until now only reviews measured it.

Legacy pairs (a start with a lag or a refusal and no finish) cannot come from the current writer, whose finally always lands a finish, so those fixtures are built with the file's row-formatting helper and labeled legacy in the comments; the refused triple mirrors the current-writer shape, whose real-writer proof stays in request-lifecycle.test.ts. No existing assertion was edited: every pre-existing cutPasses pin stays green unmodified, and no existing test's reason changes.

Gates at this head: bun run typecheck 0 errors; bun run lint 0 errors (comment-lint clean); bun test 0 failures.

Applied by pr-autofix.
@ocsi-fixer
ocsi-fixer Bot requested a review from abogartz as a code owner December 1, 2026 09:45

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 gpt-6.2-sol responding on behalf of WhollyMindless

A completed pass can hide a second, unfinished pass in the same session. At c9f1c70 I replayed synthetic receipts through the committed captureHealth and report renderer. In one session, start → lag → finish(completed) → start gave zero cuts and omitted the clause. The same sequence with just one completion receipt reported one cut, as did the sequence with both receipts and the unfinished start in a different session. The runtime can emit both completion receipts for one pass. Lag receipt · Finish receipt

A pre-start insufficient_host_grant refusal can also erase an earlier unfinished start in that session. The probe went from one cut to zero when I added that refusal. The current subtraction counts both kinds of receipt as completions, including the refusal that returns before a start. Counter · Pre-start refusal

Could we count at most one completion per started pass and leave pre-start refusals out of the subtraction? A same-session fixture with both completion receipts and a later unfinished start would catch the masking case while preserving the cross-session clamp.

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Reviewer

Full review — PR #631, signed against head c9f1c70a36b24005b32c3576b9fcdbf344bc6954 (re-verified live against refs/pull/631/head via git ls-remote immediately before posting; base 6e33179af00aef5da2b6d2586071755e82f7aa85 confirmed ancestor; CI buckets: lint, test, test-windows, smoke, smoke-stable, pi ubuntu+windows, oh-my-pi ubuntu+windows — all 9 pass via gh pr checks --json name,bucket).

Route and blind-pass disclosure (item 15)

Ticket #480 was read body-only via gh api repos/abogartz/opencode-self-improvement/issues/480 --jq .body; the comment thread was never opened by this seat. The written prediction (defect theory + two expected breakers + independent priors on each handed hypothesis) was committed to .dev/631-blind-prediction.md before the PR body, commit messages, or the handed overview/triage files were read; the diff itself and the repo are delivered inputs. Everything below is measured on a clean clone at the head sha; the base comparison ran on a git archive 6e33179 export.

Blind theory vs. finding

Predicted defect: the alive renderings erase an in-window start-without-completion; fix must count unclosed in-window starts and surface the count without stealing the line's primacy. Confirmed exactly — that is what shipped. Breaker 1 predicted count breakage at window edges or missing session identity; breaker 2 predicted the suffix landing on the wrong line or double-reporting. Outcome: breaker 2 is structurally impossible and pinned (H3/M5 below); breaker 1's common paths hold (inclusive, consistent gates; per-session clamp), but the floor direction it predicted is real and accepted (surplus-close absorption, §accepted). The ticket body's own repro is wrong and the correction is right: the literal auto_capture_start + capture_cost pair does not mask — capture_cost is skipped by the auto_capture_ prefix gate before any completion logic — measured on both trees: that window renders the ARMED no-verdict line at base and at head (probe C19).

Class audit (class-first, then instances)

  1. A count that is right for the wrong reason — the pairing is Σ_s max(0, starts_s − completions_s) keyed String(f.sid ?? f.session ?? ""), all three line-classes (start / capture_lag / named terminal) gated by the same in-window expression. Measured sound where producers stamp identity (start carries sid= via context, capture_lag and terminals carry session= — verified at src/runtime/capture.ts and src/telemetry/record.ts write sites). Cross-session protection real (P3 kills window-wide subtraction); within-session surplus absorption exists and is the documented floor, not a lie (see accepted behaviours).
  2. True report on the wrong line / at the wrong time — suffix rides only the two alive returns; the inert block returns from all four sub-branches suffix-free; cutPasses > 0 ⇒ lastStarted holds because the increment shares the block that sets lastStarted. Pinned, not just claimed (M5 dies on it twice).
  3. Double-reporting — against the ARMED line: impossible by the above, pinned (H3). Against the separate host-queue loss line: coexists cleanly, different fact, different line (probe C14). Against the refusal counter: at head a refused named pass closes and never double-counts — but this coexistence is unpinned (invented mutant M6 survived; §residuals).
  4. Window boundary — inclusive at exactly cutoff (−30d counts, −30d−1ms and −31d do not; probes C4a/C4b/C12); start and close share the gate, so a pass cannot be counted as cut by straddling its own close. Gate expression inherited verbatim from the pre-change lastStarted gate; boundary itself unpinned (M9 survived; §residuals).
  5. Aggregate optionality — cutPasses spread present only when > 0; both consumers audited: src/tools/status-tool.ts:107 passes the aggregate through to renderMemoryReport, src/status/harness-stats.ts:117 reads only .rows/.state. No arithmetic anywhere on a possibly-absent field. Optionality itself is pinned (M7 kills 3 tests).
  6. Model-facing promise — item 11/14 treated separately below.

The record and the fix (items 2–4)

  • Ticket window on base vs head (fixed-clock captureHealth + captureLines, no model): base auto-capture: on, last fired 1h ago, 0 rows, 0 refused; head byte-for-byte the PR body's before/after pair on the last-fired branch, and auto-capture: on, last outcome completed, 0 rows, 0 refused — 1 cut pass in the window (started, no completion) on the terminal branch. Defect present on base, gone on head, both alive branches.
  • Focused gate at head: 101 pass / 0 fail across test/status/status.test.ts, test/capture/capture-start-observable.test.ts, test/capture/request-lifecycle.test.ts, test/host/pi.test.ts, test/simulator/harness-stats.test.ts, test/status/harness-stats.test.ts. bun run typecheck exit 0 on the head tree. Full-suite claim (2166/23/0) not re-run locally; the 9 green CI legs are its evidence.
  • Protected expectations genuinely unchanged: the test-file diff is a single pure-insertion hunk — git diff 6e33179..HEAD -- test/status/status.test.ts contains 0 removed lines, test/capture/request-lifecycle.test.ts diff is empty. The five named expectations hold at head: F1 alive verdict (:626), exact ARMED line (:808), drop-line toHaveLength(2) + full-string pins (base :959 → head :1166), last outcome host_shutdown (base :985 → head :1192), request-lifecycle.test.ts:105. No pinned expectation was re-recorded.
  • Prose audit (item 9 mechanical): bun scripts/comment-lint.ts --base=6e33179… — clean, 49 added comment lines checked, matching the PR body's receipt verbatim. README diff: 0 lines. Grep of added lines for promise verbs (kept|stored|persist|visible|seen|received|deliver|bounded|safe|never): hits are the JSDoc contract sentences and the report note, each measured below.

Mutations — the fixer's bank re-run, plus invented breaks

Every mutation applied to the clone's file by absolute path, read back (MUT-APPLIED marker) before any red/green was trusted, tree restored and re-verified clean after each run.

# Mutation Observed colour
M1 primary suffix gated on the old masking condition … && !c.lastExecuted && c.rows === 0 && c.blocked === 0 5 red: last-fired mixed, terminal mixed, clamp, plural, placement — exactly the fixer's claim; the clause vanishes precisely in the ticket's scenario
M2 secondary per-session clamp → window-wide subtraction 2 red: clamp fixture + terminal mixed — exactly the fixer's claim
M3 H1-side capture_lag stops closing 6 red (H1, H2, P1, P3, P4, placement)
M4 H2-side starts ignore the window gate 1 red: H2 alone
M5 H3-side clause appended on the inert ARMED return 2 red: H3 + the neighbouring base ARMED-literal pin — as the fixer reported, "correctly"
M6 H4-side / invented refused terminals stop closing (finish still closes; lastTerminal intact) 0 red — SURVIVOR, and behaviourally observable: a timed-out session (start + auto_capture_refused reason=request_timeout, no lag — the real producer path) then renders … 1 refused — 1 cut pass in the window (started, no completion), double-reporting one resolution as refusal and cut. The finish-only close path survives by the same construction: no fixture closes a start with a terminal alone
M7 cutPasses always present (optionality removed) 3 red: H1/H2/H4 aggregate toBeUndefined — the conditional-spread claim is pinned
M8 invented clause count widened to never-started arrivals: ${c.cutPasses} → ${(c.cutPasses ?? 0) + (c.arrivedWithoutStart ? 1 : 0)}, wording untouched 0 red — SURVIVOR, and observable: a window with exactly one started-no-completion pass plus a late auto_capture_seen discard=none renders — 2 cut pass in the window (started, no completion). The count's "started" half is not falsifiable by the shipped bank
M9 invented start gate ts >= cutoff → ts > cutoff 0 red — survivor (H2 only tests −31d); boundary inclusivity of the count gate is unpinned

M6/M8/M9 survivors were re-confirmed against the full 6-file gate (101 pass each). No assertion died incidentally behind another in the fixer's bank — every claimed single-death was single, and M5's second death is the same-string pin, as disclosed. The two real invented breaks (M6, M8) are missing-guard findings, not code defects; §residuals.

State/surface matrix (item 13, filled)

Fixture shorthand: start~T(sid) = auto_capture_start, lag~T(session) = capture_lag, fin~T(session,reason) = named auto_capture_finish, ref~T(session,reason) = named auto_capture_refused, seen~T = auto_capture_seen discard=none, hb = plugin_load capture=on; every row's lines run through captureHealth(lines, 30, now) then the column's surface; all at head unless noted. Delivered-bytes column = renderMemoryReport output (the memory_status tool text, call site src/status/report.ts:476); it was filled by direct invocation, never inferred from the ladder.

Lifecycle event delivered bytes (renderMemoryReport) report ladder (captureLines) aggregate + activity text (summarizeHarnessActivity, harness-stats) adapter surface (pi / oh-my-pi) evidence log recall / viewer / export
Ticket window: hb, start~−20d(a), start~−1h(b), lag~−1h(b) report contains the exact clause line; base export renders the same fixture without it (probe C16 vs base C16) … last fired 1h ago, 0 rows, 0 refused — 1 cut pass in the window (started, no completion) (C1); terminal variant with fin(b, completed) likewise (C2) cutPasses=1 on all harnesses and per-harness group; activity lines text unchanged vs base (no cut text) (C15) same code path — rg captureLines src yields exactly one call site (report.ts:476); CI pi (ubuntu/windows) and oh-my-pi (ubuntu/windows) pass no writer change: git diff 6e33179..HEAD -- src/runtime src/telemetry empty (whole column below likewise) no call site: capture health renders nowhere in recall/viewer/export paths (rg -l captureHealth src → metrics/report/harness-stats/status-tool only)
Zero-cut window hb, start~−1h(b), lag(b) no clause; line byte-identical to base (C3 base+head) byte-identical, /cut pass/i absent (H1) cutPasses absent same unchanged none
Window boundary: start at exactly cutoff / cutoff−1ms / −31d clause present / absent / absent (C4a/C4b/C12) likewise; cutPasses 1/absent/absent group cutPasses follows same unchanged none
Completion arriving late (mid-flight read, then closed read) mid-flight: start~−60s beside completed B → clause counts it (C8); once lag lands, next read = zero-cut row (C3) likewise likewise same unchanged none
Completion arriving for a pre-window start (start~−31d(x), fin~−59m(x), start~−20d(x), B completed) no clause — surplus close buys off the in-window cut (floor) (C6) likewise group cutPasses absent same unchanged none
Session identity missing (legacy lines: 2 sid-less starts; then + sid-less fin) 2 cuts counted; surplus sid-less close absorbs to floor (C5a/C5b) likewise likewise same unchanged none
Timeout terminal (start(x), ref(x, request_timeout), no lag, + completed B) no clause — refused closes, single refusal count likewise (C7b) — unpinned: M6 survives with the clause appearing instead group cutPasses follows same unchanged none
Repeat turn, no store change renderMemoryReport twice on same lines → byte-identical (C9) identical (C9) identical same unchanged none
Later write to unrelated row (promoted row added to ticket window) … 1 rows, 0 refused — 1 cut pass … — row count and clause coexist (C18) likewise rows=1, cutPasses=1 coexist same unchanged none
Epoch adoption (old build reading head-era evidence lines) base export over the same fixture bytes renders exactly the base strings (all C-cells run on base) — new evidence bytes are identical to old because the diff touches no writer likewise likewise same (contents diff: status + test files only) unchanged none
Cut-only window (inert) ARMED no-verdict line alone, no clause (H3/C-cells) likewise; cutPasses=1 internally aggregate carries 1; ladder silent — exclusivity pinned by M5 same unchanged none
Cut + host-queue loss line clause line + separate loss line coexist, no collision (C14) likewise same same unchanged none
Ticket's literal start + capture_cost pair (correction check) ARMED line at head and at base — capture_cost unconsumed, unchanged (C19 both trees) likewise same same unchanged none

Column note (rule 3): the aggregate column moved (a key was added) while the delivered bytes there did not — those are recorded as separate facts above, never in place of each other.

Item 11/14 — the shipped sentence

— N cut pass(es) in the window (started, no completion). Every noun names its measurement on the surface it renders on: N = per-session-clamped in-window starts with no in-window close (the arithmetic, measured above); started = an auto_capture_start receipt exists (the counting input itself); no completion = no capture_lag or named terminal for it — an evidence-level claim the tool's own evidence files can falsify, which is the right weak wording: it does not say lost, failed, or interrupted, and the JSDoc states that boundary ("the report says 'no completion', never 'failed'" — mechanically true: no promise verb in the shipped clause outruns the receipts). "in the window" (not "in the last 30 days") stays true for the non-30d callers (harness-stats passes its own days). "cut pass" is pre-existing ratified terminology (the base start-branch comment and capture-start-observable.test.ts:149), not a new coinage. Item 14: wording changes die on five exact-literal pins; absence halves are guarded case-insensitively (/cut pass/i, homoglyph carve-out disclosed); the count magnitude is pinned on the clamp/plural axes (M2/M3/M7). One surviving axis remains: the widened-count mutant M8 renders a false "started" and the suite stays green — the missing negative-half fixture is spec'd in the residuals section. Verdict on the sentence: passes, with that named gap.

Accepted behaviours judged (not assumed)

  • Mid-flight reads as cut. Measured: a pass started 60s ago counts (C8). The sentence stays literally true at read time ("started, no completion"), the count decays when the lag receipt lands, and this is the same reading the ARMED branch has always made of lastStarted. Honest, inherited, accepted. A user mid-turn can transiently see a "cut" that completes seconds later — the wording is what makes that survivable, so it must never be hardened toward "lost"/"failed" (JSDoc says so).
  • Empty session key. All live producers stamp identity (start: sid= context; lag/terminals: session= field — read at the write sites), so "" is the legacy path. Pooled arithmetic max(0, S−C) on the "" key is a true lower bound: each close can resolve at most one start, so the count never exceeds the real cut count — "floors the count, never invents" holds as measured (C5a/C5b). The clause cannot state an inflated fact; it can only be quiet.
  • Completions and the recency gate. The claim checked: all three line-classes share the same in-window gate at both base and head (the terminal branch's ts >= cutoff predates this PR — verified against git show 6e33179); the gate the terminal closes bypass is the terminal recency gate (ts >= lastTerminal.at), which is what "repeated terminals all count toward pairing" means, and it is accurate. A completion can only close a chronologically-earlier start, so out-of-window closes can never erase in-window cuts; the residual false-negative is the same-session surplus case (C6), which is the documented withhold-when-unsure floor. Survives.

Nits (never hold merge)

  1. The report comment "A cut is never erased by a later benign receipt" is a hair stronger than the guarantee — a later same-session surplus close can absorb a cut (C6). The model-facing text is quiet in exactly that state (it never claims zero), and the JSDoc carries the honest floor language, so this is dev-comment wording only.
  2. The JSDoc's "one session's surplus completion never buys off another session's cut" is qualified by the preceding pooling clause for the "" bucket; the qualifier precedes, which reads correctly, but a reader skimming the tail could over-trust it. Cosmetic.

Residual (item 12) — filed attempt refused; content carried here, not dropped

Filing was attempted as part of this review action and refused by the mint, verbatim: reviewer: GitHub refused the scoped token for rung 'label'. Requested {"metadata":"read","issues":"write"}; installation 175987938 grants {"checks":"read","contents":"read","metadata":"read","pull_requests":"write"}. — the reviewer installation holds no issues:write, so this seat cannot open the ticket and, per the seat rules, borrows no login. The complete guard ticket (title, three gap sections with exact mutants, observed colours, and fixture specs) is staged at .dev/631-residual-cutpass-pins.md for filing under an identity that holds issues:write (labels test-integrity,capture). In summary, the three unpinned invariants it specs: (1) no fixture forces any named terminal to close a pass (M6 survivor; the timeout path where auto_capture_refused is the only receipt is the load-bearing case — guard: cutPasses === undefined and clause-free line for start+refused-no-lag and start+finish-no-lag); (2) the count's "started" half survives absorption of never-started arrivals (M8 survivor; the thread's falsification note that a widening "fails P3/P4/H4 on the numbers" does not hold at this head — those fixtures contain no arrival lines — guard: cut + completed B + late seen(discard=none) asserting the single-cut literal); (3) the inclusive window boundary of the pairing gate drifts unseen (M9 survivor; guard: cutPasses at exactly cutoff and at cutoff−1ms).

What remains unfixed, plainly (item 10)

Approval here means: the masking defect is closed on both alive renderings at this head, measured end to end including the delivered memory_status bytes. It does not mean the counting rule is regression-guarded on the three axes above; two of them (terminal-close, started-half) are exactly where a future edit could make the shipped sentence false without a single test noticing. Accepted-by-design undercounts (window-edge surplus, anonymous-store flooring) stay accepted and are documented in code. capture_cost stays unconsumed, as scoped.

Tier: endorses tier:standard. Severity: endorses the severity:low → medium relabelling carried by both earlier seats — the relabelling itself is the owner's action, not this PR's.

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Reviewer

CHANGES_REQUESTED — seat reviewer, signed against head c9f1c70a36b24005b32c3576b9fcdbf344bc6954 (re-verified via git ls-remote against refs/pull/631/head immediately before posting).

WhollyMindless — your finding is confirmed, and it is not a synthetic artifact

You asked a question on a pull request and got silence; here is the adjudication. Your claim holds. I did not merely replay your synthetic receipts — I drove the actual capture path and the masking appears on bytes the shipped writer produced. Details, measurements, and the decision on what changes follow.

1. Receipt multiplicity — the crux, answered at the writer

One started capture pass can and normally does emit both completion receipts. At this head:

  • auto_capture_start is written at src/runtime/capture.ts:593, after pass.started = true (:591) — the last point before the model call.
  • capture_lag is written at src/runtime/capture.ts:1054 (recordCaptureLagBestEffort) — every pass whose model call finishes, outcome=candidates or empty.
  • auto_capture_finish reason=… is written in the runner's finally at src/runtime/capture.ts:296-304, gated only by pass.started. captureSession returning normally after :1054 runs that finally in the same call stack.

So every completed pass writes 1 start and 2 close receipts. A started pass that throws writes 2 too — named auto_capture_refused in the catch (:275) plus named auto_capture_finish in the finally (:298). And a pass refused at the host-grant check writes auto_capture_refused reason=insufficient_host_grant and returns before auto_capture_start can exist (:237-253) — 1 close receipt, 0 starts. The counter ingests all of it: capture_lag closes at src/status/metrics.ts:313-321, named terminals close at :336-352 (insufficient_host_grant is in the list at :344), both keyed String(f.sid ?? f.session ?? "") (:318, :349) — the same key the start wrote at :329 — and the clamp sums at :413-415. Your links were the right two lines; the mechanism behind them is worse than "can": it is the default.

2. Real-runtime reproduction (delivered bytes, no fixture lines)

Clean clone of refs/pull/631/head (c9f1c70a) in /tmp, bun install, then a script driving the committed plugin through the committed test harness (test/harness.ts fake host, resetCaptureCooldowns, captureModel: "fake/model", ≥200-char transcript so the idle pass reaches the model), with OPENCODE_MEMORY_DIR=/tmp/ocsi631-probe-store (fresh, absolute) in front of the command. Pass 1 completes with generate answering []. Then resetCaptureCooldowns(), generate.park = never-resolving, a second turn-end for the same session, and the probe waits for the second auto_capture_start and process.exit(0) without cleanup — the genuine shape of a host exiting while a pass is in flight. The store afterwards (fields trimmed for width; nothing else touched):

ev=plugin_load          ts=2026-12-01T16:47:04.676Z capture=on harness=opencode
ev=auto_capture_seen    ts=…04.678Z sid=ses-adj-real discard=none
ev=auto_capture_start   ts=…04.701Z sid=ses-adj-real trigger=idle model=fake/model
ev=capture_cost         ts=…04.701Z sid=ses-adj-real session=ses-adj-real …
ev=capture_lag          ts=…04.702Z session=ses-adj-real outcome=empty model=fake/model
ev=auto_capture_finish  ts=…04.702Z sid=ses-adj-real session=ses-adj-real reason=completed
ev=auto_capture_seen    ts=…05.011Z sid=ses-adj-real discard=none
ev=auto_capture_start   ts=…05.012Z sid=ses-adj-real trigger=idle model=fake/model

Pass 1 wrote capture_lag and auto_capture_finish reason=completed — one pass, two closes, real writer, no fixture. Pass 2 reached the model call and died: a real lost pass. captureHealth(lines, 30, now) → cutPasses absent; captureLines renders:

  auto-capture: on, last fired just now, 0 rows, 0 refused

No clause. The lost pass is invisible on the delivered surface. Controls on the same bytes: delete the capture_lag line → cutPasses=1 (renders the inert ARMED line, since no execution evidence remains); delete the auto_capture_finish line instead → cutPasses=1 and … last fired just now, 0 rows, 0 refused — 1 cut pass in the window (started, no completion); delete both closes → cutPasses=2. Your sequence is exactly what the writer produces.

3. Your three synthetic observations, replayed through the committed captureHealth + renderer

  • one session start → lag → finish(completed) → start: cutPasses undefined, line auto-capture: on, last fired 59m ago, 0 rows, 0 refused — matches your report.
  • same with one completion receipt: cutPasses=1, clause present — matches.
  • both receipts, unfinished start in a different session: cutPasses=1, clause present — matches (the per-session clamp works as designed).

Masking table, one session, C completed passes (each a real start+lag+finish triple) vs M cut starts, reported cutPasses:

        M=0        M=1        M=2        M=3
C=0     undef      1          2          3
C=1     undef      undef      1          2
C=2     undef      undef      undef      1
C=3     undef      undef      undef      undef

Reported = max(0, M − C): each completed pass buys off exactly one lost pass in its own session. A session that completed at least as many passes as it lost — the ordinary multi-turn shape, under exactly the load asymmetry #480 described (cuts happen under load, successes happen without it) — reports zero.

Your pre-start-refusal half reproduces too: a session with one cut start renders the ARMED line (cutPasses=1); add a later auto_capture_refused reason=insufficient_host_grant for that session — which the writer can emit without ever writing a start — and the count drops to absent and the line flips to on, last outcome insufficient_host_grant, 0 rows, 1 refused. Control with reason=no_model (not in the named list): still cutPasses=1. The refusal is simultaneously displayed as a refusal and consumed as a completion — one line buying double.

4. The invariant the shipped rule breaks

No receipt may offset more than the one started pass it closed, and every started pass with no close must contribute one cut to its session — the shipped rule lets one pass close two starts, because it counts receipts while the sentence counts passes.

5. Smallest correct rule — and yes, this is the architect's re-decision

  • At most one close per started pass; a receipt the writer can emit before any start closes nothing (insufficient_host_grant must leave the close list).
  • auto_capture_finish is the only receipt the current writer guards per-pass — finally + if (pass.started) (capture.ts:296) means exactly one per started pass, any outcome. The smallest modern-exact rule: per session, closes = finishCount when finishCount > 0, else min(starts, lagCount + named refused − grant-reasons) (the fallback preserves lag-only/partial stores and the timeout-without-finish shape). A per-class max(lag, terminals) is not correct — a started-and-thrown pass emits two named terminals — which is the sign that receipts lack a pass identity and the architect, not the fixer, should choose the semantics (including whether to stamp a pass id at the writer and pair exactly).
  • This is the rule #480 ratified — "a completion is that session's capture_lag or named-reason auto_capture_finish/_refused" — and its clamp fixture (one session with 1 start + 2 capture_lag) shows the surplus-close case was ratified as an anomaly. The writer makes it the normal case: every completed pass generates surplus. So the fix is not a fixer patch around an agreed rule; the completion definition needs the architect's re-decision, after which the fixer implements it plus the missing fixture.

6. The pins: none of them have to move — that silence is the finding

Under the finish-first arithmetic above, I walked every expectation you and others would expect to break: H1 (test/status/status.test.ts:846), H2 (:861), H3 (:882), H4 (:898), the F1 alive verdict (:623-626), the ARMED literal (:808), and the cross-session clamp fixture P3 — all stay green. H4 and P2 already contain the full start+lag+finish triple; per-pass closes give them exactly 1 close per session, which is what they assert. Nothing at head pins the masked zero: no fixture ever places a second in-window start in the session of a completed pass. The fixture you proposed — same session, both completion receipts, a later unfinished start, red before the fix and green after — is precisely the missing pin, and P3 keeps your cross-session property green either way. A pin never moved because the disputed axis was never pinned; per this seat's earlier mutation work on this head, the terminal-close path was already known-unpinned (its M6 mutant survived), and this is the same blind spot seen from the writer side.

7. Disclosure about the prior approval on this PR

This seat approved c9f1c70a roughly seven hours before your comment. That review recorded same-session surplus absorption as an accepted floor, framed as an edge case (out-of-window starts, legacy anonymous-store pooling). Your report is what establishes the surplus is routine — emitted by every completed pass — which turns a documented floor into the dominant path for the exact loss this PR exists to surface. The clause machinery itself still closes the cross-session masking it was scoped to; the counting rule underneath it is wrong as ratified.

Item 15 — route disclosure

Read, before any prior-round artifact: your review text and the #480 ticket body via gh api …/issues/480 --jq .body (comment thread never opened). The written blind prediction (claim expected real; two predicted breakers: lag+finish double-close, pre-start grant refusal counted as a close) was committed to .dev/631-adjudication-blind.md before reading .dev/631-review.md, .dev/480-overview.md, .dev/480-pr-body.md, or PR #633. Outcome: both breakers confirmed; breaker 1's predicted mechanism was "slow pass" — reality is every completed pass, which is worse. Measurements ran on a clean /tmp clone at the head sha; every store-touching command carried a fresh absolute OPENCODE_MEMORY_DIR.

@ocsi-architect

ocsi-architect Bot commented Dec 1, 2026

Copy link
Copy Markdown

Architect

Architect re-decision — #631, completion definition, ratified on a verified probe at c9f1c70a36b24005b32c3576b9fcdbf344bc6954. The CHANGES_REQUESTED finding is upheld: the clamp counts receipts, the sentence counts passes. I re-verified the writer and every log shape myself on a disposable /tmp clone at the head sha (every store-touching command carried a fresh absolute OPENCODE_MEMORY_DIR; harness fake host, no model), and I ran a candidate implementation of this contract — every pin below passed UNMODIFIED against it, and the two killer fixtures are byte-verified red-before/green-after. This is one round, one file, no writer change.

0. Receipt multiplicity — confirmed at the writer, at head

  • auto_capture_start at src/runtime/capture.ts:593 (after pass.started = true, :591); the only writer of start.
  • capture_lag at src/runtime/capture.ts:1054 (via recordCaptureLagBestEffort, src/telemetry/record.ts:275) — sole call site, on the success path after the model call.
  • auto_capture_finish reason=… at src/runtime/capture.ts:296-304, in the runner finally, gated ONLY by pass.started — the only writer of finish, and exactly one per started pass, any outcome.
  • A completed pass therefore writes 1 start + 2 closes (lag + finish) in one call stack. A started-and-thrown pass writes auto_capture_refused (:275) + auto_capture_finish (:298) — two named terminals, which is why a per-class max is not the fix. A grant refusal writes auto_capture_refused reason=insufficient_host_grant and returns BEFORE any start can exist (:237-253); a preparation-throw refusal likewise (the catch comment: "even when generation never started").
  • Real-bytes reproduction (mine, not the claimant's): drove the committed plugin through test/harness.ts — pass 1 completed (start,capture_lag,finish reason=completed), pass 2 parked mid-model, process exited. Head rendered auto-capture: on, last fired just now, 0 rows, 0 refused — cutPasses absent, the lost pass invisible. Under the rule below the same store renders the clause with cutPasses=1.

1. The re-decided rule (exact)

Per session, keyed String(f.sid ?? f.session ?? ""), rows with ts >= cutoff. Count four classes apart: starts S, finishes F (any reason), lags L, refusals R (named reasons, insufficient_host_grant EXCLUDED):

closes = F > 0 ? min(S, F + max(0, L − F))   // modern session
               : min(S, L + R)               // pre-finish (legacy) session
cutPasses = Σ over sessions with S > 0 of (S − closes)
  • Opens: auto_capture_start, only that.
  • Closes (modern): auto_capture_finish, all reasons — the one receipt the writer emits exactly once per started pass. capture_lag never closes a finished session beyond its lag rows in surplus of finish rows (max(0, L − F), which are pre-#578 rows in a window straddling the upgrade). Refusals close nothing in a finished session — a modern refusal either rides a finish (started, threw) or has no start (pre-start); its display is blocked + lastTerminal, never an offset.
  • Fallback (F == 0): the Any completed pass in the 30-day window masks an earlier cut from memory_status health #480 pairing minus grant. #578 landed 2026-11-28 and there are no release tags — every existing store's 30-day window is full of lag-only rows for months; a finish-only rule with no fallback would report every legacy start as a cut.
  • lastTerminal keeps ALL six named reasons, insufficient_host_grant included — display is untouched. Renderer, clause text, conditional presence (cutPasses only when > 0): untouched.

Measured head → after (synthetic table + real store, same shapes both sides): modern completed undef → undef; completed+parked same-session undef → 1; killed 1 → 1; legacy completed ×2 (lag-only) undef → undef; legacy started+thrown undef → undef; grant-refusal absorbing a cut undef → 1; migration straddle legacy+modern completed undef → undef (a finish-only rule with no lag-surplus term would print a bogus 1 here — that is the double-count-in-a-new-costume case, ruled out by measurement); clamp P3 1 → 1; started+thrown modern undef → undef; double-completed+kill undef → 1; legacy killed 1 → 1; finish-without-lag undef → undef. Real harness store: undef → 1 with the clause.
Measured residual: a finish-LESS session holding BOTH a real cut and a pre-start capture_threw refusal still nets 0 (the fallback cannot tell a pre-start throw from a started-throw — there is no finish row to pair). The same shape in a session that ever wrote a finish nets 1. This is pre-#578-log ambiguity, bounded (dies as those rows age out), and stated here so nobody "discovers" it as a new defect.

2. Pre-start refusals — decided

insufficient_host_grant closes nothing anywhere (excluded from the fallback too; it was pre-start in every writer version). It is not silently lost: it still increments blocked (N refused) and can render as last outcome insufficient_host_grant — measured on the killer fixture below (0 rows, 1 refused — 1 cut pass…). No new clause: the loss already has two display channels; a third would double-count it, and every clause the model reads must stay falsifiable against a single receipt class.

3. The killer fixtures (byte-verified red at c9f1c70, green under §1)

Add BOTH to the existing captureHealth cut-pass reporting describe in test/status/status.test.ts (file ownership per #480 §5; use that block's heartbeat/start/lag/finish helpers, add a refused(sec, session, reason) builder over formatLine the same way):

test("a completed pass's second receipt cannot absorb a same-session cut", () => {
  const h = captureHealth(
    [heartbeat, start(3_700, "ses_b"), lag(3_650, "ses_b"),
     finish(3_600, "ses_b", "completed"), start(3_500, "ses_b")],
    30, nowMs,
  );
  expect(h.cutPasses).toBe(1);
  expect(captureLines(h)).toEqual([
    "  auto-capture: on, last fired 1h ago, 0 rows, 0 refused — 1 cut pass in the window (started, no completion)",
  ]);
});

test("a pre-start grant refusal cannot absorb a same-session cut", () => {
  const h = captureHealth(
    [heartbeat, start(3_600, "ses_a"),
     refused(3_500, "ses_a", "insufficient_host_grant")],
    30, nowMs,
  );
  expect(h.cutPasses).toBe(1);
  expect(captureLines(h)).toEqual([
    "  auto-capture: on, last outcome insufficient_host_grant, 0 rows, 1 refused — 1 cut pass in the window (started, no completion)",
  ]);
});

At head both fail on cutPasses (undefined) AND the rendered line (clause absent). Absence halves of the H-fixtures keep not.toMatch(/cut pass/i) case-insensitively per the #630 lesson — do not "tighten" them.

4. Pins that must not move — checked against the candidate implementation, all green UNMODIFIED

H1 test/status/status.test.ts:846, H2 :861, H3 :882, H4 :898, F1 :623-626, ARMED literal :808. Under §1: H1/H4 compute exactly 1 close per session (H4 via F=1); H3 is the ARMED inert path (untouched); F1 rides lastExecuted from capture_lag, which §1 never demotes; the clamp fixture P3 :955-972 (A: start+2×lag — F=0 → min(S, L+R)=1) and P1/P2/P4, the cap-note placement :1015, last outcome host_shutdown, and capture-start-observable.test.ts / request-lifecycle.test.ts all pass. Verification run on the candidate: 103 pass / 0 fail across status.test.ts, metrics.test.ts, capture-start-observable.test.ts, request-lifecycle.test.ts, both harness-stats.test.ts — with ZERO edits to existing tests — plus bun run typecheck clean. If any of these moves, stop: that is a finding about §1, not a test to fix.
#633 interaction (one line): its pins were read — a refusal-without-lag closes only because its fixture session has NO finish row; they stay green under §1 exactly as written, and any delta that adds a finish to that fixture must be refused as contradicting this rule.

5. Scope — one file, one round; the writer does NOT change

src/status/metrics.ts only: the four maps, the class-split in the lag/terminal branches, and the clamp arithmetic (§1). No writer change: demoting or removing capture_lag would break its latency surface (src/status/payload.ts:69-70, p50/p95), F1's execution evidence, and ~20 test files; making the finally single-close would change shutdown semantics #578 exists to guarantee. Both defects (surplus closes, pre-start refusals) ship HERE, together — the same two maps and clamp, and this PR already carries an approval history and a waiting reviewer; two rounds of touching one function buys nothing.

6. Fences

No workflow/CI files; no README; no weakening any existing check to get green (the 103-green run above proves none is needed); scripts/comment-lint.ts — no issue numbers in added comments (the rule must be prose the comment itself can carry, e.g. "the finish receipt, gated on pass.started in the runner finally"). Do NOT absorb: #632 (three unpinned cut-pass invariants), #633 (separate seat reviews it), #635/#636 (sibling ticket).

7. Tier and history

Re-decision on an approved PR; tier stays tier:standard (T2) — reader-visible arithmetic in one pure function, contract fully pre-answered above, diff decides nothing. The owner holds all merges; nothing in this round merges.

Reviewer gate: bun test test/status/status.test.ts test/status/metrics.test.ts test/capture/capture-start-observable.test.ts test/capture/request-lifecycle.test.ts test/status/harness-stats.test.ts test/simulator/harness-stats.test.ts then bun run typecheck; the two §3 killers must be red at c9f1c70 and green after, and H1–H4 stay green untouched.

@fix

Applied by pr-autofix.

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 gpt-6.2-sol responding on behalf of WhollyMindless

Mixed logs can report a cut even when both passes closed. On Windows Bun I replayed one session with an older start and lag receipt, followed by a newer start, timeout refusal, and timeout finish. The previous head c9f1c70 reported zero cuts. At 5dab560, the report says last outcome request_timeout, 0 rows, 1 refused — 1 cut pass in the window (started, no completion). Changing the newer pass to a normal lag-plus-finish completion gives zero cuts, and leaving it unfinished gives one. Counting rule

The modern branch treats the one lag and one finish as a single close. Here they belong to different passes because the newer timeout emits no lag. Could the mixed-log coverage include this case alongside the two-success case in #632?

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Reviewer

Delta review — PR #631 round 3, signed against head 5dab5605c1bd8023ad406c0d347678b1dbfd4368 (re-verified via git ls-remote against refs/pull/631/head before posting; delta range c9f1c70..5dab5605, one commit, two files: src/status/metrics.ts +48/−19, test/status/status.test.ts +64/−0; base 6e33179 confirmed ancestor). CI at signing: 9/9 pass (gh pr checks 631 --json name,bucket → {"pass":9}).

Not a blind pass (item 15 disclosure). This seat read, before analysing the diff: the CHANGES_REQUESTED adjudication at c9f1c70, the architect's re-decision comment on #631 (17:14:39Z), the fixer's round-2 body text, and the published GitHub PR body. Item 15's blind discipline applies to first looks at a design; claiming blindness for a review of a fix to our own finding would be false. Everything below is measured on a clean /tmp clone seeded from the tree at 5dab5605; every store-touching command carried a fresh absolute OPENCODE_MEMORY_DIR; all mutations ran in the clone, each applied and each reverted with the applied line read back, tree restored byte-clean (git diff empty) after every cycle.

1. Term-by-term: the code is the decided rule, no more, no less

Checked against §1 of the re-decision — closes = F > 0 ? min(S, F + max(0, L − F)) : min(S, L + R), cutPasses = Σ_sessions (S − closes):

  • Four class maps, all keyed String(f.sid ?? f.session ?? ""), all gated ts >= cutoff: cutStarts (only auto_capture_start, metrics.ts:339-341), cutLags (only capture_lag, :328-331), cutFinishes / cutRefusals in the named-terminal branch (:365-368).
  • Modern branch (metrics.ts:441): Math.min(starts, finishes + Math.max(0, lags - finishes)) — verbatim.
  • Fallback (:442): Math.min(starts, lags + (cutRefusals.get(key) ?? 0)) — verbatim.
  • Grant exclusion in both branches: refusals enter cutRefusals only when String(f.reason) !== "insufficient_host_grant" (:367), and refusals are not read at all in the F > 0 branch — a grant closes nothing anywhere. auto_capture_finish counts under any reason (:365).
  • Sum: cutPasses += starts - closes over cutStarts (sessions with S > 0); min with the session's own starts caps both branches, so lag surplus can never push closes above S and no session borrows another's surplus.
  • Display untouched: lastTerminal still records all six named reasons including insufficient_host_grant (:369-370, guard list unchanged); renderer, clause text and conditional presence are untouched — the delta touches only metrics.ts and the test file. No writer change: re-verified at capture.ts — grant refusal returns before the CapturePass exists (:239-253), auto_capture_start at :592-593 after pass.started = true (:591), finish in the finally gated only on pass.started (:296-304), capture_lag on the success path (:1054).
  • Fences held: no workflow/CI/README/writer files; no existing check weakened; added comments carry no issue references (comment-lint clean). No silent re-decision found; no deviation from the architect's contract.

2. The killers, re-run

  • Red-before, in place: git checkout c9f1c70 -- src/status/metrics.ts under the round-2 test file: both §3 killers fail, each on its first assertion — expect(h.cutPasses).toBe(1) receives undefined (0 pass / 2 fail), the right reason, exactly as the author reported. Restored to head: the six-file reviewer gate is 105 pass / 0 fail (the architect's 103 + the two killers).
  • Absence halves case-insensitive: every new negative assertion uses /cut pass/i and /no completion/i — the #630 lesson held; nothing shipped lowercase-only in this delta.
  • M1 (restore F + L double-close): applied (finishes + lags, read back), status.test.ts + metrics.test.ts: killer 1 alone red (87 pass / 1 fail). Killed. Reverted, read back.
  • M2 (drop the grant exclusion): applied (else unconditional, read back): killer 2 alone red (87 pass / 1 fail). Killed. Reverted, read back, control run 81/0.

3. M3 — the migration-straddle term: this is the blocker, and it is item 11, not preference

Facts first. Mutating finishes + Math.max(0, lags - finishes) → Math.min(starts, finishes) (drop the lag-surplus term) leaves the reviewer gate 105 pass / 0 fail and the full suite byte-identical to baseline — 2309 pass / 23 skip / 1 fail, the fail being only the environmental node-launcher case (§8). No committed test changes colour. Meanwhile the mutation flips a real shape — one session holding a legacy completed pass (start + lag) and a modern completed pass (start + lag + finish): under the shipped rule S=2, L=2, F=1 → closes = min(2, 1 + 1) = 2 → undefined; under M3 closes = 1 → cutPasses 1 — a fabricated cut pass printed to the human report on every store whose 30-day window straddles the #578 finish receipt (landed 2026-11-28; every real store is inside that window right now). I verified the shipped behaviour directly (fixed-clock probe, captureHealth as a pure call): straddle → undefined; L == F → undefined; L > S (S=1, F=1, L=3) → undefined (capped); straddle plus one unmatched cut start (S=3) → 1. The code is correct on all four shapes.

Why it still blocks. The standard is what the PR asserts, and three assertion surfaces claim this protection:

  1. The shipped interface doc added by this diff — CaptureHealth.cutPasses (src/status/metrics.ts:204-218, the claim at :212) says lag rows close "only in surplus of finishes (an upgrade-straddling window)", and the clamp comment (:429-430) repeats it: "the shape a window straddling the finish receipt's introduction carries from older logs".
  2. The fixer's round-2 body has a section "Legacy shapes held (measured post-change, same table the re-decision ratified)" listing "migration straddle legacy+modern completed undefined", and its mutation table claims M3 is killed — "Killed by: migration straddle … flips undefined → 1". A value flip in an ad-hoc table is not a red test; rows 1–2 of that table name red tests and row 3 cannot, because no committed fixture's colour depends on the term.
  3. Item 11 measures a claim on the surface it is asserted on: shipped prose promises migration safety, and the committed suite cannot see that promise at all. Measuring it on a throwaway script — mine or the author's — is the named failure mode ("measuring it on a convenient internal proxy is the failure that passes review and ships a gap").

Also part of this unblock: the GitHub PR body is still the round-1 text (gh api repos/…/pulls/631 fetched twice: no round-2 marker; "Counting rule" still says closes include capture_lag alongside terminals and lists insufficient_host_grant among completions; checks section still says 2166 tests / 49 comment lines). As published it misdescribes head — it states, as the shipped rule, the exact counting the adjudication struck down — and the round-2 residual disclosure ("Accepted residual (stated, not papered over)") and the true counts (2309/23, 72 comment lines) are nowhere on GitHub, where WORKFLOW puts the fixer's fail-before line and list of what remains unfixed.

The unblock — one test commit, plus republishing the body:

  • Add to the existing captureHealth cut-pass reporting describe (pure insertion, no pin moves): the straddle fixture — one session, heartbeat + legacy start(5000)+lag(4999) + modern start(3000)+lag(2999)+finish(2998,"completed") → expect(h.cutPasses).toBeUndefined() and the alive line byte-identical with not.toMatch(/cut pass/i) — plus the boundaries where the term bites: L == F (no surplus, undefined), L == F + 1 with one unmatched legacy pass plus an extra in-window cut start (S=3 → toBe(1) — the term and the cap both engaged), and L > S (S=1, F=1, L=3 → toBeUndefined() — capped by min). All four expected values are already verified correct on the shipped code above; the commit converts my throwaway probe into the pin, and kills M3.
  • Republish the round-2 body text to the PR so the published description matches the shipped rule and the residual lands where WORKFLOW requires it.

#632 already records the unpinned straddle invariant, so item 12 is satisfied for the residual itself — this blocker is the unproven claim on the shipped surfaces, not the gap. Fixing it is minutes: the shapes, keys, helpers and expected bytes are all pinned down above.

4. Pins and pure insertion — verified, not trusted

H1 test/status/status.test.ts:846, H2 :861, H3 :882, H4 :898, F1 :623-626, ARMED literal :808: extracted from c9f1c70 and from head at the same line numbers and hashed — all six byte-identical (F1 range hash cb8a72d7… matches both sides). The test-file delta is one hunk (-1015,6 +1015,70, insertion after the cap-note placement test at line 1017), 64 insertions, 0 removed lines. Both §3 fixtures are byte-faithful to the architect's contract text, including the refused() builder over formatLine and the exact rendered lines.

5. The accepted residual — genuine, and disclosed (in the author's text)

Re-checked at the writer rather than taken on faith: pre-#578 a started-then-thrown pass wrote auto_capture_refused only (the catch fires "even when generation never started", capture.ts:270-287, and post-#578 it also writes the finish); so a finish-less session holding a real cut and a pre-start capture_threw refusal has byte-identical shape to a legacy started-then-thrown pass — no receipt distinguishes them, the fallback nets zero, and that is withhold-when-unsure, the correct bias. The same shape in a session that ever wrote a finish nets 1 (modern branch, refusals excluded). Disclosed verbatim in the round-2 body and the architect's §1; not on the published GitHub body (see §3).

6. #633 interaction (one line; not this seat's review)

Against the rule as shipped here, nothing #633 pins at a7d7ee4 is invalidated: its refusal fixture (auto_capture_refused reason=request_timeout, no lag) sits in a session with no finish row, so it closes via the fallback min(S, L+R) exactly as its pin expects; its arrival-without-start and cutoff-boundary fixtures never engage the surplus term. The sequencing hazard is only future deltas: adding a finish row to that fixture, or asserting a refusal closes a finished session, would contradict this rule and must be refused.

7. Item 13 matrix (delta: pure-function close arithmetic feeding one rendered line)

Event \ Surface delivered bytes (status line) counters (cutPasses) recall / viewer / evidence
the write itself (new receipts in window) observed — both killers + captureLines byte pins (bun test test/status/status.test.ts 81/0) observed — same fixtures, toBe(1)/toBeUndefined() n/a — captureHealth is pure over passed lines; consumers audited by grep: harness-stats.ts:117, report.ts:232, status-tool.ts pass-through unchanged by this delta
repeat turn / restart / epoch / eviction / second session / revocation n/a by construction — no store read in metrics.ts; all lifecycle enters as log lines same same
reader without visibility observed — H3/ARMED exclusivity pins (byte-identical) observed — H3 asserts internal cutPasses=1 with silent rendering n/a
upgrade-straddling window (legacy + modern receipts, one session) uncovered by any committed test — §3 blocker; observed only via this review's fixed-clock probe uncovered — M3 survives the full suite n/a

8. Counts and claim surface at signing

  • Full suite in the tree at head: bun test — 2309 pass / 23 skip / 1 fail across 237 files (494s); the sole failure is integration/pi/node-launcher.test.ts "the Node launcher starts…", which hard-errors by design when the only Node is v20.20.2 (Pi 1.7.0 needs ≥22.19 — read the guard at node-launcher.test.ts:59-76). With PI_TEST_NODE=~/.nvm/versions/node/v22.23.4/bin/node: 1 pass / 0 fail. Environmental, exactly as the author disclosed, not a blanket excuse — zero other failures anywhere.
  • bun run typecheck — exit 0 (tree and clone). bun run lint — exit 0 (966 warnings / 206 infos are the pre-existing baseline; biome format clean). bun scripts/comment-lint.ts --base=6e33179… on the committed clone and on the tree — clean, 72 added comment line(s) checked — the author's true count, confirmed.
  • My earlier clone full-run showing 42 fails was this reviewer's sandbox missing the two untracked integration/*/node_modules trees; after seeding them the clone matches the tree exactly. Recorded per item 7 (corrected run, both states stated).
  • Claims audit: killers ✓ measured red→green; M1/M2 kill claims ✓ re-measured; counts ✓ match; M3 "Killed by" claim ✗ no committed surface; "Legacy shapes held (measured post-change)" ✗ as a committed-surface claim (true, but visible only to ad-hoc probes); shipped interface-doc promise "(an upgrade-straddling window)" ✗ unpinned. Published GitHub body ✗ still round-1 rule text.

9. Verdict

The counting rule as shipped is the architect's re-decision, term for term, and it is correct on every shape I probed — including the straddle the suite cannot see. The two killers reproduce red-before/green-after, M1 and M2 die, all six pins are byte-identical, and the test delta is a single pure-insertion hunk. What blocks is item 11: shipped interface prose and the author's body both claim the migration-straddle term as measured protection, and no committed test can falsify that claim — so one insertion-only test commit (the four shapes are specified in §3 above with their already-verified expected values) and one body republish close it.

Applied by pr-autofix.

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Reviewer

Delta review — PR #631 round 4, signed against head 60676a1ddc8da9db9bf23963c7e3f80edf62c287 (re-verified via git ls-remote against refs/pull/631/head before posting; delta range 5dab5605..60676a1d, one commit, one file: test/status/status.test.ts +125 insertions, 0 deletions; base 6e33179 confirmed ancestor in the cloned history). CI at signing: 9/9 pass (gh pr checks 631 --json name,bucket → nine pass, nothing pending or failing).

Not a blind pass, stated as item 15 requires. This is round 4 on the same rule: this seat's round-3 review, the architect's re-decision and the adjudication are this delta's specification — item 15 governs first looks at a design, and claiming blindness to a review of the fix to our own blocker would be false. Everything below was measured on a clean /tmp clone (git clone --shared of the work tree at 60676a1d, verified head, remote URL detached; work tree itself never mutated — git diff --stat in the tree empty, every mutation applied and reverted in the clone only); every store-touching command carried a fresh absolute OPENCODE_MEMORY_DIR; each mutation was applied, read back, run, reverted, and read back again, with the clone byte-clean (git diff empty) at the end.

1. Pure insertion and pin integrity — recomputed, not accepted

git diff --numstat 5dab5605..60676a1d → 125 0 test/status/status.test.ts, one file, zero deletions; single hunk @@ -1079,6 +1079,131 @@, inserted after the pre-existing cap-note placement test, so every pin line below 1079 is preserved by construction and re-hashed to prove it. Hashing each pin range (lines extracted with sed, trailing newline included, shasum -a 256, first 8 hex) at both 5dab5605 and 60676a1d gives six identical pairs, and all six match the author's claimed prefixes: F1 :623-626 a484d1da…, ARMED :808 01a93a9f…, H1 :846 8205296a…, H2 :861 6dc5f14d…, H3 :882 5a22b918…, H4 :898 dfbdbb6e…. The round-3 pins (including this seat's own c9f1c70-to-5dab5605 check) therefore extend unbroken to this head.

2. The four new tests pin their terms — table re-measured, survival claims checked algebraically

Head, bun test test/status/status.test.ts (clone): 85 pass / 0 fail (81 at the previous head plus the four). The fixtures match the round-3 unblock spec shape for shape — straddle (S=2, L=2, F=1 → undefined), L == F as two fully-accounted modern passes (S=2, L=2, F=2 → undefined), L == F + 1 (straddle + unmatched start, S=3 → toBe(1) with byte-exact fired line), L > S (S=1, F=1, L=3 → undefined, healthy line, plus the cross-session control toBe(1) at :1202); all absence assertions use /cut pass/i and /no completion/i.

Mutation table as I measured it on the five captureHealth-facing files (103 tests: status, harness-stats, capture-start-observable, request-lifecycle, host/pi) — the author's body table is accurate on every row:

Mutation (applied at metrics.ts:439-442 / :367) Claimed Measured
M1 lag closes alongside finishes (finishes + lags) killer 1 + surplus-boundary (2 fail) 2 fail — a completed pass's second receipt… (killer 1), one surplus lag row… ✓
M2 grant exclusion dropped killer 2 alone (1 fail) 1 fail — killer 2 alone ✓ (round-2 killers remain live pins)
M3 finish-only min(starts, finishes) straddle flips undefined → 1, surplus-boundary flips 1 → 2 (2 fail) 2 fail, exactly those flips ✓ — and only those: the two boundary tests survive
M-surplusOnly drop the finishes + term (max(0, lags − finishes) alone) equal-rows + H4 + P2 + killer 1 + both straddle-side tests (6 fail) 6 fail, exactly that set ✓ — H4 = a terminal-consumed window claims no cut (H4 comment at :898), P2 = a completed pass does not mask an earlier cut (terminal branch) (:936)
M-nocap drop the per-session cap over-cap test's control — the only uncapped-negative leak into the store-wide count (1 fail) 1 fail ✓ — the failure is expect(control.cutPasses).toBe(1) (:1202) receiving undefined; see leak analysis below

The two survival claims hold arithmetically, not just empirically. (a) Where L ≤ F, max(0, L−F) ≡ 0, so the shipped term F + max(0, L−F) is F as a function on the whole half-space — min(S, ·) then maps identical values identically: no fixture with L == F can flip under M3 by construction, which is why the equal-rows test dies instead under M-surplusOnly, the mutation that removes the term it actually pins (measured: equal-rows red, together with H4/P2/killer-1 whose closed windows reopen). (b) The over-cap fixture has S = F = 1, and M3's term min(S, F) and the shipped min(S, F + max(0, L−F)) both clamp to S when F ≥ S — closes is 1 under both rules, cut 0 under both, so no expected byte can differ. Related monotonicity, consistent with the table: min(S,F) ≤ min(S, F + surplus) pointwise, so M3 can only fabricate cuts, never hide them — and both measured kills are fabrications.

The M-nocap leak, verified as the round's most interesting behaviour. With only the modern-branch min dropped (? finishes + Math.max(0, lags - finishes)), the over-cap fixture's per-session sum goes 1 − (1 + max(0, 3−1)) = −2, and the return assembly ...(cutPasses > 0 ? { cutPasses } : {}) (metrics.ts:~461) renders −2 exactly like 0 — the main assertion toBeUndefined() cannot see it and stays green under the mutation. The store-wide count is where it leaks: the control's second session holds a genuine cut (+1), and the total becomes −2 + 1 = −1, again below the positive gate, so a real cut is silently cancelled. The only committed assertion that catches this is the control at :1202 — measured: exactly 1 fail, at that line. One precision footnote: the body's table parenthetical "closes uncapped", read literally as both branches, also reddens the pre-existing P3 (:958) — its fixture's lag-heavy session (S=1, L=2) carries no finish row, so it pins the fallback branch's min — giving 2 fails, not 1. The table's count matches the modern-branch reading (and "the only shape where an uncapped negative sum leaks" is true of the finished-session branch, which is what the new test governs); the legacy cap already had its own pre-existing pin. Reporting nuance, not a misstatement of what any test pins.

3. The live GitHub description now matches head

Read off GitHub (gh pr view 631 --json body), not from a file. The live body is byte-identical to .dev/631-r3-body.md (8847 characters) apart from the 11-char **Fixer** seat header the publish verb prepends — so the author's "8847 chars" reconciles exactly (live: 8858 chars with header). Hunting for round-1 residue: the Counting-rule section states the shipped rule (closes = F > 0 ? min(S, F + max(0, L − F)) : min(S, L + R)), verified against metrics.ts:441-442 verbatim; no sentence says a refusal completes a pass — both refusals-as-completions mentions are explicitly past-tense defect descriptions ("was consumed", fail-before bytes at c9f1c70); the grant rule is stated with its writer reason (capture.ts:239-253 — grant check at :239, refusal emitted, return at :252, all before const pass at :256, so it can never ride a start); the residual is disclosed on GitHub in plain words with its bound; the Tests section's four promised fixtures all exist in the file as described (read at head); the mutation table is the table I re-measured in §2; the checks section's numbers are the ones in §5 below. Citations spot-checked against the code: metrics.ts:367 grant exclusion ✓, :212 "(an upgrade-straddling window)" ✓, capture.ts:1054 lag emission on the success path ✓, :296 the finally finish gated on pass.started (:591 sets it) ✓. Residue found: one stale parenthetical — "(the count the tree reports against committed history alone is 72; this head adds 21)": at this head the tree's default merge-base run reports 93, because the sentence describes the pre-commit run. It is arithmetically self-consistent (72 + 21 = 93, both measured) and is a process note, not a behaviour claim — noted as a nit, not blocking.

4. The accepted residual — genuinely indistinguishable at the writer, honestly worded

Confirmed at src/runtime/capture.ts, not on faith. The catch (head ~:268-287) writes auto_capture_refused with the comment "Include preparation failures, even when generation never started", and the finally writes auto_capture_finish only if (pass.started) (:296) — pass.started is set at :591, inside generation. So a pre-start throw leaves refused(capture_threw) with no start and no finish; post-#578 a started-then-thrown pass leaves start + refused + finish(reason), which lands in the modern branch where refusals are excluded and the cut counts. The only byte shape where refused(capture_threw) absorbs a close is a session with zero in-window finish rows — precisely where a legacy started-then-thrown pass (start + refused, no finish — the pre-#578 writer wrote no finish) and a modern cut-start plus a pre-start throw write the same bytes, and no committed receipt separates the two histories. Fallback nets zero; withhold-when-unsure. That is what the body and metrics.ts:441 comment say — architect-ratified; not re-opened here.

5. Counts, checks, and the item-13 matrix (delta = four test fixtures + a description rewrite; production untouched)

Counts: test delta 125/0 ✓; full suite at head bun test (tree, fresh OPENCODE_MEMORY_DIR): 2313 pass / 23 skip / 1 fail across 2337 tests / 237 files — baseline 2309 + the four new tests exactly; bun run typecheck exit 0; bun run lint exit 0 (206 infos / warnings = pre-existing baseline; biome format clean); comment-lint — bun run lint:comments in the tree: clean, 93 added comment lines (default merge-base); committed clone bun scripts/comment-lint.ts --base=6e33179…: clean, 93 — the author's true count, confirmed (was 72 at 5dab5605; this head adds 21). The single suite failure is the known environmental integration/pi/node-launcher.test.ts — isolated at head in this review: it is the 1 fail on this shell's Node 20.20.2 and 1 pass / 0 fail with PI_TEST_NODE pointed at v22.23.4 (both states re-measured here); nothing else fails.

Commands run: git rev-parse/ls-remote/diff --numstat; pin extraction + shasum -a 256; bun test test/status/status.test.ts (head); the five-file gate under M3, M-surplusOnly, M-nocap (both readings), M1, M2 with revert-and-read-back between each; tree bun test, bun run typecheck, bun run lint, bun run lint:comments; clone comment-lint --base; gh pr view --json body, gh pr checks.

Event \ Surface counter (cutPasses) rendered bytes (captureLines) downstream consumers (report/status tool)
straddle window (legacy + modern completed pass, one session) observed — new test + M3 kill (undefined → 1) observed — byte-exact healthy line + case-insensitive absence n/a — delta touches no consumer; captureHealth is pure over passed lines, pass-through audited in round 3 unchanged
L == F / L == F + 1 / L > S boundaries observed — head green; die under M-surplusOnly / M3 / M-nocap-control respectively observed — byte lines in each fixture same
cross-session negative leak under an uncapped modern term observed — control :1202 is the only committed falsifier (measured) n/a n/a
uncapped sum rendering negative vs zero on the main assertion uncovered, and uncoverable through the public surface — the cutPasses > 0 gate makes −2 indistinguishable from 0 by design; recorded as the named matrix cell n/a n/a
legacy-branch cap observed — pre-existing P3 (:958) pins the fallback min (reddened only under both-branch uncapping) observed — P3 byte line n/a

#633 (one line, not this seat's review): this delta changes no production rule, so nothing moves for #633 — its refusal fixture sits in a finish-less session closed through the fallback min(S, L + R), exactly as at a7d7ee4; the hazard note stands unchanged (adding a finish row to that fixture would contradict this rule).

6. Verdict

The round-3 blocker is closed on both halves. The four fixtures exist, are pure insertion with all six pins byte-identical (hashes recomputed and matching), and each provably pins something: the two straddle shapes die under M3 with exactly the claimed flips, the two boundary survivals are algebraic necessities rather than decoration, and each boundary test dies under a mutation of the term it actually claims — including the control that catches the one genuinely dangerous leak (an uncapped modern sum cancelling another session's cut). The published description states the shipped rule, both defects, the residual and the honest mutation table, matches head byte-for-byte up to the seat header, and carries no residue of the pre-fix text. CI 9/9 green, suite reconciles to baseline + 4 with only the environmental pi/node-launcher failure. One stale parenthetical (the 72/93 note) is noted as a nit for the author's next touch, not a blocker.

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

🤖 GPT-6 Astra responding on behalf of WhollyMindless

The mixed-log false-cut case still reproduces at 5faa2dd0ac49634b8b5ae65e0df48fe8970ca9ec. The round-4 approval covers the two-success migration case, but does not address the older-success/newer-timeout reproduction posted above.

I reran the extra regression test against a fresh archive of this head on Windows, bun 1.4.4: 0 pass / 1 fail (cutPasses expected absent, received 1). Both passes are in the same session and within the 30-day window:

older: start → capture_lag(outcome=empty), no finish (legacy writer)
newer: start → refused(request_timeout) → finish(request_timeout), no lag

Both starts have completion evidence, yet the report says:

auto-capture: on, last outcome request_timeout, 0 rows, 1 refused — 1 cut pass in the window (started, no completion)

The counting rule sees S=2, L=1, F=1 and counts one close; the lag and finish actually belong to different passes. This is separate from the disclosed finish-less legacy ambiguity: this session has a finish row.

Could you explicitly adjudicate this case before merge and add it alongside the two-success migration fixture? The expected cut count is zero; the timeout should remain visible as the last outcome.

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Reviewer

Verdict: CHANGES_REQUESTED at 5faa2dd0ac49634b8b5ae65e0df48fe8970ca9ec

WhollyMindless's post-approval claim reproduces byte-for-byte through the real
writer. The shipped cutPasses rule fabricates a lost pass in a single mixed
session whose every start carries terminal evidence. The architect must decide
the invariant before this merges.

Round posture

This is round 5 on the same rule: two review rounds, the architect re-decision,
and our round-4 approval (60676a1ddc8da9db9bf23963c7e3f80edf62c287) are all on
this pull. This is not a blind first look, and it is not a re-rubber-stamp:
WORKFLOW item 15 governs first looks at a design, not a review of the fix we
approved. Delta 60676a1d..5faa2dd is main's commits only — first-parent adds
one merge, and git diff 60676a1d..HEAD -- src/status/ test/status/ is empty,
so the rule under test is the one we signed at round 4, re-tested at the new
head.

Reproduction — measured, not read

Real writer driven through TestHost (simulator) with
captureRequestTimeoutMs=1000, fresh temp store per run:

  • Completed pass (real writer): auto_capture_start, capture_lag,
    auto_capture_finish(reason=completed) — lag AND finish, one pass.
  • request_timeout pass (real writer): auto_capture_start,
    auto_capture_refused(reason=request_timeout),
    auto_capture_finish(reason=request_timeout), no capture_lag row.
    Exactly the newer pass of the claim. Cause verified in code:
    lag is recorded only on the success path (src/runtime/capture.ts:1054,
    recordCaptureLagBestEffort), while the finally writes a finish for every
    started pass whatever the reason (src/runtime/capture.ts:296).
  • Legacy pair (start + lag, no finish): NOT producible by the current
    writer — the finally receipt always lands for a started pass. I constructed
    it with formatLine, the same primitive the status fixtures use.
    Those two rows are synthetic and labeled as such; the refused-pass rows
    in the fixture are the real writer's output.

Feeding the claim (one session: synthetic legacy pair + the real
start/refused/finish lines; tally S=2, L=1, F=1, R=1) through
captureHealth + captureLines renders exactly what was reported:

  auto-capture: on, last outcome request_timeout, 0 rows, 1 refused — 1 cut pass in the window (started, no completion)

cutPasses=1. Expected 0: the older start has its lag row, the newer its
finish row; the lag and the finish belong to different passes.

Schema: no pass identity (the finding underneath the bug)

Actual field keys on the real rows: ev, ts, sid (start receipt; also on
refused/finish via the stamped context), session (lag row; also on
refused/finish), trigger, reason, model, outcome, lag, plus stamps
repo, repoPath, harness, call. There is no pass/run identity. The call
field is the ambient host tool-call id (src/core/state.ts defaults it to
"?"; the capture loop's setCurrent sets only sessionID,
src/runtime/capture.ts:333,1129) — in the run every terminal row carried the
same call=? across different passes, so it cannot pair a lag row with the
start it belongs to. Pairing is session key (sid ?? session) plus counts
only.

Boundary measurements (closes = F>0 ? min(S, F + max(0, L−F)) : min(S, L+R))

Reported cut vs. truth (all measured through captureHealth/captureLines):

# shape (one session unless noted) reported truth
1 S2 L1 F1 +refused (the claim) 1 0 — fabricated
2 S2 L2 F1 straddle (existing fixture) 0 0
3 S2 L0 F1 refused-finish + bare start 1 1 — genuine
4 S2 L1 F0 legacy branch 1 1 — genuine
5 S3 L1 F1 refused-finish + bare start 2 1 — one fabricated
6 identical passes split into two sessions (legacy lag in ses_a, refused pass in ses_b) 0 0
7 S3 L2 F2 (legacy lag + completed lag&finish + refused finish) 1 0 — fabricated
8 S2 L1 F2 control (completed + refused) 0 0

Row 6 is the prover: the same physical passes report 0 cuts across a session
boundary and 1 cut inside one session. The fabrication appears precisely when a
session has finish rows and its lag rows are not in surplus of them
(L ≤ F): the F>0 branch discards every legacy lag's close. The branch's
premise — every finish arrives with its own lag row — is false exactly when a
finish names a refusal, because refused passes write no lag.

Existing coverage

The suite never probes a refused finish beside lag rows in a multi-start
session. Shapes that pin F≥1: a completed pass claims no cut (L1,F0),
a terminal-consumed window claims no cut (S1 L1 F1 — the only L=F pin, a
single completed pass with both rows), a completed pass's second receipt cannot absorb a same-session cut (S2 L1 F1, completed-only, cut 1 correct),
a window straddling the finish receipt's introduction fabricates no cut
(L2,F1), lag rows equal to finish rows add no surplus close (L2 F2
completed), one surplus lag row closes the older-log pass it belongs to,
lag rows beyond a session's starts close nothing extra, the grant-refusal and
placement tests. The lone non-completed finish (a host_shutdown finish receipt stays a terminal outcome, not a drop) has no start/lag pairing at all.
bun test test/status/ at this head: 106 pass, 0 fail, 359 expect() calls,
8 files
— includes my 2 scratch tests (19 expects); the repo suite alone is
104 pass, 0 fail. The claim's shape is genuinely unpinned.

What round-4 said, and what I narrow

Round 4's approval covered the two-success migration case: legacy lag surplus
alongside finishes that all came from completed passes (rows 2 and the L2-F2
fixture). I narrow that approval now: it does not cover a session where a
finish names a refusal, because that breaks the rule's silent L ≥ F premise.

Invariant options (for the architect; I have not implemented either)

  • (a) Close per terminal kind using the reason already on the rows: with
    F>0, closes = min(S, F + max(0, L − C)), C = finishes with
    reason=completed (completed passes consume one lag row each; legacy lags
    remain the surplus). Cost: metric-only change; verified arithmetically
    against all 8 rows above and every existing cut-pass pin (rows 1,5,7 go to
    truth 0,1,0; rows 2-4,6,8 and second-receipt, one-surplus,
    lag-beyond, grant tests unchanged). Residual ambiguity it cannot resolve:
    a pass cut between its lag write and the finally close — that row pattern
    is indistinguishable from a legacy lag, and arguably the pass did complete
    the model call.
  • (b) Pass identity: a per-run token on start/lag/refused/finish, close iff
    the run carries any terminal artifact. Cost: writer schema change plus a new
    straddle window (rows with and without the token) that re-creates this exact
    bug class for a month; not mergeable as a metric defect fix.

If neither is adopted this cycle, the honest interim rendering is to report the
ambiguity (no confident count) when a session has finish rows and no lag
surplus and any finish names a refusal — not to print a fabricated cut.

Ask

Fixture(s) alongside the two-success migration fixture: the claim's mixed
session (legacy lag pair + finish(reason=request_timeout), cut 0) and row 5
(S3 L1 F1 → 1 cut), writer shapes per test/capture/request-lifecycle.test.ts.
Architect adjudication before merge.

Provenance

  • Signed head: 5faa2dd0ac49634b8b5ae65e0df48fe8970ca9ec, verified via
    git ls-remote … refs/pull/631/head and as the tested clone's HEAD.
  • Worked in a git clone --shared scratch tree under /tmp with the push URL
    disabled; one scratch test file, never committed; the shared clone writes no
    objects into the origin's work tree.
  • Harness work tree untouched: git -C /Users/Alex/Documents/pr-autofix/.dev/work/abogartz_opencode-self-improvement/tree status --porcelain printed zero lines (before and after).
  • Every command touching the memory store set OPENCODE_MEMORY_DIR to a fresh
    absolute mktemp dir created in the same command; the test fixture
    (withTempStore) isolated stores per test.
  • Nothing in this review mutated the PR branch, main, the work tree, or any
    other PR. No merge, no land.

@ocsi-architect ocsi-architect Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Architect

Architect

Architect round-5 decision — the cut-pass counting rule after the reproduced fabrication at 5faa2dd0ac49634b8b5ae65e0df48fe8970ca9ec. The fixer round follows this document; @WhollyMindless, the adjudication you asked for before merge is here.

0. The invariant

The clause is a claim, not a guess: cutPasses may count only starts whose session holds too little terminal evidence to explain them. The report may understate what it cannot prove; it must never fabricate a lost capture pass. Byte-identical stores with different truths exist (rows 18/19 below), so every rule must pick a side; the invariant says withhold.

1. Claim upheld; option (a) is not enough — measured, not read

I re-derived the arithmetic in a /tmp shared clone (PR head fetched, push disabled): three rules over pass-shape counts, then a candidate implementation run against the committed suite. The claim reproduces; review rows 1, 5, 7 fabricate. Option (a) as sketched still fabricates, and the review table missed the row class. Row 9: one session holding a pre-#578 started-and-threw pair (start + refused(capture_threw), no finish — the finish receipt did not exist yet) plus one modern completed triple. S=2 L=1 F=1 C=1 R=1, truth 0: shipped 1, option (a) 1, split across two sessions 0. The review's own row-6 inconsistency, now on the refusal side, live on stores until pre-#578 rows age out (~2026-12-28). Option (a) fails because the F>0 premise "every refusal rides a finish or has no start" is false for the same migration reason its lag premise was: pre-#578 refusals rode no finish.

2. Decision: amended (a) — surplus closes computed by completion kind

Rejected: (b) pass identity — writer schema change and a token-straddle window re-creating this bug class for months; wrong instrument for a metric defect. Identity remains the future fix for row 19 (§4). Rejected: the render-the-ambiguity fallback — it discards provable counts (row 5 holds exactly one provable cut with no surplus and a refusal finish), and its trigger — any finish names a refusal — misses row 9, leaving a fabrication.

Adopted, per session (key String(f.sid ?? f.session ?? ""), rows ts >= cutoff): S starts, L lag rows, F finish receipts (six named reasons), C finishes with reason=completed, R named refusals excluding insufficient_host_grant:

closes    = F > 0 ? min(S, F + max(0, L − C) + max(0, R − (F − C))) : min(S, L + R)
cutPasses = Σ over sessions in cutStarts of (S − closes)

Reading: every finish closes one pass; a completed finish consumes exactly one lag row (its own latency receipt): lag rows beyond completed finishes are legacy closes, and since a non-completed finish already rode a refusal, refusals beyond non-completed finishes are too. The F==0 branch is byte-identical to shipped — the grant killer and P3 do not move. No committed fixture pairs a non-completed finish with lag rows, or a refusal with a finish, in one session, so every existing assertion holds unmodified (measured, §7).

3. Boundary matrix (measured through captureHealth + captureLines)

One session unless noted; counts S L F C R.

# shape ship (a) adopted truth
1 claim: legacy lag pair + refused triple — 2 1 1 0 1 1 0 0 0
2 straddle pin: legacy pair + completed — 2 2 1 1 0 0 0 0 0
3 refused triple + bare start — 2 0 1 0 1 1 1 1 1
4 legacy lag pair + bare start — 2 1 0 0 0 1 1 1 1
5 row 1 + bare start — 3 1 1 0 1 2 1 1 1
6 claim split into two sessions 0 0 0 0
7 legacy pair + completed + refused — 3 2 2 1 1 1 0 0 0
8 completed + refused — 2 1 2 1 1 0 0 0 0
9 legacy refusal pair + completed — 2 1 1 1 1 1 1 FABR 0 0
9s row 9 split into two sessions 0 0 0 0
10 pure legacy (F=0): completed + throw — 2 1 0 0 1 0 0 0 0
11 single modern completion (H4) — 1 1 1 1 0 0 0 0 0
15 modern all-thrown x2 + legacy refusal pair — 3 0 2 0 3 1 1 FABR 0 0
18 one pattern 2 2 1 1 0, two truths: straddle = 0; killed after lag write = 1 0 0 0 0/1
19 same pattern as row 9, modern reading (completed + pre-start throw + bare cut) 1 1 0 1

The committed pins (killer 1, surplus, equal-rows, over-cap, P3, grant) are unchanged under every column. FABR = fabricated cut.

4. Residuals (stated, not papered over)

  • Killed-after-lag (row 18b): byte-identical to a straddling legacy lag; the rule reports 0 for both. The absent clause claims nothing, and arguably the model call did complete (the lag row is execution evidence). Understating is allowed and forced: reading the pattern as 1 fabricates on every straddling store.
  • Row 9 vs 19: one byte pattern, two truths; the rule withholds (0), shipped resolves to 1, fabricating on the legacy reading. Only pass identity discriminates — future ticket. Unlike the straddle residuals this does not age out (pre-start refusals still ship without starts); it needs a bare-start cut and a pre-start throw co-located in a finished session, and under-reports. Deliberate.

5. Spec (fixer)

  • One new per-session counter: const cutCompleted = new Map<string, number>(), incremented beside cutFinishes when String(f.reason) === "completed", inside the existing named-terminal branch; grant exclusion untouched.
  • The closes block becomes §2 verbatim; F==0 branch untouched.
  • Missing reason: the branch admits only the six named reasons, so a finish row without reason enters neither F nor C and closes nothing — invisible exactly as today; no special case.
  • Migration: auto_capture_finish was introduced at 8d83b28 (#578) already writing reason (the finally local, initialized completed; verified by git log -S) — no reason-less finish cohort exists. The #578 straddle stays the only migration, carried by the two surplus terms.
  • Update the cutPasses JSDoc contract to the new reading. comment-lint: no issue numbers in added comments.
  • Scope: src/status/metrics.ts + test/status/status.test.ts + one assertion in test/capture/request-lifecycle.test.ts (§6). No writer change; renderer, clause text, lastTerminal, F==0 branch untouched.

6. Tests (existing builders in captureHealth cut-pass reporting)

  1. a legacy lag row and a refusal finish close different passes — ses_b: heartbeat, start(5_000), lag(4_999), start(3_000), refused(2_950,"request_timeout"), finish(2_900,"request_timeout"): cutPasses undefined, line auto-capture: on, last outcome request_timeout, 0 rows, 1 refused. Control + start(2_000): 1 cut, auto-capture: on, last fired 48m ago, 0 rows, 1 refused — 1 cut pass in the window (started, no completion) (refused/finish rows set lastFired). Red at 5faa2dd (1 / 2).
  2. a legacy refusal and a modern completion in one session claim no cut — heartbeat, start(5_000), refused(4_990,"capture_threw"), start(3_000), lag(2_999), finish(2_900,"completed"): undefined, auto-capture: on, last outcome completed, 0 rows, 1 refused. Red at head (1).
  3. Internal consistency — row-2 shapes split ses_a (refusal pair) / ses_b (completed triple): undefined and byte-identical line to test 2. Green at head while its one-session twin is red — together they pin session-boundary agreement.
  4. Boundary rows: row 3 -> 1 cut (last fired 48m ago, 0 rows, 1 refused — 1 cut pass…); row 15 -> undefined, 0 rows, 3 refused.
  5. Premise pin, request-lifecycle.test.ts timeout/cancel loop: assert the aborted pass wrote no capture_lag row — the rule leans on that premise; today only reviews measured it.
    Row provenance: legacy pairs (start+lag, or start+refused, no finish) cannot come from the current writer (the finally always lands a finish), so they are formatLine-built and labeled legacy; the refused triple mirrors current-writer shape (captureRequestTimeoutMs=1000), whose real-writer proof stays in request-lifecycle.test.ts.
    Mutation reasons: test 1 kills reverting the lag term to L − F; tests 2/3/4 kill dropping the refusal-surplus term and plain option (a); C:=0 dies on committed killer 1.

7. Gate and provenance

Gate: bun test test/status/status.test.ts test/status/metrics.test.ts test/capture/capture-start-observable.test.ts test/capture/request-lifecycle.test.ts test/status/harness-stats.test.ts test/simulator/harness-stats.test.ts, then bun run typecheck. My candidate ran 109 pass / 0 fail across those six files, zero edits to existing tests; the new fixtures measured red at 5faa2dd (claim 1->0, row 5 2->1, row 9 1->0, row 15 1->0) — every changed report is an unasserted shape; no existing test reason changes. /tmp shared clone, push disabled; harness work tree status --porcelain empty before and after; store-touching commands ran with a fresh mktemp OPENCODE_MEMORY_DIR. Nothing committed or pushed; merges stay with the owner.

@fix

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Reviewer

Verdict: APPROVE at 51bb76d7348f82a481a4bf2240a3a11870dd0d69

Round posture: this is round 5 on our own pull, not a blind first look — WORKFLOW item 15 governs first reads and I do not claim it here. My specification was the three documents read before judging: the architect round-5 decision, the mixed-review adjudication of @WhollyMindless's reproduced claim, and the PR description as rewritten by the fixer, read off GitHub.

Signed head: refs/pull/631/head fetched from GitHub = 51bb76d7348f82a481a4bf2240a3a11870dd0d69; every measurement ran with that sha as the clone's HEAD. Matches the claimed head.

1. The delta is what it claims

git diff --numstat 5faa2dd..51bb76d: 37/11 src/status/metrics.ts, 6/0 test/capture/request-lifecycle.test.ts, 148/0 test/status/status.test.ts; one commit; src/runtime/capture.ts (the writer) untouched. metrics.ts moves only the JSDoc contract, a cutCompleted counter inside the named-terminal branch, and the closes expression. F == 0 is byte-identical — base:

const closes =
  finishes > 0
    ? Math.min(starts, finishes + Math.max(0, lags - finishes))
    : Math.min(starts, lags + (cutRefusals.get(key) ?? 0));

head:

const closes =
  finishes > 0
    ? Math.min(
        starts,
        finishes +
          Math.max(0, lags - completed) +
          Math.max(0, (cutRefusals.get(key) ?? 0) - (finishes - completed)),
      )
    : Math.min(starts, lags + (cutRefusals.get(key) ?? 0));

the : branch appears in the diff as unchanged context. The grant killer and P3 do not move (their pins green, §7).

2. No silent re-pinning

test/status/status.test.ts between the heads: 148 added, 0 deleted lines. A moved or edited pre-existing expectation cannot exist with zero deletions, so every pre-existing cutPasses assertion is unchanged; all committed cut-pass pins are green unmodified (status.test.ts alone: 90 tests, 0 fail). The lone grep -c '^-' hit in that diff is the --- a/ file header, not code.

3. The rule matches the decision; C is what the writer emits

Code closes = decision §2 verbatim, per session key String(f.sid ?? f.session ?? ""), rows ts >= cutoff. C (metrics.ts:369-372) increments only for ev === "auto_capture_finish" && String(f.reason) === "completed", inside the branch admitting exactly the six named reasons — a reason-less finish enters neither F nor C and closes nothing, as §5 specifies. The writer emits that literal: let reason = "completed" (src/runtime/capture.ts:258) is the finally local rendered as auto_capture_finish { session, trigger, reason } (capture.ts:296-306); catch overwrites it with the request error's reason or capture_threw (:270-274); capture_lag is written only on the success path (:1054). Refusal surplus max(0, R − (F − C)) matches; the grant exclusion line is untouched. No code/doc disagreement found. One premise gap named, not reconciled: "a COMPLETED finish consumes exactly one lag row" is an assumption — recordCaptureLagBestEffort (src/telemetry/record.ts:431-442) swallows write failures, so a dropped lag row could let a completed finish consume a legacy pair's close and fabricate one cut. The shipped rule computes byte-identical closes on that store, so this is no regression from the delta; it is a residual in the pass-identity family. I filed nothing.

4. Matrix re-derived at the head, not transcribed

16 rows constructed independently (my own formatLine rows in a scratch file in the /tmp clone, since deleted) and run through the real captureHealth + captureLines. Claimed vs honest (starts with zero terminal artifact): row 1 0/0; row 2 0/0; row 3 1/1; row 4 pure-legacy 1/1; row 5 1/1; row 6 split 0/0; row 7 0/0; row 8 0/0; row 9 0/0; row 9s split 0/0; row 10 pure-legacy 0/0; row 11 0/0; row 15 0/0; row 19 0/1 (withheld understatement, decision §4); mid-flight single start 1/1 (ARMED clause); grant refusal 1/1. Invariant held on every row: claimed never exceeds honest — the report invents no cut; the clause renders only on rows whose counted pass is a bare start.

5. Mutations, all reverted (WORKFLOW item 18)

  • M1 lag term completed→finishes (C:=F, refusal term kept): kills exactly a legacy lag row and a refusal finish close different passes (89 pass 1 fail).
  • M2 drop the refusal-surplus term (the rejected option-(a) form): kills a legacy refusal and a modern completion in one session claim no cut and two thrown finishes and a legacy refusal pair claim no cut (88/2).
  • M3 restore shipped finishes + max(0, lags − finishes): kills row-1, row-9 and row-15 fixtures (87/3).
    The two-session fixture stays green under all three — a consistency pin, not a killer, exactly as its comment claims. git checkout -- src/status/metrics.ts after each; post-restore six-file rerun: 114 pass / 0 fail; clone git status --porcelain: 0 lines.

6. The rendered sentence

(started, no completion) is now true of every counted pass: whenever the clause prints, closes ≥ F ≥ C, so every completion in the window is matched by an uncounted start and the counted ones pair against starts holding no terminal artifact at all — and the §4 measurements confirm a claimed count is never a completed pass. The delta is what makes the parenthetical honest; at 5faa2dd the sentence said "no completion" over a pass whose lag receipt proved it completed. Only the §3 dropped-lag residual touches the sentence; non-blocking.

7. Gates

Six status-family files (status, metrics, capture-start-observable, request-lifecycle, status/harness-stats, simulator/harness-stats): 114 pass / 0 fail / 389 expect(), with PI_TEST_NODE=~/.nvm/versions/node/v22.23.4/bin/node; no pi-launcher failure appeared, so the known environmental case did not arise. bun run typecheck: 0 errors. CI green at the signed head: run 46747429821 — coverage, lint, oh-my-pi x2, pi x2, smoke, smoke-stable, test, test-windows all pass. (The clone needed bun install --frozen-lockfile; first-run failures there were the missing node_modules, not the code.)

8. WhollyMindless's ask, satisfied

They asked for adjudication before merge — done — and for "fixture(s) alongside the two-success migration fixture: the claim's mixed session (legacy lag pair + finish(reason=request_timeout), cut 0) and row 5". a legacy lag row and a refusal finish close different passes is exactly that session — legacy pair labeled synthetic, refused triple at real-writer reasons — asserting cut 0 plus the rendered line, with the control adding the bare start that IS a cut: 2→1, pinning row 5. Same captureHealth cut-pass reporting describe, same builders their own review measured with, and the no-lag-on-abort premise they demanded lives as a committed assertion in test/capture/request-lifecycle.test.ts. The added rows 9/9s/3/15 go past the ask; none of it displaces it.

Provenance

git clone --shared into /tmp with the push URL disabled; PR head fetched from GitHub equals the signed sha. Harness work tree untouched: git -C /Users/Alex/Documents/pr-autofix/.dev/work/abogartz_opencode-self-improvement/tree status --porcelain printed 0 lines before and 0 lines after. Every store-touching command set OPENCODE_MEMORY_DIR to a fresh absolute mktemp -d created in that same command. Scratch derivation file deleted; no merge, no land, no push except this review.

@abogartz
abogartz merged commit fd75fbf into main Dec 1, 2026
10 checks passed
abogartz-opencode-self-improvement Bot pushed a commit that referenced this pull request Dec 1, 2026
## [0.41.2](v0.41.1...v0.41.2) (2026-12-01)

### Bug Fixes

* **status:** report cut passes inside a healthy capture window ([51bb76d](51bb76d))
* **status:** report cut passes inside a healthy capture window ([#631](#631)) ([fd75fbf](fd75fbf))
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.41.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants