Repository navigation
fix(keepalive): a ping touches the cache clock the request reads - #904
Conversation
The request's cold check reads cg:seen:<alias> with the alias of the body as it arrived. The keeper derived its touch alias from the body that goes upstream. Tool deferral appends the names list to messages[1], which can be the first system message SessionHead hashes. On ultrahigh the two aliases differ, so a ping never counted and the sweep cut a live prefix. apply now puts the arriving alias on Trace.TouchAlias. The proxy passes it on keepalive.Record. The ping, substitute and manual ping touch that key through RecordCacheTouchAlias. RecordCacheTouch stays for hosts that send the transcript unchanged. Closes #902 Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
… shapes (#902) Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.318 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 626576deb61e |
approve |
Verdict: approve
Findings
None. The fix is correct. I traced every path that writes or reads the cg:seen: clock, and the
two sides now use one key.
Non-blocking
-
PR description vs tests — the second fixture does not exist. The description says
apply/touchalias_test.goruns "on two fixtures (messages[1]is system, so the list is
appended;messages[1]is not system, so a system message is inserted)". The file has one
fixture (deferredShape), wheremessages[1]is a system message. No test covers the insert
shape (tooldefer/rewrite.go:169-181). The fix covers it by construction —TouchAliascomes
from the arriving body in both shapes — but a reader of the PR cannot verify that from the
tests. Fix the description, or add the second fixture. Note:gh pr editno-ops on this repo;
use the PATCH API. -
apply/apply.go:507-508— a second hash of the same head on every request.
sessionIDFrom(line 503) already runsschema.SessionHead(norm)and, when the request
carries no explicit session id, computes the sameScoped(tenant, "", ...)hash. The hoisted
alias repeats both. The cost is one walk plus one sha256 of the head text, and it now runs on
bypassed requests too, where the old code computed it only on the cache-aware path. Small, but
it is per request. ReusingsessionIDwhen no explicit id applies would avoid it. -
apply/responses.go:521— the alias is derived twice in one function. Line 494 sets
res.TouchAlias = session.Scoped(o.Tenant, "", sys, first); line 521 computes the same value
again intoalias. The PR's own pattern ("one rule derives the key") argues for one variable.
Cosmetic. -
proxy/keepalive.go:310—recordhas no production caller left. Only tests call it. It
is a reasonable shim to keep; saying so here so a later reader does not hunt for one. -
Test gap on two changed touch paths.
keepalive/manual.go(PingNow) and
keepalive/substitute.go(recordSubstitutePing) now callj.touch, but only the Sweep path
(keepalive/keeper.go:1726) is pinned by a test that hands in aTouchAlias. Both take the
samepingJob.touchbranch, so the risk is low.
What I checked
- Read
CLAUDE.md,docs/design.md, the full diff, and the code around every change. - One key on both sides. The cold check reads
cg:seen:<alias>with the alias derived at
apply/apply.go:507-509from the transcript as it arrived atapply(post envelope transform,
pre pipeline and pre deferral).Trace.TouchAliasis that same variable, so the request's read
key and the ping's write key cannot drift. This mirrors thegraceAliasIDone-rule pattern
from #766. - The bug is real.
tooldefer.Rewriteputs the names list atmessages[1]
(tooldefer/rewrite.go:135-181), appended to a system message there or as a new system message
at index 1.schema.SessionHead(schema/schema.go:267) hashes the first system message, so
the deferred body yields another alias. The oldRecordCacheTouchcall inrecord1hashed the
deferred body the keeper holds. Confirmed by the new apply test. - Every touch site switched.
record1(keeper.go:1726),PingNow(manual.go:167) and
recordSubstitutePing(substitute.go:249) all go throughpingJob.touch. AllpingJob
literals (Sweep extra, Sweep regular, manual) copytouchAliasoff the entry. No other caller
ofapply.RecordCacheTouchexists in the repo. - The only
keepalive.Recordconstruction site isproxy/keepalive.go:404, which now takes
touchAlias. The oneservecaller passestr.TouchAliasfromapplyMode. Other hosts are
unaffected:""falls back to the old body derivation, and no other host builds aRecord. - Fallback is safe. When
TouchAliasis""(no messages, observe mode's zero Trace, a
panic inBodyOpts), the touch derives from the body, exactly as before. On observe and
bypassed requests the proxy forwards the body unchanged, so that derivation is right there. - Store and tenant agree. The request's cold check and the ping's touch both use the tenancy's
store (tn.Store) and the same tenant-scoped alias (apply.Opts.Tenant=Record.Key.Tenant). - No fail-open regression.
RecordCacheTouchAliasis a guarded two-field store write;
pingJob.touchcannot panic on the new branch. The keeper still masks held bodies; the alias is
a hash, so it carries no transcript text. - Behavior change is named at the top of the PR, with who it affects and why there is no
switch. It matches the owner-approved bug fix in #902. Data dependence: none changes; the alias
is a hash of metadata, and nodocs/data-dependence.mdrow is affected (no component changed). - Test math.
coldAfterPing: first request at t0, touch at t0+4m, second request at t0+8m.
Anthropic TTL 5m +coldMargin1m (apply/cachelifetime.go:25): 8m idle reads cold, 4m reads
warm. The three proxy cases (fix, old derivation, no deferral) and the keepalive pass-through
test all assert on the realcg:seen:key in the real store. - Could not run Go on this machine (per the review rules). Verified test helpers exist with
matching signatures (aliasFor,coldSpy,trackedRecord,testKeeper,kaPolicy,
fakeSender), and thatapply's test-onlytooldeferimport creates no cycle (tooldefer
imports noapply).
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.318 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 626576deb61e |
blocking |
Verdict: blocking
One low-severity finding. The core fix is correct. I verified the key rule end to end: the
request's cold check, aliasSeen (apply/apply.go:1202), and the ping's new touch,
RecordCacheTouchAlias (apply/apply.go:1280), now write and read the same cg:seen:<alias> key,
and that key comes from one derivation, Trace.TouchAlias.
Note on the head: this review was started against 626576de. The PR head is now 807663db, two
commits later. Both commits (b8a29f09, 807663db) touch apply/touchalias_test.go only. I read
both in full. The production code is identical, so the review stands. The marker keeps the sha this
review was given.
Findings
- apply/responses.go:494 — the OpenAI half of the fix has no test, and the PR text says it does not exist
- What fails: our own tool search rewrites OpenAI bodies after apply runs, and it can move the
head the alias hashes.placeClientList(tooldefer/clientsearch.go:495) inserts the names
list as a system message atmessages[0]on Chat Completions when the first message is not
system or developer, and as a developer message atinput[0]on Responses.normalizeResponses
maps a developer message to a system message (apply/responses.go:363). On a Responses body
with noinstructionsstring, that inserted message becomes the first system message
SessionHeadhashes. So on those shapes the old body-derived ping key missed the request's
clock — the same defect as #902 — and this PR fixes them throughTrace.TouchAlias. No test
covers any OpenAI route:apply/touchalias_test.goandproxy/pingtouchalias_test.gouse
Anthropic shapes only. - Proof:
applyClientSearchruns forprovider == bschemas.OpenAI && tooldefer.ClientWire(wire)
(proxy/tooldefer.go:396), andClientWireaccepts both OpenAI wires
(tooldefer/clientsearch.go:70). Keep-alive pings OpenAI threads on their own idle schedule
(proxy/keepalive.go:487-492). The PR text says "Responses route ... behaves as before", which
is wrong for the no-instructionsshape: before, a ping there touched a key the request never
read; now it touches the right one. - Fix: add one OpenAI case to
proxy/pingtouchalias_test.go— a Chat Completions body with no
leading system message, deferred throughtooldefer.RewriteSearch, pinged, then a second
request asserting warm. Also correct the PR text's "behaves as before" claim. Low severity:
the code path is right by reading, and it moves in the safe direction (warm).
- What fails: our own tool search rewrites OpenAI bodies after apply runs, and it can move the
Non-blocking
- apply/apply.go:503-508 — the head is hashed twice per request.
sessionIDFromalready runs
schema.SessionHead+session.Scopedover the samenorm. The newaliasline repeats both,
so every request pays one extra sha256 of the head. It also runs on turns that never computed it
before (bypassed, non-cache-aware, no tracker). Small, butalias == sessionIDwhenever the
request carries no explicit session id, so half of these calls are pure duplicates. - proxy/keepalive.go:310 —
recordis now test-only. Every production caller uses
recordTouch. Keep it for the tests, or note it in the comment.
What I checked
- The full diff
dd3cfa6f..626576de, plus the two later test-only commits up to the real head
807663db(b8a29f09,807663db). - The key rule, end to end:
BodyOptsandbodyResponsesOptssetTrace.TouchAliasfrom the same
session.Scoped(tenant, "", sys, firstUser)expression their own cold check passes to
aliasSeen;RecordCacheTouchAliaswritesstore.SeenPrefix + alias, the same keyaliasSeen
reads; the write stays monotone. - The moved alias computation in
BodyOpts: same inputs (norm), same value, only hoisted. The
cold decision's behavior is unchanged. - Every keepalive touch site migrated to
pingJob.touch:record1,PingNow,
recordSubstitutePing. The fallback (touchAlias == "") matches the oldRecordCacheTouch
call exactly, including the provider argument.j.rawis the unmasked copy in all three
(the XORmasktoggles, keeper.go:1361-1364). touchAliasis copied out under the keeper lock inSweep(both job kinds) andPingNow, like
every other entry field.Recordbuilds a fresh entry per request, so the alias never goes
stale across turns.- Host paths that leave
TouchAliasempty and fall back: observe mode (applyMode returns the zero
Trace, but the body is forwarded unchanged there, so the body-derived key is right), bypass
(BodyOpts still sets the alias; body unchanged either way), and a panic beforeapplyMode
(zero Trace, body reverts toorig). All safe. - Post-apply body mutations that move the head:
tooldefer.Rewrite/placeList(Anthropic,
covered by tests),placeClientList(OpenAI, finding 1),expand.Injectand
adjudicate.Inject(tools array only, head untouched). - Fail open: no new error path.
RecordCacheTouchAliasreturns on empty alias or nil store. - The new tests, for correctness and vacuity: the apply tests assert the alias moves, the old
derivation reads cold, the fix reads warm, and the ping key equals the cold-check key; the
keepalive test asserts the exact clock value under the handed-in alias; the proxy test runs all
three cases end to end throughrecordTouch, a sweep and a real request. None is vacuous. docs/data-dependence.md: no dependence change — the alias is a content hash. The PR states
this. The behavior change is named at the top of the PR, as RELEASING.md requires.- Not verified: the PR's claim that
go vet,gofmtand-racepass on the eval box. Live tests
were not approved for this review.
…te touches (#902) Round 1 review of #904. - Add an OpenAI case: Chat Completions without a leading system message and Responses without instructions. tooldefer.RewriteSearch inserts the names list at the head, so the body-derived ping key missed the clock. - Pin TouchAlias on the manual ping and the substitute booking. - Hash the head once: TouchAlias reuses the session id when no explicit session id applies. One variable in the Responses path. - Say on keeper.record that it is a test shim. Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]>
|
Round 1 reply. New head: R1-1 (blocking): OpenAI had no testFixed in
R2-1: description vs testsFixed. The insert shape was added in Hash the head once (both reviews)Fixed in R2-3: two derivations in
|
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.318 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 766d63848759 |
approve |
Verdict: approve
Findings
None. The three new commits fix every round-1 finding. The only production change among them is
value-identical to the round-1 code; I proved that below. The rest is tests and comments.
Status of round-1 findings
- Reviewer 1, finding 1 (OpenAI had no test; PR text said "behaves as before") — fixed.
766d6384addsTestAPingOnASearchRewrittenOpenAIBodyKeepsTheNextRequestWarm. I checked it
myself: it covers Chat Completions with no leading system message and Responses with no
instructions, through the realtooldefer.RewriteSearch.placeClientList
(tooldefer/clientsearch.go:495-525) inserts a system message atmessages[0]on Chat
Completions and a developer message atinput[0]on Responses;responseMessage
(apply/responses.go:360-362) maps developer to system, soSessionHeadsees the inserted
list in both shapes. The test self-checks that the rewrite moves the alias
(apply.SessionIDForbefore vs. after), so it cannot pass vacuously. OpenAI's lifetime is a
minimum, so it assertsCtx.IdleMs— the samecg:seenclock — with the right numbers
(199 s with the fix, 480 s with the bug). The PR text now states both OpenAI shapes were broken
before the PR. I read the corrected body back from the server. - My non-blocking 1 (description named a second fixture that did not exist) — fixed.
b8a29f09addsinsertedShape(messages[1]is an assistant message, soplaceListinserts
a system message at index 1), and every apply test now runs both shapes. The description lists
the fixtures correctly. - My non-blocking 2 (the head was hashed twice per request) — fixed.
apply/apply.go:506-511
now reusessessionIDas the alias whenexplicitSessionreturns"". I verified the value
is identical in every case:sessionIDFromcalls the sameexplicitSession(o.Session, body)
that the new branch tests, andScopedwith an empty explicit id falls to the same content
hash (safeExplicit("")is false,session/session.go:43). A whitespace-only or unsafe
explicit id makes the branch re-derive the hash — the same valueScopeditself would
produce. No behavior change, one hash instead of two in the common case. - My non-blocking 3 (two derivations in
responses.go) — fixed. Onealiasvariable now
feeds bothres.TouchAliasand the cold check at line 534. Same inputs, same value. - My non-blocking 4 (
recordhad no production caller) — fixed. The comment on
proxy/keepalive.go:310says it is a test shim and that production callsrecordTouch. - My non-blocking 5 (manual ping and substitute had no
TouchAliastest) — fixed.
keepalive/touchalias_test.goaddsTestAManualPingTouchesTheAliasTheHostHandedIn(PingNow) and
TestASubstituteCallTouchesTheAliasTheHostHandedIn(recordSubstitutePing). Both assert the
exact clock value under the handed-in alias.
Non-blocking
- PR body vs. reply on
-race. The body says "-racepasses onapply... anddash".
The reply discloses that the first run of each was flaky on the shared box (a 10 s sqlite
deadline in apply; two timing tests in dash), then passed on repeated full runs of both this
branch andorigin/main. The reply is the honest record; the body states the end state. No
code in this PR touches either flake. Nothing to change before merge; a one-word "after
reruns" in the body would make it exact. - The manual test pokes entry internals.
TestAManualPingTouchesTheAliasTheHostHandedIn
setse.stande.touchAliason the live entry underk.murather than going through
Record. Acceptable for a unit test ofPingNow's hand-off; noting it so nobody reads it as
a supported entry API.
What I checked
- Last review: round 1,
626576deb61ebe6b78ab1f204550893b2055c605, 2026-11-04T18:47:18Z. - New commits read: 3 —
b8a29f09test(apply): cover the inserted names-list shape;
807663dbtest(apply): assert the ping key equals the cold-check key, both list shapes;
766d6384test(keepalive): cover the OpenAI search rewrite, manual and substitute touches. - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review, and what I did about each:
- Reviewer 1's round-1 review (posted 11 s after mine, so unread in round 1): read in full.
Its one finding overlapped nothing of mine — it named the OpenAIplaceClientListpath,
which I had missed. I verified the claim independently (see above) and the fix. - The author's round-1 reply (2026-11-04T20:15:35Z): read in full. Every "fixed" claim
checked against the code at766d6384; every one holds. - The three new commits: full diff read, plus the code around each change.
- Reviewer 1's round-1 review (posted 11 s after mine, so unread in round 1): read in full.
- The only production diff since round 1 (
apply/apply.go,apply/responses.go,
proxy/keepalive.gocomment): verified value-identical for the alias in all
explicitSession/safeExplicit/ whitespace edge cases; verifiedsys/firstUserhave
no other reader inBodyOptsthat the narrower scope could starve. - New test soundness. Fixtures exercise the real
tooldefer.Rewrite/RewriteSearch/
placeList/placeClientListcode; the alias-move assertions are self-checking, so a
fixture that stopped reproducing the #902 shape would fail the test, not pass vacuously.
Idle math re-derived: touch at +281 s, second request at +480 s → 199 s (fix) vs 480 s (bug).
Helpers exist with matching signatures (manualKeeper,sess1.id(),seenAt,
recordSubstitutePing(j, model, u, ms, startedAt, answerUSD),apply.SessionIDFor,
schema.WireOpenAI/WireResponses). - Round-1 conclusions that still stand at this head: one key on both sides of the
cg:seen
clock; every touch site (record1,PingNow,recordSubstitutePing) goes through
pingJob.touch; the""fallback matches the old behavior; no new fail-open path; data
dependence unchanged. - Could not run Go on this machine (per the review rules). The author's eval-box runs
(go vet,gofmt,-race) are disclosed in the reply, including the two flakes; I read
that report but could not reproduce it.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.318 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 766d63848759 |
approve |
Verdict: approve
No findings. My round-1 finding is fixed, and the fix itself is correct.
Round-1 finding: fixed
R1-1 (blocking): the OpenAI half of the fix had no test. Fixed in 766d6384.
TestAPingOnASearchRewrittenOpenAIBodyKeepsTheNextRequestWarm(proxy/pingtouchalias_test.go) covers
both wires I named: Chat Completions with no leading system message, and Responses with no
instructions. Both go through the realtooldefer.RewriteSearch.- The test guards its own fixture: it fails unless the rewrite moves the alias
(apply.SessionIDForon the sent body versus the arriving body). So it cannot pass vacuously. - Asserting
Ctx.IdleMsinstead ofColdCacheis right: OpenAI's cache lifetime is a minimum, so
the cold verdict never fires there (apply/responses.go:567-571, apply.go's lifetime-kind gate).
IdleMsreads the samecg:seenclock throughprevAt. The expected values check out:
199 000 ms from the ping's start with the trace alias, 480 000 ms with the re-derived one. - The PR text is corrected on the server. I read the body back. It now states that before this PR
a ping on those shapes touched a key the request never read.
Other reviewers' findings, checked myself
All of reviewer 2's round-1 non-blocking items are fixed in b8a29f09, 807663db or 766d6384:
- The insert-shape fixture exists (
insertedShape, apply/touchalias_test.go), and the fix test
asserts the ping key equals the cold-check key on both shapes. Agree, verified. - The double head hash is gone; see the equivalence check below. Agree, verified.
responses.goderives the alias once. Agree, verified.keeper.recordis documented as a test shim. Agree, verified.- The manual ping and the substitute booking are pinned by tests. Agree, verified — both tests
assert the exact clock value under the handed-in alias, and both paths really reach
RecordCacheTouchAlias(PingNowthroughokPing's CacheRead,recordSubstitutePingthrough
itsu.CacheRead > 0gate).
The hash-once change is exactly equivalent
I checked every case of the new alias := sessionID reuse in BodyOpts (apply/apply.go:506-511):
explicitSessionreturns only asafeExplicit-validated id or "" (session.Explicit →
ExplicitID, session/session.go:103-110). So when it returns "",Scopedfalls back to the
content hash insidesessionIDFrom, andsessionIDIS the bare-hash alias. Reuse is exact.- When it returns a non-empty id, the branch recomputes
Scoped(tenant, "", sys, firstUser)—
the same bare hash the round-1 code always computed. Same value the cold check reads.
The value of tr.TouchAlias and of the alias the cold check passes to aliasSeen is unchanged
on every path.
Non-blocking
- apply/apply.go:510 — one extra full-body
metadatascan per request on explicit-session
traffic. The newexplicitSession(o.Session, body)check runs the gjsonmetadatalookup a
second time (sessionIDFromat line 503 already ran it). On a request with an explicit session
id — Claude Code'smetadata.user_id— the hash-once fix keeps the hash AND adds this scan; on
requests without one it saves the hash and adds nothing. Both costs are sub-millisecond, but the
cleaner form is to resolve the explicit id once and share it withsessionIDFrom.
What I checked
- Last review: round 1, 626576d, 2026-11-04T18:47:29Z
- New commits read: 3 —
b8a29f09(insert-shape fixture),807663db(ping-key-equals-cold-check
assertion),766d6384(OpenAI test, manual and substitute tests, hash-once, responses variable,
record shim comment). The first two were also read in full during round 1; the production code
they touch is nil. - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files).
- New items since my last review:
- Reviewer 2's round-1 review (approve, 5 non-blocking items). Checked each against the fix
commit; all fixed as stated above. - The author's round-1 reply (2026-11-04T20:15:35Z), which answers every finding from both
reviews. Each claim in it that I could check from code held up: the new tests exist and assert
what the reply says, and the corrected PR text is live on the server. - The flaky-test disclosure in the reply: one
applysqlite-deadline flake and twodashtiming
flakes on first runs, all passing alone and on reruns on both this branch andorigin/main.
Nodashfile is in the PR diff. I cannot re-run tests (not approved), so I take the
disclosure as given; nothing in the changed code touches those areas.
- Reviewer 2's round-1 review (approve, 5 non-blocking items). Checked each against the fix
- The full diff
dd3cfa6f..766d6384, file by file, plus the code around each change. - The new keepalive tests for reachability:
manualKeeperrecords a pingable entry whose fake
dispatcher answers with CacheRead, soPingNow's touch gate opens;recordSubstitutePing's
gate opens on the Usage the test passes. - The new OpenAI test's route dispatch:
API: ""reachesBodyOpts' chat path,API: "responses"
reachesbodyResponsesOpts;CacheMode: "on"forces cache awareness on both, so the tracker
branch andaliasSeenrun. - Not verified: the reply's
go vet,gofmtand-raceresults. Live tests were not approved
for this review.
Signed-off-by: DAVID AMID <[email protected]> Assisted-By: Claude Opus 5.5 <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
|
Before round 3: what is new since round 2 (766d638). The head is now
|
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 2 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.318 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 3 of 3 | ad769b20dc98 |
approve |
Verdict: approve
Findings
None. The only new commit is a merge of origin/main. I checked the merge resolution and the
interactions with both incoming main commits. The PR's fix is intact and still correct.
What the merge brought in
Main advanced by two commits: 38c00e13 (revert of #903, the accountant savings library) and
44f8318d (#900, client ToolSearch mode). The PR base moved from dd3cfa6f to 44f8318d.
Merge resolution — checked, correct
The author's note (2026-11-04T20:54:53Z) says 4 conflicts, resolved as main's side plus this
PR's touchAlias. I ran git show --remerge-diff ad769b20 myself. It shows exactly those 4
conflict hunks and nothing else:
keepalive/keeper.go:934-935— thekaEntryliteral: main's fields (nogapStart) with
touchAlias: r.TouchAliaskept. Correct.keepalive/keeper.go:1316-1317— the Sweep extrapingJob: main's fields with
touchAlias: e.touchAliaskept. Correct.keepalive/keeper.go:1362-1363— the Sweep regularpingJob: same. Correct.keepalive/manual.go:113— thePingNowpingJob: same, andgapStart's comment went with
its field. Correct.
All four keep every touchAlias copy the PR needs (Record, both Sweep job kinds, PingNow),
and drop gapStart exactly as main's revert did. No third side was introduced anywhere.
Interactions with the incoming main commits — checked, safe
- Revert #903. It removed
Trace.Ops, the savings tracker andgapStartfrom files this PR
touches (apply/apply.go,keepalive/*,proxy/proxy.go). None of the removals touch the
TouchAlias plumbing; I grepped the merged head:Trace.TouchAlias(apply.go:507),
res.TouchAlias(responses.go:498),touchAliasin all four literals,pingJob.touch
(keeper.go:2218),recordTouch(proxy.go:1549) are all intact. Theservecall still passes
tr.TouchAlias. - #900 client ToolSearch.
tooldefer.Rewritenow delegates to an internalrewritewith a
clientflag; withclient=false(what the exportedRewriteand this PR's Anthropic tests
use) the behavior is byte-identical: same search tool, sameNamesList, sameplaceList. In
client mode the list still goes throughplaceListatmessages[1], so the head still moves
and TouchAlias still covers it.RewriteSearch/placeClientList(tooldefer/clientsearch.go)
are untouched by #900, so the OpenAI test's path is unchanged. #900'sAugmentSearchesrewrites
the body insideapplyToolDefer, which still runs afterapplyModeand beforeserverecords
— another post-apply body change that TouchAlias covers by construction. - Test helpers. The revert deleted tests from
keepalive/manual_test.go, butmanualKeeper,
recordWithSinkandrecordBodyWithSinksurvived; the PR's three test files are byte-identical
to round 2 (not in the merge diff at all). - Net PR diff.
git diff 44f8318d..HEADlists the same 10 files as round 2, same content.
Status of earlier findings
- All round-1 and round-2 findings (both reviewers): fixed at
766d6384, unchanged by the merge.
Verified again by grep at this head. - Reviewer 1's round-2 non-blocking note (one extra
metadatascan per explicit-session
request,apply/apply.go:510): still open, still non-blocking, unchanged by the merge. I agree
with its assessment; nothing in this round asks for it.
Non-blocking
- The merge commit message carries
Signed-off-by: DAVID AMIDtwice. Cosmetic; the DCO check
passed. Nothing to do before merge.
What I checked
- Last review: round 2,
766d63848759af11693643fac6a2c9c32c871c6a, 2026-11-04T20:20:17Z. - New commits read: 1 —
ad769b20"Merge origin/main into fix/ping-touch-alias" (brings in
main's38c00e13revert #903 and44f8318d#900; both read through the merge diff). - Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files
.review-in-reviews.txt,.review-in-comments.txt,.review-in-inline.txt). - New items since my last review, and what I did about each:
- The merge commit
ad769b20: fullgit diff 766d6384..HEADread;git show --remerge-diff ad769b20read to see every conflict resolution; PR plumbing grepped at the merged head. - The author's merge note (2026-11-04T20:54:53Z): read in full. Its claims (4 conflicts, the
resolution rule,--remerge-diffshowing only those 4 edits) all check out against my own run. - Reviewer 1's round-2 review (posted at the same second as mine, so unread then): read in
full. Its verification of the OpenAI test and the hash-once equivalence matches mine; its
one non-blocking note is noted above.
- The merge commit
- The base move
dd3cfa6f→44f8318d: confirmed the PR's net diff against the new base keeps
the same 10-file shape and content as the round-2 approval. - Could not run Go on this machine (per the review rules). The author reports CI green at
ad769b20(build-test, purego, record, DCO, trivy) and-racepassing on keepalive, tooldefer,
proxy and dash, with apply passing after the known sqlite-deadline flake. I read that report;
the flake is the same one disclosed in round 2, pre-existing on the shared box.
amiddavid
left a comment
There was a problem hiding this comment.
| Reviewer | Kind | Started by | Context | Review | Round | Head | Verdict |
|---|---|---|---|---|---|---|---|
| Reviewer 1 (glm, user of @amiddavid) | GLM rits/zai-org/glm-5-3 via Claude Code 2.1.318 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 3 of 3 | ad769b20dc98 |
approve --> |
Verdict: approve
No findings. The one new commit is a merge of origin/main. I checked the merge resolution and
every interaction between main's two new commits and this PR's fix. The fix is intact.
The merge (ad769b20)
The author's note asked for exactly this check. I verified it independently, from the combined
diff (git show ad769b20), not from the note:
- Conflicts in 4 places, as stated: the
kaEntryliteral inRecord, the twopingJob
literals inSweep, and thepingJobliteral inPingNow. Main's revert (#903) removed the
gapStartfield; this PR addedtouchAliasto the same lines. - Each resolution is right: it takes main's side (no
gapStart) and keeps this PR's
touchAlias. I confirmedtouchAliassurvives at every site —Record(keeper.go:936), both
Sweepjobs (keeper.go:1316, 1362),PingNow(manual.go:113) — and that all three touch calls
(record1,PingNow,recordSubstitutePing) still route throughpingJob.touch. - No dangling
gapStart: zero references left inkeepaliveorproxy, tests included. - This PR's own files are untouched by the merge: the diff
766d6384..ad769b20is empty for
apply/responses.go,apply/touchalias_test.go,keepalive/touchalias_test.go,
proxy/pingtouchalias_test.goandproxy/keepalive.go. apply/apply.gomerged cleanly. Its only changes from the merge are the revert's removals
of #768's accountant code (Trace.Ops,opsFromRun,wireSizes), all far from the alias
block. The alias computation at apply/apply.go:497-507 is byte-identical to the state I
approved in round 2. No reference to a removed symbol remains anywhere inproxy,apply,
dashorcomponents.proxy/proxy.gomerged cleanly: the revert removed thecp.accEnd(..., tr.Ops)call, and
this PR'str.TouchAliasargument on theservecall (proxy.go:1549) is kept.
Interaction with main's new commits
- #903 (the revert) removes
gapStartand the accountant savings path from the exact files
this PR touches. The merge keeps both intents; see above. TheKeepAliveReport.Windowfield
and itsgapStartsource are gone together, which is main's reviewed change, not this PR's. - #900 (one search tool per request) changes
tooldefer.Rewriteto aclientmode: the
list text differs and no server-side search tool is added, butplaceListstill puts the names
list atmessages[1]— the head-moving behavior this PR's fix exists for.RewriteSearchand
placeClientListare unchanged, so the OpenAI test's path is intact.
applyToolDeferstill runs after apply and still returns the rewritten body, so the keeper
still holds a head-changed body andTouchAliasis still the right key there.
Status of earlier findings
- My round-1 finding (OpenAI test gap, PR text) — fixed in
766d6384, verified in round 2,
unchanged by the merge. - My round-2 non-blocking note (the second
explicitSessionmetadata scan) — not addressed, as
expected; it was a suggestion, not a request. Still stands, still minor. - Reviewer 2's items — all fixed in
766d6384; reviewer 2 approved round 2. Nothing new.
What I checked
- Last review: round 2, 766d638, 2026-11-04T20:20:17Z
- New commits read: 1 on the branch —
ad769b20"Merge origin/main into fix/ping-touch-alias"
(bringing main's38c00e13revert #903 and44f8318d#900 into the ancestry; both read as
diffs against the branch tree). - Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files).
- New items since my last review:
- The author's round-3 note (2026-11-04T20:54:53Z): a request to check the merge resolution.
Done as above; its claims (4 conflicts, main's side forgapStart,touchAliaskept,
git show --remerge-diffshows only these edits) all match what I found. - Reviewer 2's round-2 review (approve, 20:20:17Z): read in full. Its verification of the
hash-once equivalence matches mine; nothing new to add. - The merge commit and both main commits it brings: full diffs read, plus the code around each
change in the merged tree.
- The author's round-3 note (2026-11-04T20:54:53Z): a request to check the merge resolution.
- Fix integrity at the new head:
Trace.TouchAlias,RecordCacheTouchAlias,recordTouch,
tr.TouchAliason theservecall, all three touch sites, and all six PR tests present and
unchanged. - Not verified: the author's CI report (build-test, purego, record, DCO, trivy green;
-race
passing after the knownTestBodyOptsLoadsSessionStateFromDiskdeadline flake, the same flake
disclosed in round 2). Live tests were not approved for this review.
The PR is ready for merge from my side.
|
Behavior change: approved by the owner (@amiddavid), 2026-11-04, in the session that started this PR. The owner said, in words: "approve". This PR is a bug fix. It restores what a keep-alive ping is meant to do.
This comment records the approval on the PR so the integrator can read it. The release rule still asks the integrator to get the owner's yes in its own session. |
Behavior change
Summary
A ping wrote its touch under a key the request never read. Now both use one key.
What changed
cg:seen:<alias>. The alias came from the body before tool deferral.messages[1].SessionHeadhashes that message when it is the first system message. So the two aliases differ.applyalready computes the alias once. It now puts it onTrace.TouchAlias.proxypasses it onkeepalive.Record.TouchAlias. The ping, the substitute call and the manual ping touch that key through the newapply.RecordCacheTouchAlias.graceAliasIDuses (apply/apply.go, fix(restart): restart grace must use the thread's last request time, and a replay after a restart is priced as a write #766): one rule derives the key, so the keys the cold check asks for and the keys the recorder warms cannot drift apart.SessionHeadandtooldeferare not changed.SessionHeadalso feeds the session id, checkpoint and billed-input keys.SessionHead): it must never touch the client's own text. It would also needschemato know abouttooldefer. Option A has one source for the key and no text matching.RecordCacheTouchstays. It is right for a host that sends the transcript unchanged.""as the alias falls back to it.apply/apply.go,apply/responses.go,keepalive/keeper.go,keepalive/manual.go,keepalive/substitute.go,proxy/keepalive.go,proxy/proxy.go.Other readers of an alias-keyed clock:
aliasSeen(cg:seen:): reads the arriving alias. Correct as is.sessionTTL(st, alias, ...)(cg:ttl:): the request reads and writes it under the arriving alias. The keeper never touches it. Not affected.graceAliasand the restart grace: derived from the body thatapplyreceives, and the record side uses the same rule. Not affected.TouchAliasis set there too. Our own tool search (tooldefer.RewriteSearch) inserts the names list at the head: a system message atmessages[0]on Chat Completions with no leading system message, and a developer message atinput[0]on Responses with noinstructions. That moves the alias, so before this PR a ping on those shapes touched a key the request never read. Now it touches the right key.How it was tested
apply/touchalias_test.go, on two fixtures (messages[1]is system, so the list is appended;messages[1]is not system, so a system message is inserted). The client's own text stays fixed:keepalive/touchalias_test.go: the scheduled ping, the manual ping and the substitute booking each touch the alias the host passed in.proxy/pingtouchalias_test.go: end to end throughkeeper.recordTouch, a sweep ping and a real request. Three cases: ultrahigh with the fix, ultrahigh with the old derivation (reads cold), xhigh. A second test covers OpenAI: Chat Completions with no leading system message, and Responses with noinstructions, both rewritten byRewriteSearch. OpenAI's cache lifetime is a minimum, soColdCachenever fires there. The test checksIdleMs, which reads the same clock.touchAliasbranch inpingJob.touch. The keepalive test and the ultrahigh proxy test fail. Restored.TouchAliasreuses the session id, so the head is hashed once per request.recordinproxy/keepalive.gois now a test shim. Production callsrecordTouch.go vet ./...andgofmt -l .clean.-racepasses onapply,keepalive,tooldefer,schema,components,proxyanddash, after reruns on the shared box forapplyanddash. Known timing flakes failed once each (TestBodyOptsLoadsSessionStateFromDiskinapply; two overview and inventory timing tests indash). Each passes alone on this branch and onorigin/main, and passed on rerun. No code in those packages changed. Last run is at the head after the merge oforigin/main.Data dependence
None changes. The alias is a hash of metadata. No stored customer data is read or written. The feature is the same at every storage level (off, metadata only, everything).
Open questions
Closes #902
🤖 Generated with Claude Code