Skip to content

fix(server): scope Git status polling to the current worktree - #7

Draft
Harold Hunt (huntharo) wants to merge 2 commits into
mainfrom
perf/worktree-status-inputs-mwvr22gm
Draft

Harold Hunt (huntharo) wants to merge 2 commits into
mainfrom
perf/worktree-status-inputs-mwvr22gm

Conversation

@huntharo

@huntharo Harold Hunt (huntharo) commented Nov 25, 2026 •

Copy link
Copy Markdown

Problem

Each idle remote status poll ran git show-ref --head for every subscribed checkout. A shared checkpoint ref or a commit in a sibling worktree then invalidated local status and Changes totals in every linked checkout.

Change

Polls read the checkout's HEAD, effective config, comparison base and shallow boundaries through scoped Git queries. The same Git ref read supplies upstream divergence and the remote default branch. The service falls back to the full read for inputs it cannot resolve reliably. Full local reads resolve remote presence and the default branch in the checkout's own Git config. Explicit refreshes compute the branch-picker digest separately from their status inputs.

Scope

This follows up on the idle refresh optimization in pingdotgg#40093. The polling change overlaps pingdotgg#38949 in refreshRemoteStatus. Related PRs cover config discovery in pingdotgg#30838 and fetch refspecs in pingdotgg#34042. Short base overrides, nonstandard upstream mappings and replacement refs use the full read.

Verification

vp run check:changed origin/main passed with 605 tests passing and one skipped. One 30-second poll tick per row on macOS arm64 with Git 2.56.0-dev-pwrgit.3 and Node 26.12.1. The fixture uses real Git linked worktrees and a local bare remote. The poll clock is simulated and elapsed time is measured on the host. The ref counts below are extra remote-tracking refs, in addition to the worktrees' branch and upstream refs.

Fixture and trigger Git processes, base → head Git stdout bytes, base → head Elapsed ms, base → head Full local reads, base → head
50 linked, 1,000 extra loose refs, idle 552 → 402 4,529,149 → 297,999 1,397.7 → 517.8 0 → 0
50 linked, 1,000 extra packed refs, idle 552 → 402 4,529,149 → 297,999 711.6 → 387.2 0 → 0
50 linked, 100 extra loose refs, idle 552 → 402 1,019,099 → 297,749 633.1 → 450.9 0 → 0
Same 100-ref fixture, one checkpoint update 1,052 → 402 1,304,889 → 297,749 1,463.1 → 521.4 50 → 0
Same 100-ref fixture, one sibling branch move 1,052 → 414 1,304,889 → 303,430 1,324.5 → 441.9 50 → 1
One tracking worktree, idle 13 → 10 1,189 → 1,544 81.2 → 64.5 0 → 0
One unborn worktree, idle, no remote 20 → 7 992 → 704 84.3 → 25.2 1 → 0
One unborn worktree, idle, with remote 22 → 7 1,435 → 878 99.6 → 28.4 1 → 0

The sibling row includes zero full local reads in the 49 unaffected worktrees. The seeded tests use 20261125 and 424242 and compare poll results to direct Git across linked worktrees, loose, packed and reftable refs, upstream and base moves, worktree-specific config and checkout changes. Separate cases verify shallow deepening, unborn status, and fallback.

Commands

Run the handoff's bench-status-inputs.ts with its harness.ts and resolve-hook.mjs imports pointing at the checkout. Use the same command at fbd939eb4c and bead997e08.

env GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null \
  GIT_TERMINAL_PROMPT=0 GIT_ALLOW_PROTOCOL=file \
  node --import "$BENCH_DIR/resolve-hook.mjs" "$BENCH_DIR/bench-status-inputs.ts"

vp test run apps/server/src/vcs/GitVcsDriverCore.test.ts \
  -t 'scopes linked worktree poll inputs|polls an unborn worktree|ref snapshot detects branch identity'
vp run check:changed origin/main

AI usage: Codex GPT-6.2-Sol xhigh with Codex harness via PwrAgent desktop.


See it in action
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XL labels Nov 25, 2026
@github-actions

github-actions Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: fbd939e · PR result: 62c1b02 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant