feat: G4 repeat-read recall serving + G5 dollar conversion — Build 5 - #58
Merged
Conversation
G4 — the hook now ACTS on repeat-reads: 2nd+ read of an unchanged file (same mtime, count from the session reads map) whose exact bytes are already content-addressed in CCR is denied with the real resolvable ⟨recall:hash⟩ — retrieve serves it byte-exact instead of re-consuming tokens. Strictly fail-open: first reads, changed mtime, absent CCR entry, missing io, or any error → allow (fresh content is never blocked). The deny records saved:0 — savings count only when the recall is retrieved. Precedence: constraints > repeat-read recall > large-file redirect. G5 — meter persists the last seen model NAME (surfaced as MeterReading.model, survives reset like savings); the receipt adds an api-billing-only line '≈ $X.XX avoided at <model> input rates (as of 2026-07, estimate)' from a small dated static table. Plan-billing sessions never see dollars — their cost is quota, not $. Live-verified: knitbrain_read → CCR → 1st hook read allows, 2nd denies with handle → knitbrain_retrieve returns the file byte-exact (sha256 match). verify EXIT=0 (578 tests).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What (Build 5 — optimization completions, docs/LOOP-ENGINEERING.md Tier-2 G4+G5)
⟨recall:hash⟩; retrieve serves it byte-exact. Fail-open everywhere; deny records saved:0 (honest math — savings count only on actual retrieval). Precedence: constraints > recall > large-file redirect.≈ $X.XX avoided (rates as of 2026-07, estimate)keyed off the persisted model name; plan billing never shows dollars.Verification
rm -rf dist && npm run verifyEXIT=0 (578 tests). Live chain on built binaries: MCPknitbrain_read→ CCR → 1st hook read allows → 2nd read denies with handle →knitbrain_retrievebyte-exact (sha256 verified).No new MCP tools, no bump.