Repository navigation
fix(dash): seed the billed cache tier after a restart - #958
Conversation
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.319 | offload-review skill, @amiddavid's session | fresh | 2 of 2 | 1 of 2 | 71ffd91dbdf1 |
blocking |
Verdict: blocking
Findings
-
dash/capture.go:759 — a failed last request erases a known 1h tier, so the miss is still mislabeled
ttl_expiry- What fails: a thread writes a whole 1h entry, its next request fails (upstream 5xx, row recorded with
keepalive = 0,status = 500,cache_write = 0), the proxy restarts.SeedSessionspicks that failed row as the thread's latest.write = 0leaves the tier unknown, soseedTierstays empty. The first same-model miss 5 to 60 minutes later (model already seen by another request) getsttl_expiryagain — the exact label this PR exists to remove. - Proof: the query has no status filter (dash/capture.go:759-762), unlike
SeedGraceSessions, which filtersstatus >= 200 AND status < 300because "a failed request wrote no cache entry" (dash/capture.go:821-823). The live rule agrees: only a 2xx request commits facts and can set the tier (dash/prefixcause.go:81-83, proxy/dashcapture.go:662-663). Failed requests are recorded as rows: proxy/proxy.go:1941-1943 names "an upstream failure" as a path that emits the row. So the seeded row can be a failed one. Money follows the label:causedWriteUSDcharges $0 forttl_expirybut the write forprefix_change(dash/compactepisode.go:1017-1024), so the mislabel understates the debit — the flattering direction this repo treats as the worse one. - Fix: add
AND r.status >= 200 AND r.status < 300to the seeding query. Better: seed from the thread's latest 2xx row withcache_write > 0(one query, same shape), which also fixes the successful full-hit case noted under Non-blocking.
- What fails: a thread writes a whole 1h entry, its next request fails (upstream 5xx, row recorded with
-
dash/prefixcause.go:122-123 — the new
cur.NoWrite && seededTierbranch has no test- What fails: nothing today, but the branch is new behavior in this diff and no test runs it.
TestSeededTierAfterARestartalways gives the post-restart turn a write (ttlTurn(..., 0, 50_000, 50_000)), soNoWriteis false on every committed turn. A regression in this branch (a read-only first turn on a seeded 1h thread losing the tier, mislabeling the next miss) would pass the suite. - Proof: the only restart test is
TestSeededTierAfterARestart(dash/prefixcause_test.go:552-586); its miss turn passeswrite = 50_000.TestTTLTierSurvivesAReadOnlyTurn(line 477) covers thesamebranch only. - Fix: add one case — a seeded 1h thread whose first post-restart request is read-only (
read > 0, write = 0), then a miss 20 minutes later must not readttl_expiry.
- What fails: nothing today, but the branch is new behavior in this diff and no test runs it.
Non-blocking
- Full-hit last row keeps 5m (documented). A 2xx read-only last row (
cache_write = 0, a full cache hit) also leaves the tier unknown, so a 1h thread is mislabeledttl_expiryafter a restart. Issue #956 and the PR state this limit, and the test pins it ("latest row wrote nothing seeds 5m"). The latest-writing-row query from finding 1 fixes this case too, at no extra cost. - Seed is thread-keyed, not per model.
seedTieris keyed by thread alone (dash/capture.go:196), while the live tier belongs to a (thread, model) entry. A multi-model thread whose last row is a helper request on another model seeds that model's tier for every model. Mostly benign while the 1h beta is set per client (all models in a thread then write 1h), but it diverges from the per-model live rule. - The 20,000-entry fallback prune misses
seedTier(dash/capture.go:726-730). It emptieslastSeen,lastTail,lastFactsandgraceSeen, but notseedTier; and afterlastSeenis emptied, the age-based prune can no longer deleteseedTierentries either, because it iterateslastSeen(dash/capture.go:705-710). A stale startup tier can then reach theNoWritecommit branch for a thread whose live tier has since changed. Edge case: it needs more than 20,000 live sessions. - Fork threads do not inherit a seeded tier. When
hasFromis set and the parent also has no facts,seededTierreads the fork's key only (dash/prefixcause.go:107), so a brand-new fork after a restart gets 5m. The PR lists this as out of scope.
What I checked
- The full diff (one commit) and the code around every change:
dash/capture.go(SeedSessions,pruneSessionsLocked,observe,ObserveThread),dash/prefixcause.go(ObservePrefix,FactsOf),dash/prefixcause_test.go. - The consumers of the returned
prevOneHour:proxy/dashcapture.go:662-680(cacheAttributionTTLMs,AttributeCache) and the label's money paths indash/compactepisode.go(causedWriteUSD,coldCreationUSD). - Schema:
cache_writeandcache_write_1hareINTEGER NOT NULL DEFAULT 0inrequests(dash/schema.go:118, dash/schema.go:154, migration at dash/schema.go:762), so the addedScantargets cannot be NULL. - Concurrency:
seedTieris written underr.muinSeedSessionsand read underr.muinObservePrefix;SeedSessionsruns once at startup (cmd/context-guru-proxy/main.go:428) and never overwrites a thread this process has observed. - Key consistency:
SeedSessionsandObservePrefixboth key onthread.Key(session, thread); the test's keys line up with the seeded rows. - Test logic: traced all four cases of
TestSeededTierAfterARestartthroughrestartedWith→SeedSessions→ttlTurn→AttributeCache; the expected labels follow. The polling loop inrestartedWithhas a 3-second deadline and fails loudly, so it cannot pass silently on a stalled flush. - Data dependence: the change reads existing token-count columns only; no new stored data, so
docs/data-dependence.mdneeds no row. - Behavior-change rule: the PR names the change at the top, with who it affects and the old and new behavior, and flags that a human developer must approve.
- I did not run builds or tests (not approved for this review); all verification is by reading the code.
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.319 | offload-review skill, @amiddavid's session | fresh | 1 of 2 | 1 of 2 | 71ffd91dbdf1 |
blocking |
Verdict: blocking
Findings
- dash/prefixcause.go:122-123 — the seeded read-only branch has no test
- What fails: the new
else if cur.NoWrite && seededTierpath is never run by any test.TestSeededTierAfterARestartalways observes a writing turn (write=50_000), so the branch could be deleted and every test would still pass. The production path it guards is real: a restart during an active 1h thread, the first post-restart turn hits the cache (writes nothing), a miss 20 minutes later with a changed prefix. With the branch the label isprefix_change; without it the committed facts carryOneHour=false, the next turn reads the 5-minute limit, and the label isttl_expiry— the exact mislabel this PR removes. The label also routes money:ttl_expirypaysColdCreditUSDwhileprefix_changepays nothing (dash/compactepisode.go:858-868). - Proof:
ttlTurnin dash/prefixcause_test.go:433 setsf.NoWritefromFactsOf, and the new test's only observed turn passeswrite=50_000(prefixcause_test.go:576).TestTTLTierSurvivesAReadOnlyTurn(prefixcause_test.go:477) covers only thesamevariant of the inheritance, not the seeded variant.grepoverdash/*_test.goshows no other test setsseedTieror seeds a 1h thread and then runs a read-only turn. - Fix: add one case to
TestSeededTierAfterARestart(or a sibling test): seed a 1h thread, run a read-only first turnttlTurn(r, t0+2*min, base(), 50_000, 0, 0), then the 20-minute miss with a changed prefix must not readttl_expiry. A mutation check (delete theelse if) should fail it.
- What fails: the new
Non-blocking
- dash/capture.go:726-730 — the wholesale reset does not clear
seedTier. The PR body says the tier "ages out withlastSeen". The by-age prune does delete it (capture.go:709), but the >20,000-sessions fallback emptieslastSeen,lastTail,lastFactsandgraceSeenand leavesseedTieralone. The effect is benign: a thread with nolastSeenentry readscold_startbefore the TTL test (event.go:1210), so the orphaned tier is never used, and the entries self-heal on the next by-age prune. One line,r.seedTier = map[string]bool{}, would make the claim hold. - The seed is per thread, not per model.
prevOneHourshould describe the same-model entry (prefixcause.go:66), but the seed comes from the thread's latest row on any model. A/modelswitch that spans a restart borrows the other model's tier. The window is narrow — the seed is read only on the thread's first post-restart request, and the first request per (tenant, model) readscold_startanyway becauseseenModelis not seeded. Worth a line in the PR or a follow-up. - A latest row that wrote nothing loses the thread's earlier 1h tier. The seed reads one row per thread; the in-memory path inherits the tier across a read-only turn. The PR names the 5-minute fallback as out of scope, so this is a recorded limit, not a defect. A follow-up could seed from the thread's last row with
cache_write > 0. - PR body wording. "ObservePrefix uses it only when the thread has no facts and the request wrote nothing" is not exact: the returned tier (prefixcause.go:138) applies to any first post-restart request, writing or not. The code is right; the sentence is not.
What I checked
- The full diff (dash/capture.go, dash/prefixcause.go, dash/prefixcause_test.go) and the code around each change.
- The seed rule
write > 0 && write1h >= writeagainstFactsOf(prefixcause.go:50) — identical. - Keying:
SeedSessionsandObservePrefixboth usethread.Key(session_id, thread_id)from the same columns, matching the existinglastSeenseeding. Tenant scoping is the same pre-existing approximation aslastSeen. - Locking:
seedTieris written underr.muinSeedSessions, read underr.muinObservePrefix, deleted underr.muinpruneSessionsLocked. Nil-map reads are safe. - Schema:
cache_writeandcache_write_1hareINTEGER NOT NULL DEFAULT 0(schema.go:118, 154) with an additive migration, so the 6-column scan cannot fail on old rows. Startup order in cmd/context-guru-proxy/main.go runs migrations beforeSeedSessions. - The caller chain: proxy/dashcapture.go:662-680,
cacheAttributionTTLMs, andAttributeCache's case order (hit, cold start, TTL, unknown, prefix change).seededTieronly lengthens the TTL; a false positivecold_startstill masks it. - The guard
!same && !hadAny: live facts and inherited parent facts always win over the seed; the seed is read only while the thread has no facts at all. - Traced
TestSeededTierAfterARestartby hand throughrestartedWith,ObserveThread(model-seen workaround) andttlTurnfor all four cases; the expectations match the code. The poll-then-SeedSessionshelper fails loudly if the row never lands. - Existing
SeedSessionstests (cachecost_test.go, grace_test.go, thread_test.go) still fit the widened query. - Data dependence: metadata only (token counts already stored); no new columns, no storage-level change. The PR states this.
- Behavior change: named at the top of the PR body, per RELEASING.md. It is a dashboard label fix with no switch, closing #956.
|
Round 1 replies. Fixed in the new head. Reviewer 2
Reviewer 1
Tests on the box: |
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.319 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 2 of 2 | 7d0914add53d |
approve |
Verdict: approve
Findings
None. Both round-1 findings are fixed and tested. I found no defect in the new commit.
Round-1 findings
- Failed last request erased a known 1h tier — fixed. The tier now comes from
seedOneHourTiers(dash/capture.go:822-845), a second query that picks each thread's latest non-ping, 2xx row withcache_write > 0. I checked the query against the live rule: only a 2xx request commits facts (dash/prefixcause.go:81-83), and a read-only turn keeps the earlier tier, so the latest writing 2xx row is the right source. The rulewrite1h >= writewithwrite > 0in the WHERE matchesFactsOf. Tests "failed last row keeps the earlier 1h tier" and "failed 1h write does not seed 1h" pin both directions. - No test for the
cur.NoWrite && seededTierbranch — fixed. The new case "read-only first turn keeps the seeded 1h tier" runs a read-only turn att0+2minand a miss att0+22min. I traced it: the read-only turn commitsOneHour = truethrough the branch (dash/prefixcause.go:122-123), so the miss reads a 20-minute gap under a 1-hour TTL and stays offttl_expiry. Delete the branch and the committed facts carryOneHour = false, the miss readsttl_expiry, and the case fails.
Non-blocking from round 1
- Full-hit last row: fixed by the same query. Test "full-hit last row keeps the earlier 1h tier" pins it.
- Wholesale reset: fixed.
pruneSessionsLockednow clearsseedTier(dash/capture.go:729). - Per-thread seed, not per model: rejected as out of scope, now documented in the PR body under "Out of scope (known limits)". I accept the reason:
seenModelis not seeded, so the first post-restart request on a model readscold_startregardless, and the seed only matters once another request on the same model has run in the new process. The limit is now stated where a reader will find it. - Fork threads: rejected as out of scope, documented in the same list. Accepted for the same reason.
New commit reviewed
- I read the whole diff of
7d0914add53dand the code around it. Checks beyond the findings above:- The first query is back to four columns; recency and the tail still come from the latest non-ping row, unchanged.
seedOneHourTiersruns beforer.muis taken and builds a local map, so no lock is held across the query. A query error failsSeedSessionsas a whole, the same startup-only failure class as before; the proxy itself is unaffected.- Every thread in the tier query's result also has a latest non-ping row inside the window (its writing row is one), so the merge loop at dash/capture.go:797-811 cannot orphan a tier entry, and the
lastSeenguard still stops the seed from overwriting a thread this process has observed. - A thread whose only writing rows are older than the two-hour window seeds no tier, which is correct: no provider entry outlives that window.
/compactand observe-mode rows cannot distort the tier seed:/compactwrites no cache (cache_write = 0, excluded), and the empty-session key is the same pre-existing approximation the recency seed has always had.- The nine test cases: I traced each through
restartedWith→SeedSessions→ttlTurn→AttributeCache. The expectations match the code, including "later 5m write replaces an earlier 1h write" and "only read rows: tier unknown, 5m", which pin the live rule in both directions. - The PR body now describes the return and commit paths of the seeded tier exactly (reviewer 1's wording point).
What I checked
- Last review: round 1, 71ffd91, 2026-11-08T15:33:40Z.
- New commits read: 1 (
7d0914ad— "fix(dash): seed the tier from the latest successful write"). - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files; the inline file is empty).
- New items since my last review: the commit above; the author's round-1 reply comment (2026-11-08T15:58:52Z), which I checked item by item above; the updated PR body, which I read against the code. Reviewer 1's round-1 review I read in full this round; their finding matches my finding 2 and their non-blocking items match mine — all checked, no new proof to add.
- I did not run builds or tests (not approved for this review); all verification is by reading the code.
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.319 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 2 of 2 | 7d0914add53d |
approve |
Verdict: approve
Findings
None.
Earlier findings
- My finding 1 (no test for
cur.NoWrite && seededTier): fixed. The new case "read-only first turn keeps the seeded 1h tier" (dash/prefixcause_test.go:593) seeds a 1h thread, runs a read-only first turn (ttlTurn(r, t0+2*min, base(), 50_000, 0, 0)), then a miss 20 minutes later. I traced it: the read-only turn hits, commits facts withOneHour=truethrough the branch, and the next turn reads the 1h limit, so the miss isprefix_change. Delete theelse ifand the committed tier is false, the limit is 5m, and the case fails. The author's mutation check matches my trace. - Reviewer 2, finding 1 (failed last row erases the tier): fixed. I checked it myself. The tier now comes from
seedOneHourTiers(dash/capture.go:822-845), a second query that takes each thread's latest non-ping, 2xx row withcache_write > 0. The failed row can no longer be the tier source. Test "failed last row keeps the earlier 1h tier" covers it. - Reviewer 2, finding 2: fixed, same as my finding 1.
- My non-blocking items: all addressed. Wholesale reset now clears
seedTier(dash/capture.go:729). "Latest row wrote nothing" is fixed by the same query change — the tier now comes from the last row that wrote, not the last row. The PR body wording is rewritten and now matches the code. Per-thread, not per model, and fork inheritance stay as out-of-scope limits, now listed in the PR body. I accept both: the first request per (tenant, model) after a restart readscold_startanyway, and forks were out of scope from the start. - Reviewer 2's non-blocking items: full-hit last row — fixed, with test; wholesale reset — fixed; per-model and forks — out of scope, as above.
Non-blocking
- The tier row can be older than the recency row, and recency still comes from any status. A 1h write at T0, a failed request at T0+50m, a restart, a miss at T0+70m: the seed measures the age from the failed row (20m, not expiry), while the live path measures from the last committed request (70m, expiry). Which is right depends on whether the failed request read the cache before it failed — unknowable from metadata. The miss-label direction is the under-claim, the one this repo treats as safe. Recency from a non-2xx row is a pre-existing
SeedSessionsrule; the new tier only inherits the ambiguity. seedOneHourTiersreturns threads that cannot be inseedednever: a 2xx writing row inside the window implies the thread's latest non-ping row is at least as recent, so it is inside the window too. The merge loop readsoneHour[id]forseededids only. No spurious entries. (Checked, not a defect.)
What I checked
- Last review: round 1,
71ffd91dbdf1592193ffbd29d007eb79ef65bdf6, 2026-11-08T15:34:26Z. - New commits read: 1 —
7d0914ad"fix(dash): seed the tier from the latest successful write". - Read in full: 2 reviews, 1 comment, 0 inline comments (from the three files in my folder).
- New items since my last review: the author's comment at 2026-11-08T15:58:52Z, which replies to both round-1 reviews. I checked every reply against the code, as the section above shows.
- The full round-2 diff (
git diff 71ffd91d..HEAD) and the code around each change:SeedSessions, the newseedOneHourTiers,pruneSessionsLocked, and the reworked test. - The new query: outer and inner predicates match, so the outer row is the inner-selected latest qualifying row per thread.
write > 0comes from the WHERE, sowrite1h >= writeis theFactsOfrule. Both queries share thenow - staleSessionwindow. - Concurrency:
seedOneHourTiersruns beforer.mu.Lock()and touches onlyr.db.sql; the pool allows 100 open connections (dash/store.go:281), so the second query while the first result set is open is safe. Startup order in main.go is unchanged. pruneSessionsLocked: the by-age prune still deletesseedTierwithlastSeen(capture.go:709), and the wholesale reset now clears it too (capture.go:729), so the PR body's claim holds on both paths.- Traced all nine cases of
TestSeededTierAfterARestartby hand throughrestartedWith(multi-row threads, status on every row, seed time from the last row),ObserveThread,ttlTurnandAttributeCache. The expected labels follow in every case, including the two-row cases where the tier source and the recency source differ. - The test helper fails loudly if the rows do not land (poll with a 3-second deadline, then
SeedSessionsmust return 1). prefixcause.gois unchanged in this round; theseededTierguard and theNoWritebranch are as reviewed in round 1.- The updated PR body: every claim in "What changed" matches the code, the out-of-scope list names the two accepted limits, and the behavior-change banner is still at the top.
- Data dependence: unchanged, metadata only (token counts). No storage-level change.
- I did not run builds or tests (not approved); all verification is by reading the code.
|
Behavior change approved by a human developer. The repo owner (@amiddavid) approved the behavior change of #943 and #958 in the authoring session on 2026-11-08, in these words: "I approve the behavior change on both". |
SeedSessions reloaded recency and tail hash, not the billed tier that PR #943 added. After a restart, the first miss of a 1h thread fell back to the 5-minute limit and got ttl_expiry although the entry was alive. SeedSessions now reads cache_write and cache_write_1h from the latest non-ping row of each thread. It applies the FactsOf rule. ObservePrefix uses the seeded tier only while the thread has no facts, and only for a request that wrote nothing, like the read-only inheritance of #943. Closes #956 Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
Review round 1 found that the latest row of a thread can be a failed request or a full hit. Both wrote nothing, so the seeded tier was lost. SeedSessions now takes the tier from the thread's latest 2xx, non-ping row with cache_write > 0, in a second query. Recency and tail still come from the latest row. The wholesale reset also clears seedTier. Tests: failed last row, full-hit last row, failed 1h write, later 5m write, and the read-only first turn after a restart. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: DAVID AMID <[email protected]>
7d0914a to
b9695d6
Compare
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.319 | offload-review skill, @amiddavid's session | resumed | 2 of 2 | 3 of 3 | b9695d66cbe1 |
approve |
Verdict: approve
Findings
None. The PR content is unchanged from the head both reviewers approved in round 2. The only change is where the branch sits.
What changed since round 2
- Retarget and rebase, no content change. The PR moved from base
84997131to base48d54447(currentmain), and the two PR commits got new SHAs (b9282ecc,b9695d66). I compared the PR'sdash/diff against the old base with the one against the new base: byte-identical. So the code I verified line by line in rounds 1 and 2 is exactly what this PR now proposes. - The rebase absorbed eight main commits (#945, #950, #946, #954, #951, #943, #937, #944). They are not this PR's changes. Only two of them touch
dash/at all: #937 editsdash/keepalive.goand addsdash/write1hfrac_test.go; #943 is the PR this one was stacked on, and its content was already the old base. Neither overlapsdash/capture.go,dash/prefixcause.goordash/prefixcause_test.go. The byte-identical diff confirms no interaction. - The human approval for the behavior change is on the PR (comment at 2026-11-08T16:04:52Z): the repo owner approved the behavior change of #943 and #958 on 2026-11-08. That closes the gate CLAUDE.md and RELEASING.md set for a behavior change.
- Reviewer 1's round-2 review (16:02:46Z): approve. I read it in full. Their non-blocking note — recency can come from a non-2xx row while the tier comes from the last write, so the seeded age can read shorter than the live path would — is correct, pre-existing for recency, and safe in direction. Nothing to add.
What I checked
- Last review: round 2, 7d0914a, 2026-11-08T16:01:40Z.
- New commits read: the range
7d0914ad..HEADholds 10 commits. Two are the rebased PR commits (b9282ecc"seed the billed cache tier after a restart",b9695d66"seed the tier from the latest successful write"); I verified their combineddash/diff is byte-identical to the approved84997131..7d0914addiff. The other eight are main merges absorbed by the rebase; I read their stats and confirmed none touch this PR's three files. - Read in full: 4 reviews, 2 comments, 0 inline comments (from the three saved files; the inline file is empty).
- New items since my last review: the rebase and retarget (checked for content change, none); reviewer 1's round-2 review (read, agreed); the owner's behavior-change approval comment (checked against the PR's banner, satisfied).
- The PR body against the code once more: the "What changed" and "Out of scope" sections still match, now against the new base.
- I did not run builds or tests (not approved for this review); all verification is by reading the code and the diffs.
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.319 | offload-review skill, @amiddavid's session | resumed | 1 of 2 | 3 of 3 | b9695d66cbe1 |
approve |
Verdict: approve
Findings
None. The code is byte-identical to the head I approved in round 2. Only the base moved.
What changed since round 2
- The retarget. The PR moved from the #943 stack to
mainat48d54447.git range-diffreports both patches unchanged (71ffd91d = b9282ecc,7d0914ad = b9695d66), and the cumulative diff against the new base is identical, byte for byte, to the diff I approved in round 2. The PR body asked for this retarget after #943 merged; #943 is in the new base ase5fe606d. - The new base. Eight upstream commits landed between the old and the new base. I checked each for interaction with this PR. Only #937 touches the same area: it changes 1h-write pricing (
Price.CacheWrite1hFor,Resolved) indash/keepalive.go,internal/modelinfoandkvcache.modelinfo.CacheLifetimelives ininternal/modelinfo/cachelifetime.goand is untouched, and no base commit touchesdash/capture.go,dash/prefixcause.go,dash/prefixcause_test.goorproxy/dashcapture.go. The other commits (#944, #945, #946, #950, #951, #954) touch docs, CI and scripts only. - The behavior change has the owner's yes. The comment at 2026-11-08T16:04:52Z records the owner's approval in their words, with the date. This closes the one open condition from the PR's own banner.
- Reviewer 2's round-2 review (2026-11-08T16:01:40Z, approve) matches my round-2 result. I read it in full; I have no new proof to add and no disagreement.
What I checked
- Last review: round 2,
7d0914add53dcc6c5e56d30fa81800003032db8b, 2026-11-08T16:02:46Z. - New commits read: the two PR commits rebased (
b9282ecc"seed the billed cache tier after a restart",b9695d66"seed the tier from the latest successful write") — both verified identical to the reviewed patches — plus the eight base commits, read as a diff against the PR's touch points. - Read in full: 4 reviews, 2 comments, 0 inline comments (from the three files in my folder).
- New items since my last review: reviewer 2's round-2 review (read, agreed); the author's comment recording the owner's behavior-change approval (checked against the PR banner); the retarget to
main(verified withgit range-diffand a byte-compare of the cumulative diffs). - The PR body: still matches the code; the base is now
main, as the body itself instructed. - My round-2 approval stands for the code: the seeding, the
NoWritecommit branch, the prune paths, the locking, and the nine traced test cases. - I did not run builds or tests (not approved); all verification is by reading the code.
Behavior change — needs a human developer's yes
ttl_expiry.ttl_expiryin that window.Stacked on #943. Retarget this PR to
mainafter #943 merges.Closes #956
Summary
SeedSessionsnow reloads the billed cache tier of each thread.What changed
SeedSessionsreads the thread's latest non-ping, 2xx row withcache_write > 0. Recency and tail still come from the latest row.cache_write_1h >= cache_write. It is the rule ofFactsOf.Recorder.seedTiermap, with the per-thread key. It ages out withlastSeenand clears in the wholesale reset.ObservePrefixreturns the seeded tier for the first request after a restart, while the thread has no facts. If that request wrote nothing, it also commits the tier, like fix(proxy): label a 1h thread's miss by its billed TTL, not 5m #943 does for a read-only turn.How it was tested
TestSeededTierAfterARestart(restart = new Recorder andSeedSessionson the same DB; miss after 20 min with a changed prefix). Cases: 1h, 5m, mixed write, only read rows, full-hit last row, failed last row, failed 1h write, later 5m write, read-only first turn.NoWritebranch: the read-only case fails. Drop the status and write filters: the "only read rows" and "failed 1h write" cases fail. Remove the seeding: the 1h case fails.go test -race ./dash/...ok,go test -race ./proxy/...ok,go vet,gofmtclean.Data dependence
Metadata only (token counts). No change at any storage level.
docs/data-dependence.mdneeds no update.Out of scope (known limits)
/modelswitch across a restart borrows the other model's tier. The first request per model readscold_startanyway.