Repository navigation
fix(capture): fire on turn-end events; session.idle is never emitted (#136) - #142
Conversation
…136) Auto-capture has never run on any opencode 2.x host. The subscription waited for `event.type === "session.idle"`, and a live desktop service (2.1.4) never sends it: 150 s of its own SSE stream over a complete turn plus 80 s of quiet produced `session.execution.started` -> steps -> `session.usage.updated` -> `session.execution.succeeded`, and no `session.idle` or `session.status` at all. Zero `capture_lag` lines exist in the entire evidence history. `session.idle` IS declared by the protocol, which is why schema membership alone was never going to catch this — the authority has to be a recording of the host. So the trigger set is now `session.execution.succeeded` and `session.execution.interrupted`, both actually recorded (the latter by interrupting a running turn). Declared-but-unobserved names stay out: adding one later costs a line, and shipping them is how #136 happened. Also: - `plugin_load` heartbeat (#138): version, `capture=off|invalid_model| no_capabilities|on`, capabilities present, and the subscribed vocabulary, so "off", "misconfigured" and "armed but inert" are distinguishable from the evidence log instead of from an hour of archaeology. Guarded — a corrupt store must not turn plugin load into a throw. - `test/event-fidelity.test.ts` + `test/fixtures/host-events.jsonl` (#137): every capture trigger must appear in the manifest AND in the live recording. The recording assertion is the one that would have caught this two releases ago. Fixture holds event names and counts only — no payloads. - Capture tests no longer fabricate the invented envelope; they drive the recorded ones. Against pre-fix src these are red (9 failures); with the fix, 532 pass / 12 skip / 0 fail, tsc clean, lint at baseline. - `bench/live-capture-audit.ts` and `bench/live-capture-run.md`: the live dogfood harness, its rubric (locked before data), and the run's findings, including that relaunching the desktop app does not restart the service that holds the parsed plugin options. Co-Authored-By: Claude <[email protected]>
The pre-push hook runs with git's own environment exported. Tests that assert a temp dir is NOT a git repo, or that resolve repo scope from the working tree, then see this repository instead of nothing: `test/init.test.ts` goes from 6/6 green to 2 failures on `GIT_DIR` alone, and the repo-scoped capture and serve-host tests time out for the same reason. Every push under the hook looked like a broken build that was not — while the same command run by hand, or by CI, passed. Verified by re-running the full gate with GIT_DIR and GIT_WORK_TREE exported: 521 pass / 0 fail unit, 11 pass e2e. Co-Authored-By: Claude <[email protected]>
|
Formal verdict: CHANGES_REQUESTED (posted as comment — GitHub blocks formal change-requests on one's own PR; treat this as blocking until the ask below is addressed) Verdict: CHANGES_REQUESTED — the fix is verified and mergeable; two undeclared files must come off the branchReviewed head What I verified independently (all claims below were reproduced, not taken from this body)The bug is real and the trigger set is recorded, not guessed.
Gates reproduce.
Design checks that passed: fidelity test has anti-vacuity controls (parse counts >50/>10) and pins the bug in both directions (idle declared ∧ unobserved ∧ not subscribed); negative tests pin all three excluded events; heartbeat states match the real gating logic ( Blocking
Nits (non-blocking)
|
|
Fixes applied (1f4ac1b): dropped the two undeclared bench files (kept untracked in the author's working tree for the armed run); body red-check corrected 9→17 and lint claim made exact. Gates re-run on the final head: tsc clean, 521 pass / 12 skip / 0 fail. Merged. |
|
🎉 This PR is included in version 0.14.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
CI runs the PR merge commit, and main (0.14.10, abogartz#142) added an `ev=plugin_load` boot record: instance B's own line — a session-less write, legitimately stamped with B's repository under the very rule this round fixed — shares the day file with A's tool_result. Probe 2's whole-file `not.toContain` tripped on B's legitimate stamp; A's line itself was correctly unstamped on CI too. Scan the line carrying A's marker instead: the smoking-gun line is the one that must lose the foreign repo= field. Red at d56956e (A's own line carries B's stamp there), green at the fix; unrelated stamped lines cannot redden it.
CI runs the PR merge commit, and main (0.14.10, abogartz#142) added an `ev=plugin_load` boot record: instance B's own line — a session-less write, legitimately stamped with B's repository under the very rule this round fixed — shares the day file with A's tool_result. Probe 2's whole-file `not.toContain` tripped on B's legitimate stamp; A's line itself was correctly unstamped on CI too. Scan the line carrying A's marker instead: the smoking-gun line is the one that must lose the foreign repo= field. Red at d56956e (A's own line carries B's stamp there), green at the fix; unrelated stamped lines cannot redden it.
Closes #136. Partial #137, #138.
What was wrong
Auto-capture has never run on any opencode 2.x host. The subscription waited on
event.type === "session.idle"; a live desktop service never sends it. Zerocapture_lle/capture_lagand zeroauto_capture_*lines exist in the entire 10-day evidence history on the machine that developed the feature.session.idleis declared by the protocol and never emitted — see the correction on #136, which also explains why the obvious "use the schema-correct name" fix would have produced a second dead subscription (session.statusis not emitted either).What this does
session.execution.succeededandsession.execution.interrupted, both captured from a running host (the latter by interrupting a live turn). Declared-but-unobserved names (session.idle,session.status,session.execution.failed) are deliberately excluded, with the reasoning in a comment where someone will be tempted to add them back on faith.plugin_loadheartbeat (No artifact distinguishes capture off / misconfigured / inert: add plugin_load heartbeat and hook_error evidence #138): version,capture=off|invalid_model|no_capabilities|on, capabilities present, subscribed vocabulary. "Off", "misconfigured" and "armed but inert" are now one line apart in the evidence log instead of an hour of archaeology. Guarded, so a corrupt store cannot turn plugin load into a throw.test/event-fidelity.test.ts+test/fixtures/host-events.jsonl(Capture tests fabricate {type:"session.idle"} — the green suite pins a trigger the host has never sent #137): every capture trigger must appear in the manifest and in a recording of the live host. The recording assertion is the one that would have caught this two releases ago. Fixture holds event names and counts only — no payloads, no prompt content.{type:"session.idle"}, which is how 480 green tests pinned a trigger that does not exist.Evidence
src: 17 failures across the four touched suites — 12 capture, 3 compaction, 1 fidelity (import), 1 framing (the red-check).tsc --noEmitclean,biome lintwarnings only (+1noExplicitAnyfrom the heartbeat cast, matching the existing baseline style)./tmp/sse{2,3,4}.txton the dev box, summarised into the committed fixture.Not here
captureModelinheritance (event.modelis delivered to every hook and never read) — separate branch, it changes config semantics.capture_lagline). The plugin under test is the published npm build, so that check needs this merged and released.Second commit: the pre-push gate was lying (#141)
While pushing this, the hook failed a gate that passed by hand. Cause: git exports
its own environment to hooks, so
GIT_DIR/GIT_WORK_TREEpoint every test atthis repo.
test/init.test.tsmeasured 6/6 green → 2 failures onGIT_DIRalone; the repo-scoped capture test and a serve-host replay time out the same
way. The gate's verdict under a hook was not the verdict of the same code path —
which mostly trains you to reach for
SKIP_GATE=1.scripts/merge-gate.tsnow scrubs everyGIT_*variable before spawning anystep and logs the count. Re-run with
GIT_DIRandGIT_WORK_TREEexported:521 unit / 11 e2e / 0 fail.