perf(worktrees): skip unchanged projection updates and evidence replay - #808
Merged
Conversation
Keep catalog freshness separate from content identity and invalidate replay on baseline, cwd and bounded evidence generation changes. Preserve catalog-ready callbacks so late history hydration still receives attribution correction. Fixes #806
Owner
Author
|
Verification update: both current CI checks passed on cccae6e (quality-gate and minimum-node-fixture-gate, run 33957522009). Local baseline-only corpus failure remains documented above. Implementation is ready for review; no merge performed or authorized. |
This was referenced Sep 5, 2026
Owner
Author
|
Owner authorized review, fixes, and merge of #808/#810 after final checks. Two independent reviewers have been started through Agent Code orchestration (Review A and Review B); each covers both PRs and their interaction at cccae6e / a96f00a. Current CI gates pass. Planned order: #808 first, then update #810 with resulting main and verify combined state. Merge remains gated on both review outcomes. |
LiveWorktreeReconciler.performance.test.ts asserts identity and invalidation contracts, never timing; the .performance suffix implied a benchmark tier the repo does not define (unit/renderer/system key off their own suffixes). An .invalidation.test.ts name documents what the file actually protects. No config or CI references the previous name. Also records the independent-review boundary notes in the plan: sameCatalog compares head, so any checkout change intentionally invalidates catalog identity and replays the bounded window; and the pre-existing pre-catalog evidence-eviction loss is tracked as a separate issue rather than fixed in this PR. Refs #806
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.
Problem
Quiet sessions receive new worktree projection identities for identical Git data, and unrelated transcript batches replay up to 500 retained records on the renderer thread.
Change
Verification
Seven new invalidation/identity regression tests, including actual retained-record read counts. Four tests failed on unchanged production code before the fix. Existing recorded attribution tests remain green, including stale-hydration accounting reversal.
24 focused unit tests, 2 worktree UI renderer tests, full typecheck, test contract and five-fixture privacy gate passed.
Full local unit suite: 2138 passed, one existing missing-private-session corpus failure, reproduced identically on unchanged main (Refs #684/#669/#641). No skips or weakened assertions. Both current CI gates passed on cccae6e (quality-gate and minimum-node-fixture-gate, run 33957522009); the review-fix head 29e2dc8 re-triggers CI.
Before/after measurement
Reproducible sanitized-fixture script: scripts/benchmark-worktree-reconciliation.mts.
200 unrelated batches with 500 retained records: median 2.118166 ms to 0.000333 ms; p95 2.476792 ms to 0.000375 ms; unnecessary identity changes 200 to zero. Isolated synchronous work only, not an app-wide typing-latency claim.
Review
Two independent orchestration reviewers approved cccae6e with no correctness defects: invalidation keys (cwd, baseline identity, evidence revision, catalog identity), retained identity, replay avoidance, and the accounting-reversal path were all verified. Final head 29e2dc8 only renames the replay-cache coverage file to LiveWorktreeReconciler.invalidation.test.ts — it protects identity/invalidation contracts, not timing, and the previous
.performancesuffix implied a tier this repo does not define. Boundary worth knowing (recorded in #806): any checkout commit change intentionally invalidates catalog identity because sameCatalog compareshead, so that cwd replays its bounded evidence window at the next refresh. A pre-existing, unrelated evidence-eviction loss (>500 relevant records buffered before the first successful Git IPC reply are folded against an empty catalog and dropped) is filed separately, not fixed here.Boundaries / remaining work
The existing bounded full replay remains for genuine invalidations; timestamp and attribution policy are unchanged. Per-pane subscriptions #763, screen interest #762 and remaining diagnostics #767 are separate increments. No overlap with A6 #802-805. Await explicit owner approval before merge.
Fixes #806