Skip to content

Refuse capture candidates the next session can read or re-derive (#389) - #397

Closed
abogartz wants to merge 7 commits into
mainfrom
389-capture-availability
Closed

abogartz wants to merge 7 commits into
mainfrom
389-capture-availability

Conversation

@abogartz

Copy link
Copy Markdown
Owner

Part of #386. Addresses #389.

What this does

Capture now asks, before it writes, whether the next session could get the fact by itself.

The discriminator is measured, not chosen. Reuse pays nothing (six pairs, every arm 6/6, median L2/L0 0.98×, a memory about an unrelated task 0.88×). Transport pays everything (empty store 0/5, the same store seeded 5/5). What separates them is availability, not interest and not durability. Capture had no notion of the question, and at roughly a third of a session's own generation a row that changes nothing is not free.

Two availability questions are answerable by a code path — no prompt, no model call, which is what criterion 1 demands:

  1. Is this text already in the working tree? git ls-files, docs and config read first, 2 MB byte budget per pass, verbatim modulo case, wrapping and markdown emphasis. The refusal names the file.
  2. Is this command already declared by the project's own gate? package.json scripts, Makefile and justfile targets and recipes, workflow run: lines. The refusal names the gate: package.json scripts.deploy.

Matching is positional, never substring. A make target named all must not refuse a row saying "install all deps", so a single-word gate matches only the operand position after the runner is stripped.

Fail-open everywhere. No git, no repo, an unreadable file, an exhausted budget — none is evidence that a fact is available, and refusing on those would spend the one measured benefit capture has.

AC status, stated before review

# criterion status
1 restatable-in-a-tracked-file refused by a code path, refusal logged with the file met
2 derivable-by-the-project's-own-gate refused, log says which gate met for the declaration. Not met for a gate's result — see below
3 base4 transport preserved, 5/5 offline-verified, live run pending. The transport fact is kept; the gate refuses none of the noise bank either
4 base3 re-run at n≥6, cost before and after, ships only if cost falls cannot be met by this mechanism. Pinned by test
5 noise bank ≥10 entries scored as false positives met, 17 rows scored, result below
6 refusals never delete a row the store already kept met by construction, asserted

Criterion 4: this mechanism cannot lower token cost, and a test says so

Candidates come from the model. Availability can only be evaluated after the call that produced them, so a pass costs one call whether it keeps three rows or none. What falls is rows, not tokens.

The test asserts generate.calls.length === 1 alongside two refusals and one promotion. Lowering token cost means changing when the pass runs — triggers and cooldown — which is a different ticket. Criterion 4's premise is wrong, and shipping would otherwise leave a cost claim nobody can re-test.

Criterion 2's unmet half

Refusing a fact derivable by running a gate (a test result, a build output) would mean executing project commands during capture: side effects, unbounded time, and a model call already paid for. Not taken. What is implemented is the declaration check — the project already names the command, so the row restates it. A fact that is only knowable by running something is still stored, correctly.

Criterion 5: the noise bank, scored

bun available-score.ts against the base4 tree:

transport fact: kept (must be kept)
restated README sentence: REFUSED in_tracked_file README.md
noise refused 0/17

The honest reading: an availability gate cannot see a wrong fact, only a restatable one. It refuses none of the poison, and that is why #393 exists. The two lines that matter are the other two — the transport fact survives (so this does not spend the win) and a genuine restatement is refused (so the gate is not inert).

Verification

bun run gate: 1217 unit tests, 30 e2e against a real opencode host, typecheck and lint clean. test/capture-available.test.ts: 9 tests — 4 fail without the wiring; the other 5 are over-refusal guardrails that pass either way, which is the point.

Not in this PR

  • Live base4 transport 5/5 with the gate active (criterion 3). The seat is currently degraded and shared with the agent driving this work; the run needs a quiet window.
  • Gate-result derivability (criterion 2's second half).
  • Trigger and cooldown policy, which is where token cost actually lives.

Part of #388's sibling #386 ticket #389: capture spends its budget on facts the
next session cannot obtain any other way.

The discriminator is measured, not chosen. Reuse pays nothing (six pairs, every
arm 6/6, median L2/L0 0.98x, one memory about an unrelated task 0.88x). Transport
pays everything (empty store 0/5, the same store seeded 5/5). What separates them
is whether the next session could get the fact by itself. Capture had no notion of
that question, and at roughly a third of a session's own generation a row that
changes nothing is not free.

Two availability questions are answerable by a code path with no prompt and no
model call, which is what criterion 1 demands:

  - is this text already in the working tree? `git ls-files`, docs and config read
    first, 2 MB byte budget per pass, verbatim modulo case, wrapping and markdown
    emphasis. The refusal names the file.
  - is this command already declared by the project's own gate? package.json
    scripts, Makefile and justfile targets and recipes, and workflow `run:` lines.
    The refusal names the gate (`package.json scripts.deploy`).

Matching is positional, never substring: a make target named `all` must not refuse
a row that says "install all deps", so a single-word gate matches only the operand
position after the runner is stripped.

Fail-open everywhere. No git, no repo, an unreadable file, an exhausted byte budget
-- none of those is evidence that a fact is available, and refusing on them would
spend the one measured benefit capture has. The tests pin both directions: the
restatement is refused AND the unavailable fact is kept.

Criterion 6 (refusals never delete) holds by construction: the check runs before
runWriteGate, so nothing is superseded, blocklisted or rewritten. A test asserts a
pre-existing row on the same scope survives a refused candidate.

Criterion 4 cannot be met by this mechanism, and a test now says so. Capture's
candidates come FROM the model, so availability can only be evaluated after the
call that produced them: one call per pass either way. What falls is the number of
rows, not the tokens. Lowering token cost means changing WHEN the pass runs --
triggers and cooldown -- which is a different ticket.

A guided row is refused on the same rule, and that is safe for the reason the test
names: a row that contradicts the tree is by definition not verbatim in it, so the
correction case still reaches the store and the conflict surface.

- src/capture/available.ts: the index, the two checks, the positional gate matcher
- src/capture/runtime.ts: refuse before the write gate, `auto_capture_available`
  evidence with reason, where and the matched span
- test/capture-available.test.ts: 9 tests. 4 fail without the wiring; the other 5
  are over-refusal guardrails that pass either way

Co-authored-by: OpenCode <[email protected]>

@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.

P2 — matching part of a candidate does not establish that the whole fact is available (src/capture/available.ts:307–327, head 362655ca9afdeb39cbc5835bf4002b9bb591c47e).

Independently replayed through the capture hook with a tracked manifest declaring deploy, and a README containing the existing reorder rule:

  • Never run npm run deploy until finance confirms approval code BLUEBIRD. (command backticked in the actual candidate) is refused as declared_gate, even though the approval restriction/code appears nowhere in the tree. An otherwise identical candidate naming undeclared npm run publish is kept.
  • The known README rule followed by ; Finance confirmed the external supplier rate is 1900 basis points. is refused as in_tracked_file: one old clause matches, so the new unavailable clause is lost with it.

Both missing rows and both refusal receipts were observed in the real write path; the control persisted. This spends the unavailable-fact behavior the gate is intended to preserve. Could the refusal require the whole assertion to be restatable, keeping mixed/conditional/negative guidance when only its command or one clause matches? Merely finding a declared command does not establish a new instruction about when to avoid it.

Validation: Windows/Bun 1.4.4; 86 focused availability/capture tests and typecheck pass, plus one separate synthetic capture probe (5 assertions). Canned generation and throwaway store only; no claim about a real model's frequency or the pending transport benchmark. Please feel free to narrow or defer the heuristic rather than adopting this particular fix direction.

Review finding on #397 (WhollyMindless), both cases reproduced as stated.

The gate refused on one hit, and one hit is not a restatement:
- a candidate adding a restriction to a declared command ("Never run
  `npm run deploy` until finance confirms approval code BLUEBIRD") was
  refused as declared_gate although the restriction and the code appear
  nowhere in the tree;
- a restated README rule plus "; Finance confirmed the supplier rate is
  1900 basis points" was refused as in_tracked_file on the old clause,
  losing the new one. Both refusals spend the exact behavior the gate
  exists to preserve -- unavailable facts.

Refusal now requires the whole assertion to be restatable:
- in_tracked_file: EVERY clause (>= MIN_CLAUSE, falling back to the whole
  content when there are none) must be found in the tracked text. One
  missing clause keeps the row.
- declared_gate: refuse only when the candidate says nothing beyond the
  command. Stripping every stated command span must leave less than one
  clause of prose; a clause's worth of condition, restriction or code is
  information the manifest does not carry.

Order flipped to put in_tracked_file first: literal presence is the
stronger evidence, and a candidate that restates the tree AND names a
declared command should report the presence, not the gate.

Cost of the tightening, named: a full restatement split into clauses that
individually miss the haystack (heavy rewording) is now kept where the
any-clause rule might have refused -- the gate's recall of refusals drops
toward precision, which is the direction the evidence supports: a false
refusal costs the one measured benefit (transport 0/5 empty, 5/5 seeded),
a missed restatement costs one redundant row.

Offline noise bank re-scored after the change, unchanged: 0/17 refused
(an availability gate cannot see a wrong fact -- #393 owns poison), the
transport fact kept, a restated README sentence refused.

- src/capture/available.ts: all-clause presence; residual-bound gate rule
- test/capture-available.test.ts: the review's two cases pinned as kept,
  the pure restatement and declared-command refusals untouched

Co-authored-by: OpenCode <[email protected]>
@abogartz

Copy link
Copy Markdown
Owner Author

@WhollyMindless finding confirmed and fixed in c449c42, in the direction you proposed — refusal now requires the whole assertion to be restatable.

  • in_tracked_file: EVERY clause (≥ MIN_CLAUSE, falling back to the whole content when there are none) must be present in the tracked text. Your mixed candidate — README rule + "; Finance confirmed the external supplier rate is 1900 basis points." — is now kept, pinned as a test.
  • declared_gate: refuses only when the candidate says nothing beyond the command. Stripping every stated command span must leave less than one clause of prose; your BLUEBIRD restriction leaves a clause's worth of condition and code the manifest does not carry, so it is kept, pinned. The pure Ship this repo with \npm run deploy`` refusal is untouched.
  • Order flipped: literal presence is checked before the gate — stronger evidence, and it names the file.

Cost named (opposite direction to your ask, so stating it): refusal recall drops toward precision. A heavy rewording whose clauses individually miss the haystack is now kept where any-clause might have refused. That is the correct trade on this evidence: a false refusal costs the one measured benefit (transport 0/5 empty, 5/5 seeded); a missed restatement costs one redundant row.

Offline noise bank re-scored against the new matcher: unchanged — 0/17 refused (an availability gate cannot see a wrong fact; #393 owns poison), transport fact kept, restated README sentence refused.

bun run gate green: 1220 unit, 30 e2e, typecheck, lint.

@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.

The two original long examples now survive on c449c42690b81fdb677b4722f6f9d9be09027b3e, independently replayed. The same refusal defect remains for short new assertions (src/capture/available.ts, the MIN_CLAUSE filter and residual-length check):

  • Never run npm run deploy without approval. (command backticked in the candidate) is still refused as declared_gate when deploy is declared. The manifest contains no approval restriction. The identical publish control is stored.
  • The existing long README rule followed by ; External rate is 1900. is still refused as in_tracked_file. The new clause is below 48 characters and is removed from needed, so every remaining clause matches while the unavailable fact is discarded.

Both refusals and absent rows reproduce through capture/store, alongside the two passing original examples. A short condition or number can carry all the new information; length is not evidence that the residual adds nothing. Could unmatched short clauses and meaningful residual instructions keep the candidate rather than being dropped before the availability decision? Keeping the request for changes for this remaining P2.

88 focused availability/capture tests, two separate hook probes (9 assertions), and typecheck pass on Windows/Bun 1.4.4. Synthetic generation/temporary stores only; no live-model frequency claimed.

Review #397 (WhollyMindless): both availability rules dropped short clauses
before deciding, so a fact that fits in one short clause was refused as
restatable.

- in_tracked_file: clauses below MIN_CLAUSE are no longer discarded from
  `needed`; every clause above MIN_TRACE must be found, so
  "<restated README rule>; External rate is 1900." is kept.
- declared_gate: stripping the command spans must leave not just a short
  residual but an unconditional one. A manifest declares that `deploy`
  exists, never when it may be run, so
  "Never run `npm run deploy` without approval." is kept.
Union resolution in src/capture/runtime.ts: #389 availability check runs
first and continues; #393's inferred-claim check keeps its own receipt and
its CODE_CHECKED_TAG path.
@abogartz

Copy link
Copy Markdown
Owner Author

Review accepted — fixed on bf0d14d

Both cases in the round-2 review are correct. I reproduced them independently before changing anything, against c449c42 with a direct call into the index (fixture: tracked README.md with the reorder rule, package.json declaring deploy):

REFUSE A short gate restriction (deploy declared) -> declared_gate @ package.json scripts.deploy
KEEP   B control: undeclared command              -> -
REFUSE C long README rule restated verbatim       -> in_tracked_file @ README.md
REFUSE D long rule + short new fact               -> in_tracked_file @ README.md
KEEP   E long rule + long new fact                -> -
REFUSE F bare gate restatement                    -> declared_gate @ package.json scripts.deploy
KEEP   G gate + long restriction                  -> -

A and D are the two defects, exactly as reported.

What changed

in_tracked_file — short clauses are no longer discarded before the decision.
The MIN_CLAUSE filter dropped every clause under 48 characters from needed, so with <restated README rule>; External rate is 1900. the only clause left to match was the old one, every clause "matched", and the row was refused. Clauses are now kept down to a new MIN_TRACE = 16 and every one of them must be found before the candidate is refused. A clause below MIN_TRACE is punctuation, not an assertion. The change is monotone: it can only turn refusals into keeps, never the reverse.

declared_gate — a condition is new information however short it is.
The residual check was length-only, so Never run \npm run deploy` without approval.(27 characters after the command span is stripped) was refused. Length is not evidence that the residual adds nothing, as the review says. The manifest declares thatdeploy exists; it declares nothing about when it may be run. The refusal now additionally requires that the residual carry no restriction vocabulary (never, only, must, without, unless, until, require*, approval, before, after, confirm*, credential`, and friends).

Both rules keep their fail-open contract: an uncertainty keeps the candidate.

Verification

test/capture-available.test.ts gains two tests, one per reported case. Both are red without the fix and green with it — I reverted the two edits and re-ran:

(fail) capture availability gate (#389) > a SHORT restriction on a declared command is kept (#397 round 2)
(fail) capture availability gate (#389) > a restated clause carrying a SHORT new clause is kept (#397 round 2)
 11 pass  2 fail

With the fix, the same probe now reads:

KEEP   A short gate restriction (deploy declared) -> -
KEEP   D long rule + short new fact               -> -
REFUSE C long README rule restated verbatim       -> in_tracked_file @ README.md
REFUSE F bare gate restatement                    -> declared_gate @ package.json scripts.deploy

The two true restatements still refuse, and the previously added long-form cases (until finance confirms approval code BLUEBIRD, Finance confirmed the external supplier rate is 1900 basis points) still keep, so the round-1 behaviour is unchanged.

Full gate on the merged branch: 1270 pass / 19 skip / 0 fail, e2e 30 pass / 0 fail, typecheck clean, lint exit 0 with no new warnings from these edits.

Also

The branch was CONFLICTING against main. bf0d14d merges ce36c65 (0.23.0, including #384/#393/#399/#400). The only conflict was src/capture/runtime.ts; resolved as a union — the #389 availability check runs first and continues with its own auto_capture_available receipt, and #393's inferred-claim check keeps its auto_capture_contradiction receipt and its CODE_CHECKED_TAG path.

@ocsi-reviewer ocsi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approving the change; the outstanding request for changes is still open.

The P2 is addressed at bf0d14d: refusal now requires the whole assertion to be restatable, short clauses are no longer discarded before the decision, and a condition on a declared command is kept however short it is — Never run npm run deploy without approval. survives, while a verbatim restatement still refuses. Both cases are pinned by tests that are red without the fix, and the branch merges ce36c65 cleanly.

This approval does not dismiss the reviewer's request for changes; that review still has to be re-reviewed or dismissed by its author. Not merged — the merge is left to a human.

@abogartz
abogartz dismissed stale reviews from WhollyMindless and WhollyMindless November 12, 2026 20:30

Resolved at bf0d14d. Refusal now requires the whole assertion to be restatable: short clauses are no longer dropped before the availability decision, and a condition on a declared command is kept however short it is. Both reproductions from this review are pinned by tests that fail without the fix. Dismissing on the owner's instruction; the author may re-review.

@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 7ab595d through the capture hook with a scripted response and a tracked temporary repo. Both cases from my previous review are now fixed: the short approval restriction and README rule plus External rate is 1900. are stored. The bare-command and verbatim-README controls still refuse. Thank you for addressing those.

Two remaining P2 cases prevent me from clearing the request:

  1. A declared command still suppresses new behavioral facts. With only scripts.deploy = "rsync dist/ box:/srv" declared, both `npm run deploy` wipes the staging database. and `npm run deploy` fails on Windows; use WSL. produce auto_capture_available reason=declared_gate and store zero rows. The manifest establishes neither fact. At available.ts:356, a short residual without the restriction vocabulary still counts as a restatement. Please retain unmatched assertions unless the entire candidate is positively recognized as a command restatement; extending the restriction vocabulary alone leaves this class open.

  2. Substring matching reverses a negated README rule. With We do not use tabs for indentation. in README, the candidate Use tabs for indentation. is refused as in_tracked_file, including with guided: true. The same candidate without that README sentence is stored. The clause lookup matches inside the opposite assertion. Please require a complete assertion match, preserving negation, or keep the candidate when uncertain.

Our earlier review missed these cases. The 131 focused capture/provenance/failure tests and typecheck pass; these additional observations came from fresh Windows probes in throwaway stores. No live capture model was used, so incidence in real capture output is unmeasured.

Two ways the availability gate refused a row it should have kept, both from
WhollyMindless's round-3 review of #397.

The clause lookup was a bare indexOf, so `Use tabs for indentation.` matched
inside `We do not use tabs for indentation.`: the reversal of a README rule was
refused as already available, which stores the wrong fact with the doc's
authority. A match now has to begin and end on a word boundary and sit in a
sentence whose polarity the clause shares.

The declared-gate rule took a SHORT residual as a restatement on length alone,
so "`npm run deploy` wipes the staging database." was refused against a manifest
that only declares that `deploy` runs rsync. The burden moves: refuse only when
stripping the stated commands leaves no assertion at all, or assertions the
tracked files state themselves. RESTRICTION is gone — an open list of condition
words cannot decide what is new, which is what the review showed.

Consequence for the controls: the bare-command case is now "Ship with `npm run
deploy`.". "Ship this repo with `npm run deploy` from the root." is kept,
because the manifest does not say the command is run from the root.
@abogartz

Copy link
Copy Markdown
Owner Author

Both cases reproduce on 7ab595d and both are fixed on fe00c92.

1. A declared command suppressed new behavioral facts — confirmed.

`npm run deploy` wipes the staging database.  -> declared_gate, 0 rows
`npm run deploy` fails on Windows; use WSL.   -> declared_gate, 0 rows

The cause is as you described: at available.ts:356 the test was
rest.length < MIN_CLAUSE && !RESTRICTION.test(rest), so a 26-character residual
that happened to miss the vocabulary was accepted as a restatement on length.

Fixed the way you asked — the burden now sits on positive recognition, and the
vocabulary is not extended, it is removed. After every stated command span is
stripped, declared_gate fires only when the residual carries no assertion at
all
(nothing above MIN_TRACE), or when every assertion it does carry is
itself restatable from the tracked files. RESTRICTION is deleted: an open list
of condition words cannot decide what is new, which is exactly what this review
showed. A condition found verbatim in the tree is now refused because it is
available, not kept because of which word it contains.

2. Substring matching reversed a negated README rule — confirmed.

README: We do not use tabs for indentation.
candidate: Use tabs for indentation.  -> in_tracked_file README.md (guided too)

The clause lookup was a bare haystack.indexOf(c). A hit now must

  • begin and end on a word boundary (use tabs is not a hit inside abuse tabs), and
  • sit in a sentence of the same polarity: negation the tree carries and the
    clause drops is a reversal, not a restatement.

The sentence is walked out to the same [.;:,\n] boundaries the candidate is
split on, so polarity is judged in one sentence rather than a whole file. I kept
substring matching inside a same-polarity sentence rather than requiring whole
assertion equality: Note that the deploy step rsyncs dist. should still refuse
The deploy step rsyncs dist., and equality would stop it. Only the polarity
guard was needed to close your case. NEGATION is a closed list answering one
closed question (same polarity?), not the open one RESTRICTION tried to answer.

One consequence, stated plainly. The bare-command control was
Ship this repo with \npm run deploy` from the root.. Under the new rule that candidate is **kept**: the manifest does not say the command is run from the root, so it is an unmatched assertion. That test's content is now Ship with `npm run deploy`.` — the case the manifest can actually answer. I
did not want to leave the old string in place passing for a reason it no longer
tests.

Gates. bun test ./test/ 1337 pass / 0 fail; tsc --noEmit clean;
biome lint 551 warnings, identical to 7ab595d measured in a clean worktree,
so no new warnings. Two tests added (gate-claim, negated); the negated
test also asserts the verbatim negated rule still refuses, so the polarity guard
cannot be quietly switched off.

Incidence in real capture output is still unmeasured, as you note — no live
capture model in either round.

@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.

Replayed fe00c92 independently through capture/store. The database-wipe and Windows examples now store, as does the tabs correction (including guided capture). The verbatim README and new bare-command controls still refuse. Thank you for addressing those cases.

P2 — the refusal still discards unverified information before deciding that the whole candidate is available. With only scripts.deploy = "rsync dist/ box:/srv" declared, these both log auto_capture_available reason=declared_gate and store zero rows:

  • Never `npm run deploy`.
  • Before `npm run deploy`, run `aws sso login --profile prod`.

Neither the prohibition nor the login prerequisite appears in the tracked files. Both candidates stored on 7ab595d with the identical fixture; both now refuse. The undeclared-command control Never `npm run publish`. still stores.

There are two connected gaps: assertions() drops every fragment shorter than 16 characters, including Never; and the residual calculation removes every command span after finding one declared gate, including the undeclared AWS command. An empty claims array then becomes evidence for refusal.

Please keep the candidate when a meaningful residual or command span has not been established as available. A narrowly recognized bare-command form would be fine; the current length cutoff is still treating short assertions as absent. Keeping the request for changes for this remaining refusal defect.

Validation: 133 focused tests and typecheck pass; 33 earlier scripted cases replayed, plus eight additional observations on each of the old and new heads. Windows, temporary repos/stores, scripted generation only. This establishes the observed refusals, not their frequency with a live capture model or the pending transport benchmark.

Round 4 of #397 (WhollyMindless) found the refusal still discarding information
before it decided the whole candidate was available. Both cases store on
`7ab595d` and refused on `fe00c92`:

    Never `npm run deploy`.
    Before `npm run deploy`, run `aws sso login --profile prod`.

`assertions()` dropped every fragment under MIN_TRACE, so the only claim in the
first row was `never`, the claim list came back empty, and an empty list was read
as proof of a restatement. The residual then stripped EVERY command span after
finding ONE declared gate, erasing the undeclared AWS prerequisite in the second
row.

Length is replaced by a FILLER test: a fragment states nothing only when every
one of its tokens is a function word or a mention verb ("ship with X", "run X").
It is a whitelist for filler rather than for newness, which is the only direction
a word list can go — a word left off it is read as a claim and the row is kept,
whereas the RESTRICTION list this replaces lost a fact for every word it missed.
Temporal, conditional and modal words are deliberately not filler: a manifest
declares that a command exists, never when it may be run.

The declared-gate rule now also requires every command span the row states to be
declared. An undeclared one is a fact the tree does not hold, whatever the rest
of the row says.

Consequence: the accepted mention is narrower, as the review asked. "Run `npm run
deploy` from the root." is kept, because the manifest does not say where the
command runs; "Ship with `npm run deploy`." and "Deploy with `npm run deploy`."
still refuse.
@abogartz

Copy link
Copy Markdown
Owner Author

Both cases reproduce on fe00c92 and both store on 1930bf6.

Never `npm run deploy`.                                  -> was declared_gate, now stored
Before `npm run deploy`, run `aws sso login --profile prod`. -> was declared_gate, now stored

The length cutoff is gone, on both rules. assertions() becomes claims():
a fragment states nothing only when every one of its tokens is a function word
or a mention verb (ship with X, run X, use X). never is a claim at five
characters, so the residual of Never \npm run deploy`.is no longer empty and an empty list is no longer reachable that way. The same cutoff was open on the other rule — a short prohibition riding a restated README sentence was dropped before matching — soclaims()is what both rules now split on, andMIN_TRACEis deleted. The new test pins all three: the prohibition on the command, the prerequisite, and${README_TEXT}; never.`.

Why a word list is acceptable here and was not in round 3. This one whitelists
filler, not newness. A word left off it is read as a claim and the row is kept,
so incompleteness fails toward the safe side. RESTRICTION whitelisted what
counted as new, so every word it missed lost a fact — that is why removing it was
right and why it is not coming back. Temporal, conditional and modal words
(before, after, until, unless, when, if, only, every modal) are
deliberately not filler: a manifest declares that a command exists, never
when it may be run.

Command spans are now checked individually. Refusal requires every span the
row states to hit a gate:

const undeclared = spans.some((s) => gateHit([s], gates) === null);

An undeclared span is a fact the tree does not hold, whatever else the row says,
so the AWS login prerequisite keeps the row on its own.

The accepted mention is narrower, which is what you asked for. Kept now:
`npm run deploy` needs sudo., `npm run deploy` twice daily.,
Run \npm run deploy` from the root.. Still refused: `` npm run deploy.``, Run `npm run deploy`., Ship with `npm run deploy`., Deploy with `npm run deploy`.`, the verbatim README, the near-verbatim
README, and the verbatim negated tabs rule (so the round-3 polarity guard is
still load-bearing).

Gates. bun test ./test/ 1338 pass / 0 fail; tsc --noEmit clean;
biome lint 549 warnings, two below the fe00c92 baseline of 551. Pre-push
merge gate (unit + e2e smoke/BDD on a real host) runs on the push.

Frequency with a live capture model is still unmeasured — scripted generation
only, both rounds.

@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 1930bf6 independently through capture/store. Both cases from my last review now store: the short Never prohibition and the undeclared AWS login prerequisite. The earlier database-wipe, Windows and tabs cases remain fixed; bare-command and verbatim-README controls still refuse.

Two P2 gaps remain with a tracked fixture declaring only scripts.deploy = "rsync dist/ box:/srv":

  1. The new tokenizer drops non-Latin assertions. Никогда не запускайте `npm run deploy` без разрешения дежурного. (never run the command without on-call approval) now produces declared_gate, zero rows; it stored on fe00c92. Appending Выпуск запрещён без разрешения дежурного. (release is forbidden without on-call approval) to the test's README_TEXT similarly changes from stored to in_tracked_file, zero rows. Neither restriction is in the tree. The English prohibition and the Russian sentence with undeclared npm run publish still store. At available.ts:372, splitting on [^a-z0-9']+ leaves no tokens for Cyrillic prose, and the next line discards it. Please preserve unrecognized Unicode text as a claim rather than treating it as punctuation.

  2. Checking every command span still accepts undeclared arguments. Use `npm run deploy -- --dry-run`. refuses as declared_gate, zero rows, although the manifest never specifies --dry-run. Changing only deploy to undeclared publish stores. This also occurs on fe00c92; it is a remaining gap, not a new regression. gateHit() accepts the first operand alone, so the new per-span check considers the entire command verified and strips the additional argument. Please require the full invocation to be established, or retain its unmatched arguments as information.

Validation: 134 focused tests / 371 assertions and typecheck pass; 41 prior scripted cases replayed, plus eight targeted observations on each old/new head. These are Windows capture/store observations with scripted generation, not live-model incidence or transport-benchmark results.

@abogartz

Copy link
Copy Markdown
Owner Author

Closing in favour of #403. This is a pivot, not a rejection — everything this branch earned is carried over.

What was carried

Commit 2fe2287 on #403 is this branch's full diff, cherry-picked wholesale onto main: the tree scan, the gate parser (package.json scripts, Makefile targets, CI run: lines), the byte-budgeted reader, and all 16 tests from the four review rounds. Nothing here is discarded.

What changed, and why it ends the loop

Every round on this branch found the same defect in a different place — round 2 a short residual, round 3 a substring of the opposite rule, round 4 a discarded fragment and a stripped command span. Each round patched one instance and the reviewer found the next.

The measurements say the matcher was never the problem:

original 362655c this branch 1930bf6
real captured rows refused 30 of 1166 0 of 1170
of those, genuinely restatable 1 —

The original refused "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, and none of them left a trace. Hardening was correct and moved the yield from 2.6% to 0.0%.

So #403 changes the consequence instead of the check: the verdict is now the restatable tag on a row that is stored anyway. No code path in available.ts can prevent a write, which makes every defect raised on this branch structurally impossible rather than individually patched. A wrong match costs one row; a right one saves an injection slot.

The open review threads

Both are answered by the new contract rather than left hanging:

  • WhollyMindless, round 4 (5884545007) — the discarded-fragment and stripped-command-span gaps. Both fixes are in 2fe2287 and both cases are in feat(capture): tag restatable rows instead of dropping them (#402) #403's bank (nothing is discarded before the tag is decided). They now assert the row reaches the store, which they could not distinguish before: "kept" and "refused" both produced zero rows.
  • WhollyMindless, round 3 (5882961142) — the opposite-rule substring. Kept, plus a second polarity source. One correction to what I said in that thread: core/tokenize.ts's polaritySigns cannot replace the cue list. It is a predicate-sign extractor, so "we do not use tabs" returns []; substituting it compares [] with [] and re-opens exactly this defect. feat(capture): tag restatable rows instead of dropping them (#402) #403 unions the two, which keeps the guard and adds the antonym pairs and the dual-role never.

Two things this branch surfaced that outgrew it

Full reasoning, the literature check and the remaining phases (P3 read-time availability, P4 the case bank and bench, P5 the existence decision) are in #402.

@abogartz

Copy link
Copy Markdown
Owner Author

Superseded by #403, which carries this branch's full diff as commit 2fe2287 and changes the refusal policy per #402.

@abogartz abogartz closed this Nov 13, 2026
abogartz pushed a commit that referenced this pull request Nov 13, 2026
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.
abogartz pushed a commit that referenced this pull request Nov 13, 2026
…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 pushed a commit that referenced this pull request Nov 13, 2026
…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-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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants