Repository navigation
perf(gateway): skip redundant same-tip session PR probes - #159301
Conversation
|
🦞👀 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 September 26, 2026, 9:32 PM ET / September 27, 2026, 01:32 UTC. ClawSweeper reviewWhat this changesThe Gateway session pull-request reader skips an ancestry process when the checkout and default branch have matching tips, with tests for branch visibility and missing objects. Merge readiness✅ Ready for maintainer review Keep open. Current main still performs the redundant equal-tip ancestry probe, and this focused improvement has no identified correctness or security regression. Priority: P2 Review scores
Verification
How this fits togetherThe Gateway combines a session’s checkout state with GitHub pull-request data. Its Git worker reads branch tips and working-tree changes, then sends branch status and a possible Create PR link to the Control UI. flowchart LR
A[Session checkout] --> B[Gateway PR loader]
C[GitHub PR data] --> B
B --> D[Git worker reads tips]
D --> E{Tips match?}
E -->|Yes| F[Read working-tree diff]
E -->|No| G[Check ancestry]
G --> F
F --> H[Control UI branch row]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +5, Tests +6. Total +11 across 3 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep the optimization in the Gateway branch-facts owner; assess a broader checkout cache separately if polling cost still warrants it. Do we have a high-confidence way to reproduce the issue? Yes. Current main’s source shows the equal-tip merge-base call, and the PR reports baseline and candidate measurements using real Git checkouts; this read-only review did not rerun the fixture. Is this the best way to solve the issue? Yes. It removes one redundant call through the existing Git worker while retaining different-tip ancestry checks and the missing-object fallback. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 273742f9a0c4. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
What Problem This Solves
The session PR panel repeatedly starts an unnecessary Git ancestry process when a checkout's HEAD already equals the default-branch tip.
User Impact
Removes one Git process per uncached read of that state while preserving branch visibility, uncommitted diff counts, and the missing-object fallback. A 40-worktree plus three-project fixture measured 25% fewer idle Git spawns.
This is a bounded improvement, not the full event-driven checkout cache: idle zero and at-most-two processes after a changed checkout remain unmet. A metadata-only cache would miss unstaged file edits; a complete solution needs working-file invalidation as well.
Why This Change Was Made
Equal object IDs provide the candidate merge base directly. The existing diff read validates the object before equal remote tips suppress Create PR, so another ancestry probe is redundant. Different tips still use Git's merge-base calculation.
Production code grows by five net lines, with no configuration, cache, observer, or broker-capacity changes. The existing branch tests cover the process reduction and a HEAD pointing at a missing object.
Evidence
Real Git fixture: 40 linked worktrees and three independent project checkouts, all initially at the default-branch commit, exercised through the session PR loader and Git worker. Ten 60-second polling steps used a virtual clock; counts exclude fixture construction.
Blacksmith Testbox, profile
openclaw-check:tbx_01m3g3zvpb9adxqtcnmbmymq9q: baseline and candidate fixture runs produced the counts above. The fixture correctly failed its original zero-idle target on both versions; it was temporary measurement tooling and is not added to per-PR CI. Candidate branch and landing suites passed all 61 tests.tbx_01m3g4xy2ra2hgse5jw21ygefs:node scripts/check-changed.mjs --base HEADpassed, including formatting, core and test typechecks, lint, and guards (21m40s remote command).pnpm test src/gateway/control-ui-session-prs-branch.test.ts --maxWorkers=1passed all 49 tests: 40.37s wall including worker compilation, about 21s test execution. The added missing-HEAD case costs roughly 0.5s; existing Git-worker/session fixtures own these real-process contracts. GitHub CI run 36285487289 passed on239ec7ebb7c6in 829s end to end, including scheduling and builds. Separate per-file CI seconds were not available in the run artifacts.git diff --checkpassed.The first lease lacked dependencies; frozen-lockfile installation succeeded. Its later checksum sync timed out twice, so it was stopped and replaced. The fresh lease's default check compared against newer origin/main and tripped an unrelated UI line-growth ratchet; using the actual unchanged task HEAD as the diff base selected only these three files and passed. No live Gateway was modified or used for validation.