Skip to content

feat(sweep): sweep v3, rules and one big cut on the warm path - #763

Merged
amiddavid merged 14 commits into
mainfrom
feat/sweep-v3-rules
Nov 11, 2026
Merged

amiddavid merged 14 commits into
mainfrom
feat/sweep-v3-rules

Conversation

@amiddavid

@amiddavid amiddavid commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Data dependence change (owner approved 2026-10-28; path hash approved 2026-11-01). The rules read tool names, tool input paths and commands from the request in flight. The drop record in the Store now also keeps the tool name, the tool class (read, edit, command, other) and an 8-byte hash of the file path or command. The path itself is never stored. The extract_llm_sweep row in docs/data-dependence.md is updated. "Decided by" stays the owner.

Base is main. #720 (the warm sweep) is merged as 54a51b5. This PR holds only the v3 work on top of it.

Summary

  • Sweep v3 is a setting of the warm path. It is not a new component.
  • It makes one big cut late, when the prompt is near the compaction point.
  • Rules pick clear drops with no model call.
  • Every v3 setting is off by default. The default config gives the same bytes as main. A test proves it.

What changed

  1. Sweet spot. Try a cut when P >= fill(C) x C. fill is fill_small (0.70) at C <= 200k and fill_large (0.6) at C >= 1M, linear between. C is CutFrac x window with a summarizer, else the compaction point (unless its source is the window fallback), else the window.
  2. compaction_point in MODEL_PRICES (optional, billed tokens, beside window). It does not change the window. The proxy, the summarizer and the dashboard read it first. Nothing changes unless it is set.
  3. One cut per round. After an accepted cut, wait until P grows by min_drop_frac x C. A refusal does not start the wait. No judge question runs during the wait.
  4. Meaningful drop. D >= min_drop_frac x P (default 0.15).
  5. Payback. The warm gate is the last check. v3 prices the saving on N, the turns until the compaction would come without the cut. N' (turns after the cut) is only logged.
  6. selector: judge (default), rule (no model call), hybrid (one cut).
  7. Rules. (a) file_reread. (b) build_rerun. (c) rule_unreferenced (off by default): drop an output that nothing later references. Every rule obeys every protection.
  8. Protected: protect_tools, protect_paths, protect_last_n (default 10), anything expanded, any marker output.
  9. dry_run (default false): everything runs, no cut is made. The forwarded request has no drops.
  10. Drop record and re-reads. The record stores which rule or the judge chose the drop and the path hash. /stats v3.reread_after_drop counts later re-reads by source and kind. v3.expands counts first expands by source.
  11. compaction_premium_usd (default 0, experiment): when a cut postpones the compaction, the premium joins the saving side. v3.cuts_on_cost and v3.cuts_on_premium show which cuts needed it.
  12. Counters in /stats under keepalive.sweep_warm.v3 and in the decision log.

How it was tested

Eval box 1, on head 9ea9277, -count=1:

  • make lint: clean.
  • go test ./...: all 48 packages ok (run on the head before the last rebase onto Fix: Price rows booked at $0 before the price map loaded #1002).
  • -race: components/offload (625 s), keepalive, config, internal/compactionpoint, internal/modelinfo, apply, proxy (603 s), dash (851 s). All ok.
  • mkdocs build --strict: ok.
  • After the last rebase (Fix: Price rows booked at $0 before the price map loaded #1002, unrelated): lint, dash, components/..., internal/..., config and mkdocs run again. All ok.
  • New tests are in extract_sweep_v3_test.go, apply/sweep_dryrun_test.go, dash/operatorpoint_test.go, internal/compactionpoint, internal/modelinfo, proxy/compactionpoint_resolve_test.go. The default-config test (same bytes as main, no v3 counter) still holds.
  • Mutation checks from the earlier rounds still apply (fill clamp and slope, sweet-spot gate, min-drop gate, growth wait, refusal starting the wait, rule scope, marker and expanded exclusion, protections, selector behavior, v3 on by default).
  • No live run, per the repo rule.

Open questions

  • Rule drops count toward D at the gate, not toward the trigger estimate. Say if you want otherwise.
  • "Same command" is an exact match after white space collapse.

Technical notes

Part of #491.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 c7df5ddf8706 blocking

Verdict: blocking

Findings

  1. components/offload/extract_sweep_ping.go:497 — the v3 protections and gates do not cover the keep-alive ping question, so a protected output can still be dropped and selector: rule still pays model calls
    • What fails: the operator sets warm: true, selector: rule and protect_tools: [TodoWrite]. The thread goes idle. The keep-alive fires a ping. SweepPingSubstitute (called by keepalive/substitute.go:398 for any registered thread, with no v3 check) collects candidates. In collect, the v3 plan runs only when cand.warm is true (if cand.warm && e.v3, line 497). A ping candidate has warm: false, so:
      • the judge is asked a model question, although the doc for selector: rule says "No model call." (docs/components/advanced-offload.md:667);
      • the judge is offered the TodoWrite output, although the doc says such outputs are "Never dropped, by rule or by judge" (docs/components/advanced-offload.md:677);
      • the answer is written to the Store, and the next cold request applies it through coldStep → applyHeld → storeHeld (extract_sweep.go:600, extract_sweep_apply.go:784), a path that has no v3 gate and no protection filter. The drop happens.
    • Proof: trace the code paths. registerPing (extract_sweep_ping.go:258) registers a candidate on every request when v3 is on; nothing disables ping questions when warm: true or when v3 is on — the warm path and the ping path coexist by design (the latch in runWarmQuestion only stops a ping that fires after a warm question). v3Dispatch's cold branch (extract_sweep_v3.go:497-508) reads only the in-memory answer (in.hasHeld is t.held != nil); the ping's Store answer is applied by coldStep, which never consults e.v3.
    • Fix: pick one and make code and docs agree. Either (a) apply the v3 plan in collect for ping candidates too, filter protected ids when a stored answer is applied, and refuse the ping question outright when selector: rule; or (b) keep the ping path as it is and scope every v3 promise in docs/components/advanced-offload.md to the warm path ("no model call on the warm path", "never dropped by a v3 cut"). Add a test for whichever behavior is chosen.

Non-blocking

  • extract_sweep_v3.go:809 — var _ = thread.Key exists only to keep an unused import. Remove the import and the line.
  • extract_sweep_v3.go:543 — if in.cold { return nil, 0 } inside v3Step is dead: v3Dispatch routes every cold request away before v3Step runs.
  • extract_sweep_v3.go:409-410 — newV3Held writes Tokens: h.saves. heldOutput.Tokens means the output's own size (extract_sweep_hold.go:47-49). No reader uses it today, so nothing breaks, but the field carries a wrong value for the next reader.
  • extract_sweep_v3.go:549-560 — the cut_point_unknown and not_in_sweet_spot refusals are counted on every warm request once v3 is on, before any pace gate, and a thread's first request (P = 0) counts as cut_point_unknown. On a deployment without an exact window this fills refused with noise and hides the real reasons.
  • extract_sweep_v3.go:603-611 — v3Asked stays true after an answer that was applied and refused, so a carried set that later expires makes the hybrid rules-only branch fire and count hybrid_rules_only ("the judge gave no answer") although the judge did answer. The rules still pass the same gates, so the cut itself stays safe; only the counter and the label are wrong.
  • extract_sweep_v3.go:656-663 — a changed-prefix apply of a v3 answer skips the v3 gate (it is warm-gated only), so it drops outputs without counting a cut or starting the growth wait. The next attempt finds markers, so nothing is dropped twice; only the ledger under-counts.

What I checked

  • The full diff of 6298673..c7df5ddf and the code around each change: extract_sweep_v3.go in full, warmStep/warmGate/carryRefused/warmHold/memHeld in extract_sweep_warm.go, applyHeldFrom/recheckHeld/heldAnswer in extract_sweep_apply.go and extract_sweep_recheck.go, collect and the ping registry in extract_sweep_ping.go, Offload's cold/warm ordering in extract_sweep.go, keeper.go's stats wiring.
  • The v3 gates against the doc: sweet spot (v3Fill), one cut per round (v3Baseline/v3Await, shrink ends the wait), meaningful drop (gate 3 in v3Gate), payback (the #720 gate, unchanged). All four match the doc.
  • The rule engine: file_reread and build_rerun conditions, marker and expanded exclusions, protect_last_n/protect_tools/protect_paths (glob semantics via globRegexp, test table covers the tricky cases), rule precedence over judge verdicts in combine, judge-only carrying in carryRefused.
  • Config parsing: v3 off by default, selector: judge alone does not switch it on, settings without warm: true are accepted and do nothing, out-of-range values fall back to the defaults, unknown selector is an error. The test TestV3IsOffByDefaultAndTheSettingsAreChecked covers this.
  • Fail-open and reversibility: v3 runs inside warmStep's recover; every drop goes through applyHeldFrom (marker + stash + drop record, panic restore); the default config is byte-identical to the old warm path (tested).
  • The data-dependence row and its update: rules read tool names, paths and commands in flight, store nothing new; per-thread state is two flags and one number. The row's "Decided by" (David Amid) is also the PR author, so the confirmation requirement is satisfied by the PR itself.
  • keepalive/keeper.go: V3 is an additive, nil-when-empty field; /stats stays append-only.
  • I did not run the tests: live tests are not approved and Go is not installed on this machine.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 c7df5ddf8706 blocking

Verdict: blocking

Findings

  1. components/offload/extract_sweep_ping.go:497 — sweep v3 does not govern the keep-alive ping question, so protected outputs are still dropped and selector: rule still pays model calls.
    • What fails: an operator sets warm: true plus protect_tools: [todo] (or protect_paths, protect_last_n) or selector: rule. The thread goes idle. The keep-alive ping fires the sweep question instead of a plain ping. collect builds the v3 plan only when cand.warm is true, so the ping judge is offered every protected output. The judge's drop verdict goes to the Store (putHeld, extract_sweep_ping.go:675). The next cold request applies it through coldStep → applyHeld (extract_sweep_apply.go:612) with no v3 filter and no gate. Two documented contracts break: "Never dropped, by rule or judge" (docs/components/advanced-offload.md:677) and "rule: rules only. No model call." (docs/components/advanced-offload.md:667).
    • Proof: trace, all in the PR head. Offload registers a ping candidate on every request (extract_sweep.go:573, registerPing has no warm or v3 condition). The keeper calls SweepPingSubstitute on every due ping (keepalive/keeper.go:2050, fireSweepSubstitute; no warm or v3 condition there either). SweepPingSubstitute → cand.collect (extract_sweep_ping.go:434) with cand.warm == false (only runWarmQuestion sets warm: true, extract_sweep_warm.go:1110-1111). Line 497 then skips v3Plan, so v3p.protected and v3p.ruleIdx are empty and lines 511-518 pass protected outputs to the judge. In rule mode nothing stops the ping question, so the model call the selector forbids is still paid. The stored answer applies cold with no protection check.
    • Fix: build the v3 plan in collect whenever e.v3 is on, not only for warm questions. For selector: rule, refuse the ping question (count it, as other refusals are). Or filter protected outputs from a Store-held answer before the cold apply. Add a test that runs a ping question under v3 and proves a protected output survives and rule makes no call. No test in extract_sweep_v3_test.go covers the ping path or the v3 cold branch.

Non-blocking

  • extract_sweep_v3.go:81 — the comment on parseSweepV3 says "A v3 setting without warm: true is an error". The code silently turns v3 off (lines 99-102), and TestV3IsOffByDefaultAndTheSettingsAreChecked pins that. The PR text also says "does nothing". Fix the comment; it states the opposite of the behavior.
  • extract_sweep_v3.go:409-410 — newV3Held writes Tokens: h.saves. The field is documented as "the output's own size" (extract_sweep_hold.go:49). Nothing reads Tokens on this path today, so it is latent, but a future reader will misprice it. Write the output's token count.
  • extract_sweep_v3.go:543-545 — if in.cold { return nil, 0 } in v3Step is dead code. v3Dispatch routes every cold request to the apply path at lines 494-495, so v3Step never sees in.cold.
  • extract_sweep_v3.go:497-507 — the cold apply of a waiting judge answer does not clear t.v3Asked and does not arm v3Await. Later, one spurious hybrid_rules_only attempt can fire. All v3 gates still check it, so the outcome stays safe.
  • extract_sweep.go:1313 — the fill_small hint says only fill_small, fill_large and min_drop_frac switch v3 on. protect_tools, protect_paths and protect_last_n also do (extract_sweep_v3.go:92-95). The doc page and the v3 file header list all of them; make the hint agree.
  • extract_sweep_v3.go:809 and extract_sweep_v3_test.go:597-598 — var _ = thread.Key and the test equivalents are unused-import shims. Remove them and the imports.

What I checked

  • The full diff 6298673..c7df5dd: extract_sweep_v3.go (all 809 lines), the warm, ping, apply and hold changes, the keeper stats wiring, both docs pages, and the new test file (all 598 lines).
  • The machinery v3 plugs into, read in full: warmStep, warmGate, applyHeldFrom, recheckHeld, carryRefused, memHeld/warmHold/mergeHeld, registerPing, SweepPingSubstitute, collect, ask, buildHeld/putHeld, changePoint, marker generation (markToken, commitMark), warmFor eviction, FillDenominator, PrevBilledInputThread.
  • Gate arithmetic: sweet spot, one-cut-per-round baseline and shrink reset, drop_too_small on both the rule pre-check and the apply gate, payback hand-off to #720's gate. Traced the hybrid one-cut ordering (waiting answer, rules-only fallback, ask) against the tests.
  • Reversibility and fail-open: every v3 drop goes through applySweepDrop, so a <<cg:HASH>> marker and a Store stash back it. Panics recover per request. Rule drops are content-deterministic markers, so a concurrent double apply writes the same bytes.
  • Config parsing: defaults, out-of-range clamps, glob translation (traced each test case), selector validation, the "v3 off unless a setting is written" rule, and the settings-registry declarations against components/registry.go.
  • Data dependence: docs/data-dependence.md row updated; the PR states the owner approved it on 2026-10-28; nothing new is written to the Store.
  • I did not run builds or tests (not approved). Claims above come from reading the code, not from executing it.

amiddavid added a commit that referenced this pull request Oct 28, 2026
)

Review round 1 on #763.

- the ping question builds the v3 plan: no protected output is offered,
  and in hybrid no rule-decided output
- selector rule refuses the ping question (ping_refused_rule)
- a Store answer applied cold skips protected outputs
- a cold or changed-prefix apply counts as a cut and starts the wait
- rule drops record their own token count
- refusals not_in_sweet_spot and cut_point_unknown count once per
  warm_every_n; a request with no billed size counts nothing
- hybrid_rules_only counts only a real "no answer"
- remove dead code and unused imports; fix comments and hints

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1 fixes are in at the head below. Verified on eval box 1: -race on components/offload, keepalive, config; make lint; mkdocs build --strict; go test on proxy and components/all.

Blocking: v3 did not cover the ping question. Fixed (option a).

  1. collect now builds the v3 plan whenever v3 is on. The ping never offers a protected output. In hybrid it does not offer a rule-decided one.
  2. selector: rule refuses the ping question (SweepReasonV3Rule, counted as ping_refused_rule). The ping stays plain. No model call.
  3. A Store answer applied cold goes through v3Filtered, which removes protected ids first (cold_protected_filtered).
  4. Tests, each with a killed mutation: TestV3PingQuestionNeverOffersAProtectedOutput, TestV3RuleSelectorMakesNoModelCallAtThePing, TestV3HybridPingDoesNotOfferRuleDecidedOutputs, TestV3ColdApplyOfAStoredAnswerSkipsProtectedOutputs.

Non-blocking, all fixed

  • parseSweepV3 comment now says "does nothing".
  • newV3Held writes the output's own token count to Tokens (TestV3RuleDropsRecordTheirOwnTokenCount).
  • The dead if in.cold is gone from v3Step.
  • The var _ = thread.Key shims and the unused imports are gone, in code and test.
  • The fill_small hint lists every setting that turns v3 on.
  • v3Asked is cleared when an answer is used. hybrid_rules_only now counts only a real "no answer".
  • not_in_sweet_spot and cut_point_unknown count once per warm_every_n warm requests. A request with no billed size counts nothing (TestV3PacedRefusalsAreCountedOncePerQuestionInterval).
  • A cold or changed-prefix apply under v3 counts as a cut and starts the growth wait (TestV3ACountedCutOnAColdApplyStartsTheGrowthWait).

New mutations, all killed: ping plan only when warm; ping rule not refused; hybrid ping offers rule-decided; cold apply unfiltered; cold cut not counted; Tokens = Saves; pace ignored; P = 0 counted.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 8637651b1970 approve

Verdict: approve

Earlier findings, dispositions

  1. Reviewer 2, round 1, finding 1 (blocking): v3 did not cover the ping question. — Fixed. The author chose option (a), commit 8637651b. I checked each part:
    • collect builds the v3 plan whenever v3 is on, not only for warm questions (extract_sweep_ping.go:504). The ping judge never sees a protected output (line 518) and, in hybrid, never a rule-decided one (line 522).
    • selector: rule refuses the ping question before the collection slot and before the asked check (extract_sweep_ping.go:411-413). SweepReasonV3Rule makes the keeper send a plain ping (it logs the reason and returns false), so the path fails open. ping_refused_rule is counted.
    • A Store answer applied cold goes through v3Filtered (extract_sweep_apply.go:786-789). It removes protected ids from the answer (extract_sweep_v3.go:853-869) and counts cold_protected_filtered. So an answer stored before a config change cannot drop a protected output.
    • Tests cover each part: TestV3PingQuestionNeverOffersAProtectedOutput, TestV3RuleSelectorMakesNoModelCallAtThePing, TestV3HybridPingDoesNotOfferRuleDecidedOutputs, TestV3ColdApplyOfAStoredAnswerSkipsProtectedOutputs (extract_sweep_v3_test.go:598, 607, 624, 640).
  2. Reviewer 1, round 1, finding 1 (blocking): the same ping-path gap. — Fixed by the same change. I checked it myself, as above. We found it independently in round 1.
  3. Round 1 non-blocking items (both reviewers, same set): all fixed.
    • parseSweepV3 comment now says "does nothing" and matches the code. Fixed.
    • newV3Held writes the output's own token count to Tokens (extract_sweep_v3.go:410). TestV3RuleDropsRecordTheirOwnTokenCount pins it. Fixed.
    • The dead if in.cold block is gone from v3Step. Fixed.
    • The unused-import shims (var _ = thread.Key and the test equivalents) are gone. Fixed.
    • The fill_small hint now lists every setting that switches v3 on. Fixed.
    • v3Asked is cleared when an answer is used, applied or refused (extract_sweep_v3.go:673-680), and v3CutDone clears it on every counted cut (line 697). A later expiry can no longer count a false hybrid_rules_only. Fixed.
    • The cut_point_unknown and not_in_sweet_spot refusals count once per warm_every_n warm requests (extract_sweep_v3.go:545-571), and a request with no billed size counts nothing. Fixed.
    • A cold or changed-prefix apply counts as a cut and starts the growth wait (extract_sweep_apply.go:791-798, extract_sweep_v3.go:509-513 and 682-689). Fixed.

No finding was rejected by the author. Every round-1 finding is fixed.

Findings

None. The fix commit introduces no defect I could prove.

Non-blocking

  • extract_sweep_apply.go:787-789 — applyHeld builds the v3 plan on every request when v3 is on, before it knows whether the Store holds an answer for the thread. Under rule or hybrid the plan runs the full rules over the conversation. Most requests have no stored answer, so applyHeldFrom returns at the first get miss and the plan work is wasted. Consider checking for an answer first, then building the filter.
  • extract_sweep_apply.go:793 and extract_sweep_v3.go:511 — the cut records of a cold apply label every drop a judge drop (judge: changed). The warm gate splits rule drops from judge drops through ruleOf (extract_sweep_v3.go:732-738); the cold paths do not. Under hybrid, an in-memory answer can carry rule verdicts, so rule_drops under-counts on a cold apply. Ledger labels only; the cut itself is correct.
  • extract_sweep_ping.go:411 — under selector: rule every due ping is refused at the substitute, but registerPing still keeps a full conversation snapshot per thread and the keeper still calls it. The snapshot is never read. Consider skipping registration when v3 and rule are both on.

What I checked

  • Last review: round 1, sha c7df5ddf870681dc60044d1408fe85e6b6b904ab, submitted 2026-10-28T11:05:19Z.
  • New commits read: 1 — 8637651b "fix(sweep): cover the ping question and the cold apply in sweep v3 (#491)" (7 files, +220 −25). Read the full git diff c7df5ddf..8637651b and the code around every hunk.
  • Read in full from the saved lists: 2 reviews (my round 1, reviewer 1's round 1), 1 comment (the author's fix summary, 2026-10-28T11:29:10Z), 0 inline comments (the file is empty).
  • New items since my last review, with dispositions: the fix commit, read as a first review — approve with 3 non-blocking notes; the author's comment — claims the tests ran on eval box 1 with -race and the mutations were killed. I cannot run Go on this machine, so I verified the fixes by reading the code and the tests, not by running them.
  • The fix against each promise in the docs: the ping question under judge and hybrid never offers a protected output; under rule the ping stays plain; a cold apply skips protected ids; a cold apply counts as a cut; refusals are paced. All confirmed in docs/components/advanced-offload.md and the code.
  • The new SweepReasonV3Rule against the keeper: fireSweepSubstitute logs the reason string and returns false, so a plain ping goes out. No keeper change was needed. Confirmed.
  • The pacing arithmetic: warmEveryN is clamped to at least 1, so t.v3Reqs % e.warmEveryN cannot divide by zero. v3Reqs counts only warm requests, because v3Dispatch routes cold requests away from v3Step. Confirmed.
  • v3Filtered against the apply machinery: get strips without counting, claim strips and counts, so cold_protected_filtered fires only when an apply proceeds. The panic put-back writes the stripped answer, which is safe: a protected output must never be dropped anyway. A fully protected answer is spent without effect, which is the intended read-once behavior. Confirmed.
  • The new tests: read all 7 (extract_sweep_v3_test.go:598-707). Each names the behavior it pins, and each matches the code paths I traced by hand.
  • I did not run the tests: live tests are not approved and Go is not installed on this machine.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 8637651b1970 approve

Verdict: approve. The blocking finding is fixed and tested. Two small items stay, both non-blocking.

What I checked

  • Last review (round 1, c7df5dd, 2026-10-28T11:07:29Z)
  • New commits read: 1 (8637651 fix(sweep): cover the ping question and the cold apply in sweep v3 (#491))
  • Read in full: 2 reviews, 1 comment, 0 inline comments
  • Each new item since my last review, and what I did about it:
    1. Commit 8637651 — read the full diff and the code around each change in all 7 files. Results below.
    2. Author comment (2026-10-28T11:29:10Z) — checked every claim against the code. All 4 blocking-fix claims hold; all 8 non-blocking claims hold (one only in part, see finding 2).
    3. Reviewer 2's round-1 review — read in full. The main finding matches mine; I checked its 3 unique non-blocking items myself before agreeing (all fixed, one in part).
    4. No new inline comments, no other comments.

Earlier findings

Finding 1 (blocking, mine; reviewer 2's finding 1 is the same — I agree, I checked it myself): v3 did not govern the ping question or the cold apply. FIXED.

I traced each half of the fix:

  1. collect builds the plan whenever v3 is on (if e.v3, extract_sweep_ping.go:504). A ping candidate no longer skips v3Plan. Protected outputs are not offered. In hybrid, rule-decided outputs are not offered either (ruleIdx, same loop). Verified against TestV3HybridPingDoesNotOfferRuleDecidedOutputs: 8 outputs, 3 rule-decided and 1 protected leave 4 offered.
  2. selector: rule refuses the ping before the asked latch, the slot and the model call (extract_sweep_ping.go:410-413). It returns SweepReasonV3Rule and counts ping_refused_rule. The keeper sees the same shape as every other refusal, so the ping stays plain. No asker call: TestV3RuleSelectorMakesNoModelCallAtThePing pins asker.calls == 0.
  3. The cold apply filters the Store answer: applyHeld wraps storeHeld in v3Filtered when v3 is on (extract_sweep_apply.go:786-789). strip removes every protected id. It counts cold_protected_filtered on claim only, not on get, so one apply counts once. The stripped answer is still spent — the safe direction: a lost removal, never a dropped protected output.
  4. A stored answer made before a config change cannot drop a now-protected output. TestV3ColdApplyOfAStoredAnswerSkipsProtectedOutputs models exactly that: an answer stored by a non-v3 sweep, applied under v3 with protect_last_n: 1.

The two doc promises hold again: "No model call" (advanced-offload.md:667) and "Never dropped, by rule or judge" (:677). The doc states the new ping and cold-apply behavior (:671-674) and the two new refusal reasons.

My non-blocking items:

  1. parseSweepV3 comment — fixed. It now says "does nothing" (extract_sweep_v3.go:79), which is what the code and the test pin.
  2. Tokens: h.saves — fixed. v3Hit carries tokens (the output's own TextTokens), and newV3Held writes it (extract_sweep_v3.go:362, 410). TestV3RuleDropsRecordTheirOwnTokenCount pins Tokens above Saves.
  3. Dead if in.cold in v3Step — fixed. Removed.
  4. Cold apply of a waiting answer leaves v3Asked set — fixed in part. When the apply changes something, v3CutDone clears v3Asked and arms v3Await. When it changes nothing, see finding 2 below.
  5. fill_small hint — fixed. It lists all seven settings that switch v3 on (extract_sweep.go:1313).
  6. var _ = thread.Key shims — fixed. Gone from the code and the test, with the imports.

Reviewer 2's unique non-blocking items (I checked each myself):

  1. Refusal noise — fixed. t.v3Reqs paces not_in_sweet_spot and cut_point_unknown at one per warm_every_n warm requests; P <= 0 counts nothing (extract_sweep_v3.go:545-573). warmEveryN cannot be 0: the config clamps <= 0 to the default and the registry declares Min: 1, so the modulo is safe. TestV3PacedRefusalsAreCountedOncePerQuestionInterval pins both halves.
  2. hybrid_rules_only mislabel — fixed on the warm path. v3Apply clears v3Asked whenever a mem answer is used, applied or refused (extract_sweep_v3.go:673-680). The cold-apply residual is finding 2 below.
  3. Changed-prefix apply uncounted — fixed. wn > 0 with !cut.set books a cut with p, c, pShareC and starts the growth wait (extract_sweep_v3.go:682-689). Cold applies book it too, in applyHeld and in v3Dispatch's cold branch.

New findings (this commit), both non-blocking

  1. extract_sweep_apply.go:786-789 — applyHeld runs v3Plan on every cold request when v3 is on, before it knows a held answer exists. applyHeldFrom returns at its first src.get when there is no answer, but the plan is built first. In hybrid and rule mode that is the full rule scan (file evidence plus command matching) on every cold request of every thread. coldStep already scans the conversation twice, so this is one more O(n) pass, not a new order of cost. Build the filtered source only when getHeld finds an answer, or lazily inside v3Filtered. Perf only; nothing is wrong in behavior.
  2. extract_sweep_v3.go:507-515 — a cold apply of a waiting hybrid answer that changes nothing still leaves v3Asked set. The v3Dispatch cold branch claims the mem answer, so it is gone either way. When wn == 0 (the recheck threw out every verdict) the branch skips v3CutDone, so v3Asked stays true. A later warm request then meets line 621 (!in.hasHeld && !in.busy && asked) and counts one hybrid_rules_only although the judge did answer. The rules still run through the same gates, so the cut itself stays safe; only the counter and the label are wrong, on a narrow path. Move the src.useMem clear from v3Apply into a place the cold branch reaches too.

What else I checked in the new commit

  • Fail-open and reversibility: the new code adds no drop path. Every drop still goes through applyHeldFrom (marker, stash, drop record, panic restore). v3Filtered only removes outputs from an answer.
  • The default path is untouched: every new branch is behind e.v3 (applyHeld, collect, SweepPingSubstitute, v3Step). With v3 off the behavior is byte-identical.
  • Two answers, one request: a store answer (coldStep) and a mem answer (v3Dispatch's cold branch) can both apply on one cold request. Each books its own cut. Overlapping outputs are safe: the marker key is content-deterministic, so the second apply finds the marker and skips.
  • v3Apply's changed-prefix cut divides by C only after v3Step's C <= 0 return, and applyHeld guards its own division with if C > 0. No division by zero.
  • The doc changes match the code: the ping and cold-apply paragraph, the paced counters line, and the two new refusal reasons in the counter list.
  • I did not run builds or tests (not approved). The author reports -race runs on the eval box; my claims come from reading the code.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 3 notes are fixed in one push. Verified on eval box 1: -race on components/offload and keepalive; make lint; mkdocs build --strict.

  1. Plan only when needed. The cold apply builds the protected set lazily, inside v3Filtered, on the first stored answer that has an output. A cold request with no stored answer builds no plan. TestV3AColdRequestWithNoStoredAnswerBuildsNoPlan counts plan builds (0 without an answer, 1 with one). Mutation: build it eagerly. Killed.
  2. No ping copy for rule. registerPing returns at once when v3 is on and selector: rule. TestV3RuleSelectorMakesNoModelCallAtThePingAndKeepsNoCopy checks that no candidate is kept. The refusal at the ping stays as a second guard (TestV3RuleSelectorRefusesARegisteredPingCandidate). Mutation: do not skip. Killed.
  3. Cold cut split. The cold apply now books rule drops and judge drops through ruleOf, counting only ids that were claimed drops and carry a marker after the apply that they did not carry before. TestV3ColdCutSplitsRuleDropsFromJudgeDrops. Mutations: ignore ruleOf; count unmarked ids. Both killed.
  4. v3Asked on a no-change cold apply. The cold branch clears it before the apply, so a used answer is never read later as "no answer". TestV3AColdApplyThatChangesNothingStillClearsTheHybridQuestion. Mutation: do not clear. Killed.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 2 of 2 3 of 3 775e5d70b60f approve

Verdict: approve

Earlier findings, dispositions

  1. My round-2 note 1 and reviewer 1's round-2 finding 1 (the same): applyHeld built the v3 plan on every request, answer or not. — Fixed. The plan is now built lazily, inside v3Filtered.strip, on the first stored answer that has an output (extract_sweep_v3.go:866-880). strip returns early when the answer is missing or empty, so a cold request with no stored answer builds no plan. The closure memoizes the result. TestV3AColdRequestWithNoStoredAnswerBuildsNoPlan counts plan builds: 0 without an answer, 1 with one. Verified in the code and the test.
  2. Reviewer 1's round-2 finding 2: a cold apply of a waiting hybrid answer that changed nothing left v3Asked set. — Fixed. The cold branch of v3Dispatch clears t.v3Asked before the apply, applied or not (extract_sweep_v3.go:519-524). The clear cannot fire while a question is still pending: the branch runs only when in.hasHeld && !in.heldTried (line 509), and hasHeld means an answer is there to claim. TestV3AColdApplyThatChangesNothingStillClearsTheHybridQuestion pins it with an answer whose only output is gone, so changed = 0. I checked the trace myself.
  3. My round-2 note 2: cold-apply cut records labeled every drop a judge drop. — Fixed. v3ColdCut (extract_sweep_v3.go:906-926) splits through ruleOf, as the warm gate does. It counts only ids that were claimed drops and whose message carries a marker after the apply that it did not carry before, so a pre-marked or not-applied id counts nothing. v3Dispatch's cold branch passes the mem answer's ruleOf; applyHeld passes nil, which is right: a Store answer never holds a rule verdict, because collect never offers a rule-decided output to a hybrid question (extract_sweep_ping.go:522). TestV3ColdCutSplitsRuleDropsFromJudgeDrops covers all four cases (rule, judge, marked-before, never-marked).
  4. My round-2 note 3: registerPing kept a conversation copy per thread under selector: rule. — Fixed. registerPing returns at once when v3 and rule are both on (extract_sweep_ping.go:261-264). The refusal in SweepPingSubstitute stays as a second guard for a candidate left by a config change. Both are pinned: TestV3RuleSelectorMakesNoModelCallAtThePingAndKeepsNoCopy (no copy kept, no call) and TestV3RuleSelectorRefusesARegisteredPingCandidate (a leftover candidate is still refused). Verified.

No finding was rejected by the author. Every round-2 finding and note is fixed.

Findings

None. The fix commit introduces no defect I could prove.

Non-blocking

  • docs/components/advanced-offload.md:671-672 — the doc says the rule ping is "counted as ping_refused_rule". After this commit, a steady rule deployment keeps no ping candidate, so the keeper sees no candidate and ping_refused_rule stays 0; the keeper counts sweep_no_candidate instead. Only a candidate left by a config change reaches the refusal. The behavior is right; update the doc sentence so an operator reading refused does not expect that counter.
  • extract_sweep_apply.go:797 — before := v3MarkedIDs(req) runs on every request when v3 is on, even with no stored answer. It is one O(conversation) text scan, lighter than the plan but the same shape of waste the lazy plan removed. It could be tied to the answer's presence, as the plan now is.
  • extract_sweep_v3.go:912 and 932 — the marker test is strings.Contains(text, "<<cg:"), not the strict carriesRealMarker used elsewhere. A tool output that quotes the marker literal (a grep over a transcript, say) reads as already marked, so its drop is under-counted in the ledger. The drop itself still happens and stays reversible. Very narrow; ledger only.

What I checked

  • Last review: round 2, sha 8637651b19700187a0cd99dac34122b2de6f4ef3, submitted 2026-10-28T11:35:32Z.
  • New commits read: 1 — 775e5d70 "fix(sweep): sweep v3 review round 2 notes (#491)" (4 files, +175 −25). Read the full git diff 8637651b..775e5d70 and the code around every hunk.
  • Read in full from the saved lists: 4 reviews (both round-1 reviews, both round-2 reviews), 2 comments (the round-1 fix summary at 11:29:10Z, the round-3 fix summary at 12:11:21Z), 0 inline comments (the file is empty).
  • New items since my last review, with dispositions:
    • Reviewer 1's round-2 review (11:36:42Z) — read in full. Their two findings match my round-2 notes 1 and 3 plus one item I had called fixed in part; I re-checked each in the new commit before agreeing. All fixed now.
    • The author's round-3 comment (12:11:21Z) — checked every claim against the code. All four hold. The eval-box runs and killed mutations are the author's; I verified by reading.
    • Commit 775e5d70 — reviewed as a first review, result above.
  • The lazy plan against the apply machinery: get and claim both call strip; strip builds the plan only when an answer with outputs exists, and the closure memoizes it. v3Filtered is passed by value, but the closure and the claimed pointer share state, so the memo and the claimed list work. Confirmed.
  • v3MarkedIDs correctness: toolCallID reads the tool message's own ToolCallID (extract_sweep_v3.go:281-286) and toolIndices returns tool-message indices (common.go:457-465), so the before-set is keyed by the same ids the claims use. A tool message with no id maps to "", which no claimed id can be. Confirmed.
  • The v3Asked clear against the question lifecycle: the cold branch runs only when a mem answer exists (in.hasHeld, line 509), so a pending, unanswered question is never cleared. The hybrid rules-only branch (line 651) still sees asked only while a question is truly out. Confirmed.
  • The new and changed tests: read all 5 (TestV3RuleSelectorMakesNoModelCallAtThePingAndKeepsNoCopy, TestV3RuleSelectorRefusesARegisteredPingCandidate, TestV3AColdRequestWithNoStoredAnswerBuildsNoPlan, TestV3ColdCutSplitsRuleDropsFromJudgeDrops, TestV3AColdApplyThatChangesNothingStillClearsTheHybridQuestion). Each matches a path I traced by hand. The helpers they use (sweepPingCand, warmHold, heldFor, coldCtx, v3Conv, tCalls) all exist.
  • Fail-open and the default path: every new branch is behind e.v3; with v3 off, applyHeld returns through the plain storeHeld source, byte-identical to before. The new code adds no drop path. Confirmed.
  • I did not run the tests: live tests are not approved and Go is not installed on this machine.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 1 of 2 3 of 3 775e5d70b60f approve

Verdict: approve. Every earlier finding is fixed. Three small notes stay, all non-blocking.

What I checked

  • Last review: round 2, 8637651, 2026-10-28T11:36:42Z
  • New commits read: 1 (775e5d7 fix(sweep): sweep v3 review round 2 notes (#491))
  • Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
  • New items since my last review, and what I did about it:
    1. Commit 775e5d7 — read the full diff and the code around each change in all 4 files. Results below.
    2. Author comment (2026-10-28T12:11:21Z) — checked all 4 claims against the code. Claims 1, 2 and 4 hold fully. Claim 3 holds only in part: the split exists and its test passes, but no production caller can pass it a rule drop (note 1 below).
    3. Reviewer 2's round-2 review (2026-10-28T11:35:32Z) — read in full. I checked its 3 non-blocking items myself: item 1 is my item 1, item 3 is fixed, item 2 is addressed but vacuous in production (note 1).
    4. No new inline comments.

Earlier findings

My round-2 finding 1: applyHeld built the v3 plan on every cold request. FIXED.

v3Filtered now takes a plan closure and calls it inside strip, and strip returns at once when the answer is absent or has no outputs (extract_sweep_v3.go:868-871). The closure caches its result, so one apply builds one plan. TestV3AColdRequestWithNoStoredAnswerBuildsNoPlan pins both sides: 0 builds without a stored answer, 1 with one. The v3PlanBuilds counter is the test's probe. A lighter scan stays on the same path — note 2 below.

My round-2 finding 2: a cold apply that changed nothing left v3Asked set. FIXED.

The v3Dispatch cold branch now clears v3Asked before the apply, not only after a counted cut (extract_sweep_v3.go:519-524). It runs whether the apply changes something or nothing. TestV3AColdApplyThatChangesNothingStillClearsTheHybridQuestion pins it: an answer whose only output is gone from the conversation, changed == 0, v3Asked false. I traced the test's path by hand: the recheck drops the verdict as output_gone, the claim consumes the mem answer, and the clear has already run. A panic between the clear and the apply also stays correct: the recover gives the answer back, and a held answer takes the apply branch, not the hybrid_rules_only branch.

Reviewer 2's round-2 items (I checked each myself):

  1. Lazy plan — the same as my finding 1. Fixed.
  2. Cold-cut rule/judge split — addressed, but the split cannot fire. See note 1.
  3. No ping copy under selector: rule — fixed. registerPing returns before it snapshots anything (extract_sweep_ping.go:261-264). The early return skips only the registration; the keeper sends a plain ping through the existing no-candidate path. TestV3RuleSelectorMakesNoModelCallAtThePingAndKeepsNoCopy goes through Offload, so the mutation "do not skip" would register a candidate and fail the test. The refusal in SweepPingSubstitute stays as the second guard for a candidate registered before a config change, pinned by TestV3RuleSelectorRefusesARegisteredPingCandidate. A doc line now overstates the counting — note 3 below.

No earlier finding was rejected by the author.

Findings

None.

Non-blocking

  1. extract_sweep_v3.go:906-921 — the cold cut's rule/judge split cannot fire on any production path. Both call sites pass an empty ruleOf: applyHeld passes nil (extract_sweep_apply.go:801), and the v3Dispatch cold branch nils plan.rules before newV3Held (extract_sweep_v3.go:517), so src.ruleOf is empty too. A mem answer never carries rule verdicts anyway — carryRefused's v3 branch strips them before carrying (extract_sweep_warm.go:1446-1456). So every cold-apply drop is a judge drop, and the ledger is correct — but TestV3ColdCutSplitsRuleDropsFromJudgeDrops exercises the split only by calling v3ColdCut directly with a hand-built ruleOf. The marker-verification half of the function is a real gain (a counted drop must be claimed, unmarked before, and marked now). If the split is meant to stay, drop a note on v3ColdCut saying ruleOf is empty today; if not, simplify it away.
  2. extract_sweep_apply.go:797 — v3MarkedIDs runs on every cold request when v3 is on, even with no stored answer. It is much lighter than the plan it replaced (no JSON parsing, no regex, no file evidence), but it still reads the full text of every tool output. The same lazy treatment would remove it: compute the set only when an answer was claimed.
  3. docs/components/advanced-offload.md:671-672 — the doc says the rule-mode ping is "counted as ping_refused_rule". After the registerPing skip, a rule-mode deployment counts its pings as sweep_no_candidate (the no-candidate path), and ping_refused_rule fires only for a candidate registered before a config change. The commit changed no docs. Reword the parenthetical, or count the skip itself.

What else I checked in the new commit

  • Fail-open and reversibility: the commit adds no drop path. v3ColdCut only books numbers. registerPing's skip removes work; the keeper's plain-ping fallback is the pre-existing no-candidate path.
  • The default path is untouched: applyHeld returns early for !e.v3 with the same call as before; the registerPing skip needs e.v3 && selector == rule.
  • The before sets are ordered right: applyHeld computes before after replayDrops has re-marked old drops, so replays are not counted. When a store answer and a mem answer both apply on one cold request, the second before (in v3Dispatch) is computed after the first apply, so no id is counted twice.
  • The v3Filtered claim list: get strips without recording, claim strips, counts cold_protected_filtered and records the claimed drop ids. One apply records each id once.
  • Concurrency: the plan closure and its cache live in one applyHeld call; the claimed slice is a pointer to a local. The v3Asked clear takes warmMu, like every other write to the warm table.
  • The tests: read all 5 new or changed ones. Each names the behavior it pins, and each matches a path I traced by hand.
  • I did not run builds or tests (not approved). The author reports -race and lint runs on eval box 1; my claims come from reading the code.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Cleanup push. No behavior change. Verified on eval box 1: -race on components/offload, make lint, mkdocs build --strict.

  1. Docs. A rule-mode ping now reads as sweep_no_candidate (no copy is kept). ping_refused_rule fires only for a candidate left from before a config change.
  2. v3ColdCut. A comment says ruleOf is empty on every production path today, so every cold drop is a judge drop. The split code stays.
  3. Lazy marked set. v3MarkedIDs now runs when the claim wins, before the apply changes a message, the same way as the plan. A cold request with no stored answer does not compute it.
  4. Marker test. carriesRealMarker replaces the "<<cg:" substring test in both places. The test fixture now stores the marker key, as a real marker has.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 2 of 2 4 of 5 96b0434e32d6 approve

Verdict: approve

Earlier findings, dispositions

All round-3 items were non-blocking notes. Reviewer 1 raised the same three, plus one on the rule split. All are fixed in commit 96b0434e:

  1. My round-3 note 1 (reviewer 1's note 3): the doc said the rule ping is "counted as ping_refused_rule", which the registerPing skip made stale. — Fixed. The doc now says a rule-mode ping keeps no copy and counts as sweep_no_candidate, and ping_refused_rule fires only for a candidate left from before a config change (docs/components/advanced-offload.md:671-673). That matches the code: registerPing returns before it snapshots anything, so the keeper meets no candidate. Verified.
  2. My round-3 note 2 (reviewer 1's note 2): v3MarkedIDs ran on every request, answer or not. — Fixed. The set is now read through an onClaim callback that runs when a claim hands out an answer, before the apply changes any message (extract_sweep_apply.go:797-798, extract_sweep_v3.go:874-886). A cold request with no stored answer computes neither the plan nor the marked set. Verified in the code; the ordering is right, because strip runs inside claim, before the recheck and before any drop is written.
  3. My round-3 note 3: the loose "<<cg:" substring test could under-count a drop whose output quotes the marker literal. — Fixed. Both the before-set and the after-check use carriesRealMarker (extract_sweep_v3.go:926, 943-948). The test fixture now stores the marker key, so its marker is real (extract_sweep_v3_test.go:744-747). carriesRealMarker does a cheap text check first and reads the Store only for marker-carrying text, and c.Store is set on both call paths. Verified.
  4. Reviewer 1's round-3 note 1: the cold cut's rule/judge split could not fire on any production path, and they asked for a note on the function. — Done, and their reading is right. I checked it myself: applyHeld passes nil, and the v3Dispatch cold branch nils plan.rules before newV3Held (extract_sweep_v3.go:516-517), so ruleOf is empty on both production paths. The comment on v3ColdCut now says so (extract_sweep_v3.go:918-921). Keeping the split is sound: it costs nothing and counts a future path right.

No finding was rejected by the author. Every round-3 note is fixed.

Findings

None. The cleanup commit introduces no defect I could prove.

Non-blocking

None. I looked for new notes in the changed code and found none that would survive a check.

What I checked

  • Last review: round 3, sha 775e5d70b60f22e18178aaf2e81fb284f4943972, submitted 2026-10-28T12:15:52Z.
  • New commits read: 1 — 96b0434e "chore(sweep): sweep v3 round 3 cleanup, no behavior change (#491)" (4 files, +29 −8). Read the full git diff 775e5d70..96b0434e and the code around every hunk.
  • Read in full from the saved lists: 6 reviews (both round-1, both round-2, both round-3), 3 comments (11:29:10Z, 12:11:21Z, 12:40:33Z), 0 inline comments (the file is empty).
  • New items since my last review, with dispositions:
    • Reviewer 1's round-3 review (12:16:17Z) — read in full. Their three notes match mine; I re-checked each in the new commit before agreeing. Their note on the vacuous rule split I verified independently (see disposition 4). Their claim that carryRefused strips rule verdicts before carrying I take from their trace; the empty-ruleOf conclusion holds through the two call sites alone.
    • The author's cleanup comment (12:40:33Z) — checked all four claims against the code. All hold. The eval-box runs are the author's; I verified by reading.
    • Commit 96b0434e — reviewed as a first review, result above.
  • The onClaim mechanism against the apply machinery: v3Filtered.strip calls it only on claim, never on get, and always before any message is changed; v3Held.claim calls it once, when combine accepts, before claimedIDs is built. v3ColdCut runs only when changed > 0, which implies the claim won, so before is never read unset; a nil map read would be safe anyway. The closures are set before the source is passed to applyHeldFrom, so both copies see them. Confirmed.
  • The marker pair for consistency: the before-set and the after-check now use the same strict test, so an output that quotes the marker literal reads as unmarked in both and can no longer hide a drop, and an output whose marker's Store record was pruned reads unmarked in both, so the pair stays self-consistent. carriesRealMarker returns true when the Store is nil, the safe direction, and both call paths always have a Store. Confirmed.
  • The ruleOf comment for accuracy: plan.rules = nil in the cold branch and nil at the applyHeld call site, so every production cold drop is booked as a judge drop today. The ledger was already correct; the comment now says why. Confirmed.
  • Fail-open and the default path: the commit changes ledger counting and doc text only. No new drop path, no request-path change; with v3 off, nothing in the diff runs. Confirmed.
  • The changed test: TestV3ColdCutSplitsRuleDropsFromJudgeDrops now stores the marker key before it marks the fixture messages, so carriesRealMarker accepts them. The four cases (rule, judge, marked-before, never-marked) are unchanged. Verified against the new signature.
  • I did not run the tests: live tests are not approved and Go is not installed on this machine.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 1 of 2 4 of 5 96b0434e32d6 approve

Verdict: approve. All three of my round-3 notes are fixed. No new defect.

What I checked

  • Last review: round 3, 775e5d7, 2026-10-28T12:16:17Z
  • New commits read: 1 (96b0434 chore(sweep): sweep v3 round 3 cleanup, no behavior change (#491))
  • Read in full: 6 reviews, 3 comments, 0 inline comments (from the three files)
  • New items since my last review, and what I did about it:
    1. Commit 96b0434 — read the full diff and the code around each change in all 4 files. Results below.
    2. Author comment (2026-10-28T12:40:33Z) — checked all 4 claims against the code. All hold.
    3. Reviewer 2's round-3 review (2026-10-28T12:15:52Z) — read in full. Its 3 non-blocking notes map to my notes 2 and 3 plus one I had not raised (the marker substring test). I checked all three myself; all are fixed in this commit.
    4. No new inline comments.

Earlier findings

My round-3 note 1: the cold cut's rule/judge split cannot fire, so a note or a simplification was needed. FIXED (a note).

v3ColdCut now carries the comment: ruleOf is empty on every production path today, a cold answer never carries rule verdicts, and the split stays for a future path that does (extract_sweep_v3.go:918-920). That is the option I proposed, and the comment states the facts I verified in round 3.

My round-3 note 2: v3MarkedIDs ran on every cold request, answer or not. FIXED.

The set is now read through an onClaim callback: applyHeld and the v3Dispatch cold branch set src.onClaim = func() { before = v3MarkedIDs(c, req) }, and the callback runs only when a claim hands out an answer — in v3Filtered.strip on the claim pass (extract_sweep_v3.go:886-888) and in v3Held.claim after the claim wins (extract_sweep_v3.go:475-477). I traced the timing: the claim happens inside applyHeldFrom before any message changes, so before still sees the pre-apply state. When no answer exists, strip returns at !ok and the callback never runs. When a claim loses the race, same. A cold request with no stored answer now computes neither the plan nor the marked set.

My round-3 note 3: the doc said the rule ping is counted as ping_refused_rule. FIXED.

The doc now says the rule ping keeps no conversation copy, so it counts as sweep_no_candidate, and ping_refused_rule fires only for a candidate left from before a config change (docs/components/advanced-offload.md:671-673). That matches the code exactly: registerPing's skip leads the keeper to the no-candidate path, and the SweepReasonV3Rule refusal is reachable only by a stale candidate.

Reviewer 2's round-3 note 3 (the marker substring test — I had not raised it; I checked it myself and agree): FIXED.

Both v3MarkedIDs and v3ColdCut now use carriesRealMarker instead of strings.Contains(text, "<<cg:") (extract_sweep_v3.go:929, 942-946). This is better than a one-sided fix: the before-set and the after-check use the same real-marker test, so an id counts only when its message was unmarked before the claim and carries a real marker after the apply — exactly the writes this apply made. A quoted marker literal no longer reads as marked. The test fixture stores the marker key (st.Put("zz", ...)), as a real marker requires. I also checked the nil-Store branch of carriesRealMarker (returns true, the safe direction): without a Store there are no stashed drops anyway, so it can only under-count the ledger, never miscount a drop.

No earlier finding was rejected by the author.

Findings

None.

Non-blocking

None new.

What else I checked in the new commit

  • The onClaim plumbing: v3Filtered is passed by value, but the callback is a closure over the local before, so the write is visible to the caller. v3Held is a pointer, set after newV3Held. Each apply calls claim once, so the callback runs at most once per apply. A panic after the claim and before the apply leaves before set and unused — changed is reset to 0 by the recover, so v3ColdCut is not called.
  • The claim-order split on a double apply: when a store answer and a mem answer both apply on one cold request, each before is read at its own claim time, so the first apply's markers are in the second before. No id counts twice.
  • No behavior change beyond the ledger precision: the commit changes what is counted and when the scans run, not what is dropped. Every drop path is unchanged, so fail-open and reversibility hold as verified in earlier rounds.
  • The default path is untouched: all changes sit behind e.v3.
  • The changed test (TestV3ColdCutSplitsRuleDropsFromJudgeDrops) still covers all four cases: rule drop, judge drop, marked-before, never-marked. The fixture now matches carriesRealMarker's contract.
  • I did not run builds or tests (not approved). The author reports -race, lint and mkdocs build --strict on eval box 1; my claims come from reading the code.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Design change from the owner: the sweet spot is a share of the effective context (where the client compacts), not of the window.

Why. compactionpoint.For has no GLM entry, so it returned window_fallback and C was the 200k window. Claude Code compacts GLM near 167k billed (peak 167,120 over 96 sessions), so the 170k sweet spot was never reached.

What changed

  1. New table field. compaction_point (billed tokens) in the MODEL_PRICES table, next to window. It does not change window and is not derived from it. compactionpoint.Resolve prefers it (new Source operator) over the bootstrap table. The proxy resolves it for /v1/messages and /compact (resolveCompactionPoint) and passes it to Ctx.CompactionPoint and CompactionPointSource, as the window flows.
  2. v3 C. CutFrac x C with a summarizer, else the compaction point unless its source is window_fallback, else the window. A window_fallback point is the window under another name. The code says so.
  3. Visible source. keepalive.sweep_warm.v3.c_source counts the checks by cutfrac, compaction or window. Each recent_cuts entry has C and c_source. The decision log has cut_point and c_source for a sweet-spot refusal and a drop_too_small refusal.
  4. Shared package. The summarizer and the dashboard span read compactionpoint too, so an operator value applies to them as well. It changes nothing unless the field is set.
  5. Data dependence. None. It is config.
  6. Docs. advanced-offload.md (sweet spot = fill x effective context, and how to set the field) and a commented example in prices.example.yaml.

Tests (mutation killed for each): the table field is parsed and the chain passes it on; Resolve prefers the operator value and does not move with the window; with no value, Resolve equals For, and the proxy gives the same point as before; v3 sweet spot at 0.85 x 167k; c_source for each of the 3 cases; C and its source in an accepted cut and in the refusal log.

Verified on eval box 1: -race on components/offload, proxy, keepalive, internal/compactionpoint, internal/modelinfo; go test on dash, config, components/all; make lint; mkdocs build --strict.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 2 of 2 5 of 5 47e1badb394d approve

Verdict: approve

Earlier findings, dispositions

Round 4 ended with no findings and no notes on either side, and the author rejected nothing. Reviewer 1's round-4 review (12:43:47Z) was an approve with nothing new, so there is no earlier finding left open. This round reviews the new feature commit on its own.

Findings

None. The feature commit introduces no defect I could prove.

Non-blocking

  • internal/modelinfo/table.go:109-112 — ParseTable rejects a negative compaction_point but accepts one above the window. A typo (1670000 for 167000) makes C larger than the window, and then Resolve uses it as it is (compactionpoint.go:215-230). For v3 that is the safe direction: the sweet spot is never reached, so nothing is dropped. For the summarizer it is the dangerous one: the trigger fires at a fraction of C, so it never fires, and the conversation runs into the provider's limit. The compactionpoint package's own notes call a too-high C "the dangerous one" (compactionpoint.go:97-102). Consider rejecting compaction_point > window in ParseTable when the entry states both, as a guard against the typo. Not deriving the value from the window, as the design says, and guarding against nonsense input are different things.
  • extract_sweep_v3.go:612 — noteV3CSource counts on every warm request that reaches the sweet-spot check, while not_in_sweet_spot next to it is paced at warm_every_n. On a deployment that sits below the spot, c_source grows about warm_every_n times faster than refused. The doc says it counts checks, so the meaning is right; only the noise shape differs from the paced counters beside it. Consider pacing it too.

What I checked

  • Last review: round 4, sha 96b0434e32d69b716f6332f2d68ceae91fcebce5, submitted 2026-10-28T12:43:40Z.
  • New commits read: 1 — 47e1badb "feat(sweep): size the v3 sweet spot from the effective context (#491)" (13 files, +367 −45). Read the full git diff 96b0434e..47e1badb and the code around every hunk.
  • Read in full from the saved lists: 8 reviews (both round-1, both round-2, both round-3, both round-4), 4 comments (11:29:10Z, 12:11:21Z, 12:40:33Z, 13:30:45Z), 0 inline comments (the file is empty).
  • New items since my last review, with dispositions:
    • Reviewer 1's round-4 review (12:43:47Z) — read in full. An approve with no findings; nothing to re-check.
    • The author's design-change comment (13:30:45Z) — checked all six points against the code. All hold. The data-dependence statement ("None. It is config.") matches what the code reads: the new input is the operator's MODEL_PRICES table, not stored customer data, so the existing sweep row still covers it.
    • Commit 47e1badb — reviewed as a first review, result above.
  • The "nothing changes unless the field is set" claim, the critical one: the old base was FillDenominator() (the point when set, else the window, cachephase.go:175-183). The new base skips a point whose source is window_fallback. I checked every source the shipped resolver can produce: For returns WindowFallback with Frac: 1.00 (compactionpoint.go:196-199), so a fallback point always equals the window, and the skip changes the label only. Measured (haiku, 0.996) and Assumed (opus, sonnet, 1.00) points pass through to C exactly as before, and CutFrac multiplies the same base as before. With no compaction_point in the table, Resolve returns For unchanged. Confirmed: the numbers move only when the operator states a value.
  • The proxy wiring: resolveCompactionPoint (proxy.go:2158-2170) reads the operator table through the same chain pattern as the window, falls back to For when the chain states nothing, and is safe when Windows is nil (the type assertion fails, stated stays 0). Both paths use it: /compact (proxy.go:727, 756-757) and the chat path (proxy.go:1143, 1305-1306), so the summarizer and the span read the same figure, as the doc says. Confirmed.
  • Division safety in the new code: noteV3Refusal divides p by c only after v3Step's P <= 0 and C <= 0 returns, and v3Gate divides by P and C on the same guarantee. v3CutPoint returns a non-empty source whenever it returns C > 0. Confirmed.
  • The stats surface: CSource in V3Stats, CSource in each V3Cut, CutPoint/CSource in WarmDecision — all additive with omitempty, so /stats stays append-only. Any() now also fires on CSource, which only makes the v3 block appear when checks ran. Confirmed.
  • The new tests, read against the code: TestV3CutPointFollowsTheSummarizerThenTheCompactionPointThenTheWindow (all six cases including the fallback label), TestV3SweetSpotUsesTheOperatorCompactionPoint (0.85 x 167k reached at 150k; the window case refused at 150k under 170k, with the rig's warm_every_n: 3 pacing giving one paced refusal over four requests), TestV3CSourceIsReportedForEachCase (all three sources, plus the decision-log fields), TestV3AnAcceptedCutRecordsCAndItsSource, the three compactionpoint tests, TestTableParsesCompactionPoint, and the proxy resolution test. The helpers they use (lastWarmDecision, r.refused, eventAppliedWarm, the rig fields) all exist. Each test names the behavior it pins.
  • Fail-open and the default path: with v3 off, nothing in the offload diff runs; the proxy change is behind the same option as the window and degrades to the old resolver when the table states nothing. The feature changes when a cut is tried, not how a drop is made, so reversibility and the per-component recover are untouched. Confirmed.
  • I did not run the tests: live tests are not approved and Go is not installed on this machine. The author reports -race, lint and mkdocs build --strict runs on eval box 1; my claims come from reading the code.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 1 of 2 5 of 5 47e1badb394d blocking

Verdict: blocking. One finding: the dashboard span does not read the operator's compaction_point, but three shipped texts say it does.

What I checked

  • Last review: round 4, 96b0434, 2026-10-28T12:43:47Z
  • New commits read: 1 (47e1bad feat(sweep): size the v3 sweet spot from the effective context (#491)). Read the full diff and the code around every hunk.
  • Read in full: 9 reviews, 4 comments, 0 inline comments. My saved lists held 8 reviews; reviewer 2's round-5 review (13:36:00Z) arrived after I saved them. I fetched it and read it in full before posting.
  • New items since my last review, and what I did about it:
    1. Commit 47e1bad — reviewed as a first review. Result below.
    2. Author comment (2026-10-28T13:30:45Z) — checked all six points against the code. Five hold. Point 4 ("the summarizer and the dashboard span read compactionpoint too, so an operator value applies to them as well") is half false. See the finding.
    3. Reviewer 2's round-5 review (2026-10-28T13:36:00Z) — read in full. Approve, two non-blocking notes. I checked both myself; see Non-blocking. Their check of the doc sentence traced only the proxy paths, not the dash package.

Earlier findings

Round 4 ended approve on both sides, with no findings and no notes. Nothing is open. The author rejected nothing.

Findings

1. The dashboard span does not read the operator's compaction_point, but the doc, the config example, and the PR comment say it does.

Three shipped texts make the claim:

  • docs/components/advanced-offload.md:666 — "The summarizer and the dashboard span read the same figure, so an operator value applies to them too."
  • deploy/service/prices.example.yaml:33-34 — "the summarizer and the dashboard span read it too."
  • The PR comment, point 4 (13:30:45Z).

The summarizer half is true. The proxy fills Ctx.CompactionPoint through resolveCompactionPoint (proxy/proxy.go:2158-2170). The summarizer paths size their span from CutFrac x FillDenominator() (components/offload/prefix_econ.go:285-286, components/offload/extract_sweep_warm.go:608-609). FillDenominator returns the compaction point when it is set (components/cachephase.go:175).

The dashboard half is false. Both dashboard readers call the bootstrap table directly:

  • dash/compactepisode.go:502 — ceil := compactionpoint.For(conv[0].Model)
  • dash/replaycap.go:249 — ceil := compactionpoint.For(model).Frac

The operator-aware Resolve has one production caller: proxy/proxy.go:2168. I grepped the repo; those two dash lines are the only other readers of the package.

Consequence, with the doc's own example (GLM, compaction_point: 167000, window 200000):

  • Live v3 sweet spot: 0.85 x 167k = 142k. Live summarizer span: CutFrac x 167k.
  • Dashboard: For has no GLM entry, so it returns window_fallback, Frac 1.0. The compact-episode span and the replay-cap ceiling use the whole 200k window.
  • The dashboard then disagrees with live behavior exactly when the operator sets the field — the motivating case of this commit. In replaycap the counterfactual client compacts at 200k instead of 167k, so turns past 167k stay credited to us. The cap over-credits.

The fix is small. The dash walk already takes the operator's window through modelinfo.Exact(windows, ctx, model) (dash/compactepisode.go:1283-1286), and modelinfo.Chain.CompactionPoint exists. Route the ceiling through the same chain, like the window. Or correct the three texts to say the dashboard reads the built-in table only.

Why blocking: the claim is operator-facing, in the doc and the config example. An operator who sets the field will trust a dashboard that no longer matches production.

Non-blocking

  • proxy/proxy.go:2141-2150 — the commit inserted resolveCompactionPoint between resolveWindow's doc comment and resolveWindow itself. The comment now reads as if it documents the new function. Move it down past the new function, or split it.
  • I agree with reviewer 2's round-5 notes 1 and 2, after checking each myself:
    • ParseTable rejects a negative compaction_point only (internal/modelinfo/table.go:109-112). A value above the window parses. For the summarizer that is the dangerous direction: the trigger never fires and the conversation runs into the provider limit. A guard in ParseTable when the entry states both fields would catch the typo.
    • noteV3CSource counts every sweet-spot check, while not_in_sweet_spot next to it is paced at warm_every_n (components/offload/extract_sweep_v3.go:612-616). The doc says it counts checks, so the meaning is right. Only the noise shape differs.

What else I checked in the new commit

  • "Nothing changes unless the field is set." The old base was FillDenominator(): the point when set, else the window. The new v3CutPoint skips a point whose source is window_fallback. I checked every source the shipped resolver can produce. For returns WindowFallback with Frac: 1.00, so a fallback point always equals the window. The skip changes the label only. Measured and Assumed points pass to C as before. CutFrac multiplies the same base as before. With no field in the table, Resolve returns For unchanged, and a test pins that. Confirmed.
  • resolveCompactionPoint safety. Nil Windows fails the type assertion, stated stays 0, and Resolve falls back to For. Both /compact (proxy.go:727) and the chat path (proxy.go:1143) use it.
  • Division safety. noteV3Refusal divides p by c only after v3Step's P <= 0 and C <= 0 return. v3Gate divides by P and C on the same guarantee. v3CutPoint returns a non-empty source whenever it returns C > 0.
  • The stats surface. V3Stats.CSource, V3Cut.CSource, and WarmDecision.CutPoint/CSource are additive with omitempty, so /stats stays append-only. Any() now fires on CSource too, which only makes the v3 block appear when checks ran.
  • Fail-open and the default path. With v3 off, nothing in the offload diff runs. The proxy resolution degrades to the old figure when the table states nothing. The feature changes when a cut is tried, not how a drop is made, so reversibility and the per-component recover are untouched.
  • Data dependence. The new input is the operator's MODEL_PRICES table, not stored customer data. The author's statement ("None. It is config.") matches the code.
  • The new tests, read against the code: TestV3CutPointFollowsTheSummarizerThenTheCompactionPointThenTheWindow, TestV3SweetSpotUsesTheOperatorCompactionPoint, TestV3CSourceIsReportedForEachCase, TestV3AnAcceptedCutRecordsCAndItsSource, the compactionpoint tests, TestTableParsesCompactionPoint, and the proxy resolution test. The helpers they use all exist. Each test names the behavior it pins.
  • I did not run builds or tests (not approved). The author reports -race, lint and mkdocs build --strict on eval box 1; my claims come from reading the code.

amiddavid added a commit that referenced this pull request Oct 28, 2026
Review round 5 on #763.

- the compact-episode span, the summarize ledger and the replay cap
  resolve the compaction point through the operator table first, as
  they already do for the window; with no field set the numbers are
  the same as before
- ParseTable rejects a compaction_point above the entry's window, and
  names the model
- noteV3CSource is paced at warm_every_n, like the refusal counters
- move resolveWindow's doc comment back above resolveWindow

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 5 fixes are in one push. Verified on eval box 1: -race on dash (own call), proxy, components/offload, internal/compactionpoint, internal/modelinfo, keepalive; make lint; mkdocs build --strict.

Blocking: the dashboard did not read the operator's compaction_point. Fixed.

  • walkCompactEpisodes and walkCapConversation now take a pointFn. The dashboard builds it with operatorPoint(ctx, windows): modelinfo.OperatorCompactionPoint (the capability on Chain) in front of compactionpoint.Resolve. The compact-episode span, the summarize ledger and the replay cap (the SQL path too) all use it, as they already use the operator's window.
  • With no field set, Resolve returns For, so the numbers are the same as before. walkCompactEpisodes and walkReplayCap keep their signatures and use the bootstrap table.
  • Tests: the episode span and the replay-cap ceiling use the operator value; the replay cap closes at the operator's ceiling; through SQL, ReplayLedgerFor takes it; with no field, both are unchanged. Five mutations, all killed (episode ignores the operator; episode calls For; replay cap calls the bootstrap; the SQL path ignores the operator, first missed by the tests and then killed by the new SQL test; the helper skips the capability).

Non-blocking, all fixed

  1. ParseTable rejects compaction_point > window when both are stated, and the error names the model. Test and mutation: killed.
  2. noteV3CSource is paced at warm_every_n, like the refusal counters. TestV3CSourceIsReportedForEachCase counts exactly 2 over 6 requests. Mutation: killed. The docs say so.
  3. resolveWindow's doc comment is back above resolveWindow, and resolveCompactionPoint has its own.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 1 of 2 6 of 6 d4cf2d5b5eaf approve

Verdict: approve. My round-5 finding is fixed, on all three dashboard paths. Both of reviewer 2's round-5 notes are fixed. No new defect.

What I checked

  • Last review: round 5, 47e1bad, 2026-10-28T13:40:40Z
  • New commits read: 1 (d4cf2d5 fix(dash): read the operator's compaction_point in the dashboard (#491)). Read the full diff and the code around every hunk in all 11 files.
  • Read in full: 10 reviews, 5 comments, 0 inline comments (from the three files; the inline file is empty).
  • New items since my last review, and what I did about it:
    1. Commit d4cf2d5 — reviewed as a first review. Result below.
    2. Author comment (2026-10-28T15:07:42Z) — checked every claim against the code. All hold.
    3. No new review from reviewer 2 since my round-5 post. No new inline comments.

Earlier findings

My round-5 finding (blocking): the dashboard span did not read the operator's compaction_point, but three shipped texts said it does. FIXED.

I traced all three dashboard paths:

  1. The compact-episode span. walkCompactEpisodesWith takes a pointFn, and CompactionEpisodesFor passes operatorPoint(ctx, windows) (dash/compactepisode.go:446-457, 1301-1308). The old compactionpoint.For call at line 502 is now point(conv[0].Model, w).
  2. The summarize ledger. summarizerLedger passes the same operatorPoint (dash/summarizeattr.go:134-138).
  3. The replay cap, including the SQL path. ReplayLedgerForCtx passes operatorPoint(ctx, windows) to walkCapSession (dash/replaycap.go:390), and ReplayLedgerFor delegates to ReplayLedgerForCtx (replaycap.go:348-349), so the api.go callers get it too. The old For call at line 249 is now point(model, w).Frac.

The resolution matches the proxy's precedence. operatorPoint asks modelinfo.OperatorCompactionPoint (the capability on the resolver, dash/compactepisode.go:455-459), then compactionpoint.Resolve. A stated value wins; nothing stated gives Resolve(model, 0, w), which returns For(model) unchanged. So with no field set, every number is the same as before. The plain walkCompactEpisodes and walkReplayCap keep their signatures and use bootstrapPoint, which is For — I grepped: no production caller of either is left, so no dash path reads the bootstrap table while an operator value exists.

The arithmetic is right where the window is a guess. In walkCapConversation the assumed window gives Frac = stated / w, and limit = Frac x w = stated, so the absolute limit is the operator's figure whatever the window.

The tests pin each side: the episode span and the replay-cap ceiling use the operator value, the cap closes at the operator's ceiling, the SQL path takes it through ReplayLedgerFor, and with no field both walks are unchanged (dash/operatorpoint_test.go). The helpers they use all exist — I checked exactWindow, testPrice, row, capTestRow, fixedWindow, testWindows, handPrice, mkEvent, openTestDB, DayMs, CacheHit, AccountingComplete.

The doc now names the three readers and is true (docs/components/advanced-offload.md:666). The prices.example.yaml claim is true again.

My round-5 non-blocking note (proxy comment placement): FIXED. resolveWindow's doc comment is back above resolveWindow, and resolveCompactionPoint has its own (proxy/proxy.go:2143-2177).

Reviewer 2's round-5 note 1 (ParseTable accepted a point above the window): FIXED. I checked it myself. ParseTable now rejects compaction_point > window when the entry states both, and the error names the model (internal/modelinfo/table.go:112-114). The guard runs only when window > 0, so a point stated without a window still parses — right, because the window may come from another link. TestTableRejectsACompactionPointAboveItsWindow covers the rejection and both accepted cases. I grepped every compaction_point fixture in the repo; none states a point above its window, so nothing existing now fails to parse.

Reviewer 2's round-5 note 2 (noteV3CSource unpaced): FIXED. I checked it myself. The counter now sits under the same paced flag as the refusal counters — t.v3Reqs % e.warmEveryN == 0 (components/offload/extract_sweep_v3.go:586, 612-614). I traced the test's arithmetic: request(0) plus six requests give v3Reqs 1 through 7, paced at 3 and 6, so exactly 2 counts — what the test asserts. The doc says "counted once per warm_every_n warm requests" (advanced-offload.md:701).

No earlier finding was rejected by the author.

Findings

None.

Non-blocking

  • Two doc comments still name the old ceiling source. dash/replaycap.go:29 says the cap uses "compactionpoint.For"; it now uses the point resolver, which is For only when no field is set. dash/compactepisode.go:1125 says ClientCeilingUsed.Provenance is "measured", "assumed" or "default"; it can now carry "operator" too (and "window_fallback", already before this PR). One-line fixes, whenever the files are touched next.

What else I checked in the new commit

  • No request-path change. The dash is offline analysis. The only components/offload change is the counter's pace. Fail-open, reversibility and the default path are untouched.
  • OperatorCompactionPoint safety. A resolver without the capability fails the type assertion and returns (0, false), so operatorPoint falls back to For (internal/modelinfo/modelinfo.go:314-323). A nil resolver behaves the same. modelinfo.Exact is already called on the same resolver unguarded, so no new nil path exists.
  • The With-wrapper pattern. walkCompactEpisodes and walkReplayCap delegate to the With forms with bootstrapPoint, so the old signatures and their tests are unchanged. I grepped for production callers of the plain forms: none remain.
  • Resolve with a stated point. Frac is stated / window, capped at 1. Both dash call sites pass w > 0 (the episode walk skips unknown windows first; the cap walk substitutes an assumed window first), so the cap-1 branch is a safety net only. limit = Frac x w gives the stated figure exactly.
  • The ParseTable guard against existing tables. The check runs before the negative check and uses the entry's original match text in the error. An entry with a point and no window, or a point equal to the window, still parses — the test covers both.
  • The v3 test change. TestV3CSourceIsReportedForEachCase now asserts an exact count (2 over 6 requests), not just "at least one", so a mutation that ignores paced fails it.
  • Data dependence. Unchanged: the dash reads the operator's config table, not stored customer data.
  • I did not run builds or tests (not approved). The author reports -race on dash (own call), proxy, components/offload, internal/compactionpoint, internal/modelinfo, keepalive, plus lint and mkdocs build --strict on eval box 1; my claims come from reading the code.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Verdict: approve. One new commit since my round-5 review. It fixes every round-5 finding: reviewer 1's blocking dashboard gap, and both of my notes. I found no new defect in it. One residual note stays non-blocking.

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.312 offload-review skill, @amiddavid's session resumed 2 of 2 6 of 6 d4cf2d5b5eaf approve

What I checked

  • Last review round: round 5, sha 47e1badb394d2fa21f127f9ee993de9748158bcb, posted 2026-10-28T13:36:00Z.
  • New commits read: 1 — d4cf2d5b "fix(dash): read the operator's compaction_point in the dashboard (#491)" (11 files, +224 −31). Full diff read, plus the code around each hunk.
  • Items read in full: 10 reviews (.review-in-reviews.txt, 492 lines), 5 comments (.review-in-comments.txt, 67 lines), 0 inline comments (.review-in-inline.txt, empty).
  • New items, with dispositions:
    1. Reviewer 1's round-5 review (2026-10-28T13:40:40Z, blocking). Disposition below.
    2. Author's round-6 comment (2026-10-28T15:07:42Z). Claims match the code.
    3. Commit d4cf2d5b. Reviewed in full. No blocking defect.

Dispositions of round-5 findings

  1. Reviewer 1, blocking: the dashboard did not read the operator's compaction_point. Fixed. I re-checked this myself before agreeing.
    • The removed lines in this commit's diff prove the round-5 state: ceil := compactionpoint.For(...) in dash/compactepisode.go and dash/replaycap.go. Reviewer 1 was right, and my round-5 check of the doc sentence was incomplete: I traced only the proxy paths. I did not check the dash package readers. My miss, noted.
    • Now all three dash readers take a pointFn. The compact-episode span (CompactionEpisodesFor), the summarize ledger (summarizeattr.go), and the replay cap (ReplayLedgerForCtx, the SQL path too) build it with operatorPoint(ctx, windows).
    • operatorPoint puts modelinfo.OperatorCompactionPoint in front of compactionpoint.Resolve. A nil or plain resolver fails the capability assert, so stated is 0 and Resolve returns For. Fail-open holds.
    • With no field set, nothing changes. bootstrapPoint is For, and walkCompactEpisodes/walkReplayCap keep their old signatures by delegating to it. Tests pin both readers unchanged.
    • I grepped the repo. The only remaining production caller of compactionpoint.For is bootstrapPoint itself. Both Resolve callers (proxy, dash) sit behind the operator lookup. No reader is left behind.
  2. My note 1: ParseTable should reject compaction_point above the window. Fixed. The guard sits before the negative check, and the error names the model. Tests cover reject, point-alone, and point == window.
  3. My note 2: noteV3CSource was not paced. Fixed. It now counts inside if paced, like the refusal counters. The test expects exactly 2 counts over 6 requests at warm_every_n: 3. I checked the v3Reqs arithmetic myself: the request(0) makes v3Reqs 1, the six 10k requests make it 2..7, paced at 3 and 6. Exactly 2. The doc says "once per warm_every_n warm requests".
  4. Reviewer 1, non-blocking: resolveWindow's comment was displaced. Fixed. The comment is back above resolveWindow, and resolveCompactionPoint has its own.

Findings

None blocking.

Non-blocking

  1. The ParseTable guard has a residual hole. It fires only when one entry states both window and compaction_point. An entry that states a point but no window escapes the check. The model's window can still be known, from the public window map or another entry. So a typo'd point can still exceed the window. This is narrower than before — both fields in one entry, the common case, are now caught. A later change could look up the resolved window when the entry states none.

Notes on the fix

  • The new tests in dash/operatorpoint_test.go use only helpers that exist elsewhere in the package (row, capTestRow, testWindows, handPrice, mkEvent, openTestDB). I checked each.
  • The replay cap computes its limit as point(model, w).Frac * w. With an operator point this round-trips tokens through a fraction and can lose one token to float precision. A dashboard span does not need better. Not a finding.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

New work from the owner, on top of d4cf2d5. Hybrid is not changed. Verified on eval box 1: -race on components/offload and keepalive, make lint, mkdocs build --strict.

1. Rule (c), unreferenced. Off by default. Set rule_unreferenced: true (and rule_unreferenced_min_age, default 30 tool calls). It switches v3 on.

  • It uses the recheck's own signal: coref.IndexNovel over the agent's conversation (RawInput when set), and a record with identifiers and no later reference (ConsumeLag -1). No second definition.
  • An output that introduced no identifier is never chosen (no evidence either way).
  • It obeys protect_*, protect_last_n, expanded and already-marked outputs. Its drops count under rule_drops.unreferenced.
  • Tests: drops only what nothing later references; a later model turn, or a later tool call, that reuses an identifier protects the output; a full cut never drops a referenced output; min age; each protection; opaque outputs; off by default; the agent's own conversation is read. Mutations (all killed): ignore references; pick opaque outputs; ignore min age; ignore protection; on by default; read the pipeline copy.

2. Rule-mode logging. drop_too_small and no_rule_drops are now paced at warm_every_n and write one cg.sweep.warm_decision line with D, D/P, P/C, C, c_source and rule_d (for example rule_d=build_rerun:567,unreferenced:8901). v3.recent_refusals in /stats has the same. The gate's drop_too_small decision (hybrid) also carries rule_d; nothing else about hybrid changed. Two old tests counted these refusals on every request; I updated them to the pace.

3. Expand rate per source. The expand path could not tell the source without a stored label. It now can, with a name only: the drop record (cg:swd:) stores rule (a rule name or judge; empty with v3 off). v3.expands counts first expands by that name. With rule_drops and judge_drops it gives the rate per rule and for the judge. A cold judge drop counts under judge. With v3 off nothing is counted.

4. Docs and data dependence. advanced-offload.md and the extract_llm_sweep row: rule (c) reads later message text in flight, as the recheck already does, and the drop record gains a rule name (no content).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 1 of 2 7 of 7 cd94f98781a6 approve

Verdict: approve. The new feature commit adds rule (c) and three observability surfaces. I found no defect in it. Round 6 ended approve on both sides, so no finding is open.

What I checked

  • Last review: round 6, d4cf2d5, 2026-10-28T15:13:32Z
  • New commits read: 1 (cd94f98 feat(sweep): v3 rule (c) unreferenced, D by rule, expand per source (#491)). Read the full diff and the code around every hunk in all 7 files.
  • Read in full: 12 reviews, 6 comments, 0 inline comments (from the three files; the inline file is empty).
  • New items since my last review, and what I did about it:
    1. Commit cd94f98 — reviewed as a first review. Result below.
    2. Author comment (2026-10-28T22:42:35Z) — checked all four points against the code. All hold.
    3. Reviewer 2's round-6 review (2026-10-28T15:13:58Z, posted after my round-6 post) — read in full. Approve, one non-blocking note. I had checked its subject myself in round 6; see Earlier findings.

Earlier findings

Round 6 ended approve on both sides. No finding is open. The author rejected nothing. Two non-blocking notes stay open, both fine to leave:

  • My round-6 note (two stale dash doc comments): not fixed, unchanged. The commit touches no dash file. dash/replaycap.go:29 still names compactionpoint.For, and dash/compactepisode.go:1123 still lists three provenance values. Still one-line fixes for later.
  • Reviewer 2's round-6 note (a point stated without a window escapes the ParseTable guard): not fixed, unchanged. The commit touches no modelinfo file. I agreed with this residual in round 6 and still do: the common case (both fields in one entry) is caught; the hole needs a point-only entry plus a window known from elsewhere.

Findings

None.

Non-blocking

  • components/offload/extract_sweep_v3.go:941 — the V3Refusal comment says RecentRefusals holds "the last cut attempts a size gate refused (drop_too_small, no_rule_drops)". not_in_sweet_spot refusals land there too: noteV3Refusal now routes through noteV3SizeRefusal (extract_sweep_v3.go:976-977), which appends to RecentRefusals. The doc page says "size-gate refusals" and is right; only the Go comment's parenthetical under-lists. One-line fix.
  • components/offload/extract_sweep_v3.go:836-839 — the drop_too_small branch of v3Gate calls warmRatios a second time with the same arguments, inside the branch that already computed content three lines above. Same result, wasted call. Reuse the outer content.

What else I checked in the new commit

  • Rule (c) is the recheck's own signal, not a second definition. unreferencedIDs calls coref.IndexNovel(flattenForCoref(raw), e.minTokens, schema.TextTokens) with ConsumeLag < 0 and Novel > 0 (extract_sweep_v3.go:424-439). The recheck calls the same function with the same e.minTokens (extract_sweep_apply.go:930, extract_sweep_recheck.go:119) and reads ConsumeLag >= 0 for a reference after the question. With no question, "no reference at all" is the right analog. It reads RawInput when set, as the recheck does, so a reference only the agent's conversation carries still protects — TestV3UnreferencedReadsTheAgentsOwnConversation pins it. The echo and boilerplate guards live inside Index, so a path echoed from a tool-call argument does not count as a reference.
  • Opaque outputs are never chosen. Novel > 0 requires the output to have introduced an identifier; TestV3UnreferencedNeverChoosesAnOpaqueOutput pins it with boilerplate-only outputs. This is the safe direction: no evidence, no drop.
  • Protections. The rule loop runs after the protection loop and skips p.protected[i], marked outputs (carriesRealMarker), expanded outputs (isKeptVerbatim, restoredSpanGuard), and outputs below minTokens or with no positive save. TestV3UnreferencedObeysEveryProtection covers all of them. protect_last_n protects the newest 10 by position; the min age of 30 newer tool calls makes a rule (c) candidate older than that window anyway.
  • The min age. len(tools)-1-k >= e.ruleUnrefMinAge counts tool calls newer in the request (extract_sweep_v3.go:393). The config clamps <= 0 to the default 30, and the registry declares Default: 30, Min: 0. TestV3UnreferencedMinAgeIsInToolCalls pins the count.
  • Off by default. parseSweepV3 switches v3 on only when rule_unreferenced is written (extract_sweep_v3.go:101-104); the rule itself runs only when e.ruleUnref is set and the selector is not judge (the plan returns before the rules section for judge). Two tests pin both halves.
  • Fail-open and reversibility. Rule (c) adds candidates to plan.rules; every drop still goes through applyHeldFrom (marker, stash, drop record, panic restore). No new drop path. TestV3UnreferencedCutNeverDropsAReferencedOutput runs a full cut and checks the referenced output survives.
  • The rule label on the drop record. applyHeldFrom writes Rule: ruleOfSource(src, o.ToolUseID) (extract_sweep_apply.go:1009-1012). v3Held.ruleFor returns the rule from ruleOf, else judge; v3Filtered.ruleFor returns judge, which is right because a Store answer never holds a rule verdict (rule mode asks no question; a hybrid question is never offered a rule-decided output). Old records unmarshal with Rule empty, so the field is backward compatible. With v3 off, ruleOfSource returns "" and nothing is counted — TestV3NoRuleIsRecordedWithV3Off pins it.
  • expands counting. NoteSweepExpand counts a first expand under rec.Rule when non-empty (extract_sweep_apply.go:452-455). noteV3Expand takes v3Mu while the caller holds dropMu; no path takes them the other way round, so no lock cycle. v3Counters copies Expands and RecentRefusals under v3Mu. RecentRefusals is capped at maxV3Recent (50), like Recent.
  • The pacing change is counting only. no_rule_drops and rule-mode drop_too_small now count once per warm_every_n; the return (no drop) is unchanged. The gate's drop_too_small (once per real cut attempt, after a question) stays unpaced, and the doc scopes the pacing to rule mode, which matches. Two old tests were updated to the pace.
  • The /stats surface stays append-only. V3Stats.Expands, V3Stats.RecentRefusals, WarmDecision.RuleD and V3Refusal are new fields, all additive; Any() grows to include them.
  • Data dependence. The row is updated: rule (c) reads later message text in flight, as the recheck already does, and stores nothing new beyond a rule-name label with no content (docs/data-dependence.md). This matches the code.
  • The D-by-rule arithmetic. ruleD sums Saves x content per rule, and dBilled is validTokens() x content where validTokens sums Saves — so the per-rule values sum to D. The rule-mode refusal passes plan.ruleTokens(content), the same sum over the plan.
  • I did not run builds or tests (not approved). The author reports -race on components/offload and keepalive, lint, and mkdocs build --strict on eval box 1; my claims come from reading the code.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 2 of 2 7 of 7 cd94f98781a6 approve

Verdict: approve. One new commit since my round-6 review: cd94f987, a feature commit (rule (c), rule-mode refusal logging, expand counts per source). I found no blocking defect in it. Three notes stay non-blocking.

What I checked

  • Last review: round 6, sha d4cf2d5b5eafa4c9294eee22e09075ff7361ecad, posted 2026-10-28T15:13:58Z.
  • New commits read: 1 — cd94f987 "feat(sweep): v3 rule (c) unreferenced, D by rule, expand per source (#491)" (7 files, +502 −13). Full diff read, plus the code around each hunk.
  • Items read in full: 12 reviews (.review-in-reviews.txt, 600 lines), 6 comments (.review-in-comments.txt, 82 lines), 0 inline comments (.review-in-inline.txt, empty).
  • New items since my last review, with dispositions:
    1. Reviewer 1's round-6 review (2026-10-28T15:13:32Z, approve). It landed 26 seconds before my round-6 post, so I read it only now. Its one non-blocking note: two stale dash doc comments. Disposition below.
    2. Author's round-7 comment (2026-10-28T22:42:35Z). Checked every claim against the code. All hold.
    3. Commit cd94f987. Reviewed as a first review. No blocking defect.

Dispositions of round-6 items

  1. Reviewer 1, round 6, non-blocking: two dash doc comments still name the old ceiling source. Not fixed, and I agree it stays non-blocking. I checked both myself:
    • dash/replaycap.go:29 still says the cap uses "compactionpoint.For". It now uses the point resolver, which is For only when no field is set.
    • dash/compactepisode.go:1124-1125 still says Provenance is "measured", "assumed" or "default". It can now carry "operator" too.
    • This commit does not touch the dash package, so the notes stay open. One-line fixes whenever those files are touched next.
  2. My round-6 note: the ParseTable guard misses a point stated without a window. Still open. This commit does not touch internal/modelinfo. Non-blocking, as before.

Findings

None. What I verified in cd94f987:

  • Rule (c) is the recheck's own signal, not a second definition. unreferencedIDs calls coref.IndexNovel with the same arguments and the same RawInput-when-set wrapping as recheckHeld (extract_sweep_recheck.go:118-120). It keeps an output only when Novel > 0 (it introduced identifiers) and ConsumeLag < 0 (no later reference at all). That is strictly stronger than the recheck's test, which counts a reference only after the question. An output with Novel == 0 is opaque and never chosen — the coref package's own Classify says the same (coref.go:216-218).
  • flattenForCoref reads only req.Input (coref.go:413), so passing the whole req or &{Input: raw} gives the same index. Ids, not positions, join the two halves, so a raw/request message mismatch cannot mislabel.
  • Rule (c) sits last in the else-if chain after file_reread and build_rerun, and behind every shared gate: protections, Rewritable, carriesRealMarker, minTokens, the expanded check, saves > 0. The doc's claims ("obeys every protection", "never chosen when marked or expanded") all hold in the loop.
  • ruleUnreferenced alone switches v3 on but stays inert under selector: judge, because v3Plan returns before the rule loop. The hint and the doc both say "needs selector rule or hybrid". Agreed behavior, stated.
  • v3Plan runs only past the sweet-spot gate, so IndexNovel does not run on every request. It is one more O(conversation) pass on a path that already runs file evidence and the recheck's own index.
  • The refusal pacing. In rule mode, no_rule_drops and drop_too_small now count and log only on paced requests, like not_in_sweet_spot and cut_point_unknown. P, C and cSource are in scope at both new call sites, and noteV3SizeRefusal guards both divisions. The two updated tests match the pacing arithmetic I verified in round 6 (v3Reqs paced at 3 and 6 over the rig's requests).
  • The gate's ruleD covers the same set dBilled counts — both range over res.Valid with the same content ratio, so the per-rule numbers sum to D.
  • The drop-record label. ruleOfSource type-asserts a ruleNamer; v3Filtered answers judge (a stored answer is the judge's), v3Held answers the plan's rule or judge. With v3 off no source implements it, so Rule stays empty and nothing counts — pinned by TestV3NoRuleIsRecordedWithV3Off. Old drop records have no rule field and count nothing. The label is a name only, so the data-dependence row's "no content" claim holds; the row was updated.
  • /stats stays append-only. Expands and RecentRefusals are new omitempty fields. noteV3Expand and noteV3SizeRefusal take v3Mu. RecentRefusals is capped at maxV3Recent (50).
  • Fail-open and the default path. rule_unreferenced is off by default (parseSweepV3, TestV3UnreferencedIsOffByDefaultAndNeedsTheSetting checks three configs). Every drop still goes through applyHeldFrom, so the marker and the stash back it. Rule (c) changes which outputs are chosen, not how a drop is made.
  • The new tests use only helpers that exist elsewhere in the package (ruleIDs, assistantMsg, tCmdArgs, v3Out, refOutput, tReadArgs, heldFor, coldCtx, resetV3ForTest, lastWarmDecision, fakeAsker, MarkKeptVerbatim). I checked each.

Non-blocking

  1. components/offload/extract_sweep.go:1320 — the fill_small hint omits rule_unreferenced. The hint lists every setting that switches v3 on: "selector (rule or hybrid), fill_small, fill_large, min_drop_frac, protect_tools, protect_paths or protect_last_n". This commit makes rule_unreferenced a v3-switching setting (parseSweepV3), so the list is stale again. This is the same defect class as reviewer 1's round-1 note, fixed then in 8637651b. The field's own hint does say "Writing it switches the v3 gates on", so only the aggregate list lags. Add the name to the list.
  2. The doc claims more for recent_refusals than it holds. advanced-offload.md calls it "the last size-gate refusals". The hybrid/judge-path drop_too_small in v3Gate is a size-gate refusal: it writes a decision line with the same fields, but it does not enter RecentRefusals. Only the rule-mode refusals and the sweet-spot ones do. Also, V3Refusal's comment names only drop_too_small and no_rule_drops, but sweet-spot refusals land there too, with D = 0. Say in the doc which refusals the list covers, or add the gate's refusal to it.
  3. Reviewer 1's round-6 note and my round-6 note stay open (see Dispositions). Neither is addressed by this commit, and neither blocks.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Gate change from the owner, after t99 (rule (c) found 15-17% at 0.85 x C, but all 10 checks were refused does_not_pay: "since the shrinking postpone the compaction"). Verified on eval box 1: -race on components/offload and keepalive, make lint, mkdocs build --strict. #720's warm path without v3 is unchanged.

1. Turns left count the postponement. In v3, N' = (C - (P - D_billed)) / g, capped by warm_max_turns. It is one function, turnsUntilCut, now also used by cacheRewriteHorizon, so coref and the gate share the definition. The trigger uses the same rule with its own D. warmTurnsLeft keeps its signature and result; warmTurnsLeftAfter takes D. The decision log has N (turns_no_cut) and N' (turns_after_cut).

  • The t99 case (P 142k, D 24.8k, g 1.1k, C 167k): N = 22.7, N' = 45.2, N' - N = D/g = 22.5.

2. The avoided compaction is credited (credit_avoided_compaction, on in v3 only; write false to turn it off).

  • Credited only when the compaction would have come inside the horizon without the cut (N <= warm_max_turns) and the cut pushes it past (N' > warm_max_turns). If it only delays the compaction, nothing is credited.
  • saving_compaction_usd = C x read + compactionSummaryFrac x C x write, with compactionSummaryFrac = 0.10 (a named constant). The summary call reads the prompt at the warm read rate. The summary's own output is not counted. Every choice makes the credit smaller. The formula and inputs are in the docs. The gate accepts on saving + saving_compaction >= rewrite.
  • v3.compactions_avoided and v3.saving_compaction_usd in /stats; each recent_cuts entry carries its credit. They count what the gate credited, not a measurement.

3. rule_d on every decision line, accepted or refused, does_not_pay included. It is set once, in the gate's deferred log, from the gate's own D by rule.

Tests (mutation killed for each unless noted): N' > N by D/g with the t99 numbers and the cap; one definition; the credit only when avoided; the formula; the off switch; the gate accepting on the credit and refusing without it; the stats; the plain warm path unchanged (no post-cut turns, no credit); rule_d on does_not_pay and on accept. One mutation (drop the !e.v3 check in the credit) is equivalent: creditAvoided is only ever set inside the v3 parse, so it is already false without v3.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 2 of 2 8 of 8 4feec280d616 approve

Verdict: approve. One new commit since my round-7 review: 4feec280, a gate change (turns after the cut, credit for an avoided compaction, rule_d on the gate's decision lines). I found no blocking defect in it. The open notes stay non-blocking.

What I checked

  • Last review: round 7, sha cd94f98781a6c654373f91a7484e89e8325becf4, posted 2026-10-28T22:48:20Z.
  • New commits read: 1 — 4feec280 "feat(sweep): v3 gate counts the postponed and the avoided compaction (#491)" (7 files, +383 −43). Full diff read, plus the code around each hunk.
  • Items read in full: 14 reviews (.review-in-reviews.txt, 700 lines), 7 comments (.review-in-comments.txt, 97 lines), 0 inline comments (.review-in-inline.txt, empty).
  • New items since my last review, with dispositions:
    1. Reviewer 1's round-7 review (2026-10-28T22:47:51Z, approve). It landed 29 seconds before my round-7 post, so I read it only now. Two non-blocking notes on cd94f987: the V3Refusal comment under-lists (open, same point as my round-7 note 2), and the double warmRatios call in v3Gate (fixed by this commit — the ruleD computation is hoisted into the measured block, and the branch now reads wa.ruleD).
    2. Author's round-8 comment (2026-10-29T08:07:53Z). Checked every claim against the code. All hold, including the mutation-equivalence claim (see below).
    3. Commit 4feec280. Reviewed as a first review. No blocking defect.

Dispositions of round-7 items

  1. My note 1: the fill_small hint omits rule_unreferenced. Not fixed. I grepped extract_sweep.go:1323: the hint still lists seven settings, without rule_unreferenced. This commit adds credit_avoided_compaction (not a v3 switcher, so its absence from the list is correct) but does not fix the stale list. Still a one-word fix.
  2. My note 2: the doc and the V3Refusal comment claim more for recent_refusals than it holds. Not fixed. The doc still says "the last size-gate refusals" (advanced-offload.md:730), and the gate's hybrid drop_too_small still writes a decision line but no RecentRefusals entry. Reviewer 1's round-7 note on the V3Refusal comment is the same point; I agree with it.
  3. My note 3 / the round-6 notes: still open, unchanged. This commit touches no dash or modelinfo file. The two stale dash comments and the ParseTable residual hole stay as they were. All non-blocking.

Findings

None. What I verified in 4feec280:

  • The postponement arithmetic. warmTurnsLeftAfter computes the after-cut turns with turnsUntilCut(cut, P-D, g), which is exactly the no-cut (cut-P)/g plus D/g. With removedBilled = 0 the function returns the old estimate unchanged — warmTurnsLeft delegates with 0, and TestV3TurnsLeftCountFromThePromptAfterTheCut pins the equality plus the t99 numbers (N 22.7, N' 45.2, difference D/g 22.5).
  • One definition. turnsUntilCut is the old cacheRewriteHorizon body lifted into a function. The coref call passes the same three values as before, so coref's behavior is unchanged. The floor at 0 is kept.
  • The plain warm path is unchanged. removedBilled is 0 without v3 at both call sites, so te.Raw == te.RawNoCut and the crossing test in avoidedCompactionUSD is false by construction. credit is then 0, so !(saving+credit > rewrite) is the old comparison. TestV3OffTheWarmGateIsUnchanged and TestV3OffTheWarmGateCountsTurnsFromThePromptAsItIs pin both halves.
  • The credit fires only on a real crossing. te.RawNoCut <= horizon && te.Raw > horizon uses the raw (uncapped) values — the right choice, because the capped N can never exceed warm_max_turns. Without a cut the two raws are equal, so the test is false. A cut that only delays the compaction (Raw still inside) credits nothing. The model must be turnsModelCut and te.Cut > 0, so the expected-turns and no-billed estimates never credit.
  • creditAvoided is really v3-only. parseSweepV3 returns early when v3 is off or warm is false, before the creditAvoided line (extract_sweep_v3.go:102-108). So creditAvoided stays false off v3, and the author's claim that dropping the !e.v3 check is an equivalent mutation is right. credit_avoided_compaction alone does not switch v3 on — it is not in the on-switch list, and the hint says "It does nothing without v3".
  • The gate ordering for rule_d. v3Gate sets wa.ruleD from res.Valid before it calls the inner gate, and warmGate's deferred log reads wa.ruleD on every exit, so accepted, does_not_pay and every other apply-stage refusal carries it. TestV3DoesNotPayRefusalCarriesRuleD and TestV3AcceptedDecisionCarriesRuleD pin both. The hoist also removed the duplicate warmRatios call (reviewer 1's round-7 note 2, fixed).
  • The stats surface. CompactionsAvoided, SavingCompactionUSD (in V3Stats and V3Cut) and the four WarmDecision fields are new omitempty fields, so /stats stays append-only. noteV3Cut counts an avoided compaction only when the credit is positive. Any() grows to include CompactionsAvoided.
  • The credit formula matches the doc: C x read + compactionSummaryFrac x C x write, compactionSummaryFrac 0.10, both rates from warmGateRates (the cache read rate). No division, no new data input — C and the rates are metadata, as the doc says.
  • Fail-open and reversibility. The commit changes when a cut is accepted, not how a drop is made. Every drop still goes through applyHeldFrom. The trigger's worth test uses the same credit with its own D (every candidate), as the commit message says.
  • The new tests use only helpers that exist elsewhere in the package (warmCfg, newWarmRig, payingTail, toHeld, resetWarmForTest, lastWarmDecision, the rig's c/window fields). I checked each. The gate test strips warm_expected_turns from the rig so the cut turns model runs — without that, avoidedCompactionUSD could never fire.

Non-blocking

  1. The round-7 notes stay open (see Dispositions): the fill_small hint, the recent_refusals doc sentence and V3Refusal comment, the two stale dash comments, the ParseTable residual hole.
  2. docs/components/advanced-offload.md:724 — "rule_d is on every v3 decision line" overstates. The trigger-stage lines (no_billed_size, no_candidate, below_mass, does_not_pay from warmWorthAsking, Stage "trigger") carry no rule_d; only the apply-stage lines do. The gate cannot know a rule split there — it sums every candidate — so the behavior is right; the doc should say "every apply-stage decision line". The author's comment says exactly that ("set once, in the gate's deferred log"); only the doc page is broader.
  3. Two small doc-code mismatches in the new gate text. The doc says the gate accepts when saving + saving_compaction >= rewrite; the code keeps the strict > (!(saving+credit > rewrite)), so an exact tie refuses. And the doc's horizon test is written as N <= warm_max_turns / N' > warm_max_turns, but the code compares the raw, uncapped values — the logged turns_no_cut/turns_after_cut are capped, and a capped N' can never exceed the horizon. The code is right in both cases; the words could say it exactly.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.312 offload-review skill, @amiddavid's session resumed 1 of 2 8 of 8 4feec280d616 blocking

Verdict: blocking. One finding: the v3 payback gate now counts the removal's saving past the turn where the no-cut thread stops reading the removed tokens, and credits the compaction that stops it. The two terms assume opposite baselines, so their sum over-credits.

What I checked

  • Last review: round 7, cd94f98, 2026-10-28T22:47:51Z
  • New commits read: 1 (4feec28 feat(sweep): v3 gate counts the postponed and the avoided compaction (#491)). Read the full diff and the code around every hunk in all 7 files.
  • Read in full: 15 reviews, 7 comments, 0 inline comments (from the three files; the inline file is empty).
  • New items since my last review, and what I did about it:
    1. Commit 4feec28 — reviewed as a first review. Result below.
    2. Author comment (2026-10-29T08:07:53Z) — checked every claim against the code. The postponement arithmetic, the credit formula, the off switch and the rule_d hoist all hold. The payback arithmetic itself is the finding.
    3. Reviewer 2's round-7 review (2026-10-28T22:48:20Z, 29 seconds after my round-7 post) — read in full. Approve, three non-blocking notes. I checked each; see dispositions.
    4. Reviewer 2's round-8 review (2026-10-29T08:12:19Z) — read in full. Approve, with notes on the open round-7 items and three new doc-wording notes. I checked each; I agree with notes 2 and 3 and say so below. The review does not cover the baseline question in my finding.

Earlier findings, dispositions

Round 7 ended approve on both sides. No finding is open. The author rejected nothing.

  • My round-7 note 1 (the V3Refusal comment under-lists what RecentRefusals holds): not fixed. The comment still names only drop_too_small and no_rule_drops (extract_sweep_v3.go:941). Reviewer 2's round-7 note 2 is the same point, wider (the doc sentence too). Still a one-line fix, still non-blocking.
  • My round-7 note 2 (v3Gate called warmRatios twice): FIXED. wa.ruleD is now computed once, in the measured block, before the drop_too_small branch and before the inner gate runs (extract_sweep_v3.go). The branch reads wa.ruleD. Reviewer 2 confirmed the same fix.
  • Reviewer 2's round-7 note 1 (the fill_small hint omits rule_unreferenced): not fixed. I checked the hint (extract_sweep.go:1323): it still lists seven settings without rule_unreferenced. credit_avoided_compaction is correctly absent — it does not switch v3 on. Still a one-word fix.
  • Reviewer 2's round-7 note 3 and the round-6 notes (stale dash comments, the ParseTable residual hole): unchanged. This commit touches no dash or modelinfo file. Still non-blocking.

Findings

1. The v3 gate's saving term and its avoided-compaction credit use opposite baselines, and the sum over-credits by more than the credit itself.

Where: components/offload/extract_sweep_warm.go:770-785 (turns := te.N, warmEcon, avoidedCompactionUSD, the accept test), extract_sweep_warm.go:600-645 (warmTurnsLeftAfter).

What the two terms say about the same no-cut thread:

  • The saving term: saving = D x content x read x turns, with turns = N' capped at warm_max_turns. It prices D as read by the no-cut thread for N' more turns.
  • The credit term: avoidedCompactionUSD fires only when N <= horizon < N'. It says the no-cut thread compacts at N, inside the horizon, and prices that compaction (C x read + 0.10 x C x write).

Both cannot hold. If the no-cut thread compacts at N, the summary replaces the dropped content, so the thread stops reading D at N. The saving must stop at N too. If the no-cut thread does not compact inside the horizon, there is no compaction to credit. Under either reading, one of the two terms counts benefit that the other one's baseline says does not exist.

The stretch between N and min(N', horizon) is not just mis-sized, the sign is wrong. After its compaction the no-cut thread reads a summary-sized prompt. The model's own compactionSummaryFrac (0.10) says that is 0.10 x C. The cut thread reads about C - D there. So per turn in that stretch the cut thread pays MORE than the no-cut thread, by about (C - D - 0.1C) x read. The gate counts +D x read.

Numbers, the t99 case from the author's comment (P 142k, D 24.8k, g 1.1k/turn, C 167k, default horizon 60):

  • N = 22.7, N' = 45.2. No credit fires (N' < 60). The gate now counts the saving over 45.2 turns; the old gate counted 22.7.
  • For the 22.5 turns between N and N', the no-cut thread reads about 16.7k regrowing to 41k; the cut thread reads 142k growing to 167k. The honest difference is about -125k tokens per turn. The gate counts +24.8k.
  • Over-count: about 22.5 x 125k x read = 2.8M token-reads. The whole counted saving is 24.8k x 45.2 x read = 1.1M. The over-count is about 2.5 times the counted saving.
  • In the avoided case of the PR's own test (horizon 30): the stretch is 7.3 turns, the over-count about 0.9M x read, the credit 167k x read + 16.7k x write. At the test's rates that is $0.27 against $0.11 — the over-count alone is about 2.4 times the credit.

What fails: the gate accepts cuts whose honest payback is negative, in the near-compaction regime this change targets. The PR's own test TestV3TheGateAcceptsOnTheCompactionCreditAndLogsIt builds one: the credit off, the gate refuses; the credit on, it accepts. The customer pays the rewrite premium once, then pays more per turn than the compacted thread would have.

Why blocking and not a design note:

  • The gate's own stated principle is "The direction of every doubt is 'refuse'" (warmRatios, extract_sweep_warm.go:495-496). This change's error direction is accept, in the feature's target regime.
  • The t99 motivation (all 10 checks refused does_not_pay) is real, but the honest mechanism for "a removal is worth more than the reads it avoids" is a stated premium, as #720's doc did with reward_premium ("where that gap is stated, in config, falsifiably"). A horizon that counts turns no baseline world contains hides the premium inside the saving.
  • credit_avoided_compaction: false turns off only the credit. The N' extension of the saving has no switch. A v3 operator cannot get the old saving arithmetic back.

Fix direction, pick one:

  1. Smallest: keep the credit, count the saving to N only. te.NNoCut is already computed and logged. Both terms then share one baseline (the no-cut thread compacts at N).
  2. Full counterfactual: saving to N, minus (C - D - 0.1C) x read per turn from N to min(N', horizon), plus the credit when avoided. This will refuse most near-compaction cuts on token cost alone.
  3. Keep the arithmetic and rename what it is: a deliberate premium for postponing compaction, not a payback calculation. Then saving_usd in the decision log no longer means "cache reads saved", and the doc must say so.

Non-blocking

  • I agree with reviewer 2's round-8 note 2, after checking it myself: "rule_d is on every v3 decision line" (docs/components/advanced-offload.md:724) overstates. The trigger-stage lines carry no rule_d; only apply-stage lines do. The author's comment says "the gate's deferred log", which is the apply stage. Say "every apply-stage decision line".
  • I agree with reviewer 2's round-8 note 3, both halves: the doc says the gate accepts on saving + saving_compaction >= rewrite but the code keeps the strict > (extract_sweep_warm.go:785), and the doc writes the horizon test on N and N' while the code compares the raw, uncapped values (the logged turns_no_cut and turns_after_cut are capped). The code is right in both; make the words exact.
  • The round-7 notes stay open, unchanged: the fill_small hint, the recent_refusals doc sentence and V3Refusal comment, the two stale dash comments, the ParseTable residual hole.

What else I checked

  • The postponement arithmetic is right. warmTurnsLeftAfter computes N' with turnsUntilCut(cut, P - D, g), which is the no-cut form plus D/g. The t99 numbers check out: N 22.7, N' 45.2, difference 22.5. warmTurnsLeft with D = 0 returns the old estimate unchanged, and the test pins the equality.
  • One definition. turnsUntilCut (components/offload/prefix_econ.go) is the old cacheRewriteHorizon body lifted out. The coref call passes the same three values as before, floor at 0 kept. Coref is unchanged.
  • The plain warm path is unchanged. removedBilled is 0 without v3 at both call sites, so Raw == RawNoCut and the credit's crossing test is false by construction. !(saving + 0 > rewrite) is the old comparison. TestV3OffTheWarmGateIsUnchanged and TestV3OffTheWarmGateCountsTurnsFromThePromptAsItIs pin both halves.
  • The credit's crossing test uses the raw, uncapped values. te.RawNoCut <= horizon && te.Raw > horizon — the right choice, because the capped N can never exceed warm_max_turns. A cut that only delays the compaction credits nothing; a far cut point credits nothing. turnsModelCut and te.Cut > 0 are required, so the expected-turns and no-billed models never credit.
  • creditAvoided is v3-only. parseSweepV3 returns before the field is read when v3 is off, so the missing !e.v3 check in avoidedCompactionUSD is an equivalent mutation, as the author says. credit_avoided_compaction alone does not switch v3 on.
  • The rule_d hoist. v3Gate sets wa.ruleD once when measured, before the drop_too_small branch and before the inner gate. warmGate's deferred log reads it on every exit, so accepted and does_not_pay lines both carry it. TestV3DoesNotPayRefusalCarriesRuleD and TestV3AcceptedDecisionCarriesRuleD pin both. The hoist also removed the duplicate warmRatios call (my round-7 note 2).
  • The trigger does the same with its own D. warmWorthAsking builds removed optimistically (every candidate dropped, saves summed over the same candidate scan the question uses) and passes its own removedBilled to warmTurnsLeftAfter (extract_sweep_warm.go:996-1005). The trigger and the gate share one turns model, as the comment claims.
  • The stats surface stays append-only. CompactionsAvoided, SavingCompactionUSD (in V3Stats and V3Cut) and the four WarmDecision fields are new omitempty fields. noteV3Cut counts an avoided compaction only when the credit is positive. Any() grows to include CompactionsAvoided.
  • The cut point in the credit. te.Cut is FillDenominator() or CutFrac times it — the same effective-context C the v3 gates use. No division, no new data input; C and the rates are metadata.
  • Fail-open and reversibility. The commit changes when a cut is accepted, not how a drop is made. Every drop still goes through applyHeldFrom (marker, stash, drop record, panic restore). No new drop path.
  • Data dependence. Unchanged: the credit reads C and the two rates, all metadata. The doc states this.
  • I did not run builds or tests (not approved). The author reports -race on components/offload and keepalive, lint, and mkdocs build --strict on eval box 1; my claims come from reading the code.

amiddavid added a commit that referenced this pull request Oct 29, 2026
)

Review round 8 on #763.

- the saving is priced on N, the turns until the compaction would have
  come without the cut: (C - P) / g. A cut only delays the compaction,
  and the compaction at N removes the dropped outputs anyway, so
  nothing past N is a saving
- N' (turns from the prompt after the cut) stays in the log for reading
  and is not priced; one function, turnsUntilCut, still serves coref
  and the gate
- remove credit_avoided_compaction, saving_compaction_usd,
  compactions_avoided and compactionSummaryFrac; the key is refused
  with a reason
- doc and comment fixes: apply-stage decision lines, strict >,
  fill_small hint, recent_refusals, two dash comments

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 8 fix. Verified on eval box 1: -race on components/offload and keepalive, make lint, mkdocs build --strict, and go test on config and components/all.

The saving is priced on N, not N'. R1 was right. Without the cut the thread compacts at N, and that compaction removes the dropped outputs anyway.

  • The gate's turns are te.N: (C - P) / g, capped by warm_max_turns, weighted as before. No session-end estimate and no premium.
  • warmTurnsLeftAfter still reports NAfter (N'), counted from the prompt after the cut by the shared turnsUntilCut. The log keeps both: turns_no_cut (N, priced) and turns_after_cut (N', for reading). The docs say the gate prices on N only, and why.
  • The trigger's estimate uses N too.

The avoided-compaction credit is removed. credit_avoided_compaction, saving_compaction_usd, compaction_avoided, compactions_avoided, compactionSummaryFrac, their stats, docs and tests. It never shipped. The key is in sweepBannedKeys with the reason, so an operator who wrote it gets a clear error.

Doc and comment fixes

  • "every v3 decision line" is now "every apply-stage decision line".
  • The doc says saving > rewrite (strict), as the code does.
  • The fill_small hint lists rule_unreferenced.
  • The recent_refusals doc sentence and the V3Refusal and noteV3SizeRefusal comments now say these are refusals made before the gate. The gate's own are in the decision log.
  • The two dash comments (replaycap.go header, compactepisode.go "ceiling is per model") say the operator's compaction_point comes first.

Tests

  • TestV3GatePricesTheSavingOnNAndNotOnNPrime: N = 25, N' = 50 in the t99 shape; the priced turns equal N x weight; on N the cut does not pay, on N' it would; the gate refuses. Mutation "price on N'" fails it.
  • N' is reported beside N and does not change N when D is passed; N' ignoring D fails.
  • The removed key is refused with a reason.
  • With v3 off the warm gate is unchanged (existing test, now without credit fields).
  • Mutations killed: price on N'; fold N' into N; N' not logged; N' ignores D; banned key dropped. One survives: saving > rewrite to >=. The line is feat(sweep): the warm path, an economic gate on a held answer (#491) #720's, unchanged, and a fixture that hits exact float equality would be contrived. I did not add one.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

Two more items from the owner, on top of b97dede. Verified on eval box 1: -race on components/offload and keepalive, make lint, mkdocs build --strict, and go test on config and components/all.

1. fill_small default is 0.70 (from 0.85): 70% of the effective context at C <= 200k, a general rule. fill_large stays 0.6, so the line still falls. An unset or out-of-range value reads as 0.70. The hint and the docs use the new numbers (0.70 x 167k = 117k). The tests that pinned 0.85 now pin 0.70, and TestV3FillDefaultsAreSeventyAndSixty covers the defaults, the out-of-range case and a written value.

2. compaction_premium_usd (float, default 0, v3 only). An experiment knob to measure whether cutting as much as possible improves quality; cost is a constraint, not the goal.

  • When a cut postpones the compaction (N' > N, in the cut turns model), the gate accepts on saving_to_N + premium > rewrite. With 0 it is exactly the cost gate: saving to N, no credit.
  • Every apply-stage decision logs premium_usd and passed_on_cost (true when the saving to N beat the rewrite alone). The real cost (saving_usd, rewrite_usd) is still logged.
  • /stats: v3.cuts_on_cost and v3.cuts_on_premium. A cold or changed-prefix cut runs no gate and is in neither.
  • The docs call it an experiment knob. A high value (for example 10) effectively turns the cost gate off in a $0 test. Setting it switches v3 on, like every v3 setting.

Tests (mutations killed): premium 0 equals the cost gate (same refusal, same numbers); a premium lets a refused case through and marks it passed_on_cost=false, counted on premium; a cut that pays on cost stays on cost with a premium; the premium needs a postponement and the cut model; it is off without v3. Two survivors, both equivalent: dropping the premium <= 0 guard (a premium of 0 adds 0 anyway) and dropping the !e.v3 guard (off v3 the parse leaves the premium at 0).

Add a v3 configuration of the warm path. Off unless a v3 setting is
written; the default config is unchanged from #720.

- sweet spot: cut only when P >= fill(C) x C
- one cut per round: wait for growth after an accepted cut
- meaningful drop: D >= min_drop_frac x P, then #720's payback gate
- selector: judge (default), rule (no model call), hybrid (one cut)
- rules: file re-read or write, build/test/lint re-run
- protect_tools, protect_paths, protect_last_n
- counters under keepalive.sweep_warm.v3 and in the decision log

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
)

Review round 1 on #763.

- the ping question builds the v3 plan: no protected output is offered,
  and in hybrid no rule-decided output
- selector rule refuses the ping question (ping_refused_rule)
- a Store answer applied cold skips protected outputs
- a cold or changed-prefix apply counts as a cut and starts the wait
- rule drops record their own token count
- refusals not_in_sweet_spot and cut_point_unknown count once per
  warm_every_n; a request with no billed size counts nothing
- hybrid_rules_only counts only a real "no answer"
- remove dead code and unused imports; fix comments and hints

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
- build the protected set lazily on a cold apply: no plan without a
  stored answer
- selector rule keeps no ping copy, as the ping is always refused
- a cold-apply cut splits rule drops from judge drops through ruleOf
- a cold apply of a waiting hybrid answer clears v3Asked even when it
  changes nothing

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
- docs: a rule-mode ping counts as sweep_no_candidate; ping_refused_rule
  fires only for a candidate left from before a config change
- v3ColdCut: note that ruleOf is empty on every production path today
- read the marked-id set only when a claim wins, as the plan is built
- use carriesRealMarker, not a substring test, for the marker check

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
The sweet spot is a share of where the client compacts, not of the
window. An operator can state that point per model.

- MODEL_PRICES: new optional compaction_point (billed tokens), beside
  window. It does not change window.
- compactionpoint.Resolve prefers it (Source operator) over the
  bootstrap table. The proxy resolves it for /v1/messages and /compact.
- v3 C: CutFrac x C with a summarizer, else the compaction point unless
  its source is window_fallback, else the window.
- /stats v3.c_source, C and c_source in each recent cut and in the
  decision log.
- Nothing changes unless the field is set.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
Review round 5 on #763.

- the compact-episode span, the summarize ledger and the replay cap
  resolve the compaction point through the operator table first, as
  they already do for the window; with no field set the numbers are
  the same as before
- ParseTable rejects a compaction_point above the entry's window, and
  names the model
- noteV3CSource is paced at warm_every_n, like the refusal counters
- move resolveWindow's doc comment back above resolveWindow

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
…491)

- rule (c), off by default (rule_unreferenced, rule_unreferenced_min_age):
  drop an output that nothing later references, using the recheck's own
  referenced_later signal (coref.IndexNovel); it obeys every protection
- rule-mode refusals (drop_too_small, no_rule_drops) are paced at
  warm_every_n and log one decision line with D, D/P, C, c_source and D
  by rule; /stats v3.recent_refusals has the same
- the drop record stores the name of what chose the drop (a rule or
  judge); /stats v3.expands counts first expands by that name
- hybrid is unchanged

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
…491)

- turns left in v3 count from the prompt after the cut:
  N' = (C - (P - D)) / g. One function, turnsUntilCut, now shared with
  the co-reference horizon. The trigger does the same with its own D.
  The plain warm path is unchanged.
- credit_avoided_compaction (on in v3 only): when a cut pushes the
  compaction past the horizon, credit saving_compaction_usd =
  C x read + compactionSummaryFrac x C x write. The gate accepts on
  saving + saving_compaction >= rewrite. Nothing is credited when the
  compaction is only delayed.
- N, N', saving_compaction_usd and rule_d are in every v3 decision
  line; /stats v3 counts the compactions avoided and their credit.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
)

Review round 8 on #763.

- the saving is priced on N, the turns until the compaction would have
  come without the cut: (C - P) / g. A cut only delays the compaction,
  and the compaction at N removes the dropped outputs anyway, so
  nothing past N is a saving
- N' (turns from the prompt after the cut) stays in the log for reading
  and is not priced; one function, turnsUntilCut, still serves coref
  and the gate
- remove credit_avoided_compaction, saving_compaction_usd,
  compactions_avoided and compactionSummaryFrac; the key is refused
  with a reason
- doc and comment fixes: apply-stage decision lines, strict >,
  fill_small hint, recent_refusals, two dash comments

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
#491)

- fill_small default is 0.70 (70% of the effective context, a general
  rule), from 0.85. fill_large stays 0.6. An unset or out-of-range
  value reads as the default.
- compaction_premium_usd (default 0, v3 only, an experiment knob): when
  a cut postpones the compaction, the premium joins the saving side:
  accept on saving_to_N + premium > rewrite. With 0 the gate is the
  cost gate. Every apply-stage decision logs premium_usd and
  passed_on_cost; /stats has v3.cuts_on_cost and v3.cuts_on_premium.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
…eads (#491)

- the drop record (cg:swd:) stores the tool name, the class of the tool
  (read, edit, command, other) and an 8-byte HASH of the call's file
  path or command. The path itself is never stored. One hash function
  serves the drop and the later scan; a prefix keeps a path and a
  command apart.
- on each later request the sweep hashes the path or command of the
  later tool calls and matches them against the dropped hashes. Each
  drop counts once.
- /stats v3.reread_after_drop (total, by_source: a rule name or judge,
  by_kind) and v3.dropped_by_kind, the denominator for a re-read rate.
- with v3 off nothing is recorded or scanned.
- data-dependence row and docs updated.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
- dry_run (bool, default false, v3 only): everything runs as a normal
  v3 run (the pings, the judge's questions, the rules, the recheck, the
  gate and its logs), but no drop is applied on any path: warm, cold
  (Store or memory answer), changed-prefix and the v3 cold branch.
- each would-be cut is logged as cg.sweep.dry_run_cut with a real cut's
  fields and counted in v3.dry_run_cuts (and v3.dry_run_drops,
  v3.dry_run_recent_cuts).
- a would-be cut does not start the growth wait, so a dry run asks as
  often as a real one does before its first cut.
- the forwarded request has no sweep drops: no message changes, no
  stash, no marker, no drop record.
- data-dependence row: the stored path hash is approved 2026-11-01.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid
amiddavid changed the base branch from feat/sweep-warm to main November 10, 2026 14:24
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Box results (eval box 1, head 9ea9277, -count=1)

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.322 offload-review skill, @amiddavid's session resumed 1 of 2 12 of 13 9ea92771aa17 approve

Verdict: approve. The PR was rebased onto a new main (base 87b29db, was 6298673). No new feature commit came with it. I verified the rebase commit by commit: 10 of the 12 commits are byte-identical patches to the ones I reviewed in rounds 2-11 (patch-ids match), and the 2 the rebase reworked I read in full. No blocking defect. One new non-blocking note: the new "operator" compaction-point source is missing from three enumeration comments.

What I checked

  • Last review: round 11, sha 694b5a294eadb506e064d07d012b823e5a5ae203, posted 2026-11-01T09:26:35Z.
  • New commits read: 12 — git log 694b5a29..9ea92771 lists the whole series again, because the rebase rewrote every SHA:
    fdc11a6d sweep v3 on the warm path · e5c38b37 ping question and cold apply · 6278f86f round 2 notes · dd7fdb46 round 3 cleanup · 64920442 reworked sweet spot from the effective context · 27ef9036 reworked operator compaction_point in the dashboard · 686bf36c rule (c) unreferenced · cedcb227 gate counts postponed and avoided compaction · 24b38bdb saving priced on N · a7e55757 fill_small 0.70 and the premium · d0d851b0 drop records and re-reads · 9ea92771 dry_run.
  • How I read them. main moved about 100 commits between the two bases (#720's merge and the compactionpoint work behind it, through #1002). I matched each rebased commit to its old counterpart by title and compared patch-ids: 10 pairs identical, so the code I verified in rounds 2-11 is unchanged. The 2 differing pairs (47e1badb→64920442, d4cf2d5b→27ef9036) I read as full patches, old and new side by side, plus the code around every hunk at the new head.
  • Read in full: 22 reviews (.review-in-reviews.txt, 1174 lines), 12 comments (.review-in-comments.txt, 181 lines), 0 inline comments (.review-in-inline.txt, empty).
  • New items since my last review, with dispositions:
    1. Reviewer 2's round-11 review (2026-11-01T09:25:22Z, approve). It landed 73 seconds before my round-11 post, so I read it only now. Its two notes I checked myself: the cold-path dry-cut numbers (agree — same as my round-11 note 1, still open) and the carry-over list (agree, none fixed by the rebase).
    2. Author's comment (2026-11-10T14:25:38Z): box results on head 9ea92771 — lint, go test ./... (48 packages), -race on 8 packages, mkdocs build --strict, and a rerun on the final head after #1002 landed. Consistent with what I verified: the base is main, #720 is merged, the branch holds 12 commits. I did not run tests myself (not approved).
    3. The rebase itself. Reviewed as a first review where it changed content — see Findings.

What the rebase reworked (and I verified)

  • 64920442 (sweet spot from the effective context). main now has Point.Abs, the Tokens() shortcut and Recorded from the #720/#955-era work, so the commit no longer re-adds them. It adds the Operator source on top: Resolve() in internal/compactionpoint, Chain.CompactionPoint and Table.CompactionPoint in internal/modelinfo, the compaction_point field in the MODEL_PRICES table, and resolveCompactionPoint in the proxy. I checked the wiring end to end: both /v1/messages and /compact go through compactionPointFor (proxy.go:931, proxy.go:1336), which keeps the user's own client setting first and falls back to resolveCompactionPoint; the source flows into components.Ctx.CompactionPointSource (proxy.go:948), and v3CutPoint treats any point that is not window_fallback as C. Precedence and fail-open behavior are unchanged from what I approved before.
  • 27ef9036 (operator point in the dashboard). main added episodeConversationPoint/capConversationPoint, so the commit now threads a pointFn through them instead of replacing compactionpoint.For calls. It also gates noteV3CSource on paced (extract_sweep_v3.go:686-688), so the c_source counter runs at the same warm_every_n pace as the refusal counters — this matches the docs, and TestV3CSourceIsReportedForEachCase pins it (2 counts over 6 requests). A compaction_point above a stated window is now rejected at table parse. I checked the C <= 0 refusal returns before noteV3CSource, so the empty source is never counted.
  • Behavior-change naming (new repo rule). The PR body names it at the top: the data-dependence change with its approval dates, and "Every v3 setting is off by default. The default config gives the same bytes as main. A test proves it." The compaction_point field is opt-in ("Nothing changes unless it is set"). Satisfied.
  • Keep-alive and the cache strategy (new repo rule). The reworked commits touch no cache-strategy code. dry_run keeps the pings and the questions running. Nothing shortens a cache strategy.

Dispositions of earlier findings

No finding was rejected by the author. Nothing earlier is blocking.

  1. My round-11 note 1 (cold dry cuts log hard-coded passed_on_cost=false / premium_usd=0): not fixed. Both call sites unchanged (extract_sweep_apply.go:851, extract_sweep_v3.go:626). Reviewer 2's round-11 note 1 is the same finding; I re-checked it myself and agree. Still open.
  2. My round-11 note 2 (V3CutsForTest exported, never used): not fixed. Still only its definition (extract_sweep_testing.go:34).
  3. The dash Provenance comment: not fixed, and now concretely incomplete. See Findings, note 1.
  4. Reviewer 2's round-10 notes 2 and 3 (re-read denominator includes drops with an empty Target; client compaction pins RereadAt): not fixed, unchanged. I re-checked both; I still agree with the author's reasoning on each.
  5. The other open notes: not fixed, unchanged. tkind()/target() still each parse the same arguments (extract_sweep_v3.go:1267, 1274); scanRereads still writes the drop records per request; a negative compaction_premium_usd still switches v3 on (line 109, != 0) while the guard reads > 0 (line 137); the ParseTable hole (a point stated without a window skips the above-window check — kept deliberately, the new test says so); the postponementPremium raw edge; the t.Skipf in TestV3GatePricesTheSavingOnNAndNotOnNPrime. None is blocking.

Findings

None blocking. What I verified beyond the rework:

  • The rebase drops nothing. The PR diff against the new base touches the same 24 files plus proxy/compactioncfg.go (which main split out of handler.go), with the same shape: 4220 insertions against 4218 before. The warm-path files (extract_sweep_warm.go and the rest) are modifications on top of main's #720, as before.
  • The dry-run and record features are intact. The last two commits are byte-identical to 59b4ddb4 and 694b5a29, which I verified in full in rounds 10 and 11. I spot-checked the dry branches at the new head (v3Dispatch, v3Apply) — unchanged.

Non-blocking

  1. The new "operator" source is missing from the enumeration comments. The rebase makes an operator-stated compaction_point a real CompactionPointSource value (it reaches components.Ctx, and ClientCeilings.Provenance can be "operator" — TestOperatorPointFeedsTheCompactEpisodeSpan asserts it). Three comments still enumerate the old set: components/component.go:685-687, apply/opts.go:56 ("measured | assumed | configured | client_default | window_fallback"), and the ClientCeilings.Provenance comment in dash/compactepisode.go — the one already open from round 8, now missing one word. The compactionPointFor comment (proxy/compactioncfg.go:134) also still says "else the bootstrap table", where the fallback is now the operator table first. One sentence each.
  2. The earlier open notes stay (see Dispositions): the cold dry-cut numbers, V3CutsForTest, the re-read denominator sentence, the double parse, the scanRereads traffic, the negative premium, ParseTable, postponementPremium, the t.Skipf.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.322 offload-review skill, @amiddavid's session resumed 2 of 2 12 of 13 9ea92771aa17 approve

Verdict: approve. The change this round is a rebase, not new work. The branch moved from the old base 62986738 to main (87b29db). All 12 commits are the reviewed v3 stack. Ten apply with byte-identical patches. Two were adapted during the rebase. I read every adapted hunk and the final code around it. I found no defect.

What I checked

  • Last review: round 11, 694b5a294eadb506e064d07d012b823e5a5ae203, 2026-11-01T09:25:22Z.
  • New commits read: 0 new commits. The head 9ea92771 is a rebase of the reviewed stack, not new work. Evidence:
    • git range-diff 62986738..694b5a29 87b29db..9ea92771: 12 commits before, 12 after. Ten map with identical patch-ids (=). Two changed (!): 64920442 (was 47e1badb, sweet spot from the effective context) and 27ef9036 (was d4cf2d5b, dash reads the operator's compaction_point).
    • The old range 694b5a29..9ea92771 lists the whole rebased stack plus main's own commits, because the two heads sit on different lines. I enumerated it and separated the two.
    • I read the full range-diff (243 lines), the final code of every adapted hunk, and the head-to-head delta of every PR-touched file that differs.
  • Read in full: 22 reviews (.review-in-reviews.txt), 12 comments (.review-in-comments.txt), 0 inline comments (.review-in-inline.txt, empty). The two items newer than my last review are listed below. The rest are unchanged since round 11, when I read them in full.
  • New items since my last review, and what I did about it:
    1. Reviewer 1's round-11 review (2026-11-01T09:26:35Z, 73 seconds after my post, so I read it only now) — approve, two non-blocking notes. Dispositions below.
    2. Author comment (2026-11-10T14:25:38Z) — box results on the final head. I checked its claims myself: the base is main, #720 is merged, the branch holds 12 v3 commits, and the final head is 9ea92771. All hold.
    3. The rebase itself — reviewed like a first review. Result below.
    4. No new inline comments.

Findings

None. What I verified in the rebase:

  • No PR hunk was silently changed. I diffed the reviewed head against the new head on every PR-touched file that differs (14 files). Every delta is main's own change, not a rewrite of a PR hunk:
    • components/offload/extract_sweep_apply.go: a doc comment on msgPrint (main's #787 note). The PR's hunks are untouched.
    • keepalive/keeper.go: the head-to-head delta is byte-identical to the base-to-base delta. Main's keep-alive work sits beside the PR's hunks; nothing of the PR moved.
    • dash/summarizeattr.go, docs/data-dependence.md, docs/components/advanced-offload.md: main's own rows and sections. The extract_llm_sweep component row, with its path-hash Decided-by line, is unchanged.
  • The dry-run, re-read and premium work from rounds 9-11 is unchanged. Those commits carry identical patch-ids, so their code is exactly what I reviewed.
  • The warm path under the PR did not regress. The old base and main each hold a version of the warm path. I checked that main's version (#720) contains the old line's round-8 fixes: the carried counters (carried_expired and friends) exist in components/offload/extract_sweep_warm.go, keepalive/keeper.go and their tests on the new base. extract_sweep_warm.go is byte-identical between the two bases. Nothing was lost in the move.
  • Commit 5 adaptation (64920442). The commit now adds only the Operator source and Resolve on top of main's Configured/ClientDefault/Recorded work, instead of redefining the Source list. internal/modelinfo keeps the compaction_point field, its validation (a point above the window is rejected; negatives are rejected) and the CompactionPoint lookup (ok=false when the entry states none). The proxy gains resolveCompactionPoint — one reader for /v1/messages and /compact, the operator's table in front of the bootstrap. The WriteFrac refactor from main is folded in correctly: the file-level cache_write_frac applies only where the match charges a cache-write premium, and prices.example.yaml leaves cache_read_frac unset so the per-model tiers apply, with a comment saying so.
  • Commit 6 adaptation (27ef9036). The dash now injects a pointFn. operatorPoint wraps modelinfo.OperatorCompactionPoint plus compactionpoint.Resolve. episodeConversationPoint and capConversationPoint keep the client-recorded row first (newest wins), then the injected point. walkCapConversation prices the limit from cpt.Tokens(w) and splits CeilingConfigured (absolute) from CeilingFrac (fraction) by source. A client's absolute number stays absolute even when the window is a stand-in, which is right: the client's own setting does not scale with our window.
  • The adapted code is consistent between the proxy and the dash. Both put the user's own client setting in front of the operator's statement.
  • Data dependence. The rebase changes no row of this PR. The extract_llm_sweep row and its approval line stand as reviewed.
  • Behavior-change rule. Nothing in this round's change decides a new behavior for an edge case. The one precedence interaction (below) comes from composing with main's already-merged #948/#963, and the code documents it.
  • I did not run builds or tests (not approved). The author reports, on the final head: make lint ok, go test ./... 48 packages ok, -race ok on the eight touched packages, mkdocs build --strict ok, and a re-run of lint and the touched packages after main moved once more (#1002). My claims come from reading the code.

Earlier findings, dispositions

Round 11 ended approve on both sides. No blocking finding is open. The author rejected nothing.

  • wa.premium written and never read (my round-9 note): FIXED in 694b5a29, still fixed at the new head. v3Apply passes wa.premium to noteDryRunCut.
  • Reviewer 1's round-11 note 1 (a cold dry cut logs passed_on_cost=false and premium_usd=0 although no gate ran): not fixed, and I agree. This is my round-11 note 1; reviewer 1 found the same thing independently. Still open, non-blocking, under-labelling only.
  • Reviewer 1's round-11 note 2 (V3CutsForTest exported and unused): not fixed, and I agree after checking. No test or non-test file calls it at the new head. V3DryRunCutsForTest, DropRecordsForTest and ResetV3ForTest are used; only this one is an orphan. Still open, non-blocking.
  • My round-10 notes 2 and 3 (the re-read denominator holds drops that can never be re-read; a client compaction pins RereadAt): not fixed, unchanged. Reviewer 1 checked both and agrees. Undercount only. Still open, non-blocking.
  • The remaining open notes are unchanged (the dash Provenance comment, the postponementPremium raw edge, the ParseTable residual hole, the negative compaction_premium_usd on-switch, the double callTarget parse, the scanRereads write volume, the t.Skipf in the pricing test). The rebase touches none of them.

Non-blocking

  • proxy/compactioncfg.go:150 — the rebase puts the operator's compaction_point behind the user's own client setting. compactionPointFor tries ClaudeCompact/BobCompact/CodexCompact first (main's #948/#963) and only then resolveCompactionPoint. On the old base no client setting existed, so this order is new to this PR's path. I believe the order is right — the user's own setting is where the client actually acts, and the dash does the same — and the code comment at compactioncfg.go:135-144 states the layering. One sentence in the PR description naming the order would let a human confirm it.

#491)

Comment lines only. No code or test change.

Assisted-By: Claude Sonnet 5.5
Signed-off-by: DAVID AMID <[email protected]>
Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Merged origin/main (b329371) into this branch: d4fc4b2.

  • Remerge-diff: empty. No conflicts, no hand edits.
  • Semantic check: v3 reads no prefix floor of its own, so it agrees with fix(keepalive): choose the keep-alive prefix floor by wait cause #1040 (floor by wait cause). go vet ./... clean.
  • Tests (box, -race): apply, components, internal, keepalive, deploy ok. dash and proxy ok (both halves each).
  • CI: first run failed on the timing test TestALateFirstByteOnTheRealTransportNeverReachesTheClient (15 ms limit, CI load). It passed on the box. The rerun of the failed job passed. CodeQL and Docs green.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant