Repository navigation
feat(batch): sealed operator recovery and guarded terminal outcome for language guards - #23812
Conversation
…r language guards Two reviewed capabilities for the 5-r1027b held set (lead 0f7cec / op1 900ca2): 1. An operator take-over of sealed prepared epoch-1 intents. A new --prepared-independent mode in batch_pipeline_speech_redrive.py admits exactly the ids in a unit-ids file, only while each unit is language-guarded, epoch-1 prepared, unspent (no receipt, result or marker) and above the runtime 60s independent bound, up to a scoped --max-seconds. It spends the EXISTING intent through RecoveryStore.start (the same at-most-once token fence; no new marker), rechecks the owner allowance against Soniox exactly as the runtime independent route, and settles through the same Soniox receipts. Dry-run by default; the plan sha binds the seal census, max_seconds and --usd-cap; the closed cost estimate must fit the cap. The global 60s bound and every runtime path are unchanged. 2. A guarded terminal outcome. A language-guarded unit may settle no_recoverable_speech only when both recognizers returned a validated empty (receipts recorded) and the independent side was attempted; the refusal stands when recovery was not attempted. The payload records LANGUAGE_GUARD_EMPTY_EVIDENCE. Guarded silence and canary routes keep refusing in the terminal tool. An empty or failed take-over settles failed_held; it never fabricates the unattempted Modulate receipt that the independent silence contract requires.
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 57c40eed6e
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| '--prepared-independent', | ||
| action='store_true', | ||
| help='Operator take-over of sealed prepared epoch-1 intents above the 60s bound; exact unit IDs required', |
There was a problem hiding this comment.
Document the new operator recovery and terminal exceptions
Update backend/docs/listen_pusher_pipeline.mdx alongside these transcription changes. Its “Independent language-guarded batch recovery” section still describes 60 seconds as a hard per-unit cap and requires a new epoch-3 plan for existing held units, whereas this change permits a scoped above-60-second epoch-1 takeover and adds a guarded terminal outcome. Operators following the authoritative pipeline contract therefore receive contradictory authorization and settlement guidance. backend/AGENTS.md explicitly requires updating that document in the same PR for transcription changes.
AGENTS.md reference: backend/AGENTS.md:L163-L163
Useful? React with 👍 / 👎.
| return 'running_held' | ||
| payload, failure, billable = None, None, False | ||
| try: | ||
| payload = independent_stt(item, audio, MultilingualEmpty(duration, spans, worker)) |
There was a problem hiding this comment.
Carry scoped authorization through the Soniox adapter
For prepared units whose decoded audio exceeds 60 seconds, the default independent_stt=second_transcribe still calls utils/stt/soniox_batch.py::transcribe, whose authorization(duration) invokes the unchanged allowed(duration) hard cap. Consequently, even an approved --max-seconds 190 plan is rejected before any HTTP request, after protocol.start() and the Soniox claim have already consumed the existing intent; the exception then settles the unit as failed_held, preventing a retry. Pass an explicit scoped authorization through the adapter without relaxing the runtime cap, and exercise the real adapter authorization in the takeover tests—the current tests replace soniox_batch.transcribe entirely and miss this rejection.
Useful? React with 👍 / 👎.
repair and #23795 duration-limit Reconciles the operator script's four modes (epoch-2 default, epoch-3 independent, epoch-4 words repair from main, epoch-1 prepared take-over from this lane) and keeps every existing plan digest byte-stable. Also extends the prepared take-over to the exact failed_held shape that #23795's hold_duration_limit refusal settles without ever starting the intent: RecoveryStore.start_duration_limited reopens only that shape (never a spent intent) in one fenced transition into the running take-over, so a concurrent sweep cannot re-settle the refusal between reopen and start.
Luna round 1 (P2): float('inf') passed the positive-value checks, so an
infinite --usd-cap accepted any estimate and an infinite --max-seconds
admitted any unit up to the 7200s audio limit. Both argparse gates and
prepared_budget now require math.isfinite; NaN was already refused by the
comparison and is covered by the new budget tests.
Summary
Two reviewed capabilities for the 5-r1027b language-guarded held set (lead ruling 0f7cec on op1 900ca2; partition in
selector/proposal-14z.md, option A design inselector/proposal-soniox18.md):Scoped operator recovery for language-guarded
preparedunits above the 60s bound (option A). A new--prepared-independentmode inbackend/scripts/batch_pipeline_speech_redrive.pyaccepts an explicit sealed id list (--unit-ids-file, exact ids required) and takes over the existing epoch-1 prepared intent viaRecoveryStore.start— the same at-most-once token fence; no new marker intent is created and custody is preserved. It then runs independent Soniox recovery for those ids only, up to a scoped--max-secondsthat must exceed the runtime 60s bound. Dry-run by default; the plan sha (paid_digest) binds the seal census,max_secondsandusd_cap; the closed cost estimate (ESTIMATED_USD_PER_AUDIO_HOUR) must fit--usd-capor the plan refuses. The owner allowance is rechecked against Soniox exactly as the runtime independent route (sync_allowed,DispatchPath.QUARANTINE) — the take-over never bypasses it.Guarded terminal outcome. A language-guarded unit may settle
no_recoverable_speechonly when every recognizer returned a validated empty receipt (modulate and soniox,word_count == 0) and independent recovery was attempted; the payload recordsLANGUAGE_GUARD_EMPTY_EVIDENCE. The existing refusal (independent recovery required) stands whenever recovery was not attempted or any receipt is non-empty (words/error/refused). Guarded silence and the guarded canary route keep refusing in the terminal tool.Reconciliation with #23795 (duration-limit refusal) and #23775 (words repair)
Main moved under this lane; the branch merges origin/main and reconciles the operator script's four modes (epoch-2 default, epoch-3 independent, epoch-4 words repair, epoch-1 prepared take-over) with every existing plan digest byte-stable.
#23795's
hold_duration_limitsettles the sealed population's no-CPU-span subset asfailed_heldwith anindependent_duration_limitrefusal — without ever starting the intent (no provider call, receipt, provider or failure). Once that fix train serves, those units are no longerprepared, so the take-over extends to exactly that shape:config.batch_language_recovery.duration_limited(job)recognizes only the exact refusal shape fix(batch): stop impossible language recovery inspection loops #23795 writes; a spent intent (real failure) never matches.RecoveryStore.start_duration_limitedmirrorshold_duration_limit's fence and performs one atomic transition refusal→running (providermodulate, freshstarted_at, refusal and itssettled_atremoved). Going straight to running closes the race where a concurrent sweep could re-settle the refusal between a reopen and astart().(token, epoch, privacy_generation, prepared_at), none of which the refusal settlement touches — so one frozen cohort covers each unit in whichever state the runtime has left it (prepared, refusal-settled, or already spent by this plan).What is deliberately unchanged
MAX_AUDIO_SECONDS) andallowed()— the env can still only lower it. The runtime's new fix(batch): stop impossible language recovery inspection loops #23795 settlement behavior is preserved verbatim (testtest_runtime_duration_limit_still_settles_without_a_provider_call).held_result_allowed/ the runtime settle fence — a guarded unit still cannot settleno_recoverable_speechthrough the runtime; only the reviewed terminal tool path gains that outcome.failed_heldthrough the same Soniox receipts as the runtime independent route. It never fabricates the unattempted Modulate receipt that the independent silence contract (validate_independent_silence) requires, so a take-over cannot settle silence.Fences (per unit)
prepared_eligible: owner pin, quarantined in window,worker_failed, language-guarded, epoch 1 with token and nostarted_at/receipts,prepared(unsettled) or the exact duration-limit refusal shape, no result and nospeech_redrive/silence_disposition/terminal_dispositionmarker, and60 < duration <= max_seconds. Every id in the sealed file must be eligible (unit_not_eligibleotherwise); the cohort manifest freezes ids and per-unit fingerprints;checked_preparedrevalidates seal identity, eligibility and ledger debt in a read-only transaction before any apply step;RecoveryStore.checkedgains an opt-inallow_completed_recoveryledger path (default off, no existing caller changes) so a settled unit replays after projection completes.start_duration_limitedrefuses everything except the exact refusal shape (wrong token, foreign audio uri, sub-bound duration, spent intent).Tests
New:
tests/unit/test_batch_pipeline_prepared_independent.py(30) — sealed-selection fence matrix (including the refusal shape and a spent-failure negative), dry-run read-only and no-audio-download, spend cap, scoped bound (both > max and <= 60 refused), runtime bound identity (flag on + env 190 still refuses >60s), #23795 runtime identity, refusal reopen through the take-over,start_duration_limitedshape-fence negatives, words recovery through worker-VAD word clocks, empty/error settlefailed_heldwith soniox-only receipts, allowance recheck, at-most-once (already_applied,running_held, artifact-only reconcile), fingerprint stability across refusal settlement and spend, digest binding incl. legacy byte-stability.tests/unit/test_batch_pipeline_guarded_terminal.py(17) — guarded terminal settle with recorded evidence + replay, negative controls for each missing/non-empty receipt condition, guarded silence and canary still refused, dry-run read-only, and the live runtime→terminal integration (runtime records both empty receipts, plan settles the unit). Existing suites for every touched module (12 files incl. main's repair/duration-limit suites) pass unchanged.Operator runbook (after lead grant by plan sha)
Dry-run from the pinned train image, RO tier:
--stage prod --prepared-independent --unit-ids-file <sealed 18 file> --cohort-file <new> --quarantined-after/-before <window> --expect-count 18 --expect-speech-count 18 --paid-epoch 1 --max-seconds 190 --usd-cap 3. Then apply with--apply --approve-plan-sha256 <plan sha> --apply-limit 18under prod-operator. Sealed snapshot:prepared-snapshot-124022.json(sha256 bfc0e6d5…, 18 ids, 60.02–181.02s, 1458.57s total ≈ $0.04 estimated). The plan covers each unit whether the runtime has left itpreparedor #23795-refusal-settled.Note for the run: on an empty Soniox answer these units settle
failed_held(soniox-only receipt). The terminal tool then requires padded-retry evidence they do not carry, so empty answers stay held — words are what releases them. The 6 guarded failed_held with both empty receipts (and padded evidence) settle throughscripts/batch_pipeline_terminal_empty.pyasno_recoverable_speech.Failure-Class: none