Repository navigation
[PR] perf: rewrite fold coverage without repeated scans - #6705
Merged
ranxianglei merged 1 commit intoNov 14, 2026
Merged
Conversation
This was referenced Nov 14, 2026
ranxianglei
pushed a commit
that referenced
this pull request
Nov 15, 2026
The rebase onto f648217 (which carries #6705's fold-coverage linear rewrite, the instruction-preservation reconcile fixes, and 7402629's OpenAI cache-attribution golden regen) changes the persisted state the drive produces. Regenerated with the sanctioned scripts/update-storage-render-goldens.ts; only digest values move (stateDigest/stateDigestAligned, stats/metadata sections) — no wire body or structural change.
ranxianglei
pushed a commit
that referenced
this pull request
Nov 17, 2026
The rebase onto f648217 (which carries #6705's fold-coverage linear rewrite, the instruction-preservation reconcile fixes, and 7402629's OpenAI cache-attribution golden regen) changes the persisted state the drive produces. Regenerated with the sanctioned scripts/update-storage-render-goldens.ts; only digest values move (stateDigest/stateDigestAligned, stats/metadata sections) — no wire body or structural change.
ranxianglei
pushed a commit
that referenced
this pull request
Nov 18, 2026
The rebase onto f648217 (which carries #6705's fold-coverage linear rewrite, the instruction-preservation reconcile fixes, and 7402629's OpenAI cache-attribution golden regen) changes the persisted state the drive produces. Regenerated with the sanctioned scripts/update-storage-render-goldens.ts; only digest values move (stateDigest/stateDigestAligned, stats/metadata sections) — no wire body or structural change.
ranxianglei
pushed a commit
that referenced
this pull request
Nov 19, 2026
The rebase onto f648217 (which carries #6705's fold-coverage linear rewrite, the instruction-preservation reconcile fixes, and 7402629's OpenAI cache-attribution golden regen) changes the persisted state the drive produces. Regenerated with the sanctioned scripts/update-storage-render-goldens.ts; only digest values move (stateDigest/stateDigestAligned, stats/metadata sections) — no wire body or structural change.
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.
Closes #6704
Problem
After reconciliation has matched a resent history to existing folds,
rewriteBlocks()rewrites effective and direct coverage one ID at a time. Each target performs a full-array membership scan, and each replacement shifts the remaining array withsplice(). A full remint or a model switch between split reasoning/text and merged assistant turns therefore incurs quadratic coverage-array work even when every match is unambiguous.Change
Build occurrence counts for the current list, then emit a stable replacement list in one pass. The counts include unread originals and replacements already emitted, preserving the existing membership decision at each step. Copy the result back into the original array so callers retain the same array references, including shared effective/direct coverage arrays.
The change is confined to coverage rewriting. Matching, reconciliation modes, anchor storage, turn-integrity enforcement, and kernel code keep their existing behavior. The rewrite uses temporary counts and an output array proportional to the coverage size.
Verification
reconcileFoldCoverage()path. They cover a full remint, reasoning/text-pair collapse, merged-turn expansion, shared coverage arrays, warn-mode non-mutation, unchanged resends, and mixed stable/reminted IDs with repeated claims.9495c764d36909eec263f404d4802d68b608f23f, the three complexity regressions fail with 5,132,800, 1,445,400, and 2,883,600 operations respectively; the other three controls pass. The assertions also verify exact ordered contents, successful reconciliation, and original array identity before enforcing the work bound.a86713cda51998ae46bfd47bd18ec30be22a8cb9548ed1062ca53e1851f98763). These figures describe this synthetic case, not every history shape.npm run typecheck,npm run build, andgit diff --checkpass. Full repository tests were not run locally; hosted CI remains pending.Prior work checked
The complete Afloat16 production-patch index has only #6492 touching this file; that change bounds claimed-message index extrema and does not modify
rewriteBlocks(). Actual relevant patches from #2644 (the existing one-to-many/many-to-one rewrite), #4353 (turn integrity), #4085 (retained inactive coverage), #2738, and #2300 do not implement this optimization. All-state rewrite/quadratic-reconciliation searches found no matching change.