Repository navigation
Description
Problem
src/capture/available.ts (from #397, implementing #389 criterion 1) refuses a capture candidate when it concludes the next session could read the fact in the working tree. Four adversarial review rounds on #397 each found the same defect: text that was merely short or partly matched was treated as already known, and a genuinely new fact was dropped silently.
Measured on this repo, 2026-11-13, against the live store:
| Measurement | Result |
|---|---|
Real captured rows the shipped gate (1930bf6) refuses |
0 of 1166 |
Rows the original rule (362655c) refused |
30 (2.6%) |
| Of those 30, genuinely restatable | 1 |
auto_capture_available events ever logged |
0 |
| Index build, synchronous, per capture pass | 108 ms (218 files, 2.11 MB) |
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. The four rounds hardened this correctly and moved the yield from 2.6% to 0.0%.
The scan runs before the candidate list is examined, so 108 ms of spawnSync + readFileSync is paid on every pass, including passes where the model answers []. scanned() exists "for evidence" and is never called.
Against #389: AC4 ("ships only if cost falls") is unsatisfiable at this position in the pipeline — candidates come from the model, so availability can only be evaluated after the call that produced them, and test/capture-available.test.ts now pins that. AC5's noise bank does not exist for this mechanism; its false-kill rate has never been measured.
Root cause
The repo already has one theory of "is this the same claim?" This file built a second, weaker one beside it and refused silently.
| Existing | What it already provides |
|---|---|
src/core/tokenize.ts |
polaritySigns — negators, a copula span that keeps negation alive across "must not be enabled", antonym pairs, dual-role "never"; plus numericTokens: "a change here is a different fact, not a rephrasing". |
src/gate/gate.ts GATE-3 |
Floors, and refusal that returns a recovery instruction plus ordered evidence. |
src/store/tombstones/tombstone.ts |
Measured: a correction scores higher than a rewording (0.800 for 30→90 days, 0.778 for enable→disable, against 0.500–0.615 for honest rewordings), so no floor separates them. |
src/consolidate/propose.ts |
The house doctrine for redundancy: deterministic, proven reads replayed from the use ledger, proposals not writes. "'Looks redundant' is not a reason." |
src/capture/checked.ts (#393) |
Three-way verdict agrees / contradicts / undecidable; only one refuses; the non-refusing outcome is kept and labelled. |
available.ts uses none of it: its own filler list, its own negation regex, and a two-way verdict with no third state. Everywhere else in this codebase an uncertain match yields a label or a proposal. Here it yields a silent delete.
The cost is asymmetric and unbounded: a false keep costs one row in a store measured at 0.98× cost-neutral; a false kill costs a fact that nobody can find.
Evidence that a better matcher is not the fix
Prototype on the same 13-case bank, using tokens + polaritySigns + numericTokens with shingle containment: 11 of 13. The shipped matcher scores 13 of 13 only because the bank is its patch history.
The literature says the primitive is the wrong class, not merely unpatched:
- Substring containment is not Broder's containment. Broder, SEQUENS 1997 defines containment over w-shingle sets and flags estimation of very short documents into substantially larger ones as "rather error prone due to the paucity of samples". Our input is a 60-character row against 2 MB. Charikar, STOC 2002: no locality-sensitive hashing scheme exists for the Dice or Overlap coefficients.
- Tuned dedup precision is mediocre. Henzinger, SIGIR 2006 over 1.6 B pages: 0.50 (SimHash), 0.38 (shingles). Manku et al., WWW 2007: precision and recall both ≈ 0.75 at the chosen threshold.
- Overlap and meaning come apart on demand. PAWS (NAACL 2019) builds pairs with full word overlap and different meaning; SemAntoNeg (BlackboxNLP 2022) adds antonym swap and negation, with paraphrase models below random.
- Our negation regex is NegEx-class. Chapman et al., JBI 2001: curated trigger regexes plus a pseudo-negation filter reach PPV 84.5%, sensitivity 77.8%. We have no pseudo-negation filter (
no doubt,none the less,not really). - Our clause splitter exploits an annotation artifact. Fancellu, Nissim & Webber, EACL 2017: reported negation-scope accuracy is high because corpora mark scope as punctuation-delimited spans; "for scopes not delimited by punctuation, accuracy is low".
claims()splits on. ; : ,and judges polarity inside that window. The *SEM 2012 shared task measured cue-detection F1 85–91 against exact-scope F1 64.78 (best) and 12–20. - The gate implements a named fallacy. McCoy, Pavlick & Linzen, ACL 2019 (HANS) call it the lexical-overlap heuristic: models scoring 80+ on MNLI score 0% on subject/object swap. "Clause found as substring ⇒ already stated" is that heuristic.
- Monotonicity gives the exact condition we violate. A match is admissible evidence only in upward-entailing position; negation,
never,without,avoid,doubt, questions and conditionals reverse it (van Benthem 1986). - The operating point must come from a cost matrix. Elkan, IJCAI 2001: predict the class of lowest expected cost, from calibrated probabilities and an explicit cost ratio — not from a rule that happens to pass examples.
- Fail safe in the right direction. Saltzer & Schroeder 1975: base decisions on permission, so bugs fail in the quickly-detected direction. For a suppression filter that means the default is keep, and a bug surfaces as a visible duplicate, never as lost content.
And nobody in the agent-memory literature does this. MemGPT, A-MEM, Reflexion, Generative Agents and Agent Workflow Memory do not reject at write time. Mem0 (arXiv 2504.19413) did LLM adjudication at write time and retreated in 2026 to single-pass ADD with MD5 exact-hash dedup, moving redundancy to retrieval. Vinayaka (REALM@ACL 2026) measures exactly our failure: the same filter gains +0.186 at perfect label reliability and loses −0.176 under label corruption, with "greater degradation from false-drop than false-keep". TraceRetain (ICML 2026) finds retention policy makes no measurable difference on clean streams — the same null as our own base3 reuse result (median 0.98×, #385).
Decision
Stop patching the matcher. Make refusal recoverable, narrow it to what is provable, buy the measurement, then decide whether the gate exists at all.
Plan
Each phase ships alone, no flag, each a net deletion or a wash.
P0 — pay less, see more. Build the index only when candidates.length > 0. Cache the normalised bytes and sketch per (repoDir, git HEAD, dirty set), keyed by content hash — never a verdict: a cached verdict would survive a normaliser or rule change, which is complete-mediation failure and gives a result that depends on the order of previous rows (the failure capture/checked.ts already names). Move spawnSync/readFileSync off the hook thread. Wire scanned() into capture_lag: files, bytes, ms, cap hit.
Accept: warm pass < 5 ms; evidence line names files/bytes/ms; no behaviour change.
P1 — refusal becomes a label. Store the row tagged restatable with the same where/matched proof instead of dropping it; rename the evidence line auto_capture_restatable and log the full candidate content so a refused row is never unrecoverable; injection sorts restatable rows last so budget pressure drops them first. This is #393's three-way verdict applied here, and it makes every defect in rounds 1–4 structurally impossible rather than individually patched.
Accept: no code path in available.ts can prevent a write; a test asserts every case in the bank reaches the store, and the tag is what differs.
P2 — narrow the provable core, reuse the house primitives. Whole-candidate containment only (the normalised candidate inside one tracked file), not per-clause. Declared-command mention: all claims are filler over a declared command. Replace the local NEGATION regex with polaritySigns and the local FILLER with STOPWORDS, so one definition of "same claim" exists. numericTokens as a veto. Polarity as scope: reject a match site with any downward-entailing operator over it, and add the pseudo-negation filter NegEx needed. Shingle containment is allowed only as a recall-oriented prefilter feeding the tag; a hit never asserts meaning-equality by itself.
Accept: the gate produces a tag only; the bank passes; the file loses more lines than it gains.
P4 — the bank and the bench, before any further rule. Promote the four rounds' cases into a fixture with the round that produced each. Add #389 AC5's noise bank: ≥10 plausible, well-formed rows about the wrong thing, scored as false positives. Add a runner in the style of bench/runners/capture-trigger-compare.ts whose header states MUST GO RED if the gate-off arm scores the same as the gate-on arm, since today that difference is exactly zero on 1166 rows. Adopt a MERIT-style leak check as the false-kill metric: for each row the gate would have refused, replay later sessions and count how many needed it.
P5 — existence decision on P4's numbers. Expect the delete branch: a month of real output contains one genuine restatement and twenty-nine wrong refusals. If refusal rate is material and false-kill rate is ~0, keep P2's narrow core. Amend #389 AC4 at the same time: cost per session cannot fall at this position, so the criterion should be rows-per-session and injected bytes per session, both already metered by #387.
P6 — rules this buys. (1) A similarity check has three outcomes — proved, disproved, unknown — and unknown is the common one; two-outcome checks are rejected in review. (2) No new word lists; entries go into the shared src/core/tokenize.ts set with a replayed read justifying them. (3) Nothing is dropped silently from a store; refusal carries a recovery path. (4) Every gate ships with a negative control that can fail. (5) Every threshold names its cost matrix in a comment. (6) A cue regex ships with a pseudo-negation filter list or not at all.
Deferred: P3, moving availability to read time (demote a row whose content is in a file the session already read). It is the correct long-term home — whether a README restatement is redundant depends on whether the next session reads the README, which write time cannot know — but it touches injection selection and needs its own bench arm.
Explicit non-goal
No new matcher. No new word list. Any phase that adds a rule without a replayed read behind it is out of scope.
Considered and rejected
A small NLI cross-encoder is the proven cheap upgrade — SummaC (TACL 2022) 74.4% balanced accuracy, Vectara HHEM 0.872 TRUE AUC, MiniCheck-FT5 (770 M) matching GPT-4 at ~400× lower cost (EMNLP 2024). It is still a model call per candidate, which #389 criterion 1 rules out, and it inherits the negation weakness MoNLI and Language Models Are Not Naysayers (StarSem 2023) document. Its home is the bench, as the upper bound the code path is measured against.
Activity
abogartz commentedon Nov 13, 2026
P0, P1 and the P2 vetoes shipped in #403. P3 (read-time availability), P4 (case bank + bench) and P5 (the existence decision) remain open.
Measured after the change, against this repo's live store:
scanned()never called)auto_capture_scan: files, bytes, ms,cappedTwo things the measurement added:
capped: truein this repository. The tracked text exceeds the 2 MB budget, so the tail of the tree is never read. The verdicts assert presence, so truncation can only lower the tag rate — but no test covered it, and nothing in the trail said it until now.A scratch document in the tree suppresses real memories. While measuring, the gate tagged the row "On OCSI PR #396,
bun run benchprints 56109/55889 while the published README values are 55478/55258." — because a plan document in the repo root quotes that sentence, andgit ls-filesfeeds the scan. The tag was correct: with that file committed, the next session can read it there. Under the old policy the row would have been deleted on the strength of a file nobody intended as a source of truth. Worth carrying into P4's noise bank: the false-positive class is not only "plausible row about the wrong thing", it is "any document that quotes the store".One correction to the plan as written:
core/tokenize.ts'spolaritySignscannot replace the gate's cue list. It extracts signed predicates for the contradiction surface, so"we do not use tabs"returns[]—useis not a table term. Substituting it compares[]with[], matches, and re-opens the #397 round-3 defect. #403 unions the two instead.test(bench): four-arm availability policy comparison (#402, #403)
test(bench): give the availability bench a case bank, a ceiling, and …
test: run the availability case bank where CI can see it (#402)
test(bench): record the code-span dependency of the command check (#402)
test(bench): test the tag's own claim, and report the base rate the b…
test(bench): test the tag's justification, and measure what only P3 c…
fix(bench): measure the ceiling on the rows the arms hold, and make t…
test(bench): make the scripted capture reply say what the shipped pro…
test(e2e): stop reporting a missing trigger event as a teardown failu…
Merge pull request #403 from abogartz/402-availability-restatable
chore(release): 0.25.0 [skip ci]
abogartz-opencode-self-improvement commentedon Nov 14, 2026
🎉 This issue has been resolved in version 0.25.0 🎉
The release is available on:
Your semantic-release bot 📦🚀