Repository navigation
fix(cheapmodel): move the trailing breakpoint onto the appended question - #725
Conversation
Claude Code 2.1.310 ends each request with a system message that holds the last cache_control breakpoint. The prefix ask kept it there and appended the bridge and the ask with none. The provider then missed the turn's cache entry and the question rewrote the conversation. The sweep gate refused every answer. - insertAskMessage moves the last message's breakpoint (same object, ttl kept) onto the bridge, or onto the ask when there is no bridge. It adds none when the last message has none. - The sweep write gate refuses a write only when it is larger than the tokens the question appended, plus a named margin. - The ping candidate scan skips only real markers. Text that quotes marker syntax is a candidate (same fault as #705). Fixes #721 Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
The provider never reads a cache entry that ends at a text turn, so a correct question always rewrites that turn's tail. A write limit would still refuse most questions. prefixAskCacheOK is now the one decision. It refuses a read of 0 and a read below the last real turn's read. An optional write cap (min of 2 percent of the prefix and 2,000 tokens) is off until the owner decides. The keeper passes the turn's cache_read to the sweep through SweepPingWait. The old "write > appended tokens" allowance is removed. Refs #721 Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
The owner has not chosen the cap yet. prefixAskWriteCapEnabled is one constant, so the cap can go without a rewrite. Adds table rows for a typed-prompt tail write, and a test that the shipped switch is on. Refs #721 Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 86e92f336a07 |
blocking |
Verdict: blocking
Findings
- components/offload/extract_sweep_apply.go:797 — a quoted-marker output is offered and judged, but its drop can never be applied
- What fails: a tool output that only QUOTES marker syntax now enters the sweep at the ping
(carriesRealMarker, extract_sweep_ping.go:475, returns false when the hash is not in the
Store). The question is asked and paid for. The model's drop verdict is held. On the next cold
request,applyHeldre-checks the verdict, then skips the output, because line 797 still tests
the bareexpand.HasPlaceholder(content)— which is true for a quoted marker too. The skip
records no gate and no counter. So the new candidate class this PR adds can never produce a
saving, and nothing in/statsshows that. - Proof: trace. Ping side:
collect(extract_sweep_ping.go:475) admits the output, because
carriesRealMarker(line 621) finds no store key for the quoted hash.askstores the verdict
throughbuildHeld/putHeld(lines 584-591). Apply side:recheckHeld
(extract_sweep_recheck.go:91) has no marker test, so the output lands inres.Valid. The apply
loop at extract_sweep_apply.go:797 then hitsexpand.HasPlaceholder(content) == trueon the
same quoted text andcontinues beforeapplySweepDrop. Norep.Gateor event fires on that
path — contrastapplySweepDropfailing, which countseventApplyDeclined. The PR's own test
(TestThePingOffersAnOutputThatOnlyQuotesAMarker) covers the offer only. No test covers the
apply of a quoted-marker verdict. - Fix: at extract_sweep_apply.go:797, replace
expand.HasPlaceholder(content)with
carriesRealMarker(c, content)(the function already takes the*components.Ctxthat
applyHeldholds), so the apply side and the offer side use one rule. Count the skip when it
does fire. Add a test that a held drop on a quoting output applies on a cold request.
- What fails: a tool output that only QUOTES marker syntax now enters the sweep at the ping
Non-blocking
- components/offload/extract_sweep_ping.go:77 — the struct comment says "Never read to decide
anything here." The newLastTurnReadfield is read to decide the cache gate. The field's own
comment says so. Update the struct comment; it now states something false. - components/offload/prefixask_gate.go:19-20 — the comment says "The owner has not chosen the
cap yet (#721)", but the cap ships on andTestPrefixAskCacheOKShipsWithTheCapOnasserts that.
The comment will mislead the next reader into thinking the shipped value is unsettled. - docs/components/advanced-offload.md:466-475 — the section "When the cache read does not
happen" still describes only the zero-read and the write rules. The new below-turn rule appears
only in the gate list at line 578. Add one sentence there. - docs/data-dependence.md — the candidate gate now reads Store key-presence
(carriesRealMarker). It is presence only, and a nil Store keeps the old answer, so it likely
sits inside the existingextract_llm_sweeprow. But CLAUDE.md asks each PR to state a change of
dependence; the diff does not touch this file. Say it in the PR text or the row. - keepalive/keeper.go:828 —
turnReadis copied fromu.CacheReadeven whenusageOKis
false. This matches howprefixis built on the line above, so it is consistent; noting it only.
What I checked
- Read
CLAUDE.mdanddocs/design.md, then the full diff of all three commits and the code
around each change:cheapmodel/anthropic.go(insertAskMessage,takeLastBreakpoint,
marshalAppended,CompletePrefixed,thinkingAdjustedMaxTokens),components/offload/ extract_sweep.go(adjudicateWithand its one caller),extract_sweep_ping.go(collect,
ask,carriesRealMarker),extract_sweep_apply.go(applyHeld,replayDrops),
extract_sweep_recheck.go,prefixask_gate.go,keepalive/keeper.go(Record),
keepalive/substitute.go(sweepWaitCause,fireSweepSubstitute), and every changed test file. - Verified
adjudicateWithhas exactly one production caller (the ping path), and that
SweepPingWaitis built in production only bysweepWaitCause, which setsLastTurnRead. - Verified all prefix asks route through
cheapmodel.Anthropic.CompletePrefixed→
insertAskMessage, so the breakpoint move covers every asker; the OpenAICompletePrefixedResponses
path is untouched and carries nocache_control. - Checked the breakpoint move for the shapes I could think of: string and block content, message-level
and block-levelcache_control,ttlpreserved verbatim, count preserved (no new 4-breakpoint
400),sjson.Deletefailure leaves the message untouched (fail open, plain ping), and no
breakpoint is added when the last message has none. - Checked the gate change for regressions in the unknown-turn case (
lastTurnRead == 0): the write
cap (2% of read+write, ceiling 2000) still refuses a rebuild, e.g. read 13,440 / write 12,000.
Checked the keeper's own stop guard (CacheWrite > CacheRead, substitute.go:385) stays valid
under the new rule. - Checked
carriesRealMarkeragainstexpand.HasPlaceholder,ParseMarkers, and the StoreGet
contract (two-value return; sliding-TTL refresh on a real marker is benign). A quote whose hash
collides with a real marker id is skipped — the safe direction. - Did not run builds or tests (not approved). Findings rest on code reading only.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 86e92f336a07 |
blocking |
Verdict: blocking
Findings
- components/offload/prefixask_gate.go:49 — the write cap refuses every real question in the no-bridge shape, because the question's own text sits inside the write
- What fails: a thread whose last sent message is not
role: systemand carriescache_control(the placement Anthropic's own docs recommend for the final message). The question reads the full entry, so the read rule passes. But the write contains the whole ask prompt, so the cap refuses it. The sweep pays for every question on that thread and discards every answer. The persisted rejection says "re-created the agent's prefix instead of reading it". That is false. - Proof:
insertAskMessage(cheapmodel/anthropic.go:461-473) puts the moved breakpoint on the bridge, or on the ask when there is no bridge.marshalAppended(cheapmodel/anthropic.go:507-522) putscache_controlon the ask's own text block. So the cache write covers everything from the read boundary to that block — the whole ask text.- The ask text is large. It is the adjudication contract (482 words, internal/extract/adjudicate.go:139-180), the evidence section (254 words, :198-215, on by default — extract_sweep.go:292), up to 12 inventory lines with 90-char heads and evidence (:229-255,
maxAskItems = 12, extract_sweep.go:163), plus the opening line (ask_role.go:15). That is about 1,400 tokens; the smallest real ask is about 1,000. - The cap (prefixask_gate.go:49-56) passes only when
write <= 0.02 x (read+write), so a write of ~1,500 needs a read of ~73,500. On a 25,000-token prefix the limit is ~512. The ask alone is ~3x over it. - The PR's own test contradicts itself here: "typed prompt: a 300-token tail write passes" (extract_sweep_ping_test.go:1074) reports
write = 300for the no-bridge shape. In that shape the write cannot be 300. The ask alone is ~1,400. The row passes only because the fake asker reports an invented number. - The live replays in the comment (read 25,588, wrote 6 and 20) are all bridge-shape, where the ask sits after the breakpoint and is fresh input, not a write. They do not cover the no-bridge shape. The "wrote 20" replay also used a stub ask, not the real ~1,400-token prompt.
- Fix: keep the ask out of the write the cap judges. Either (a) put the breakpoint on a short synthetic assistant message in the no-bridge case too, so the ask stays after it (same as the bridge case, write ~6); or (b) pass the ask's own token count to the gate and judge
write - askTokensagainst the cap. A true rebuild writes the whole prefix, so it stays far above either cap.
- What fails: a thread whose last sent message is not
Non-blocking
- components/offload/extract_sweep.go:856 — a zero read with a write used to record both
sweep_prefix_cache_read_ZEROandsweep_prefix_cache_write. Now the switch records only the first. A dashboard trendingsweep_prefix_cache_writewill see those cases leave it. Say in the PR if this drop is intended. - keepalive/keeper.go:828 — no test covers that
RecordsetsturnReadfrom the turn'sCacheRead.TestSweepWaitCauseCarriesTheTurnsReadbuilds thekaEntryby hand, so a mutation of theturnRead: u.CacheReadassignment survives. - components/offload/extract_sweep_ping.go:625 —
carriesRealMarkertreats any⟪cg⟫as real. A tool output that greps this repo quotes that sentinel (expand/expand.go:29) and is skipped as a candidate. Safe direction, but it is the same fault #705 fixed for<<cg:HASH>>. The summary sentinel carries no key, so the store cannot confirm it. - docs/data-dependence.md —
carriesRealMarkeradds a new read of the Store (key existence, extract_sweep_ping.go:630-633). The sweep's row there does not mention it. CLAUDE.md asks for that update when a feature's data dependence changes. The PR body states "only key names and token counts", which covers the intent; the row should still say it.
What I checked
- The full diff
a0e5f9e5..86e92f33, all three commits, and the code around every change. insertAskMessage,takeLastBreakpoint,marshalAppended,lastBridgeand their one callerCompletePrefixed; the ask prompt assembly (internal/extract/adjudicate.go,ask.go,ask_role.go).adjudicateWithand its single caller (the ping path); the gate change and the newprefixask_gate.go;carriesRealMarkeragainstexpand.HasPlaceholder,ParseMarkers, and the #705 fix (2e29045).- The keeper side:
Record,kaEntry.turnRead,sweepWaitCause,fireSweepSubstitute, and every construction ofSweepPingWait(one, in production code). - Arithmetic traces: cap limit for read 25,516 with a 1,400-token ask; the read rule against the entry the last real turn wrote; both bridge and no-bridge shapes.
- All new and changed tests, and the gate names against
docs/components/advanced-offload.md. - No tests were run. Live tests are not approved and Go is not on this machine.
…rker check Review round 1 of #725. - A trailing user message that carries a breakpoint now also gets the "Understood." bridge, and the breakpoint moves onto the bridge. The ask stays fresh input. Before, the breakpoint sat on the ask and the cache write held the whole ask (about 1,000 to 1,400 tokens), so the write cap refused every question in that shape. - The cold apply and the replay use carriesRealMarker, the same rule as the ping's candidate scan. A drop on an output that only quotes marker text now applies. A skip on a real marker is counted (sweep_apply_already_marked). - Docs: the read rules in advanced-offload, the Store presence read in data-dependence. Refs #721 Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
|
Round 1 fixes are in the new head.
|
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | b9aeecb3ad32 |
approve |
Verdict: approve
Findings
None. Both round-1 findings are fixed, and I found no new defect in the fix commit.
Earlier findings
- Mine, round 1 — the write cap refused every question in the no-bridge shape. Fixed, with my option (a).
insertAskMessage(cheapmodel/anthropic.go:454-487) now gives a trailing user message that carries a breakpoint the "Understood." bridge, and the breakpoint moves onto the bridge. The ask is always built withmarshalAppended("user", ask, gjson.Result{}), so no shape ever puts a breakpoint on the ask. The write is now the bridge plus the turn's tail, never the ~1,400-token ask. I traced every shape:- system last: bridge always, breakpoint moved onto it (the measured shape, read 25,588 / wrote 6).
- user last with a breakpoint: bridge added, breakpoint moved onto it. Write = tail + bridge.
- user last without a breakpoint: no bridge, ask appended directly. Legal shape, no breakpoint added.
- assistant last: untouched, ask follows directly. The breakpoint stays on the assistant message; the bridge measurement shows a breakpoint on a non-last assistant message still reads the entry, and the ask after it is fresh input, so the write is 0.
- empty messages: ask only.
The invented 300-token test rows are gone from both gate test files.TestThePingGateWriteExcludesTheRealAskcounts the tokens of the real ask (asserts at least 300), then checks the gate accepts a bridge-sized write and refuses an ask-sized one. That is the right test.
- Reviewer 2, round 1 — a quoted-marker output was offered but its drop could never apply. Fixed, and I checked it myself.
applyHeld(extract_sweep_apply.go:805) andreplayDrops(:579) now callcarriesRealMarker, the same rule as the ping scan. The apply-side skip raisessweep_apply_already_marked. The trace from round 1 now ends in an applied drop: offer (quoted hash not in Store) → verdict held → cold apply uses the same rule → drop applied and replayed byte for byte on the warm request. Tests cover all three: the quoting drop applies cold and replays warm; an output whose quoted hash became real after the ping is skipped and counted; the replay uses the same rule. - Non-blocking items. The struct comment on
SweepPingWait, the cap comment, the read-rules paragraph in advanced-offload.md, and the data-dependence row are all updated. The zero-read single-gate change and the⟪cg⟫quote are stated in the PR body as intended. The keeperturnReadtest gap is left as is; I accept that — the wiring has a test and the gap is one assignment.
Non-blocking
- docs/components/advanced-offload.md:542 — the request-side gate list does not name
sweep_apply_already_marked. Round 1 added the new ping gate to this list; the new apply gate should get the same line. - PR body — two stale claims remain under "How it was tested" and "Technical notes": "a typed-prompt tail write of 300 passes" and "(15 table rows)" describe rows that this commit deleted (13 remain), and the notes still list "breakpoint on the ask" as a shape, which the code now never builds. The round-1 section corrects the record, so this is text only.
What I checked
- Last review: round 1,
86e92f336a072a50c2d234dac1c7fc459a03dd3c, 2026-10-26T00:43:00Z. - New commits read: 1 —
b9aeecb3"fix(cheapmodel): keep the breakpoint off the ask, one rule for the marker check". - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files), plus the current PR body.
- New items since my last review: reviewer 2's round-1 review (checked its finding myself against the new code), the author's round-1-fixes comment (each claim verified in the diff), and the fix commit (reviewed below).
- The full diff
86e92f33..b9aeecb3and the code around every change:insertAskMessage,askBridgeFor,takeLastBreakpoint,marshalAppended,AskBridge;applyHeld,replayDrops;carriesRealMarker's new doc; the gate file's new cap comment. - Traced all five last-message shapes through the new
insertAskMessage(system with and without breakpoint, user with and without, assistant, empty array) against the position rule, the write coverage, and the measured reads from #721. - Confirmed the removed
lastBridgehelper has no remaining callers, and every helper used by the new tests exists (applyConv,refOutput,coldCtx,warmCtx,resetSweepLedgerForTest). - Checked the apply-side bookkeeping around the new skip: a skipped output writes no drop record, and the held answer is spent on a cold request either way.
- No tests were run. Live tests are not approved and Go is not on this machine.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | b9aeecb3ad32 |
approve |
Verdict: approve
Earlier findings
- Mine, round 1 (apply side skipped quoted-marker outputs) — fixed.
applyHeld
(extract_sweep_apply.go:800-803) now callscarriesRealMarker, the same function the ping scan
calls, and counts the real-marker skip assweep_apply_already_marked.replayDrops(line 579)
uses the same rule. I verified the tests do what they claim:
TestAColdApplyDropsAnOutputThatOnlyQuotesAMarkerdrops a quoting output on a cold request and
replays it byte for byte on a warm one;TestAColdApplySkipsAndCountsAnOutputThatNowCarriesARealMarker
covers the marker-turned-real skip and its counter. - Reviewer 1, round 1 (the cap refused every no-bridge question, because the write held the whole
ask) — fixed, and I checked it myself.insertAskMessagenow never puts the breakpoint on the
ask:marshalAppended("user", ask, gjson.Result{})at cheapmodel/anthropic.go:481. A trailing
user message with a breakpoint gets the "Understood." bridge and the breakpoint moves onto it
(askBridgeFor). I traced every shape: system-last (bridge always), user-last with a breakpoint
(bridge), user-last without (no bridge, plain ask), assistant-last (untouched, plain ask). The
breakpoint can never be dropped on the floor:movedis non-empty only for system or user last
messages, and both then get a bridge. The invented "300-token tail write" test rows are gone,
replaced byTestThePingGateWriteExcludesTheRealAsk, built from the real ask's token count. - My round-1 non-blocking items — all fixed. The
SweepPingWaitstruct comment, the cap
comment in prefixask_gate.go, the read-rules paragraph in advanced-offload.md, and the
data-dependence row (presence-only Store read stated). - Reviewer 1's round-1 non-blocking items — dispositioned. The data-dependence row is updated.
The zero-read gate change is stated in the PR body (I read the body; it says one failure, one
gate — intended). The keeperturnReadassignment test and the⟪cg⟫quote were left as they
are, with reasons in the body. I accept both reasons: the first is a coverage nit on a one-field
copy, the second fails safe (the sentinel carries no key to check).
Findings
None in the new commit.
Non-blocking
- docs/components/advanced-offload.md:542-543 — the apply gate list does not name
sweep_apply_already_marked, which this PR adds. The list names the other apply gates. Add it. - cheapmodel/anthropic.go:464-466 — the assistant-last shape rests on an unmeasured assumption.
The comment cites replays for the system and user shapes only. Under the PR's own text-turn
theory, a thread whose last message is an assistant TEXT message with a breakpoint would read low
and be refused by the cap. That outcome is counted and fail-safe, and it is no worse thanmain
(the pre-PR code also left that breakpoint alone). But the PR's headline is "questions now hit the
cache", so replay one assistant-last body before calling that settled. - components/offload/extract_sweep_apply.go:579 — at replay time, a quoted hash that became a
real Store key after the drop was applied makescarriesRealMarkertrue, so the replay is
skipped. That flips the prefix back to the original bytes, and unlike the apply side the skip is
not counted. The trigger needs a stashed marker whose id equals text quoted inside that output —
a content-hash collision, so vanishingly rare. Count it if you touch this line again.
What I checked
- Last review: round 1, 86e92f3, 2026-10-26T00:41:03Z.
- New commits read: 1 — b9aeecb "fix(cheapmodel): keep the breakpoint off the ask, one rule for
the marker check". - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files), plus the PR body.
- New items since my last review: reviewer 1's round-1 review (00:43), the author's comment
(01:06), and commit b9aeecb (03:06). I checked each fix the comment claims, in the code. - The full diff
86e92f33..b9aeecb3, and the final state of every changed file around the changes:
insertAskMessage,askBridgeFor,AskBridge,takeLastBreakpoint,marshalAppended;
applyHeld,replayDrops,gateApplyAlreadyMarked; thecarriesRealMarkerdoc; the gate
comment; both docs files; and every changed test. - Compile-level checks:
lastBridgeis fully removed with no stale references; theexpandimport
removal from extract_sweep_apply.go leaves no other use; all new test helpers exist
(applyConv,refOutput,coldCtx,warmCtx,assistantMsg,userMsg,
resetSweepLedgerForTest,labelAsker.ask,Report.Replays,eventAppliedCold); test-file
imports cover the new uses. - Behavior traces: the four last-message shapes (breakpoint moved and consumed by the bridge, never
lost, never on the ask); a user-last tool_result message followed by the bridge (legal role
sequence, tool_result position rule intact); breakpoint count preserved;ttlcopied verbatim;
strip failure fails open to the pre-#721 shape. - The gate tests against the new construction: a bridge-sized write passes the cap, an ask-sized
write is refused; the removed "300-token tail" rows matched a shape the new construction no
longer produces. - Did not run builds or tests (not approved). Findings rest on code reading only.
The owner chose the read rule only (2026-10-26). The cap code and its constants stay behind prefixAskWriteCapEnabled, now false. One constant turns it on. Refs #721 Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 3 of 3 | ac89546ded5c |
approve |
Verdict: approve
The new commit
ac89546d ships the write cap OFF. prefixAskWriteCapEnabled is now false. The gate refuses a
read of 0 and a read below the last turn's read, and nothing else. This resolves the PR's open
owner decision (read rule only, 2026-10-26). I checked that every place agrees:
- The code:
prefixask_gate.go— the switch, the comment, and the unchanged read rules. - The tests:
TestPrefixAskCacheOKShipsWithTheCapOffasserts the constant is false, a large write
with a good read is accepted, and the read rule still refuses a model switch.
TestThePingGateJudgesTheReadAgainstTheLastTurnnow expects the large-write row to be held.
TestThePingGateWriteExcludesTheRealAskforces the cap on throughprefixAskJudgeto keep the
cap arithmetic covered while it is off. The cap rows inTestPrefixAskCacheOKstill passcapOn
explicitly, so nothing there depended on the shipped value. - The docs:
advanced-offload.mdsays a write alone is not refused, and names the cap as present
but off. - The PR body: "Off as shipped" with the owner decision, and the mutation list updated
(11a2, 12a).
The keeper's own stop guard (CacheWrite > CacheRead, keepalive/substitute.go:385) still
backstops the extreme case, and the cap-off switch also removes the one shape the cap could have
mis-refused. I found no defect in the commit.
Earlier findings
- Mine, round 1 (apply side skipped quoted-marker outputs) — fixed in
b9aeecb3, verified in
round 2. The new commit does not touch it. - Reviewer 1, round 1 (the cap refused every no-bridge question) — fixed in
b9aeecb3,
verified in round 2. The new commit makes the concern moot by shipping the cap off, and keeps
the ask off the breakpoint either way. - All round-1 and round-2 non-blocking items from both reviewers — the four fixed ones (struct
comment, cap comment, read-rules docs, data-dependence row) stay fixed. The open ones are listed
below; none were addressed by this commit, and none block.
Findings
None in the new commit.
Non-blocking
Still open from round 2, in priority order:
- docs/components/advanced-offload.md:542-543 — the apply gate list still omits
sweep_apply_already_marked. Both reviewers flagged it in round 2. One word. - PR body, "How it was tested" — line 40 still says "15 table rows" and "a typed-prompt tail
write of 300 passes". Those rows were deleted inb9aeecb3(13 remain). Reviewer 1 flagged this
in round 2; it is text only, but the body now also contradicts itself (that line vs. the correct
"Off as shipped" line 26). - cheapmodel/anthropic.go:464-466 — the assistant-last shape is still unmeasured. With the cap
off, a bad read there is now caught by the below-turn rule only when the keeper knows the turn's
read; the outcome stays counted and fail-safe. Still worth one replay. - components/offload/extract_sweep_apply.go:579 — the replay-side marker skip is still
uncounted. Hash-collision trigger; note stands for whoever touches the line next.
What I checked
- Last review: round 2, b9aeecb, 2026-10-26T01:13:34Z.
- New commits read: 1 — ac89546 "fix(offload): ship the prefix-ask write cap off".
- Read in full: 4 reviews, 1 comment, 0 inline comments (from the three files), plus the PR body
re-fetched after the new commit. - New items since my last review: reviewer 1's round-2 review (01:12:14, approve — read in full;
its verification of both round-1 fixes matches my own from round 2), the PR body edits (cap-off
decision and mutation-list updates), and commit ac89546 (07:28). The issue comments and inline
comments are unchanged since round 2. - The full diff
b9aeecb3..ac89546dand the final state of all four changed files: the gate
switch and its comment, all three touched test files, and the docs paragraph. - Traced the gate with the switch off: only
read_zeroandread_below_last_turncan fire;
sweep_prefix_cache_writeis unreachable in production, and the docs say so. - Checked no test still depends on the shipped cap value: every cap assertion either passes
capOnexplicitly or forces the switch throughprefixAskJudge, and the one shipped-value test
asserts OFF. - Did not run builds or tests (not approved). Findings rest on code reading only.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 3 of 3 | ac89546ded5c |
approve |
Verdict: approve
Findings
None. The new commit turns the write cap off, and I found no defect in it.
The new commit
ac89546d ships prefixAskWriteCapEnabled = false. The owner chose the read rule only (2026-10-26, #721). I checked the change is consistent everywhere:
- Code:
prefixAskCacheOKnow judges the read rules only. The cap, its constants, and theprefixAskWriteOverCaparm stay behind the switch, so one constant turns it back on. - Tests: the end-to-end row now asserts a 12,142 write with a good read is accepted and no write gate fires.
TestThePingGateWriteExcludesTheRealAskforces the cap on throughprefixAskJudge(..., true), so the cap logic and the ask-size premise stay covered.TestPrefixAskCacheOKShipsWithTheCapOffpins the constant false and that the read rule still refuses a model switch. - Docs: advanced-offload.md now says a write alone is not refused, and names the constant that turns the cap on. The PR body and the gate file comment say the same.
The cap off is safe. Since round 2 the breakpoint sits on the bridge, so a question's write is the turn's own tail plus a few tokens — client bytes, not a defect signal. A true rebuild reads low or zero, and the read rules refuse it. The original production incident (asks that re-created the prefix) is still caught: those asks read a partial prefix, below the last turn's read.
Earlier findings
- Mine, round 1 (cap refused every no-bridge question) — fixed in round 2, unchanged by this commit. The cap question is now closed by the owner's decision, and the fix that made the cap safe (bridge carrier, ask as fresh input) stays in the code.
- Reviewer 2, round 1 (apply side skipped quoted-marker outputs) — fixed in round 2, unchanged by this commit.
- Round-2 non-blocking items. Reviewer 2's assistant-last note (live replay not done) and replay-skip note (not counted) were left with no reply; both are fail-safe and rare, and I accept them. My two doc items below are still open.
Non-blocking
- docs/components/advanced-offload.md:542 — the apply gate list still does not name
sweep_apply_already_marked. Both reviewers raised this in round 2; the new commit does not address it and no comment explains why. One line. - PR body, "How it was tested" — the stale claims from round 2 remain: "(15 table rows)" and "a typed-prompt tail write of 300 passes" describe rows deleted in round 2 (13 remain). Text only.
What I checked
- Last review: round 2,
b9aeecb3ad321d4c2c977c33736cc613e44b9c54, 2026-10-26T01:12:14Z. - New commits read: 1 —
ac89546d"fix(offload): ship the prefix-ask write cap off". - Read in full: 4 reviews, 1 comment, 0 inline comments (from the three saved files), plus the current PR body.
- New items since my last review: reviewer 2's round-2 review (01:13, read in full; its fixes-verified claims checked against the code in round 2 and re-confirmed at this head), the new commit (reviewed above), and the PR body's cap-decision edits (verified against the code).
- The full diff
b9aeecb3..ac89546dand the final state ofprefixask_gate.go, both gate test files, and the docs paragraph. - Confirmed
prefixAskWriteCapEnabledhas no reader outside the gate file and its tests, and that the docs gate list and read-rules paragraph match the shipped behavior. - No tests were run. Live tests are not approved and Go is not on this machine.
…ds the cache (#491) - Rewrite model. The provider reads back only up to a cache entry an earlier request wrote before the change. A drop farther back than warmLookbackBlocks (20 content blocks) from the last breakpoint reaches only the fixed system prompt and tools, so the rewrite is the whole conversation. A drop inside the look-back rewrites only the tail from the drop. In 6,968 recorded Opus calls every large cache drop read back exactly the fixed size. - Mass gate: ask only when the removable mass is at least warm_min_mass_frac (0.20) of the conversation. The trigger's expected turns are the warm turns run so far, capped. Every refusal at the trigger is counted by reason. - The warm question is judged by prefixAskCacheOK against the turn's own read (#725), with no write check of its own. - Each applied warm sweep records the tokens removed, the conversation before and after, the gate's numbers and the expected net, in /stats and as events on the dashboard row. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
…ds the cache (#491) - Rewrite model. The provider reads back only up to a cache entry an earlier request wrote before the change. A drop farther back than warmLookbackBlocks (20 content blocks) from the last breakpoint reaches only the fixed system prompt and tools, so the rewrite is the whole conversation. A drop inside the look-back rewrites only the tail from the drop. In 6,968 recorded Opus calls every large cache drop read back exactly the fixed size. - Mass gate: ask only when the removable mass is at least warm_min_mass_frac (0.20) of the conversation. The trigger's expected turns are the warm turns run so far, capped. Every refusal at the trigger is counted by reason. - The warm question is judged by prefixAskCacheOK against the turn's own read (#725), with no write check of its own. - Each applied warm sweep records the tokens removed, the conversation before and after, the gate's numbers and the expected net, in /stats and as events on the dashboard row. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
…ds the cache (#491) - Rewrite model. The provider reads back only up to a cache entry an earlier request wrote before the change. A drop farther back than warmLookbackBlocks (20 content blocks) from the last breakpoint reaches only the fixed system prompt and tools, so the rewrite is the whole conversation. A drop inside the look-back rewrites only the tail from the drop. In 6,968 recorded Opus calls every large cache drop read back exactly the fixed size. - Mass gate: ask only when the removable mass is at least warm_min_mass_frac (0.20) of the conversation. The trigger's expected turns are the warm turns run so far, capped. Every refusal at the trigger is counted by reason. - The warm question is judged by prefixAskCacheOK against the turn's own read (#725), with no write check of its own. - Each applied warm sweep records the tokens removed, the conversation before and after, the gate's numbers and the expected net, in /stats and as events on the dashboard row. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
…ds the cache (#491) - Rewrite model. The provider reads back only up to a cache entry an earlier request wrote before the change. A drop farther back than warmLookbackBlocks (20 content blocks) from the last breakpoint reaches only the fixed system prompt and tools, so the rewrite is the whole conversation. A drop inside the look-back rewrites only the tail from the drop. In 6,968 recorded Opus calls every large cache drop read back exactly the fixed size. - Mass gate: ask only when the removable mass is at least warm_min_mass_frac (0.20) of the conversation. The trigger's expected turns are the warm turns run so far, capped. Every refusal at the trigger is counted by reason. - The warm question is judged by prefixAskCacheOK against the turn's own read (#725), with no write check of its own. - Each applied warm sweep records the tokens removed, the conversation before and after, the gate's numbers and the expected net, in /stats and as events on the dashboard row. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Review round 1 of #777 found doc comments that still described the #721 move. CompletePrefixed, the #725 paragraph, askBridgeFor and the write-cap note in prefixask_gate.go now say the question changes no existing byte and copies the breakpoint onto the bridge only below the provider's 4-breakpoint cap. One test is renamed to match. No code change. Refs #776 Assisted-By: Claude Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
… (#777) fix(cheapmodel): the prefix question keeps the turn's breakpoint (#776) The sweep question at a keep-alive ping moved the turn's last breakpoint onto its "Understood." bridge (#721). The question read the turn's cache entry, but only the entry it named got a new lifetime. The turn's own entry expired 5 minutes after the turn, so the plain ping 2 after the question wrote the whole conversation again. The last message now keeps its breakpoint. The bridge gets a copy only while the request stays at or under the provider's 4 breakpoints. Live, ping 2 after the question, Sonnet 5.5: read 13,487 / write 18,053 before, read 31,542 / write 0 after. Opus 5.5: 13,371 / 18,214 before, 31,592 / 0 after. Fixes #776 Assisted-By: Claude Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: DAVID AMID <[email protected]> docs(offload): the prefix question keeps the turn's breakpoint (#776) Refs #776 Assisted-By: Claude Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: DAVID AMID <[email protected]> docs(cheapmodel): say the breakpoint is copied, not moved (#776) Review round 1 of #777 found doc comments that still described the #721 move. CompletePrefixed, the #725 paragraph, askBridgeFor and the write-cap note in prefixask_gate.go now say the question changes no existing byte and copies the breakpoint onto the bridge only below the provider's 4-breakpoint cap. One test is renamed to match. No code change. Refs #776 Assisted-By: Claude Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
Summary
Sweep questions now hit the cache, and the sweep gate accepts a correct answer.
Fixes #721. Blocks v0.6.0.
What we found
role: systemmessage. It holds the lastcache_controlbreakpoint.insertAskMessagekept that breakpoint there and appended the bridge and the ask with none.What changed
insertAskMessagemoves the last message's breakpoint onto the "Understood." bridge. A trailing user message with a breakpoint now gets the bridge too, so the breakpoint never sits on the ask (the cache write would hold the whole ask, 1,000 to 1,400 tokens).cache_controlobject as is, sottlstays.prefixAskCacheOK(components/offload/prefixask_gate.go).sweep_prefix_cache_read_ZERO).sweep_prefix_cache_read_below_turn).prefixAskWriteCapFracandprefixAskWriteCapMax, behind the constantprefixAskWriteCapEnabled. Off as shipped. The owner chose the read rule only, on 2026-10-26. The code and constants stay; set the constant true to turn the cap on. A refusal by the cap usessweep_prefix_cache_write.turnRead, set at record time) throughSweepPingWait.LastTurnRead. No DB read. Unknown (0) means only the read-of-0 rule applies.carriesRealMarker, decides on the ping side AND the cold apply and replay. A skip on a real marker in the apply is counted (sweep_apply_already_marked). The ping candidate scan skips only real markers: the summary sentinel, or a<<cg:HASH>>whose HASH is in the store. Text that only quotes marker syntax is a candidate. Same fault as fix(offload): cache_aware_summarizer cut every span at quoted marker text #705.insertAskMessageandCompletePrefixedare corrected.How it was tested
All on eval box 1,
-count=1. Fullgo test ./...passes.-racepasses on cheapmodel, components/offload, keepalive and proxy. No known flake hit. No live model calls.New tests, each failing on main
a0e5f9e5:TestInsertAskMessageMovesTheTrailingBreakpoint(4 cases): fails on main, the old message keepscache_controland the carrier has none.TestInsertAskMessageAddsNoBreakpointWhenTheLastHasNone: guards against adding a breakpoint.TestPrefixAskCacheOK(15 table rows): A5 passes, model switch refused, read 0 refused, a typed-prompt tail write of 300 passes (the case the old rule got wrong), large write refused only with the cap on.TestPrefixAskCacheOKShipsWithTheCapOff: the shipped constant is off, a large write with a good read is accepted, and the read rule still refuses a model switch. The cap rows force it on throughprefixAskJudge.TestThePingGateJudgesTheReadAgainstTheLastTurn: end to end through the sweep. On main the A5 rows (small write) are refused.TestSweepWaitCauseCarriesTheTurnsRead: the keeper passes the turn's read.TestSweepPrefixWriteTripsTheCounterEvenOnAPartialHitwas rewritten: the partial hit is now caught by its low read.TestThePingOffersAnOutputThatOnlyQuotesAMarker: on main, no question is offered (no_inventory).Mutations, each killed by its test:
ttlwhen moving.expand.HasPlaceholder.11a. Bridge: breakpoint back on the ask; no bridge for a user message; bridge for every user message; touch an assistant-last message.
11a2. Shipped cap constant flipped on.
11b. Apply side: bare marker rule; apply never skips; replay with the bare rule.
12a. Gate: shipped cap switch off.
LastTurnRead.turnRead.One more mutation survives and is equivalent: dropping the
lastTurnRead > 0guard. A read is never below 0, so the guard is redundant. It stays for clarity.Two existing tests used a marker with no stashed original. They now stash it, as a real marker has one.
Review round 1 (#725)
carriesRealMarker. Tests: a quoting output is dropped on a cold request and replayed on a warm one; a real marker is skipped and counted.TestThePingGateWriteExcludesTheRealAsk).Other gates (F2 scope)
CacheWrite > CacheRead || CacheRead == 0): no change. This judges the ordinary ping, not a prefix-ask answer. It already allows a small write. A question that reads 25,588 and writes 20 passes.CacheWrite > CacheRead): stop rule for the sweep substitute. Left as is. It stops only when the write exceeds the read, which a question that read the prefix never does. It is not a refusal of the answer.Substituted = read > 0 || write > 0): not a refusal. No change.Open questions
Technical notes
Assisted-By: Claude Opus 5.5
sweep_prefix_cache_read_ZERO, not alsosweep_prefix_cache_write. This is intended: it is one failure.⟪cg⟫sentinel quoted in a tool output is still skipped as a candidate. It has no key to check. Safe direction.