Skip to content

feat(github-app): select app by rate limit budget - #5390

Closed
guicaulada wants to merge 1 commit into
gc/feat/github-apps-manifestfrom
codex/rate-limit-aware-app-selection
Closed

feat(github-app): select app by rate limit budget#5390
guicaulada wants to merge 1 commit into
gc/feat/github-apps-manifestfrom
codex/rate-limit-aware-app-selection

Conversation

@guicaulada

Copy link
Copy Markdown
Contributor

Replaces uniform random GitHub App selection with selection based on the last observed rate-limit budget. Apps under a secondary rate-limit cooldown are temporarily skipped, and randomized starting points spread cold-start traffic across apps.

This PR is stacked on #5282 and contains only the rate-limit selection change. Merge #5282 into main first, then retarget and rebase this PR onto main before squash-merging it separately.

Replaces #5283, which was merged into the parent feature branch rather than main. The original signed rate-limit commit is preserved here; it has been removed from #5282.

Validation: the commit is unchanged from the previously tested version (350 control-plane tests passed, TypeScript checks passed). The split preserves the combined file contents and the existing valid signature; git diff --check passes.

Follow-up to #5269 / #5038.

## Description

Follow-up to #5269, item 2 of the [#5038
review](#5038 (review)).
Stacked on #5282 (manifest transport); review that first.

Replaces uniform random GitHub App selection with budget-aware
selection, ported from our production fork:

- The auth module tracks the last observed `x-ratelimit-remaining` per
app, fed by `metricGitHubAppRateLimit` headers and the throttling plugin
callbacks.
- Selection picks the app with the most budget remaining; apps with no
observed state are assumed full.
- Apps that hit a secondary rate limit are skipped for 60 seconds; if
every app is cooling down, the one with the most budget is used anyway.
- Iteration starts at a random offset so concurrent cold-started lambdas
do not converge on the same app.

Uniform random kept sending ~1/N of traffic to apps that were already
exhausted. Selection state is per warm container and converges within a
few invocations; a cold container starts as before.

## Test Plan

- control-plane: 353 tests passed, including six new selection tests
(budget preference, unobserved-assumed-full, cooldown skip, all-cooling
fallback, single-app short-circuit, explicit appIndex) and a
selector-feed test for the rate-limit headers.
- ESLint + Prettier clean.

## Related Issues

Follow-up to #5269 / #5038. Depends on #5282.
@guicaulada
guicaulada requested a review from a team as a code owner September 8, 2026 19:53
@guicaulada guicaulada closed this Sep 8, 2026
@guicaulada
guicaulada deleted the codex/rate-limit-aware-app-selection branch September 8, 2026 19:57
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

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