Skip to content

fix(batch): bound worker VAD locates language-guard words that CPU VAD missed - #23770

Merged
Git-on-my-level merged 5 commits into
mainfrom
op1/words-without-vad-worker-evidence
Oct 27, 2026
Merged

Git-on-my-level merged 5 commits into
mainfrom
op1/words-without-vad-worker-evidence

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What changed and why

Lead ruling (bus ebc45a): root-cause invalid_payload on the batch side, priority 1. On the 5% new cohort, 16 of 19 language-guarded units had recognizer words and were still rejected at payload_validation/invalid_payload, so those users got no transcript. The other 3 were true silence (response_validation/empty_asr, both recognizers empty, VAD 0.12-0.35s). The 5% step was rolled back on T5 at 02:18Z. Full read-only RCA (op1): /Volumes/Ephemeral/scratch/op1/langguard-rca-0210.md, sections "invalid_payload root cause" and "Drain result".

Root cause. The GPU worker's language guard quarantines non-English units (worker_failure {vad_windows, unsupported_language}). Each such job carries a measured, input-bound worker_vad_receipt (0.12-9.0s of speech). Quarantine recovery re-inspects the audio with strict CPU VAD (inspect_audio). On these short, low-energy captures that VAD returns spans == []. Independent recovery then runs. In prod, Modulate returned words on all 16 (10 with Soniox empty, 6 with Soniox words too). recovery_recognizers.words_payload() raised WordsWithoutVad because spans was empty, so the unit settled failed_held. Before the independent-recovery flag was on, the same empty-span result looped held forever.

Fix (RCA option (a)). When strict CPU VAD finds no spans, words_payload may locate speech from the validated word clocks, but only when the job carries independent acoustic evidence: a bound worker VAD receipt. Without that receipt WordsWithoutVad still fails closed.

Design and the bramp3 acceptance fences (bus bdb85b)

  • Words are evidence, not ground truth. Word count alone never passes. Spans come from word clocks only if contracts.worker_vad_speech(job) returns a value. It requires a worker_vad_receipt that passes the same validation attach_held_vad already enforces, now factored into bound_vad_receipt:

    • version 1, state == 'measured', 16 kHz;
    • input_uri_sha256 equal to this job's audio_uri;
    • captured_samples within 0.1s of the job duration;
    • speech_samples at or above one full VAD frame (below_silence_threshold, 0.032s). A sub-frame or zero receipt is not evidence.

    The automatic path consults it only for language-guarded jobs.

  • Acoustic accounting (lead ruling ef03d2, after bramp3's P1 39fb29). Word clocks license word placement only. worker_vad_word_spans lays the worker receipt's acoustic measure (speech_samples / 16000, capped at the captured audio) onto the validated word clocks. It fills them in order, and it grows into adjacent silence only when the measure exceeds the word duration. As a result, speech_spans total exactly the acoustic measure, and so do:

    • speech_seconds;
    • the settlement evidence (result_vad_evidence -> measured_held_vad_speech_seconds);
    • projection usage, per part and in total;
    • the per-part speech that feeds the T2 denominator.

    These never come from ASR duration. Point words add nothing, and the words keep their own clocks. The payload still goes through projection_speech_spans() at payload_validation, and the docstring now states the placement-only exception. The payload records speech_spans_source: 'worker_vad_word_clocks' and worker_vad_speech_seconds.

  • Word-clock and window fences. These are unchanged. Words still pass validate_words (clocks within the audio, ordered), and spans cannot extend past the captured window.

  • Privacy and intent fences. These are unchanged: prepare, start, settle, privacy-generation and token checks, and the BatchPrivacyBlocked/ProjectionBlocked propagation.

  • Spend. No new paid calls, and the 60s cap and the independent_allowed gate are unchanged. If anything, spend goes down: when Modulate returns words under worker evidence, recovery completes without buying the capped Soniox call.

  • Held census. This stays monotone (held_vad_census max) and is unchanged from main. The recovered result reports the same acoustic seconds main settles.

Scope (lead ruling 7fa3d2)

This PR is only the validation fix and the declared prod flag. Shared speech-redrive routing, retention and the operator census are unchanged from main. One shared-path change remains: worker evidence reaches the existing independent (Soniox) redrive through the same fixed words_payload.

Repair of the 16 already-settled units is a separate, explicit operator path in a follow-up PR stacked on this one. On this PR alone, the 16 are refused by both existing redrive plans:

  • epoch 3 is refused because independent_attempted is true;
  • epoch 2 is refused with independent_plan_required.

That is intended.

Config: declare independent language recovery ON for prod backend-integration (bramp3 860893, lead 5da7dc/ebc45a)

Independent-language recovery was turned on at runtime on prod backend-integration at 2026-10-27 02:07:01Z via cr_apply (revisions 01384-4rg, then 01385-8c7). The lead approved that activation and ruled to keep it on. The source still declared it off: backend/deploy/runtime_env/prod.overlay.yaml had BATCH_PIPELINE_INDEPENDENT_LANGUAGE_RECOVERY_ENABLED: {value: 'false'} inside the backend-integration service block. The train that ships this fix would therefore have reset it to false and recreated the held loop.

  • In the prod overlay, the backend-integration block now declares value: 'true' (category ops_kill). This was the only declaration of the key in the overlay, so the scope is that service alone. The prod runtime_env.yaml was regenerated with compose_runtime_env.py; it shows a one-line diff under prod backend-integration.

  • Unchanged: dev.overlay.yaml (false), the GPU worker chart (explicit false) and the code default (false).

  • config/feature-flags.yaml: the summary now reads "on in prod (backend-integration recovery role only), off elsewhere". The notes record "activated in prod on backend-integration 2026-10-27 02:07Z per lead 5da7dc/ebc45a after the 5% unsupported-language held loop; declared ON with the WordsWithoutVad fix". backend/docs/feature-flag-registry.md was regenerated, and check_feature_flag_registry.py reports OK. The runbook's spend/rollback paragraph is updated.

  • test_backend_runtime_env_validator.py: the gate test now asserts prod backend-integration is the only true holder and dev has none.

  • test_cross_service_deploy_contract.py: the reader-split mutation test asserted that both envs split when the worker's explicit setting is removed. It now covers the prod-on/dev-off state with two variants:

    • source default flipped on gives a dev split;
    • source default off gives a prod split.

    The worker's explicit setting therefore still provably prevents a split in either env.

  • Checks: test_backend_runtime_env_validator.py and test_cross_service_deploy_contract.py passed (167 passed, 3 skipped). The flag-registry check and its tests, the deployment-secret-boundary tests and the public-build-contract tests passed. Also passing: soniox batch (sync and async), second provider, config train, Cloud Run env drift, forbidden env, GKE render, release vector and LLM-gateway deploy-contract.

  • Rollback: set the overlay value back to 'false', or apply the runtime kill switch on backend-integration.

Luna review (single round)

  • Run: agentctl execution exec-merit-observe-legal-dwarf-rent-canvas (codex gpt-6-luna, read-only, request key op1-pr23770-luna-review-r1), 02:40:15Z to 02:43:13Z.
  • Head reviewed: ab7dd5c2873.
  • Verdict: MERGE READY, no findings. Luna could not run pytest because its read-only sandbox has no writable temp dir; the tests were run locally, as described below.
  • Collected result: /private/tmp/claude-501/-Users-dazheng-workspace/c4527541-6508-41ec-82f5-716f25e75542/scratchpad/luna.json, retrievable with agentctl result exec-merit-observe-legal-dwarf-rent-canvas --content.

Later commits were reviewed by bramp3 and not re-run through Luna, per the single-round rule:

  • 11432652 config flag;
  • 527e2674 route refactor;
  • f5fd8573 merge of main;
  • 531d8a5f acoustic accounting per ef03d2.

Product invariants affected

  • INV-MEM-4 (path-based citation: backend/deploy/runtime_env.yaml matches its glob; this PR changes only the batch-recovery flag value in that manifest, no memory promotion behavior)

How it was verified

  • Targeted harness (12 batch files): BACKEND_UNIT_TEST_FILE_LIST=<list> BACKEND_PYTEST_WORKERS=4 omi-heavy run -- nice -n 19 bash backend/test.sh gave 538 passed, exit 0 (pre-trim). After the trim and the merge of main, tests/unit/test_batch*.py + test_silent_batch_redrive.py + test_backend_runtime_env_validator.py + test_cross_service_deploy_contract.py passed 2412 with 5 skipped, and a post-merge focused rerun passed 551 with 3 skipped. The list covers language recovery, speech redrive, redrive retention, quarantine recovery, held VAD census, empty disposition, terminal empty, redrive scope, silent redrive, projection, worker and operator policy source.
  • All tests/unit/test_batch*.py plus test_silent_batch_redrive.py through pytest: 2251 passed, 2 skipped.
  • Regression proof: with only the source changes reverted, every new or changed success-path test fails (failed_held instead of recovered). The fail-closed tests pass both before and after.
  • black --check is clean on all touched files.
  • No production read, deploy or config change was made. This ships as a normal backend image change with no new flag. Re-entry to 5% needs this merged and deployed (lead 390314).

Tests

In backend/tests/unit/test_batch_language_recovery.py (deterministic, synthetic, no provider calls):

  • test_worker_vad_locates_modulate_words_when_cpu_vad_is_empty[0.032|1.5|4.384]. This is the prod case: worker VAD positive, CPU VAD empty, Modulate words, result recovered. It asserts the typed result contract:

    • result_outcome == 'success';
    • projection_speech_spans(payload) places the acoustic measure at the word clock, and speech_seconds equals the receipt;
    • split_result yields one part with the words;
    • the job settles result_ready/recovered with a valid WorkResult(outcome='success').

    It also checks that the Modulate receipt is recorded and that Soniox is not called.

  • test_minimal_worker_frame_never_licenses_long_asr_accounting: bramp3's counterexample. A single 512-sample worker frame, empty CPU VAD and one word over the whole capture give spans [0, 0.032]. Settlement, usage total, usage parts and the census are all 0.032s, and the word keeps its [0, 5] clock.

  • test_worker_vad_fallback_conserves_main_accounting, parametrized over receipts {0.032, 1.5, 4.384}s and word clocks {[1,2], [0,5], [4.9,5]}. Conservation: it runs main's behavior on the same audio and receipt (worker placement disabled, words rejected, failed_held) and records main's settled census. It then runs the fix and asserts that the census, result_vad_evidence, speech_seconds and the sum of split_result part speech all equal main's acoustic value.

  • test_worker_vad_locates_independent_words_after_modulate_empty[sync|async]: the Soniox words path with the same contract assertions.

  • test_words_without_independent_worker_speech_still_fail_closed, parametrized over absent, zero, subframe, foreign_audio, unmeasured and other_duration receipts. Both recognizers return words, and the result is still failed_held with payload_validation/invalid_payload and nothing persisted.

  • test_independent_redrive_uses_worker_vad_for_words: the existing epoch-3 Soniox redrive recovers the same scenario (worker VAD positive, CPU VAD empty, Soniox words) with the same contract assertions.

  • Changed: test_cpu_zero_never_erases_positive_worker_census[worker_vad_words] (formerly words_without_vad). It asserted the old behavior: Soniox words under a 2s worker receipt gave failed_held. It now asserts recovered, and the 2s census is still retained.

The 16 settled units (bramp3 531ed4, lead 7fa3d2)

The failed attempts' recognizer words were not persisted anywhere:

  • words_payload raised WordsWithoutVad before any payload existed.
  • recognizer_attempt discarded the Soniox words.
  • persist_recovery_result runs only on success.
  • record_recognizer stores only {provider, outcome, word_count, vad_speech_seconds}.
  • Soniox transcripts are DELETEd at the vendor after polling, and Modulate prerecorded keeps nothing.

No no-call re-settle is therefore possible. The explicit repair path is in the follow-up PR.

UI evidence

UI-Evidence: none -- backend batch recovery only.

Failure class (fixes)

Failure-Class: FC-empty-asr-without-evidenced-disposition

🤖 Generated with Claude Code

…D missed

Language-guarded quarantine recovery re-inspects audio with strict CPU VAD.
On short low-energy non-English captures it finds no spans even though the
GPU worker's bound VAD receipt measured speech, so recognizer words were
rejected as WordsWithoutVad (payload_validation/invalid_payload) and the
unit settled failed_held with no transcript.

When CPU VAD is empty and the job carries a measured worker_vad_receipt
bound to the same audio (>= one full VAD frame), words_payload locates
speech spans from the validated word clocks. Without that independent
evidence WordsWithoutVad still fails closed. Applies to automatic recovery
(Modulate and the capped Soniox call, sync and async) and the operator
speech redrive. Spent Modulate words rejected this way route to an explicit
operator Modulate epoch, accepted by artifact retention, since their Soniox
attempt is already spent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@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-27T03:23:33.427461Z 531d8a5 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: ab7dd5c287

ℹ️ 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".

Those words are the evidence an operator Modulate epoch buys again (not an
independent Soniox one); a Soniox intent already prepared keeps its route.
"""
from utils.batch_pipeline.contracts import worker_vad_speech

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 Keep the new receipt dependency out of function-local imports

backend/AGENTS.md explicitly requires imports at module scope, but this introduces a function-local import. Simply hoisting it would create a circular dependency because utils.batch_pipeline.contracts already imports this config module. Move the shared receipt-validation logic into an acyclic lower-level module and use module-level imports so the new routing predicate follows the repository's import contract.

AGENTS.md reference: backend/AGENTS.md:L167-L173

Useful? React with 👍 / 👎.

Comment on lines +151 to +155
if not spans and worker_speech:
# Strict CPU VAD can miss short low-energy speech that the GPU worker's
# bound VAD receipt measured. Words alone never prove speech: only with
# that independent measurement may their clocks locate the spans.
spans = worker_vad_word_spans(words, duration)

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 Update the pipeline contract for the new worker-VAD exception

backend/AGENTS.md requires transcription changes to update backend/docs/listen_pusher_pipeline.mdx in the same PR, but that document is unchanged. Its “Independent language-guarded batch recovery” section still says words contradicting zero VAD retain custody and language-guarded Modulate recovery results may register only under an epoch-3 Soniox intent. This change intentionally permits recovery from worker-bound word clocks and adds an epoch-2 Modulate route, so document both exceptions and their evidence/spend fences alongside the implementation.

AGENTS.md reference: backend/AGENTS.md:L163-L163

Useful? React with 👍 / 👎.

audio,
multilingual=multilingual,
force_recognition=language_guarded(job),
worker_speech=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.

P2 Badge Pass the same worker evidence through shadow recovery

When shadow recovery is enabled, language-guarded captures with positive bound worker VAD, zero CPU VAD spans, and recognized words now produce different outcomes in shadow and serving. shadow_recovery.guarded_recovery still calls stt without worker_speech and constructs MultilingualEmpty(duration, spans) without that evidence for Soniox, so both shadow recognizers continue rejecting these words with WordsWithoutVad. Consequently, shadow can buy an unnecessary Soniox call and report failed_held plus positive speech_loss_seconds for captures that serving now recovers. Thread the validated worker evidence through both shadow recognizer calls as well.

Useful? React with 👍 / 👎.

Git-on-my-level and others added 4 commits October 27, 2026 09:52
…tegration

Independent-language recovery was activated at runtime on prod
backend-integration at 2026-10-27 02:07Z (lead 5da7dc/ebc45a) after the 5%
unsupported-language held loop. The prod overlay still declared it false, so
the train shipping the WordsWithoutVad fix would have reset it and recreated
the held loop. Declare it true on backend-integration only; dev and the GPU
worker stay off. Regenerate runtime_env.yaml and the flag registry, and
update the deploy-contract tests for the prod-on/dev-off split.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Lead ruling 7fa3d2: the WordsWithoutVad validation fix and the declared prod
flag ship alone; the operator repair of already-settled units moves to an
explicit, separately reviewed path. Restore the shared speech-redrive routing,
retention and operator census to main. Worker VAD evidence still reaches the
independent (Soniox) redrive through the same fixed words_payload.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-worker-evidence

# Conflicts:
#	backend/docs/feature-flag-registry.md
bramp3 39fb29 / lead ruling ef03d2: with empty CPU VAD and a bound worker
receipt as small as one 512-sample frame, the fallback took speech_seconds
from the union of ASR word clocks, so settlement, projection usage and the
T2 denominator silently moved from acoustic VAD to an ASR estimate.

worker_vad_word_spans now positions exactly the worker receipt's acoustic
measure (capped at the captured audio) at the word clocks, growing into
adjacent silence only when the measure exceeds them. speech_seconds and
every accounting input therefore equal the acoustic measure. Adds bramp3's
minimal-frame/long-word counterexample and a conservation test against the
main behavior for the same audio and receipt.

Failure-Class: FC-empty-asr-without-evidenced-disposition

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@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: f5fd857322

ℹ️ 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 +616 to +619
from dataclasses import fields

from utils.batch_pipeline.contracts import WorkItem, WorkResult, projection_speech_spans
from utils.batch_pipeline.projection_parts import split_result

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 Move the new test imports to module scope

backend/AGENTS.md requires “All imports at module top level — never inside functions,” but the new assertion helper imports dependencies locally, as do several newly added tests. Move these new imports to the module-level import block so the added coverage follows the backend import contract.

AGENTS.md reference: backend/AGENTS.md:L167-L167

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit af73bf7 into main Oct 27, 2026
64 checks passed
@Git-on-my-level
Git-on-my-level deleted the op1/words-without-vad-worker-evidence branch October 27, 2026 03:42
Git-on-my-level added a commit that referenced this pull request Oct 27, 2026
…s units (#23775)

## What changed and why

Lead ruling 7fa3d2 covers the 16 language-guarded units that settled
`failed_held` with `payload_validation/invalid_payload` while
recognizers had returned words. Root cause and fix are in #23770, and
the RCA is at `/Volumes/Ephemeral/scratch/op1/langguard-rca-0210.md`.
**Stacked on #23770** (base `op1/words-without-vad-worker-evidence`):
this PR uses #23770's worker-VAD placement and acoustic accounting in
`words_payload`. Merge #23770 first.

This PR adds an **explicit, operator-invoked repair path**:
- **Mode:** `--language-guard-repair`, `--paid-epoch 4`, exact unit IDs,
dry run first.
- **What it does:** it buys **one** Modulate call per eligible unit
under the unit's bound worker VAD receipt. The fixed validation then
places the words and keeps accounting acoustic.

## Rulings

**Lead a3af50 (binding, supersedes 7fa3d2 items 1-2):** "APPROVED one
bounded Modulate call each for the 16 (cap 1/unit, audited, same #23775
fences, cost trivial). If Modulate fails, ledger as failed_held with
audio retained; no further calls without me. Order: merge+deploy #23775,
dry run, then 14+16. The 4 stay held until a worker-acoustic terminal
contract exists."

The failed attempts' recognizer words were **never persisted**, so no
zero-call re-settle exists:
- `words_payload` raised `WordsWithoutVad` before any payload existed.
- `recognizer_attempt` discarded the Soniox words.
- `persist_recovery_result` runs only on success.
- `record_recognizer` stores only `{provider, outcome, word_count,
vad_speech_seconds}`.
- Soniox transcripts are DELETEd at the vendor, and Modulate prerecorded
keeps nothing.

**Eligibility (`words_repair_eligible`).** All of the following must
hold:
- language-guarded;
- spent recovery on `modulate`;
- failure `payload_validation/invalid_payload`;
- a Modulate receipt of `words` with `word_count > 0`;
- a Soniox receipt of either `empty` with `word_count == 0`, or `words`
with `word_count > 0`;
- `audio_uri` present;
- duration in (0, 60]s;
- a bound worker VAD receipt of at least one full frame.

**Refused, with no spend:**
- both-empty (`empty_asr`);
- Soniox `error`, `refused` or missing;
- an unbound, sub-frame or missing worker receipt;
- `--independent-language`;
- any unit already carrying a speech-redrive marker, including an
epoch-4 repair intent.

**Fences:**
- **Separate route.** The `speech_redrive` marker carries `paid_epoch:
4` and `provider: modulate`, and `expected_route()` keeps it distinct.
`independent_attempted` is never consulted or bypassed, and the shared
epoch-2/3 plans are unchanged (tested).
- **Cap 1 per unit.** Once a marker exists, `prepare` refuses any other
plan, and a replay never calls again.
- **60s cap on decoded audio.** The repair refuses
(`repair_budget_held`) before start, and `sync_allowed` is admitted on
the decoded duration. The company allowance is always rechecked, there
is no BYOK shortcut, and a provider-environment check runs before spend.
- **Audit receipt.** The marker keeps `prior_recovery` verbatim (the
spent intent and both receipts), `plan_digest`, `token`,
`privacy_generation` and a claimed `recognizers.modulate` receipt
(`started` -> `words|empty|error`, `word_count`).
- **Failure.** If Modulate fails, the marker settles `failed_held` with
a closed failure. The job stays `quarantined/failed_held` with its audio
retained and no result, and it never buys another call.
- **Accounting.** Accounting is acoustic (#23770, lead ef03d2).
- **Retention.** Retention accepts only a running epoch-4 Modulate
result for an eligible unit.

**The 4 both-empty units stay held** until a worker-acoustic terminal
contract exists (a3af50). Nothing here closes them.

## Dry run (op1, after #23770 and #23775 are merged and deployed;
ro-prod, read-only, per owner)

Prod reconciliation (op1) found 16 Soniox-words and 14 Soniox-empty
units. All are `invalid_payload/WordsWithoutVad` with Modulate words and
worker VAD speech. Another 4 are both-empty `empty_asr`, and 2 are
unrelated.

```
GCP_AGENT_TIER=ro-prod backend/scripts/batch_pipeline_speech_redrive.py \
  --stage prod --owner-env <OWNER_ENV> \
  --quarantined-after <T0Z> --quarantined-before <T1Z> \
  --unit-ids-file <that owner's IDs from the 30> --cohort-file <new path> \
  --expect-count N --expect-speech-count N \
  --paid-epoch 4 --language-guard-repair [--server-flags-file <serving env json>]
```

- **Expected across all owners: 30 eligible (16 + 14)**, with no spend.
Per-owner output:
- `mode: dry_run`, `operation: language-guard-words-repair-v1`,
`provider: modulate`;
  - `units: N`, `strict_vad: {worker_vad_speech: N}`;
  - `speech_epoch1_failures: {payload_validation/invalid_payload: N}`;
- `maximum_additional_paid_calls: N`, `max_audio_seconds_per_unit: 60`;
  - `paid_stt_calls: 0`, `firestore_writes: 0`.
- **Refused: the 4 both-empty and the 2 unrelated.** Passing any of
their IDs gives `{"outcome":"refused","reason":"unit_not_eligible"}`, so
keep them out of the ID files.
- **Other possible refusals:**
  - `not_failed_held`: `terminal()` fences;
  - `completed_ledger`: the content ledger no longer owes held units;
  - `policy_unpinned`: no pinned policy and no `--server-flags-file`;
  - `cohort_changed`.
- **Apply** (`prod-operator`), with the same flags plus `--apply
--source-census-sha256 <census> --approve-plan-sha256 <plan_sha256>`.
Run `--apply-limit 1` first as a canary, then the full count. The CLI
pins one owner per run.

## Luna review (one round)

The review returned CHANGES REQUIRED with two P2s, both fixed in
`fix(batch): bound the words repair on decoded audio...`:
1. The 60s cap read the declared duration, while decoded audio may run
0.1s longer. The repair now refuses (`repair_budget_held`, before start
and spend) when decoded audio is over 60s, and it admits `sync_allowed`
on the decoded duration.
2. `words_repair_eligible` could raise `KeyError` inside the retention
transaction for a job missing `audio_uri`. It now fails closed on
malformed jobs.

Both have a test:
`test_words_repair_bounds_decoded_audio_and_fails_closed_on_malformed_jobs`.
Luna confirmed the other fences were intact: one call per unit, no
epoch-2/3 change and receipts preserved. The a3af50 widening
(Soniox-words eligible) came after Luna's single round. bramp3 reviews
that delta.

## Product invariants affected

- INV-MEM-4: path-based citation inherited from the stacked #23770 diff
against main (`backend/deploy/runtime_env.yaml`). This PR itself changes
no memory promotion behavior.

## How it was verified

- `tests/unit/test_batch*.py` + `test_silent_batch_redrive.py` +
`test_cross_service_deploy_contract.py` +
`test_backend_runtime_env_validator.py` through pytest: **2481 passed, 5
skipped**. After the a3af50 widening, `test_batch*.py` +
`test_silent_batch_redrive.py` passed 2322 with 2 skipped. After the
Luna fixes, `test_batch*.py` + `test_silent_batch_redrive.py` passed
2316 with 2 skipped.
- `black --check` is clean.
- No production read, deploy, config change or paid call was made.

## Tests

In `backend/tests/unit/test_batch_language_recovery.py` (synthetic,
deterministic). `settled_words_without_vad` reproduces the exact prod
settlement through the real recovery code (pre-fix worker VAD ignored),
for both Soniox empty and Soniox words.
-
`test_words_repair_buys_one_modulate_call_for_soniox_empty_or_words_units`,
parametrized over Soniox empty/words and multilingual on/off:
  - repair gives `recovered`, and a replay gives `already_applied`;
  - the marker is epoch 4/modulate/completed with its Modulate receipt;
  - the spent `recovery` is unchanged;
  - the typed contract holds and accounting is acoustic;
- exactly one extra Modulate call is made, and Soniox is never called
again.
-
`test_words_repair_refuses_every_other_unit_without_spend[no_receipt|subframe_receipt|independent_plan|both_empty|soniox_error|epoch4_marker]`:
each gives `repair_not_eligible` (or `ProjectionBlocked` for an existing
epoch-4 intent), with no new marker and no call.
- `test_words_repair_is_capped_at_one_call_per_unit`: a Modulate empty
answer gives `failed_held`, receipted `empty/0`, with closed failure
`response_validation/empty_asr`. The job stays `quarantined/failed_held`
with audio retained and no deletes. A replay makes no call, and a new
plan raises `ProjectionBlocked`.
-
`test_words_repair_bounds_decoded_audio_and_fails_closed_on_malformed_jobs`
(Luna P2s).
- `test_words_repair_leaves_shared_redrive_plans_unchanged`: epoch 2
still gives `independent_plan_required`, and epoch 3 still gives
`already attempted`.
- `test_operator_repair_census_selects_the_modulate_words_cohort`:
covers CLI eligibility (Soniox empty and words eligible, both-empty and
marked units refused) and a distinct plan digest.

In `backend/tests/unit/test_batch_pipeline_speech_redrive_retention.py`:
- `test_running_words_repair_registers_only_its_eligible_result`: the
real retention transaction accepts Soniox-empty and Soniox-words units
(multilingual on and off) and rejects both-empty.

In `backend/tests/unit/test_batch_redrive_scope.py`:
- The `checked_job` stub signature now accepts `repair`.

## UI evidence

UI-Evidence: none -- backend operator recovery path only.

## Failure class (fixes)

Failure-Class: FC-empty-asr-without-evidenced-disposition

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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