Skip to content

lr/06: draining preconditions gate legacy_sync (cap-hold ladder debit) - #22479

Merged
Git-on-my-level merged 1 commit into
integration/legacy-retirefrom
lr/06-ramp-2
Oct 19, 2026
Merged

Git-on-my-level merged 1 commit into
integration/legacy-retirefrom
lr/06-ramp-2

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 19, 2026 •

Copy link
Copy Markdown
Member

Summary

ramp_set.py refuses to move any environment's legacy_sync off on until every id in DRAINING_PRECONDITIONS (scripts/rollout/ramp_controller.py) is confirmed with --precondition-met <id>. The first id is cap_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 to on, and draining → dark, stay ungated. The legacy-dark runbook lists the precondition, and its transition commands now match the real ramp_set CLI; 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.md was 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_set then writes legacy_sync without the precondition check.

Failure-Class: none

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T11:16:27.563809Z f05aca3 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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
Git-on-my-level merged commit 82f0b31 into integration/legacy-retire Oct 19, 2026
25 checks passed
@Git-on-my-level
Git-on-my-level deleted the lr/06-ramp-2 branch October 19, 2026 11:39
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]>
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