Repository navigation
fix(cache): record session-cache completeness per provider - #1303
Merged
Merged
Conversation
A scan is scoped on two axes, provider and date range, but completeness was one whole-cache boolean. #1229 stopped a scoped run from stamping it by adding a second, unfiltered discoverAllSessions to the stamp path, which left scoped users on a multi-provider machine permanently cold and paid an extra full discovery on every run. Completeness now lives on the provider section, with an optional completeFrom floor for the sources a date range filtered out. The whole-cache flag keeps its meaning (an unscoped scan finished) and is what a section with no flag of its own falls back to, so existing caches read exactly as before and no version bump is needed. Discovery reports which providers threw, and a provider that reported nothing because it failed is never marked complete.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the conservative guard from #1229 with the per-provider model the review preferred but deferred.
SessionCache.completeis one whole-cache boolean, but a scan is scoped on two axes. fix(parser): avoid marking partially scanned caches complete (#912) #1229 kept a provider-scoped run from stamping it by running a second, unfiltereddiscoverAllSessions()in the stamp path. On a multi-provider machine nothing else writes the flag, so scoped users never go warm: every run re-enters cold hydration and pays a full discovery across all providers (Codex reads up to 64KB per uncached rollout). That hits the Claude-scoped refresh inusage-aggregator.ts, which exists precisely to avoid touching other providers.ProviderSection.complete. A scoped run marks only the provider it walked; an unscoped run marks every section and the whole-cache flag, which is the only thing that can vouch for providers with no section at all.true= all complete,false/absent = none). The two new envelope fields are additive and ignored by older readers, soCACHE_VERSIONis unchanged and nobody's session cache is thrown away.DAILY_CACHE_VERSIONis untouched.dateRange.startstores that start as the section'scompleteFromfloor instead of claiming all of history. A watermark rather than a plain boolean because nearly every parse is ranged - the 365-day history parse skips everything older, and withholding completeness outright would leave any machine with older sessions permanently cold. Readers pass the requested range start; a wider request than the floor re-enters cold hydration and lowers the floor as it goes.discoverAllSessionsWithFailuresreports which providers threw, and one that returned an empty list because it failed is never marked complete. Per-file and per-provider parse isolation is unchanged.npx tsc --noEmitclean; fullnpm test3938 passed, 5 skipped, 0 failed across 290 files.tests/scoped-run-completeness.test.tsrewritten (deadCODEX_HOMEblock dropped - the codex provider resolves its dir at import time andtests/setup/env-isolation.tsalready isolates it) with cases for scoped marking, three-run convergence with a cold-hydration counter, the date floor, a throwing provider, and both legacy-cache states.Known gap: a provider skipped mid-parse on a permission error is still marked complete, as it is today. Left alone deliberately - changing it would leave a Full-Disk-Access-denied machine cold on every launch, which is a separate call.