Repository navigation
fix: thread partial-progress saves into non-Claude provider phases - #1097
Merged
Merged
Conversation
scanProjectDirs (Claude) has long taken a throttled saveProgress callback so a killed cold parse resumes from a warm cache; parseProviderSources (every other provider) only persisted at the whole-provider boundary. A run killed mid-way through a large single- provider phase (a multi-GB codex corpus is the common case) discarded everything parsed since the last provider finished, restarting that whole phase from zero. parseProviderSources now accepts the same onFileParsed callback, invoked once per source right after that source's cache entry lands, outside the per-file try/catch, mirroring scanProjectDirs' placement and throttle. A file's fingerprint is only ever set after it fully parses, so a mid-file kill can never leave a half-parsed file looking complete on resume. Verified against a real ~2GB Claude + ~4GB codex corpus (frozen snapshot): kill -9 mid-codex-phase leaves a genuine partial cache (no codex-results flush, complete: false), a resume only reparses the unfinished remainder, and the final report is byte-identical to an uninterrupted cold parse.
This was referenced Aug 22, 2026
Closed
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.
Summary
scanProjectDirs(Claude) has long taken a throttledsaveProgresscallback (src/parser.ts:1949) so a killed cold parse resumes from a warm cache.parseProviderSources(every other provider — codex, cursor, gemini, and the rest) did not accept it, and only persisted at the whole-provider boundary (a comment near the top ofparseProviderSourcesacknowledged this).parseProviderSources(src/parser.ts:3023) now accepts the sameonFileParsedcallback and invokes it once per source, right after that source's cache entry lands andmarkCacheDirtyruns — placed outside the per-file try/catch (mirroringscanProjectDirs' exact placement) so a throttled caller only ever observes a fully-installed entry, never a mid-write one. Both call sites inparseAllSessionsnow thread the existingsaveProgressclosure through, on its existing file-count/wall-clock throttle — no new throttle, no new write mechanism.Correctness / safety
fingerprintis written intosection.files[source.path]only after its entire parse (for await (const call of parser.parse())) has finished and the resulting turns/calls are computed — never incrementally. A mid-file kill therefore can never leave a half-parsed file's fingerprint looking complete on resume; the file simply doesn't appear in the cache yet and gets fully re-parsed next run.Test
tests/provider-phase-partial-save.test.tsdrivesparseProviderSourcesdirectly against a 4-file Kiro fixture:Confirmed revert-proof: reverting
src/parser.tsalone makes the test fail immediately (parseProviderSources is not a function, since it isn't exported pre-fix).Real-corpus sanity (read-only source, scratch cache)
Froze a snapshot of a real ~2 GB Claude + ~4 GB codex corpus (1396 codex rollout files) to an isolated
HOME/CLAUDE_CONFIG_DIR/CODEX_HOMEfor a byte-identical comparison:kill -9~1.5s into the codex phase: cache left withcomplete: false, 637/1396 codex files captured, nocodex-results.v15.jsonflush marker (proof the kill was genuinely mid-loop, not post-completion).1396 - 637), confirming only the unfinished remainder re-parses.generatedtimestamp) is byte-identical to the uninterrupted reference.Verification
tsc --noEmit: cleannpm test: 222 files / 3023 tests passed, 5 skipped, exit 0npm run verify:upgrade: PASSED (parity vs 0.9.20 baseline, serve --stdio, parse-worker determinism, warm-run idempotence, never-lose-across-partial-source-aging all green)Closes nothing on its own; documents the telemetry/repro findings above.