Repository navigation
fix(capture): grant the hint channel only on checkable guidance - #486
Conversation
A guided row rides every later session's injection prefix, ahead of the lexically-relevant picks. Attribution alone cannot decide entry: a task brief is a user turn, so a sentence written for the harness earns the same lane as a rate the user supplied. Entry now requires a handle a later session can verify — a stated number, or a declared keyword the tool ledger corroborates — and a refused row keeps its prose, losing the grant and the verbatim quote. The refusal is recorded as its own evidence outcome.
WhollyMindless
left a comment
There was a problem hiding this comment.
Note
🤖 GPT-6.2 Astra responding on behalf of WhollyMindless
I found two cases where the capture decision disagrees with what the session actually established on b611b40. All 12 tests added by the PR passed locally. I used the same capture harness and checked the stored tags, quote, and auto_capture_brief_echo event.
-
A filename version in the model’s summary grants
user-guided. In the #382 fixture I changed onlydocs/ARCHITECTURE.mdtodocs/ARCHITECTURE-v2.mdin the model’scontent. The user quote and tool calls stayed identical. The original fixture recorded a brief echo. The versioned-filename variant keptuser-guidedand emitted no echo.guidedAttestationincludes the model’s prose in its digit check, so the2counts as a value the user supplied. Could the value check require evidence in the user’s verified words? The existing user-stated tax-rate case is a good positive control. -
Declaring
goas a keyword makes a genuine Go convention lose its quote. With the user saying “Use Go for the repository tooling” and the ledger containinggo test ./..., the candidate withkw: ["go"]lostuser-guidedand its quote, and counted as a brief echo. Omittingkwpreserved both on the same input. An exact executable match would handle short tool names without matching arbitrary two-letter fragments. Treating an all-skipped keyword list like an omitted list would also avoid this reversal.
There was a problem hiding this comment.
reviewed as ocsi-reviewer. Verdict: approve. No blockers. Four nits/follow-ups below; none hold merge.
Reproduction, both arms (run independently)
Both arms exported with git archive to scratch dirs with symlinked node_modules; the new test file was copied into the origin/main export unchanged.
origin/main (374a0cf) — the grant reproduces; the brief row lands user-guided:
$ bun test test/capture/capture-brief-echo.test.ts # in a main export
109 | expect(row?.tags).toEqual(["auto-capture"]);
error: expect(received).toEqual(expected)
[
"auto-capture",
+ "user-guided",
]
at .../test/capture/capture-brief-echo.test.ts:109:23
(fail) hint-channel entry in a real capture pass > a brief sentence naming nothing the session used loses the grant
(pass) ... a value stated in the brief keeps the grant and the verbatim quote
(pass) ... a tool convention the session exercised keeps the grant
2 pass
1 fail
Fail-before matches the claimed line test/capture/capture-brief-echo.test.ts:109:23 exactly, and both narrowness guards pass on main.
Head (b611b40):
$ bun test test/capture/
272 pass
0 fail
Ran 272 tests across 20 files.
The demotion scenario passes on the head (tags ["auto-capture"], original absent, auto_capture_brief_echo line with withheld: "1"), and both guards still pass there.
Architecture outcomes
1. The number escape hatch — acceptable, with one widening nit. Aggregate over the validator's store copies (counts only): 7,999 rows tagged user-guided, of which 1,936 (24.2%) contain a digit in content/claim/original. That is the upper bound of rows the value clause alone keeps — roughly a quarter of the lane, and the ledger/undecidable clauses keep most of the rest, so the demotion set is the rows that name nothing the session touched. Given src/core/tags.ts:7 records the measured alternative (a lexical refusal rejected 30 of 1,166 rows and 29 rejections were wrong), accepting digit-bearing boilerplate as wrong-keep = status quo is the right trade. Nit below on what "states a number" actually scans.
2. kw-as-corroboration — weaker than "exercised", exactly at the ticket's floor. wholeTerm (src/capture/attest.ts) skips terms under 3 chars and requires word boundaries, but git, bun, test all pass and appear in nearly every ledger; no-kw keeps (attest.ts:130-131) and an empty ledger keeps (attest.ts:136). So the check cannot prove a convention was exercised — it can only refuse rows whose declared keywords appear nowhere the session acted. That is precisely the ticket's minimum bar ("a REQUESTS-only row with no supporting tool call"), and the module comment states the limitation rather than hiding it. Accept the strength as designed: refuses vacuity, does not prove use.
3. Demotion field-stripping — swept, clean. Every downstream consumer of guided/original/ref/claim/klass guards absence:
src/store/model/memory.ts:78-88— all five fields optional on the row type;sanitizeComparisonFieldsdrops a junk field, never the row.src/store/files/append.ts:126-127—containsSecretis total onundefined(src/store/secrets.ts:89-91).src/store/files/load.ts:82-93— typed parse, absent →undefined.src/recall/relevant.ts:171— contradiction surface:if (!m.ref || !m.claim || !m.klass) continue;— demoted rows are skipped, never reachconflicts.tsrendering.src/inject/format.ts:43-44—m.original ? " (user said: ...)"— no quote, no rendering.src/gate/value-conflict.ts:257-264— tag-keyed with optional chaining; a demoted candidate simply loses guided-retirement authority, which is the intent.src/init/retag.ts:91—row.original ?guarded.src/capture/available.ts— its "claims" are computed from content text, not theclaimfield; unaffected.src/gate/resolver.ts—s.refis span refs, an unrelated concept.- Viewer (
src/viewer/*) — no direct access to any stripped field.
No crash or silent mis-render path found. One coupling worth a comment, nit below.
4. Demote vs refuse — accept. A wrong demotion costs one row the always-ride lane while the row stays stored, relevance-recallable, and re-grantable on the next pass; a wrong grant costs every later session's prefix and cache. The store's measured history (tags.ts:7) says over-refusal was the past failure mode. The ticket's stated minimum — a distinct evidence outcome so the bench can count brief echoes — is met by auto_capture_brief_echo.
Nits (none hold merge)
-
src/capture/attest.ts:128-129scanscontent, not just the user's words.const words = \${candidate.claim ?? ""} ${candidate.original ?? ""} ${candidate.content}`— the PR text says the value clause reads "a number in the user's own words or in the declaredclaim", but the model's own distilled prose also earns the grant: a capture model that paraphrases boilerplate with any digit ("Python 3", "HTTP 429", "the newest 3") mints the value clause from prose the rule exists to distrust.originalis the only field the runtime verifies as the user's. Follow-up: restrictstatesValuetooriginal(+claim`), or state the widening in the module comment. -
Demotion changes the verdict path, so "demoted, never refused" has a narrow exception.
src/capture/runtime.ts:957-963: guided rows skipclaimVerdictFromContent; a demoted row is no longer guided, so it now runs the inferred-claim check and is refused entirely (runtime.ts:966-983) if its content contradicts the tree. Consistent with "demoted = ordinary row" and arguably correct, but theauto_capture_brief_echowithheldcount can then include rows whose prose did not survive. One comment at the attest call site should say so. -
Window fingerprint surface. Demoted rows shift
guidedSeen/guidedIds/guidedRodeIds(src/inject/epochs.ts:230-232) and therefore epoch accounting on affected repos. Flagging the surface per standing review policy; not validated here. -
auto_capture_brief_echosurfacing: log-only. It is recorded atsrc/capture/runtime.ts:803and asserted only in tests.src/status/metrics.ts:257sweeps everyauto_capture_*line generically, so it updateslastFiredbut is counted as neither rows nor blocked (the name ends in neitherblocked/refused/partial). Acceptable as log-only per the brief; if the bench wants a rate, a blocked-class suffix or a dedicated counter is the follow-up.
Test integrity
git diff origin/main...HEAD --stat: 4 files, 509 insertions, 0 deletions — no existing assertion touched. Added comments/test names carry no issue refs, dates, or narration (grepped #[0-9]{3,}, date patterns, "this PR"/"as of"). README is untouched by the diff and measures 4028 words (wc -w README.md), at the guard's ceiling but unchanged.
CI at head
gh pr checks 486: lint pass, smoke pass, test pass, test-windows pass.
What remains unfixed, plainly
- Brief-echo prose is still stored as an ordinary row (by design; the ticket's harms — always-riding, poisoned provenance, guided-lane slot — are what the PR claims to stop, not storage).
- Existing poisoned
user-guidedrows in real stores are untouched; no migration. This is honest: distinguishing a harness echo from a genuine convention using stored prose alone is the same undecidable call the capture pass now declines, and the human per-row path is stated. "no semicolons"-style preferences with no digit and no ledger-corroborated keyword lose the always-ride lane; stored and relevance-recallable, no longer forced into every prefix.- A boilerplate sentence whose declared keyword collides with an unrelated tool call keeps the tag (wrong-keep = today's behavior, acknowledged).
|
🎉 This PR is included in version 0.33.10 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Reproduction (current
main, v0.33.9)Measured before any code was written, using the repo's own capture harness (
test/harness.ts— fake host, canned capture-model reply, real write gate, real store).Session: brief containing
Documentation in docs/ may be stale: trust the code's invariants over the docs., two tool calls (read src/pricing.ts,bash bun test src/pricing.test.ts), capture model emitting the row the benchmark recorded. Row stored onmain:{ "type": "preference", "scope": "docs", "content": "In this repository, src module invariants are authoritative over docs/ARCHITECTURE.md; documentation may contain stale behavior claims.", "tags": ["auto-capture", "user-guided"], "original": "Documentation in docs/ may be stale: trust the code's invariants over the docs." }Still reproduces. Nothing between v0.22.2 and v0.33.9 closed it: the verdict rework, the restatable checks and the prompt edits all act on whether a row is stored, and this row is stored and additionally holds the highest provenance the store has.
The decision path, not the prompt
src/capture/runtime.tsgranteduser-guidedfrom one condition: the capture model emittedguided: true, and (default path) the row'soriginalis a substring of the user's turns. A task brief is a user turn. So the test admits every sentence a session contains, and harness boilerplate passes it unchanged — the user really did type those words.That condition is not weak; it is aimed at the wrong axis. It proves attribution. It cannot prove the sentence is about this repository, which is what a persistent repo fact claims to be.
Why that is expensive, in this codebase specifically:
user-guidedis a grant, not a label.selectRelevantputs the newest 3 guided rows into every later session's injection block regardless of lexical overlap, ahead of the relevant picks, andsrc/recall/relevant.tsexempts the guided lane from the budget demotion applied torestatablerows. The row is not crowding a queue — it owns a slot every later session pays for in prompt bytes and a prompt-cache miss.Layer chosen: the provenance grant itself
src/capture/attest.ts, called from the capture pass after quote verification and before the write gate. A guided row keeps the tag when it carries a handle a later session can check outside the prose:claim. The contradiction surface already code-checks these against the tree, and a rate or a limit is the kind of thing only the user can supply.tool,cmd,arg; output deliberately excluded, because reading a file that contains a sentence is not exercising a convention)."we use bun here"is confirmable by abuncommand."trust the code over the docs"is confirmable by nothing, which is the reason it should not own a slot.A refused row loses the grant, the verbatim quote (injection renders it as
user said, the attribution just refused) and the comparison fields. The prose stays. The refusal is recorded as its own evidence outcome,auto_capture_brief_echo, so the bench can count brief echoes — the ticket's stated minimum.Why this layer over the alternatives:
The trade-off, stated for review. The rule is deliberately asymmetric toward keeping the grant: no keywords declared → kept (keywords are optional in the capture contract, so their absence disproves nothing); empty ledger → kept (a capped tail is not evidence that nothing ran); a keyword that collides with an unrelated tool call → kept. A wrong demotion costs one row its always-ride lane while the row itself survives and stays recallable by relevance; a wrong grant costs every later session and puts an unchecked sentence in the lane this store has measured being obeyed over the code. The asymmetry is the design, not an oversight.
Fail-before
New behaviour test run against a clean
git archiveexport ofmain(never agit checkoutover uncommitted work):The two guards in that file — a value stated in the brief, and a tool convention the session exercised — pass on
mainand pass here. They pin behaviour that must survive, so they prove the fix is narrow rather than a blanket refusal of guided rows.test/capture/capture-attest.test.tscovers the decision function directly and cannot run onmain(the module does not exist there), which is why the behavioural proof above is the one that matters.Verification
bun run typecheckbun run lintbun run lint:commentsbun run testmainexportDelta: +12 tests, +2 files, nothing weakened, skipped or retried. No e2e was run for verification; the only e2e execution was the repository's own mandatory
pre-pushgate.Not fixed
Closes #382claims the three measured harms are stopped — always-riding, the poisoned provenance, the guided-lane slot — not that the sentence is gone."no semicolons"is stored and recallable, but no longer forced into every prefix. Accepted: an unverifiable sentence is precisely what must not own an always-ride slot, and the ticket's prompt rule is about storing it, which still happens.guidedon REQUESTS text; the runtime now decides whether that earns the lane. Keeping the prompt byte-stable avoids churn on every capture pass and keeps the fix testable.