Skip to content

feat(keepalive): share the ping with the summary call (#404 point 10) - #688

Merged
amiddavid merged 1 commit into
mainfrom
feat/sweep-ping-share
Oct 25, 2026
Merged

amiddavid merged 1 commit into
mainfrom
feat/sweep-ping-share

Conversation

@amiddavid

@amiddavid amiddavid commented Oct 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

What changed

  1. One choice, one guard. New offload.ClaimPing(threadKey) in components/offload/ping_claim.go. It returns summary, sweep, none or plain, and it holds the thread until Release().
  2. The rule, per thread:
    • The summarizer has a registered candidate: summary owns the ping. If the sweep also had a candidate, sweep_summary_owned_ping +1. This also counts pings where the summary then declined.
    • Only the sweep registered: sweep may ask.
    • A summary is already running on the thread: plain ping, sweep_summary_in_flight +1.
    • The thread is already claimed by an earlier slow call: plain ping, sweep_ping_thread_busy +1.
  3. Keeper. fire() calls fireSubstitute, which calls ClaimPing once, runs what the claim names, and frees the claim with a defer. A panic frees the thread too.
  4. Cold apply hook for PR C. offload.ColdApplyPhase(phase) is the summary reserve's own graduation test (cacheAwareApplyPhase): cold or unknown. This PR builds no sweep apply.
  5. Stats and docs. sweep_summary_owned_ping, sweep_summary_in_flight and sweep_ping_thread_busy in /stats, and in the "Counted at the ping" paragraph of docs/components/advanced-offload.md.
  6. The no_candidate counters now count only the lookups that run. A ping whose claim goes to the sweep alone does not look the summary up, so summarySubstituteNoCandidate does not rise.
  7. Summary behavior with the sweep off is unchanged. Its tests pass unchanged.

How it was tested

Eval box 1, -count=1. gofmt and go vet ./... clean. go test ./...: 41 packages ok, 0 failed. -race passes on keepalive and components/offload.

ID Test
S1 (trigger fires) TestWhenTheSummarizerTriggerFiresTheSummaryTakesThePingAndTheSweepDoesNotAsk (keepalive)
S1 (trigger does not fire) TestWhenTheSummarizerTriggerDoesNotFireTheSweepAsks (keepalive)
Summary declines TestWhenTheSummaryDeclinesTheSweepStillDoesNotAskAndAPlainPingGoesOut (keepalive): 1 ordinary ping, 0 sweep asks, owned-ping +1
One ping, never both, 2 threads due TestOnePingNeverRunsBothCallsWithTwoThreadsDue (keepalive)
Claim and slot freed on every exit TestAClaimedPingFreesTheThreadAndTheSlotOnEveryExit (keepalive)
Per-thread choice TestClaimPingChoosesPerThread (offload)
One holder per thread, busy counted TestClaimPingAllowsOneHolderPerThread, TestClaimPingRaceHasOneWinner (16 goroutines)
Summary running TestClaimPingGivesTheSweepNothingWhileASummaryRuns
Cold apply hook TestColdApplyPhaseIsTheSummaryReservesRule
Summary first (PR A) TestKeepAliveSummaryTakesThePingBeforeTheSweep

Mutation checks (each made a test fail, then restored):

  • sweep wins over the summary
  • owned-ping not counted
  • busy guard removed
  • in-flight check removed
  • Release does not free the thread
  • keeper runs the sweep as well as the summary
  • claim release not deferred
  • sweep asks after the summary declines (fails the new decline test)
  • busy not counted

Open questions

None.

Technical notes

  • Rebased onto main c7da735 (feat(sweep): ask at the keep-alive ping, hold the answer, recheck, shadow mode #508 squashed). The PR keeps one commit. The diff against feat(sweep): ask at the keep-alive ping, hold the answer, recheck, shadow mode #508's head was checked equal before the fixes.
  • Why no second trigger check at the ping. The summarizer registers a candidate only after trigger.Fires passed on the thread's last request. Nothing changes between that request and the ping, so a registered candidate already means "the trigger fired".
  • Slot and claim. The claim is taken first and freed by a defer in fireSubstitute. The sweep's collection slot is freed by a defer in SweepPingSubstitute. A ping holds neither after the call.
  • Known gap, for PR C. The in-flight check is check-then-act. A detached summary that a real request starts after the look can overlap the sweep's question. The summary's single-flight and the sweep's asked flag still stop two of the same kind. PR C decides whether to take the summary's flight in ClaimPing.

Part of #404.

@amiddavid
amiddavid force-pushed the feat/sweep-cold-ask branch 2 times, most recently from cea7b42 to 0211b4d Compare October 25, 2026 09:31
@amiddavid
amiddavid force-pushed the feat/sweep-ping-share branch from d9506f9 to f995427 Compare October 25, 2026 09:44
@amiddavid
amiddavid force-pushed the feat/sweep-cold-ask branch from 0211b4d to 173180d Compare October 25, 2026 10:42
@amiddavid
amiddavid force-pushed the feat/sweep-ping-share branch from f995427 to 315d9ea Compare October 25, 2026 11:45
@amiddavid
amiddavid changed the base branch from feat/sweep-cold-ask to main October 25, 2026 11:50

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 315d9ead01fe blocking

Verdict: blocking

Findings

  1. keepalive/keeper.go:1779 — the new fail-open path of the priority rule has no test: a summary candidate that declines must still send the ordinary ping and must not let the sweep ask.

    • What fails: the PR's central rule changes behavior here. Before, a declined summary fell through to the sweep. Now the sweep must not ask, and the ordinary ping must go out. No test covers this combination. TestKeepAliveSubstituteFallsBackToPingOnFailure has no sweep candidate. S1 and TestKeepAliveSummaryTakesThePingBeforeTheSweep use a summary that succeeds. So a regression on this path — the sweep asking after a declined summary, or a lost ping — passes the whole suite.
    • Proof: I listed every kaCandidate* call site (substitute_test.go:83, 118, 149, 189, 324, 358, 417, 581, 628; sweepsubstitute_test.go:264, 400, 452). None pairs a failing or declining summary model with a registered sweep candidate.
    • Fix: add one keeper test. Register both candidates. Give the summary model an error. Assert: 1 ordinary ping, 0 sweep asks, sweep_summary_took_ping +1.
  2. keepalive/keeper.go:1575 — the two new /stats counters are not in the counters documentation.

    • What fails: an operator reads "did it fire at all?" from the listed plain-ping reasons. docs/components/advanced-offload.md:522 and :578 list sweep_no_inventory, sweep_already_asked, sweep_model_declined, sweep_ask_needs_shadow, sweep_concurrency_full as the reasons a ping stayed plain. sweep_summary_took_ping and sweep_summary_in_flight are two new reasons of the same class, and they are documented nowhere. The repo's own config doc says unexplained counters invite an invented reading.
    • Proof: grep -rn "sweep_summary_took_ping" docs/ returns nothing. The doc section names every other plain-ping reason.
    • Fix: add both counters to the "Counted at the ping" list in docs/components/advanced-offload.md, with one line each saying what they mean.
  3. PR #688 description — the PR does not state its data dependence, as CLAUDE.md requires for every PR that changes a feature.

    • What fails: CLAUDE.md says every PR that adds or changes a feature states its data dependence at each storage level. The PR changes the keep-alive substitute feature and states no dependence. The claim map is metadata only, in memory, and no doc row needs to change — but the PR must say so.
    • Proof: the PR body's "What changed" and "Technical notes" describe behavior and counters. Neither mentions data dependence.
    • Fix: add one line to the PR description: "Data dependence: none added. The claim reads registry existence (metadata, in memory) and stores nothing."

Non-blocking

  • components/offload/ping_claim.go:85 — the inFlight.peek check is check-then-act. A detached summary can start on the request path after the peek, and then run while the sweep question runs. The new comment in keeper.go:1245 ("never race on one thread") is stronger than the code. Today the overlap is harmless: both calls only read the prefix, and the store writes use different keys. Tighten the comment, or the check, before PR C makes the overlap matter.
  • components/offload/ping_claim.go:100 — a PingNone claim is released before the two lookups run. A candidate registered in that window can take a sweep slot with no claim held. The PR body says a thread never holds a slot without its claim. The window is narrow and the asked flag and single-flight still protect the thread.
  • The no_candidate counters now count fewer pings. When one component owns the ping, the other's lookup no longer runs. summarySubstituteNoCandidate and sweepPingNoCandidate therefore undercount against the old meaning. The PR body notes the none claim runs both lookups, but not that the counters narrowed.
  • pingGuardBusy is keyed by thread.Key(session, thread), with no tenant. Two tenants that share a session id force each other to plain pings. The candidate registries use the same key, so this is a pre-existing pattern, and the failure is fail-open.
  • ColdApplyPhase is exported for PR C and unused in this PR.
  • ping_claim_test.go:118 — for claimed.Load() < 16 {} spins with no runtime.Gosched(). Go's preemptive scheduler makes it safe; a yield would be kinder to a single-CPU test box.

What I checked

  • The full diff of 315d9ea against 8f06983: all six files, every changed line.
  • ping_claim.go against what it guards: keepAliveCand and sweepPingCand registries, inFlight (summarize_async.go), sweepSlots. Keying is consistent (thread.Key(session, thread) everywhere). Locks never nest. Release is idempotent and safe on a plain claim.
  • Fail-open: every claim choice ends in an ordinary ping or a substitute. The claim is released by a defer, so a panic frees the thread. A busy thread sends a plain ping. No path loses a ping.
  • Slot lifecycle: the sweep's collection slot is taken and freed inside SweepPingSubstitute on every exit; the ask takes its own slot. Confirmed the PR body's claim.
  • The priority rule against #404 point 10 and the PR body: summary first, one substitute per ping, no fall-through to the sweep. The behavior matches the stated design.
  • Stats wiring: SweepPingCounters reads the new atomics; Keeper.Stats maps them; JSON tags are additive, no rename, so the /stats append-only contract holds.
  • Tests: read all new tests and the shared helpers (testKeeper inline runner, registerSweep, kaCandidate, waitPings). Traced the scenarios by hand; they test what they claim.
  • Docs: docs/design.md, docs/data-dependence.md (sweep and keep-alive rows), docs/components/advanced-offload.md counters section.
  • The PR body, the single commit's DCO sign-off and Assisted-By: line.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 315d9ead01fe blocking

Verdict: blocking

Findings

  1. docs/components/advanced-offload.md:522 — the two new /stats counters are not documented
    • What fails: the PR adds sweep_summary_took_ping and sweep_summary_in_flight to the keeper's Stats (keeper.go:1576-1580, filled at keeper.go:1638-1639, json tags sweep_summary_took_ping / sweep_summary_in_flight). The component doc lists every other ping-time counter and says each "names a reason the ping stayed plain" (advanced-offload.md:522-552). The two new reasons are absent. An operator who sees these counters in /stats has no doc that explains them. The doc itself makes the case: "counters with no explanation invite an invented reading" (advanced-offload.md:510).
    • Proof: grep -rn "sweep_asked\|sweep_model_declined" docs/ hits only advanced-offload.md:522-552; neither new name appears anywhere under docs/.
    • Fix: add both counters to the "Counted at the ping" list at line 548, one sentence each: took-ping = the summarizer's trigger fired so the summary owned the ping; in-flight = a summary was already running for the thread.

Non-blocking

  • ping_claim.go:86-88 — the summary "owns" the ping on registration, not on use. keepAliveCand is re-registered on every turn with commission material (cache_aware_summarizer.go:886-895), even after a checkpoint exists. So when the summary substitute itself declines (checkpoint exists, over budget, phase mismatch, in flight, call failed), the sweep no longer asks and a plain ping goes out. Before this PR the sweep asked in those cases. This matches #404 point 10 as written, and the skip is counted, so I read it as intended. Worth a line in the PR description, because it is a real capability change on summarizer-active threads.
  • ping_claim.go:153-155 — sweep_summary_took_ping counts the skip even when the summary then declined the ping too. The name says "took"; the refusal reason lives only in the keeper's summarySubstitute* counters. Consider naming or doc wording that says "owned" rather than "took".
  • keeper.go:410-414 — the summarySubstituteNoCandidate comment is now too broad. A ping where only the sweep registered no longer runs the summary lookup, so that counter does not count it. The PingNone doc in ping_claim.go states the new rule correctly; the keeper comment does not.
  • No counter for a busy thread. A ping that stays plain because an earlier substitute still holds the claim (ping_claim.go:62-65) is counted nowhere. Every other plain-ping reason has a counter.
  • ping_claim.go:93 — the in-flight check is one-way. A detached summary started by a real request after ClaimPing's inFlight.peek can still run concurrently with the sweep's ask. The guard narrows the race; it does not remove it. The file comment "never race on one thread" (keeper.go:1245) overstates this.
  • ping_claim.go:107 — ColdApplyPhase is exported ahead of PR C. No non-test caller exists on this head. Fine as scaffolding for the series; remove it if PR C slips.
  • sweepsubstitute_test.go:445-447 — sumB is never registered, so the sumB.calls == 0 assertion is vacuous. It cannot fail. Register it as thread B's summary model, or drop it.
  • ping_claim_test.go:125 — for claimed.Load() < 16 {} spins with no sleep or runtime.Gosched. It terminates (async preemption), but every other wait in these files sleeps. Match the file's idiom.

What I checked

  • Read CLAUDE.md, docs/design.md, and the full diff of the one commit (315d9ea) against base 8f06983.
  • Traced fire → fireSubstitute → ClaimPing → fireSummarySubstitute / fireSweepSubstitute (keeper.go:1213-1306, 1774-1786; substitute.go:67-335) and checked every decline path falls back to the ordinary ping. Fail-open holds on all paths I traced, panic paths included (deferred claim.Release() runs first in fireSubstitute; the sweep's own recover in SweepPingSubstitute and fireSweepSubstitute is unchanged).
  • Checked lock discipline: pingGuardMu, keepAliveCandMu, sweepPingMu and summaryFlight.mu are taken one at a time, never nested; the claim is a map entry held with no mutex across the substitute call. No deadlock path found.
  • Verified key agreement: thread.Key(session, thread) is the key for keepAliveCand (cache_aware_keepalive.go:177), sweepPingCand (extract_sweep_ping.go:282), inFlight (convKey, state.go:523) and the new guard. Session keys are tenant-scoped (session.Scoped), so no cross-tenant collision in the new pingGuardBusy map.
  • Verified the claim's value is real: a summary-substitute call can outlive the keeper's idle interval (300 s call vs 280 s idle), so a later ping on the same thread can arrive while a substitute runs; before this PR that ping could start a sweep question concurrent with a summary on one thread. The guard closes exactly that.
  • Checked counter wiring end to end: sweepSummaryTookPing / sweepSummaryInFlight → SweepPingStats (extract_sweep_ping.go:187) → keeper Stats() json fields. Field reorder in Stats changes no json names; no golden test parses that order.
  • Checked the new tests against the mechanics: S1 both directions, the two-thread case, the busy/in-flight/single-holder/race cases in ping_claim_test.go, and the slot-release test. All helpers used exist; imports are present; the wait loops and assertions line up with the code paths they name. Existing tests that register both candidates (TestKeepAliveSummaryTakesThePingBeforeTheSweep) stay valid under the new rule.
  • Read issue #404 for point 10's wording and the S1 acceptance test; the implementation matches both, and S1 is covered by tests in both directions.
  • Confirmed no data-dependence change: the PR stores nothing new and reads no stored content beyond what the substitutes already read.
  • Did not run builds or tests (not approved). Go is not installed on this machine.

…nt 10)

A due ping can be replaced by the summary call or the sweep question.
ClaimPing is now the single per-thread choice and single-call guard for
both. When the summarizer's trigger fired (it registered a candidate),
the summary takes the ping and the sweep does not ask. The skip is
counted as sweep_summary_took_ping. A summary already running counts
as sweep_summary_in_flight. A thread is held until the attempt ends,
so 2 calls never run at one ping for one thread.

ColdApplyPhase exposes the summary reserve's cold-apply test for the
sweep's cold apply.

Summary behavior with the sweep off is unchanged.

Assisted-By: Claude Opus 5.5
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid
amiddavid force-pushed the feat/sweep-ping-share branch from 315d9ea to edd46ef Compare October 25, 2026 12:33
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1: replies to every finding

Fixed

  • R1-1 Added TestWhenTheSummaryDeclinesTheSweepStillDoesNotAskAndAPlainPingGoesOut: both candidates, summary model fails. It checks 1 ordinary ping, 0 sweep asks, owned-ping +1. A mutation where the sweep asks after the summary declines fails it.
  • R1-2, R2-1 docs/components/advanced-offload.md, "Counted at the ping": sweep_summary_owned_ping, sweep_summary_in_flight and sweep_ping_thread_busy are documented.
  • R1-3 The PR body now says: "Data dependence: none added. The claim reads registry existence (metadata, in memory) and stores nothing."
  • R2 Renamed sweep_summary_took_ping to sweep_summary_owned_ping. It has not shipped. It is documented as "the summarizer had a candidate, so it owned the ping, and the sweep did not ask".
  • R2 The PR body says plainly what changes: where the summarizer is active, the sweep no longer asks when the summary declines (extract_llm_sweep fires at the wrong moment and loses money; ask at the keep-alive ping and apply when cold #404 point 10).
  • R2 New counter sweep_ping_thread_busy for a ping that stays plain because an earlier substitute holds the claim. A mutation (not counted) fails TestClaimPingAllowsOneHolderPerThread.
  • R1, R2 The "never race on one thread" comment is corrected in keeper.go and ping_claim.go. The in-flight check is check-then-act, so a detached summary that a real request starts after the look can overlap the sweep's question. Noted in the PR body for PR C.
  • R2 The summarySubstituteNoCandidate comment now says it counts only when the summary lookup runs. The PR body notes the same for the no_candidate counters.
  • R2 sumB was vacuous. Registering it on thread B would make B a summary thread and remove the sweep ask the test checks. I removed it and the assertion. Thread A's summary call count stays asserted.
  • R1, R2 The spin loop in ping_claim_test.go now calls runtime.Gosched().

Not changed

  • R1 The PingNone release window is narrow. If a candidate registers between the claim and the lookups, asked and the summary's single-flight still protect the thread from two calls of one kind.
  • R1 The tenant-less pingGuardBusy: R2 checked that session keys are tenant-scoped, so two tenants cannot share a key.
  • ColdApplyPhase stays exported. PR C is being built now and calls it.

Tests on eval box 1 (-count=1): go test ./... 41 ok, 0 failed. -race passes on keepalive and components/offload. 9 mutations each fail a test. The PR is based on main c7da735 and retargeted to main.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 2 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 edd46effc5f3 approve

Verdict: approve

Findings

None. Every round-1 finding is fixed, and the fix commit adds no new defect.

Earlier findings

  • Mine, finding 1 (two new counters undocumented): fixed. docs/components/advanced-offload.md:550-553 now documents sweep_summary_owned_ping, sweep_summary_in_flight and sweep_ping_thread_busy, each with one sentence saying what it means. The wording matches what the code counts.
  • Reviewer 1, finding 1 (no test for the declined-summary path): fixed. TestWhenTheSummaryDeclinesTheSweepStillDoesNotAskAndAPlainPingGoesOut registers both candidates, gives the summary model an error, and asserts 1 ordinary ping, 0 sweep asks, 0 sweep substitutions, owned-ping +1. I traced it by hand: the claim picks the summary, commissionSync returns Committed: false on the model error, fire falls through to the ordinary ping. The assertions match that path. Helpers and the err field on fakeSummaryModel exist; errors is imported.
  • Reviewer 1, finding 2 (docs): fixed. Same doc change as my finding 1.
  • Reviewer 1, finding 3 (no data-dependence statement): fixed. The PR body now says "Data dependence: none added. The claim reads registry existence (metadata, in memory) and stores nothing." I read the body and confirmed the line, plus a plain statement of the decline behavior change.
  • My non-blocking items: all addressed. The counter is renamed sweep_summary_owned_ping (complete rename, no old name left anywhere in the repo; it had not shipped). The summarySubstituteNoCandidate comment now says the lookup must run for it to count (keeper.go:409-414). The busy thread has its own counter, sweep_ping_thread_busy, wired end to end (ping_claim.go:55,83 → extract_sweep_ping.go:190 → keeper.go:1646) and asserted in TestClaimPingAllowsOneHolderPerThread. The "never race" comments in keeper.go:1246-1248 and ping_claim.go:28-32 now state the check-then-act gap honestly and hand the decision to PR C. sumB is removed — the author's reason is right: registering a summary on thread B would make B a summary thread and remove the sweep ask the test exists to check. The spin loop now calls runtime.Gosched().
  • ColdApplyPhase stays exported: accepted. The author says PR C is being built now and calls it. That was always its stated purpose.
  • Reviewer 1's "not changed" items: accepted. The PingNone release window is protected by the asked flag and the summary's single-flight, as the reply says. The tenant-scoping of session keys is what I verified myself in round 1.

Non-blocking

  • ping_claim.go:83 — the busy counter counts only claims that reach ClaimPing. A ping refused earlier (no spare slot, k.spare in fire) never claims, so it is not in this counter either. That is consistent with the other plain-ping reasons, which also count only inside the substitute decision. No change needed; noting it so the counter's denominator is clear.

What I checked

  • Last review: round 1, 315d9ea, 2026-10-25T11:54:39Z.
  • New commits read: 2. c7da7351 is the retargeted base — its tree is byte-identical to the old base 8f069839 (verified: git diff 8f069839 c7da7351 --stat is empty), so the retarget introduces no new code. edd46eff is the point-10 commit, rewritten with the fixes; I read its full diff against both the new base and my round-1 head (git diff 315d9ead edd46eff, 97 insertions, 37 deletions, 6 files).
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from .review-in-reviews.txt, .review-in-comments.txt, .review-in-inline.txt).
  • New items since my last review: reviewer 1's round-1 review (posted one second before mine, so I read it only now — its findings overlap mine and one adds the missing decline test); the rewritten head commit with the fixes; the author's reply comment of 2026-10-25T12:34:25Z. I checked each reply claim against the code: the doc lines, the rename, the busy counter wiring, the new test's assertions, the sumB reasoning, the Gosched fix, and the PR body's data-dependence line. All are as stated.
  • Re-checked the fix diff for new defects: the busy counter sits on the busy exit only; the rename touched every declaration, mapping and test; the new test uses existing helpers and imports; the corrected comments match the code's actual behavior.
  • Did not run builds or tests (not approved). Go is not installed on this machine. The author reports go test ./... 41 ok and -race clean on the two touched packages, plus 9 failing mutations; I could not verify that myself.

@amiddavid amiddavid left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewer Kind Started by Context Review Round Head Verdict
Reviewer 1 (glm, user of @amiddavid) GLM rits/zai-org/glm-5-3 via Claude Code 2.1.310 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 edd46effc5f3 approve

Verdict: approve

Findings

None. The reworked commit fixes every finding from both reviewers and adds no new defect.

Status of earlier findings

Mine, round 1:

  1. Missing test for the declined-summary path — fixed. TestWhenTheSummaryDeclinesTheSweepStillDoesNotAskAndAPlainPingGoesOut (sweepsubstitute_test.go:515) registers both candidates, fails the summary model, and asserts 1 ordinary ping, 0 sweep asks, sweep_summary_owned_ping +1. I traced it: the claim goes to PingSummary, commissionSync runs the model once, the error declines the commit, fire falls through to the ordinary ping. The assertions match that path. The "sweep asks after the summary declines" mutation would fail it.
  2. Undocumented counters — fixed. docs/components/advanced-offload.md:550-553 now documents sweep_summary_owned_ping, sweep_summary_in_flight and sweep_ping_thread_busy, each with its meaning.
  3. No data-dependence statement — fixed. The PR body now says: "Data dependence: none added. The claim reads registry existence (metadata, in memory) and stores nothing." That matches the code.

Reviewer 2, round 1:

  • R2-1 (docs, same as my finding 2) — fixed. Checked myself; see above.
  • Non-blocking items — addressed: sweep_summary_took_ping renamed to sweep_summary_owned_ping (the name now matches the "owned, not took" semantics); new sweep_ping_thread_busy counter, tested in TestClaimPingAllowsOneHolderPerThread; the "never race on one thread" comment corrected in both files; the summarySubstituteNoCandidate comment now states the lookup rule; the vacuous sumB removed; runtime.Gosched() added to the spin loop.
  • Declined with a reason, checked by me:
    • PingNone release window stays open. I agree. The window is narrow, asked and the summary's single-flight still prevent two calls of one kind, and the gap is now documented in ping_claim.go and the PR body for PR C.
    • Tenant-less pingGuardBusy key. The reason is right and my round-1 note was wrong. I verified it myself: apply.sessionIDFrom (apply.go:1367) builds the session id through session.Scoped(tenant, ...) (session.go:151), which prefixes the tenant id, and the proxy records threads with that scoped id (proxy/keepalive.go:378). Two tenants cannot share a thread.Key.
    • ColdApplyPhase stays exported. Fine. PR C calls it; it is tested here.

Non-blocking

  • sweep_ping_thread_busy counts every busy claim, including one held by a summary substitute on a thread with no sweep candidate. The name sits in the sweep's counter block. The doc wording ("an earlier substitute still held the thread") is accurate, so this is a naming choice, not a defect.

What I checked

  • Last review: round 1, 315d9ea, 2026-10-25T11:54:38Z
  • New commits read: 2 in 315d9ead..HEAD. c7da7351 is the new base (#508 squashed into main; outside this PR's diff, reviewed in its own PR). edd46eff is the reworked PR commit; I read its full diff against the base (git diff c7da7351..HEAD, 7 files) and diffed it file by file against the round-1 head. The changes are exactly the ones the author listed: the rename, the busy counter, the corrected comments, the new decline test, the sumB removal, runtime.Gosched(), and the doc paragraph. No hidden change.
  • Read in full: 2 reviews, 1 comment, 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:
    • Reviewer 2's round-1 review (posted 1 s after mine, so unread then). Read now; its one finding matched my finding 2, its non-blocking list matched mine plus the rename, the busy counter and sumB. Each checked above.
    • The author's reply comment (2026-10-25T12:34:25Z). Every "Fixed" claim verified in the diff; every "Not changed" reason checked and accepted.
    • The updated PR body. Data-dependence line, the "What changes" capability statement, and the PR C gap note are all present and match the code.
  • Re-checks on the reworked code: the busy counter is added after pingGuardMu unlocks; no old sweep_summary_took_ping name remains anywhere (grep over Go and docs); the new test's helpers and imports exist; fail-open paths unchanged from round 1 and still sound (claim released by defer, every decline ends in an ordinary ping).
  • Did not run builds or tests (not approved). Go is not installed on this machine.

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

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant