Skip to content

v3 fast finish: reserve each long-pass retry before it sends (SCA-4434) - #26379

Merged
Git-on-my-level merged 6 commits into
mainfrom
lane/ff-long-retry-reserve
Nov 27, 2026
Merged

Git-on-my-level merged 6 commits into
mainfrom
lane/ff-long-retry-reserve

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

What changed and why

Follow-up to #26344, which is now merged; the base is main. SCA-4434: about 1.5× as many long manual Finishes fit under the same daily fast-STT cap, and the cap stays strict.

Before, a long pass (over 20 min) reserved 2 × planned + 30 s at admission, so its one retry per chunk was paid for up front. At the 7,200 s default (CONVERSATIONS_V3_FAST_FINISH_LONG_DAILY_SECONDS), only one 30-minute pass (3,666 s) fit at a time, and about two fit in a day.

Now:

  • Admission reserves planned + 30 s (each chunk once, plus the probe clip). Admission screening (screen / room) checks against the same amount.
  • Each chunk retry first reserves its own seconds on the pass's key, v3_fast_finish:long_audio_seconds:<day>. It uses the same INCRBYFLOAT with an immediate take-back over the cap, in one pipelined round trip on the existing bounded (1 s) client, and only on the retry path. The reserve runs only:
    • after the sticky privacy check and the stop check,
    • after a second check of the recorded denial, just before the reserve,
    • with at least 3 s (RESERVE_MIN_SECONDS) of the deadline left.
  • When the reserve fails (over the cap, Redis error or timeout), the retry is not sent. The chunk fails as a failed retry does, and the pass yields to batch through the existing path with outcome retry_cap. With under 3 s left, the chunk fails with its first error, as before.
  • No audio is sent unreserved. _Sent closes when the pass settles. After that, nothing more is sent or reserved, and a retry reserve that lands after the settle gives its seconds back. A settle can therefore only refund, never undercharge.
  • Late reservation: a retry whose reservation returns with under 1 s (RETRY_SEND_MIN_SECONDS) of the deadline left is not sent (_Expired, which counts as deadline). Its reserved seconds are refunded at settle. A retry's reservation can take about 3–4 s in the worst case (AUTH on a new connection, the health-check PING, the pipeline and the give-back). The admission reservation can take about 5 s, so it ends within STOP_GRACE_SECONDS past the deadline. The slot bound holds because every wait on these calls is bounded.
  • Settle works as before: it charges what was sent and refunds the rest, including a reserved retry that was never sent.
  • Metric: omi_conversations_v3_fast_finish_total{outcome="retry_cap"} is pre-initialised and kept by the existing GMP keep regex (conversations_v3_fast_finish_total).

At 7,200 s, about three 30-minute passes fit a day, versus two, and two fit at once. The bound is unchanged.

Ramp: move CONVERSATIONS_V3_FAST_FINISH_LONG_PERCENT 25 → 100 after the first 24 h readback of long-pass latency (first card within 60 s) and long audio seconds. Any cap raise is David's spend decision. Flag notes, the runbook and the change note say the same.

This PR does not deploy, set any env or merge anything.

Product invariants affected

How it was verified

The worktree is on head cbc8142a113, which includes origin/main at cb15ebd4fa5 (#26344 merged as 4e5dfdb1088). All runs went through omi-heavy:

  • test_conversations_v3_fast_finish_chunked.py plus test_conversations_v3_fast_finish.py: 243 passed. With test_real_clock_budget_ratchet.py added: 254 passed.
  • python -m testing.pipeline_lab scenario run --jobs 4 --repeat 2 --json --stt replay: overall outcome passed. 12 of 13 scenarios passed and finish_after_second_close was xfail, as it is declared expected_failure (v3: Finish a sealed recording before its first live window #26288).
  • Mutation checks, each run on both fast-finish files:
    • _run reading _Sent instead of close() fails the abandoned-chunk test.
    • Dropping the post-reserve time check fails the late-reservation test.
    • Replacing the 1 s minimum with a plain deadline check fails the 0.1 s-left case.
    • Removing retry_cap from the pre-init list fails the fresh-process test.
  • scripts/check_feature_flag_registry.py: OK.

These are unit and lab results only. Nothing was deployed.

Tests

In test_conversations_v3_fast_finish_chunked.py:

  • Admission reserves planned + 30, and that is all the counter holds while the pass runs.
  • A retry reserves its own seconds before it sends. The counter equals admission plus that chunk's seconds at the retry's send.
  • With the cap set exactly to the admission amount, the retry is skipped, the outcome is retry_cap, nothing is written, and nothing beyond the reservation is sent.
  • A Redis error at the retry reserve skips the retry.
  • Two _FleetBudget instances (two processes) racing 40 takes on one counter keep at most the cap. A second process taking the last room makes the pass's retry retry_cap.
  • Settle refunds a reserved retry that was not sent (the pass stopped during the reserve). A retry reserve that lands after settle gives its seconds back.
  • A denial recorded by another check, a denial at the retry check, or a stop during the first request: no reserve.
  • A retry with under 3 s left reserves nothing.
  • Two 30-minute passes fit under 7,200 s at once, and three in a day; a fourth gets long_cap.
  • _run-level: three abandoned long chunks are held just before their send until run() has returned and settled. After that they make no provider call and charge nothing. The language probe cannot reach add after settle, because the pass waits on its resolution until the deadline and the probe rechecks the deadline before charging.
  • A retry whose reservation returns past the deadline, or with 0.1 s left, is not sent and is refunded.
  • Every outcome, retry_cap included, is pre-initialised at import. This is checked in a fresh process, so test order cannot create the label. All outcomes are also kept by the GMP regex.

UI-Evidence: none -- backend only

Failure class (fixes)

Failure-Class: none

🤖 Generated with Claude Code

Git-on-my-level and others added 2 commits November 26, 2026 00:10
A long pass reserved every chunk twice (its one retry) plus the probe at
admission, so at the 7,200 s default only one 30-minute pass fit at a time
and about two a day. Admission now reserves every chunk once plus the 30 s
probe clip; each chunk retry reserves its own seconds on the pass's key
just before it sends, after the sticky privacy and stop checks and with at
least 3 s of the deadline left. A retry that does not fit, or meets a Redis
error or stall, is not sent: the chunk fails and the pass yields to batch
as retry_cap. No audio leaves unreserved, so the cap stays strict; settle
still charges what was sent and refunds the rest, reserved retries
included. About three 30-minute passes now fit a day at 7,200 s.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-long-retry-reserve

# Conflicts:
#	backend/utils/conversations/v3/fast_finish.py
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T20:13:26.234163Z cbc8142 New commits
ℹ️ 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 and others added 2 commits November 26, 2026 00:55
…serve (SCA-4434)

Review of #26379 at a7bf71c:
- P2: a _run-level test holds three long chunks just before their send
  until run() has returned and settled; they then send and charge nothing.
  It fails when _run reads _Sent instead of closing it.
- P3: a retry whose reservation returns past the deadline ends as _Expired;
  its reserved seconds are refunded at settle.
- P3: outcome pre-initialisation is checked in a fresh process, so test
  order cannot create the label.
- P3: the RESERVE_MIN_SECONDS comment states the 3-4 s worst case and why
  the slot bound still holds.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Base automatically changed from lane/ff-long-multi to main November 26, 2026 19:22
Git-on-my-level and others added 2 commits November 26, 2026 14:59
Review of #26379 at 1753873 (P3s):
- A retry whose reservation returns with under RETRY_SEND_MIN_SECONDS
  (1 s) of the deadline left is not sent (_Expired, refunded at settle),
  not only one past the deadline. The test covers 0.1 s left and past.
- The RESERVE_MIN_SECONDS comment covers the admission reserve's worst
  case (about 5 s, ending within STOP_GRACE_SECONDS past the deadline)
  as well as a retry's.
- The abandoned-chunk test releases its gate in a finally.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit b79d96b into main Nov 27, 2026
77 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/ff-long-retry-reserve branch November 27, 2026 02:22
Git-on-my-level added a commit that referenced this pull request Nov 27, 2026
Resolve backend/docs/feature-flag-registry.md by re-rendering it from the
auto-merged config/feature-flags.yaml with scripts/render_feature_flag_registry.py:
main's CONVERSATIONS_V3_FAST_FINISH_LONG_DAILY_SECONDS row (retry_cap text from
#26379) followed by this branch's CONVERSATIONS_V3_FINISH_HOME_SLI row.

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