Repository navigation
docs(readme): state the injection contract the code ships (#344) - #379
Conversation
The injection contract changed under #334/#339/#340 and the README still described the old one: nothing said that user-stated rows ride ahead of the relevance picks, at what cap, or that the block now re-scores at every user turn. Two bullets state it, each pointing at the test that pins it rather than at prose. Invalidations are now called byte-moving recomputes, matching what the counter actually measures and the wording #353 put on the status surfaces. The reason values (first / store_changed / prompt_reveal) are display-only on /memory and memory_status: they are interpolated, not enumerated. A test pins that an unknown value a later build adds still renders verbatim, so the surfaces cannot silently swallow a new reason. The viewer has no epoch surface, so it needed no change.
Adversarial review — REQUEST_CHANGESReviewed head Most of the PR is accurate and green. One P1: the new README states a cache invariant the shipped code violates. That invariant only becomes true with sibling PR #396, which is still open. P1 — README.md:153 asserts "a prompt change that selects the same rows costs no cache bust". False on this tree.The block renders in score order: Reproduced end-to-end through the real hooks with a seeded two-row store and a temporary store root: Direct render proof: PR #396 ("Render the memory block in a canonical order so re-ranking stops busting the prompt cache (#388)") is open and fixes exactly this; its The cited issue #340 carries the same wrong premise ("bytes move only when the SELECTED rows change"), and the cited test Fix, pick one:
P2 — The new test under-pins claim 3; a one-sided enumeration regression passes
Fix: assert each surface independently, for example NITs
Claim-by-claim
Issue #344 acceptance#344 lists three items and one AC: "README + docs diff reviewed against the merged code; no claim without a linked measurement or test."
Measured numbers (head
|
…344) Case 1 seeds a single row, so it cannot show a rank order. Seed two rows both prompts score identically and assert the second prompt adopts without moving the bytes: one epoch_recompute, reason=first. This is the half that must survive #388's canonical render order, so the current order-sensitivity is deliberately not pinned.
…end on (#344) "a prompt change that selects the same rows costs no cache bust" is false on this tree: src/recall/relevant.ts renders the lexical picks in score order, so a prompt that keeps the same rows and re-ranks them renders different bytes and src/inject/epochs.ts moves the epoch with reason prompt_reveal. State the qualified claim, name the order as part of the bytes, and point at #388/#396 for canonical render order. The bench note gains the matching bound: its policies re-score only when the store fingerprint moves, so the 20 prompts never re-rank one shared set and D's 0 is not evidence about that churn. No measured number changes.
The display-only test joined contextLines() and cacheLines() into one string, so a regression where only one of them learns an enumeration stayed green: mutating either src/status/report.ts interpolation alone left it passing. Assert the CONTEXT line and the CACHE line independently, each over the three known reasons plus an unknown one.
Review follow-ups applied at
|
| Mutation | Old joined shape | New per-surface shape |
|---|---|---|
src/status/report.ts:42 (contextLines) only |
1 pass / 0 fail | 42 pass / 1 fail |
src/status/report.ts:57 (cacheLines) only |
1 pass / 0 fail | 42 pass / 1 fail |
| both | 0 pass / 1 fail | 42 pass / 1 fail |
The new failure is the surface that moved, e.g. Expected to contain: "provider_restart" / Received: " this epoch other epoch since …". Each assertion now takes the single line it is about ( this epoch …, epochs whose bytes moved …) and checks it contains the reason verbatim, for first, store_changed, prompt_reveal and the unknown provider_restart. report.ts is back at its original bytes — git diff over src/ is empty.
F3 (NIT) — the body's panel citation was wrong and is gone
The epoch reason is not interpolated at src/tui/panel.tsx:371; that line renders the blocked-write reason. The body now names the shared functions contextLines() and cacheLines() in src/status/report.ts rather than a line number, so it cannot rot.
F4 (NIT) — the bench note states what D's 0 does not cover
The bench re-scores only inside the store-fingerprint guard (if (!cEpoch || cEpoch.version !== version), and the same guard in D), so its 20 prompts never re-rank one shared set. The note now says D's 0 is not evidence about that churn. No measured number changed, and bun run bench on this head reproduces the published table (A 60996 / B 55478 / C 55258 / D 53500).
F5 — body accuracy
"No claim is left pointing at prose" still holds after the F1 rewrite: the qualified claim points at the new test/epoch.test.ts case, not at prose. The body's other statements were re-checked against the tree — the viewer claim included (src/viewer/page.html renders no epoch surface; its reason fields are blocklist and undo reasons). The body now reports the current counts and names two tests instead of one.
Gate at 991811d
bun run gate green: typecheck exit 0; biome 542 warnings (the baseline, unchanged) and 147 infos; unit 1192 pass / 19 skip / 0 fail (1211 run, 13185 expects); terminal smoke + BDD 30 pass / 0 fail. bun test test/status.test.ts 43 pass / 0 fail, 140 expects (was 136); bun test test/epoch.test.ts 24 pass / 0 fail (was 23). git status --porcelain empty.
Deliberately not fixed
The order churn itself stays: a same-set re-rank still moves bytes and still reports prompt_reveal. That is #388's fix in #396, not a docs change, and pinning today's behaviour would have blocked it. Two related items belong to #396 rather than here: it changes the rendering that makes the stronger claim true, and at its head bun run bench prints B=56109 / C=55889 against this table, which is bench-runner drift on that side. Merge order also matters — #398 edits the same README section and conflicts with this PR's note sentence.
There was a problem hiding this comment.
Approving.
The blocking claim is corrected at 991811d: the README now says the epoch moves only when the rendered bytes move and qualifies the no-cost case to the same rows in the same order, with #388/#396 named as the work that makes order-stability true. The status-surface test now asserts each surface separately, so a one-sided enumeration regression fails.
Full gate green, CI green. Not merged — the merge is left to a human.
|
🎉 This PR is included in version 0.24.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What
The injection contract changed under #334 / #339 / #340; the README still described the old one. This states what the code ships, and pins the claims that had no guard.
1. The injection section gains the two rules that changed.
injectBudgetstill bounds the whole block — and why it exists: a prompt about "the injected bug" shares no vocabulary with "the correct sales tax rate is 8.25%", and the shipped matcher scored it zero.memory_recalland the contextual pull stay query-driven.prompt_reveal), and the epoch MOVES only when the rendered bytes move — a prompt change that selects the same rows in the same order costs no cache bust. Order is part of those bytes on this build:src/recall/relevant.tsrenders the lexical picks in score order, so a prompt that keeps the same rows and re-ranks them renders different bytes and pays the bust. Canonical render order, which removes that churn, is still open (#388, #396).Each claim names the test that pins it:
test/hint-channel.test.ts("guidance rides without lexical overlap, capped newest-first and never duplicated"),test/epoch.test.ts— including the new "a prompt that re-selects the same rows in the same order costs ZERO cache busts", which seeds two rows so that a rank order exists at all — andtest/guidance-provenance.test.tsfor the provenance reservation (#342). No claim is left pointing at prose.2. Status surfaces:
prompt_revealis display-only, now pinned per surface./memoryand the TUI panel both reach the epoch reason through the sharedcontextLines()andcacheLines()insrc/status/report.ts; neither enumerates it, so a value a later build adds renders as-is instead of blanking.test("epoch reason is display-only: known and unknown values render verbatim")asserts the CONTEXT line and the CACHE line separately, each overfirst,store_changed,prompt_revealand an unknownprovider_restart. Asserting the two surfaces as one joined string was not enough: with that shape, replacing either interpolation with an enumeration left the test green.The ticket lists the viewer as a third surface. It has no epoch surface at all — it is an admin view over rows, deletions and blocklist entries — so there was nothing to change there. Verified by reading
src/viewer/page.htmlrather than assumed: the page carries no epoch rendering, and itsreasonfields are blocklist and undo reasons.3. Invalidations wording. "The byte-change counter records epochs whose …" becomes "The invalidation counter counts byte-moving recomputes", matching what #353 put on the status surfaces. The sentence keeps the bound: it is not a provider cache-miss or re-prefill count. The note also states what the D column does not cover: the bench re-scores only when the store fingerprint moves, so its 20 prompts never re-rank one shared set, and D's
0is not evidence about the same-set re-ranking above. No measured number changes —bun run benchon this head reproduces the published table exactly.Measured
bun test test/status.test.ts— 43 pass / 0 fail, 140expect()calls.bun test test/epoch.test.ts— 24 pass / 0 fail.bun run gategreen on991811d: typecheck exit 0; biome 542 warnings (the existing baseline) and 147 infos; unit 1192 pass / 19 skip / 0 fail; terminal smoke + BDD 30 pass / 0 fail.Docs plus two tests: no
src/change, so no behavior changes and nothing new can break.Closes #344