Skip to content

fix(proxy): label a 1h thread's miss by its billed TTL, not 5m - #943

Merged
amiddavid merged 2 commits into
mainfrom
fix/ttl-expiry-1h
Nov 8, 2026
Merged

amiddavid merged 2 commits into
mainfrom
fix/ttl-expiry-1h

Conversation

@amiddavid

@amiddavid amiddavid commented Nov 8, 2026 •

Copy link
Copy Markdown
Collaborator

Behavior change — needs a human developer's yes

  • Who: threads on a 1h cache tier on Anthropic, Bedrock and Vertex.
  • Old: a miss after 5-60 minutes got ttl_expiry. The summarizer got the write rate. The turn counted as keep-alive-addressable.
  • New: the miss gets prefix_change or unknown, as for a live entry. The summarizer gets the read rate. The turn no longer counts as ttl_expiry. A miss after 60 minutes is still ttl_expiry.
  • Dollar effect: a summarizer's first removal on a 1h thread's miss moves from the write rate to the read rate. Savings shown on those turns go down.
  • Trend break: the miss-reason series breaks at this commit. Old rows keep their label.
  • Switch: none. The old label was wrong. Old rows keep their label.
  • Data dependence: metadata only. It uses the cache_write_1h and cache_write token counts. No stored text. No row in docs/data-dependence.md changes.

Closes #941.

Summary

A 1h thread no longer gets ttl_expiry for a miss inside the hour.

What changed

  • PrefixFacts has two new flags: OneHour (the whole write billed at 1h, as keepalive ResolveTier does; a mixed 1h head plus 5m tail stays 5m) and NoWrite.
  • ObservePrefix returns the previous same-model request's billed tier. A request that wrote nothing inherits it.
  • cacheAttributionTTLMs takes that tier. 1h gives 3,600,000 ms. Unknown gives 5 minutes.
  • Tier source: the capture state already tracks per-thread facts. This needs no keeper, so it works with the keeper off. It uses the billed tier, not the asked tier.
  • apply.CacheLifetime and modelinfo.CacheLifetime are unchanged.

How it was tested

New tests cover:

  • 1h thread, miss after 20 min, changed prefix: not ttl_expiry
  • 1h thread, miss after 70 min: ttl_expiry
  • mixed write (1h head, 5m tail): stays ttl_expiry
  • fork's first request inherits the parent's tier
  • 1h asked, billed 5m, miss after 10 min: ttl_expiry
  • 5m thread: unchanged
  • read-only turn keeps the 1h tier
  • summarizer on the 20 min 1h case: read rate

Commands, on the shared box:

  • go test -race ./dash/...: ok
  • go test -race ./proxy/...: ok
  • go vet ./dash/ ./proxy/, gofmt -l: clean
  • Mutation (revert the tier source and the 1h branch): the new tests fail.

Out of scope

  • keepaliveCreditFloorMs (dash/event.go)
  • the 1h write-rate pricing

Both are report-only. The accountant merge replaces them.

  • Restart seeding: the tier is in memory, so the first miss after a restart can still read ttl_expiry.
  • dash/keepalive.go:206 uses the asked tier, not the billed tier.

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

The cache attribution always used the 5-minute lifetime. A miss on a
1h thread after 5-60 minutes got ttl_expiry although the entry was
alive. The lifetime now follows the billed tier (cache_write_1h > 0)
of the thread's previous same-model request. A read-only request keeps
that tier. An unknown tier keeps 5 minutes.

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

@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.319 offload-review skill, @amiddavid's session fresh 1 of 2 1 of 2 b99d17bf3ccf approve

Verdict: approve

Findings

None. I could not prove a defect in the changed logic.

Non-blocking

  • dash/prefixcause.go:48 — a mixed write (some 5m, some 1h breakpoints) reads as fully 1h.
    OneHour = e.CacheWrite1h > 0 sets the tier when any part of the write was billed at 1h. For a full miss this is right: every breakpoint must have missed, so a surviving 1h part would have produced a read. For a partial-read miss (partialRead in AttributeCache) where only the 5m part expired, the label now reads unknown, not ttl_expiry. The error direction is under-credit, which the pricing comments name as the safe one. No change needed.
  • The tier does not survive a restart. lastFacts is in-memory only. SeedSessions reloads refresh times but not the tier, so the first post-restart miss of a 1h thread after 5–60 minutes is again labeled ttl_expiry. This is the exact bug the PR fixes, narrowed to one turn per thread per restart. The requests table holds cache_write_1h, so a later PR could seed it.
  • dash/keepalive.go:206 still uses the asked tier. The keep-alive coverage SQL passes cache_ttl = '1h' (what the request asked for), not the billed tier this PR moves to. A 1h-asked, 5m-billed thread gets a too-long coverage window there. Pre-existing and out of scope, but it is the same class of issue.
  • Name the figure change in the PR body. The label change moves the summarizer's unique rate on a 1h thread's miss from the write rate to the read rate (uniqueRate, dash/event.go:927). Savings figures on those turns go down. The commit message names the label; confirm the PR body names the dollar change too.
  • The fromThread path of the tier inheritance is not tested. A read-only first request of a forked thread inherits the parent's tier (same can come from the parent). Only the same-thread path has a test.

What I checked

  • The full diff of dash/prefixcause.go, dash/prefixcause_test.go, proxy/dash_test.go, proxy/dashcapture.go, and the commit message.
  • The tier plumbing end to end: FactsOf sets OneHour/NoWrite from usage; ObservePrefix inherits the tier on a read-only turn and returns prev.OneHour; cacheAttributionTTLMs maps it through modelinfo.CacheLifetime. I traced every return path of ObservePrefix, including the nil-receiver, fromThread, failed-request (!commit) and model-change paths.
  • That CacheWrite1h is a subset of CacheWrite (internal/providerusage/providerusage.go:15, proxy/usage.go:31, dashcapture.go:545). So NoWrite = CacheWrite == 0 really means "wrote nothing at either tier", and a 1h-only write is not misclassified. PromptTokens also already includes the 1h part.
  • That AttributeCache uses the TTL only for the ttl_expiry label, after the cold-start case and before the cause cases ("TTL wins ties"). A longer TTL can only remove ttl_expiry labels, never add one. The only dollar effect is uniqueRate, in the under-credit direction.
  • That cacheAttributionTTLMs keeps returning 0 for OpenAI and Gemini: the kind != Exact early return runs before the new oneHour branch, so the GPT-5.6+ 30-minute minimum cannot be turned into an "exact" 1h.
  • That all callers of the changed signatures were updated: ObservePrefix (only proxy/dashcapture.go and tests), cacheAttributionTTLMs (only dashcapture.go and tests). Test imports (time in proxy/dash_test.go, modelinfo in dash/prefixcause_test.go) are present.
  • The new tests by hand: all six TestTTLExpiryUsesTheBilledTier cases, TestTTLTierSurvivesAReadOnlyTurn (fails without the inheritance fix), and TestSummarizerOnA1hThreadMissIsPricedAtTheRead. Each expected label matches my trace of AttributeCache.
  • Locking (r.mu held for the whole ObservePrefix body) and the lastFacts pruning path (pre-existing).
  • Data dependence: the change reads usage token counts only, already covered by the metadata rule. No new stored data.
  • I did not read the PR body or any PR comments, per the round-1 rule. I did not run builds or tests (not approved; Go is not on this machine).

@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.319 offload-review skill, @amiddavid's session fresh 2 of 2 1 of 2 b99d17bf3ccf blocking

Verdict: blocking

Findings

  1. dash/prefixcause.go:48 — OneHour: e.CacheWrite1h > 0 calls a mixed-tier write a one-hour entry, but only part of it lives one hour
    • What fails: a request can bill a 1h head and a 5m tail in one write (cache_write_1h > 0 and cache_write_1h < cache_write). This is a designed shape in this repo: apply/headttl.go builds exactly it ("a one-hour anchor on the request's HEAD, the five-minute default on its tail"), and a client can send the same mix. The flag then says the whole entry lives 1h. On the next request, 5 to 60 minutes later, the 5m tail is gone but the 1h head is alive. With a tail-dominant prompt the row is a partial-read miss, the cause is "" (nothing differed), and the TTL test now compares 20 min against 1h. The row reads unknown. Before this PR it read ttl_expiry, which was correct: the tail died of TTL.
    • Proof: trace — turn N rewrites the system block (head 10k billed at 1h, tail 40k billed at 5m; CacheWrite=50k, CacheWrite1h=10k, so OneHour=true). Turn N+1 after 20 min, prefix unchanged: CacheRead=10k (live head), CacheWrite=40k (tail re-created). AttributeCache (dash/event.go:1206): partialRead holds (10k*2 < 50k, 40k > 10k), TTL = 1h so 20 min < TTL, cause = "" → CacheUnknown. The repo already answers this exact question the other way: keepalive/keeper.go:257-277 (ResolveTier) rejects a mixed write with u.CacheWrite1h >= u.CacheWrite, and its comment names the reason — "A mixed ask (the proxy's own 1h head over a 5m tail) leaves a tail that expires in five minutes". The label also moves a dollar figure: uniqueRate (dash/event.go:927) prices a summarizer's first removal at the write rate only on ttl_expiry/cold_start. The removed transcript is the tail, and its 5m entry expired, so the honest counterfactual is a re-write at the write rate. The new label prices it at the read rate.
    • Fix: demand the whole write at the 1h tier, as ResolveTier does: OneHour: e.CacheWrite > 0 && e.CacheWrite1h >= e.CacheWrite. A mixed write keeps the five-minute lifetime. The new tests write 400k of 400k at 1h, so they pass unchanged. Add one case: head 1h + tail 5m, miss after 20 min, want ttl_expiry.

Non-blocking

  • cacheAttributionTTLMs (proxy/dashcapture.go:768) now takes its 5m base from apply.CacheLifetime and its 1h upgrade from modelinfo.CacheLifetime. One modelinfo.CacheLifetime(provider, model, oneHour) call after the Exact check would give both. The values come from the same constants, so they cannot drift today. Style only.
  • Old rows keep the labels they got. AttributeCache's comment already says so. No migration is needed for a label fix, but readers of the miss-reason trend should know the series breaks at this commit.
  • This change moves dashboard labels and the summarizer saving figure. CLAUDE.md asks that such a change be named at the top of the PR. I did not read the PR body (round 1 rule), so I only ask the author to confirm it is there.

What I checked

  • The full diff f43d9fa5..HEAD and the code around every hunk: dash/prefixcause.go, dash/prefixcause_test.go, proxy/dashcapture.go, proxy/dash_test.go.
  • Every caller of the changed symbols. ObservePrefix has one production caller (proxy/dashcapture.go:662) and test callers, all updated for the new return value. cacheAttributionTTLMs has one production caller, updated. FactsOf has one production caller.
  • The label path end to end: FactsOf → ObservePrefix (tier inheritance on a read-only turn, parent-thread inheritance, failed-request handling) → entryAgeMs/keep-alive age cut → AttributeCache case order → uniqueRate.
  • The TTL sources: apply.CacheLifetime (nil body → 5m, Exact only for cache-control providers), modelinfo.CacheLifetime, HonoursCacheControl (anthropic, bedrock, bedrock-mantle, vertex), so the new proxy test's bedrock case is right and the OpenAI Minimum case still returns 0 before the 1h branch.
  • The new tests by hand, each case traced through AttributeCache: all six TTL cases, the read-only tier survival, and the summarizer read-rate case give the wanted values.
  • The keep-alive side for consistency: keepalive/keeper.go ResolveTier (finding 1), dash/keepalive.go missLifetime, dash/kvcache.go observedTTL. The keeper's own tier rule and the ping paths do not touch lastFacts, so no double counting.
  • Data dependence: the new fact is a token count and a flag, already stored. No new data class. docs/data-dependence.md needs no row.
  • No live tests were run (not approved). No files outside this folder were changed.

A mixed write (1h head, 5m tail) now keeps the five-minute lifetime,
as keepalive ResolveTier does. cacheAttributionTTLMs makes one
modelinfo.CacheLifetime call. New tests cover a mixed write and the
fork inheriting its parent's tier.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
@amiddavid

Copy link
Copy Markdown
Collaborator Author

Round 1 replies. New head: 8499713.

Reviewer 2, finding 1 (blocking, mixed write): fixed in 8499713. OneHour is now CacheWrite > 0 && CacheWrite1h >= CacheWrite, as in ResolveTier. New test: head 10k at 1h plus tail 40k at 5m, miss after 20 min, gives ttl_expiry. It fails with the old rule. The read-only inheritance test still passes.

Reviewer 2, non-blocking:

  • One modelinfo.CacheLifetime call: fixed in 8499713.
  • Trend break: named in the PR body.
  • Top-of-PR block: present, now with the dollar effect.

Reviewer 1, non-blocking:

  • Mixed write read as 1h: fixed, same change as finding 1.
  • Restart does not keep the tier: out of scope. Listed in the PR body.
  • dash/keepalive.go:206 asked tier: out of scope. Listed in the PR body.
  • Dollar change in the PR body: fixed.
  • fromThread test: fixed in 8499713 (TestTTLTierIsInheritedFromTheParentThread).

Tests: go test -race ./dash/... ok, go test -race ./proxy/... ok, vet and gofmt clean.

@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.319 offload-review skill, @amiddavid's session resumed 2 of 2 2 of 2 84997131b07e approve

Verdict: approve

Findings

None. My round-1 finding is fixed, and I found no defect in the new commit.

Round-1 findings

  1. Mixed write read as a 1h entry — fixed in 8499713. FactsOf now sets OneHour: e.CacheWrite > 0 && e.CacheWrite1h >= e.CacheWrite, the billed half of ResolveTier's rule. I traced the new test TestTTLExpiryOnAMixedWriteKeepsFiveMinutes by hand: turn 1 writes 50k (10k at 1h), so OneHour=false; turn 2 at +20 min reads 10k, writes 40k, partialRead holds, TTL stays 5m, 20 min > 5m → ttl_expiry. That is the exact scenario of my finding. The doc comment on PrefixFacts.OneHour now states the whole-write rule and names ResolveTier.

    I also checked the stricter rule for a new hole: can a pure-1h write (all written tokens at 1h) still mask a live 5m tail? No. The provider hashes head before tail, so a head write forces a tail write too. A write that is all 1h therefore covers the whole written prefix, and the shapes left are all-5m, mixed (now 5m), and all-1h. Sound.

Non-blocking

  • Reviewer 1's two scoped-out items (restart seeding of the tier, dash/keepalive.go:206 using the asked tier) stay out of scope. Both are named in the PR body under Out of scope. Each deserves its own issue later, per the repo rule that a main defect does not ride a feature branch.
  • The author reports go test -race ./dash/... and ./proxy/... green on the shared box. I could not run them (live tests not approved). My hand traces of every new and changed test agree with the wanted values.

What I checked

  • Last review: round 1, b99d17b, 2026-11-08T10:12:51Z.
  • New commits read: 1 — 84997131 "fix(dash): count only a whole 1h write as the one-hour tier".
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from the three saved files), plus the PR body.
  • New items since my last review, and what I did about them:
    • Commit 84997131: read the full diff and the code around each hunk. The OneHour rule, the cacheAttributionTTLMs simplification, and the two new tests all check out (details below).
    • Author's round-1 reply comment (2026-11-08T10:35:01Z): verified each claim against the code. "Fixed" claims are real; "out of scope" claims are named in the PR body.
  • The cacheAttributionTTLMs rewrite: the Exact gate still runs first, so OpenAI Minimum and Gemini Unknown still return 0. The one modelinfo.CacheLifetime call returns the same 5m/1h values as the old two-source shape. This also closes my round-1 style note.
  • The ttlTurn refactor: it now derives OneHour, NoWrite and PromptTokens through FactsOf, so the test mirrors production. PromptTokens is new and non-zero; I traced its only effect (partialRead) through every existing case — no wanted label changes.
  • TestTTLTierIsInheritedFromTheParentThread: traced both calls. The fork's read-only first request inherits the parent's tier through the fromThread lookup; the second request keeps it through the fork's own stored facts. This closes reviewer 1's untested-path note.
  • The PR body: the behavior-change block sits at the top, with who, old, new, the dollar effect, the trend break, and the data-dependence statement (metadata only). This closes my round-1 disclosure note.
  • No live tests were run (not approved). No files outside this folder were changed.

@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.319 offload-review skill, @amiddavid's session resumed 1 of 2 2 of 2 84997131b07e approve

Verdict: approve

Findings

None. The fix commit is correct, and every round-1 item is resolved or accepted as out of scope.

Earlier findings

  • Reviewer 2, finding 1 (mixed write, blocking): fixed in 8499713. I checked it myself, not only the reply. OneHour is now CacheWrite > 0 && CacheWrite1h >= CacheWrite (dash/prefixcause.go:50). CacheWrite1h is a subset of CacheWrite, so the test says "the whole write was billed at 1h", the same billed half as keepalive.ResolveTier (keepalive/keeper.go:269). I traced TestTTLExpiryOnAMixedWriteKeepsFiveMinutes through AttributeCache: head 10k at 1h, tail 40k at 5m, next turn reads 10k and re-writes 40k after 20 min. partialRead holds (20k < 50k, 40k > 10k), TTL stays 5m, 20 min > 5m → ttl_expiry. Under the old rule the tier reads 1h and the label becomes unknown, so the test guards the fix.
  • Reviewer 2, non-blocking (one modelinfo.CacheLifetime call): fixed. The refactor is behavior-identical: apply.CacheLifetime(provider, model, nil) returns modelinfo.CacheLifetime(provider, model, false) for Exact providers, and the non-Exact early return still runs first, so OpenAI and Gemini still get 0.
  • My round-1 items: mixed write — fixed by the same change. Restart seeding and dash/keepalive.go:206 — the author rejects both as out of scope and lists them in the PR body; I accept that, both are pre-existing and report-only. Dollar change named in the PR body — verified, the top block has who, old, new, dollar effect, trend break, switch ("none") and data dependence. fromThread test — added (TestTTLTierIsInheritedFromTheParentThread), traced and correct.

Non-blocking

  • The new fork test sets OneHour and NoWrite by hand, not through FactsOf. It tests ObservePrefix in isolation, which is what it claims, so this is fine. The production path (FactsOf → ObservePrefix) is covered by ttlTurn.
  • The ttlTurn helper now also sets PromptTokens from the usage (it did not before). I checked the existing tests for a behavior change from that: every asserted turn has CacheRead = 0, so partialRead cannot change an outcome. No impact.

What I checked

  • Last review: round 1, b99d17bf3ccf65c4827c5ce7f391ae1718131e8a, 2026-11-08T10:11:59Z.
  • New commits read: 1 — 84997131 "fix(dash): count only a whole 1h write as the one-hour tier".
  • Read in full: 2 reviews, 1 comment, 0 inline comments (from .review-in-reviews.txt, .review-in-comments.txt, .review-in-inline.txt). I also read the PR body, to verify the author's claims about it.
  • New items since my last review, and what I did:
    • Reviewer 2's round-1 review (blocking on the mixed write): checked the finding and the fix myself, as above. Its proof matches the code I read; I have nothing to add.
    • The author's round-1 reply comment: checked each claim. "Tests ok on the shared box" I cannot re-run (live tests not approved, Go not on this machine); I verified the new and changed tests by hand trace instead. The PR-body claims (behavior-change block, dollar effect, trend break, out-of-scope list) I verified against the body itself: all present.
    • Commit 84997131: full diff plus the code around each hunk.
  • The new OneHour rule against real usage shapes: a whole-1h write gives CacheWrite1h == CacheWrite (subset semantics, internal/providerusage/providerusage.go:15), so it still reads 1h; a 5m-only write and a missing usage block both read 5m or inherit; the round-1 tests (400k of 400k at 1h) still pass under the stricter rule.
  • The consumers of the ttl_expiry label (uniqueRate, dash/compactepisode.go:858,1019,1044) — the PR body's claims about the summarizer rate and keep-alive addressability match them, and all are report-only.
  • ResolveTier (keepalive/keeper.go:257-277) for the claimed rule match, and apply/headttl.go for the mixed-write shape being real.
  • I did not run builds or tests (not approved). No files outside this folder were changed.

@amiddavid

Copy link
Copy Markdown
Collaborator Author

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".

amiddavid added a commit that referenced this pull request Nov 8, 2026
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]>
amiddavid added a commit that referenced this pull request Nov 8, 2026
Round 1 of #960, non-blocking points:
- The CodeQL check run must come from GitHub's code-scanning app
  (github-advanced-security), so a job renamed to CodeQL cannot pass
  the check with no scan behind it.
- A passing check run can still carry an alert. The script now also
  reads the open code-scanning alerts on the PR's merge ref, and a
  failed read stops it with an error.
- The messages say what to do: the PR must target main to be scanned,
  and a run still in progress means wait.

Tested with a stub gh: a clean PR is READY; an open alert gives NOT
READY with the alert; a failed alert read gives an ERROR. On real
PRs: #951 and #960 pass the scan check; #943 fails it.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 8, 2026
check-ready.sh now fails a PR whose head has no passing CodeQL check
run from GitHub's code-scanning app. RELEASING.md gets new rules:
a PR opened before #945 needs a new push before it merges; after an
--admin merge, read the merge's rule results and tell the owner of
any failed rule other than the review rule; a PR's scan covers only
its changed lines, so read main for all open alerts; a false
positive is dismissed only with the owner's yes.

Why: on 2026-11-08 #943, #937 and #944 merged past the code-scanning
rule because they were opened before the CodeQL workflow (#945).
CodeQL scans of main afterwards found no new alert. --admin does not
say which rules it bypasses, and the script did not check code
scanning.

New integrator rule: an integrator talks with many sessions and with
the owner, so its main session must stay free. Implementation work
goes to subagents, and the main session only coordinates. The owner
asked for this.

Behavior change: none. Release scripts and docs only.
Data dependence: none. The script reads GitHub check runs only.

Reviews: 2 offload reviews (GLM), round 3 (owner granted round 3), both approve at df9d719.

Assisted-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
amiddavid added a commit that referenced this pull request Nov 8, 2026
The dashboard now seeds the billed cache tier of each thread after a
proxy restart. Before, SeedSessions reloaded recency and the tail
hash, but not the tier that #943 added. After a restart, the first
miss of a 1h thread fell back to the 5-minute limit. It got
ttl_expiry although the entry was alive. SeedSessions now reads the
tier from the thread's latest successful (2xx), non-ping row with
cache_write > 0. It applies the FactsOf rule: cache_write_1h >=
cache_write. A failed request or a full hit does not erase the tier
of the earlier write. ObservePrefix uses the seeded tier only for the
first request after a restart, while the thread has no facts. A
thread with no successful write in the window keeps the 5-minute
limit. Closes #956.

Behavior change: this affects 1h-TTL threads on Anthropic, Bedrock
and Vertex, across a proxy restart. Old: the first miss after a
restart, 5 to 60 minutes after the last request, got ttl_expiry.
New: the label follows the billed tier of the thread's last
successful cache write before the restart. A 1h thread is no longer
ttl_expiry in that window. Switch: none. It is a label fix with no
setting.
Owner's yes, 2026-11-08, in the integrator session: "it will send u 958 and 959 both approved".

Data dependence: metadata only (token counts). No change at any
storage level. docs/data-dependence.md needs no update.

Reviews: 2 offload reviews (GLM), round 3 (owner granted round 3), both approve at b9695d6.

Assisted-By: Claude (Anthropic AI) <[email protected]>
Signed-off-by: DAVID AMID <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

A miss on a 1h-TTL thread is labelled ttl_expiry after 5 minutes

1 participant