Skip to content

perf(pr): stop small reviews from spending uncached REST quota - #115199

Merged
steipete merged 1 commit into
mainfrom
codex/cache-small-pr-file-metadata
Jul 28, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cache-small-pr-file-metadata

Conversation

@steipete

@steipete steipete commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where every scripts/pr review-init bypassed the shared GitHub cache and spent direct REST quota to paginate changed files, even when the PR had only a handful of files and gh pr view --json files already returned the complete list. Exhausted direct quota then blocked the entire native landing workflow until reset.

Why This Change Was Made

PR metadata now uses the cacheable GraphQL file list when the reported count is at most 100 and every file has the complete typed shape. Large, truncated, malformed, or older-CLI responses still fall back to the existing paginated REST path, with the same head-drift and count validation.

User Impact

Most PR review and landing initialization no longer spends uncached REST quota, reducing latency and avoiding quota stalls. Large PRs and incomplete client responses preserve the current exhaustive fail-closed behavior.

Evidence

  • Live incident: a four-file PR landing was blocked until the direct REST quota reset because the wrapper unconditionally called the paginated files endpoint.
  • Live post-fix proof on PR perf(pr): stop small reviews from spending uncached REST quota #115199: pr_meta_json 115199 returned the exact two-file typed GraphQL list while an instrumentation guard made any pulls/115199/files REST call fail with exit 97. The command exited 0 and the guard never fired.
  • Live returned head: 939878c2348b2f4c5dbb6b6860c346b6e63fa2de; files: scripts/pr-lib/worktree.sh and test/scripts/pr-metadata.test.ts, both MODIFIED with exact additions/deletions.
  • Added coverage proving a complete two-file GraphQL response succeeds even when the REST endpoint is configured to fail.
  • Added compatibility coverage proving GraphQL responses without changeType fall back to REST instead of weakening deletion classification.
  • Existing 101-file pagination, incomplete-response, API-failure, and head-drift tests remain covered.
  • pnpm test test/scripts/pr-metadata.test.ts — 6 passed on Blacksmith Testbox tbx_01kymc4jc055dfmpf8b9nfh7wd.
  • pnpm check:changed — passed test-root typecheck, script lint, formatting, declaration contracts, and repository guards on the same Testbox.
  • Exact-head CI run 30361211077 — green.
  • Autoreview (gpt-5.6-sol, high) — first pass found and fixed the older-CLI changeType gap; final pass clean with no accepted/actionable findings.

The branch remains behind main without conflicts. Per repository landing policy, behind-main drift is advisory; scripts/pr merge-run will perform the strict App-owned test merge against current main rather than rewriting this already-green exact head solely for drift.

@steipete steipete self-assigned this Jul 28, 2026
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts size: S maintainer Maintainer-authored PR labels Jul 28, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. labels Jul 28, 2026
@clawsweeper

clawsweeper Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 10:39 AM ET / 14:39 UTC.

ClawSweeper review

What this changes

This PR lets native pull-request review initialization use a complete cacheable GraphQL file list for small PRs, while retaining paginated REST collection for large, incomplete, or older-client responses.

Merge readiness

⛔ Blocked until real behavior proof from a real setup is added - 5 items remain

Keep open for maintainer review. The submitted change is focused and its tests cover the intended cache-first and REST-fallback branches, with no concrete line-level defect established; however, this protected maintainer-labeled automation change is behind current main and only has mock/Testbox evidence rather than a redacted live gh behavior trace.

Likely related people: steipete is the attributable recent contributor for this exact script path, though current-main ownership could not be established from the supplied history (low confidence).

Priority: P3
Reviewed head: 939878c2348b2f4c5dbb6b6860c346b6e63fa2de
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation and fallback coverage appear solid, but the missing real GitHub CLI/API behavior proof remains a merge gate.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: The PR reports focused Testbox tests and checks, but it does not include after-fix evidence from a real GitHub PR showing the cache-hit request path and REST fallback; attach redacted terminal output before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: The PR reports focused Testbox tests and checks, but it does not include after-fix evidence from a real GitHub PR showing the cache-hit request path and REST fallback; attach redacted terminal output before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 4 items Cache-first implementation: The PR adds files to the initial pull-request metadata query, accepts that list only when it is complete and includes the typed fields needed by downstream guards, and otherwise retains the REST pagination path.
Fallback coverage: The focused test fixture now emits GraphQL file metadata and covers both a complete two-file response that avoids REST and an older/incomplete response that must fall back rather than weakening deletion classification.
Submitted validation: The PR body reports six focused metadata tests and changed-check validation on a Blacksmith Testbox, but this is test/mock evidence rather than an observed post-change run against a real GitHub PR.
Findings None None.
Security None None.

How this fits together

The native PR landing scripts obtain GitHub pull-request metadata before review and landing guards run. This change selects a complete cached GraphQL file list when possible, otherwise preserves the existing REST pagination path before handing normalized change data to those guards.

flowchart LR
  A[Pull request number] --> B[GitHub metadata request]
  B --> C{Complete typed file list?}
  C -->|Small and complete| D[Cached GraphQL files]
  C -->|Large or incomplete| E[Paginated REST files]
  D --> F[Normalized changed paths]
  E --> F
  F --> G[Review and landing guards]
Loading

Decision needed

Question Recommendation
Should this protected landing-automation change merge after a current-main refresh and redacted real GitHub cache-hit/fallback proof? Require live proof before merge: Ask for a redacted real small-PR trace that proves the cache-hit path avoids REST and that the fallback remains available after a current-main refresh.

Why: The patch modifies the metadata source used by native landing guards, and its supplied validation is mock/Testbox coverage rather than direct evidence from the real GitHub CLI and API path.

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: The PR reports focused Testbox tests and checks, but it does not include after-fix evidence from a real GitHub PR showing the cache-hit request path and REST fallback; attach redacted terminal output before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Resolve merge risk (P2) - This changes metadata consumed by native review and landing guards; a malformed or version-dependent GraphQL response must demonstrably take the existing REST fallback rather than silently omit changed paths.
  • Resolve merge risk (P1) - The branch is behind current main, so the final merge result needs a rebase or review refresh before landing.
  • Complete next step (P2) - The protected maintainer label and missing live behavior proof require explicit maintainer merge review rather than an automated repair lane.
Agent review details

Security

None.

PR surface

Tests +68, Other +31. Total +99 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 70 2 +68
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 48 17 +31
Total 2 118 19 +99

Review metrics

None.

Stored data model

Persistent data-model change detected: unknown-data-model-change: test/scripts/pr-metadata.test.ts, vector/embedding metadata: scripts/pr-lib/worktree.sh, vector/embedding metadata: test/scripts/pr-metadata.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Capture a live cache-hit trace (recommended)
    Before merge, attach a redacted terminal trace from a real small PR showing complete GraphQL metadata avoids the REST files endpoint and that incomplete metadata still falls back safely.

Technical review

Best possible solution:

Rebase onto current main and attach a redacted live terminal trace from a real small PR showing that complete GraphQL metadata avoids the REST files request while incomplete metadata still uses the existing fallback.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR targets an internal GitHub quota and review-initialization path, not a user-reported product failure. The supplied focused tests reproduce the intended branch selection with a fake GitHub CLI.

Is this the best way to solve the issue?

Likely yes: using the cacheable file list only when it is complete and typed, while retaining exhaustive REST fallback, is the narrow maintainable approach. A live current-client run is still needed to confirm the dependency contract in practice.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3fa4805563eb.

Labels

Label changes:

  • add P3: This is a narrowly scoped internal landing-workflow performance and quota-efficiency improvement rather than a demonstrated user-facing runtime regression.
  • add merge-risk: 🚨 automation: The patch changes the file metadata source that native review and landing automation use to classify changed paths.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports focused Testbox tests and checks, but it does not include after-fix evidence from a real GitHub PR showing the cache-hit request path and REST fallback; attach redacted terminal output before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P3: This is a narrowly scoped internal landing-workflow performance and quota-efficiency improvement rather than a demonstrated user-facing runtime regression.
  • merge-risk: 🚨 automation: The patch changes the file metadata source that native review and landing automation use to classify changed paths.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR reports focused Testbox tests and checks, but it does not include after-fix evidence from a real GitHub PR showing the cache-hit request path and REST fallback; attach redacted terminal output before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

  • Cache-first implementation: The PR adds files to the initial pull-request metadata query, accepts that list only when it is complete and includes the typed fields needed by downstream guards, and otherwise retains the REST pagination path. (scripts/pr-lib/worktree.sh:94, 939878c2348b)
  • Fallback coverage: The focused test fixture now emits GraphQL file metadata and covers both a complete two-file response that avoids REST and an older/incomplete response that must fall back rather than weakening deletion classification. (test/scripts/pr-metadata.test.ts:17, 939878c2348b)
  • Submitted validation: The PR body reports six focused metadata tests and changed-check validation on a Blacksmith Testbox, but this is test/mock evidence rather than an observed post-change run against a real GitHub PR.
  • Merge state: GitHub reports the PR as mergeable but behind main; refresh against current main is needed before relying on the branch-level evidence for landing. (3fa4805563eb)

Likely related people:

  • steipete: The supplied PR history attributes the focused cache-first implementation to this contributor; no independent current-main feature-history owner was available in the provided review material. (role: recent contributor to the script path; confidence: low; commits: 939878c2348b; files: scripts/pr-lib/worktree.sh, test/scripts/pr-metadata.test.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Attach redacted live terminal evidence from a real small PR showing that the complete GraphQL list avoids the REST files request.
  • Refresh the branch against current main and repeat the focused metadata proof on the resulting head.

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 a8f088e into main Jul 28, 2026
119 of 126 checks passed
@steipete
steipete deleted the codex/cache-small-pr-file-metadata branch July 28, 2026 15:21
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Jul 28, 2026
* origin/main:
  test(codex): de-flake attempt turn-watch timing tests (#115258)
  fix: preserve retryable ACPX lease ownership (#115247)
  fix: serialize ACPX lease ownership transitions
  fix: retain ACPX leases across wrapper reconnects
  refactor: parse ACPX lease command identity
  fix: preserve OpenClaw profile env in macOS launch-at-login plist (#99752)
  refactor(config): retire compaction truncateAfterCompaction gate (#115206)
  improve(ui): reduce duplicate chat startup work (#114743)
  fix(ui): keep reconnects, browser tabs, and localized search consistent (#115221)
  perf(pr): cache complete small file lists (#115199)
  perf(sqlite): skip no-op automatic schema repair (#115193)
  docs(browser): correct Docker sandbox setup (#115254)
  fix(ui): avoid duplicate session refreshes during startup (#114764)

# Conflicts:
#	ui/src/pages/agents/panels-tools-skills.browser.test.ts
vincentkoc added a commit that referenced this pull request Jul 28, 2026
* origin/main:
  test(codex): de-flake attempt turn-watch timing tests (#115258)
  fix: preserve retryable ACPX lease ownership (#115247)
  fix: serialize ACPX lease ownership transitions
  fix: retain ACPX leases across wrapper reconnects
  refactor: parse ACPX lease command identity
  fix: preserve OpenClaw profile env in macOS launch-at-login plist (#99752)
  refactor(config): retire compaction truncateAfterCompaction gate (#115206)
  improve(ui): reduce duplicate chat startup work (#114743)
  fix(ui): keep reconnects, browser tabs, and localized search consistent (#115221)
  perf(pr): cache complete small file lists (#115199)
  perf(sqlite): skip no-op automatic schema repair (#115193)
  docs(browser): correct Docker sandbox setup (#115254)
  fix(ui): avoid duplicate session refreshes during startup (#114764)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant