Skip to content

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

Merged
guicaulada merged 1 commit into
gc/feat/github-apps-manifestfrom
gc/feat/rate-limit-aware-app-selection
Sep 8, 2026
Merged

feat(github-app): select app by rate limit budget#5283
guicaulada merged 1 commit into
gc/feat/github-apps-manifestfrom
gc/feat/rate-limit-aware-app-selection

Conversation

@guicaulada

Copy link
Copy Markdown
Contributor

Description

Follow-up to #5269, item 2 of the #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 review from a team as code owners August 19, 2026 18:03
@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

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

Scanned Files

None

Replace uniform random GitHub App selection with budget-aware
selection. The auth module tracks the last observed
x-ratelimit-remaining per app (fed by response headers and the
throttling plugin callbacks) and selects the app with the most budget
left. Apps that hit a secondary rate limit are skipped for 60 seconds.
Iteration starts at a random offset so concurrent cold-started lambdas
do not converge on the same app.

Uniform random selection kept sending ~1/N of traffic to apps that
were already exhausted or throttled. Selection state is per warm
container and converges within a few invocations.
@guicaulada
guicaulada force-pushed the gc/feat/rate-limit-aware-app-selection branch from 210cd52 to fb3555f Compare September 8, 2026 13:11
@guicaulada
guicaulada force-pushed the gc/feat/github-apps-manifest branch from 70c81ad to 19b8130 Compare September 8, 2026 13:11
@guicaulada
guicaulada merged commit 3eb2d6a into gc/feat/github-apps-manifest Sep 8, 2026
12 of 18 checks passed
@guicaulada
guicaulada deleted the gc/feat/rate-limit-aware-app-selection branch September 8, 2026 17:50
guicaulada added a commit that referenced this pull request Sep 8, 2026
## 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 added a commit that referenced this pull request Sep 8, 2026
## 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 added a commit that referenced this pull request Sep 8, 2026
## 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 added a commit that referenced this pull request Sep 8, 2026
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.

- 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.

Follow-up to #5269 / #5038. Depends on #5282.
guicaulada added a commit that referenced this pull request Sep 8, 2026
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.

- 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.

Follow-up to #5269 / #5038. Depends on #5282.
guicaulada added a commit that referenced this pull request Sep 8, 2026
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.

Uses the credential storage interface introduced on main and preserves
the selected app index throughout each operation. Includes a regression
test verifying selection from an injected credentials store without
reading SSM.

This PR targets `main` and contains only the rate-limit selection
change. The manifest prerequisite was merged separately in #5282.
Replaces #5283, which was originally merged into the parent feature
branch.

Validation: 350 control-plane tests passed; TypeScript, ESLint, and diff
whitespace checks passed. The commit is signed and verified.

Follow-up to #5269 / #5038.
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.

2 participants