Repository navigation
lr/06: draining preconditions gate legacy_sync (cap-hold ladder debit) - #22479
Merged
Merged
Conversation
ramp_set refuses `--legacy-sync draining|dark` from `on` until every id in ramp_controller.DRAINING_PRECONDITIONS is confirmed with --precondition-met. The first id is cap_hold_ladder_debit: batch-admitted cap-hold units must debit the ladder v1 usage budget (Subscription session ruling 10-19), and no environment drains until that is closed. Returning to on, and draining -> dark, stay ungated. The legacy-dark runbook lists the new precondition, and its transition commands now match ramp_set's real CLI (--show, --expected-revision, --actor, --reason, --apply). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Git-on-my-level
added a commit
that referenced
this pull request
Oct 19, 2026
…dow (ladder debit) (#22513) * feat(funding): cap-hold units handed to batch are charged without a stale window Subscription ruling 10-19 on #22467 (cap-hold rehome). This closes the cap_hold_ladder_debit draining precondition (#22479). A: legacy recovery debits the ladder budget synchronously, but a hold handed to batch is debited only when projection commits. The backlog worker therefore checked the next candidate against stale capacity, and with remaining=None a whole page overshot (60-unit allowance, three 40-unit holds: 3 admitted, now 1). - recover_selected reserves the hold's units (the worker's own candidate units) before the hand-off is durable. - work() subtracts open reservations for the current period from capacity(). - A reservation settles when the batch outcome is known. Projected means the usage is committed atomically with the ledger; briefly both count, never neither. Failed or abandoned releases it. A 6h TTL releases it with an error log and a counter. - Previous-period reservations never shrink the new month. - The real job lease serializes two workers for one owner; a test proves it. B: cap-hold admission carries usage_period (the funded choice's month). Projection backdates the hourly stamp to that period's last second only across a rollover, never forward. Transcription has no day rollup, and the month query reads the doc id/year/month from the stamp. Usage sessions re-read a closed month in full. C: a test asserts the cap-hold path (accept_upload) never builds a native_record binding, which would skip the usage write. Lane 8 signed off on the edits in its files (recover_selected, intake.accept_upload usage_period, its hook test expectations). Worker test harnesses stub the reservation read; the new behaviour is covered in test_cap_hold_batch_debit.py. Co-Authored-By: Claude Opus 5.5 <[email protected]> * refactor(funding): pyright-clean reservation arguments Co-Authored-By: Claude Opus 5.5 <[email protected]> * feat(funding): never release a still-pending cap-hold reservation by age Subscription session review of #22513 (PR comment 6270782314). A batch job that is still pending past the threshold is slow, not lost; a lost job already reads as abandoned. Releasing it would let the backlog worker over-admit while batch still owes the debit, which reopens gap A. Such a reservation is now kept and still counted. It is marked stale once, with an error log and omi_cap_hold_reservations_released_total{outcome= "stale"}. Release happens only on projected, failed or abandoned. Other-period entries stop counting at once and are pruned after 7 days. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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
ramp_set.pyrefuses to move any environment'slegacy_syncoffonuntil every id inDRAINING_PRECONDITIONS(scripts/rollout/ramp_controller.py) is confirmed with--precondition-met <id>. The first id iscap_hold_ladder_debit: batch-admitted cap-hold units must debit the ladder v1 usage budget, and no environment drains until that is closed (Subscription session ruling, 10-19). Rollback toon, anddraining→dark, stay ungated. The legacy-dark runbook lists the precondition, and its transition commands now match the realramp_setCLI; the old ones would have been refused.Lane / contract
Lane 06, contracts (g) and (h) (entry precondition). Owner sign-offs for edits to other lanes' files: lane 10's
docs/runbooks/legacy-dark.mdwas edited at the lead's request (gate list); lane 10 was notified directly.Product invariants affected
INV-DATA-1: path match only, from the integration merge base. This diff touches only
scripts/rollout/, a test and a runbook; it does not alter the Firebase/Firestore project or any serving endpoint.Verification
tests/unit/test_ramp_controller.py: 51 pass locally (unit layer, m5, serial). No staging or prod run; this is an operator-CLI guard.Rollback
Revert the PR.
ramp_setthen writeslegacy_syncwithout the precondition check.Failure-Class: none
🤖 Generated with Claude Code