Skip to content

feat(capture): tag restatable rows instead of dropping them (#402) - #403

Merged
abogartz merged 18 commits into
mainfrom
402-availability-restatable
Nov 14, 2026
Merged

abogartz merged 18 commits into
mainfrom
402-availability-restatable

Conversation

@abogartz

Copy link
Copy Markdown
Owner

What this does

Closes #402. Supersedes #397.

The #389 availability check refused a capture candidate whenever it concluded the next session could read the fact in the working tree. This PR keeps the check and changes the consequence: the verdict becomes the restatable tag on a row that is stored anyway.

No code path in src/capture/available.ts can prevent a write.

Why the policy, not the matcher

Four adversarial review rounds on #397 each found the same defect — text that was merely short or partly matched was read as already known — and each round patched one instance. Measured against this repo's live store:

original 362655c shipped 1930bf6 this PR
real captured rows refused 30 of 1166 0 of 1170 0, always
of those, genuinely restatable 1 — —
tree scan on a pass with no candidates 108 ms 108 ms 0 ms
rows recoverable after a wrong verdict 0 0 all

The original check() opened with if (gate) return refuse and had no residual test, so it refused rows such as "OpenCode V2 (v2.0.26) does NOT run LSP servers…" against package.json scripts.typecheck, and "PR #124 … reviewed + APPROVED on the merged tree" against scripts.test. Twenty-nine of thirty were wrong.

So the four rounds were correct, and they moved the yield from 2.6% to 0.0%. That is the evidence: a lexical rule is not defensible as a delete. Under a tag, a wrong match costs one row and a right one saves an injection slot — the first version of this where both error directions are survivable.

Changes

P0 — cost and visibility

  • The index is built on first use. The old code paid a synchronous git ls-files plus a read of every tracked text file before looking at the candidate list, so a pass that answered [] scanned the tree anyway.
  • scanned() is wired into a new auto_capture_scan evidence line naming files, bytes, milliseconds and whether the 2 MB budget truncated the scan. It shipped "for evidence" and was never called. It reports capped: true in this repository — the tracked text exceeds the budget, so the tail of the tree is never read.

P1 — refusal becomes a label

  • RESTATABLE_TAG (src/core/tags.ts) on the stored row.
  • auto_capture_restatable carries the full candidate, so the audit trail alone can rebuild a row a later consolidation drops. A silently dropped candidate left nothing to recover, which is why 29 lost rows stayed invisible for a month.
  • selectRelevant walks restatable rows last under a budget, outside the guided lane only. selected is untouched: the use ledger still sees the ranking, so a recall miss stays diagnosable.

P2 — two vetoes, each able only to decline a tag

  • Polarity: the local cue list unioned with core/tokenize.ts's polaritySigns. polaritySigns is a predicate-sign extractor, not a negation detector — "we do not use tabs" returns [] because use is not a table term. Substituting it for the cue list compares [] with [], matches, and re-opens the round-3 defect. What it adds is the part a cue list cannot see: antonym pairs and the dual-role never.
  • Numbers: numericTokens against the declared command. The manifest states that deploy exists; it states no count, so "Ship with npm run deploy, 3 times." is a new fact.

Proof the #397 issues are solved

test/capture-available.test.ts is rewritten to the new contract: every case asserts the row reaches the store first, and the tag is what differs. All four review rounds are kept as cases, and each now has a MUST-GO-RED counterpart — before this PR those cases produced zero rows, so "kept" and "refused" could not be distinguished by looking at the store.

New cases:

  • the availability check cannot prevent a write — three restatable candidates, three rows.
  • a figure the declaration does not carry is a different fact — veto 2.
  • a pass with no candidates reads no tree — P0, and it fails if the build moves back out of the lazy closure.
  • a pass that checks names what it read — the scan line.
  • restatable rows give up injection budget first (test/inject.test.ts) — the restatable row is deliberately the newer one, so the assertion cannot pass by accident of recency or scoring.

Gate: 1344 unit + 31 e2e green, tsc --noEmit clean, biome lint and biome format clean at the 551-warning baseline.

Two findings worth recording

A scratch file in the tree suppresses real memories. While measuring, the gate tagged the row "On OCSI PR #396, bun run bench prints 56109/55889…" — because a plan document in the repo root quotes that sentence. git ls-files feeds the scan, so any document that quotes captured output makes those rows look restatable. Under the old policy that row would have been deleted. This is the mechanism working as designed and the policy being wrong, in one measurement.

#389 AC4 is unsatisfiable by construction. Candidates come from the model, so availability can only be evaluated after the call that produced them; the check changes which rows give up injection budget, never how many tokens the pass spent. A test pins this rather than arguing it. The criterion should be rows-per-session and injected bytes per session, both already metered by #387.

Explicit non-goal

No new matcher, no new word list. Every phase that adds a rule needs a replayed read behind it, per consolidate/propose.ts.

Deferred to a follow-up: P3, moving availability to read time — whether a README restatement is redundant depends on whether the next session reads the README, which write time cannot know. It touches injection selection and needs its own bench arm.

Part of #386.

Cherry-picked wholesale from PR #397 before the pivot in #402: the tree scan,
the gate parser and the four rounds of review cases are the valuable part of
that branch. The refusal policy on top of them is what #402 changes.
The #389 availability check refused a capture candidate whenever it concluded the
next session could read the fact in the working tree. Measured against this repo's
live store, the original rule refused 30 of 1166 real captured rows and 29 of those
were wrong: "OpenCode V2 (v2.0.26) does NOT run LSP servers" was refused because
the row contained the string `bun test` and the project declares a `test` script.
Four review rounds on #397 hardened the matcher until it refuses 0 of 1166, which
is the other half of the same evidence — no lexical rule is defensible as a delete.

The consequence changes. The check stays.

- A verdict is now the `restatable` tag on a row that is stored anyway. No code
  path in `available.ts` can prevent a write, so a wrong match costs one row and
  the defect class rounds 1-4 patched one at a time becomes unrepresentable.
- `auto_capture_restatable` carries the full candidate, so the audit trail alone
  can rebuild a row a later consolidation drops. A silently dropped candidate
  left nothing to recover, which is why 29 lost rows stayed invisible.
- Retrieval walks `restatable` rows last under a budget, outside the guided lane
  only. `selected` is untouched, so the use ledger still sees the ranking and a
  recall miss stays diagnosable.
- The index is built on first use. The old code paid a synchronous `git ls-files`
  plus a read of every tracked text file — 96 ms here — before looking at the
  candidate list, so a pass that answered `[]` scanned the tree anyway.
- `scanned()` is wired into a new `auto_capture_scan` line. It shipped "for
  evidence" and was never called; the line now names files, bytes, milliseconds
  and whether the 2 MB budget truncated the scan. It does, in this repo.
- Two vetoes, each able only to DECLINE a tag. Polarity: the local cue list
  unioned with `core/tokenize.ts`'s `polaritySigns`, which is a predicate-sign
  extractor and must not be used as a negation detector on its own — "we do not
  use tabs" returns [], so substituting it compares [] with [] and re-opens the
  round-3 defect. Numbers: `numericTokens` against the declared command.

Tests are rewritten to the new contract: every case asserts the row reaches the
store first, and the tag is what differs. The four #397 review rounds are kept as
cases. Each test now gets its own session id, because capture keeps a per-session
window cursor and a shared id makes the next pass see a zero-length window.

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked 5780d8c in an isolated checkout against the cases from my last #397 review. The storage-loss findings no longer reproduce: all eight replay cases now persist their complete candidate text, including both Cyrillic restriction cases and Use npm run deploy -- --dry-run (with the command backticked). These probes exercise the capture hook, write gate, store and evidence log with scripted generation responses.

The same three false matches still receive restatable: the Cyrillic deployment prohibition, the README fact plus a Cyrillic restriction, and the undeclared --dry-run arguments. They are now recoverable stored rows; the remaining consequence is reduced injection priority under a tight budget. Those would be useful fixtures for #402 P4's retrieval replay, particularly before treating the tag as proof that the entire fact is available from files.

Validation: 156 focused capture/provenance/failure/injection/hint-channel tests passed (435 assertions), the eight independent replay cases passed explicit persistence/content assertions, and typecheck passed. This verifies the storage-policy change on these fixtures; it does not establish the live-store tag rate or transport benefit.

P4's measurement, so the claim in the commit above is a number rather than an
argument. One capture pass through the shipped plugin; four arms differing only
in what the availability verdict does; budgets swept over five sizes because a
single budget chooses its own answer — too loose every arm fits everything, too
tight none fits anything.

Result, at the budget where selection binds:

  transport facts in block   off 9 / tag 9 / delete-hardened 9 / delete-original 5
  restatable facts kept      off 5 / tag 5 / delete-hardened 0 / delete-original 5

The win against `362655c` is retrieval: a deleted fact cannot be surfaced, so the
original rule loses four of ten new facts permanently. The win against #397's
hardened delete is not recall — it is identical — it is that deleting also
destroys the five facts the tree does state, unreachable at any budget. Against
no check at all the tag arm is never behind on recall at any budget and never
spends more block bytes on facts the tree already states.

The cost is reported rather than hidden: doc facts lose their slot between 25%
and 60% budget (0/6 vs 5/6). That is the demotion working, and it is still a loss.

11 controls, exit 1 if any fails: negative control (a header-only budget shows
nothing), no-drop (tag holds every row the no-check arm holds), the `362655c`
reproduction pinned to exactly the four candidates it must refuse, never-worse at
every swept budget, the guided-lane exemption, and prompt containment. Deterministic
across runs: no Math.random, the delete arms are derived from the same stored rows.
…bers (#403)

Self-review of the diff found the audit trail said something the store did not
support. `restatements` was incremented where the availability check returned a
verdict, which is before the write gate, so a candidate that earned a verdict and
was then refused — a duplicate, a credential-shaped scope — was counted as a
tagged row that does not exist. The bench reproduced it directly: the scan line
reported 6 while 5 rows carried the tag.

The field now counts rows the gate actually wrote, which is the only part that is
a fact about the store, and the raw verdict count rides beside it as `verdicts`.
Keeping both is the point: the difference between them is the set of verdicts the
gate refused, and a reader who sees one number will assume it is the other.
`auto_capture_restatable` is documented as a verdict trace rather than proof of
storage, because it is written before the gate and cannot be anything else.

test/capture-available.test.ts pins the case: a candidate with a verbatim README
claim and a credential scope gets `verdicts=1`, `restatements=0` and no row, with
the verdict line and the block line both asserted so the test cannot pass on a
pass that did nothing.

The bench also stops losing a row for an unstated reason. One scripted candidate
cites `config/limits.ts` in its prose, the gate refuses a write whose cited path
is absent (`ref_path_missing`), and the store silently held 15 of 16. The fixture
now creates that file and a conservation control names any candidate that fails
to reach the store, so the next such loss reports its prose instead of quietly
changing every number derived from the rows.

README gains the measured result for the availability policy, which the
auto-capture section previously listed as wholly unmeasured, and
`bun run bench:availability` runs it.

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the 5780d8c → 91c0f17 delta. The verdict/tagged-row counter split passes the new blocked-write regression: 139 focused tests, 401 assertions, and typecheck pass. The unmodified benchmark also reproduces its committed results and passes all controls.

Two P2 benchmark findings below came from instrumenting the same fixture and replaying the actual historical matcher. Both affect the reported experiment; neither probe overturned the measured transport-recall ordering. The earlier storage-policy verification still applies. These are synthetic, scripted-capture results, not live-store measurements.

await sleep(600);

const stored = (await loadAll()).filter(
(m) => isActive(m) && m.tags?.includes("auto-capture"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Include the seeded distractors in the selector inputs.

This filter removes every seeded background row because they have no auto-capture tag, and every arm is then built solely from stored plus guidedRow. Instrumenting the shipped runner showed 30 active distractors on disk but zero in every array passed to selection (arm sizes 17/17/11/13). The report therefore does not measure the advertised 30-distractor competition.

Please include the same background rows in every arm, compute their availability verdicts too, and assert their presence at the selection boundary before regenerating the results. In a scratch probe doing that, the unbudgeted block changed from 2413 to 2791 characters and the byte totals changed; the transport-recall ordering still held. This is an experiment-coverage correction, not evidence that the policy's recall benefit disappears.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 2c81b06. The seeded rows never reached selection: stored filtered on the auto-capture tag and the seeded background carries none, so every arm was the captured rows plus the guided control while the report advertised 30 rows of competition. Both halves of your finding reproduce exactly as written.

The background is now read back from the store and included in every arm, and the shipped check judges it too, not only the captured rows. Rather than assert a new size, the runner compares the non-captured set across arms, so a filter that drops the background again fails with the sizes named:

PASS — the background really competes: the 30 seeded rows plus the guided control are the identical set in every arm (sizes 47/47/41/37, differing only by captured rows the policy deletes) — RED if a filter drops them again

Regenerated numbers: unbudgeted block 2413 to 2791 bytes, arm sizes 47/47/41/37, and the ordering the report claims is unchanged — transport recall at the binding budget is 9 for tag against 5 for delete-original.

SCRIPTS.some((g) =>
g.includes(" ")
? f === g || f.startsWith(`${g} `)
: f === g || f.split(" ")[0] === g,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Preserve the tracked-file branch in the historical baseline.

originalRuleRefuses reproduces only command matching, but 362655c's availabilityIndex.check also refuses in_tracked_file matches. I loaded that commit's actual module against this runner's repo and candidates: it refused all six DOCUMENTED rows plus the four command facts (10 refusals), while this helper returned only four.

Using the historical verdicts changes delete-original from 13 rows / 6 of 6 documented facts retained to 7 rows / 0 of 6 (including the shared guided control row). The current “4/4 reproduction” control rejects that faithful result. Please replay both historical branches, or name this a command-only hypothetical policy and adjust the historical claims. The 9-versus-5 transport-query result remained unchanged in this probe; the store, doc-query and restatable-byte columns did not.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed and fixed in 2c81b06. originalRuleRefuses reproduced only the declared-command branch; the module that shipped at 362655c also refuses in_tracked_file matches, and your point that this matters is correct rather than academic: loading 362655c's own module against this fixture refuses all six documented rows and 10 of 16 candidates, where my approximation caught 4.

delete-original now runs the pinned module. It is vendored at bench/fixtures/available-362655c.ts with the historical source present verbatim, and a control compares the copy against the git object so the fixture cannot drift into a story:

PASS — the pinned baseline is the real module — RED if the fixture was edited away from 362655c
PASS — the baseline is the historical rule, not a stand-in: the pinned 362655c module refuses 10 of 16 captured rows, including every documented fact and all 4 command-stating ones

The corrected numbers are worse for the historical rule and the report now says so: delete-original goes from 13 rows and 6/6 documented facts retained to 7 rows and 0/6. It deleted the documented facts it was meant to notice, which is the finding the approximation was hiding. The headline comparison does not move: transport recall at the binding budget stays 9 for the tag arm against 5 for that baseline.

…le` a lifecycle (#403)

Second self-review round, six findings, four real. Each was reproduced before it
was changed.

1. `negated()` widened the polarity test on BOTH sides of `findClause`, and that
   comparison is the tag-CREATING path: equality gets easier as both predicates
   broaden. Measured, tree `Do not assume the cleaner removes unused rows.` and
   candidate `The cleaner removes unused rows.` — `polaritySigns` reads the
   dual-role `removes` as negative in both strings, they agree, and the
   affirmative claim is tagged as restating the sentence that warns against it.
   That is the #397 round-3 reversal arriving from the opposite direction, and it
   is the exact mistake the comment above the function warns about, committed two
   lines below it. `findClause` now compares on the cue list alone. The union
   stays in `forbidsCommand`, where the answer is absolute and a wider predicate
   can only decline: `Drop using \`npm run deploy\`` still refuses the
   manifest as evidence, which the new pair of tests pins from both sides.

2. `restatable` had no lifecycle. `nonCaptureTags` stripped only `user-guided`,
   so `tools/update.ts` carried the verdict onto the replacement row: a user
   correcting a restatable fact left the CORRECTION demoted in injection
   forever, on a verdict about prose that no longer exists. `portable/import.ts`
   had the same hole across machines — the tag asserts "this working tree states
   it", and an imported row kept another machine's verdict against a tree that
   was never scanned. Both now drop it. A row that is genuinely restatable gets
   the tag from the next pass, so this costs a demotion and never a fact.

3. `content` and `matched` on the restatement line were the only capture evidence
   fields carrying model prose with no control-character flatten: the candidate
   validator checks type and scope but not content, `scrubFields` only redacts
   credentials, and the logfmt writer escapes five characters. A NUL survives
   `norm()` and reaches the verdict, so it landed raw in the day log, which
   `memory_evidence` returns to a model. Flattened at the field, not in
   `scrubFields`: the systemic version would change the meaning of existing audit
   lines that carry multi-line values.

4. The header claimed a wrong tag costs nothing. It costs the row its slot, which
   is the entire mechanism. Corrected, together with the one consequence of
   storing rather than deleting that the change really does introduce: a stored
   row is a live GATE-3 contender, so a later write at >=0.9 overlap is now
   refused `superseded_overlap` where the delete policy let it promote. Measured
   with an ordinary-tagged seed, which blocks the same write for the same reason
   — the tag changes nothing in the gate, the row being there does.

The `capped` nit is not a bug: it is set only when a file is skipped, so a final
file that crosses the cap correctly reports false, because nothing was left
behind. Documented, along with `bytes` counting decoded characters rather than
octets.

1349 unit + 31 e2e, typecheck clean, `bun run lint` exit 0, bench unchanged and
green.
@abogartz

Copy link
Copy Markdown
Owner Author

Self-review of this diff found four defects in what had just been written, and both benchmark findings from @WhollyMindless reproduce. Summarising so a moving diff stays legible.

What changed since 5780d8c

91c0f17 — the scan line reported a fact the store did not support. restatements was incremented where the availability check returned a verdict, which is before the write gate, so a candidate that earned a verdict and was then refused (a duplicate, a credential-shaped scope) counted as a tagged row that does not exist. The bench reproduced it directly: the line read 6 while five rows carried the tag. The field now counts rows the gate actually wrote, and the raw verdict count rides beside it as verdicts; the difference between them is the refused set, which is worth seeing. test/capture-available.test.ts pins the case with both the verdict line and the block line asserted, so it cannot pass on a pass that did nothing.

05482ba — three more.

  1. The polarity union widened a predicate on the tag-creating comparison. findClause compares polarity between a candidate clause and a tree sentence, and an agreement there is what adds the tag, so broadening both sides makes tags easier to earn — the opposite of the veto-only shape the comment above the function claims. Measured: tree Do not assume the cleaner removes unused rows., candidate The cleaner removes unused rows. — polaritySigns reads the dual-role removes as negative in both strings, they agree, and the affirmative claim is tagged as restating the sentence that warns against it. That is the Refuse capture candidates the next session can read or re-derive (#389) #397 round-3 reversal arriving from the other direction. findClause now compares on the cue list alone; the union stays in forbidsCommand, where the answer is absolute and a wider predicate can only decline. Two tests pin both directions.
  2. restatable had no lifecycle. nonCaptureTags stripped only user-guided, so tools/update.ts carried the verdict onto the replacement row: correcting a restatable fact left the correction demoted in injection forever, on a verdict about prose that no longer exists. portable/import.ts had the same hole across machines — the tag asserts "this working tree states it", and an imported row kept another machine's verdict against a tree that was never scanned. Both now drop it; the next capture pass re-derives it, so this costs a demotion and never a fact.
  3. content and matched on the restatement line were the only capture evidence fields carrying model prose with no control-character flatten. A NUL survives norm() and reaches the verdict, so it landed raw in the day log, which memory_evidence returns to a model. Flattened at the field rather than in scrubFields, because the systemic version would change the meaning of existing audit lines that carry multi-line values.

The header's cost model was also wrong: a wrong tag is not free, it costs the row its slot. Corrected, along with the one consequence storing genuinely does introduce — a stored row is a live GATE-3 contender, so a later write at ≥0.9 overlap is now refused superseded_overlap where the delete policy let it promote. Measured with an ordinary-tagged seed, which blocks the same write for the same reason: the tag changes nothing in the gate, the row being there does.

Both benchmark findings are confirmed

Distractors never reached selection. Reproduced by reading the arm construction: stored filters on the auto-capture tag and the seeded background rows carry none, so every arm was stored plus the guided row and the advertised 30-row competition was not in the selector. The report claims a competition it did not run.

delete-original was not the historical rule. Loading 362655c's own module against this fixture and its candidates refuses all six documented rows — four in_tracked_file, two declared_gate — where originalRuleRefuses caught only the four command facts. So the arm is a command-only hypothetical, and the "what #389's first rule stored" framing is wrong.

Neither is an argument about the policy's benefit; both are claims the bench made that the bench did not earn. Fixing both: seeded rows go into every arm with their own verdicts, and the historical baseline replays 362655c's real matcher rather than an approximation. Results regenerate from the corrected runner, and the README numbers move with them.

On the three false matches

Agreed, and the first one is now narrower than when you filed it: the removes-class masking above was a fourth case of the same shape, and it was live in the shipped matcher rather than in the baseline. The remaining ones — the Cyrillic prohibition, the README fact plus a restriction, the undeclared --dry-run arguments — stay false matches under a tag rather than under a delete, which is the point of the change. They go into the P4 case bank as fixtures, and the caution stands: the tag is a lexical verdict on a clause, not proof that the whole fact is readable from files.

Validation on this push: 1349 unit + 31 e2e, tsc --noEmit clean, bun run lint exit 0, CI green on 05482ba. The benchmark is currently not trustworthy for the two reasons above and is being corrected.

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified 05482ba's delta: the reported removes example now stays untagged, and the tag-lifecycle/control-character cases pass. 125 focused tests (382 assertions) and typecheck pass. I contributed the earlier provenance-boundary work; those checks are regression verification of the maintainer's change.

Two findings below were reproduced through the capture hook, actual temporary store and evidence log on both 91c0f17 and 05482ba. One is a new polarity regression; the redaction gap predates this push. Scripted model responses and synthetic credentials only. The acknowledged benchmark findings remain pending, so I have not repeated them.

Comment thread src/capture/available.ts Outdated
if (
!/\w/.test(String.fromCharCode(before)) &&
!/\w/.test(String.fromCharCode(after)) &&
cueNegated(sentenceAt(hay, i, clause.length)) === reversed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Narrowing the equality predicate also introduces new false tags.

With tracked README text Stop assuming the cache supports TTL expiration., capture candidate The cache supports TTL expiration. is stored untagged on 91c0f17 but stored with restatable on 05482ba. Drop the assumption that the cache supports TTL expiration. produces the same regression. Both were verified through the real capture path. The reported Do not assume … removes … case is fixed.

The cue list returns false for both sides here, so removing the predicate-sign comparison merges a warning and its embedded affirmative claim. The row survives, but its new tag can demote it under injection pressure. Please retain an independent predicate-sign veto alongside cue comparison, and cover these cases together with the fixed removes example; narrowing one boolean equality is not monotone in which tags it permits.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced on 05482ba through the real capture path, both cases, exactly as you wrote them:

notag  [Stop assuming the cache supports TTL expiration.] vs [The cache supports TTL expiration.]   <- was TAG in_tracked_file
notag  [Drop the assumption that the parser keeps comments.] vs [The parser keeps comments.]         <- was TAG in_tracked_file

You are right that narrowing one boolean equality is not monotone in which tags it permits, and right that the row survives but its new tag can demote it under injection pressure.

One correction, stated because it changes the fix: the suggested remedy — retain an independent predicate-sign veto alongside cue comparison — does not fix these two cases. polaritySigns finds no negation in either string (supports is not a table term carrying POL_NEG), so a predicate-sign comparison agrees on both sides and the tag stands. That is the same property that made the union re-open the round-3 defect from the other direction, which is why it is still excluded from the comparison.

What does fix it is reading the words between the sentence start and the hit (WARNS_AGAINST, src/capture/available.ts): Stop assuming and Drop the assumption that govern the clause that follows them. To keep the veto from becoming the over-refusal this whole change exists to remove, the ambiguous verbs (drop, discard, ignore, overlook, reject, forget) are veto words only when a claim noun follows — The parser drops stale entries. keeps its tag. A vetoed hit is skipped rather than ending the search, since a later sentence may state the claim plainly.

Covered together with the case you credit as fixed, in test/capture-available.test.ts and as a direct probe of the matcher. Must-not-tag: Stop assuming X, Drop the assumption that X, Do not assume the cleaner removes unused rows, We do not use tabs for indentation, Everyone assumes retries are idempotent, which is wrong, Never assume the queue preserves order. Must-still-tag: the same six trees reworded so the claim is stated, including The job stops at midnight and the cache supports TTL expiration. and The parser drops stale entries after a write.

That last control caught a second bug, in the veto itself: the regex was three alternatives with $ on the last one only, so branch one matched any sentence containing stop anywhere. One alternation with one shared tail now, and the case is named in the comment.

Comment thread src/capture/runtime.ts
// carries model prose too: measured, `Ship with \`npm run deploy\`.<NUL>`
// yields `matched` ending in the NUL. Flattened for the reason
// below.
matched: flattenMemoryText(avail.matched),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Scrub the matched span before normalization destroys credential recognition.

Using the synthetic README/candidate The staging access key is AKIA1234567890ABCDEF for the integration account., the capture hook writes [redacted] in both stored content and the receipt's content, but matched contains akia1234567890abcdef. The access-key-shaped value is recoverable by uppercasing. This reproduces on both 91c0f17 and 05482ba, so it is an existing gap, not a regression from the new flattening.

available.ts lowercases the span before returning it; the boundary scrubber's AKIA prefix is case-sensitive and therefore misses it. Redacting avail.matched again at this line cannot recover the lost recognition. Please derive the logged span from credential-scrubbed source text before case normalization/truncation, then flatten it, and assert the synthetic value is absent from all fields of the raw evidence line.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced on both 91c0f17 and 05482ba, as you said — an existing gap, not a regression from the flattening:

TAG  matched=[the staging access key is akia1234567890abcdef for the integration account]

Fixed as you specified: the logged span is now derived from credential-scrubbed source text before case normalisation and truncation, not scrubbed afterwards. You are right that redacting avail.matched at this line cannot recover the lost recognition, and that is exactly why the scrub moved to the raw candidate.

One placement decision worth flagging, because it is the difference between fixing this and opening another: the scrub applies to the evidence mirror only. Verdict logic still reads the unscrubbed claims, because scrubbing them there would make AKIAAAAA... and AKIABBBB... both read as [redacted], tag one as restating the other, and demote a fact that is genuinely different. matched is evidence-only — introducesNewNumber is fed content and the command spans, never this field — so the mirror costs nothing in verdicts.

The new test asserts absence from the raw line, not from the field under test, and case-insensitively:

for (const line of raw) {
  expect(line.toLowerCase()).not.toContain("akia1234567890abcdef");
  expect(line).not.toContain(SECRET);
}

It also pins the positive, so the case cannot pass because nothing was logged: the row is tagged, matched contains [redacted], and the stored content contains [redacted] rather than the key. sk- shaped tokens are covered by the same path.

…istorical rule (#403)

Both benchmark findings from the review reproduce, and both were claims the bench
made that the bench did not earn.

The seeded background rows never reached selection. `stored` filters on the
`auto-capture` tag and the seeded rows carry none, so every arm was the captured
rows plus the guided control while the report advertised 30 rows of competition.
The background is now read back from the store and included in every arm, the
shipped check judges it too, and a control asserts the non-captured set is
identical across arms so a filter cannot quietly drop it again.

`delete-original` was not the historical rule. `originalRuleRefuses` looked only
for declared commands; the module that shipped also refuses `in_tracked_file`.
Loading `362655c`'s own module against this fixture refuses all six documented
rows and ten of sixteen candidates, where the approximation caught four. The arm
now runs the pinned module, vendored verbatim with a control that compares it to
the git object, so the copy cannot drift into a story.

Numbers move accordingly and the ordering does not. Unbudgeted block 2413 to 2791
bytes; `delete-original` 13 rows and 6 of 6 documented facts retained, now 7 rows
and 0 of 6 — the historical rule deleted the documented facts it was meant to
notice, which is the finding the approximation was hiding. Transport recall at the
binding budget stays 9 for the tag arm against 5 for that baseline.

15 controls, all green, byte-identical across runs.
…its write (#404)

No test had ever asked whether a real `opencode run` turn fires a capture pass.
Every capture test builds its own event envelope and its own `session.context`,
which is exactly how this feature shipped dead while its tests passed: the
fabricated envelope is what the assertions were driving.

Two things had to be true before the question could be asked. `makeGuest` could not
pass plugin options, so `autoCapture` was unreachable from an end-to-end scenario.
And the fake provider served scenario steps only to requests carrying a tools
array, while the capture pass is a plain generation with none — so the scripted
capture reply was structurally unreachable and the pass always got the canned
answer. Both are fixed; the capture lane is recognised by the extractor prompt's
own opening line, so if that line changes the lane stops matching and the scenario
fails loudly instead of passing on a canned reply.

The answer, measured on 12 identical runs: the trigger fires and the pass starts,
12 of 12. It reaches the write gate in 3. `opencode run` disposes the plugin as the
turn ends, `captureCleanup` aborts, and the pass stops between the model answer and
the gate — the #211 contract, which is right for the teardown it was written for
and wrong here, where nothing is torn down and the process just exits. The model
answered instantly in these runs; a real model takes seconds. Filed as #404.

The scenario asserts only what that race permits and says so: the switch state on
the load line, that a real turn really started a pass, that a pass which survives
writes the candidate byte for byte with the new scan fields, and the negative
control that the same turn with the switch off fires nothing and writes nothing. It
prints `[capture-race]` when the pass is cut, so a lost run cannot be mistaken for
a pass that wrote the right thing. Five consecutive green runs; the byte-exact
assertion tightens to unconditional when #404 is fixed.

README's auto-capture status is corrected to match: the event and the pass are no
longer in doubt, the surviving write is, and the standing "never observed firing"
note now has a mechanism behind it.

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked 66dfdaa in an isolated Windows checkout. Both benchmark findings from round 2 are addressed: all 30 background rows now enter each selector arm, and the historical arm executes the original matcher. I separately compared the entire vendored module with 362655c (excluding the added header and normalizing line endings). The rerun matches the corrected tables: 47/47/41/37 rows; the historical matcher refuses 10/16 captured candidates, including all six documented facts. The transport-query ordering still holds across the five budgets. Typecheck passes.

The new real-host capture test also reproduces the failure shape in #404 here: Windows, Bun 1.4.4, opencode v2.2.7, scripted provider. Both enabled turns recorded capture_cost with text_chars=149, then no gate_start, no capture_lag and no stored row; the disabled control recorded neither capture event nor row. The suite reports 3 passing tests / 12 assertions because the write test accepts that race branch. This verifies trigger coverage and corroborates the reported loss; it does not verify a successful capture write or establish the maintainer's 12-run frequency.

The previous polarity and matched-span redaction findings remain pending: there are no src/ changes since 05482ba, so I have not duplicated those reports. Disclosure: I authored the original #211 lifecycle report and contributed earlier provenance-boundary work; this is targeted verification, not independent approval of that earlier work.

…swered (#404)

`opencode run` disposes the plugin the moment the turn ends. `captureCleanup`
aborted every in-flight pass and every pass checked that signal after the model
call, so a pass that had its answer and was on its way to the gate stopped
instead of writing. On the CLI nothing is being torn down — the store stays, no
caller waits on cleanup, the process simply exits — so the abort fired on the
healthy path, in the only window capture is allowed to run. Measured A/B/A on one
script, 12 runs each: 12/12 reached the gate, 6/12 with the fix reverted, 12/12
again. An earlier sample of the unfixed code gave 3/12; the unfixed rate moves
with load, and no unfixed sample reached 12/12.

The single signal conflated two different situations, so it is now two phases.
A pass still parked in `generate.text` is abandoned, exactly as #211 requires:
its caller may remove the store the moment cleanup resolves, and a parked
generate can outlive any bound. A pass that holds its answer is drained instead,
because what remains is the gate — local, milliseconds — and that is what the
drain is for. `PassPhase { pastModel, abandoned }` is created by the trigger
before its first await and set by the pass the instant the model resolves.

All of #211's disposal assertions pass unchanged, which is the point: the fix
narrows what gets abandoned, it does not weaken when. Nothing was added to the
evidence trail. An abandonment receipt was written and then removed — it broke
the tested "nothing at all after cleanup" contract in all four of #211's cases,
because `appendLog` calls `ensureDir` and the receipt resurrects a directory the
caller deleted. A cut pass is identified instead by the gap it already leaves: a
`capture_cost` with no later `capture_lag` for the same session.

Self-review of this diff found one gap the change itself introduced. The
between-candidates check no longer fires for a past-model pass, so a model that
returns many candidates can now run past the drain bound and write after cleanup
returned. When the bound expires the drain abandons whatever is still in flight,
so at most the gate run already in progress can land and the residual is a
constant rather than a function of the candidate count. That branch is defensive
and untested: pinning it needs a gate that is slow on purpose, and the only
lever is holding the store lock until its own acquisition times out, which tests
the lock's timeout rather than this behaviour.

`e2e/capture.test.ts` now asserts the row unconditionally, byte for byte, with
`capture_lag outcome=candidates` — the control for this fix, and probabilistic by
nature: 1 of 4 reverted runs failed, 15 of 15 fixed runs passed. The
deterministic half is the new unit case, which disposes a pass parked in the
model call and a pass that has answered and gets opposite answers from them.
…d span before it is lowercased (#403)

Both review findings reproduce on 05482ba and both were verified through the real
capture path before anything changed.

A warning that QUOTES a claim was tagged as a restatement of it (4568066706's
successor, 4568409650). `Stop assuming the cache supports TTL expiration.`
contains the affirmative sentence `The cache supports TTL expiration.`, so a
substring test plus cue equality merged the warning with the claim it warns
against, and the row's new tag could demote it under injection pressure. The
reviewer's suggested remedy — keep a predicate-sign veto — does not fix this
case: `polaritySigns` sees no negation in either string, which is the same reason
an earlier round's union re-opened the opposite defect. What works is reading the
words between the sentence start and the hit. `Stop assuming ` and `Drop the
assumption that ` govern the clause that follows; `The parser drops stale
entries.` does not, so the ambiguous verbs are veto words only when a claim noun
follows them. A vetoed hit is skipped rather than ending the search, because a
later sentence may state the claim plainly.

Self-review of that regex found it written as three alternatives with `$` on the
last one only, so the first branch matched any sentence containing `stop`
anywhere and cost the tag from `The job stops at midnight and the cache supports
TTL expiration.` — an over-decline the change itself introduced. One alternation
with one shared tail, and the case is in the comment so it stays fixed.

The logged span carried a recoverable credential (4568409660). `norm()`
lowercases before the verdict's `matched` span is cut, and the prefix scrubber in
store/secrets.ts matches `AKIA[A-Z0-9]{16}` case-sensitively, so the stored row
said `[redacted]` while the evidence line said `akia1234567890abcdef`. Redacting
`avail.matched` at the log site cannot recover recognition normalisation already
destroyed, so the scrub now runs on the raw candidate before `norm()`, for the
evidence mirror only: verdict logic still reads the unscrubbed claims, because
redacting them there would make two different access keys look like the same fact
and tag one as restating the other. The new test asserts the synthetic value is
absent from the raw evidence line case-insensitively, not merely from the field
under test.

The availability bench is unchanged by both — same 16 candidates, same 6 verdicts,
same recall at all five budgets — so neither fix costs a tag on that dataset.
@abogartz

Copy link
Copy Markdown
Owner Author

Third and fourth rounds: the teardown race, and two more P2s

Branch is at 2932672. Three commits since the last summary comment, and the first one is a bigger finding than anything in the availability change.

Writing the end-to-end capture scenario found a feature that loses its own write (#404)

No test had ever asked whether a real opencode run turn fires a capture pass. Every capture test builds its own event envelope and its own session.context — which is how this feature shipped dead while its tests passed: the fabricated envelope is what the assertions were driving. Two things had to be true before the question could be asked. makeGuest could not pass plugin options, so autoCapture was unreachable from an end-to-end scenario. And the fake provider served scenario steps only to requests carrying a tools array, while the capture pass is a plain generation with none, so the scripted capture reply was structurally unreachable and the pass always got the canned answer. Both are fixed; the capture lane is recognised by the extractor prompt's own opening line, so if that line changes the scenario fails loudly instead of passing on a canned reply.

The answer, A/B/A on one script, 12 runs each, back to back:

fixed reverted fixed
passes started (ev=capture_cost) 12/12 12/12 12/12
passes that reached the write gate 12/12 6/12 12/12

An earlier sample of the unfixed code gave 3/12, so the unfixed rate moves with load; what does not move is that no unfixed sample reached 12/12 and two fixed samples did.

opencode run disposes the plugin as the turn ends, and captureCleanup aborted every in-flight pass, so a pass that had its answer and was on its way to the gate stopped instead of writing. Nothing is being torn down on the CLI — the store stays, no caller waits on cleanup, the process exits — so the abort fired on the healthy path, in the only window capture is allowed to run. This is the leading explanation for the absence of any auto_capture_* line in the maintainer's evidence history.

PassPhase { pastModel, abandoned } splits the one signal into two phases. A pass still parked in generate.text is abandoned, exactly as #211 requires: its caller may remove the store the moment cleanup resolves, and a parked generate can outlive any bound. A pass that holds its answer is drained, because what remains is the gate — local, milliseconds — and that is what the drain is for. All of #211's disposal assertions pass unchanged, which is the point: the fix narrows what gets abandoned, it does not weaken when.

Nothing was added to the evidence trail. An abandonment receipt was written and then removed — it broke the tested "nothing at all after cleanup" contract in all four of #211's cases, because appendLog calls ensureDir and the receipt resurrects a directory the caller deleted. A cut pass is identified instead by the gap it already leaves: a capture_cost with no later capture_lag for the same session.

Self-review of that diff found a gap the change itself introduced: the between-candidates check no longer fires for a past-model pass, so a model returning many candidates can run past the drain bound and write after cleanup returned. When the bound expires the drain now abandons whatever is still in flight, so at most the gate run already in progress can land and the residual is a stated constant rather than a function of the candidate count. That branch is defensive and untested — pinning it needs a gate that is slow on purpose, and the only lever is holding the store lock until its own acquisition times out, which would test the lock's timeout rather than this behaviour.

The end-to-end scenario now asserts the row unconditionally, byte for byte, with capture_lag outcome=candidates. It is the control for this fix and it is probabilistic by nature: 1 of 4 reverted runs failed, 15 of 15 fixed runs passed. The deterministic half is a new unit case that disposes a pass parked in the model call and a pass that has already answered, and gets opposite answers from them.

The two new P2s

Both reproduce on 05482ba through the real capture path, and both are fixed in 2932672. Replies on the two threads.

False restatable tags from a warning that quotes a claim. Reproduced, including Drop the assumption that X. One correction on the suggested remedy: a predicate-sign veto does not fix these cases — polaritySigns finds no negation in either string, which is the same property that made the union re-open the round-3 defect from the other direction. What fixes it is reading the words between the sentence start and the hit. Narrowed so it does not become the over-refusal this change exists to remove, and its own regex bug (three alternatives, $ on the last one only, so branch one matched any sentence containing stop) was caught by a must-still-pass control.

Credential in the logged matched span. Reproduced on 91c0f17 and 05482ba: stored content said [redacted], the evidence line said akia1234567890abcdef. Fixed by scrubbing the raw candidate before norm(), for the evidence mirror only — scrubbing the claims used for matching would make two different access keys read as the same fact and tag one as restating the other. The test asserts absence from the raw line case-insensitively, and pins the positive so it cannot pass because nothing was logged.

State

bun test ./test/ 1352 pass / 0 fail, bun test ./e2e/ 34 pass / 0 fail, bunx tsc --noEmit clean, bun run lint exit 0. The availability bench is unchanged by the two matcher fixes — same 16 candidates, same 6 verdicts, same recall at all five budgets — so neither costs a tag on that dataset.

Not merged. #404 is filed separately and its fix is carried here, so closing it should wait on this PR.

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified 2932672 against the original capture/store probes: both stop/drop warnings now leave the row untagged, and the synthetic access-key case logs [redacted] in matched while preserving the expected tag. 151 focused tests / 442 assertions and typecheck pass; the four original probes also pass.

I exercised the drain deadline without waiting for a lock timeout: hold the daily store lock, start a two-candidate pass, wait for gate_start, await cleanup, then release the lock. Cleanup returned after 1001 ms; the in-progress gate wrote one row and the second candidate never started a gate. The no-disposal control wrote both rows. This pins the documented residual on that path (2 probes / 7 assertions).

There is a Windows harness failure below. A native-PATH control completes the strict real-host write assertion. My preceding Windows observation established the missing-row symptom, but this control shows that its attribution to teardown was confounded by the guest environment.

One factual correction to the polarity explanation: at this head, polaritySigns("Stop assuming the cache supports TTL expiration.") and polaritySigns("Drop the assumption that the cache supports TTL expiration.") each return ["neg"]; the affirmative candidate returns []. stop and drop are table entries. The current prefix fix passes the reproductions; comments saying the helper cannot see those words should reflect its actual result.

Disclosure: I authored the original #211 report and contributed earlier provenance-boundary work. These are targeted regression checks, not independent approval of that earlier work.

Comment thread e2e/capture.test.ts

/** A guest whose project is a real git repo, so grounding and availability work. */
function gitGuest(options: Record<string, unknown>): Guest {
const g = makeGuest(fake, REPO, [], options);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Give the Windows capture guest a usable Git PATH.

makeGuest sets PATH to ${dirname(bin)}:/usr/bin:/bin:/usr/sbin:/sbin. On Windows this is a Unix-delimited value with no Git directory, while gitGuest initializes the fixture using the parent process's working PATH. A child probe with the shipped environment returns Bun.which("git") === null.

On Windows / Bun 1.4.4 / opencode 2.2.7, the strict write scenario fails at line 222 (expected 1 row, got 0); evidence stops after capture_cost, text_chars=149. In a scratch copy changing only g.env.PATH to the native Windows PATH, it passes all 7 assertions and records gate_start, write_promoted, auto_capture_scan and capture_lag outcome=candidates. Switching back fails again. This is a guest-environment confounder, so the missing-row trace alone cannot identify the teardown race.

Please construct the guest PATH using the platform delimiter and required executable locations, and verify Git resolution inside the guest, so this new capture scenario runs under the same tool prerequisites as its fixture setup.

…controls that bite (#402)

The runner's own header said "its case bank does not [exist]". It does now, and
writing the rest of it found two defects in the bench itself, which is what the
controls were for.

Case bank: `bench/fixtures/availability-cases.ts`, 21 (tree, candidate) pairs
covering every adversarial verdict this matcher has been found guilty of across
#397 rounds 2-4, #402 and the three #403 review rounds, each in its own repo —
sharing one tree would let a candidate match a different case's line and report a
verdict for the wrong reason. The unit tests pin behaviour one case at a time; the
bank says whether the POPULATION of verdicts moved, because one flipped verdict
changes the tag rate and therefore every number in the report. One expectation was
wrong when written: `Run \`npm run deploy\` to rsync against the box.` is not
tagged, because the residual is checked too. That boundary is now two cases
instead of one wrong one.

Ceiling: the bench had a control proving a hit can be MISSED (a header-only budget
scores 0) and nothing proving one can be FOUND. Adding the positive direction
showed 7 of the 21 curated transport queries retrieve their gold when that gold is
the ONLY row in the store, so "9/21" was never 43% recall. The report now states
the ceiling beside the recall figures and a control goes red if a query family goes
wholly blind. Filed as #405 with the mechanism named: `scoreMemories` requires two
shared tokens for any query of three or more, and m02 shares exactly one —
`throttling`, an exact keyword hit — and is discarded.

Two defects the new controls caught, both in the harness:

- Verdicts were keyed on `ts`. `ts` is not unique: the 16 rows one pass writes
  land in the same millisecond, so the map held one entry for all of them and
  every lookup returned whichever row was written last. The byte column had been
  reading absent verdicts as restatable. Keyed on content now, which is what the
  check is a function of.
- `restatableBytes` summed bytes over all 21 queries and was labelled "in block".
  It is a per-block mean now, and labelled as one.

Two more measurements, because both were claimable and neither had been tested:

- Store size. The background is resampled at 0/30/90/180 rows with the budget
  recomputed per size. The ordering holds at every size and every budget, so the
  win is not an artefact of one competitor count.
- A fifth arm, `drop-at-read`, previews P3: the row is stored and a read never
  shows it, background included. It matches the tag arm's transport recall at all
  five budgets and spends 0 bytes on facts the tree states — and answers 0 of 6
  doc queries at every budget, including the loosest, where the tag arm answers 6.
  That is the price of a read-time drop, measured, which is what P5 has to decide
  against.

Controls 15 -> 21, all green, byte-identical across runs. Each new control was
mutated and verified to fail with a named reason: arm built wrong, one bank
expectation flipped, hit metric forced blind.
@abogartz

Copy link
Copy Markdown
Owner Author

Bench deepened: a case bank, a ceiling, and two defects in the harness

Branch is at 8db41b9. No production code changed in this round — the point was to make the bench able to fail in ways it could not before, and it failed twice on the first run.

The case bank (closes the gap this runner's header declared)

bench/fixtures/availability-cases.ts: 21 (tree, candidate) pairs covering every adversarial verdict this matcher has been found guilty of across #397 rounds 2–4, #402 and the three review rounds on this PR, each in its own repo. One repo per case is not tidiness — sharing a tree lets a candidate match a different case's line and report a verdict for the wrong reason, which is the exact failure mode this file exists to keep out.

The unit tests pin behaviour one case at a time. The bank answers a question they cannot: did the population of verdicts move? One flipped verdict changes the tag rate and therefore every recall number in the report.

Writing it caught one of my own expectations being wrong. I asserted Run \npm run deploy` to rsync against the box. would tag against a manifest that states the command. It does not: the residual is checked too, and a reworded residual is kept. That boundary is now two cases (declared-command-reworded-residual, declared-command-new-context`) instead of one wrong one.

The ceiling — and what it says about every recall figure above

The bench had a control proving a hit can be missed (a header-only budget scores 0). It had nothing proving a hit can be found. Adding the positive direction:

7 of the 21 curated transport queries retrieve their own gold when that gold is the only row in the store.

Not "lose to competition" — the selector returns nothing. So 9/21 was never 43% recall; the achievable maximum is 14, and the best arm reaches 9. The report now prints the ceiling beside the recall figures, and a control goes red if a query family goes wholly blind.

Mechanism, named in #405: scoreMemories requires two shared tokens for any query of three or more. m02 shares exactly one — throttling, an exact authored-keyword hit — and is discarded for want of a second. Filed as #405 with all seven pairs and the token counts.

Two defects in the bench, both caught by the new controls

Verdicts were keyed on ts. ts is not unique: the 16 rows one pass writes land in the same millisecond, so the map held one entry for all of them and every lookup returned whichever row was inserted last. The byte column had been reading absent verdicts as restatable; the new drop-at-read arm deleted all 16 captured rows because six of them were restatable. Keyed on content now, which is what the check is a function of. The control that caught it asserts an arm that filters by verdict keeps the rows it must keep — transport golds are not restatable, that is the whole premise of the tag policy, so an arm dropping them is scoring a bug.

restatableBytes summed bytes over all 21 queries and was labelled "in block". A number that looked like a block size and was twenty-one of them. It is a per-block mean now, and labelled as one.

Two measurements that were claimable and untested

Store size. Background resampled at 0/30/90/180 rows, budget recomputed per size:

background off tag drop-at-read delete-hardened delete-original
0 7/9/9 8/9/9 8/9/9 8/9/9 5/5/5
30 7/9/9 8/9/9 8/9/9 8/9/9 5/5/5
90 7/9/9 7/9/9 7/9/9 7/9/9 4/5/5
180 8/9/9 8/9/9 8/9/9 8/9/9 4/5/5

The ordering holds at every size and budget. The win is not an artefact of one competitor count.

drop-at-read, previewing P3. The row is stored and a read never shows it — applied to the background too, because a read-time drop would not know which rows capture wrote.

transport recall restatable bytes per block doc facts answered
tag 7,8,9,9,9 20,41,41,48,54 0,0,0,0,6
drop-at-read 7,8,9,9,9 0,0,0,0,0 0,0,0,0,0

Equal transport recall at every budget, zero bytes spent on facts the tree states — and 0 of 6 doc queries at every budget including the loosest, where the tag arm answers 6. A demoted row can still win its own question when the budget allows; a dropped row never can. That is the price of P3, measured, which is what P5 has to decide against.

Controls

15 → 21, all green, byte-identical across two runs. Each new control was mutated and verified to fail with a named reason: arm built wrong (keeps 0/10 transport facts), one bank expectation flipped (DRIFTED: verbatim-restatement expected keep, got tag), hit metric forced blind (0/21 transport … a wholly blind family reports 0 in every arm). Exit code 1 on each.

bun test ./test/ 1352 pass / 0 fail, bunx tsc --noEmit clean, bun run lint exit 0.

Not merged.

`.github/workflows/ci.yml` runs no bench, so the 21 adversarial verdicts in
bench/fixtures/availability-cases.ts would fail nothing but a command nobody is
required to type. This is the same bank, asserted, inside `bun test` — 22 tests,
about 1 s.

One case per entry rather than one aggregate assertion: a failure names the case
and the review round that found it, where "19/21" would leave the reader to work
out which veto moved. Verified by flipping one expectation:

  (fail) availability: verbatim-restatement
  #389 — the rule's only true positive — expected no verdict (keep the row),
  got in_tracked_file matched [reorder is inclusive]

The bank's own shape is asserted too — at least 3 must-tag and 6 must-not cases,
unique ids — because a bank of one polarity passes on a check that decides
nothing.
@abogartz

Copy link
Copy Markdown
Owner Author

Follow-up 3697244: the case bank now runs inside bun test (test/availability-case-bank.test.ts, 22 tests, ~1 s). CI runs no bench, so the 21 adversarial verdicts would otherwise fail nothing but a command nobody is required to type. Verified red by flipping one expectation:

(fail) availability: verbatim-restatement
#389 — the rule's only true positive — expected no verdict (keep the row), got in_tracked_file matched [reorder is inclusive]

One case per test, not one aggregate assertion, so a failure names the case and the review round that found it.

Writing the bank's coverage of the command half raised a question the code
answers and no test did: `statedCommands` reads only backticked spans
("the backticked spans, which is how this plugin writes them"), so a candidate
that names a declared command in prose is never matched by the command half of
the check. That is a false negative in the safe direction — a row that should be
demoted is kept — and it was invisible: nothing in the repo said which side of
the check depends on formatting.

Two cases, 21 -> 23:

- `prose-command-not-a-code-span` pins the limit.
- `prose-restatement-still-tags` is its counterpart, pinning that the TEXT half
  has no such dependency: prose restatement of a tracked sentence is still
  caught. Paired, they say which half the limit belongs to; either alone says
  nothing.

Both decided by the shipped check as written, not as intended: the bank records
what the matcher does, and a future change to prose-command handling turns
`prose-command-not-a-code-span` red with the reason in its own `source` string.

21 controls green, report byte-identical across runs, 1376 unit tests pass,
tsc clean, lint exit 0.

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the benchmark changes through 3bf0b69, including the CI case-bank addition. The unmodified benchmark passes all 21 controls; the new case-bank suite passes 24 tests / 27 assertions. The two inline findings concern what those checks actually exercise: the recall denominator uses different row metadata, and declared-command matching can be disabled without either check failing. These do not reverse the observed transport-query ordering.

The Linux smoke run on 3697244 also fails the strict capture write assertion (e2e/capture.test.ts:222: expected 1 row, received 0). The subsequent smoke run on 3bf0b69 passes, with no runtime/test-harness change between those heads. This is intermittent evidence distinct from the previously reported Windows guest-PATH defect; these logs alone do not establish its cause.

Disclosure: I authored the original #211 report and contributed earlier provenance-boundary work. This is targeted verification, not independent approval of those earlier contributions.

scope: "widget-api",
content,
status: "settled",
...(kwId ? { kw: storeRows.get(kwId)?.kw } : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Measure the recall ceiling with the same rows the policy arms retrieve.

solo(..., q.gold) adds authored kw metadata from buildStore(600), but none of the 16 captured rows used by the measured arms has those keywords. Replaying each query against its actual captured gold row alone gives 9/21 hits, versus the reported 14/21. Adding only kw to those same actual rows reproduces all five extra hits (m05, m07, m10 and both m11 queries), so this is not a competition/budget loss.

Consequently the README/report's 9/14 mixes a measured numerator with a different representation's ceiling. Please derive the ceiling from the exact stored rows, or add keywords consistently to all measured arms and rerun. Overall recall remains 9/21 on this curated set; a conditional “of retrievable pairs” metric should be labelled separately. The observed ordering across policy arms still holds.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced, and you were right. Fixed in 03e00df, and following the cause to the end turned up a second defect you had not seen yet — in the fixture rather than the reporting — fixed in 32d2148.

Confirmed. Recomputing the ceiling against the exact captured rows gives 9/21, matching your number; with the dataset's authored kw it gives 14/21. The delta is exactly the five you named — m05, m07, m10 and both m11 queries — so it is a representation difference, not competition or budget. capturedWithKw is now counted and printed, so this cannot silently recur.

The cause was upstream of what you flagged. src/capture/prompt.ts asks the model for "3-5 search keywords for how a DIFFERENT session would ask for this", candidates.ts cleans them, runtime.ts persists them. The scripted reply in this runner emitted none — so every arm was measured on rows production would not write. Your finding was about the ceiling; the deeper problem was that the fixture was unfaithful in a way that moved the ceiling by five queries.

With the fixture corrected, the win gets stronger and simpler:

budget off / tag / drop-at-read / delete-hardened / delete-original
15% 14 / 14 / 14 / 14 / 7
25% 14 / 14 / 14 / 14 / 7
40% 14 / 14 / 14 / 14 / 7
60% 14 / 14 / 14 / 14 / 7
85% 14 / 14 / 14 / 14 / 7

The tag arm delivers the whole achievable ceiling (14/14) at every budget and every store size; the original rule delivers 7 of 14 at every one. The budget still binds — on the restatable rows, which is what the policy is for: the tag arm gives up 5 to 6 of 6 doc queries at 15–60% and recovers them at 85%.

Both numbers are printed, neither averaged. The prompt permits omitting keywords ("Omit (or []) when the content already uses those words"), so the report also strips the 10 lists the reply carried and prints the ceiling that produces — 9/21 — and names the five pairs that are load-bearing on keywords. No conditional metric is folded into a recall figure anywhere.

Knock-on. #405 was filed from the kw-injected measurement. Its mechanism (LONG_QUERY_TOKENS = 3, needShared = 2) is unchanged, but the blind count is representation-dependent and the issue needed that stated. Correcting it now.

Comment thread test/availability-case-bank.test.ts Outdated
function repoFor(name: string, tree: string): string {
const dir = join(root, name);
mkdirSync(dir, { recursive: true });
writeFileSync(join(dir, "README.md"), tree);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Give the declared-command cases actual command declarations.

repoFor writes every case's tree to README.md only; the benchmark case-bank helper does the same. There is no package.json/Makefile declaration for the cases named *-on-declared-command. Even declared-command-restated earns in_tracked_file, so those cases do not exercise the declared-command branch they name.

As a mutation check, I replaced only const gate = gateHit(spans, gates) with a null gate in a scratch checkout. All 21 benchmark controls still passed, and these 24 CI tests still passed (27 assertions). A separate repo containing only tracked package.json with scripts.deploy = "rsync dist/ box:/srv" proves the mutation matters: Run `npm run deploy`. changes from declared_gate to null.

Please let cases specify their tracked files, include a positive that must return declared_gate, and pair it with restriction/new-number/second-command negatives against the same actual declaration. As written, this bank stays green if that functionality disappears.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reproduced exactly, and it was worse than "does not exercise the branch". Fixed in 03e00df.

Confirmed. The bank's own reason histogram, printed before the fix: 16 none, 7 in_tracked_file, 0 declared_gate. repoFor wrote every case's tree to README.md, and parseGates reads only package.json, Makefile, makefile, justfile and .github/workflows/*.yml — so nothing was ever declared.

The part that should have stopped the build. Five of those cases are the veto cases — prohibition-on-declared-command, restriction-on-declared-command, short-restriction-on-declared-command, second-command-not-swallowed, new-number-on-declared-command. They assert expectTag: false. With no gate present they return none because nothing matched at all, not because a veto refused. So they were not merely testing the wrong branch; they were passing for a reason that would still hold if every veto in available.ts were deleted. That is false assurance in the one place this PR's behaviour actually changed.

Fixed as suggested, plus a control that does not depend on any case being right:

  • AvailabilityCase gains files: Record<string, string> and expectReason?: "in_tracked_file" | "declared_gate".
  • The gate family declares scripts.deploy in a real package.json, against a README that states nothing about deploying, so a declared_gate verdict cannot be imitated by prose.
  • A second gate source is added (Makefile target) so the bank does not silently depend on package.json alone.
  • expectReason is asserted where set, and two new controls: a case that names a branch must get that branch, and both branches must appear in the population at least twice.

Your mutation, re-run. const gate = gateHit(spans, gates) → const gate: Gate | null = null:

(fail) availability: declared-command-restated
(fail) availability: make-target-restated
(fail) the case bank reaches both branches of the check
- FAIL — the shipped matcher still decides every adversarial case: 23/25 — DRIFTED: …
- FAIL — every case that names a branch gets that branch: 3 branch-pinned cases, 2 answered by the other half …
- FAIL — the bank reaches both branches of the check: 0 declared_gate and 6 in_tracked_file verdicts

Three CI test failures and three bench controls, where before it was 24 tests and 21 controls green.

One of my own expectations was wrong while writing this. I added make-target-restated as "Run make test before merging." → tag. It does not tag: the target is declared, the when is not. Split into make-target-restated (tags, declared_gate) and make-target-new-condition (kept). Bank 23 → 25 cases, controls 23 → 25, all green; 1379 unit tests pass.

…ench cannot measure (#402)

The report asserted, in prose, that a row is tagged because the tracked tree
states the fact. Nothing tested it. Now something does, and writing it turned a
number that read well into a number with its cause attached.

New control — every marked row must share substantive words with the tracked
tree, read back from `git ls-files` the way the check reads it. Both halves were
mutated and verified red:

  - FAIL — every marked row is supported by the tracked tree: 6 marked of 196
    rows, 6 with no substantive word in common — which redis db the rate limiter
    uses is | the healthz readiness probe is wired to | ...
  - FAIL — ... 0 marked of 196 rows ... — RED if a row is marked on nothing, or
    if nothing is marked at all

The second half is not decoration. `markedAll.length > 0` is what stops the
first clause passing vacuously, which is exactly how a check that stopped
marking anything would read: green.

New report paragraph — where the tag lands:

  6 of 16 rows this pass wrote carry it (38%), against 0 of 180 rows already in
  the store (0%).

The 0 is the kind of number a report should not print without its cause. The
cause is measured too: 0 of the 180 seeded rows quote a sentence of the tracked
tree, so there was nothing there for the check to find. It is a fixture
artefact, not a base rate, and no real-world base rate is claimed — that needs a
store written in the same repo it is read from. The sentence is built by a
conditional so it cannot outlive the number that makes it true.

Controls 21 -> 22, all green, report byte-identical across runs. Runner header's
MUST-GO-RED list now names the scoring-validity and case-bank controls it had
left out. 1376 unit tests pass, tsc clean, lint exit 0.
@abogartz

Copy link
Copy Markdown
Owner Author

Third bench round on this branch (3697244..a2e6c2c). No production code changed; the point was to give the harness ways to fail that it did not have. It found one new thing about the policy and one thing the report was asserting without testing.

The tag's own claim is now tested

The report said, in prose, that a row is tagged because the tracked tree states the fact. Nothing tested it. Now something does: every marked row must share substantive words with the tree, read back from git ls-files the way the check reads it. Both halves mutated red:

- FAIL — every marked row is supported by the tracked tree: 6 marked of 196 rows,
  6 with no substantive word in common — which redis db the rate limiter uses is |
  the healthz readiness probe is wired to | ...
- FAIL — ... 0 marked of 196 rows ... — RED if a row is marked on nothing, or if
  nothing is marked at all

The second half is not decoration. markedAll.length > 0 is what stops the first clause passing vacuously — which is precisely how a check that had stopped marking anything would read: green.

A number that read well, and the cause attached to it

New report paragraph:

Where the tag lands. 6 of 16 rows this pass wrote carry it (38%), against 0 of 180 rows already in the store when the pass ran (0%).

That 0 flatters the check and I am not going to print it bare. The cause is measured in the same run: 0 of the 180 seeded rows quote a sentence of the tracked tree, so there was nothing there for the check to find. It is a fixture artefact, not a base rate, and no real-world base rate is claimed — that needs a store written in the same repo it is read from. The sentence is built by a conditional so it cannot outlive the number that makes it true.

The code-span dependency, recorded as a limit

statedCommands reads only backticked spans ("the backticked spans, which is how this plugin writes them"). So a candidate that names a declared command in prose is never matched by the command half of the check. False negative, safe direction — a row that should be demoted is kept — and until now nothing in the repo said which half of the check depends on formatting. Two cases, 21 → 23:

  • prose-command-not-a-code-span pins the limit;
  • prose-restatement-still-tags is its counterpart, pinning that the text half has no such dependency. Paired they say which half the limit belongs to; either alone says nothing.

Both decided by the shipped check as written, not as intended. If prose-command handling ever changes, the first case goes red with the reason in its own source string.

The bank now runs where CI can see it

.github/workflows/ci.yml runs no bench at all, so 21 adversarial verdicts would fail nothing but a command nobody is required to type. test/availability-case-bank.test.ts is the same bank inside bun test — one test per case, so a failure names the case and the review round that found it:

(fail) availability: verbatim-restatement
#389 — the rule's only true positive — expected no verdict (keep the row), got in_tracked_file matched [reorder is inclusive]

State

Controls 21 → 22 this round (15 before the deepening began), all green, report byte-identical across runs, every new control verified red by deliberate mutation. 1376 unit tests pass, bunx tsc --noEmit clean, bun run lint exit 0.

Still open, unchanged by this round: #403 is not merged and will not be without your explicit approval.

…an give back (#402)

The report claimed a row is tagged because the tracked tree states the fact. Two
things follow from that claim and neither had been measured: the verdict must
follow the tree, and a policy that decides at read time can change its mind when
the tree does.

New section, on a COPY of the repo so every arm above keeps the tree it was
measured against:

| tree state | rows still marked |
| --- | ---: |
| as shipped | 6 |
| README prose emptied, manifests intact | 0 |
| prose and declared commands both emptied | 0 |

All 6 verdicts came from the prose and disappear with it. Nothing survives an
empty tree, which is the control:

  - FAIL — the verdict follows the tree, not the row: 6 rows marked against the
    shipped tree, 6 still marked with the README prose emptied, 6 with the tree
    emptied entirely — RED if anything survives an empty tree, because then the
    tag is justified by something the tree has nothing to do with

Verified red by forcing the probe to ignore the tree; exit 1.

The second half is the finding, and it belongs to P5 rather than to this change.
A read-time drop re-asks the question on every read, so a row whose tracked
sentence has since been deleted becomes retrievable on its own again. A deleted
row has no such moment: the tag arm holds 197 rows, the hardened arm 191 and the
original 187, and the 6 and 10 rows those arms never wrote stay unwritten
whatever the tree later says. That is the first number in this epic that argues
for P3 on something other than bytes.

Controls 22 -> 23, all green, report byte-identical across runs. 1376 unit tests
pass, tsc clean, lint exit 0.
@abogartz

Copy link
Copy Markdown
Owner Author

Fourth bench round (25c1fe2). This one tests the tag's justification, and produces the first number in the epic that argues for P3 on grounds other than bytes.

The claim, tested

The report says a row is tagged because the tracked tree states the fact. Two things follow and neither had been measured: the verdict must follow the tree, and a policy that decides at read time can change its mind when the tree does.

New section, run on a copy of the repo so every arm above keeps the tree it was measured against:

tree state rows still marked
as shipped 6
README prose emptied, manifests intact 0
prose and declared commands both emptied 0

All 6 verdicts came from the prose and disappear with it. Nothing survives an empty tree, which is the control:

- FAIL — the verdict follows the tree, not the row: 6 rows marked against the shipped
  tree, 6 still marked with the README prose emptied, 6 with the tree emptied entirely
  — RED if anything survives an empty tree, because then the tag is justified by
  something the tree has nothing to do with

Verified red by forcing the probe to ignore the tree; exit 1.

Why this is a P5 number, not a bench curiosity

A read-time drop re-asks the question on every read. A row whose tracked sentence has since been deleted becomes retrievable on its own again. A deleted row has no such moment: the tag arm holds 197 rows, the hardened arm 191, the original 187 — and the 6 and 10 rows those arms never wrote stay unwritten whatever the tree later says.

So the two policies are not ordered by bytes alone. drop-at-read costs the 6 doc queries at every budget (round 3's finding) and buys back the ability to be wrong temporarily. delete is the only arm where a false verdict is permanent. If P5 keeps the gate at all, that asymmetry is the argument for deciding at read time.

State

Controls 22 → 23, all green, report byte-identical across runs. 1376 unit tests pass, bunx tsc --noEmit clean, bun run lint exit 0. CI: lint, smoke, test green; test-windows informational.

Nothing here changes the production diff. #403 stays open and unmerged pending your approval.

…he gate cases use a real gate (#402)

Both reproduced before anything was changed, and both were worse than they
looked.

CEILING. `solo(..., q.gold)` put the dataset's authored `kw` on a synthetic row.
The 16 rows the arms actually retrieve carry none — the scripted capture reply
emits no keywords, now counted in the report (0 of 16). Adding only `kw` turns 5
of the 12 blind queries around, so the reported 14/21 was a ceiling for a
representation no arm holds, and "9/14" mixed a numerator from one with a
denominator from the other. Measured on the exact captured rows the ceiling is
9/21, and the best arm reaches 9/9 — at the achievable maximum, which is a
stronger claim than the one it replaces and one the old number hid. Both ceilings
are printed and labelled; neither is averaged with the other.

GATE CASES. `repoFor` wrote every case's tree to README.md, so no case named
`*-on-declared-command` declared anything: `parseGates` reads `package.json`,
`Makefile`, `makefile`, `justfile` and `.github/workflows/*.yml`, and the text
branch answered all seven instead. The bank's own histogram said so — 16 none, 7
in_tracked_file, 0 declared_gate — which also means the five veto cases in that
family passed because nothing matched at all, not because a veto refused. A
mutation replacing `gateHit(spans, gates)` with a null gate left 24 CI tests and
21 bench controls green.

Fix: `AvailabilityCase` gains `files` and `expectReason`; the gate family declares
`scripts.deploy` in a real manifest against a README that cannot match; a second
gate source (`Makefile` target) is added so the bank does not depend on
package.json alone; and two controls pin it — a case that names a branch must get
that branch, and both branches must appear in the population at least twice.
Re-running the reviewer's mutation now fails in both places:

  (fail) availability: declared-command-restated
  (fail) availability: make-target-restated
  (fail) the case bank reaches both branches of the check
  - FAIL — the bank reaches both branches of the check: 0 declared_gate and
    6 in_tracked_file verdicts — RED if either drops below 2

Writing the Makefile case caught a wrong expectation of mine: "Run `make test`
before merging." is NOT restatable, because the WHEN is new information. Split
into `make-target-restated` (tags, `declared_gate`) and `make-target-new-condition`
(kept). Bank 23 -> 25 cases, controls 23 -> 25, 1379 unit tests pass, tsc clean,
lint exit 0, report byte-identical across runs.
…mpt asks for (#402)

Chasing the ceiling finding to its cause turned up a defect in the fixture rather
than in the reporting, and fixing it changes every recall number in the file.

`src/capture/prompt.ts` asks the model for "3-5 search keywords for how a
DIFFERENT session would ask for this", `candidates.ts` cleans them and
`runtime.ts` persists them. The scripted reply in this runner emitted none, so
every arm was measured on rows production would not write. That is why the
ceiling looked like a scorer question when part of it was a fixture question.

With the authored keyword lists in the reply:

| budget | off / tag / drop-at-read / delete-hardened / delete-original |
| --- | --- |
| 15% | 14 / 14 / 14 / 14 / 7 |
| 25% | 14 / 14 / 14 / 14 / 7 |
| 40% | 14 / 14 / 14 / 14 / 7 |
| 60% | 14 / 14 / 14 / 14 / 7 |
| 85% | 14 / 14 / 14 / 14 / 7 |

The win gets stronger and simpler: the tag arm delivers the whole achievable
ceiling at every budget and every store size, and the original rule delivers 7 of
14 at every one of them. The budget still binds — on the restatable rows, which is
what the policy is for: the tag arm gives up 5 to 6 of 6 doc queries at 15-60% and
recovers them at 85%.

Two things are now stated rather than hidden:

- The counterfactual. The prompt permits omitting keywords ("Omit (or []) when the
  content already uses those words"), so the report strips the 10 lists the reply
  carried and prints the ceiling that produces: 9/21. Keywords are load-bearing for
  5 of these pairs, and a reader can now see that instead of inheriting it.
- What the size sweep can show. With keyword-bearing rows the transport column
  saturates for every arm that keeps its rows, so the sweep proves the DELETE
  arms' loss is size-independent, not that tag's margin grows with the store. The
  control text says so rather than letting a flat table imply more than it does.

Controls 25, all green; report byte-identical across runs; 1379 unit tests pass;
tsc clean; lint exit 0.

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rechecked 03e00df on native Windows. Both benchmark findings from my previous review are addressed in the current fixture:

  • The measured arms' captured rows give a solo ceiling of 9/21, and the separately labelled authored-keyword experiment gives 14/21. The tag arm reaches 9/21 overall, or 9/9 of the pairs this representation can retrieve.
  • The bank now reaches declared_gate through real package.json and Makefile declarations. Repeating the original null-gate mutation now fails the two positive cases plus branch coverage: 3 failing tests and 3 failing benchmark controls, both commands exit 1. Unmodified: 27 tests / 34 assertions, 25 benchmark controls, and typecheck pass.

Separate Windows CI triage, not attributed to this benchmark diff: attempt 1 and attempt 2 on 5780d8c both start failing at test/concurrency.test.ts:128. The error is memory store is busy … locked for 5002ms — retry, from the in-process lock-queue deadline at src/store/lock.ts:298; this test already has a 30-second Bun budget. The reader assertions are never reached, so these logs do not establish a torn read. Subsequent ENOENT/unhandled errors and five more failures follow that rejection. The same test/lock files are unchanged through this head.

Locally, concurrency plus bounded-session-ledgers pass 12 tests / 283 assertions under --parallel=4; I have not reproduced the hosted failure under ordinary local load. This is distinct from the previously reported Windows E2E guest-PATH defect, which remains unchanged.

This is targeted verification and CI triage, not independent approval of earlier code I contributed.

…re (#402, #406)

The push that would have carried the bench round was blocked by this file's own
e2e test, so the test got investigated instead of overridden.

Reproduced: `bun test ./e2e/ --parallel=4` failed this test in 2 of 8 runs; the
file alone passed 6 of 6. The kept guest directories show why, and it is not
#404. A failing run's evidence is complete and stops here:

  ev=plugin_load … ev=epoch_recompute … ev=tool_result …

No `capture_cost`. No `capture_lag`. Nothing blocked. The pass never started, so
the availability check, the write gate and the two-phase drain were never
reached — the signature of #404 is `capture_cost` present with no
`write_promoted`, and that is not what this is. Capture subscribes to
`session.execution.succeeded` / `interrupted`; under load the host can exit
before that reaches the plugin. Filed as #406, with the reason it matters: no
evidence line means a disabled capture, a capture that found nothing, and a
capture that never fired are three indistinguishable states.

The test was asserting something it cannot guarantee, and every future push would
have paid for that in re-runs. `turnUntilCaptureStarts()` now retries the real
turn up to four times, asserts a pass started within them — so a capture that is
genuinely dead fails outright instead of passing vacuously — and prints the
attempt count:

  [capture-start] test 2: pass started on attempt 1
  [capture-start] test 2: pass started on attempt 2

8 of 8 parallel runs green afterwards, 2 of them on the second attempt, so the
retry is carrying real weight and the rate is visible in the log rather than
re-run away. The byte-for-byte teardown assertion is unchanged and still
unconditional once a pass has started; the deterministic half stays in
test/capture-dispose-drain.test.ts.

1379 unit tests pass, 34 e2e pass, tsc clean, lint exit 0.
@abogartz

Copy link
Copy Markdown
Owner Author

The push that carried the bench round was blocked by this PR's own e2e test, so the test got investigated instead of overridden. That turned out to be worth more than the round it delayed.

What the gate actually caught

bun test ./e2e/ --parallel=4 failed the pass survives host teardown and writes the candidate byte for byte in 2 of 8 runs. The file alone: 0 of 6. So it was load-dependent, not random.

KEEP=1 kept the guest directories, and the evidence trail says it is not #404:

# working
ev=plugin_load … ev=epoch_recompute … ev=tool_result …
ev=capture_cost … trigger=idle … ev=gate_start … ev=write_promoted … ev=capture_lag … outcome=candidates

# failing, in full
ev=plugin_load … ev=epoch_recompute … ev=tool_result …

No capture_cost. No capture_lag. Nothing blocked. The pass never started — capture subscribes to session.execution.succeeded / interrupted, and under load the host exits before that reaches the plugin. #404's signature is the opposite: capture_cost present, no write_promoted. The availability check, the write gate and the two-phase drain were never reached, so nothing in #403 or #404 is implicated.

Why it is worth an issue and not just a retry

No evidence line means three states are indistinguishable from the log: capture disabled, capture ran and found nothing, capture never fired. That is the failure class that shipped this feature dead once before. Filed as #406, with the measurements, both signatures, and the open question — whether the host awaits plugin handlers for the turn-end event before tearing down, or dispatches and exits.

What changed in the test

It was asserting something it cannot guarantee, and every future push would have been paid for in re-runs. turnUntilCaptureStarts() retries the real turn up to four times, asserts a pass started within them — so a genuinely dead capture fails outright instead of passing vacuously — and prints the attempt count:

[capture-start] test 2: pass started on attempt 1
[capture-start] test 2: pass started on attempt 2

8 of 8 parallel runs green after the change, 2 of them on the second attempt. The byte-for-byte teardown assertion is unchanged and still unconditional once a pass has started; the deterministic half stays in test/capture-dispose-drain.test.ts.

Also in this round, from the two P2 findings

Both reproduced first. 03e00df measures the ceiling on the rows the arms actually hold and gives the gate cases real declarations — the reviewer's null-gateHit mutation now fails 3 CI tests and 3 bench controls where it previously left 24 tests and 21 controls green. 32d2148 follows the ceiling finding to its cause: the scripted capture reply emitted no keywords, while src/capture/prompt.ts asks for them and the write path persists them, so every arm was measured on rows production would not write. With the fixture corrected the win is stronger — tag delivers the whole achievable ceiling (14/14) at every budget and store size, the original rule delivers 7 of 14 — and the keyword-free counterfactual (9/21) is printed beside it. #405 corrected for the same distinction.

State

b5df1fa, MERGEABLE. lint, smoke, test green; test-windows informational. 1379 unit tests, 34 e2e, 25 bench controls, tsc clean, lint exit 0, report byte-identical across runs.

Not merged. Nothing here changes production code.

@WhollyMindless WhollyMindless left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked b5df1fa on native Windows. The revised scripted keyword fixture reproduces the 14/21 solo ceiling and 9/21 keyword-free counterfactual; all 25 benchmark controls, 34 focused tests / 48 assertions, and typecheck pass.

One new finding below concerns what the E2E retry can establish. Two isolated probes / 11 assertions reproduce a delivered turn-end event and an entered model call with no capture_cost after disposal; the otherwise identical live control writes the row. This is a counterexample to the new diagnosis, not a reproduction of the macOS/CI failure's cause.

Disclosure: I reported #211 and contributed earlier provenance-boundary code; this is targeted verification, not independent approval of that earlier work.

Comment thread e2e/capture.test.ts
}
if (withEv(ev, "capture_cost").length > 0) return { ev, started: attempt };
}
return { ev, started: 0 };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Keep a missing cost receipt distinct from a missing trigger.

capture_cost is recorded only after generate.text resolves and the phase.abandoned check (src/capture/runtime.ts:620-647). Consequently this loop retries some passes that did start and were abandoned during teardown, as well as passes whose trigger never arrived.

On this head, a deterministic scratch probe pushes session.execution.succeeded, waits for one context read and one model call, disposes while that call is parked, then releases it. The entire evidence sequence is plugin_load, tool_result: no capture_cost, no capture_lag, no row. Releasing the same call without disposal produces the receipt, gate, row and completion line. Both probes pass (11 assertions).

Thus this trace does not establish the missing-event cause stated in the new header and failure message, or exclude a pre-answer teardown path. The printed attempt count measures reaching the post-model receipt, not event delivery. Please either use an earlier test-only observation to classify the attempts, or describe this as a post-model checkpoint and leave the missing-receipt cause unresolved. The bounded retry can remain a deliberate test policy; it should not direct #406's investigation away from a path that produces the identical trace.

@abogartz
abogartz merged commit f34d6bb into main Nov 14, 2026
4 checks passed
abogartz-opencode-self-improvement Bot pushed a commit that referenced this pull request Nov 14, 2026
# [0.25.0](v0.24.2...v0.25.0) (2026-11-14)

### Bug Fixes

* **bench:** measure the ceiling on the rows the arms hold, and make the gate cases use a real gate ([#402](#402)) ([03e00df](03e00df))
* **capture:** report availability verdicts and tagged rows as two numbers ([#403](#403)) ([91c0f17](91c0f17))
* **capture:** stop teardown abandoning a capture pass that already answered ([#404](#404)) ([e12c8a3](e12c8a3)), closes [#211](#211)
* **capture:** stop the polarity union adding tags, and give `restatable` a lifecycle ([#403](#403)) ([05482ba](05482ba)), closes [#397](#397)
* **capture:** veto a warning that quotes a claim, and scrub the logged span before it is lowercased ([#403](#403)) ([2932672](2932672))

### Features

* **capture:** tag restatable rows instead of dropping them ([#402](#402)) ([5780d8c](5780d8c)), closes [#389](#389) [#397](#397) [#397](#397)
* **capture:** the [#389](#389) availability gate, as shipped by [#397](#397) ([2fe2287](2fe2287)), closes [#402](#402)
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.25.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@abogartz
abogartz deleted the 402-availability-restatable branch November 19, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The availability gate refuses nothing and costs a tree scan: make refusal a label, then decide if it exists

3 participants