Skip to content

feat: G4 repeat-read recall serving + G5 dollar conversion — Build 5 - #58

Merged
PDgit12 merged 1 commit into
mainfrom
feat/g4-g5
Jul 7, 2026
Merged

feat: G4 repeat-read recall serving + G5 dollar conversion — Build 5#58
PDgit12 merged 1 commit into
mainfrom
feat/g4-g5

Conversation

@PDgit12

@PDgit12 PDgit12 commented Jul 7, 2026

Copy link
Copy Markdown
Owner

What (Build 5 — optimization completions, docs/LOOP-ENGINEERING.md Tier-2 G4+G5)

  • G4: repeat-read of an unchanged file whose exact content is in CCR → hook denies with the real ⟨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.
  • G5: api-billing receipts show ≈ $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 verify EXIT=0 (578 tests). Live chain on built binaries: MCP knitbrain_read → CCR → 1st hook read allows → 2nd read denies with handle → knitbrain_retrieve byte-exact (sha256 verified).

No new MCP tools, no bump.

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).
Copilot AI review requested due to automatic review settings July 7, 2026 07:49

Copilot AI 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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@PDgit12
PDgit12 merged commit 76c9f03 into main Jul 7, 2026
5 checks passed
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