Skip to content

fix(sweep): with warm on, keep the copy without a ping (#1191) - #1193

Merged
amiddavid merged 6 commits into
mainfrom
fix/sweep-warm-copy-without-ping
Nov 26, 2026
Merged

amiddavid merged 6 commits into
mainfrom
fix/sweep-warm-copy-without-ping

Conversation

@vz-ibm

@vz-ibm vz-ibm commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Owner approval, 2026-11-26: David Amid approved the behavior change and the data-dependence change in a session, and asked for this PR to be merged: #1193 (comment) . The integrator confirms it with him before the merge.

Behavior change and data-dependence change. Do not merge until @amiddavid says yes on this PR.

  • Approved by the repo owner, @vz-ibm, on 2026-11-17.
  • @amiddavid approved the design and the extract_llm_sweep row on 2026-11-17 (D1 in #1191), with one condition: the copy lives only until the warm question ends. This PR does that (commits 035a635 and 67cb46f). Still needed: his yes that the code matches.
  • Who: any config with extract_llm_sweep: {warm: true} on a thread that the keep-alive cannot ping. Today only the Bob plugin's bob-ultrahigh sets warm: true, so in practice: IBM Bob users with bob-ultrahigh.
  • Old: such a thread kept no conversation copy, so the warm question never asked (sweep_not_registered, sweep_warm_not_registered).
  • New: with warm: true, a thread the keep-alive cannot ping keeps the registry's conversation copy only while a warm question is due or running, so the warm question can ask after a forwarded request. The copy is dropped when the question ends or the request fails (at most 300 s). Data: conversation content in memory on that route, where there was none (2 copies per thread, never in the Store).
  • Not changed: the keep-alive. Such a copy is marked not pingable, so a ping, the ping substitute and the fix(keepalive): ping 2 re-writes the whole prefix after a ping 1 that wrote 6 tokens #776 extra sweep request never see it. Every preset without warm: true keeps today's rule.
  • Note: the keep-alive kill switch and policy do not stop the warm question, because it is not a ping. Turn it off with warm: false.
  • Turn it off: warm: false (the default), or the Bob preset lossless.

Summary

Blocker 1 of #1191. The sweep's warm question asks after a forwarded request, from the ping registry's conversation copy. That copy was kept only for a thread the keep-alive can ping. IBM Bob's route can never be pinged (an OpenAI provider, and cache strategy none), so the warm question never asked on Bob. Now, with warm: true, the copy is kept without a ping.

With blocker 2 fixed on main (#1196), this PR makes the sweep act on Bob. TestBobUltrahighSweepAsksBobOnALongChat (the end-to-end test of #1192, through the proxy on Bob's route) is now on and passes: one sweep question goes to Bob after 45 turns, at the first warm check (turn 30).

What changed

Tests

  • New: TestAWarmThreadTheKeepAliveCannotPingStillAsks, with 2 cases: the keep-alive hook says no, and there is no hook at all. Each expects 1 question and no not_registered. Red before the fix: "asked 0 times, want 1", in both cases.
  • New: TestAnUnpingableWarmCopyLivesOnlyForItsQuestion, with 6 cases:
    • no question due: no copy;
    • question due: the ping path cannot read the copy;
    • question done: the copy is dropped;
    • question due: a ping claim picks no sweep;
    • the due window ended before the host resolved: the copy is dropped;
    • request not forwarded: the copy is dropped.
  • Claude Code does not change: every other warm test uses a thread the keep-alive can ping (warmCtx). They still pass, so a pingable copy keeps its 30-minute life.
  • Changed on purpose: the first subtest of TestAThreadTheKeepAliveCannotPingNeverAsksAWarmQuestion asserted the old behavior (a warm thread that cannot be pinged never asks). It is replaced by the new test above. The other 2 subtests (no registry copy means no question; the warm path keeps no copy of its own) stay, in a test renamed TestAThreadWithNoRegistryCopyNeverAsksAWarmQuestion.
  • Still guarded: TestWithKeepAliveOffNothingIsRegistered and TestNoAskerOrObserveModeRegistersNothing run with warm off. They still pass, so presets without warm keep no copy.

How it was tested

  • go test ./components/offload/ ok. go test ./components/all/ ok (the data-dependence row check). make lint clean.
  • go test ./... on macOS: every package passes except context-guru-plugin and bob-plugin.
    • The same 7 context-guru-plugin tests also fail on clean main (d008870) on this Mac: /private/var against /var paths, and golden-file differences. They are not related to this PR.
    • bob-plugin hit Go's 10-minute limit when the whole suite ran at once.
  • 2026-11-18, after merging main (cd90d55): go test ./components/... ./proxy/... ./apply/... ./config/... ok. make lint clean. Not run again: context-guru-plugin and bob-plugin (this PR does not touch them).

Assisted-By: Claude (Anthropic AI) [email protected]

The warm question asks after a forwarded request, from the ping
registry's conversation copy. That copy was kept only for a thread the
keep-alive can ping, so IBM Bob's route (an OpenAI provider, cache
strategy none) never asked. With warm: true the registry now keeps its
copy for any thread. Still one copy only (option B); presets without
warm keep today's rule. Blocker 1 of #1191.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>

@vz-ibm vz-ibm 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 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session fresh 2 of 2 1 of 2 b98d64d86072 blocking

Verdict: blocking

The fix does what the PR says for the warm question on IBM Bob. But keepsCopy also feeds the keep-alive's ping path, and the PR does not name that change. The new copy can also stay in memory longer than the row says.

Findings

  1. components/offload/extract_sweep_ping.go:265 — with warm: true, the keeper's ping substitute now asks on threads that canPing refused. The PR does not name this behavior change.

    • What fails: registerPing is the only gate between the keep-alive and a ping-time sweep question. Before this PR, a thread had a registry entry only when canPing said yes. Now, with warm: true, every thread has one. Two kinds of thread that the keeper does ping, but canPing refuses, now get a paid sweep question in place of a plain ping:
      • An OpenAI thread with keep-alive on. canPing refuses OpenAI on purpose: "the provider is not OpenAI (the sweep's question is Anthropic only)" (proxy/keepalive.go:422-428). But the keeper still pings OpenAI threads, on their own cadence (proxy/keepalive.go:490-495, keepalive/keeper.go:934 "OpenAI pings 28 minutes"). fireSubstitute (keepalive/keeper.go:2347) has no provider gate. ClaimPing sees hasSweep (ping_claim.go:116) and picks PingSweep. SweepPingSubstitute asks through the stored PrefixAsk, which on OpenAI Chat is chatPrefixAsker (proxy/prefixask.go:395).
      • A tool wait outside a time window (#858). proxy/keepalive.go:431-433 says such a thread "registers no conversation copy and still gets its plain ping; it loses only the sweep substitute". With warm: true it now keeps the substitute.
      • The same entry also makes extraReadyLocked (keepalive/keeper.go:2282, HasSweepPingCandidate) fire the #776 extra sweep request on these threads.
    • Proof: the trace above. The row text added in this PR also says "A ping never comes on such a route, so the warm question is the only one that reads the copy". That is true for Bob with cache strategy none, but false for the 2 cases above. The PR's "Who / Old / New" block names only the warm question.
    • Fix: keep the ping path on its old rule. One way: store on the candidate whether CanKeepAlive() said yes at registration (for example pingable bool). Then SweepPingSubstitute and HasSweepPingCandidate refuse an entry that is not pingable, and only the warm path reads it. Add a test: warm on, CanKeepAlive false, then SweepPingSubstitute returns ok=false and HasSweepPingCandidate returns false. If the wider behavior is wanted, name it at the top of the PR and get a human's yes, as CLAUDE.md requires.
  2. components/offload/extract_sweep_ping.go:283 — on a route the keeper never tracks, the new copy is not bounded to 30 minutes, and it is kept on every request, not only when a question waits.

    • What fails: the row says the copies are kept "for at most 30 minutes". Three things clear a copy: pruneSweepPingLocked, clearSweepPing and clearStaleSweepPing. pruneSweepPingLocked runs only inside registerPing (line 303), so it runs only when some thread registers. clearSweepPing runs from ClearKeepAliveCandidate, and the keeper calls it only for a thread in k.live (retireLocked returns at keepalive/keeper.go:1175-1177 when there is no entry). A Bob thread with strategy none is never in k.live: Record retires at line 836 and finds nothing. clearStaleSweepPing runs on the next request of the same thread only. So, on a local proxy with one Bob user, the last thread's 2 full conversation copies stay in memory until a later registration on any thread. That can be hours, not 30 minutes. Before this PR, this gap existed only for a host without a keeper. Now it is the main route of the feature.
    • Also: on such a route, the copy is read only by the warm question of the same request (registerWarm → ResolveWarmQuestion). But registerPing keeps it on every request, also when the trigger did not fire. So the content stays in memory for the whole idle span, though nothing can read it after the warm question is resolved or not fired.
    • Proof: grep -rn pruneSweepPingLocked gives one caller, extract_sweep_ping.go:303. keepalive/keeper.go:1173-1177 and 832-839 for the retire path.
    • Fix: for an entry that is not pingable (see finding 1), drop it in runWarmQuestion after the ask ends, and on the request path when no warm question is pending. Or at least prune by age on every read (SweepPingSubstitute, runWarmQuestion), and correct the row text to say what the bound really is. David Amid must confirm the row in any case.

Non-blocking

  • extract_sweep_ping.go:262-264: the keepsCopy doc says "The keep-alive asks from it at a ping". After finding 1 is fixed, say which of the 2 readers can read a non-pingable entry.
  • The PR says bob-plugin tests were still running. Post the result before merge.

What I checked

  • The full diff: extract_sweep_ping.go, extract_sweep_warm.go, extract_sweep_warm_test.go, both data-dependence row files and the generated page (the page lines match the rows).
  • registerPing, snapshotCandidate, the prune and clear functions, SweepPingSubstitute, registerWarm, runWarmQuestion and its latch.
  • Every reader of sweepPingCand: ClaimPing, HasSweepPingCandidate, SweepPingSubstitute, runWarmQuestion.
  • Host side: canPing, resolvePolicyWindows (OpenAI cadence), keeper Record, retireLocked, fireSubstitute, fireSweepSubstitute, extraReadyLocked, prefixAskerForAPI.
  • The test: both cases (hook false, hook nil) set warm on through warmCfg, and the old assertion was replaced on purpose, as the PR says. The remaining "no registry copy" subtests still guard option B. No test covers the ping path with warm on and CanKeepAlive false.
  • The PR states the behavior change and the data-dependence change at the top, and names David Amid as the person who must still confirm.
  • I did not run Go tests (not approved here).

@vz-ibm vz-ibm 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 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session fresh 1 of 2 1 of 2 b98d64d86072 blocking

Verdict: blocking

The code change is small and correct for its goal. One finding: on the newly enabled route, the "at most 30 minutes" bound in the data-dependence row is not true.

Findings

  1. components/offload/extract_sweep_ping.go:283 — a copy on a thread the keeper does not track can stay in memory past 30 minutes
    • What fails: a Bob session with bob-ultrahigh registers its 2 conversation copies, then the user stops. No later request registers on any thread. The copies stay in memory for as long as the process runs, not 30 minutes. With 256 threads, that is up to 256 full conversations, kept longer than the row says.
    • Proof:
      • Only 3 paths remove a sweepPingCand entry: clearSweepPing (from ClearKeepAliveCandidate), clearStaleSweepPing (from the next request on the same thread, proxy/proxy.go:1594), and pruneSweepPingLocked.
      • ClearKeepAliveCandidate runs only from the keeper (keepalive/keeper.go:663, 1187, 1229, 1291, 1326; lifecycle.go:121; manualhold.go:242). The keeper never tracks a thread that canPing refuses (proxy/keepalive.go:426, OpenAI is refused at :427-428).
      • pruneSweepPingLocked runs only inside registerPing (extract_sweep_ping.go:303). There is no timer and no age check at read time (runWarmQuestion, extract_sweep_warm.go:1144).
      • The code comment at extract_sweep_ping.go:230-232 says it: the keeper clears a registration, and the 30-minute age "is the backstop for hosts that run without it". Before this PR, a registered thread always had the keeper. After it, the backstop is the only path on Bob's route.
      • The rows this PR edits say "for at most 30 minutes" (docs/data-dependence/components/extract_llm_sweep.md where, and the body-stash row by reference). The PR banner asks David Amid to confirm "30 minutes each".
    • Fix: one of these.
      • Enforce the bound: prune on read as well (in runWarmQuestion, HasSweepPingCandidate, SweepPingSubstitute), and run a prune from a timer or from ResolveWarmQuestion on every request. A test: register a copy with CanKeepAlive false, move registeredAt back past 30 minutes, call no other registration, and expect the entry gone at the next read.
      • Or change the row to the true bound ("30 minutes, removed at the next registration after that") and let David confirm that text.

Non-blocking

  • Stale comments that now contradict the code. Please update them with this PR:
    • components/offload/extract_sweep_warm.go:30-31: "so it asks only on threads the keep-alive can ping". That is the old rule.
    • components/component.go:753-758 (CanKeepAlive): "registers only when it returns true". With warm: true it registers without it.
    • proxy/keepalive.go:430-432 (canPing): "A tool wait outside a window then registers no conversation copy". With warm: true it does.
    • components/offload/extract_sweep.go:80 and :174, and extract_sweep_warm.go:25: "in no preset". bob-ultrahigh sets warm: true (proxy/testdata/bob_ultrahigh.yaml:27). The PR fixed this in the row but not in the code.
  • e.warm skips every canPing gate, not only the OpenAI one. It also skips the kill switch, the policy-off case and the "no tool call yet" case. So an Anthropic thread with warm: true and keep-alive off now keeps copies too. The banner says "on a thread that the keep-alive cannot ping", so this is covered in words, but the "Who" line names only Bob. Consider saying in the banner that any route with warm: true is affected, and that the kill switch does not stop the warm question.
  • A side effect on Anthropic threads. A thread that canPing refused at record time (a tool wait outside a window, proxy/keepalive.go:430) can now have a copy. If the keeper pings that thread later, ClaimPing can pick PingSweep (components/offload/ping_claim.go:116-125) where it used to send a plain ping. The endsAtText guard (keepalive/keeper.go:2356-2359) still keeps the cache rule. I think this is safe, but it is a behavior change the banner does not name.

What I checked

  • Read the full diff: extract_sweep_ping.go, extract_sweep_warm.go, extract_sweep_warm_test.go, the 2 row files and the generated docs/data-dependence.md. The generated page matches the 2 row files.
  • Read the commit message and the PR body, including the behavior-change banner.
  • Read registerPing, snapshotCandidate, mayHaveCandidate, the prune and clear functions, registerWarm, runWarmQuestion, askWarm, ClaimPing, HasSweepPingCandidate.
  • Traced every caller of ClearKeepAliveCandidate and ClearStaleKeepAliveCandidate, and the proxy's canPing and CanKeepAlive wiring (proxy/modes.go:71).
  • Checked that the OpenAI Chat route gets a PrefixAsk (proxy/prefixask.go:392-418), so registerPing does not return early on Bob for that reason.
  • Checked that the manual Ping button sends a plain ping and never a sweep question (keepalive/manual.go:137), so a new copy cannot turn a press into a paid question.
  • Checked the new test: both cases (false hook and nil hook) expect 1 question and NotRegistered == 0. The kept subtests still cover "no registry copy" and "no own copy". The warm-off guards (TestWithKeepAliveOffNothingIsRegistered, TestNoAskerOrObserveModeRegistersNothing) are unchanged.
  • Fail open: no new error path. keepsCopy is a pure boolean.
  • Did not run tests: live tests are not approved and Go is not installed here.

Round 1 review of #1193. A copy kept for a thread the keep-alive cannot
ping is now marked not pingable: SweepPingSubstitute and
HasSweepPingCandidate do not see it, so the keep-alive pings exactly as
before. It is kept only while a warm question is due, and dropped when
the question ends or the request fails, so it never outlives the
30-minute bound on a route no keeper tracks. Stale comments and the
data-dependence rows now say so.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
@vz-ibm

vz-ibm commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Round 1 replies. Both findings were real. Fixed test-first in 035a635. The PR text at the top is updated.

Reviewer 2, finding 1: the ping path read the new copy. Fixed.

  • A registry entry now records pingable (what CanKeepAlive() said at registration).
  • SweepPingSubstitute treats a non-pingable entry as no candidate. HasSweepPingCandidate returns false for it. So the ping, the ping substitute and the fix(keepalive): ping 2 re-writes the whole prefix after a ping 1 that wrote 6 tokens #776 extra request work exactly as before: an OpenAI thread with keep-alive on, and a tool wait outside a window, still get a plain ping.
  • Test: TestAnUnpingableWarmCopyLivesOnlyForItsQuestion/question_due:_the_ping_path_cannot_read_the_copy. Red before the fix: "HasSweepPingCandidate = true for a thread the keep-alive cannot ping".

Both reviewers: the 30-minute bound was not enforced on a route no keeper tracks. Fixed by a shorter life, not by a timer.

  • A non-pingable copy is kept only while a warm question is due. registerWarm runs before the deferred registerPing, so registerPing knows (warmDue). With no question due, it keeps no copy and drops an old one.
  • runWarmQuestion drops it when the question ends, on every early exit, and when the request was not forwarded (dropUnpingable). It deletes only its own entry, so a newer registration stays.
  • A question that runs while the next request drops the entry is safe: the question holds its own slice references.
  • Tests (all red before, green after): no question due: no copy, question done: the copy is dropped, request not forwarded: the copy is dropped.
  • The data-dependence rows now say "only while a warm question is due or running (at most 300 seconds after the request)".

Reviewer 1, non-blocking: stale comments. Fixed: extract_sweep_warm.go header ("asks only on threads the keep-alive can ping", "in no preset"), extract_sweep.go (2 places, "in no preset"), components.Ctx.CanKeepAlive, and canPing in proxy/keepalive.go.

Reviewer 1, non-blocking: e.warm skips every canPing gate. Now it skips them only for the warm question's own short-lived copy, never for a ping. The PR text says that the keep-alive kill switch does not stop the warm question, because it is not a ping, and how to turn it off (warm: false).

Reviewer 2, non-blocking: the bob-plugin result. It fails on this Mac in TestBobReleasePythonSuite (the installer tests: a real binary where a fake is expected). This PR changes no Bob plugin or installer file. A run of the same test on clean main is in progress; I will post the result.

Checks on 035a635: go test ./components/... ./proxy/ ./keepalive/... ./apply/... ok; make lint clean; make datadep rebuilt.

Assisted-By: Claude (Anthropic AI) [email protected]

@vz-ibm vz-ibm 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 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 1 of 2 2 of 2 035a63570519 blocking

Verdict: blocking

The round-1 findings from both reviewers are fixed. One small new gap remains: if the request runs for more than 5 minutes, the non-pingable copy is not dropped. That breaks the new "at most 300 seconds" text in the row. The fix is one line.

Findings

  1. components/offload/extract_sweep_warm.go:1127 — if the due window ends before the host resolves the request, the non-pingable copy is never dropped
    • What fails: a Bob request with bob-ultrahigh sets a warm question due (registerWarm, pendingAt). registerPing keeps a non-pingable copy. The forward takes more than warmPendingMax (5 minutes): a long stream, or several expand rounds. Then the proxy's deferred ResolveWarmQuestion (proxy/proxy.go:2045) reaches runWarmQuestion. !t.warmPending() is true, so it returns at line 1129 and does not call dropUnpingable. Nothing else drops that copy except:
      • the next request on the same thread (registerPing → clearSweepPing, extract_sweep_ping.go:95 of the diff), or
      • pruneSweepPingLocked, which runs only when some thread registers, and only after 30 minutes.
        If the user stops after that turn, the 2 full conversation copies stay in memory with no time limit. This is the round-1 problem again, only in this edge case.
    • Proof:
      • extract_sweep_warm.go:1126-1130: if !ok || !t.warmPending() { warmMu.Unlock(); return }. No drop on this path. The other exits (not forwarded, latched, held, goroutine end) all call dropUnpingable.
      • extract_sweep_warm.go:92: warmPendingMax = 5 * time.Minute, measured from pendingAt, which is set during the pipeline, before the forward.
      • The row now says "only while a warm question is due or running (#1191; at most 300 seconds after the request)". David Amid is asked to confirm that text.
      • No test covers it: the 4 new subtests resolve the request at once.
    • Fix: in that early exit, call dropUnpingable(tkey, sweepPingCand[tkey]) too, under sweepPingMu, as the !forwarded branch does. When no question starts for this request, the copy has no reader. Add a subtest: set warmPendingMax to a short value (it is a var for tests), let it pass, call ResolveWarmQuestion(..., true, ...), and expect no entry.

Non-blocking

  • New side effect for presets without warm. registerPing now calls clearSweepPing(key) whenever a thread is not registered (diff line 95). Before, it only returned. A thread that was pingable on request N and is not on request N+1 now loses its older copy. On the proxy this changes nothing, because ClearStaleKeepAliveCandidate (proxy/proxy.go:1594) already clears that older copy after every request. It is also the safer direction. I note it only because it touches presets without warm.
  • A library host that sets PrefixAsk but never calls ResolveWarmQuestion (apply.Opts exposes PrefixAsk) keeps a non-pingable copy with only the old backstop. The PrefixAsk host contract (components/component.go:748-751) names ResolveDeferredCacheAwareSummary but not ResolveWarmQuestion. Consider adding it there. The proxy is the only host today, and it calls it in a defer on every path.
  • The bob-plugin result is still open. The author's reply says a run on clean main is in progress. Post it before merge.

What I checked

  • Last review: round 1, b98d64d, 2026-11-17T10:32:44Z
  • New commits read: 1 (035a635 fix(sweep): an unpingable copy lives only for its warm question)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Commit 035a635: read the full diff (10 files) and the code around it. See below.
    • The author's comment at 2026-11-17T10:40:19Z: I checked each reply.
      • Reviewer 2, finding 1 (the ping path read the new copy): fixed. pingable is set from CanKeepAlive() at registration. SweepPingSubstitute treats a non-pingable entry as nil, and HasSweepPingCandidate returns false for it. ClaimPing (ping_claim.go:116) still reads the map directly. So it can pick PingSweep for a non-pingable entry, but then fireSweepSubstitute gets nil from SweepPingSubstitute and the ping stays plain. A new subtest covers both readers.
      • Reviewer 2, finding 2, and my finding 1 (the 30-minute bound): fixed for the normal paths. With no question due, no copy is kept and the old one is dropped. The copy is also dropped when the question ends, on each early exit after the due check, and when the request was not forwarded. dropUnpingable deletes only its own entry (pointer check), so a newer registration stays. One exit is still open: my new finding 1.
      • My non-blocking stale comments: fixed in extract_sweep_warm.go (header), extract_sweep.go:80 and :174, component.go (CanKeepAlive), proxy/keepalive.go (canPing).
      • My non-blocking point that warm skips every canPing gate: fixed. It now skips them only for the warm question's own copy, and no ping reads that copy.
      • Reviewer 2, non-blocking (bob-plugin): still open, see Non-blocking.
  • Order: registerWarm runs in the body of Offload (extract_sweep_warm.go:932, extract_sweep_v3.go:767). registerPing is deferred (extract_sweep.go:588). So warmDue sees this request's trigger, as the author says.
  • Locks: warmDue takes warmMu before registerPing takes sweepPingMu. The !forwarded branch releases warmMu before it takes sweepPingMu. No nested order, so no deadlock.
  • The running question uses its own cand with the slices from reg, so a drop during the question is safe.
  • The proxy calls ResolveWarmQuestion inside the deferred finish of serve (proxy/proxy.go:2024-2045), so it runs on every return path.
  • The question's outer limit is CacheAwareSummarizerCallTimeout (300 s, extract_sweep_warm.go:1249-1252). That matches the row's "300 seconds" once the response is in.
  • The new tests: r.key() is thread.Key(session, ""), the same key ResolveWarmQuestion(r.session, "", ...) uses. Each subtest asserts the map state directly.
  • The rows and the generated page: the page lines match the 2 row files.
  • Did not run tests: live tests are not approved and Go is not installed here.

@vz-ibm vz-ibm 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 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 2 of 2 2 of 2 035a63570519 blocking

Verdict: blocking

Both round-1 findings are fixed for the normal path. One exit of runWarmQuestion still leaves a non-pingable copy behind. In that case the new row text "at most 300 seconds after the request" is not true. The fix is 1 line.

Earlier findings

  • Reviewer 2, finding 1 (the ping path read the new copy): fixed. pingable is set at registration (extract_sweep_ping.go:320). SweepPingSubstitute treats a non-pingable entry as no candidate (:432-434). HasSweepPingCandidate returns false for it (ping_claim.go:83). So fireSweepSubstitute and extraReadyLocked behave as before. The new subtest "question due: the ping path cannot read the copy" covers both functions.
  • Reviewer 2, finding 2 / reviewer 1, finding 1 (no 30-minute bound on an untracked route): fixed, except for the exit below. registerPing keeps a non-pingable copy only when warmDue is true, and clears an old one otherwise (:304-309). I checked the order: warmStep → registerWarm (extract_sweep_warm.go:932) runs inside Offload, before the deferred registerPing (extract_sweep.go:588), so warmDue sees this request's trigger. dropUnpingable runs on the not-forwarded exit, on both "already asked" exits, and in a defer of the question goroutine. It deletes only its own entry (sweepPingCand[threadKey] == reg), so a newer registration stays.
  • Reviewer 1, non-blocking (stale comments): fixed. I read the new text in component.go, extract_sweep.go (2 places), extract_sweep_warm.go (header) and proxy/keepalive.go canPing.
  • Reviewer 1, non-blocking (e.warm skips every canPing gate): this now holds only for the short-lived copy that the warm question reads. The author's reply says the PR text names the kill-switch case and warm: false. I accept this.
  • Reviewer 2, non-blocking (bob-plugin result): the author says TestBobReleasePythonSuite fails on the Mac, and this PR changes no Bob or installer file. The run on clean main is not posted yet. See Non-blocking.

Findings

  1. components/offload/extract_sweep_warm.go:1127-1130 — when the trigger expired before the host's hook, runWarmQuestion returns without dropUnpingable, so the copy is not bounded to 300 seconds
    • What fails: a Bob thread with bob-ultrahigh fires the warm trigger. registerPing keeps a non-pingable copy. The response streams for more than warmPendingMax (5 minutes; extract_sweep_warm.go:92). The proxy calls ResolveWarmQuestion only after the response ends (proxy/proxy.go:2045). Then t.warmPending() is false, the function returns at the first branch, and nobody drops the copy. If the user stops after that turn, the 2 full conversation copies stay in memory until a registration on another thread runs the 30-minute prune, or for as long as the process runs on an idle proxy. This is the round-1 gap again, on a narrower path. The same happens on a host that sets warm: true and never calls ResolveWarmQuestion (only the proxy calls it).
    • Proof: in runWarmQuestion, the branch if !ok || !t.warmPending() { warmMu.Unlock(); return } comes before every new dropUnpingable call. pruneSweepPingLocked still has one caller, registerPing, and it removes only entries older than 30 minutes. The row now says "only while a warm question is due or running (#1191; at most 300 seconds after the request)", and the PR asks David Amid to confirm that text.
    • Fix: drop the non-pingable copy on that branch too (read sweepPingCand[tkey] and call dropUnpingable, as the !forwarded branch does). As a second guard, let pruneSweepPingLocked also drop a non-pingable entry when warmDue is false for its key. Add a subtest: shrink warmPendingMax, fire the trigger, wait past it, call ResolveWarmQuestion(..., true, ...), and expect no entry.

Non-blocking

  • ping_claim.go:116 ClaimPing still reads _, hasSweep := sweepPingCand[threadKey] without pingable. On a pinged thread that has only a non-pingable copy (an OpenAI thread with keep-alive on), it picks PingSweep and not PingNone. fireSweepSubstitute then declines, and a plain ping goes out, so the result is the same. But sweep_summary_owned_ping / sweep_summary_in_flight count wrong, and the claim holds the thread during that ping. Use the same pingable check there.
  • The warm question can run while the next request clears the entry. The author says that is safe because the goroutine holds its own slice references. I agree: cand copies reg.input and reg.raw before the goroutine starts.
  • Post the clean-main TestBobReleasePythonSuite result before merge, as the author's reply promises.

What I checked

  • Last review: round 1, b98d64d, 2026-11-17T10:32:41Z
  • New commits read: 1 (035a635 fix(sweep): an unpingable copy lives only for its warm question)
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-1 review (10:32:44Z): checked its finding (same as my finding 2) and its 3 non-blocking points. See "Earlier findings".
    • The author's reply (10:40:19Z): checked every claim against the code. The order claim (registerWarm before the deferred registerPing) is true. The "at most 300 seconds" claim is not true on one exit (finding 1). The bob-plugin result is still pending.
  • The whole diff of 035a635: component.go, extract_sweep.go, extract_sweep_ping.go, extract_sweep_warm.go, extract_sweep_warm_test.go, ping_claim.go, proxy/keepalive.go, the 2 row files and the generated page (its #1191 text matches the row).
  • Code around the change: Offload (the defer order), warmStep, registerWarm, runWarmQuestion with all its exits, askWarm, ClaimPing, SweepPingSubstitute, HasSweepPingCandidate, pruneSweepPingLocked, the proxy's ResolveWarmQuestion call site.
  • The new test TestAnUnpingableWarmCopyLivesOnlyForItsQuestion: 4 subtests, each with a specific assertion. No subtest covers the expired-trigger exit.
  • I did not run Go tests (not approved here).

Round 2 review of #1193. runWarmQuestion now drops the warm question's
own copy also on its first exit, when the due window ended during a
long forward. ClaimPing ignores that copy too. The flag is now
warmOnly, so a registration made without it is an ordinary one. The
PrefixAsk host contract names ResolveWarmQuestion.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: Vitaly Zabershinsky <[email protected]>
@vz-ibm

vz-ibm commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Round 2 replies. Both reviewers found the same real gap. Fixed test-first in 67cb46f.

Both reviewers, finding 1: the due window ends before the host resolves the request. Fixed. runWarmQuestion's first exit (no thread, or nothing due) now drops the warm question's own copy too, as the other exits do. Test: due window ended before the host resolved: the copy is dropped (sets warmPendingMax = 0, then ResolveWarmQuestion(..., true, ...)). Red before: "the copy outlived a due window that ended before the host resolved the request".

Reviewer 2, non-blocking: ClaimPing read the copy. Fixed. It ignores a warm-only copy, so sweep_summary_owned_ping and sweep_summary_in_flight count as before, and the claim is released at once. Test: question due: a ping claim picks no sweep. Red before: ClaimPing chose "sweep".

The flag is renamed pingable → warmOnly. The existing ping-claim tests create bare entries (&sweepPingCandidate{}). With pingable they read as not pingable and failed. With warmOnly, the zero value is an ordinary registration, so any entry made without the flag behaves as before. Only registerPing sets it.

Reviewer 1, non-blocking: the host contract. Fixed. components.Ctx.PrefixAsk now names offload.ResolveWarmQuestion next to ResolveDeferredCacheAwareSummary.

Reviewer 1, non-blocking: registerPing now clears an older copy for presets without warm. Agreed, as you say: on the proxy ClearStaleKeepAliveCandidate already clears it after every request, and it is the safer direction. Kept.

The bob-plugin result. TestBobReleasePythonSuite fails on clean main (d008870) on this Mac too: 10 installer tests, where a real proxy binary appears in place of the test's fake one. On this branch, 11 fail; the extra one is in the same installer group. This PR changes no Bob plugin or installer file. It is an existing defect on macOS, to be filed apart.

Checks on 67cb46f: go test ./components/... ./proxy/ ./keepalive/... ./apply/... ok; make lint clean.

Assisted-By: Claude (Anthropic AI) [email protected]

@vz-ibm vz-ibm 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 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 2 of 2 3 of 3 67cb46fc5536 approve

Verdict: approve

All earlier findings are fixed. The new commit closes the last exit that left a warm-only copy behind, and ClaimPing now ignores that copy. I found no new defect. The data-dependence change still needs David Amid's confirmation, as the PR banner says.

Earlier findings

  • Reviewer 2, round 1, finding 1 (the ping path read the new copy): fixed (round 2). Still true after the rename: SweepPingSubstitute (extract_sweep_ping.go:433), HasSweepPingCandidate (ping_claim.go:83) and now ClaimPing (ping_claim.go:116-117) all skip a warmOnly entry.
  • Reviewer 2, round 1, finding 2 / reviewer 1, round 1, finding 1 (no 30-minute bound): fixed.
  • Reviewer 2, round 2, finding 1 / reviewer 1, round 2, finding 1 (the expired-trigger exit kept the copy): fixed. The first exit of runWarmQuestion (extract_sweep_warm.go:1128-1136) now calls dropWarmOnly. Every exit after a warmOnly registration now drops it: no thread or nothing due, not forwarded, no registry entry (nothing to drop), latched, held answer, and the question goroutine's defer. The new subtest "due window ended before the host resolved" sets warmPendingMax = 0 after the 3 requests, so the copy was registered while due, and then checks that it is gone.
  • Reviewer 2, round 2, non-blocking (ClaimPing read the copy): fixed. The new subtest "a ping claim picks no sweep" expects PingNone.
  • Reviewer 1, round 2, non-blocking (host contract): fixed. components.Ctx.PrefixAsk now names offload.ResolveWarmQuestion.
  • Reviewer 1, round 2, non-blocking (registerPing clears an older copy with warm off): kept by the author. I accept the reason. On the proxy, ClearStaleKeepAliveCandidate (proxy/proxy.go:1594) already clears that copy after every request, and the change keeps less in memory, not more.

Findings

None.

Non-blocking

  • The bob-plugin result. The author reports 10 installer failures in TestBobReleasePythonSuite on clean main and 11 on this branch. The PR changes no Bob plugin or installer file, so the difference is likely an unstable test. But please name the 11th test in the reply, and the issue you file, so that someone can check it fails on main too. This should not wait for this PR.
  • The rename pingable → warmOnly is right. The zero value is now an ordinary registration, so the bare &sweepPingCandidate{} entries in the existing ping-claim tests behave as before.

What I checked

  • Last review: round 2, 035a635, 2026-11-17T10:43:03Z
  • New commits read: 1 (67cb46f fix(sweep): drop the warm-only copy when no question starts)
  • Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-2 review (10:42:56Z): its finding is the same as my round-2 finding, and it is fixed. Its 3 non-blocking points: host contract (fixed), the clear with warm off (kept, reason accepted), bob-plugin (see Non-blocking).
    • The author's round-2 reply (10:49:29Z): I checked each claim against the code: the first-exit drop, the ClaimPing change, the rename and why, the host contract text. The bob-plugin numbers (10 against 11) are in Non-blocking.
  • The whole diff of 67cb46f: component.go, extract_sweep_ping.go, extract_sweep_warm.go, extract_sweep_warm_test.go, ping_claim.go.
  • Code around the change: every exit of runWarmQuestion, dropWarmOnly (deletes only its own entry, by pointer), registerPing (sets warmOnly = !canPing), ClaimPing's switch with the new hasSweep.
  • Locks: the first exit releases warmMu before it takes sweepPingMu, the same order as the !forwarded exit. No nested lock.
  • A thread with warm off, or a pingable thread: warmOnly is false, so the new drop on the first exit (which runs on every request without a trigger) does nothing for it.
  • I did not run Go tests (not approved here).

@vz-ibm vz-ibm 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 (claude, user of @vz-ibm) Claude Code 2.1.325 offload-review skill, @vz-ibm's session resumed 1 of 2 3 of 3 67cb46fc5536 approve

Verdict: approve

All earlier findings from both reviewers are fixed. The new commit adds no defect that I can find. The merge still needs David Amid's confirmation of the data-dependence row, as the PR banner says.

Earlier findings

  • Reviewer 1, round 1, finding 1 / reviewer 2, round 1, finding 2 (no 30-minute bound on an untracked route): fixed in 035a635, and completed in 67cb46f.
  • Reviewer 2, round 1, finding 1 (the ping path read the new copy): fixed in 035a635. 67cb46f also covers ClaimPing.
  • Reviewer 1, round 2, finding 1 / reviewer 2, round 2, finding 1 (the expired-due exit kept the copy): fixed. The first exit of runWarmQuestion (extract_sweep_warm.go:1127-1136) now reads the entry and calls dropWarmOnly. I checked that this cannot drop a copy that a question still needs:
    • If a question is due, warmPending() is true, so this branch does not run.
    • If a question runs (t.asking), its goroutine holds its own cand with the slices, so a drop is safe.
    • dropWarmOnly returns at once for an ordinary (pingable) entry, so presets without warm and pingable threads do not change.
    • The pointer check (sweepPingCand[threadKey] == reg) keeps a newer registration.
  • Reviewer 2, round 2, non-blocking (ClaimPing read the copy): fixed. hasSweep now ignores a warmOnly entry (ping_claim.go:116-117). With no summary, the claim is PingNone and is released at once (ping_claim.go:133-135). fireSubstitute then tries both substitutes, and both decline, because SweepPingSubstitute treats the entry as nil. A new subtest asserts PingNone.
  • Reviewer 1, round 2, non-blocking (host contract): fixed. components.Ctx.PrefixAsk now names offload.ResolveWarmQuestion (component.go:751-753).
  • Reviewer 1, round 2, non-blocking (clearSweepPing for presets without warm): the author kept it, with a reason. I accept it: on the proxy, ClearStaleKeepAliveCandidate already clears that copy, and the change goes in the safe direction.
  • Reviewer 2, non-blocking (bob-plugin result): answered. See Non-blocking.

Findings

None.

Non-blocking

  • TestBobReleasePythonSuite: 10 failures on clean main, 11 on this branch. The author says the extra one is in the same installer group, and this PR changes no Bob plugin or installer file. I agree that no file in this diff touches that suite. Please name the 11th test in the follow-up issue, and say whether it also fails on a second run of main. That shows it is flaky and not caused by this PR.
  • The rename pingable → warmOnly is right. The zero value is now an ordinary registration, so the existing tests that build bare &sweepPingCandidate{} entries (2 places) keep their old meaning.

What I checked

  • Last review: round 2, 035a635, 2026-11-17T10:42:56Z
  • New commits read: 1 (67cb46f fix(sweep): drop the warm-only copy when no question starts)
  • Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-2 review (10:43:03Z): its finding 1 is the same as my round-2 finding 1. Its non-blocking ClaimPing point I checked in the code (see above). It is fixed.
    • The author's round-2 reply (10:49:29Z): I checked each claim against 67cb46f. The fix, the ClaimPing change, the rename reason and the host-contract text are all true. The bob-plugin answer: see Non-blocking.
    • Commit 67cb46f: read the full diff (5 files) and the code around it: runWarmQuestion with all its exits, dropWarmOnly, registerPing, SweepPingSubstitute, HasSweepPingCandidate, ClaimPing with its release path.
  • The 2 new subtests: question due: a ping claim picks no sweep asserts PingNone. due window ended before the host resolved sets warmPendingMax = 0, which makes warmPending() false, and restores it in t.Cleanup. No test in the file uses t.Parallel, so the change to the global is safe.
  • Locks in the new branch: warmMu is released before sweepPingMu is taken, as in the !forwarded branch. No nested order.
  • No row or generated-page change in this commit. The round-2 row text ("at most 300 seconds after the request") is now true on every exit of runWarmQuestion on the proxy, which calls it in a defer on every path.
  • Did not run tests: live tests are not approved and Go is not installed here.

@vz-ibm

vz-ibm commented Nov 17, 2026

Copy link
Copy Markdown
Collaborator Author

Moved to draft: this PR is now a proposal for @amiddavid.

Assisted-By: Claude (Anthropic AI) [email protected]

@vz-ibm

vz-ibm commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator Author

@amiddavid, this PR already does D1 from #1191. The 2 review rounds yesterday added the short lifetime.

  • On a thread the keep-alive cannot ping, a copy is kept only while a warm question is due. If no question is due, no copy is kept.
  • The copy is dropped when the question ends, when no question starts, or when the request was not forwarded.
  • A ping never reads it: the keep-alive, the ping substitute and the fix(keepalive): ping 2 re-writes the whole prefix after a ping 1 that wrote 6 tokens #776 extra request skip a warmOnly copy.
  • The limits stay: 256 threads, the 80k floor. canPing does not change. There is no new Ctx hook.
  • A thread that can ping (Claude Code) keeps today's 30-minute copy.

I merged main (cd90d55) and updated the PR text. Tests and lint pass.

Please confirm that the code matches D1. I mark the PR ready for review now. It does not merge before your yes.

Assisted-By: Claude (Anthropic AI) [email protected]

@vz-ibm
vz-ibm marked this pull request as ready for review November 18, 2026 08:00
amiddavid added a commit that referenced this pull request Nov 25, 2026
test(offload): wait on the condition, not on time

Drop 3 sleeps that waited for nothing, replace 2 hand-made polls with
testutil.WaitFor, and raise one 3 s hang detector to 30 s. Remove 7
tests from the pending timing list. The warm-sweep tests and the modes
tests stay, because open PRs #1193 and #35 change their files.

Test only. Approvals carried over: the head moved only by a merge of main (SAME CHANGE).

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

Copy link
Copy Markdown
Collaborator

Behavior change and data-dependence change: approved by the owner.

David Amid approved both in a session on 2026-11-26: "I approve the behavior". He also asked for this PR to be taken to merge.

Next steps, by the flaky-tests session:

  • Merge main into this branch (157 commits behind; conflicts in extract_sweep_warm_test.go and 2 data-dependence pages). No force-push.
  • Run the review rounds on the new head.
  • Hand it to the integrator.

@amiddavid

Copy link
Copy Markdown
Collaborator

Local tests: waived (owner rule)

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

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 (claude, user of @amiddavid) Claude Code 2.1.332 offload-review skill, @amiddavid's session fresh 2 of 2 4 of 5 a9b4bc9abc5a blocking

Verdict: blocking

The PR's own code is the same as the approved round-3 head (67cb46f). The 2 merges of main resolved it correctly. But main now has the fix for #1191 blocker 2 (#1196) and the end-to-end Bob test (#1192). This PR is the last fix that test waits for, and the test is still skipped. So nothing proves the change works through the proxy on Bob's route.

Findings

  1. proxy/bobsweep_test.go:105-109 — the end-to-end Bob sweep test is still skipped, and its skip text is now false
    • What fails: TestBobUltrahighSweepAsksBobOnALongChat is the only test that drives the warm question through the proxy on Bob's route (bob-ultrahigh, the real canPing, lifecycle.Prepare and lifecycle.Finish). It is skipped with "the sweep cannot ask on Bob's route yet (no copy without a ping; every request cold)". With this PR on current main, both reasons are gone:
      • Blocker 1 ("no copy without a ping") is this PR.
      • Blocker 2 ("every request cold") is fixed on main by 5a8c92c (#1196, merged 2026-11-22).
      • The test comment says: "The fix PRs of #1191 remove this skip."
    • The unit tests use warmRig. They do not cover the host wiring: the order of ClearStaleKeepAliveCandidate (lifecycle/prepare.go:157) against registerPing, and Touch before ResolveWarmQuestion in lifecycle.Finish (lifecycle/finish.go:54-61). I read both orders and I think they are safe: the clear spares an entry written after startedAt. But only the end-to-end test proves it.
    • Proof: git merge-base --is-ancestor 0aa90706 67cb46fc is false: the test came in with the merge of main, after round 3. The PR body still says "This PR alone does not make the sweep act on Bob. Blocker 2 ... still stops the trigger." That was true at round 3. It is not true now.
    • Fix: remove the t.Skip and run go test ./proxy/ -run TestBobUltrahighSweepAsksBobOnALongChat (no -race, as the interim rule says). If it passes, keep it on. If it fails, the failure is a real gap of this PR or of #1191: fix it, or change the skip text to name the true remaining blocker. Update the PR body's Summary to match.

Non-blocking

  • PR banner is out of date. It says "Do not merge until @amiddavid says yes" and "Still needed: his yes that the code matches". The comment of 2026-11-26T11:21:41Z records his yes for both the behavior change and the data-dependence change. Update the banner so the integrator does not stop on it.
  • components/offload/extract_sweep_warm.go:1099-1108: the doc line "warmPending reports whether a trigger is waiting ..." sits above warmDue, not above warmPending. So warmDue has 2 doc lines and warmPending has none. This was already so at 67cb46f. Move the line down.

Earlier findings

  • Reviewer 2, round 1, finding 1 (the ping path read the new copy): still fixed. SweepPingSubstitute (extract_sweep_ping.go:433-435), HasSweepPingCandidate (ping_claim.go:82-83) and ClaimPing (ping_claim.go:116-117) all skip a warmOnly entry. I grepped every reader of sweepPingCand on the new head: lines 282, 328, 331, 383 (prune), 402 (clear stale), 431, the 3 reads in runWarmQuestion, and the 2 in ping_claim.go. main added no new reader.
  • Reviewer 2, round 1, finding 2 / reviewer 1, round 1, finding 1 (30-minute bound): still fixed. The proxy now calls ResolveWarmQuestion from lifecycle.Finish (lifecycle/finish.go:61), inside the deferred finish of serve (proxy/proxy.go:1836-1850). So it still runs on every return path, and every exit of runWarmQuestion drops a warmOnly copy.
  • Both reviewers, round 2, finding 1 (expired due window): still fixed. The first exit (extract_sweep_warm.go:1150-1156) calls dropWarmOnly.
  • Round-2 non-blocking points (ClaimPing, host contract, clear with warm off, bob-plugin): fixed or accepted in round 3. No change since.
  • Data-dependence and behavior change: @amiddavid approved both on 2026-11-26 (PR comment). The 2 row files and the generated page match: the extract_llm_sweep and body-stash lines in docs/data-dependence.md are the same text as the row files.

What I checked

  • Last review: round 3, 67cb46f, 2026-11-17T10:52:43Z
  • New commits read: 2 on the PR branch (first parent), plus 160 commits of main that they bring in:
    • 9ad7551 Merge main into fix/sweep-warm-copy-without-ping
    • a9b4bc9 Merge origin/main into fix/sweep-warm-copy-without-ping
  • Read in full: 6 reviews, 6 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-3 review (10:52:44Z): approve, no findings. Its 2 non-blocking points are the same as mine in round 3.
    • Comment by vz-ibm, 2026-11-17T13:24:46Z (moved to draft, a proposal for @amiddavid): superseded by the later comments.
    • Comment by vz-ibm, 2026-11-18T08:00:21Z (the code does D1; merged main cd90d55): I checked D1 against the code. The warmOnly copy lives only while a question is due or running, and no ping reads it. True.
    • Comment by amiddavid, 2026-11-26T11:21:41Z (behavior and data change approved; merge main, review, hand off): the merge is done. The approval is recorded. See Non-blocking for the stale banner.
    • Comment by amiddavid, 2026-11-26T12:37:15Z (Local tests: waived (owner rule)): noted. It is the interim rule's hand-off line.
  • The full PR diff against the new base e0ad5c5 (10 files). I compared it with the round-3 PR diff: the code lines are the same. Only the context around the test changed, because main added TestAnUnknownPhaseThreadThatReadTheCacheIsWarmForTheWarmPath and TestAHeldWarmAnswerOnAnUnknownPhaseGoesThroughTheWarmGate.
  • The merge resolution of extract_sweep_warm_test.go: the old subtest "keep-alive cannot ping the thread" is gone, the 2 #1196 tests are kept, and the new test sits between them. No test of main still asserts that a warm thread the keep-alive cannot ping never asks. I grepped every CanKeepAlive = func() bool { return false } in the test files (extract_sweep_ping_test.go:568, :849, extract_sweep_v3_test.go:115): all run with warm off, or test the ping path.
  • Host wiring on the new main: lifecycle.Prepare (the stale clear, with startedAt taken before Apply) and lifecycle.Finish (the order of Touch, ResolveDeferredCacheAwareSummary, ResolveWarmQuestion).
  • warmPendingMax is still 5 minutes, and the warm question's outer limit is still CacheAwareSummarizerCallTimeout() (300 s), so the row text "at most 300 seconds after the request" still holds.
  • Host boundary and client rules: the PR adds no logic to a host package (only a comment in proxy/keepalive.go) and no client rule.
  • I did not run Go tests (live tests are not approved here).

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

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 (claude, user of @amiddavid) Claude Code 2.1.332 offload-review skill, @amiddavid's session fresh 1 of 2 4 of 5 a9b4bc9abc5a approve

Verdict: approve

The 2 merges of main keep the PR's own change the same as the approved round-3 head. The merge resolutions are correct. I found no new defect. The owner's yes for the behavior change and the data-dependence change is now recorded on the PR (2026-11-26).

Findings

None.

Non-blocking

  • The banner at the top of the PR body is out of date. It still says "Do not merge until @amiddavid says yes on this PR" and "Still needed: his yes that the code matches". The yes is in the comment of 2026-11-26T11:21:41Z. Update the banner so that the integrator does not stop on it. Use gh api -X PATCH, because gh pr edit does nothing on this repo.
  • The row's decided_by does not name this change. The other changes in the extract_llm_sweep row each have an entry, for example "approved by David Amid 2026-11-22 (#1196)". This PR changes what the row keeps in memory, but adds no entry. Consider adding "the warm question's copy on a thread the keep-alive cannot ping: approved 2026-11-26 (#1193)", then run go run ./cmd/gen-datadep.
  • components/offload/extract_sweep_warm.go:1099: an orphan doc comment. The line "warmPending reports whether a trigger is waiting…" now sits above warmDue, so warmPending (line 1108) has no doc comment and warmDue has 2. Move the line down to warmPending. This was already the case at the round-3 head.
  • "How it was tested" names only the 2026-11-18 run. The new head merges about 160 commits of main. The waiver line is in the 12:37:15Z comment, which check-ready.sh accepts. Say in the body that no test ran on this head, so that no reader thinks it did.

What I checked

  • Last review: round 3, 67cb46f, 2026-11-17T10:52:44Z
  • New commits read: 2 on the PR branch (first parent), and 160 commits of main that they bring in:
    • 9ad7551 Merge main into fix/sweep-warm-copy-without-ping
    • a9b4bc9 Merge origin/main into fix/sweep-warm-copy-without-ping
  • Read in full: 6 reviews, 6 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Comment 2026-11-17T13:24:46Z (PR moved to draft; David owns the sweep): noted. The later comments answer it.
    • Comment 2026-11-18T08:00:21Z (the code matches D1 of #1191): I checked each point against the code. All 5 are true: warmDue gate in registerPing, dropWarmOnly on every exit, warmOnly skipped by SweepPingSubstitute, HasSweepPingCandidate and ClaimPing, no change to canPing, no new Ctx hook.
    • Comment 2026-11-26T11:21:41Z (owner approves the behavior and the data-dependence change): recorded. See the banner point in Non-blocking.
    • Comment 2026-11-26T12:37:15Z (Local tests: waived (owner rule)): accepted under the interim rule.
  • How I checked the merges. I compared the PR's own diff at round 3 (d008870e..67cb46fc) with the PR's diff now (e0ad5c51..a9b4bc9a). The only differences are hunk positions, blob ids, and context lines from main. The code lines that the PR adds and removes are the same. Two places needed a real resolution, and both are correct:
    • runWarmQuestion: main (#1196) added the lastRead update before the first exit. The merge keeps it, and the PR's dropWarmOnly call stays after warmMu.Unlock(). The lock order is unchanged: warmMu is released before sweepPingMu is taken.
    • extract_sweep_warm_test.go: TestAWarmThreadTheKeepAliveCannotPingStillAsks now sits after the #1191 test, and TestAnUnpingableWarmCopyLivesOnlyForItsQuestion and TestAThreadWithNoRegistryCopyNeverAsksAWarmQuestion follow the #1196 test. Each of the 3 functions is defined once. No test name is duplicated.
  • What main changed around the PR:
    • ResolveWarmQuestion moved from the proxy to lifecycle.Finish (lifecycle/finish.go:61). The proxy calls lifecycle.Finish in the deferred finish of serve (proxy/proxy.go:1850), so it still runs on every return path. apply/opts.go:61 documents the call. So every exit that drops a warm-only copy is still reached.
    • The readers of sweepPingCand are the same as at round 3: extract_sweep_ping.go (register, prune, clear, clear-stale, SweepPingSubstitute), extract_sweep_warm.go (runWarmQuestion), ping_claim.go (HasSweepPingCandidate, ClaimPing). main adds no new reader. The keeper's new value rule (#1444) reaches the registry only through SweepPingSubstitute, HasSweepPingCandidate and ClaimPing (keepalive/keeper.go:2593, 2604, 2657; keepalive/substitute.go:465), and all 3 skip a warmOnly entry.
    • CanKeepAlive has no new reader in components/. The Responses route (apply/responses.go:621) sets it the same way as the Chat route.
    • canPing (proxy/keepalive.go) now returns keepalive.CanKeepAlive(...). The PR changes only its comment there.
  • Data dependence: the where and off lines of extract_llm_sweep.md and the body-stash text are in docs/data-dependence.md word for word (checked with a script). Kind stays content.
  • No binary, no go.mod change, no client rule, no new host logic (the proxy change is a comment).
  • I did not run Go builds or tests. Live tests are not approved for this review.

Blocker 1 (this PR) and blocker 2 (#1196) of #1191 are both on the
branch, so the skip in TestBobUltrahighSweepAsksBobOnALongChat goes.

- The chat runs 45 turns. The first check is at turn 30 and finds the
  grep, so one question goes out. A 64-turn chat sees a second one at
  turn 60, because the stub's reply is unusable and no answer is held.
- Each run uses its own task id. The warm state is process-wide, so
  -count=N in one process failed on the second run.
- TestStatsRendersPerComponentExtractionAttribution now checks
  cost_source "none" only when the baseline row has none. The Bob test
  prices a call in the process-wide counter.
- Move the warmPending doc line back above warmPending.

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

Copy link
Copy Markdown
Collaborator

Fixed in 33c4129. The end-to-end Bob test is on and passes.

  • Skip removed. One question goes to Bob at turn 30, through the real canPing, lifecycle.Prepare and lifecycle.Finish. 5 of 5 runs pass, without -race.
  • Test changes, because the skip hid them:
    • The chat runs 45 turns, not 64. At 64 turns a second question goes out at turn 60: the stub's reply is unusable, so no answer is held and the next check asks again.
    • Each run uses its own task id. The warm state is process-wide, so -count=5 in one process failed on run 2.
    • TestStatsRendersPerComponentExtractionAttribution checks cost_source "none" only when the baseline has none. It failed in the full ./proxy/ run once the Bob test priced a call.
  • Doc line moved: the warmPending comment is back above warmPending.
  • PR body: Summary updated. The behavior-change block is unchanged.

go test ./proxy/ (no -race) passes. ./components/offload/ passes.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

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 (claude, user of @amiddavid) Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 2 of 2 5 of 5 33c4129fee36 approve

Verdict: approve

My round-4 finding is fixed. The Bob end-to-end test is on, and the author reports that it passes 5 of 5 runs. The new commit changes no production logic. I found no new defect.

Findings

None.

Non-blocking

  • The PR banner is still out of date. It still says "Do not merge until @amiddavid says yes" and "Still needed: his yes that the code matches". The author's reply says the block is "unchanged" on purpose. But the yes is in the comment of 2026-11-26T11:21:41Z. Add one line to the banner that points to that comment, so the integrator does not stop on it. Reviewer 1 raised the same point in round 4.
  • proxy/extract_attribution_test.go:112 — the new guard skips the cost_source check when the baseline is not "none". It does not check that the value stays the same as the baseline. tail.CostSource == baseTailSource would keep a check in both cases. The checks on calls and cost against the baseline (lines 89-99) still guard #176, so this is minor.

Earlier findings

  • Reviewer 2, round 4, finding 1 (the Bob end-to-end test is still skipped): fixed in 33c4129.
    • The skip and the old 2-blocker text are removed (proxy/bobsweep_test.go:107-109).
    • The test now goes through the real canPing, lifecycle.Prepare and lifecycle.Finish on Bob's route. That covers the host wiring that the unit tests do not.
    • The PR Summary now says that this PR, with #1196, makes the sweep act on Bob.
    • The 45-turn change is explained: at 64 turns a second check at turn 60 asks again, because the stub's 2-byte reply holds no answer. The test still asserts exactly 1 question, the chat's model, Bob's model path and the Apikey scheme. 45 turns stay below the next check at turn 60, so the "exactly 1" assertion is sound.
    • The task id is unique per run (bobSweepRuns), because the warm state is process-wide. This is correct for -count=N.
    • I did not run it. Live tests are not approved for this review. I rely on the author's report.
  • Reviewer 2, round 4, non-blocking (the orphan warmPending doc line): fixed. The line now sits above warmPending (extract_sweep_warm.go:1107).
  • Reviewer 1, round 4, non-blocking points:
    • Banner: not fixed. See Non-blocking.
    • decided_by entry for this change: not added. The approval is recorded in the PR comment. I leave it to the author.
    • Doc line: fixed.
    • "How it was tested": the author's reply names go test ./proxy/ and ./components/offload/ on the new head.
  • All earlier findings of rounds 1 to 3: still fixed. The new commit does not touch extract_sweep_ping.go, ping_claim.go or the logic in extract_sweep_warm.go.

What I checked

  • Last review: round 4, a9b4bc9, 2026-11-26T12:40:14Z
  • New commits read: 1 (33c4129 test(proxy): turn on the Bob end-to-end sweep test)
  • Read in full: 8 reviews, 7 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 1's round-4 review (2026-11-26T12:42:23Z): approve. I checked its 4 non-blocking points. See "Earlier findings".
    • The author's reply (2026-11-26T12:58:46Z): I checked each claim against 33c4129: the skip is removed, the run is 45 turns, there is a task id per run, the attribution test guard is new, the doc line is moved, and the Summary is updated. All are true. The claim that the tests pass is the author's, and I did not run them.
  • The full diff of 33c4129 (3 files): extract_sweep_warm.go (comment move only), proxy/bobsweep_test.go, proxy/extract_attribution_test.go. I also read the code around each change: the whole Bob test with its assertions, and the whole attribution test with its baseline reads.
  • The PR body, read from the server: the Summary is updated. The banner is unchanged.
  • The commit has the DCO sign-off and Assisted-By. There is no binary and no go.mod change.
  • I did not run Go builds or tests. Live tests are not approved for this review.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator

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 (claude, user of @amiddavid) Claude Code 2.1.332 offload-review skill, @amiddavid's session resumed 1 of 2 5 of 5 33c4129fee36 approve

Verdict: approve

The new commit fixes reviewer 2's round-4 finding. The end-to-end Bob test is now on. The test changes that came with it are correct. The sweep code is the same as in round 4, except for one moved doc line. I found no new defect.

Findings

None.

Non-blocking

  • The banner at the top of the PR body is still out of date (my round-4 point, and reviewer 2's). It still says "Do not merge until @amiddavid says yes on this PR" and "Still needed: his yes that the code matches". The author's reply says "The behavior-change block is unchanged". The yes is in the comment of 2026-11-26T11:21:41Z. Add one line to the banner that points to that comment, so that the integrator does not stop on it. Use gh api -X PATCH.
  • The row's decided_by still has no #1193 entry (my round-4 point). The author did not answer it. This is a record, not a defect, and the PR comment holds the yes. Add the entry in this PR, or say in a reply why you leave it out.

Earlier findings

  • Reviewer 2, round 4, finding 1 (the end-to-end Bob test is still skipped): fixed. The t.Skip and its false text are gone (proxy/bobsweep_test.go:106-107). The test drives the real canPing, lifecycle.Prepare and lifecycle.Finish. The author reports 5 of 5 passes without -race. The PR Summary now says that this PR, together with #1196, makes the sweep act on Bob.
  • Reviewer 1 and reviewer 2, round 4, non-blocking (orphan warmPending doc line): fixed. The line now sits above warmPending (extract_sweep_warm.go:1107), and warmDue has only its own line.
  • Reviewer 1, round 4, non-blocking ("How it was tested" names only the 2026-11-18 run): fixed. The reply gives the run on this head: go test ./proxy/ (no -race) and ./components/offload/ pass.
  • All findings of rounds 1 to 3: still fixed. The new commit does not touch extract_sweep_ping.go, ping_claim.go or runWarmQuestion.

What I checked

  • Last review: round 4, a9b4bc9, 2026-11-26T12:42:23Z
  • New commits read: 1
    • 33c4129 test(proxy): turn on the Bob end-to-end sweep test
  • Read in full: 8 reviews, 7 comments, 0 inline comments (from the three files)
  • New items since my last review:
    • Reviewer 2's round-4 review (12:40:14Z, blocking): its finding (the skipped end-to-end test) and 2 non-blocking points (banner, doc line). The finding is fixed. The doc line is fixed. The banner is not fixed (see Non-blocking).
    • The author's reply (12:58:46Z): I checked each claim against the commit. The skip is gone. The chat is 45 turns. Each run has its own task id. The attribution test compares with the baseline. The doc line is moved. The Summary is updated. The banner is not changed, as the reply says.
  • The diff of 33c4129 (3 files), read in full, with the code around it:
    • proxy/bobsweep_test.go. The skip and the blocker list are gone. The 45-turn length agrees with the assertions. WaitForState waits for at least 1 question. Then the test asserts exactly 1, with the model premium-ide, Bob's model path and the Apikey scheme. No request comes after turn 45, so no second question can start. The next check is due at turn 60, so == 1 is not a race. The test waits on a condition, not on time, so timingguard has nothing to flag.
    • The per-run task id (bobSweepRuns atomic counter) is right. The warm state (warmThreads) and the registry are process-wide and keyed by thread, so -count=N would reuse the request count of run 1. Without t.Parallel, the counter gives each run a fresh thread.
    • proxy/extract_attribution_test.go: the cost_source == "none" check now runs only when the baseline row has none. The check is the same as before when this test runs alone. With the Bob test before it, metrics.ExtractSnapshot already holds a priced extract_llm call, so the old check failed for a reason that is not #176. The calls and cost checks still subtract the baseline, so the test still proves its claim.
    • components/offload/extract_sweep_warm.go: only the doc line moves. No code change.
  • No row or generated-page change in this commit. No go.mod change, no binary, no client rule. The host change is test code only.
  • I did not run Go builds or tests. Live tests are not approved for this review.

@amiddavid
amiddavid merged commit e2d4177 into main Nov 26, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from New/ToDo to Done in Rossoctl Issue Prioritization Nov 26, 2026
@amiddavid

Copy link
Copy Markdown
Collaborator

@vz-ibm this PR is merged, as e2d4177. Thank you.

  • To bring it up to date, I merged main into the branch. I pushed no force-push. The merge resolved 3 conflicts: extract_sweep_warm_test.go and 2 data-dependence pages.
  • I turned on the end-to-end test TestBobUltrahighSweepAsksBobOnALongChat and fixed 3 test-side problems that its skip had hidden. The details are in the comments above.
  • David Amid approved the behavior change and the data-dependence change.

amiddavid added a commit that referenced this pull request Nov 26, 2026
#1463)

test(offload): the warm-sweep tests wait on the condition, not on time

Three warm-sweep tests used fixed 5 s polls or a tiny real-time bound.
They fail on a loaded machine.

- The two-asker and shared-read-rule tests wait with testutil.WaitFor.
  The rig gets one waitIdle helper, which forward also uses.
- The outer-timeout test keeps an always-on check that all 3 batches
  run. Its 3-batches-over-one-bound check is time by design: it is
  gated with RequireTiming and uses 10x wider margins.
- Remove the 3 tests from the pending list and lower the timing
  baseline.
- Add #1193 to the decided_by line of extract_llm_sweep.

test(offload): check the warm sweep's outer deadline without waiting

The timing subtest of the outer-timeout test slept in the asker and
ignored its context, so it did not test the outer bound at all.

- The asker now records the time left on its context.
- With one question's bound set far above the outer one, the first
  deadline is the outer deadline. The test checks that it is the
  keeper's timeout, and that the keeper's timeout is at least 3
  questions long. No sleep, no gate.

Test only, plus the #1193 approval added to the extract_llm_sweep row's decided_by line (a record, no data-dependence change). No behavior change.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
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.

2 participants