Repository navigation
Record a Quota wait only when the probed quota is low - #2143
Merged
Merged
Conversation
A rate-limited request whose rate_limit probe already shows the reserve (the window reset in between) recorded a wait until the next reset, so every Pass skipped and the Command slept for up to an hour with a full quota. The probe is now an ordinary observation: it records a wait only below the reserve and clears any stored one otherwise, and the Command retries the request once at once. Stored waits that still hold the reserve no longer count for Pass admission or the Inbox.
Seed a real stored wait in the regression test so it proves the probe clears it, pin the retry-once bound, check status's Inbox warning, share the quota record edit helper, move the failed-probe note to its call site, keep the glossary to what a Quota wait is, and say in the guide that a second rate limit after the retry fails the call.
Two tests modelled a primary rate limit with a rate_limit probe still showing the reserve, which now means the window already reset: no Quota wait. Their later probes now report the quota spent.
Owner
Author
|
Delivery completed on agent-authored or reviewed head 41744de. |
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A rate-limited request whose
gh api rate_limitprobe already shows the window reset recorded a Quota wait until the next reset. Every Pass on the machine then skipped, and the Command slept, for up to an hour with a full quota. The probe is now an ordinary observation.GitHub::output_with_input (rate-limited request) record_quota_failure probe rate_limit - Store::exhausted(quota) # always waiting = true - return quota.reset_at + Store::observe(quota) # waits only while quota.low(); else clears the stored wait + return Some(reset) if remaining < 500, else None - quota::command::wait(reset) # sleeps a whole window at 4995 left + Some(reset) -> quota::command::wait(reset) (unchanged) + None -> retry the call once, immediately (Commands only) Store::waiting # Pass admission, Inbox, status - keep waits with reset_at > now + keep waits with quota.low(now) # a stored 4995-left wait is not a waitremaining 0, reset in 15 minutes, so it still records a wait (src/github/execution_tests.rsunchanged and passing).RESERVEconstant. The Inbox warning always says "(fewer than 500)", since only low waits reach it.GLOSSARY.md(Quota wait),docs/guide.md(+ regeneratedsite/docs/index.html) andsite/how-it-works/describe the single immediate retry.security_run::within_cap_quota_wait_keeps_pre_audit_github_diagnostics_localandstatus::github_failures_warn_with_last_answer_and_clear_after_recovery. Under this fix a probe like that means the window already reset. Their later probes now report the quota spent, via the fake'snext_rate_limits, so they keep testing a real Quota wait.Evidence
Execution evidence
Confirmed cause:
record_quota_failurerecorded every probe viaStore::exhausted(waiting = trueunconditionally) and returned its reset.pass_quota_waitthen trusted any stored wait without probing.Before (fix not applied, original form of the test):
cargo test --test quota_wait a_rate_limit_whose_probe_shows_the_reserve_retries_without_a_quota_waitWith a probe of 4995 left and a reset beyond the two-hour cap, the Command tried to wait for that reset and failed with the original error. With an hour's reset, it sleeps an hour.
After:
test a_rate_limit_whose_probe_shows_the_reserve_retries_without_a_quota_wait ... ok.pr readyis called twice and the PR is made ready. The test now also seeds a real stored wait (graphql: 400 left) first and asserts the probe cleared it.Before:
cargo test --test pass_quota a_stored_wait_with_the_reserve_available_does_not_skip_a_passThis is the exact message the fleet logged.
After:
test a_stored_wait_with_the_reserve_available_does_not_skip_a_pass ... ok.statusshows neither the wait nor "Inbox reads paused", and Pickup does GitHub work.New:
a_rate_limit_whose_probe_shows_the_reserve_retries_only_once ... ok. If the retry is rate-limited too, the call fails with the original error after 2 calls, with no wait.Mutation checks, each reverted afterwards:
observewhen not low fails the clearing assertion.reset_retriedbound failsretries_only_once.Store::waitingonreset_atonly fails the Pass test.Other test runs:
cargo test --test quota_wait --test pass_quota: 10 + 7 passed.cargo test --bin thirdshift github::: 74 passed.cargo clippy --all-targets -- -D warningsandcargo fmt --checkare clean.npm test --prefix site: 69/69, includingdocs:check.Full suite:
scripts/affected-tests mainselects the full Rust suite plus site. A cleancargo test --no-fail-faston 4aab052 passed 4468 tests and failed 8. None of the 8 touches quota code:activity_log::an_activity_log_that_cannot_be_written…,architect_run::a_failed_send…,launch_pull::an_up_to_date_launch_directory…,merge_run::a_merge_run_ends_with_the_issue_closed…,merge_run::an_issue_branch_already_deleted…,pickup_run::ready_labels_are_read…,run_notification::a_failed_send…. Under full parallel load in the container they loggedcould not read process …'s environment: Permission deniedsweep warnings.trial_scope::trial_sessions_keep_their_cap_and_clean_detached_workfails because the container has nosystemctl.After merging the latest
main(41744de):quota_wait,pass_quota,statusandsecurity_run(10 + 7 + 79 + 130) pass, and so do thegithub::units (74), clippy, fmt anddocs:check.Environment note: this host has no C compiler. Rust builds and tests ran in the local
node:22container (--init, with host/etc/passwdmounted) using the repo's pinned 1.99.1 toolchain from the host.Visual evidence
site/how-it-works/gains one sentence in the "Deliver against the latest Base branch" paragraph. Captures are at 1440×900 (Before fromorigin/main, After from this branch; the paragraph is outlined):/tmp/before-desktop.7sdLyF.png,/tmp/after-desktop.sM3B1T.png. Uploading them to a secret Gist was denied by this session's permission policy, so they are not embedded. Layout is unchanged; it is a copy edit inside an existing<p>.Merge Danger
Door: two-way
Revertible. Existing
~/.thirdshift/github-quota.jsonrecords stay readable; a stored wait with ≥ 500 left is simply ignored.Blast Radius: quota
Affects every Pass's admission and every Command's handling of a primary rate limit. A misclassified rate limit (probe full, request still limited) now fails after one immediate retry, where it used to wait a window.
Unaddressed findings
Standards
self.wait_for_quota && quota::command::active()in the reset-retry and secondary-limit guards (src/github.rs,output_with_input). Declined: the two guards bound different counters (!reset_retried,secondary_retries < 5). A helper would name only two short field reads next to each other in onematch. Judgement call; behaviour is unaffected.record_quota_failurereturnsOption<DateTime<Utc>>(src/github/quota.rs) rather than aRecoveryenum. Declined:Nonemeans "no reset to wait for", which the doc comment states. The retry bound lives where the request is retried, beside the secondary-limit retry counter in the same loop. Judgement call; behaviour is unaffected.Spec
None. All three Spec findings were addressed: stored-wait clearing is now tested, the Inbox text is asserted, and the guide states that a second rate limit after the retry fails the call.
Security review outcome
Review coverage
Both reviewers read every changed file except
site/docs/index.html, generated fromdocs/guide.md. Both confirmed that exclusion on the evidence thatnpm run docs:check --prefix siteandnpm test --prefix site(69/69) pass.Left unread by the review:
tests/security_run.rsandtests/status.rs. They changed in 4aab052 after the review, in the fixture-only change described in the Summary.Closes #2128
Built with codex codex-cli 0.167.1 · gpt-6.1-sol · xhigh