Repository navigation
Conversation
…n fire
Auto-capture has never fired on a live host, and nothing said why. A live
probe against opencode 2.2.5 (long-lived server, autoCapture on) shows the
trigger arrives and resolves: session.execution.succeeded is delivered flat,
captureSessionID finds data.sessionID, writeTarget is ok. Then
session.context() returns messages whose role lives under `type` and whose
parts live under `content[]`:
{id, time, type:"user", text, files}
{id, time, type:"assistant", agent, model, content:[{type:"reasoning"|"tool"|"text", ...}], ...}
{id, time, type:"idle", outcome}
flattenTranscript read only info.role | role and parts[].text, so every
message failed the `if (!role || !text.trim()) continue` test and the
transcript rendered as "". The 200-character floor then returned without
recording anything, which made a dead feature indistinguishable from a
session with nothing worth remembering.
- transcript.ts: accept the role under `type` (restricted to user/assistant,
since 2.2.5 also interleaves a non-conversation `idle` record) and read
parts from `content[]` when `parts` is absent. Reasoning stays excluded;
tool parts still contribute nothing, so the transcript keeps its size.
- runtime.ts: record `auto_capture_skipped reason=transcript_too_thin
chars=N` on that return. The silence is the bug that hid the bug.
- test/fixtures/host-session-context-2.2.5.json: the real recorded context,
plus unit tests for the shape and for the new evidence line.
Verified live with the same probe: transcript 613 chars, capture model
called, `ev=auto_capture_promoted`, and a tags=auto-capture row in the store
25 s after the turn ended.
The same silence that hid the shape break has one more instance: the turn-end handler caught every error from captureSession and recorded nothing, so a capture that died mid-model-call looked identical to one that never ran. Record `auto_capture_refused reason=capture_threw error=...` (redacted, capped at 200 chars) on that path. The session still sees nothing — fail-closed is the right contract for the host — but the store now does. Adds a `throws` failure seam to the test harness's generate stub.
WhollyMindless
left a comment
There was a problem hiding this comment.
Reviewed head 694a6c5c5ae4a2f3bd3a9c41d39674775939e916 locally on native Windows / Bun 1.4.4. The five focused capture, crop/privacy and emitter-attribution suites pass: 75 tests, 352 assertions; typecheck passes. The new fixture reaches generation and excludes its reasoning text. I did not repeat the live-host model probe reported in the PR body.
F1 (P2) — Preserve the operation's attribution for the new throwing-capture receipt (src/capture/runtime.ts:358–383). The new catch calls record(..., sid, undefined) after awaiting captureSession, so record captures the session's repository at failure time rather than using the entry-time captureGate.evidenceContext already used by the other capture receipts. This reintroduces the lifecycle split addressed by #199 for this new path.
Deterministic reproduction through the real plugin harness (temporary stores, no external model): start idle capture in repo A; park generate.text; deliver the recorded-shape session.moved event from A to B and wait until the identity subscriber binds B; release generation with Error("private repo-a capture failure"). The resulting auto_capture_refused reason=capture_threw has repo=B and B's repoPath. A separate B-bound session's memory_evidence reads that error, while an A-bound session gets No evidence. The otherwise identical no-move control stamps A and is invisible to B. The ownership regression probe is 1 pass / 1 fail at this head.
Please retain the capture's entry-time evidence context for the failure receipt too, capturing it after the provisional bind and before asynchronous context/model work, and pin the moving-session error case. Keeping sid explicit alone does not freeze its repository. This finding concerns diagnostic attribution/visibility; it does not establish a durable-memory-row leak or a live-host incident.
|
Closing as superseded by #354. Nothing here is unfixed — it is fixed on the branch that carries this one.
F1 from the review is resolved at Why close rather than leave open: this head still carries the bug the review found. Merging #328 alone would ship the unfixed catch. Cherry-picking the fix onto this branch instead would put the same lines on both sides of a merge for no gain. |
Why auto-capture has never fired
The README says auto-capture "has never been observed firing on a live opencode 2.x store". A live probe finds the reason, and it is not the trigger.
Probe: throwaway
HOME,autoCapture: true,opencode serve(long-lived, so the host survives turn end), one real turn, plus a second plugin that records every event delivered to subscribers.What the store and the recorder show, in order:
ev=plugin_load … capture=on subscribed=[session.execution.succeeded,session.execution.interrupted]— the subscription registers.session.execution.succeededarrive flat, exactly the shapecaptureTriggerFormatches, with the session id underdata.sessionID, which is the first formcaptureSessionIDtries.trigger matched→dispatching capture→captureSession enter {writeTarget:true}→transcript {"chars": 0}→too thin, skip.So the event fires, the session resolves, and the transcript is empty.
session.context()on 2.2.5 returns:There is no
roleand noparts.flattenTranscriptread onlyinfo.role | roleandparts[].text, so every message failedif (!role || !text.trim()) continueand the transcript rendered as"". The 200-character floor then returned without recording anything, which made a permanently dead feature indistinguishable from a session with nothing worth remembering. That silence is the second bug, and it is why this survived a host generation.Fix
src/capture/transcript.ts— accept the role undertype, restricted touser/assistant(2.2.5 interleaves a non-conversationidlerecord in the same array), and read parts fromcontent[]whenpartsis absent. Reasoning parts stay excluded; tool parts still contribute nothing, so the transcript keeps its old size.src/capture/runtime.ts— recordauto_capture_skipped reason=transcript_too_thin chars=Non that return, andauto_capture_refused reason=capture_threw error=…(redacted, capped) where the turn-end handler previously swallowed every error fromcaptureSession. Fail-closed for the session; visible in the store.test/fixtures/host-session-context-2.2.5.json— the real recorded context, plus unit tests for the shape, the new evidence lines, and athrowsseam in the test harness.Verified live, not just in tests
Same probe, same server, with this branch:
Turn ended 00:52:22, row landed 00:52:47 — 25 s after the user already had their answer, off the critical path.
Gate: typecheck,
bun run lint, 1041 unit tests, 30 terminal/BDD tests against a real opencode host — all green.What this does not close
opencode run --standaloneexits at turn end, so the capture call is killed before it lands. Any benchmark of auto-capture must drive a long-lived host. This is why the EPIC: Plugin effectiveness benchmark — results banked, hold-out validity + latency + publishing left #315 B-chain never saw it.autoCapture: falseand no instruction, an interactive session stores about 0.5 rows.Refs #325, #327. Found by the #315 benchmark work.