Repository navigation
feat(capture): let a failed session leave a lesson, but only an attested one - #384
Conversation
…ted one Measured on the bench (results-learn-t3-diag, 2026-11-10): a session that failed after 574 s and 33,287 tokens wrote ONE captured row, and it was a paraphrase of a sentence in the task brief. Zero lesson-shaped rows. The capture prompt listed "blockers hit" as one word in a list of seven and never mentioned failure, dead ends or ruled-out hypotheses — the model was not declining to store lessons, it was never asked. This is the mechanism the plugin is for: every result the bench has so far needed a human to state the fact in pass 1. The prompt now gets an ATTESTED FAILURES block and asks for one `blocker` row per failure worth a lesson, in the form `when <condition>, avoid <action>`, naming a file or symbol so the rule can later be checked against the code. The block is not the model's recollection. attestedGateFailures reads the tool ledger for gate commands that FAILED with no later PASS of the same family, and a candidate carrying "failure" is dropped before the write gate unless that citation appears in the ledger. ReMe (Findings ACL 2026) found selective addition BEATS full addition, because one failed trajectory rarely carries enough context for a correct analysis and yields misguided experiences: the way this feature fails is by storing a wrong rule, and a rule about a failure that never happened rides every later session as an instruction. A lesson that cites a failure the agent already fixed is refused for the same reason — captureSignalSince reads the same ledger for the opposite purpose, since a recovery is the best REASON to capture and an unrecovered failure is the best thing to capture. The gate is monotone. Only a row carrying `failure` makes the claim, so an ordinary uncited `blocker` note — a type this path has always written — is untouched. Refusing every uncited blocker would delete rows the store has always kept, and a provenance fix does not buy a recall loss here. `failure` is a write-time check, not a stored field, so no row format changes. gateCmd had no `test` family: `bun test`, `npm test` and `pytest` registered as no gate at all, so a session could go red-green-red and the ledger never saw it. That made attestation useless for the commonest failure and meant `gateRecovered` could not fire for it either. The matcher is anchored on the runner, not the word, because the word appears everywhere in a repo with a test directory — `ls src/test` and `cat test/fixtures/a.json` are not test runs. Cost: no new model calls, and the block is a handful of lines bounded at eight failures. captureOnSignal is unaffected — it returns `edited` first for any session that wrote a file, which is the common case, so the added `test` family only changes verdicts for read-only sessions that ran a test and recovered. Typecheck clean. 1242 pass / 19 skip / 0 fail. Lint unchanged at 542 warnings, 147 infos. Diff is additions only.
Prompt A/B against the real capture model — and a correction to the premise aboveA full bench session cannot test this change, and the reason is worth recording: the failed session in So the prompt was measured directly:
Representative old-arm row:
Representative new-arm row:
What this correctsThe ticket says the old prompt stores nothing from a failure. That is what So the honest split of the cause is:
On the costCompletion tokens go 3,094 → 7,268, and one rep hit 13,088 with a 272 s call. That is real and it is not disqualifying on its own: the goal is better future runs, not cheaper capture. Whether the extra deliberation buys anything is a separate measurement, and it is running now — arm N ( Results go on #381. |
WhollyMindless
left a comment
There was a problem hiding this comment.
Two independently reproduced P2 findings on 458b8ce:
-
Redact the new attested-command prompt input.
src/capture/runtime.ts:494–508buildsattestedfrom raw ledgerarg, andsrc/capture/prompt.ts:120interpolates those strings withoutredactSecrets. Through the real tool-result/capture hooks, a failingbun test --token=<synthetic sk-token>puts that recognized token verbatim ingenerate.text's ATTESTED FAILURES block, even with a token-free transcript and an empty model response. The scrubber redacts the identical token in the control. The existing transcript/user/known-row redaction does not cover this new input. Please redact before rendering, and compare citations against the same safe representation shown to the model. -
Match an attested command, not a substring of the joined list. At
src/capture/runtime.ts:625–626,lessonHay.includes(cite)accepts a lesson citingtscafter the only failed command wasbun test --test-name-pattern tsc. The row persists andauto_capture_lessonsrecordskept=1, although no typecheck ran. Changing that test-name argument tocartcorrectly refuses the same candidate. Membership in a normalized set of the permitted complete citations would preserve the claimed attestation boundary; substring presence cannot establish that the cited command ran.
Validation: 128 focused capture/failure/policy/disposal tests pass; three additional synthetic hook-level probes pass with six assertions establishing the two behaviors and the refusal control; typecheck passes. Windows, Bun 1.4.4, fake generation and isolated stores only—no live credentials, model calls or production store. I read the author's prompt A/B correction and the deliberately deferred #382/#383 scope; these findings concern the new attestation path itself.
…ield Review findings on #384 (WhollyMindless), both reproduced as stated. 1. The ATTESTED FAILURES block interpolated RAW ledger args. A failing `bun test --token=<sk-...>` put the credential verbatim into generate.text's prompt even with a token-free transcript -- the #132 transcript scrub covers the transcript, not this newer input. Entries are now redacted at construction, so the prompt renders the safe string and the citation check compares against the same representation the model was shown: an honest copy of what was displayed still passes, and the raw token cannot ride the row either. 2. `lessonHay.includes(cite)` accepted a lesson citing `tsc` when the only failure was `bun test --test-name-pattern tsc` -- substring presence cannot establish that the cited command ran. Membership is now tested against COMPLETE displayed fields: each whole entry, its cmd, and its arg. The review's `tsc` case is none of those and is refused (kept=0, refused=1, receipt pinned); a cmd-only citation -- the shape the prompt's own example uses -- still passes, pinned as a no-recall-loss control. - src/capture/runtime.ts: redactSecrets at entry construction; lessonHay -> lessonSet of whole fields - test/capture-failure.test.ts: three regressions (substring refused, exact cmd passes, credential never reaches the prompt) Co-authored-by: OpenCode <[email protected]>
|
@WhollyMindless both findings confirmed and fixed in 1 — attested args redacted at construction. 2 — whole-field citation membership. One refinement over your suggested set: the list renders Three regressions in |
WhollyMindless
left a comment
There was a problem hiding this comment.
Independently rechecked 15e764edef56cf7b2108246c954ec0259072bb02: both previously reported findings are resolved. Replayed the failing-command synthetic credential case: the actual capture prompt contains [redacted] and no token. Replayed the unrun tsc fragment against bun test --test-name-pattern tsc: no cart row is stored, and the lesson receipt reports kept=0. The unmatched-citation control still refuses.
131 focused failure/capture/policy/disposal tests, three separate hook probes (7 assertions), and typecheck pass on Windows/Bun 1.4.4. Approval covers this head and the independently verified boundary fixes; no live-model or benchmark certification.
# [0.23.0](v0.22.2...v0.23.0) (2026-11-12) ### Bug Fixes * **capture:** redact attested args, and match a citation as a whole field ([15e764e](15e764e)), closes [#384](#384) [#132](#132) * **capture:** the prose extractor keeps the sign before granting code-checked ([838ac7e](838ac7e)), closes [#399](#399) * **gate:** different environments are two facts, never a correction ([64184c5](64184c5)), closes [#400](#400) [pre-#390](https://github.com/pre-/issues/390) [#399](#399) * **gate:** digits are context; only the corrected value may drop out ([d24744b](d24744b)), closes [#400](#400) * **gate:** excise the asserted value by position, not by literal ([8114cec](8114cec)), closes [#400](#400) * **gate:** same-context is established by the words, not looked up ([0d0afbe](0d0afbe)), closes [#400](#400) [pre-#390](https://github.com/pre-/issues/390) ### Features * **capture:** let a failed session leave a lesson, but only an attested one ([458b8ce](458b8ce)) * **gate:** a correction retires the row it corrects in the data ([bcba2f4](bcba2f4)), closes [#390](#390) [#393](#393) [#208](#208) [#389](#389) [#393](#393) [#393](#393) * **provenance:** an unverified row says so where the model reads it ([8bcb6ac](8bcb6ac)), closes [#386](#386)
|
🎉 This PR is included in version 0.23.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Problem
A session that fails stores nothing about why it failed.
Measured on the bench on 2026-11-10 (
benchmark-tests/ocsi/results-learn-t3-diag, pluginf8f42fdv0.22.2): a session on a bug it could not fix ran 574 s and 33,287 tokens, failed two tests, and auto-capture wrote one row:That is a paraphrase of a sentence in the task brief. Zero lesson-shaped rows out of one. The most expensive knowledge the plugin ever sees — 33k tokens of discovering what does not work — has a half-life of one session.
The cause is not the model declining.
src/capture/prompt.tslisted "blockers hit" as one word in a list of seven, and grepping the whole prompt file forfail,dead end,wrong,mistakeorruled outreturns nothing. The model was never asked.This is the mechanism the plugin is actually for. Every result the bench has produced so far needs a human to state the fact in pass 1; the plugin persists what a person said and discovers nothing.
What changes
attestedGateFailures(s, sinceTurn)(src/capture/policy.ts) reads the tool ledger for gate commands that FAILED with no later PASS of the same family. First-failure order, deduped by family, capped at eight. A recovered failure is excluded: FAIL then PASS means the agent fixed it, and "do not do what I just did" is only a lesson while the thing is still broken.captureSignalSincereads the same ledger for the opposite purpose — a recovery is the best reason to capture, an unrecovered failure is the best thing to capture.The capture prompt gets an
ATTESTED FAILURESblock and asks for oneblockerrow per failure worth a lesson, in the formwhen <condition>, avoid <action>, naming a file or symbol so the rule can later be checked against the code. When nothing failed the prompt says so explicitly rather than going quiet.A lesson must cite its failure, and the citation is checked against the ledger, not against the model's retelling. A candidate carrying
"failure"is dropped before the write gate unless that string appears in the ledger's unrecovered failures.failureis a write-time check, not a stored field, so no row format changes.gateCmdhad notestfamily.bun test,npm testandpytestregistered as no gate at all, so a session could go red-green-red and the ledger never saw it. The matcher is anchored on the runner rather than the word, because the word appears everywhere in a repo that has a test directory —ls src/testandcat test/fixtures/a.jsonare not test runs.Why attestation is the load-bearing part
ReMe (Findings ACL 2026) found selective addition beats full addition, because a single failed trajectory rarely carries enough context for a correct failure analysis and produces misguided experiences. So this feature does not fail by missing right lessons — it fails by storing wrong ones. A rule about a failure that never happened rides every later session as an instruction. The attestation requirement is not bureaucracy; it is the difference between a lesson and a rumour.
Containment for this row class is already merged: the write gate, quarantine, provenance stripping (#342), the code-checked contradiction surface, and undo.
No recall loss
The gate is monotone. Only a row carrying
failuremakes the claim "this is a lesson", so an ordinary uncitedblockernote — a type this path has always written — is untouched. Refusing every uncitedblockerwould delete rows the store has always kept, and a provenance fix does not buy a recall loss.Cost
No new model calls. The block is a handful of prompt lines bounded at eight failures.
captureOnSignalis unaffected in the common case: it returnseditedfirst for any session that wrote a file, so the addedtestfamily only changes verdicts for read-only sessions that ran a test and recovered.Out of scope, deliberately
captureSignalSincestill requires success. WithcaptureOnSignalon, a session that investigates, hits a dead end and stops is not a signal, so the cost lever suppresses exactly the class this ticket is about. AddinggateUnrecoveredis one branch, and it is filed separately.makeRepodeletestest/, so there is nothing to gate against. The prompt effect is measured directly against the capture model instead.Test plan
bun run typecheck— cleanbun test— 1242 pass / 19 skip / 0 failbun run lint— unchanged at 542 warnings, 147 infostest/capture-failure.test.ts, 22 tests: ledger attestation (recovery, per-family recovery, window, cap, non-gate commands),gateCmdtest families and thels src/testnon-match, prompt contract (block renders, rule form, citation-only-from-the-list, explicit no-failure statement, byte-identical when the argument is omitted),parseCandidatescitation shapes, and four end-to-end capture runs: attested lesson stored, unattested refused with a receipt, uncited blocker unaffected, recovered failure refused.Refs the bench plan
benchmark-tests/ocsi/PLAN-learn-from-failure-2026-11-10.md.Closes #381
Follow-ups filed from the same measurement, deliberately not in this diff: #382 (auto-capture turns task-brief boilerplate into a persistent repo "fact") and #383 (
captureSignalSincestill requires success, socaptureOnSignalcan refuse the very pass that would capture a lesson).