Repository navigation
feat(sweep): ask at the keep-alive ping, hold the answer, recheck, shadow mode - #508
Conversation
ff28d02 to
6632593
Compare
Review round 1 of 3VerdictBlocking. 1 blocking finding. The design matches the agreed decisions. H1 holds by code reading and by tests. One fail-open gap can crash the proxy. What I ranSynced head 6632593 to the eval box (
Blocking findings1. A panic in the ping-time question crashes the proxy.
What I checked and found correct
Non-blocking
|
6632593 to
101e62b
Compare
The sweep removal is temporary (restore with #508). Undo the docs and plugin text edits. Keep the two config changes and the test. Add a short comment at each of the two places. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]>
fix(config): turn the sweep off in the xhigh preset for 0.5.3 xhigh no longer runs extract_llm_sweep. In 0.5.3 it is the same as high. The sweep is still under work (#508) and returns to xhigh when #508 lands. The name xhigh still loads. extract_llm_sweep stays registered, and housellm keeps it. Update the preset comments, docs, README, and the plugin texts that said xhigh adds the sweep. Add a test that xhigh has no sweep and equals high. Closes #652 Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]> fix(config): limit the xhigh change to config only The sweep removal is temporary (restore with #508). Undo the docs and plugin text edits. Keep the two config changes and the test. Add a short comment at each of the two places. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]> fix(config): keep the two preset-list guards green for xhigh TestPresetDocsDoNotDrift and TestPluginPresetPipelinesAgreeWithConfig compare the xhigh pipeline in docs/reference/presets.md and insights.py with config.go. Change only those two lists. No prose changes. Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]> style(config): gofmt the xhigh preset entry Assisted-By: Claude Signed-off-by: DAVID AMID <[email protected]>
101e62b to
b1f4262
Compare
b1f4262 to
cea7b42
Compare
cea7b42 to
0211b4d
Compare
amiddavid
left a comment
There was a problem hiding this comment.
| Who | Backend | How this review was produced | Context | Reviewer | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.309 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 0211b4dc9953 |
blocking |
Verdict: blocking
Findings
1. The PR changes the sweep's data dependence, and docs/data-dependence.md does not say so
What fails. CLAUDE.md makes data dependence a hard boundary: every PR that adds or changes a feature states its data dependence, updates docs/data-dependence.md, and states a change in either direction at the top of the PR, with the row's "Decided by" confirmation. This PR changes the sweep's data dependence in three ways and does none of that:
- Two new full conversation copies per registered thread, in memory.
registerPing(components/offload/extract_sweep_ping.go:228) copies the whole conversation twice —cand.input(the pipeline view) andcand.raw(c.RawInput) — and holds both for up to 30 minutes, over at most 256 threads, with no byte bound. The copies are taken on every request where the sweep runs, before anything decides whether keep-alive will ever ping this thread. - A new pinned store namespace.
cg:swh:(store/store.go, added toDefaultPinPrefixes) holds one full adjudication answer per thread, and pinning means the LRU cannot evict it. - The old dependence is gone. The sweep no longer writes its removals to
cg:res:for replay. Row 198 ofdocs/data-dependence.mdsays the sweep's storage is "its removals … the originals, and 'still needed' answers" and that it "pays full price to send parts of up to 12 outputs". After this PR that row describes behavior that no longer exists. Row 216 ("Body stash … 2 full bodies per thread") now under-counts: the sweep registry adds two more copies per thread that the row does not know about.
The PR body does not state the data-dependence change at the top, and no row's "Decided by" confirmed it.
Proof.
git diff 1953b47..HEAD -- docs/data-dependence.mdis empty — the file is unchanged.registerPingcopiesinputandrawunconditionally from the Offload path (defer e.registerPinginOffload), gated only by the candidate registry's size and age, not by the keep-alive policy: a thread whose policy hasKeepAlive: falsestill pays the copies.TestNoKeepAliveNoQuestionproves the question is skipped, not the registration.- Row 198 (
docs/data-dependence.md:198) and row 216 (:216) both still describe the pre-#404 sweep.
Fix. Update docs/data-dependence.md: rewrite the extract_llm_sweep row for the ping-time question, the held answer in cg:swh:, and the in-memory conversation copies; correct the body-stash row's per-thread count. State the change at the top of the PR body, and get the row's "Decided by" confirmation before merge.
2. The pre-collection concurrency bound does not bound collection
What fails. The check at components/offload/extract_sweep_ping.go:351 reads len(sweepSlots) >= cap(sweepSlots) before collect() runs, and its comment says the bound is "BEFORE the work: collection hashes every output and runs the co-reference index, and with many threads due at once it would run unbounded". The bound does not hold. The slot is only taken later, inside ask (:440), as a non-blocking send. Between the length check and the send there is no synchronization, and the keeper dispatches every due ping at once: Sweep starts one goroutine per due job (keepalive/keeper.go:1168-1171), and fire releases the tenant's spare slot before it calls the substitutes (:1242), so nothing else limits how many run together.
So on one keeper tick with N due threads, all N goroutines can read len(sweepSlots) == 0, all N pass the check, and all N run collect() — per-output content-key hashing plus a co-reference index pass over the whole conversation, on full conversation copies, for each of N threads at the same time. Only the model call is bounded to 4. With shadow mode on and a busy proxy, this is an unbounded CPU and allocation burst on the keeper's tick, exactly what the comment says cannot happen. Fail-open holds — a thread that loses the race still gets its plain ping — so nothing breaks correctness; the defect is that the stated safety property is not enforced, and the test (TestTheConcurrencyBoundIsCheckedBeforeCollection) only covers the sequential case, so it cannot catch it.
Proof.
extract_sweep_ping.go:349-353: the check is a plainlen()on the channel;sweepSlots(:196) is a buffered channel of 4, filled only by the non-blocking send insideask(:440+), which runs aftercollect()has already finished.keepalive/keeper.go:1168-1171:for _, j := range due { k.o.Go(func() { k.fire(j) }) }— all due jobs start at once, with no concurrency limit of their own.keepalive/keeper.go:1242:release()drops the spare slot beforefireSweepSubstitute, so the tenant limiter does not bound it either.
Fix. Take the slot before collect(), not after: acquire sweepSlots (non-blocking) at the top of the dispatch path, and release it when the ask declines or errors. Then len()-style admission is unnecessary and the bound is real. Alternatively bound collection with its own semaphore and leave the ask's slot as is — but then say so in the comment.
Non-blocking
- Registry memory. The two conversation copies per thread (256 threads, 30 min, no byte cap) follow the pattern
registerKeepAliveCandidatealready set for the summarizer, and the PR's Technical notes acknowledge the cost. It still doubles the per-thread footprint. Worth a byte bound in a follow-up. Ask.Addoverwrites caller-set labels (internal/extract/ask.go:88).adjudicateWithpasses items withLabel: kalready set;Addreassigns. Harmless with one list, because the items are matched by label after the fact. A second list (#490, #485) that reads labels beforeAddwould be surprised. A doc line onCandidates()("Label unset") already exists; the caller ignoring it is the nit.markHeldReportedget-then-put race. Two concurrent cold requests for one thread can both readReported == falseand both emit the shadow report. The store is keyed per thread, so one wins the final write. Double-counted metrics only; shadow mode is diagnostic.shadowStepcould setReportedunder a mutex or CAS-style.- The ask's timeout is effectively
minof the passed timeout andllmCallTimeoutinsideadjudicateWith. The keeper passesCacheAwareSummarizerCallTimeout()(300 s); the inner cap may end the question earlier and report it as failed. Fail-open holds. Worth a comment so the two constants do not drift apart silently.
What I checked
- The full diff of all 48 files against
1953b47c, including every deleted test and the new test files, plus the code around each change. - The ping-time stale-prefix guard.
registerPingsnapshots withMaxCachedIdx: len(req.Input)-1;PrefixCoveredAsker.AskCoveredre-checks coverage on the same stash read, closing the check-then-ask race. A new request between registration and the ping makes the ask decline withErrStalePrefixand the ping go out plain. Sound. cg:swh:versuscg:res:. The replay loop reads onlygetResulthits incg:res:; held answers live incg:swh:and are never replayed.TestAHeldAnswerChangesNoRequestpins the byte-identity claim, andTestH1EveryRequestAfterAnAnswerIsByteIdenticalToTheSweepOffchecks it over four growing requests and three cache phases. Sound.- Recheck reasons (
conversation_shorter,output_gone,content_changed,referenced_later,expanded): each verified against the code, including theIdx + ConsumeLag >= Judgedreference math and the raw-coordinate hash fromrawSpanForHash. Sound. - Fail-open at every level. Panic recovery at the substitute, the dispatch closure, and
fireSweepSubstitute; every "no" (no shadow, already asked, model declines, over budget, no inventory, concurrency, ask error, panic) falls through to the ordinary ping. Tests cover each. Sound. askedlifecycle. CAS before the call; reset only when nothing left the process; left set on panic so the next ping is plain. Sound.- Registry cleanup.
ClearKeepAliveCandidate/ClearStaleKeepAliveCandidateclear the sweep registration on retire, evict, shutdown, forget, and stale-entry paths. Sound. - Bookkeeping.
recordSubstitutePingcounts a substituted question once as the ping; deferred billing reuses the #455 mechanism idempotently;recordSweepKeepstill writes the keep cache thatadmitreads at ping time. Sound. - Config. Retired keys (
econ_trigger,econ_ignore_ask_cost,reward_premium,min_pressure,block_fallback,pre_expiry_seconds) are stripped with a warning and counted; banned keys still fail the load; the housellm preset keepsmin_tokens: 1000and gains theevidence: truedefault, which the PR intends;shadowis in no preset.TestRecordedBenchmarkConfigsWithRetiredSweepKeysStillLoadcovers old configs. - Wiring.
proxy/keepalive.gopassesToolUseNamesandOpenTasks;waitcause.OpenCountsfails open on panic;ClassifyWaitingFor's call signature matches;sweep_ask_needs_shadowandsweep_ping_panicsreach/stats. - Docs.
docs/components/advanced-offload.mdmatches the new behavior (trigger, hold, recheck, shadow counters, retired keys, config table).docs/data-dependence.mddoes not — finding 1. - No tests were run (live tests not approved for this review); every claim above is from reading the diff and the surrounding code.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.309 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 0211b4dc9953 |
blocking |
Verdict: blocking
Findings
-
components/offload/extract_sweep_ping.go:419 — the sweep's cache hit-rate now always reads 100%
- What fails: after this PR,
extract_llm_sweeprecords no missed result-cache lookup. The only remaining call is the replay hit (extract_sweep.go:545). Socache_hit_ratefor this component (metrics/extract.go:507) is hits over hits, always 1.0. An operator reading/statssees a perfect hit rate that no run produced. - Proof: the base recorded one miss per non-hit candidate while collecting (base extract_sweep.go:822,
metrics.RecordExtractionCacheLookup(rep.Component, false)). This PR moved collection to the ping. The ping'scollectstill does the lookup —c.Store.Get(resultKey(c.Session, id))at extract_sweep_ping.go:419 — but records no metric. Grep over the worktree: the sweep's only call left is the hit;extract_llmstill records both sides (extract_llm.go:1045). - Fix: record the miss in
collect, next to thegetResultcheck.
- What fails: after this PR,
-
components/offload/extract_sweep_ping.go:351 — a question refused for a full concurrency bound is invisible in
/stats- What fails: when all 4 slots are busy,
SweepPingSubstitutereturnsconcurrency_fulland no counter moves. The keeper logs it at Debug only (keepalive/substitute.go:291). The Stats block this PR adds has no field for it. - Proof: every sibling reason increments a counter at its return —
sweepPingNoCandidate(:336),sweepPingNeedsShadow(:342),sweepPingAlreadyAsked(:346),sweepPingModelDeclined(:356),sweepPingNoInventory(:367, :371). The summary substitute counts the same refusal (summarySubstituteConcurrencyFull, keepalive/substitute.go:143). The sweep path has no equivalent. - Fix: count it as the summary path does. Add a
sweep_concurrency_fullcounter toSweepPingCounters()or the keeper Stats.
- What fails: when all 4 slots are busy,
-
docs/components/advanced-offload.md:242 — the doc says an in-request ask remains, and lists seven counters that no longer exist
- What fails: two stale blocks.
- Lines 240-242: "
econ_trigger... is off by default and is the only in-request ask that remains." False. This PR removes every in-request ask.Offloadonly replays frozen decisions, andTestSweepAsksNothingInsideARequestByDefaultpins zero asks in a request. - Lines 554-566: the diagnostics list still names
sweep_fallback_used,sweep_fallback_blocked,sweep_fallback_failed,sweep_fallback_no_model,sweep_inventory_below_min,econ_ask_not_repaid,prefix_rewrite_not_repaid. Lines 568-569 then tell the operator to read the last two as a pair.
- Lines 240-242: "
- Proof: grep for each of the seven names over
components/, tests excluded: zero producers. The blockquote at lines 233-238 says the keys are gone and ignored. The two blocks contradict each other in one file. - Fix: delete the "remains" sentence and the seven dead names, or mark them as history the way the #491 blockquote does.
- What fails: two stale blocks.
Non-blocking
- Comment rot names removed machinery. extract_sweep.go:642-646 explains the named result by a
defer foldFallback()that no longer exists. Lines 906-930 describe the removed FALL BACK /block_fallback: truechoice, above code that now always declines. Line 1004 citessweepIntent. extract_sweep_test.go:214-221 still explains the fallback model andeffectiveBlockFallback. summarize.go:407 contrasts against the sweep'snot_in_pre_expiry_windowgate, which this PR removes. - extract_sweep_recheck.go:127 —
r.Idx + r.ConsumeLag >= h.Judgedcompares positions on the cold request against the judged length. Messages inserted above a pre-question reference can misfile it asreferenced_later. The error keeps content, so it is fail-safe. - The ping registry is bounded by thread count (256), not bytes. Each entry holds a copy of the conversation. The keep-alive registry uses the same convention (2048 bodies), so this is consistent.
- advanced-offload.md:227 lists
retryamong the stored wait causes. A failed response never establishes a keeper entry (keeper.go:665 refuses non-2xx), soretrycannot be stored. Harmless.
What I checked
- The full diff, 48 files,
1953b47c..0211b4dc. All four new sweep files in full: extract_sweep_ping.go, extract_sweep_hold.go, extract_sweep_recheck.go, extract_sweep_shadow.go. Also internal/extract/ask.go, keepalive/keeper.go, keepalive/substitute.go, internal/waitcause, proxy/keepalive.go, store/store.go, and the rewritten docs. - Fail-open. Every "no" at the ping leaves the ordinary ping. Panics are recovered at three levels:
SweepPingSubstitute,ask, andfireSweepSubstitute. The in-request loop only replays frozen decisions. Tests pin that a held answer changes no request, across cache phases, and that nothing falls back to a full-price completion. - Namespace separation. Held answers live under pinned
cg:swh:. Nothing replays them. TheSpenttombstone stands in for the store's missing Delete. - Thread keys. Every keeper and lifecycle caller passes
thread.Key(session, thread). The keep-alive clearers also clear the ping registry.TestRegistrationIsClearedByTheKeepAliveClearerspins it. - Retired keys. Each is ignored with one warning and a counter, and the config still loads (
TestRetiredKeysLoadWarnAndChangeNothing). Banned keys are still refused.shadow: trueis absent from the shipped presets. - internal/extract/ask.go. A one-list
Prompt()equalsBuildPrefixAskbyte for byte; the test pins it. - The reworked tests: the
askOffloadhelper, the ping, recheck, evidence, keeper and proxy test files, and every deleted econ, fallback and commitgate test. - A grep for every symbol the PR removed (
askLedger,econDecision,foldFallback,runFallback,fallbackAsk, and the rest). No live reference remains. Only comments name them. - Not run: Go builds and tests. Live tests were not approved for this review.
…adow mode Part A of #404 (the cold path). The sweep asks its question in place of the keep-alive ping and holds the answer per thread. Nothing applies a held answer yet: it changes no request. - Ask at the ping, no timer of its own. The time-window trigger and pre_expiry_seconds are removed (the key is refused with the reason). - Ask with one candidate or more. min_inventory defaults to 1. - Hold per thread in the Store (cg:swh:, pinned), with tool_use_id and a SpanHash of the agent's message for each judged output, the judged length and the wait cause (#453). Stored only; nothing decides on it. - recheckHeld drops a verdict when the conversation is shorter, the output is gone or changed, a later turn referenced it (coref), or the agent expanded it. PR C calls it on the cold request. - shadow: true (off, in no preset) reports asked, proposed, still valid at the cold request, and the reasons, as request_components events and a cg.sweep.shadow log line. - evidence is on by default. - Plain ping, counted as sweep_model_declined, where the question breaks the cache (#422). - Ask only when shadow is on, until the cold apply exists (PR C). Counted as sweep_ask_needs_shadow. - Remove econ_trigger, the in-request ask and the full-price fallback. The keys econ_trigger, econ_ignore_ask_cost, reward_premium, min_pressure and block_fallback are ignored with a warning and a count, so an old config still loads. - extract.Ask composes the question from lists, so #490 and #485 can add theirs. An output in two lists is judged once. - Recover from a panic in the ping question: the ping stays plain, the panic is counted, and the next ping is plain too. Check the concurrency bound before collecting candidates. - Rebased onto #507. Point 11 now uses askStripsThinkingShipped. The keeper changes live in package keepalive (main moved the keeper there); the wait cause reaches it through Options.OpenTasks and Record.ToolUseNames. The question is framed with the shared opening line (resolveAsk.Frame) and asked through AskCovered when the asker supports it. - Review round 1: keep the conversation copies only for a thread the keep-alive can ping (Ctx.CanKeepAlive). Take the collection slot before collecting and release it on every exit. Count the result-cache miss in collect, and count sweep_concurrency_full. Report the shadow ask and the cold recheck once, under a mutex. Rewrite the sweep rows of docs/data-dependence.md and drop the stale counters and prose from advanced-offload.md. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
0211b4d to
173180d
Compare
Round 1 replies (head 0211b4d, fixed in 173180d)Reviewer 1
Reviewer 2
VerificationBox 1, foreground, |
) The ping-time question and the held answer in cg:swh: (metadata only) are approved, with the two in-memory conversation copies per thread kept only while the keep-alive can ping the thread, for at most 256 threads and 30 minutes. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 308425f17442 |
approve |
Verdict: approve
Round-1 findings
My finding 1 (data dependence): fixed.
docs/data-dependence.mdis rewritten. Theextract_llm_sweeprow now states the held answer (cg:swh:, pinned, metadata: ids, hashes, counts, verdicts, no text), the two in-memory conversation copies (30 minutes, 256 threads, only where the keep-alive can ping), and thatcg:res:removals are no longer written. The "Body stash" row, the audit lists, the summary counts and the "storage off" list all match the new behavior.- The PR body now opens with a "Data dependence change" section that states the change and the approval.
- The row's owner confirmed it: commit
308425f1is authored and signed off by DAVID AMID and records "ping-time question and held answer approved 2026-10-25 (#508)" in the row. - The registration is also narrower now:
registerPingkeeps a copy only whenc.CanKeepAlive()says the host's keep-alive can ping the thread (newcomponents.Ctx.CanKeepAlive, wired fromkeeper.canPingthroughapply.Optson both the chat and the responses path). A host with no hook keeps nothing.TestWithKeepAliveOffNothingIsRegisteredandTestCanPingFollowsTheKeepAlivePolicypin it.
My finding 2 (concurrency bound): fixed.
- The slot is now a non-blocking send taken before
collect()(extract_sweep_ping.go:364-372), released by adeferon every exit — a decline, an error, a panic, or the hand-off to the dispatch closure. The defer is registered after the panic-recover defer, so on a panic the slot is released before the recover runs. A keeper that declines afterok(the cost ceiling) and never calls dispatch holds no slot. TestCollectionRunsAtMostSlotsAtOncestarts 16 goroutines behind a barrier and checkscollectPeak <= cap(sweepSlots)and that no slot leaks;TestACollectionSlotIsReleasedWhenDispatchIsNeverCalledcovers the never-dispatched case. The look-then-take race is gone.
My non-blocking items: the markHeldReported race is fixed (claimHeldReport/claimHeldSpend under heldMu, with tests on a store that sleeps after Get); the two-timeouts comment is in ask; the registry byte bound is deferred to PR C and stated in the PR body; the Ask.Add label point is rejected with a reason I checked and accept — Candidates() documents "Label unset", and one label sequence across lists is the design.
Reviewer 2's findings — agree, and checked myself: all three fixed. The miss is recorded in collect (metrics.RecordExtractionCacheLookup(rep.Component, false), with TestCollectionRecordsTheResultCacheMiss); sweep_concurrency_full and sweep_not_registered are counted and reach /stats through SweepPingCounters() and the keeper Stats; the stale doc blocks ("the only in-request ask that remains", the seven dead counter names, the "read as a pair" text) are gone from advanced-offload.md, and the benchmark-era enabling section now shows shadow: true. Their comment-rot and retry items are fixed too; the referenced_later misfile stays by the author's reasoning, which matches reviewer 2's own note that it is fail-safe.
Findings
None.
Non-blocking
ask'sputHeldis not serialized with the claims (extract_sweep_ping.go:561writescg:swh:on the keeper's goroutine;claimHeldReport/claimHeldSpenddo their get-then-put underheldMu, but the producer is outside that mutex). A claim that reads the old answer can overwrite a fresh answer written by a concurrent ask. Two overlapping asks for one thread (an old candidate's ask still in flight when a newer one runs) can also land out of order, andputHeldhas noAskedAtMscomparison. In this PR the harm is bounded: a held answer changes no request, so the loss is shadow metrics and one wasted paid answer, and the next ping asks afresh. Fix before PR C makes the answer load-bearing: takeheldMuinputHeld, or refuse to overwrite a strictly newerAskedAtMs.spendHeldis now dead code (extract_sweep_hold.go:125) —claimHeldSpendreplaced its only caller. Delete it, or note it as the PR C seam.- The
Anthropic-Betaheader gap onCompletePrefixedstays open. The PR body lists it under Open questions with A5 covering it. Agreed as non-blocking.
What I checked
- Last review: round 1,
0211b4dc9953dccf50a77256c0e0b99021056e42, 2026-10-25T09:43:12Z. - New commits read: 2 —
173180de"feat(sweep): ask at the keep-alive ping, hold the answer, recheck, shadow mode" (the feature commit, rewritten in place: same parent1953b47c, different tree) and308425f1"docs(data-dependence): record David's approval of the sweep change". The full new change isgit diff 0211b4dc..308425f1: 20 files, +494/−153, read in full, plus the code around each change. - Read in full: 2 reviews, 2 comments, 0 inline comments (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt), plus the PR body in full. - New items since my last review, and what I did about each:
- Reviewer 2's round-1 review: read in full; re-verified each of their three findings against the code before accepting the fixes (see above).
- The author's reply comment (2026-10-25T10:43:08Z): checked every claim — the doc rewrite, the
CanKeepAlivegate and its wiring, the slot fix and its two tests, the miss metric, the two new counters, the doc cleanups, the claim-based report and spend with their slow-store tests, and the timeout comment. All match the code. - The rewritten feature commit and the approval commit: read the full diff and the commit message; confirmed the approval commit is authored and signed by the row's "Decided by" owner.
- The older comment of 2026-10-13 (review round 1 of 3, head
6632593): read in full. Its blocking panic finding and items B, C, D, E are fixed in code I verified in round 1 and re-checked here where the round-2 diff touched them; item A (the header gap) is the open question above; item F (applySweepDropReplaystill readingcg:res:) is stated in the PR body as PR C work, and onlyextract_llmwrites that namespace now.
- The slot fix in detail: send-before-collect, defer-release, LIFO order against the panic-recover defer, and the dispatch closure taking its own slot in
askafter the outer one is released. No leak path found. canPingin the proxy: kill switch, audit sink, OpenAI exclusion, empty session, and the resolved policy without a campaign decision — the conservative direction is documented and tested.canKeepAliveForrecovers a panic in the hook to "cannot", so a broken host hook keeps nothing rather than failing the request.- The claim fixes:
heldMuserializes the two claims against each other; both tests use a store that widens the get-then-put window, so a non-atomic claim would fail deterministically. The producer-side gap is the non-blocking note above. - The doc updates (
advanced-offload.md,data-dependence.md) against the code: counter names (sweep_concurrency_full,sweep_not_registered,sweep_stale_prefix), the removedretrywait cause (a failed response never establishes a keeper entry, andsweepWaitCausepassesfailed=false), the level columns, and the audit lists. They match. - No tests were run (live tests not approved); every claim above is from reading the diff and the surrounding code.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 308425f17442 |
approve |
Verdict: approve
Findings
None.
Earlier findings, and their state
Mine, round 1:
- Cache hit-rate always 100% — fixed.
collectnow records the miss (extract_sweep_ping.go:463), where the old in-request loop recorded it. Test:TestCollectionRecordsTheResultCacheMiss.rep.Componentis set, so the miss lands on the right component. concurrency_fullinvisible — fixed.sweep_concurrency_fullis inSweepPingCounters()and the keeper Stats. Test:TestAConcurrencyRefusalIsCounted. The author also made the bound real: the slot is taken with a non-blocking send, not looked at.- Stale docs — fixed. The "only in-request ask that remains" sentence, the seven dead counter names and the "read as a pair" text are gone. The enabling section no longer tells an operator to set
econ_trigger.retryis now marked as impossible, with the reason.
Reviewer 1, round 1:
- Data dependence — fixed. I checked the rewritten
docs/data-dependence.mdrow against the code:cg:swh:pinned, ids, hashes, counts and verdicts only; two in-memory conversation copies, gated byCanKeepAlive, 30 minutes, 256 threads.registerPingkeeps nothing for a thread the keeper cannot ping. David Amid's approval is commit308425f1. - The concurrency bound did not bound — fixed. Agree with reviewer 1. The slot is taken before
collectand released on every exit.TestCollectionRunsAtMostSlotsAtOnce(16 goroutines behind a barrier) and the slot-leak test cover it.
Non-blocking, both rounds: comment rot fixed in every file I named. The report and spend races fixed with claimHeldReport/claimHeldSpend. The two-deadlines comment added. The author rejected the Ask.Add relabel point: the reason is right — labels are one sequence across lists by design, and Candidates() documents it. The registry byte bound is deferred to PR C and recorded in data-dependence.md item 5. The referenced_later misfile stays: it is fail-safe and keeps content.
The comment of 2026-10-13 (head 6632593, before my round 1): its panic finding was already fixed at my round-1 head, and the three recover levels are still there. Its items C and D are fixed in 173180de. Item F (applySweepDropReplay reads cg:res:) is deferred to PR C. Item A (beta-header gap) is pre-existing and shared with the summarizer; it is not this diff.
The new code, checked as a first review
- The
CanKeepAlivehook. nil means "cannot", so a library caller keeps nothing — the safe direction. A panic in the hook reads "cannot".canPingfollows the kill switch, the audit sink, the provider and the resolved policy. A learned campaign that would turn on later reads "cannot": the safe direction, nothing extra is kept. I checkedresolvePolicywith a zeropredDecision: the campaign branch is skipped, so no misleading state. - The slot change. The release defer is registered after the panic recover, so on a panic the slot is released first (LIFO) and the recover still runs. The slot covers collection only;
asktakes its own. No leak when the keeper refuses at the cost ceiling and never calls dispatch. - The claims.
claimHeldReportandclaimHeldSpenddo the read-check-write under one mutex.getHeldrejects spent records, so the tombstone stands. The winner of the spend keeps the answer it read, with its outputs. The tests use a store that sleeps afterGet, so a non-atomic claim fails every time. - The counters. Every name the rewritten docs list has a producer or a Stats JSON tag. I checked each name by grep.
- Fail open, re-checked. Every new "no" (no hook, hook says no, slot full, claim lost) leaves the request untouched and the ping plain.
Non-blocking
spendHeld(extract_sweep_hold.go:125) has no caller after the claim refactor. Dead code;claimHeldSpendcarries its body.- The ask-level slot refusal (extract_sweep_ping.go:490) counts under
sweep_ask_failed, notsweep_concurrency_full. The docs sentence names only the pre-collection refusal. Both paths leave a plain ping. - The docs say "Counted at the ping" for
sweep_not_registered. A request counts it, inregisterPing. Only the publication block is the keep-alive's. claimHeldSpendmarks the answer spent beforerecheckHeldruns. A panic in the recheck then loses the report. Content is untouched, so this is fail-safe.
What I checked
- Last review: round 1,
0211b4dc9953dccf50a77256c0e0b99021056e42, 2026-10-25T09:43:49Z. - New commits read: 2 —
173180de"feat(sweep): ask at the keep-alive ping, hold the answer, recheck, shadow mode" and308425f1"docs(data-dependence): record David's approval of the sweep change (#508)". The branch was force-pushed:0211b4dcis no longer on it, and173180dere-authors the round-1 commit with the fixes folded in. So I read the tree diff0211b4dc..HEADin full: 1105 lines, 20 files. Anything silently dropped between the two heads would show there as a deletion. - Read in full: 2 reviews, 2 comments, 0 inline comments (from the three saved files).
- New items since my last review:
- The author's reply comment, 2026-10-25T10:43:08Z. Read; every claim in it checked against the code above.
- Commit
173180de. The fixes for both reviews; reviewed as a first review. - Commit
308425f1. The data-dependence row and the approval; checked againstheldAnswer,registerPingand the registry bounds.
- The changed files around each change: extract_sweep_ping.go (
registerPing,SweepPingSubstitute,collect,ask), extract_sweep_hold.go (the claims), extract_sweep_shadow.go (in full), apply/apply.go, apply/opts.go, apply/responses.go, components/component.go, proxy/keepalive.go (canPing,resolvePolicy), proxy/modes.go, keepalive/keeper.go (Stats), and every new test in the diff. - Not run: Go builds and tests. Live tests were not approved for this review. The author's comment reports full suites and
-raceruns on the box; I did not verify them.
Main added #691 and #692. The only conflict was docs/data-dependence.md: #691 added three sentences to the end of the "Keep-alive pings" row, and this branch edits the "Body stash" row next to it. Main's keep-alive row is kept as it is, and so is this branch's Body stash row. Also, in the same commit, two small round-2 fixes: - Delete spendHeld, which has no caller since the claim replaced it. - Say that sweep_not_registered is counted at the request, not at a ping. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 3 of 3 | 8f0698394a37 |
approve |
Verdict: approve
Findings
None.
Earlier findings, and their state
Mine, round 1 and round 2: all fixed, and nothing in the new commits touches the fixes. The miss metric, the sweep_concurrency_full counter, the docs rewrite, the slot-before-collect, the claims, the CanKeepAlive gate — all still in place at this head.
My round-2 non-blocking items:
- Dead
spendHeld— fixed. The merge commit deletes it. A grep over every Go directory finds no reference left.claimHeldSpend(extract_sweep_hold.go:126) carries the tombstone body. sweep_not_registeredwording — fixed.advanced-offload.mdnow says it is counted at the request, not at a ping. This matchesregisterPing, where the counter moves.- Ask-level slot refusal counts under
sweep_ask_failed— not addressed. Still fail-safe: both paths leave a plain ping. Agreed with reviewer 1. claimHeldSpendmarks the answer spent beforerecheckHeldruns — not addressed. A panic in the recheck loses the report only. Content is untouched. Fail-safe.
Reviewer 1's round-2 non-blocking items: the putHeld producer race is not addressed, and I agree it stays non-blocking here. A held answer changes no request in this PR. The loss is one shadow metric and one wasted paid answer. The next ping asks afresh. I add my voice to the warning: PR C must not build the cold apply on this seam. Take heldMu in putHeld, or refuse to overwrite a newer AskedAtMs, before any code reads a held answer to change a request. The Anthropic-Beta header gap stays the PR body's open question, under A5.
The new commit, checked as a first review
The branch moved by one merge, 8f069839. It brings in main's 86c118ba (#691, the plugin's Ping-header self-heal) and caac0b81 (#692, the dash ping-saving window), and folds in the two fixes above. I read the full tree diff 308425f1..HEAD: 1418 lines, 23 files.
- The merge keeps both sides intact. I ran the two checks myself.
git diff 86c118ba..HEADoverdash/,context-guru-plugin/andcodex-marketplace/is empty, so #691 and #692 landed unchanged.git diff 308425f1..HEADover every Go directory of this PR is the 8-linespendHelddeletion only. - The conflict resolution is right. The one conflict was
docs/data-dependence.md. The merged file keeps main's keep-alive row with the three self-heal sentences (:216) and this branch's Body stash row with the sweep's two-extra-copies note (:217). Nothing was dropped from either side. - No semantic conflict with this PR. #692 changes dash read queries (
kaSavedSincefloors a ping's credit at the window start). The sweep writes no dash query and no ledger field they touch. #691 changes plugin install scripts and the manual Ping button's hold. The sweep's gate isCanKeepAlive, which followskeeper.canPing— the kill switch, the audit sink, the provider and the resolved policy — not thex-context-guru-pingheader. A thread held for the button only keeps no sweep conversation copy unless the keeper can also ping it. The safe direction. - The folded docs fix reads well in place. The "Counted at the ping" paragraph now names
sweep_concurrency_full,sweep_ping_panics,sweep_model_declinedandsweep_ask_needs_shadow, and movessweep_not_registeredto its own request-counted sentence. Each name has a producer or a Stats JSON tag.
Non-blocking
- The
putHeldproducer race, stated above: fix it before PR C makes the held answer load-bearing. - The ask-level slot refusal still counts under
sweep_ask_failed, notsweep_concurrency_full. Both leave a plain ping. claimHeldSpendstill consumes before the recheck runs. A panic there loses the report, not content.
What I checked
- Last review: round 2,
308425f174428909b83fbb48727d6ed3fe134d88, 2026-10-25T10:58:10Z. - New commits read: 1 —
8f069839"Merge origin/main into feat/sweep-cold-ask" (parents308425f1and86c118ba; brings #691 and #692 from main, resolves one conflict indocs/data-dependence.md, and folds in the two round-2 fixes). The full tree diff308425f1..HEAD, 1418 lines over 23 files, was read in full, plus the code around each change:extract_sweep_hold.go,extract_sweep_shadow.go, the merged doc rows, and the #691/#692 files at the level needed to rule out interaction. - Read in full: 5 reviews, 2 comments, 0 inline comments (from
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review, and what I did about each:
- Reviewer 1's round-3 review (2026-10-25T11:27:49Z, approve): read in full. Their dispositions match mine. Their two merge checks I re-ran myself rather than trusting.
- The merge commit: read the message, the stat, the full diff, and verified both parents' sides are intact in the tree.
- No new issue comments arrived since the author's reply of 2026-10-25T10:43:08Z. The two comments on the PR are unchanged since round 2; I read them in full again.
- Not run: Go builds and tests. Live tests were not approved for this review.
…ed run (#697) fix(review): stop a reviewer that never ends, and never resume a failed run On #507 a GLM reviewer repeated one word up to the 32k output limit, 4 turns in a row, about 21 minutes each. Nothing stopped it, and a later round would have resumed that same session. - Each reviewer run now has a wall-clock limit, OFFLOAD_REVIEW_TIMEOUT (default 1800 s, 0 = off). Past it, the script stops the run's whole process group and falls back to the next backend, unless the review is already on the PR. It does not limit tokens. - A run that ends without posting drops its saved session (backend_forget_session, or backend_cleanup), so the next round starts fresh. - Any .review-in-*.txt in a reviewer's own folder is allowed. A reviewer that also saved the PR body (.review-in-prbody.txt, #508) made the round exit 1 although both reviews posted. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]> fix(review): forget a session only after the backend ran Round-1 review fixes for #697. - Forget a saved session only when the backend started. A failure before it (worktree lock, prompt) keeps the session for the next round. - Check OFFLOAD_REVIEW_TIMEOUT once at startup, before any worktree exists. - Mark a stopped run with a file, not exit code 124. A backend that exits 124 by itself is no longer labelled a timeout. - Append to review.log, so an earlier diagnostic stays. - claude: forgetting a session also removes its transcript. - Fix the function counts in the backend headers and SKILL.md. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
… what it earns The sweep asked at the keep-alive ping and held the answer, and nothing used it. This change applies it. The sweep now saves money. - Cold apply (point 3): on the next cold request of a thread, rechecks the held answer and replaces each valid output with a shape descriptor and a <<cg:HASH>> marker. The original is stashed, so expand returns it byte for byte. Each drop writes a record (cg:swd:), and every later request of the thread replays the same bytes. A warm request with an unchanged conversation never changes (H1). - Changed prefix (point 4): a rewind, an edited turn or a fork applies only the held drops after the first changed message. The ones before it stay held. Counted apart as sweep_applied_changed_prefix. - Fail open: a store that cannot hold an original refuses that drop. A panic in the apply restores every message it touched, writes no record, and forwards the request unchanged. - Dashboard (point 9): the answer cost is booked once, on the ping row the question replaced, in its own column (sweep_answer_usd). The expands of sweep markers come off the sweep's credit at the write rate. - Quality signals (point 7): an expand of a sweep marker is charged to the sweep, and a later turn that uses something a dropped output introduced counts as a false drop. False-drop rate per thread and overall, in the Components tab and in /stats (keepalive.sweep_drops). Ids, hashes and counts only. - The ping carries the forwarded body after a cold apply (point 15), by test. - The shadow-only ask gate is gone. shadow stays a setting and applies nothing. - xhigh runs the sweep again. The other presets are unchanged. - From the #508 notes: registerPing no longer keeps a conversation copy for a thread with no candidate and prunes on every registration (D); the sweep reads its own cg:swd: record, not cg:res: (F); BuildFallbackAsk and the sweep-only pricing in prefix_econ.go are removed (coref keeps what it uses). Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
… what it earns The sweep asked at the keep-alive ping and held the answer, and nothing used it. This change applies it. The sweep now saves money. - Cold apply (point 3): on the next cold request of a thread, rechecks the held answer and replaces each valid output with a shape descriptor and a <<cg:HASH>> marker. The original is stashed, so expand returns it byte for byte. Each drop writes a record (cg:swd:), and every later request of the thread replays the same bytes. A warm request with an unchanged conversation never changes (H1). - Changed prefix (point 4): a rewind, an edited turn or a fork applies only the held drops after the first changed message. The ones before it stay held. Counted apart as sweep_applied_changed_prefix. - Fail open: a store that cannot hold an original refuses that drop. A panic in the apply restores every message it touched, writes no record, and forwards the request unchanged. - Dashboard (point 9): the answer cost is booked once, on the ping row the question replaced, in its own column (sweep_answer_usd). The expands of sweep markers come off the sweep's credit at the write rate. - Quality signals (point 7): an expand of a sweep marker is charged to the sweep, and a later turn that uses something a dropped output introduced counts as a false drop. False-drop rate per thread and overall, in the Components tab and in /stats (keepalive.sweep_drops). Ids, hashes and counts only. - The ping carries the forwarded body after a cold apply (point 15), by test. - The shadow-only ask gate is gone. shadow stays a setting and applies nothing. - xhigh runs the sweep again. The other presets are unchanged. - From the #508 notes: registerPing no longer keeps a conversation copy for a thread with no candidate and prunes on every registration (D); the sweep reads its own cg:swd: record, not cg:res: (F); BuildFallbackAsk and the sweep-only pricing in prefix_econ.go are removed (coref keeps what it uses). Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
… what it earns The sweep asked at the keep-alive ping and held the answer, and nothing used it. This change applies it. The sweep now saves money. - Cold apply (point 3): on the next cold request of a thread, rechecks the held answer and replaces each valid output with a shape descriptor and a <<cg:HASH>> marker. The original is stashed, so expand returns it byte for byte. Each drop writes a record (cg:swd:), and every later request of the thread replays the same bytes. A warm request with an unchanged conversation never changes (H1). - Changed prefix (point 4): a rewind, an edited turn or a fork applies only the held drops after the first changed message. The ones before it stay held. Counted apart as sweep_applied_changed_prefix. - Fail open: a store that cannot hold an original refuses that drop. A panic in the apply restores every message it touched, writes no record, and forwards the request unchanged. - Dashboard (point 9): the answer cost is booked once, on the ping row the question replaced, in its own column (sweep_answer_usd). The expands of sweep markers come off the sweep's credit at the write rate. - Quality signals (point 7): an expand of a sweep marker is charged to the sweep, and a later turn that uses something a dropped output introduced counts as a false drop. False-drop rate per thread and overall, in the Components tab and in /stats (keepalive.sweep_drops). Ids, hashes and counts only. - The ping carries the forwarded body after a cold apply (point 15), by test. - The shadow-only ask gate is gone. shadow stays a setting and applies nothing. - xhigh runs the sweep again. The other presets are unchanged. - From the #508 notes: registerPing no longer keeps a conversation copy for a thread with no candidate and prunes on every registration (D); the sweep reads its own cg:swd: record, not cg:res: (F); BuildFallbackAsk and the sweep-only pricing in prefix_econ.go are removed (coref keeps what it uses). Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
… what it earns The sweep asked at the keep-alive ping and held the answer, and nothing used it. This change applies it. The sweep now saves money. - Cold apply (point 3): on the next cold request of a thread, rechecks the held answer and replaces each valid output with a shape descriptor and a <<cg:HASH>> marker. The original is stashed, so expand returns it byte for byte. Each drop writes a record (cg:swd:), and every later request of the thread replays the same bytes. A warm request with an unchanged conversation never changes (H1). - Changed prefix (point 4): a rewind, an edited turn or a fork applies only the held drops after the first changed message. The ones before it stay held. Counted apart as sweep_applied_changed_prefix. - Fail open: a store that cannot hold an original refuses that drop. A panic in the apply restores every message it touched, writes no record, and forwards the request unchanged. - Dashboard (point 9): the answer cost is booked once, on the ping row the question replaced, in its own column (sweep_answer_usd). The expands of sweep markers come off the sweep's credit at the write rate. - Quality signals (point 7): an expand of a sweep marker is charged to the sweep, and a later turn that uses something a dropped output introduced counts as a false drop. False-drop rate per thread and overall, in the Components tab and in /stats (keepalive.sweep_drops). Ids, hashes and counts only. - The ping carries the forwarded body after a cold apply (point 15), by test. - The shadow-only ask gate is gone. shadow stays a setting and applies nothing. - xhigh runs the sweep again. The other presets are unchanged. - From the #508 notes: registerPing no longer keeps a conversation copy for a thread with no candidate and prunes on every registration (D); the sweep reads its own cg:swd: record, not cg:res: (F); BuildFallbackAsk and the sweep-only pricing in prefix_econ.go are removed (coref keeps what it uses). Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
… what it earns The sweep asked at the keep-alive ping and held the answer, and nothing used it. This change applies it. The sweep now saves money. - Cold apply (point 3): on the next cold request of a thread, rechecks the held answer and replaces each valid output with a shape descriptor and a <<cg:HASH>> marker. The original is stashed, so expand returns it byte for byte. Each drop writes a record (cg:swd:), and every later request of the thread replays the same bytes. A warm request with an unchanged conversation never changes (H1). - Changed prefix (point 4): a rewind, an edited turn or a fork applies only the held drops after the first changed message. The ones before it stay held. Counted apart as sweep_applied_changed_prefix. - Fail open: a store that cannot hold an original refuses that drop. A panic in the apply restores every message it touched, writes no record, and forwards the request unchanged. - Dashboard (point 9): the answer cost is booked once, on the ping row the question replaced, in its own column (sweep_answer_usd). The expands of sweep markers come off the sweep's credit at the write rate. - Quality signals (point 7): an expand of a sweep marker is charged to the sweep, and a later turn that uses something a dropped output introduced counts as a false drop. False-drop rate per thread and overall, in the Components tab and in /stats (keepalive.sweep_drops). Ids, hashes and counts only. - The ping carries the forwarded body after a cold apply (point 15), by test. - The shadow-only ask gate is gone. shadow stays a setting and applies nothing. - xhigh runs the sweep again. The other presets are unchanged. - From the #508 notes: registerPing no longer keeps a conversation copy for a thread with no candidate and prunes on every registration (D); the sweep reads its own cg:swd: record, not cg:res: (F); BuildFallbackAsk and the sweep-only pricing in prefix_econ.go are removed (coref keeps what it uses). Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
… what it earns (#404 PR C) (#695) feat(sweep): apply the held answer on the next cold request, and book what it earns The sweep asked at the keep-alive ping and held the answer, and nothing used it. This change applies it. The sweep now saves money. - Cold apply (point 3): on the next cold request of a thread, rechecks the held answer and replaces each valid output with a shape descriptor and a <<cg:HASH>> marker. The original is stashed, so expand returns it byte for byte. Each drop writes a record (cg:swd:), and every later request of the thread replays the same bytes. A warm request with an unchanged conversation never changes (H1). - Changed prefix (point 4): a rewind, an edited turn or a fork applies only the held drops after the first changed message. The ones before it stay held. Counted apart as sweep_applied_changed_prefix. - Fail open: a store that cannot hold an original refuses that drop. A panic in the apply restores every message it touched, writes no record, and forwards the request unchanged. - Dashboard (point 9): the answer cost is booked once, on the ping row the question replaced, in its own column (sweep_answer_usd). The expands of sweep markers come off the sweep's credit at the write rate. - Quality signals (point 7): an expand of a sweep marker is charged to the sweep, and a later turn that uses something a dropped output introduced counts as a false drop. False-drop rate per thread and overall, in the Components tab and in /stats (keepalive.sweep_drops). Ids, hashes and counts only. - The ping carries the forwarded body after a cold apply (point 15), by test. - The shadow-only ask gate is gone. shadow stays a setting and applies nothing. - xhigh runs the sweep again. The other presets are unchanged. - From the #508 notes: registerPing no longer keeps a conversation copy for a thread with no candidate and prunes on every registration (D); the sweep reads its own cg:swd: record, not cg:res: (F); BuildFallbackAsk and the sweep-only pricing in prefix_econ.go are removed (coref keeps what it uses). Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]> fix(sweep): serialise putHeld, claim before the cold apply, retry a panicked apply once - putHeld takes heldMu and never overwrites a newer AskedAtMs, so a claim that read an old answer cannot overwrite a new one, and two asks of one thread cannot land out of order. - The cold apply claims the held answer first. A panic in the apply or the recheck restores every message, is counted (sweep_apply_panic), and hands the answer back once. A second panic leaves it spent. - The ask-level slot refusal counts as sweep_concurrency_full, not sweep_ask_failed. - The cold test now uses the summary reserve's ColdApplyPhase. - The sweep row carries the net saving and the cold-apply cache numbers for L1 and C2. - docs/data-dependence.md: the sweep row now says it stashes originals for expand. PENDING. Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]> docs(sweep): fix the xhigh and housellm preset rows; record the data-dependence approval presets.md: xhigh and housellm now describe the sweep as it is: it asks at the keep-alive ping and removes content only on a cold request. The old max_calls and "adjudicates at depth on an expired cache" text is gone. data-dependence.md: Decided by records David Amid's approval of 2026-10-25 (#695). Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]> fix(sweep): round 1 review fixes for the false-drop signal and the commit window - A marker shared by two threads lists every owner. An expand credits the thread that made it, and only a thread that carries the marker. With no thread known (the request-path repair), every owner is credited. - The reference scan, the expand note and the commit take dropMu, so a flag is not lost. - The commit is atomic in effect. A panic after the first record tombstones every record and marker owner this attempt wrote. Applied and sweep_applied_* are counted last. - The change point is computed from the answer the claim returns. - Shadow mode keeps replaying drops that already exist. It only stops new applies. - Rename AppliedChangedPrefx; fix the stale selectAffordableDrops hint; document the next-warm imprecision. Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]> fix(sweep): release dropMu when the reference scan panics, and close the panic paths - scanReferences held dropMu with a plain Unlock inside a function that recovers panics. A panic in the Store or the ledger left the lock held for good, and every later scan, expand note and commit blocked. The locked part is now a closure with a deferred unlock. - The extraction savings metrics are booked after the commit, with the events and ledger. - A panic at the held trim gives back the untrimmed answer, so the drops after the change point are not lost. - An expand of a marker with no thread known counts once in the total. Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]> test(sweep): pin the sweep question against #710, #711 and #712 - A ping the sweep's question replaced uses no output-budget step (#712), so the next plain pings differ. - A failed question is not a transport failure of a ping: it does not set #710's retry flag, the ordinary ping goes out in its place, and a question that billed asks once per idle period. - A held answer and its drop records stay on their own thread key, so a thread that moves to another id (#711 prevents it for a resume) does not carry them. Tests only. Part of #404. Assisted-By: Claude Opus 5.5 Signed-off-by: DAVID AMID <[email protected]>
Data dependence change
This PR changes the sweep's data dependence. Approved by David Amid on 2026-10-25.
docs/data-dependence.mdis updated (rowsextract_llm_sweepand "Body stash", and the audit lists).cg:swh:, pinned). It is metadata. Per judged output it holds: the tool-use id, a short hash of the message, token counts, the keep-or-drop verdict. Per answer it holds: the conversation length when asked, the model name, the cost, and the wait cause. No tool-output text, no conversation text. (Checked against theheldAnswerandheldOutputstructs.)Ctx.CanKeepAlive), for at most 30 minutes, for at most 256 threads. There is no byte bound yet (PR C, item D). This is the same kind of copy as thecache_aware_summarizerturn copies (item 6 of the audit).cg:res:) for replay. The old row said it kept "its removals, the originals, and 'still needed' answers" and "pays full price" without the body stash. That is gone.content. Everything: works.Summary
Rebased onto main after #507 merged; main (#691, #692) merged in later (see the last commit) (squash
1953b47c). The PR base ismain. One commit. Point 11 uses the sharedaskStripsThinkingShipped(no TODO left). See "Rebase" below.shadowis on. Otherwise it stays plain andsweep_ask_needs_shadowcounts why.econ_triggerand the full-price fallback are removed.What changed
pre_expiry_secondsare removed.min_inventoryis now 1. The per-ping cost ceiling still applies.cg:swh:, pinned). Each judged output keeps itstool_use_idand aSpanHashof the agent's message. The record also keeps the judged length and the wait cause (feat(dash,proxy): record wait cause and wake cause per request (#424 record half) #453, stored only).recheckHelddrops a verdict when the conversation is shorter, the output is gone or changed, a later turn referenced it (coref), or the agent expanded it. PR C calls it on the cold request.sweep_shadow_asked,_proposed,_valid,_dropped_<reason>as request events, and acg.sweep.shadowlog line.sweep_model_declined.extract.Askcomposes lists. An output in two lists is judged once. No second list is built.econ_trigger,econ_ignore_ask_cost,reward_premium,min_pressure,block_fallbackandpre_expiry_secondsare ignored: the config still loads, one warning names the key and why, andRetiredKeyscounts it. The sweep acts as if the key was absent. Other bad keys (model,strategy, ...) still fail the load.askLedger(sweep_askcost.go), and the fallback ask.How it was tested
go test ./...areas touched,go vet ./...,gofmt). Offload, waitcause and keeper tests also pass with-race.askOffload(register, then ask at the ping). Evidence tests moved toextract_sweep_evidence_test.go. Theprefix_econguard tests moved toprefix_econ_guard_test.go(coref still uses that code).extract_sweep_econ_test.go(econ trigger, 5 tests),extract_sweep_afford_test.go(3),extract_sweep_fallbackcost_test.go(4),extract_sweep_intent_test.go(3),sweep_askcost_test.go(ask ledger, pressure and opportunity floors),econ_band_sim_test.go(2).extract_sweep_test.go:TestSweepFiresOnlyInThePreExpiryWindow,TestSweepDoesNothingOutsideTheWindow,TestPreExpirySecondsWidensTheWindow,TestSweepFallsBackWhenTheCacheReadDidNotHappen,TestBlockFallbackDeclinesInsteadOfPaying,TestSweepDebugImpliesBlockFallbackUnlessExplicit,TestSweepFallsBackWithNoAsker,TestSweepDoesNotAttributeAReplyShapeToTheFallback,TestBlockFallbackDistinguishesAZeroReadFromAWrite,TestBlockFallbackDecliningAWritePublishesTheCorrectRejection,TestSweepRemovesSpentOutputsFromOneCachedAsk,TestSweepReplaysItsRemovalOnLaterTurns,TestSweepStaleGuardStaysOutOfTheWayWithNoKnownBoundary.commitgate_sweep_test.go:TestSweepFreezesNoDecisionForADropThatDidNotHappen,TestSweepTellsAReserveRefusalApartFromNothingSpent,TestSweepReportsItsOwnEconomicsAndTheWiresSeparately,TestSweepReplayBooksWhatTheReplayedMessageActuallySaved.commitgate_freshpath_test.go:TestSweepBooksNothingForADropItCouldNotStash. These test the splice; PR C brings them back.extract_sweep_dropsubtest incommitgate_irreversible_test.goand theextract_llm_sweepcase incommitgate_test.go(now ingateExemptwith a reason; PR C must add its case back).sweep_askdump_test.go: two econ-block tests.prefix_econ_premium_test.go: the config-refusal and ask-declined-label tests.prefix_econ_prunecredit_test.go: the pruning test.TestRetiredKeysLoadWarnAndChangeNothing(each removed key loads, warns once, is counted, and the sweep equals the one built without it) andTestRecordedBenchmarkConfigsWithRetiredSweepKeysStillLoad(thedeploy/harbor/cfg-iter02*.yamlfiles load and build). Mutations: stripping removed; counting removed.Rebase
Main moved a lot since the first push (198 commits). Conflicts and how I resolved them:
proxy/keepalive.go: main moved the keeper into packagekeepalive. I took main's file and put my keeper changes in the new package:keepalive/substitute.go:fireSweepSubstitute(with its recover),projectedSweepUSD,sweepWaitCause, andrecordSubstitutePing(shared with the summary substitute).keepalive/keeper.go: the call infire()after the summary, three counters, theStatsfields,Options.OpenTasksandRecord.ToolUseNames(the wait cause inputs).ToolUseNamesis onRecord, notUsage, soUsagestays comparable.proxy/keepalive.go: passesToolUseNamesand wiresOpenTaskstowaitcause.Tracker.OpenCounts.keepalive/sweepsubstitute_test.go(the oldproxy/keepalive_sweepsubstitute_test.gois deleted).components/offload/extract_sweep.go:resolveAsk(...).Frame(...). Kept. It wraps myextract.Askbody.AskCoveredwith the verified span, andErrStalePrefixcounts assweep_stale_prefix. Kept. I added a rejection string for it.extract_sweep_test.go: kept main'sTestSweepAsksOnTheSnapshotItCheckedand itsfakeCoveredAsker, adapted to the ping path (the covered span is now the whole conversation). Main's twoBlockFallbacktests test the removed fallback and are deleted.extract_sweep_fallbackcost_test.go: main changed only its imports (thecheapmodelmove anddispatchtest). All four tests in it (TestSweepFallbackAskPricesItsOwnCall,TestSweepCountsBothLegsWhenItFallsBackAfterAsking,TestAFailedFallbackStillLandsInTheLedger,TestAFailedFallbackAfterAskingStillGrowsTheRow) test the removed fallback, so it stays deleted. Main added no new behavior to it.askStripsThinkingShipped(gatesweep_thinking_would_be_stripped, then the fallback), removedaskBridge, and changedcheapmodel.insertAskMessageto uselastBridge. This PR removes that in-request ask and the fallback, so the conflict was in code I delete. I kept theaskBridgeremoval and thecheapmodelchange. The same rule runs at the ping throughsweepModelDeclinesand is counted assweep_model_declined(TestModelsWhereTheQuestionBreaksTheCacheGetAPlainPing). No path uses the gate namesweep_thinking_would_be_strippednow, so it is not in the docs list. refactor(offload): one helper for the role and opening of an appended question #507'sTestSweepDeclinesThePrefixAskWhenItWouldStripThinkingdrove the removed path; I replaced it with a pointer to that test.internal/cheapmodelis nowcheapmodel/: I updated my imports. refactor(offload): one helper for the role and opening of an appended question #507'sTestSweepQuestionOpensWithTheSharedLinedrove the removed in-request ask; it now asks throughaskOffload.TestKeepAliveSurvivesAPanicInTheKeepersOwnQuestionCode.Review round 1 (GLM, head 0211b4d) fixes
registerPingnow keeps a copy only when the keep-alive can ping the thread (TestWithKeepAliveOffNothingIsRegistered).collect(), released on every exit (TestCollectionRunsAtMostSlotsAtOnce: 16 goroutines behind a barrier,collectPeaknever abovecap(sweepSlots);TestACollectionSlotIsReleasedWhenDispatchIsNeverCalled).collect(TestCollectionRecordsTheResultCacheMiss).sweep_concurrency_fullandsweep_not_registeredare counted and in/stats(TestAConcurrencyRefusalIsCounted).advanced-offload.md: the "in-request ask remains" sentence, the dead counter names and the "read as a pair" text are gone; the benchmark-era enabling section is replaced.retryremoved from the wait-cause list (a failed response never reaches the keeper).TestTheShadowAskIsReportedOnceUnderConcurrentRequests,TestTheColdRecheckIsReportedOnceUnderConcurrentRequests).canPingignoring policy.Review round 1 fixes
SweepPingSubstituteand the dispatch closure both recover. The panic is logged, counted (sweep_ping_panics,SweepPingCounters().Panics), and the ping stays plain.cand.askedstays true, so the next ping is plain too.fireSweepSubstitutehas a last-line recover as well.TestH1EveryRequestAfterAnAnswerIsByteIdenticalToTheSweepOff). Theoptionsfieldswording is fixed.fallbackAskcomment is removed.askedreset after a panic. Each fails a test.sweep_ask_needs_shadowandsweep_ping_panicsare now in/stats(the first was missing from the stats struct).Acceptance tests (#404) for PR A
TestKeepAliveSendsTheSweepQuestionInPlaceOfTheNextPing(keepalive; the question replaces the ping, no ordinary ping is sent) andTestTheQuestionIsAskedAtThePingAndNotInTheRequest(offload; a request asks 0 times)TestNoKeepAliveNoQuestion(keepalive; keep-alive off, and a prompt under the 80k floor)TestTheQuestionIsAskedAtThePingAndNotInTheRequest(1 candidate asks),TestKeepAliveWithZeroCandidatesSendsAPlainPing(0 candidates: plain ping)TestKeepAliveSendsAPlainPingWhereTheQuestionWouldBreakTheCache(plain ping,sweep_model_declined+1),TestModelsWhereTheQuestionBreaksTheCacheGetAPlainPing(model table)TestH1EveryRequestAfterAnAnswerIsByteIdenticalToTheSweepOff(alsoTestAHeldAnswerChangesNoRequest)TestHeldAnswerNeverReachesAnotherThread(p:,a:, a subagent thread),TestHeldAnswersAreKeptPerThreadTestRecheckDropsAVerdictForEachReasonAndOnlyThen/R1_the_output_is_gone.../R2_the_content_changed.../R3_the_conversation_is_shorter_than_when_judged.../R4_a_later_turn_referenced_the_output.../R5_the_agent_expanded_itOpen questions
Unverified live, for the release integration check:
CompletePrefixeddoes not forwardAnthropic-Beta(the plain ping does). A prompt over 200k tokens may needcontext-1m-2025-08-07on some gateways, and the question could then miss the cache or fail. The failure is safe (plain ping, or thewrite > readstop). The summarizer substitute has the same gap. A5 covers it.internal/extract.BuildFallbackAskand the unused pricing code inprefix_econ.goare pruned in PR C, not here. Coref keeps what it uses.Technical notes
For PR C (review D, F).
registerPingkeeps a conversation copy per thread for up to 30 minutes (256 threads), now only where the keep-alive can ping; pruning runs only at the cap, and there is no byte bound (item D).applySweepDropReplaystill readscg:res:records that onlyextract_llmwrites now; remove or namespace it in PR C.Left for PR C (review round 2).
putHeldis not serialized with the claims (claimHeldReport,claimHeldSpend). The claims serialize with each other, but aputHeldfrom the ping can interleave with one. Fix this before PR C makes the held answer load-bearing (reviewer 1).ask) is counted undersweep_ask_failed, notsweep_concurrency_full. The collection-level refusal is counted correctly.claimHeldSpendconsumes the answer before the recheck runs, so a panic in the recheck loses the answer. That fails open (no drops); PR C should consume after the recheck.Durability.
cg:swh:has the same durability ascg:res:andcg:sum:: the Store is in memory, so a restart loses the held answer. That fails open: no drops.Registration. The pipeline registers a conversation snapshot per thread. The keeper looks it up when a ping falls due. Candidates are collected at the ping, not per request.
For PR D. The summary substitute goes first at the ping; the sweep is tried only when it declines. I extracted
recordSubstitutePingfromrecordSummarySubstituteso both book a substituted ping the same way.Gate. The shadow check is in
SweepPingSubstitute, with a TODO naming PR C. PR C removes it.Haiku 4.5 with no thinking blocks is not skipped (extract_llm_sweep: the prefix ask re-writes the cache on Haiku 4.5 with thinking #422's measured case needs a thinking block before the last message).
Part of #404.