Repository navigation
Description
What was measured
While stabilising the new e2e/capture.test.ts on #403, the same scenario was run under the CI-shaped command (bun test ./e2e/ --parallel=4 --timeout 240000) repeatedly on macOS, 2026-11-13:
| condition | runs | turn produced a capture pass |
|---|---|---|
./e2e/ at --parallel=4 |
8 | 6 |
e2e/capture.test.ts alone |
6 | 6 |
Two of eight loaded runs produced no capture pass at all.
The evidence signature
A run that works, and a run that does not, differ by everything after the tool result:
# working
ev=plugin_load …
ev=epoch_recompute …
ev=tool_result …
ev=capture_cost … trigger=idle prompt_chars=…
ev=gate_start … ev=write_promoted … ev=auto_capture_promoted …
ev=auto_capture_scan … ev=capture_lag … outcome=candidates
# failing, in full
ev=plugin_load …
ev=epoch_recompute …
ev=tool_result …
Nothing else. No capture_cost, no capture_lag, no blocked event, no refusal. The host turn completed and exited 0; the store got no row.
Why this is not the #404 teardown bug
#404 was a pass that started and was cut during cleanup — its signature is capture_cost present and no write_promoted. Here there is no capture_cost, so the pass never began: the turn-end event that capture subscribes to (TURN_END_EVENTS = ["session.execution.succeeded", "session.execution.interrupted"], src/capture/runtime.ts) did not reach the plugin before the process exited. The availability check, the write gate and the two-phase drain were never reached, so nothing in #403 or #404 is implicated.
Why it matters more than a flaky test
The failure is silent in the exact way this repo has been burned by before. There is no evidence line, so three different states are indistinguishable from the log:
- auto-capture is disabled,
- auto-capture is enabled and the pass ran and found nothing,
- auto-capture is enabled and the pass never fired.
A user who turns the feature on gets no memory from that turn and no signal that anything was missed. The README already says auto-capture is experimental partly for this reason — the feature shipped once with tests that passed while no live session ever fired a pass.
Where to look
- Whether the host awaits plugin event handlers for
session.execution.succeededbefore tearing down, or dispatches and exits. If it does not await, capture cannot rely on the turn-end event on a fast-exitingopencode run, and the guarantee has to come from somewhere else — disposal, or a flush point. e2e/support/harness.tsturn()returns when the child exits; the plugin's last chance is inside that window.- The deterministic half of the teardown contract already lives in
test/capture-dispose-drain.test.ts; this gap is the opposite case — no event at all, so nothing to drain.
What #403 does about it
Nothing, and it should not: #403 changes what a verdict does, not when a pass starts. What #403 now does is refuse to misreport it. turnUntilCaptureStarts() retries the real turn up to four times, asserts a pass started within those attempts (so a permanently dead capture still fails the test rather than passing vacuously), and prints the attempt count on every run:
[capture-start] test 2: pass started on attempt 1
[capture-start] test 2: pass started on attempt 2
That makes the file's claim the one it can support — a pass that started survives teardown and writes byte for byte — and leaves the start rate visible in CI logs instead of hidden behind a re-run.
Reproduction
bun test ./e2e/ --parallel=4 --timeout 240000
On an unloaded machine this passes. To force the condition, run the full ./e2e/ directory in parallel while another CPU-saturating job runs; the failure appears within a handful of runs. KEEP=1 leaves the guest directories behind so the evidence trail can be read directly.
Activity
test(e2e): stop reporting a missing trigger event as a teardown failu…
fix(capture): stop the cut verdict firing on healthy skips (#406 review)
fix(capture): rank capture verdicts by severity; never let the receip…
Merge pull request #474 from abogartz/fix/406-turn-end-delivery
chore(release): 0.33.8 [skip ci]
ocsi-architect commentedon Nov 25, 2026
Pre-arch review, posted by the orchestrator on the architecture seat's behalf. Measured
at
main@19ca5b3(base frozen at dispatch, rule 8; runner budget ~32 min, checkoutread-only).
Citation integrity, stated before the findings because this review got one thing
wrong in prose and nothing in data. The seat's first draft cited a tracker entry
"#526" (a ~1.2% hidden-rate measurement over 11 turns) at three points, and a "stale
sentence" about the disposal flush carrying a pid at two more. None resolve: no issue
or PR #526 exists, the string appears nowhere in the repo, and
git log -Sshows nopid sentence ever existed in any version of the evidence doc. Under audit the seat
withdrew all six sites and supplied the corrected wording used below (the substance
each site carried survives on measurements that do exist or on #406's own body), and
disclosed that a docs file it quoted had only reached its context compressed — it
asserted a sentence from text it never fully saw. Its first account attributed the
"#526" string to a recalled memory row; that account also failed verification: the
store contains no row with
#526dated before the seat's own session, and the onlyrow ever written containing it was the auto-captured echo of the seat's own draft.
Every measurement below was independently reproduced or cross-checked by the
orchestrator (silent dispatch-head
continues, the per-eventrefusedcatch with theabort-return inside it, the
metrics.ts:284genericauto_capture_*fall-through thatadvances
lastFired, the flush fieldsarmed/turn_end_events/passes/reason/subscribedwith no pid,
invalid_modelinsrc/index.ts:361, commit00339d3); no retractedreference appears in this posted version.
Host: opencode v2.3.0 (compiled 2026-11-13) macOS arm64, bun 1.4.3, 8 cores, ambient
load 3–33 logged per arm. All experiments ran against scratch copies
(
arch406/repo,arch406/repo-e1).REPRO
The current loss rate is zero across every attempt. Counts, honestly:
e2e/capture.test.tssolo (full file)attempt 1bun test ./e2e/ --parallel=4 --timeout 240000attempt 1captureModel:"no-slash-model"Statistics honestly: 0/75 under load excludes any rate ≥ ~3.9% at 95%; 0/206 overall
excludes any rate ≥ ~1.5%. A 1%-class rate remains not excluded by these zeros —
P(0/206 │ p=0.01) ≈ 0.13 — so zero is the finding, not a clean bill.
Which branch each measurement discriminates:
delivery-probe, samepattern as
e2e/support/probe-plugin) subscribed alongside capture andappendFileSync-ed every turn-end event. 14/14 receivedsession.execution.succeeded(idle and load-29), and 14/14 processes were stillalive 500 ms into cleanup (
cleanup_start→after50→after500all present).Bus-level non-delivery is not happening in the
opencode runshape on this hostbuild, corroborating fix(capture): make a lost turn-end pass observable (#406) #474 round-1's 10/10, and the host does await plugin cleanup
well beyond the drain's 1000 ms… at least past the probe's own 500 ms.
arm ran clean of any subscription (no
auto_capture_start, 0 capture lines) butthe store names it:
plugin_load … capture=invalid_model(
src/index.ts:365-376). And the console channel the ticket mourns does not existon the real host: the poisoned turn's stderr was empty — the plugin's
console.warnnever surfaces through
opencode run --standalone. The CI console line theorchestrator saw was the unit harness's captured console, not a user-visible
channel. Branch 3 is attributable from the store alone today;
plugin_loadis thearrival-side receipt this branch needed, and fix(capture): make a lost turn-end pass observable (#406) #474 shipped it.
still silent where reachable: the cooldown
continue(
src/capture/runtime.ts:1190) and thesid === undefinedcontinue(:1187)write nothing. I attempted to demonstrate the cooldown shape with two same-guest
turns seconds apart: it captured both times —
opencode runis a fresh processper turn, so the module-level
lastCaptureRunmap is always empty. Cooldown-shapedsilence is therefore long-lived-server-only (desktop/TUI), and the
run --standalonee2e shape is structurally blind to it. Theno_siddiscard isequally silent in every shape.
try/catch(:1199) writesauto_capture_refused reason=capture_threwwith themessage on any non-teardown throw. Zero
refusedlines in 206 turns. The two silentdeaths that remain are the
if (controller.signal.aborted) returninside that catch(
:1203) and the outer iterator-death catch (:1216-1218) — both belong to The capture loop's outer catch is silent: one statement above the inner try reintroduces permanent silent capture death #489'sfiled statement, not to this ticket's per-turn shape.
repo-e1): onerecordSyncBestEffort("auto_capture_seen", {trigger, sid, discard:none|no_sid|cooldown})immediately after
turnEndSeen++, before bothcontinuedecisions. 25/25 clean-config turns wrote the receipt, and the loss rate did not change (0/25) — the write
is synchronous file I/O (
recordSyncatsrc/telemetry/record.ts:205:mkdir+open+chmod+append, no lock, no sqlite) with no observable timing cost.
(spinners + driver + suite, load ≈29 — beyond the CI shape) reported
1 failin anon-capture e2e file — all three capture measurements in that same pass were
attempt 1. My grep filter dropped the failing test's name before it hit the log;that is an artifact of my collection, disclosed rather than hidden. It matches the
documented contention-flake family, not capture availability.
Caveat: for ~60 s during Phase 1 the unpatched scratch tree briefly carried the E1
patch (my patch script lacked a dry-run). Any
opencode runin that window loaded aplugin that wrote extra
auto_capture_seenlines and reorderedbindCapture;behavior is unchanged (additive sync write), all measurements in that batch were
attempt-1, and no classification depends on the line's absence.
Design space
The ticket asks to discriminate four branches. At
19ca5b3the store already namessix outcomes —
capture_lag(ran),auto_capture_skipped(deliberate skip),auto_capture_refused(skip/cut-over-throw with reason),auto_capture_start∧¬
capture_cost(cut AT the model call),plugin_load capture=off|switch_mismatch|invalid_model|no_capabilities(never armed),auto_capture_dispose(armed, disposed, no event seen). What remains unattributable,precisely:
auto_capture_dispose,which requires all of: cleanup called, store directory exists, the async append
flushed before exit, and
turnEndSeen===0 && passesStarted===0. Three of thosefour are themselves subject to the exit race.
no_siddiscard (:1187): silent, and arriving setsturnEndSeen=1,which suppresses the dispose line.
:1190): silent, same suppression; server-only shape(measured above).
auto_capture_start— during the awaitedsession.contextread (:501) orknownRowsFor(:581): no line at all;documented as silent by design in
test/capture/capture-start-observable.test.ts("NOT covered … that band stays silent like the original failure") and
src/capture/runtime.ts:637-646.:1203): silent by the abort check; The capture loop's outer catch is silent: one statement above the inner try reintroduces permanent silent capture death #489 territory.:1216): silent permanent death; The capture loop's outer catch is silent: one statement above the inner try reintroduces permanent silent capture death #489territory.
The discriminating measurements, with execution status:
store-readable classes —
¬seen ∧ dispose= delivery;¬seen ∧ ¬dispose= deliverywith the dispose write itself lost (needs the receipt to be sync at arrival, which it
is);
seen ∧ discard=cooldown|no_sid= branch 4 named;seen ∧ ¬start= the (d)band. One receipt, four classes.
capture instance, and cleanup-wait; distinguishes (a) from (b)/(c)/(d) in e2e without
touching production code.
opencode run): the only shape where (c) and any prior-instance module-state leakcan fire.
capture-unwritable-log,capture-start-observable): pins that a throw is per-turnand attributed via
refused, not permanent; the permanent variants are (e)/(f) =The capture loop's outer catch is silent: one statement above the inner try reintroduces permanent silent capture death #489.
Placement verdict
The one receipt:
auto_capture_seen,recordSyncBestEffort, in the dispatch loopdirectly after
turnEndSeen++(src/capture/runtime.ts:1185) and before the twocontinuedecisions, withdiscard:"none"|"no_sid"|"cooldown"as a field, sessionpassed so context resolves at call time (the write is synchronous and happens-before
any await, so it needs no frozen context and
bindCapturestays at:1194). It mustbe sync (the start-receipt comment at
:637-655documents exactly how much window anasync write yields) and it must be written before the discards so every delivered event
has written something before it can be silently skipped. With it, every future loss is
one of:
¬seen ∧ ¬dispose(delivery, with a named second-order case where evendispose lost),
seen ∧ discard=…(subscription state),seen ∧ ¬start(arrival-to-model band),
start ∧ ¬cost(model call). No further logging is needed for branchattribution — adding anything else is the "more logging everywhere" trap; every
other line is already attributable.
Required companions, or the receipt manufactures a new blindness:
src/status/metrics.ts— a rawauto_capture_seenline falls through to the genericauto_capture_*branch (:270) and advanceslastFired, making anarrived-but-always-cut capture read as "fired and alive". Like
startanddispose,it needs early handling; add
lastArrived, and a report arm "arrived but neverstarted" (one severity slot beside
cut > never-fired > inertinreport.ts:200-213).e2e/capture.test.ts—turnUntilCaptureStartsmust count a turn that wroteauto_capture_seenbut no pass as arrived-lost in its printed rate: today[capture-start] … attempt 2logs the success and not the loss it masked, which isthe hiding auto-capture: a delivered turn-end event can still vanish silently — four unattributable loss paths remain (current rate 0/206, ~1%-class not excluded) #406's own body asks against ("the start rate visible in CI logs instead
of hidden behind a re-run"). The failure message's claim "not reaching the plugin at
all" becomes verifiable rather than inferred.
docs/internals/auto-capture-evidence.md— a new table row for the receipt, so theinterpretation table names
auto_capture_seenalongsideauto_capture_startand thearrival-to-start band becomes a named state.
console.warnmay stay as unit-visible prose, but a note that the real host swallowsplugin console output keeps the next reader from assuming a user channel exists.
Alternatives
delivery-probeI ran, as acommitted e2e fixture): zero production change, measures bus delivery — but invisible
in users' stores and to the status surfaces, so it cannot attribute a production
loss. Adopt as complementary CI fixture; reject as the receipt.
long-term home of branch 1; out of this repo's control, and the plugin still needs
its own arrival line to attribute post-arrival bands. Filed-not-shipped here
(unexecuted by definition).
await appendFileat handler top): the 2.3.0 probe saysasync first writes flushed 12/12 — but sync yields zero event-loop windows, and the
margin this bug lives in is exactly event-loop timing. Rejected in favor of sync.
auto_capture_startearlier, before the context read: rejected — it wouldmisreport deliberate skips as cuts, the precise trade
00339d3paid to avoid. Theseenreceipt gets arrival attribution without unpinning that boundary.Rot mechanism
What let this bug survive invisibly, and what will do it again:
turnEndSeen===0 && passesStarted===0.Every future early-
continueadded to the dispatch body silently convertsattributable losses into invisible ones, and no test fails when you add one — the
two
continues already in there are untested for their silence. Theseenreceiptmakes the invariant local and checkable: an event that is delivered has written a
line before it can be skipped.
[capture-start] … attempt 2reads as a successline; the loss under it surfaces only if four fail in a row. auto-capture: a delivered turn-end event can still vanish silently — four unattributable loss paths remain (current rate 0/206, ~1%-class not excluded) #406's own body names
the requirement — the start rate must be visible in CI logs instead of hidden behind
a re-run — and the arrival receipt is what finally makes the hidden class countable
rather than merely retried.
plugin_load capture=onmeans armed, not delivered — the only healthy-readingstate name is written before any event could fail. Fine as a heartbeat, wrong as a
health guarantee;
lastArrivedis what closes that gap.capture-start-observable.test.tsistoday an accurate description of a silent band; left as-is, the next bug report files
it with a ready-made root cause. The comments here are high-quality; the risk is
prose outliving the code in both directions.
State-boundary map
lastCaptureRuncooldown Mapruntime.ts:135, module levelresetCaptureCooldowns(test preload)opencode runprocesses make it structurally invisible to the e2e (measured).turnEndSeen/passesStarted:285-286)controller(abort)captureSession's abort checks contain it) — extra work after abort, not a loss mechanism; keep it out of this fix's diff.setCurrent/bindSessionProvisionalbindCapturebefore first await; theseenreceipt adds no new global state and no frozen context (call-time resolution is safe inside the synchronous block).inFlight/passPhasesdroppedWritesrecord.ts, process memoryreport.tsalready says so — any new receipt inherits this limit.Standard
BLOCKS — and the ticket's premise needs re-scoping in the same breath, because
that is what the data says.
19ca5b3is zeroacross ~206 real-host turns including ~99 under canonical and injected contention,
but zero is not exclusion of a ~1% rate, and the silent code paths (b)/(c)/(d) plus
the async-only branch-1 receipt are present and verified by reading, so the
invisibility half of this bug is real at any rate, including zero.
seenreceipt at the named placement;metrics.tsearly-handling so it cannot advancelastFired; retry-loop ratehonesty — a turn that wrote
auto_capture_seenbut produced no pass must count asarrived-lost in the printed rate, not as a retried success; and a new evidence-doc
row for the receipt. An observability diff that adds the receipt but not the metrics
handling would make lost turns look found in
memory_status— the one outcome theticket forbids.
the canonical reproduction (0/75 canonical, 0/206 total, where the ticket's era gave
2/8). The demonstrable defect is attribution: three silent discards and a
suppression coupling in the plugin, a delivery branch whose only trace is a
cleanup-time async write, and a CI retry pattern that hides whatever rate remains.
With more budget, the discriminating measurement is exactly two: (1) ship the
seenreceipt and let ~100+ CI passes classify every future loss from the store alone —
measured unperturbing here (0/25 at load 33), and the only way to pin a rate this
session's zeros cannot; (2) a long-lived-server arm (
opencode serve, many turnsper process) — the sole shape where branch 4's cooldown and prior-instance paths can
actually fire, structurally unreachable from the
run --standaloneinstrument thatproduced every number in this ticket.
[-]auto-capture: the turn-end event can fail to reach the plugin under load, and the turn leaves no trace of it[/-][+]auto-capture: a delivered turn-end event can still vanish silently — four unattributable loss paths remain (current rate 0/206, ~1%-class not excluded)[/+]abogartz-opencode-self-improvement commentedon Nov 25, 2026
🎉 This issue has been resolved in version 0.35.0 🎉
The release is available on:
Your semantic-release bot 📦🚀