Repository navigation
perf(gateway): keep PR branch comparisons local - #166461
Conversation
Prevent lazy object fetches and stop dependent Git comparisons after the first timeout. Keep the branch visible with unavailable statistics and no GitHub Create PR link when its comparison cannot complete. Use an ancestry query instead of counting every ahead commit, and remove the per-diff Git capability probe and hydration fallback.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 1:34 AM ET / 05:34 UTC. ClawSweeper reviewWhat this changesThe PR keeps background session PR comparisons local, stops dependent Git reads after a timeout, and preserves a branch row with unavailable statistics. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still permits hydration during ancestry comparisons and continues dependent reads after timeouts. No blocking correctness or security finding was identified. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway combines checkout history with GitHub PR information to populate session branch rows in the Control UI. Local comparisons determine diff statistics and whether to offer a Create PR link. flowchart TD
A[Checkout refs and objects] --> C[Local Git comparison]
B[GitHub PR landing facts] --> C
C --> D{Comparison completes?}
D -->|Yes| E[Branch statistics and PR eligibility]
D -->|Timeout| F[Branch retained with recovery warning]
E --> G[Control UI branch row]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource -2, Tests +76, Docs 0. Total +74 across 4 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep background comparison reads local and bounded, with explicit repository fetches responsible for supplying missing objects. Do we have a high-confidence way to reproduce the issue? Yes: current-main ancestry reads can resolve absent historical heads through unrestricted Git, and swallowed timeouts allow dependent comparisons to continue. The PR records a matching partial-clone reproduction; this review established the mechanism from source. Is this the best way to solve the issue? Yes: one local-only command owner and operation-level timeout handling repair the existing comparison path while retaining Git's native statistics and landing semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 449175d2110d. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Prevent lazy object fetches and stop dependent Git comparisons after the first timeout. Keep the branch visible with unavailable statistics and no GitHub Create PR link when its comparison cannot complete. Use an ancestry query instead of counting every ahead commit, and remove the per-diff Git capability probe and hydration fallback.
What Problem This Solves
Fixes slow session pull-request comparisons when a partial clone lacks a historical PR head. Failed ancestry reads could repeatedly hydrate the same missing object and then start further 120-second waits.
User Impact
Background PR comparisons no longer fetch objects. A timed-out read leaves a visible branch without statistics or a GitHub Create PR link and logs recovery guidance. Explicit repository fetches remain responsible for hydration; old Git versions also deny transport for these background reads.
Why This Change Was Made
Route PR Git reads through one local-only command owner, propagate the first timeout to the operation boundary, and remove the per-diff capability probe and hydration fallback. Replace the full ahead-commit count with a pushed-tip ancestry check. No cache, configuration, schema, or update migration changes.
Evidence
A synthetic Linux partial clone (
--filter=blob:none, promisor origin, full commit history, advanced default branch, missing historical PR head) used a transport that fails after one second. Ten branch-facts reads before/after:Returned statistics were identical. The final-candidate run shared the rig with its changed-check gate; an earlier candidate run measured 62.5 ms mean / 86.3 ms p99, also with zero transport attempts. This reproduces the missing-operand mechanism; it does not establish which object was missing in the original production checkout. Git disables lazy fetching during parent traversal, but
merge-baseresolves operands throughlookup_commit_reference, which can fetch an absent historical PR head.Independent review: no actionable P0–P2 findings after correcting the old-Git transport assertion. Production LOC: +115 / -117, net -2; the commit-count helper and repeated version probe are removed.
Blacksmith Testbox (
blacksmith-testbox,tbx_01m4abt3pwj4hdcpzmrnfzf51f, Git 2.55.0 / Node 24.19.0):node scripts/run-vitest.mjs src/gateway/control-ui-session-prs-branch.test.ts --maxWorkers=1 -t 'stops dependent comparisons|reads missing historical PR heads'against the original production files: all four new cases failed for the intended timeout/degraded-state and transport-attempt assertions (31.72 s wrapper wall).node scripts/run-vitest.mjs src/gateway/control-ui-session-prs-branch.test.ts src/gateway/control-ui-session-prs-landing.test.ts --maxWorkers=1against the patched files: 71 tests passed, 81.66 s wrapper wall (79.23 s Vitest). This is the repository'spnpm testentrypoint. The existing branch integration fixture exercises real Git checkouts, worker transport, and session state; its 59 cases dominate the run. The four new cases total 2.98 s of test time. Timeout cases inject termination results without real waits; transport cases exercise real Git.The initial queued lease expired before admission and was replaced. The native CLI supplied no CI run URL for this delegated Testbox command. Changed gate: the lease was queued for over 20 minutes, so the authorized isolated Linux rig fallback ran
node scripts/check-changed.mjs --stagedthroughrig-staged-check.sh lane588-check 0be750916b123c328b8962117213f8c4fd1b2a0a. It passed with exit 0 (04:16–05:18 UTC).CI run 37576491672 passed for
6c900f9aa0557d248a39026b6ccd7ae351a4e0bd: 25 jobs passed, no failures. The five selected Node test jobs used 855 job-seconds (278/178/145/128/126 s); all successful CI jobs used 3,463 job-seconds. These shared jobs include existing coverage and setup, not just the four new cases. All PR checks finished without failures or pending checks.The deployed Gateway was not tested; the exact missing production object remains unconfirmed.