Skip to content

perf(tools): batch open PR file queries in check-claims.py - #404

Closed
mjmirza wants to merge 2 commits into
mainfrom
perf/optimize-check-claims-batch-query-11951701724745108977
Closed

perf(tools): batch open PR file queries in check-claims.py#404
mjmirza wants to merge 2 commits into
mainfrom
perf/optimize-check-claims-batch-query-11951701724745108977

Conversation

@mjmirza

@mjmirza mjmirza commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Problem

tools/check-claims.py checked open PR claims by executing gh pr list --state open --json number followed by a sequential gh pr view <number> --json files command for every open PR. This caused 1 + N CLI subprocess executions and API round-trips per run, creating potential timeouts and rate-limit friction in CI when multiple PRs are open.

Solution

Updated sibling_pr_paths() in tools/check-claims.py to request number,files in a single gh pr list --state open --json number,files call, reducing GitHub CLI subprocess invocations from 1 + N to 1. Updated unit tests in tools/check-claims-test.py to match the single-call batch response structure.

Validation

  • Unit tests (python3 tools/check-claims-test.py) passed cleanly.
  • Full test suite (make test) passed cleanly.
  • Code review completed with rating #Correct#.
  • Pre-commit steps completed.

PR created automatically by Jules for task 11951701724745108977 started by @mjmirza

Eliminate N+1 gh pr view calls in check-claims.py by querying
open PR numbers and changed files in a single gh pr list call. Update
unit tests in check-claims-test.py to match.

Co-authored-by: mjmirza <34001140+mjmirza@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

…athway generator

Fix a regex word boundary bug in detect_mentions() in tools/gen-by-problem-by-language.py
where r"\bc\+\+\b" failed to match C++ when followed by non-word characters. Update C++ and C#
regex patterns and regenerate docs/BY-LANGUAGE.md.

Co-authored-by: mjmirza <34001140+mjmirza@users.noreply.github.com>
@mjmirza

mjmirza commented Aug 24, 2026

Copy link
Copy Markdown
Owner Author

Review finding. this PR's second commit reverts its own first commit.

The first commit (b06290e) correctly batches the sibling-PR file
lookup into a single gh pr list --json number,files call. The
second commit (c035af6) was evidently built against a checkout that
still had the pre-batch version of sibling_pr_paths, so committing
it rolled check-claims.py and check-claims-test.py back to the
original N plus one gh pr view loop while correctly delivering the
separate C++ and C# regex word-boundary fix.

Confirmed directly against this branch's HEAD. sibling_pr_paths in
tools/check-claims.py still calls gh pr view per sibling PR, and
the batch-query optimization this PR's title describes is not present
in the final diff.

Closing in favor of #439, which applies both of this PR's intended
changes correctly against current main, with the regex fix, the
batch-query optimization actually landing this time, and the matching
test updates.

@mjmirza mjmirza closed this Aug 24, 2026
@google-labs-jules

Copy link
Copy Markdown
Contributor

Review finding. this PR's second commit reverts its own first commit.

The first commit (b06290e) correctly batches the sibling-PR file
lookup into a single gh pr list --json number,files call. The
second commit (c035af6) was evidently built against a checkout that
still had the pre-batch version of sibling_pr_paths, so committing
it rolled check-claims.py and check-claims-test.py back to the
original N plus one gh pr view loop while correctly delivering the
separate C++ and C# regex word-boundary fix.

Confirmed directly against this branch's HEAD. sibling_pr_paths in
tools/check-claims.py still calls gh pr view per sibling PR, and
the batch-query optimization this PR's title describes is not present
in the final diff.

Closing in favor of #439, which applies both of this PR's intended
changes correctly against current main, with the regex fix, the
batch-query optimization actually landing this time, and the matching
test updates.

Understood. Acknowledging that this PR has been closed in favor of #439 and stopping work on this task.

mjmirza added a commit that referenced this pull request Aug 24, 2026
* fix(tools) correctly land the check-claims batch-query fix

PR #404's second commit unintentionally reverted its own first commit
while adding a separate, real fix, so the sibling-PR check still ran
the old N+1 gh pr view loop while also carrying the intended C++ and
C# word-boundary correction. This applies both fixes cleanly against
current main.

- check-claims.py. sibling_pr_paths reads files directly off the
  single gh pr list --json number,files response instead of a second
  gh pr view call per sibling PR.
- check-claims-test.py. updated to mock the single batched response.
- gen-by-problem-by-language.py. the C++ and C# regex patterns no
  longer require a trailing word boundary that a following punctuation
  character (a comma, a period) would fail to satisfy.
- docs/BY-LANGUAGE.md. regenerated with the corrected detection.

* chore(tools) drop unused imports from check-claims-test.py

os and sys were unreferenced anywhere in the test module.
@mjmirza
mjmirza deleted the perf/optimize-check-claims-batch-query-11951701724745108977 branch August 24, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant