Skip to content

perf(gateway): keep PR branch comparisons local - #166461

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-git-merge-base-timeouts-20260919
Oct 7, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-git-merge-base-timeouts-20260919

Conversation

@steipete

@steipete steipete commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

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:

Measurement Before After
Mean 6,122.9 ms 184.9 ms
p99 (10 samples; maximum) 6,144.2 ms 259.6 ms
Transport attempts 60 0

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-base resolves operands through lookup_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=1 against the patched files: 71 tests passed, 81.66 s wrapper wall (79.23 s Vitest). This is the repository's pnpm test entrypoint. 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 --staged through rig-staged-check.sh lane588-check 0be750916b123c328b8962117213f8c4fd1b2a0a. It passed with exit 0 (04:16–05:18 UTC).

Gate summary Result
Core test type graphs 27 passed
Production/full-tree/script dead exports 0 entries
Changed-file lint 0 warnings, 0 errors
Schema, storage, media, sidecar, import-cycle, webhook and pairing guards Passed

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.

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.
@clawsweeper

clawsweeper Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: M labels Oct 7, 2026
@steipete
steipete marked this pull request as ready for review October 7, 2026 05:28
@steipete
steipete enabled auto-merge (squash) October 7, 2026 05:31
@clawsweeper

clawsweeper Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 7, 2026, 1:34 AM ET / 05:34 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: 6c900f9aa0557d248a39026b6ccd7ae351a4e0bd

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, simplifying repair has relevant real-Git before/after evidence and meaningful boundary regressions, with no blocking finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured production branch-facts benchmark exercises real Git against a missing historical head in a Linux partial clone, showing zero after-fix transport attempts and unchanged statistics with sharply reduced latency. Timeout boundary regressions supplement that run. No persisted format changes require migration proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured production branch-facts benchmark exercises real Git against a missing historical head in a Linux partial clone, showing zero after-fix transport attempts and unchanged statistics with sharply reduced latency. Timeout boundary regressions supplement that run. No persisted format changes require migration proof.
Evidence reviewed 7 items Pinned introduced change: The merge-base-to-head diff establishes the local-only command owner, timeout propagation, ancestry query replacement, documentation update, and four regression cases as this PR's changes.
Current main still needs the repair: Current main probes Git capability per diff, preserves older Git hydration, counts ahead commits, and lacks the operation-level timeout fallback. Its ancestry owner also uses unrestricted runGit calls. The requested behavior is therefore not already implemented on main or established as released.
Production boundary and degraded result: The command owner disables lazy fetch and permits no transport; timeout results become the existing typed timeout error. The branch-facts boundary returns creatable=false and stats=null, which the unchanged session presenter converts into a visible branch without statistics or a Create PR link. No stored-data contract changes.
Findings None None.
Security None None.

How this fits together

The 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
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -2, Tests +76, Docs 0. Total +74 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 115 117 -2
Tests 1 76 0 +76
Docs 1 1 1 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 192 118 +74

Review metrics

Metric Value Why it matters
Production versus regression coverage production +115/-117, net -2; tests +76 The repair consolidates command policy and removes repeated probing while adding boundary regressions.

Technical review

Best 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.

Labels

Label changes:

  • add P2: This repairs bounded background PR comparison stalls without evidence of an urgent core-runtime outage.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured production branch-facts benchmark exercises real Git against a missing historical head in a Linux partial clone, showing zero after-fix transport attempts and unchanged statistics with sharply reduced latency. Timeout boundary regressions supplement that run. No persisted format changes require migration proof.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.

Label justifications:

  • P2: This repairs bounded background PR comparison stalls without evidence of an urgent core-runtime outage.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured production branch-facts benchmark exercises real Git against a missing historical head in a Linux partial clone, showing zero after-fix transport attempts and unchanged statistics with sharply reduced latency. Timeout boundary regressions supplement that run. No persisted format changes require migration proof.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff establishes the local-only command owner, timeout propagation, ancestry query replacement, documentation update, and four regression cases as this PR's changes. (src/gateway/control-ui-session-prs-landing.ts:92, 6c900f9aa055)
  • Current main still needs the repair: Current main probes Git capability per diff, preserves older Git hydration, counts ahead commits, and lacks the operation-level timeout fallback. Its ancestry owner also uses unrestricted runGit calls. The requested behavior is therefore not already implemented on main or established as released. (src/gateway/control-ui-session-prs-git.runtime.ts:246, 449175d2110d)
  • Production boundary and degraded result: The command owner disables lazy fetch and permits no transport; timeout results become the existing typed timeout error. The branch-facts boundary returns creatable=false and stats=null, which the unchanged session presenter converts into a visible branch without statistics or a Create PR link. No stored-data contract changes. (src/gateway/control-ui-session-prs-git.runtime.ts:317, 6c900f9aa055)
  • After-fix production-path evidence: The captured PR body reports ten production branch-facts reads in a synthetic Linux partial clone with a missing historical PR head and a failing real transport: mean latency fell from 6,122.9 ms to 184.9 ms, transport attempts fell from 60 to zero, and returned statistics matched. Supplemental Testbox evidence reports all four new cases failing before the fix and 71 branch/landing tests passing afterward. These are contributor-recorded results; this read-only review did not execute tests. (6c900f9aa055)
  • Git dependency contract: The introduced command owner directly relies on Git environment semantics. Git documents GIT_NO_LAZY_FETCH=1 as disabling demand fetch and GIT_ALLOW_PROTOCOL as overriding protocol permissions; an empty list permits no protocols. The merge-base implementation resolves operands through lookup_commit_reference. Inspected Git documentation and merge-base source. (Documentation/git.adoc:891)
  • Earlier merged work is complementary: GitHub confirms perf(gateway): avoid missing-blob scans in PR statistics #166264 merged as 367d33f. Its body explicitly preserves ancestry behavior and older-Git hydration, so it does not supersede this PR's historical-head and timeout repair. (367d33f6dfae)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete merged commit 6644a3e into main Oct 7, 2026
174 of 176 checks passed
@steipete
steipete deleted the steipete/perf-micro-git-merge-base-timeouts-20260919 branch October 7, 2026 05:36
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 8, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant