Skip to content

feat(batch): sealed operator recovery and guarded terminal outcome for language guards - #23812

Merged
Git-on-my-level merged 3 commits into
mainfrom
lane/heldfix
Oct 27, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
lane/heldfix

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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 in selector/proposal-soniox18.md):

  1. Scoped operator recovery for language-guarded prepared units above the 60s bound (option A). A new --prepared-independent mode in backend/scripts/batch_pipeline_speech_redrive.py accepts an explicit sealed id list (--unit-ids-file, exact ids required) and takes over the existing epoch-1 prepared intent via RecoveryStore.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-seconds that must exceed the runtime 60s bound. Dry-run by default; the plan sha (paid_digest) binds the seal census, max_seconds and usd_cap; the closed cost estimate (ESTIMATED_USD_PER_AUDIO_HOUR) must fit --usd-cap or 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.

  2. Guarded terminal outcome. A language-guarded unit may settle no_recoverable_speech only when every recognizer returned a validated empty receipt (modulate and soniox, word_count == 0) and independent recovery was attempted; the payload records LANGUAGE_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_limit settles the sealed population's no-CPU-span subset as failed_held with an independent_duration_limit refusal — without ever starting the intent (no provider call, receipt, provider or failure). Once that fix train serves, those units are no longer prepared, 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_limited mirrors hold_duration_limit's fence and performs one atomic transition refusal→running (provider modulate, fresh started_at, refusal and its settled_at removed). Going straight to running closes the race where a concurrent sweep could re-settle the refusal between a reopen and a start().
  • The sealed plan's fingerprint freezes (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

  • The global runtime 60s independent bound (MAX_AUDIO_SECONDS) and allowed() — 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 (test test_runtime_duration_limit_still_settles_without_a_provider_call).
  • held_result_allowed / the runtime settle fence — a guarded unit still cannot settle no_recoverable_speech through the runtime; only the reviewed terminal tool path gains that outcome.
  • An empty or failed operator take-over settles failed_held through 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.
  • Existing epoch-2/3/4 plan digests are byte-stable (the new knobs are only bound into prepared-mode digests).

Fences (per unit)

prepared_eligible: owner pin, quarantined in window, worker_failed, language-guarded, epoch 1 with token and no started_at/receipts, prepared (unsettled) or the exact duration-limit refusal shape, no result and no speech_redrive/silence_disposition/terminal_disposition marker, and 60 < duration <= max_seconds. Every id in the sealed file must be eligible (unit_not_eligible otherwise); the cohort manifest freezes ids and per-unit fingerprints; checked_prepared revalidates seal identity, eligibility and ledger debt in a read-only transaction before any apply step; RecoveryStore.checked gains an opt-in allow_completed_recovery ledger path (default off, no existing caller changes) so a settled unit replays after projection completes. start_duration_limited refuses 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_limited shape-fence negatives, words recovery through worker-VAD word clocks, empty/error settle failed_held with 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 18 under 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 it prepared or #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 through scripts/batch_pipeline_terminal_empty.py as no_recoverable_speech.

Failure-Class: none

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

chatgpt-codex-connector Bot commented Oct 27, 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-27T15:41:27.948561Z ce69897 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +253 to +255
'--prepared-independent',
action='store_true',
help='Operator take-over of sealed prepared epoch-1 intents above the 60s bound; exact unit IDs required',

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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.
@Git-on-my-level
Git-on-my-level merged commit 9d2b0a3 into main Oct 27, 2026
57 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/heldfix branch October 27, 2026 16:29
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