Tier GitHub PR lookup polling to prevent quota exhaustion (#12013)

* Tier GitHub PR lookup polling to prevent quota exhaustion

The selected worktree (O(1)) checks per-minute; card list (O(N)) per-15-minutes.
Introduce process-wide cache to collapse concurrent polling and gate lookups on
available rate-limit budget with exponential backoff on failure.

- Preserve last-known review during backoff
- Invalidate cache when Orca opens a PR
- Stop coordinator from double-charging

* Tier GitHub PR lookup polling to prevent quota exhaustion

- Return the latest reset time when both GitHub API buckets are rate-limited, preventing premature retries against still-blocked buckets.
- Serve the last known review on transient lookup failures, preventing reviews from blinking out on temporary errors.
- Discard in-flight lookups that predate an invalidation so stale answers cannot overwrite newly opened reviews.

* fix: give rate-limit reset tests unique titles

oxlint vitest/no-identical-title was failing static analysis because two
cases shared the same describe title.
This commit is contained in:
Jinjing
2026-08-01 15:50:54 -07:00
committed by GitHub
parent a7d769e13d
commit 2f104d8713
24 changed files with 1070 additions and 53 deletions
+3 -12
View File
@@ -649,18 +649,9 @@ describe('pr-refresh-coordinator', () => {
'graphql',
executionOptions
)
expect(noteRepositoryRateLimitSpendMock).toHaveBeenCalledWith(
testCase.repository,
'core',
1,
executionOptions
)
expect(noteRepositoryRateLimitSpendMock).toHaveBeenCalledWith(
testCase.repository,
'graphql',
1,
executionOptions
)
// Why (#11532): the lookup itself debits the snapshot now, so every caller
// is accounted for; the coordinator must not double-charge on top.
expect(noteRepositoryRateLimitSpendMock).not.toHaveBeenCalled()
expect(getPRForBranchOutcomeMock).toHaveBeenCalledTimes(1)
})