Skip to content

perf(github): reuse repository merge metadata reads - #34848

Merged
OrcaWin merged 8 commits into
mainfrom
OrcaWin/github-repository-capability-reuse
Oct 29, 2026
Merged

OrcaWin merged 8 commits into
mainfrom
OrcaWin/github-repository-capability-reuse

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

ELI5

PR details and sidebar refreshes can ask GitHub the same repository capability questions twice. They now share the existing cached result, and overlapping requests join the first request immediately.

What Changed

  • Give PR detail lookups the same explicit execution scope as sidebar and merge-action lookups, allowing their repository/base-branch capability results to be reused.
  • Coalesce overlapping cache misses with the existing probe implementation. Keep the existing success/unknown TTLs and 256-entry response-cache bound.
  • Keep completed settings shared across worktree directories while separating accounts, tokens, hosts, native/WSL execution and SSH scopes. Relative effective configuration roots (GH_CONFIG_DIR, XDG_CONFIG_HOME, or the platform default) retain their directory identity; absolute configuration directories preserve reuse. Cold probes also retain their directory-sensitive execution identity. Represent a repository-wide query separately from a real branch named __repo__.
  • Coalesce commands only when they share an abort lifetime. Independent signals have separate probe maps; successful completed settings are shared, while aborted results never enter the cache. Already-aborted probes spend no quota.
  • Prevent an older probe from replacing newer cached settings, including probes started from different worktrees. Per-cache publication order survives overlapping probes and is removed after the last settles; canceling a newer probe leaves a surviving reader able to cache its result.

Why

An overlapping ten-reader workload with matching execution and cancellation scope previously launched ten identical GraphQL requests; it now launches one, with one quota debit. A production-caller test also proves PR details followed by a sidebar refresh use one capability request instead of two. No timers, new waiting interval, refresh changes or longer cache TTLs are introduced.

Linked Issue

Follow-up to #28778. Independent of #34842 and the earlier quota-saving PRs.

Visual Proof

N/A — main-process request reuse, with no UI contract change.

Testing

  • 47 focused tests pass on the updated code (27 request-boundary and 20 merge/auto-merge), including successful/failed completion order, absent home/config roots, cancellation, stale writers, credential/host/route isolation and existing TTLs.
  • Earlier base replay proves ten matching readers change from 10 requests to 1. The production detail/sidebar reuse regression also passes.
  • pnpm check:changed --maxWorkers=2 was run; its duplicate broad affected-test phase was stopped after exact-head CI passed. This is not a full local gate pass.
  • Exact-head CI passed on 59fb79f5c50, including all five unit shards, static analysis/typechecks, relay integration, packaging and the aggregate PR gate.
  • Executed on Linux; platform and remote isolation use mocks. No live SSH/WSL/macOS/Windows run is claimed.

Notes

A failed or missing-repository probe cannot replace a concurrently published success or prevent an older surviving success from publishing. Only authoritative successful reads advance publication order. Missing home/config roots retain cwd identity, as relative roots do. Existing TTLs are unchanged.

No UI, RPC or persisted-data changes. Folder workspaces and git worktrees use the same repository resolution. Credential environment values are hashed in memory rather than included in plaintext keys or logs.

@OrcaWin
OrcaWin marked this pull request as ready for review October 28, 2026 07:20
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 782889ea-3bff-42f4-b208-abbaa276cdf5
Commits

Reviewing files that changed from the base of the PR and between baa7f1d and 9648e10.

Files selected for processing: 2
  • src/main/github/client/detect/repository-merge-metadata.ts
  • src/main/github/repository-merge-metadata-reuse.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Walkthrough

Repository merge-metadata reads now use execution and repository context in their cache keys. Matching concurrent reads share a probe, and cache updates occur only while the probe owns the key. Pull-request fetching passes the execution scope to the detector. Tests cover reuse, expiry, context isolation, failures, and overlapping probes.

Priority: Low

Merge Risk: Minimal · up to 9648e

Matching PR reads can reuse merge metadata. No merge-blocking issue was established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the primary change: reusing repository merge metadata reads for GitHub performance.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description is mostly complete. It includes the ELI5 summary, changes, rationale, linked issue reference, visual-proof statement, testing results, platform limits, and compatibility notes. It omit…
Full details: Description check

Explanation

The description is mostly complete. It includes the ELI5 summary, changes, rationale, linked issue reference, visual-proof statement, testing results, platform limits, and compatibility notes. It omits the AI Disclosure, Review, Agent skill upstream boundary, and Checklist sections, and the issue is referenced as a follow-up rather than using the required Fixes # format.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 4 functions across 5 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 11a57ab7-91f5-4fed-9033-3055137353dd
Commits

Reviewing files that changed from the base of the PR and between be9eb93 and 7573fcc.

Files selected for processing: 3
  • src/main/github/client/detect/repository-merge-metadata-cache.ts
  • src/main/github/client/detect/repository-merge-metadata.ts
  • src/main/github/repository-merge-metadata-reuse.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@OrcaWin
OrcaWin merged commit a516ba9 into main Oct 29, 2026
34 checks passed
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