Skip to content

perf(worktrees): skip unchanged projection updates and evidence replay - #808

Merged
Juliusolsson05 merged 3 commits into
mainfrom
perf/worktree-reconciliation
Sep 6, 2026
Merged

perf(worktrees): skip unchanged projection updates and evidence replay#808
Juliusolsson05 merged 3 commits into
mainfrom
perf/worktree-reconciliation

Conversation

@Juliusolsson05

@Juliusolsson05 Juliusolsson05 commented Sep 5, 2026

Copy link
Copy Markdown
Owner

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

  • Preserve canonical state/context references when values agree.
  • Reuse catalog content identity independently of freshness.
  • Cache replay by cwd, authoritative baseline, evidence generation and catalog identity.
  • Keep catalog-ready callbacks: unchanged catalogs must still correct externally replaced stale history.
  • No lifecycle, readiness, terminal, dependency or persisted-schema changes. No migration required.

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 .performance suffix implied a tier this repo does not define. Boundary worth knowing (recorded in #806): any checkout commit change intentionally invalidates catalog identity because sameCatalog compares head, 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

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
@Juliusolsson05

Copy link
Copy Markdown
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.

@Juliusolsson05

Copy link
Copy Markdown
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
@Juliusolsson05
Juliusolsson05 merged commit 7becca7 into main Sep 6, 2026
2 checks passed
@Juliusolsson05
Juliusolsson05 deleted the perf/worktree-reconciliation branch September 6, 2026 01:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf(worktrees): preserve no-op projection identity and skip unchanged evidence replay

1 participant