Repository navigation
feat(capture): name every turn-end arrival with auto_capture_seen - #525
Conversation
…ceipt The idle dispatch loop counted delivered events in process memory only, so an event skipped for a missing session id or a cooldown, or lost between arrival and the start receipt, left no store trace. Every delivered event now writes auto_capture_seen synchronously before the loop's skips, with discard=none|no_sid|cooldown; metrics handles it ahead of the generic auto_capture_* fall-through so it never advances lastFired, tracks lastArrived, and reports an arrival that no start or skip accounts for. The status ranking gains one slot between cut and never-fired; stores with no arrival lines render unchanged. The e2e retry now prints the arrived-lost count it masks.
Review: PR #525 — combined seat (architecture conformance + code review)Disclosing up front: this seat performed both the architecture-conformance pass against the #406 review's Standard and the full code review. One reviewer, both hats. Verified at head ConformanceAll four required items ship, and both forbidden outcomes are held:
Forbidden: lost turn reading as FOUND — the seen branch Same-millisecond collision, constructed (not just read): built trails at head where New attacks(a) Old-store compatibility beyond the pinned strings. Hand-built seven pre-receipt-era synthetic trails (start/cost/skipped/dispose combinations, stale (b) Discard attribution at the parser. (c) Skip-bound mutant (the design call, not the code). Deleted the Mutant/design-callThe fixer's three-row mutant table was not re-run (orchestrator-verified); my independent contribution is the skip-bound mutant above plus the tie probes. One semantic limitation worth stating explicitly, since it shapes what the verdict means: ProseAdded-line scan over all 455 added lines: no shas, no incident narration in CIFrom VerdictAPPROVE — with three nits, none holding merge:
Nothing found contradicts the Standard: the receipt lands before every discard, cannot advance |
WhollyMindless
left a comment
There was a problem hiding this comment.
Note
🤖 GPT-6.2 Sol responding on behalf of WhollyMindless
The e2e arrived-lost count includes deliberate skips. In turnUntilCaptureStarts, the predicate counts any new auto_capture_seen line without a new auto_capture_start. I ran that predicate at 57acf32 against synthetic attempt receipts. It returns true for discard=cooldown, discard=no_sid, and discard=none followed by auto_capture_skipped reason=transcript_too_thin, as well as for a proceeding arrival without an outcome. Those first three cases can inflate the loss rate that #406 is trying to measure.
Could the retry report count only proceeding arrivals from the current attempt with neither a start nor a skip? A fixture pairing an intentional skip with a genuine arrival-to-start loss would exercise the distinction. The production status parser already distinguishes these cases in its trailing-arrival window.
There was a problem hiding this comment.
Review: PR #525 — combined seat (architecture conformance + code review)
Disclosing up front: this seat performed both the architecture-conformance pass against the #406 review's Standard and the full code review. One reviewer, both hats.
Verified at head 57acf32 against base 19ca5b3 in scratch copies (git archive, checkout untouched). Claims below were measured, not read.
Conformance
All four required items ship, and both forbidden outcomes are held:
- Receipt before the discards —
src/capture/runtime.ts:1186-1216: onerecordSyncBestEffort("auto_capture_seen", …)directly afterturnEndSeen++, withno_sidwritten inside the undefined-sid branch before itscontinue,cooldownbefore the cooldowncontinue,noneon the proceed path beforenewPhase(). All three synchronous, session passed as the context argument on the two sid-carrying writes,auto_capture_startunmoved. - Metrics early handling — the
auto_capture_seenbranch atsrc/status/metrics.ts:286continues before the genericauto_capture_gate at:303, so the receipt can never reach thelastFiredadvance at:323. Onlydiscard=nonesetslastArrived; a seen line with nodiscardfield claims nothing (pinned behavior:String(f.discard ?? "") === "none"). - e2e rate honesty —
turnUntilCaptureStartsclassifies each failed attempt (receipt count grew, start count did not) and the count rides back on the result, so it is printed on eventual success, not only on failure. Test-1's "not reaching the plugin at all" is conditional onarrivedLost === 0. - Doc row — new bullet in
docs/internals/auto-capture-evidence.mdnamesauto_capture_seenalongside the start receipt, and the prior bullet's "stays silent" claim is corrected to "names the band without moving the start line."
Forbidden: lost turn reading as FOUND — the seen branch continue is the structural guarantee; the pinned test asserts lastFired stays null for a seen-only trail. Forbidden: new logging — the only added recordSync* calls in the whole diff are the three receipt writes; the three console.log additions are the e2e rate lines, replacing (not adding to) the existing print.
Same-millisecond collision, constructed (not just read): built trails at head where seen(discard=none) and start share one timestamp → arrivedWithoutStart=false, verdict renders the pre-existing cut arm, no ARMED-BUT-NEVER-STARTED. Same-ts with auto_capture_skipped instead of start → no verdict, inert rendering preserved, in both line orders. Stepping the arrival +1 ms past the start restores arrivedWithoutStart=true (cut still outranks, correctly — a start exists). The strict > is the whole tie policy and it withholds, never invents. Nit: this behavior is implemented but not pinned — no test in the diff uses a same-ts pair (all fixtures use at(6)/at(5)). A follow-up pin would be cheap; its absence doesn't hold merge since the review bar was behavior, verified here.
New attacks
(a) Old-store compatibility beyond the pinned strings. Hand-built seven pre-receipt-era synthetic trails (start/cost/skipped/dispose combinations, stale plugin_load capture=on, plus an empty store), ran the actual captureHealth + captureLines at base and at head with a frozen clock, and diffed: byte-identical output, both verdict lines and every pre-existing field. A missing receipt claims nothing — including the interesting case where a plugin_load capture=on heartbeat coexists with a cut line.
(b) Discard attribution at the parser. seen(discard=cooldown) newer than everything: no lastArrived, no arm — the arm only ever rides a discard=none line. Cooldown/no_sid-only trail: lastArrived stays null, rendering identical to pre-PR. The converse also checked and is correct: a cooldown receipt newer than an unproven none arrival does not dismiss it (cooldown writes no auto_capture_skipped, so there is nothing for the bound to ride, and the verdict still fires) — a deliberate later skip does not excuse an earlier unaccounted arrival.
(c) Skip-bound mutant (the design call, not the code). Deleted the lastSkipped term (lastOutcome = lastStarted ?? "") on a third scratch copy and ran the full test/capture + test/status directories: 433 pass / 2 fail — exactly the healthy-skip pin flipping to ARMED-BUT-NEVER-STARTED and the "start or skip newer accounts for it" pin, nothing else in 29 files. The bound is genuinely required for the live thin-transcript trail (seen=none, then skip inside the pass). Correction to the PR's Proof paragraph: it says "without it the pre-existing skip test goes red" — no pre-existing test goes red; the two reds are pins added in this PR. Pre-existing tests cannot depend on arrivedWithoutStart because they carry no seen lines. The design call stands; the sentence overstates its evidence. One-line fix in the Proof text, not in code.
Mutant/design-call
The fixer's three-row mutant table was not re-run (orchestrator-verified); my independent contribution is the skip-bound mutant above plus the tie probes. One semantic limitation worth stating explicitly, since it shapes what the verdict means: arrivedWithoutStart compares lastArrived to the window-max start and skip, so it detects a trailing unaccounted arrival — an earlier lost arrival followed by any later start or skip is withheld. That is the same conservative direction the review mandates (withhold, never invent), and it is the correct bias for a status surface, but the docs bullet's "no later auto_capture_skipped" reads per-arrival while the implementation is per-window. Also, like the cut arm above it, an arrival-loss inside a window that also holds a completion is reported alive — the already-stated masking limitation, now inherited by the new arm. Neither is a blocker; both are wording-level.
Prose
Added-line scan over all 455 added lines: no shas, no incident narration in src/, test/ or verdict strings. The only #406/date hits are the docs/internals bullet, which is that file's pre-existing measured-evidence style (allowed). The one "October 2026" is mined-transcript fixture content inside thickMessages(). status.test.ts diff has zero removed lines, confirmed; the e2e removed lines are function-internal, and the one pre-existing assertion whose failure message changed is disclosed in the PR body. README untouched.
CI
From gh, all four checks completed/success at head 57acf32: lint (9s), test (48s), test-windows (3m30s), smoke (1m7s). The e2e suite runs inside the smoke job (bun run test:e2e = bun test ./e2e/), so the modified turnUntilCaptureStarts and its new classification ran green on CI at this head; there is no separate e2e job.
Verdict
APPROVE — with three nits, none holding merge:
- Fix the Proof sentence "the pre-existing skip test goes red": the reds under the mutant are this PR's own two pins (measured: 433/2 across
test/capture+test/status). - Pin the same-millisecond tie in a test — implemented, verified here by construction, unpinned in the suite.
- Optional: one clause in the docs bullet or the
arrivedWithoutStartdocstring stating the trailing-arrival (window-max) scope, so a future reader does not read per-arrival semantics into it.
Nothing found contradicts the Standard: the receipt lands before every discard, cannot advance lastFired, withholds at ties, keeps old stores byte-identical, exposes what the e2e retry masked even on eventual success, and adds exactly one line to the store.
The per-attempt classifier counted any new auto_capture_seen with no new auto_capture_start, so discard=cooldown, discard=no_sid and a deliberate auto_capture_skipped all inflated the printed rate alongside the genuine arrival-to-start loss. Extract the rule as a pure predicate mirroring the status parser — only discard=none owes a pass, and a skip settles its arrival — and pin the four shapes plus a paired skip-plus-loss trail deterministically, no host.
|
Confirmed and fixed — Your reading reproduced exactly: a synthetic replay of the four attempt shapes showed The classifier is now a pure predicate in Mutants move as intended: deleting the skip-exclusion reddens the paired pin + skip Side note from this head's CI run: tests 1–2 hit natural attempt-2 retries with |
|
🎉 This PR is included in version 0.35.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Closes #406. The architecture review (posted on the issue) measured the current loss
rate at zero across ~206 real-host turns — the ticket-era 2-of-8 is falsified,
though a ~1%-class rate is not excluded (P(0/206 │ p=0.01) ≈ 0.13). What remains real
is the ticket's other half: a delivered turn-end event could still vanish without a
store trace, through the
no_sidskip, the cooldown skip, the arrival-to-start band,and a dispose-flush that suppresses itself whenever any event arrived. This PR ships
the one arrival receipt that makes every future loss attributable, plus the companions
that keep it from lying.
The receipt
Three synchronous
recordSyncBestEffort("auto_capture_seen", …)writes in the idledispatch loop (
src/capture/runtime.ts), each before the branch decision it names:discard:"no_sid"inside the undefined-sid branch before itscontinue,discard:"cooldown"inside the cooldown branch before itscontinue,discard:"none"on the proceed path beforenewPhase()/bindCapture. One line perdelivered event, no new
awaitbeforebindCapture;auto_capture_startstays exactlywhere the earlier severity trade pinned it — arrival attribution without unpinning the
start boundary.
The guard that keeps it honest
src/status/metrics.tshandlesauto_capture_seenin a dedicated branch before thegeneric
auto_capture_*fall-through (verified: seen-branchcontinueat :300, genericgate at :302,
lastFiredadvance at :323 — the receipt can never reach it). Onlydiscard=nonesets the newlastArrived;arrivedWithoutStartwithholds its verdictwhen a deliberate
auto_capture_skippedis newer than the arrival, and when timestampscollide in the same millisecond (withholds, never invents).
src/status/report.tsaddsone severity slot between cut and never-fired —
ARMED BUT NEVER STARTED— with theexisting arms byte-identical, and a store containing no seen lines renders the
pre-existing verdicts verbatim (pinned by exact strings).
Rate honesty in e2e
turnUntilCaptureStartsnow classifies every failed attempt: a seen receipt with nostart counts arrived-lost, and the printed rate always carries the number — a retry
success no longer erases the loss it masked (#406's own body asks for exactly this).
Test-1's failure claim "not reaching the plugin at all" is conditional on
arrivedLost === 0: verifiable, not inferred.Proof
Mutant table (each write deleted, restore verified byte-identical):
no_sidwritecooldownwritenonewriteVerifications: typecheck clean; lint +
format:checkclean; comment-lint vs base clean(102 added comment lines); full suite 1808 pass / 22 skip / 0 fail; dispose-drain
×5 and capture-start-observable ×5 each 0 fail; e2e solo, alternating base/head ×3:
attempt-1 starts 9/9 base and 9/9 head, arrived-lost 0 at head in all runs — no new
loss class. Scope: 8 files,
src/confined to runtime/metrics/report; bench fixtureand README untouched; no pre-existing assertion edited (the one
capture-start-observablechange is a header comment whose "stays silent" claim became false; the
status.test.tsdiff has zero removed lines).
A design note the tests pin: bounding
arrivedWithoutStartby the newest skip'stimestamp is what keeps the healthy thin-transcript-skip trail rendering the old inert
verdict instead of a false ARMED-BUT-NEVER-STARTED — without it the pre-existing skip
test goes red, so the bound is requirement-shaped, not defensive decoration.