Repository navigation
fix: prevent tiny-sample live STT recovery re-benches - #23771
Conversation
…-bench Add an audited per-target operator reset with generation fencing and a reversible bench action. Preserve full-traffic detection and promotion. Failure-Class: new
Add the lead-approved 20-sample high-failure fast path, accelerate consecutive recovery cooldowns to a six-hour ceiling, and clear strikes after a clean full recovery. Retain every daily calibration assertion. Failure-Class: new
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: a53bac87ee
ℹ️ 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".
| fast_failure = n >= RECOVERY_FAST_MINIMUM and failures / n >= RECOVERY_FAST_FAILURE_SHARE and broad_failure | ||
| decisive = (decisive and n >= RECOVERY_REBENCH_MINIMUM and user_rate > gate) or fast_failure |
There was a problem hiding this comment.
Update the required listen/pusher pipeline documentation
This changes live transcription recovery behavior, including rejection thresholds, cooldown escalation and strike resets, but the commit does not update backend/docs/listen_pusher_pipeline.mdx. backend/AGENTS.md explicitly requires updating that document in the same PR for transcription or listen/pusher changes. Add a concise description of the new recovery policy and kill switch, linking to the detailed routing runbook, so the required pipeline documentation reflects the serving behavior.
AGENTS.md reference: backend/AGENTS.md:L163-L163
Useful? React with 👍 / 👎.
Capture reset generations before every dial and retain them through all settlements, while allowing ordinary connect gate changes within an epoch. Persist only a content-free generation floor; keep normal evidence TTLs. Cover real settlements, both handshake paths, and expired evidence keys. Failure-Class: new
|
Luna delta review: SHIP at The first review's reset-fencing finding is addressed: every dial retains its pre-handshake reset epoch; connect failures still follow ordinary gate changes within the same epoch; a separate content-free reset generation floor survives healthy-key expiry, while fairness data retains its 900-second TTL. New behavioral regressions exercise actual settlements, generation zero/missing evidence, all targets, evidence-key expiry, fresh failures still benching, and reset during raw handshakes in both dial modes. Corrected code passed 907 targeted tests across 13 files, the 20-test hermetic listen E2E rerun, 37 local preflight checks and push gates. Corrected-head CI is still running; merge remains gated on terminal CI. No production actions performed. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f5f2f148dc
ℹ️ 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".
| import fakeredis.aioredis | ||
| from utils.stt.live_cost_reset import reset_cost_target |
There was a problem hiding this comment.
Move the reset-test imports to module scope
The newly added test imports fakeredis.aioredis and reset_cost_target inside its body, violating the explicit requirement in backend/AGENTS.md that all imports be at module top level, never inside functions. Move both imports into the module's import section.
AGENTS.md reference: backend/AGENTS.md:L165-L167
Useful? React with 👍 / 👎.
| def pin_dial_generations(socket, generations) -> None: | ||
| outcome = getattr(socket, 'leg_outcome', None) | ||
| if isinstance(outcome, LiveLegOutcome): | ||
| outcome.generations = generations |
There was a problem hiding this comment.
Fence same-provider reconnects before their handshakes
If an operator reset and cache refresh occur during a Soniox same-provider reconnect handshake, that reconnect bypasses this pre-dial generation pinning: LiveChainSession.connect(same_provider=True) directly awaits primary() in live_session.py:453–478, and LiveLegSocket.__init__ captures generations only after the raw handshake returns. If the successor fails its liveness check, reconnect_live_stt_socket settles it against the new reset generation, admitting an outstanding pre-reset dial that this change intends to fence. Multiple such reconnects can repopulate the cleared failure evidence and re-bench the target. Capture and retain the pre-dial generations at the shared socket-building boundary, including the same-provider path.
Useful? React with 👍 / 👎.
…pecheck (#23796) ## What Backend unit CI shard walls keep grazing the 720s regression budget: #23767 754/740s, #23771 762s, #23789 724s, with main at ~681s (~5% headroom). This rebalances the shards to a simulated worst shard of **607s** (target 640s, 11% headroom) without touching `.github/` workflows, the 720s budget, or the shard count. Three causes, each fixed at its layer: 1. **The weights table priced pytest time, not wall time.** Per-file wall (import/collection startup included) is what the scheduler consumes. The old table (3-run mean pytest seconds) missed the suite's heaviest file entirely — `test_runtime_image_contracts.py` at ~183s wall was unlisted and dealt at the 1.1s default — and underpriced `test_cross_service_deploy_contract.py` at 36.7s vs a measured 130s. Rebuilt as **p90 wall seconds over the last 20 main-branch runs** (1982 entries, ≥2s floor), attribution-free from each file's `::group::` marker to its last path-bearing line +0.7s tail; `DEFAULT_WEIGHT` 1.1 → measured 1.66. 2. **Slices launched alphabetically**, so heavy files started ~75% into their shard and serialized the tail (the 183s file capped a lane for the final quarter on #23789 shard 3). Each shard's slice now keeps deal order, so `test.sh`'s four worker slots run a longest-processing-time schedule. 3. **All six shards ran the identical full-tree pyright** (~99s each: ~8m of runner time per main commit, ~99s of every shard's budget). It is deterministic over the same checkout every shard sees, so only shard 1 runs it now; its failure still fails the workflow for the commit, and the deal reserves shard 1's extra capacity (`load[0] += 360`) so shards finish level. Plus the split the brief asked for: the 183s closure walk (`test_registered_runtime_image_sources_are_closed`, 18 registered image contracts staged + AST-walked in one process) becomes the same test in two files split by parity of the sorted contract name — every contract still checked exactly once, new contracts land in exactly one half by construction. Halves measured 33.6s / 33.8s locally. Moved node IDs inherit their fast-unit duration-guard allowlist entry. ## Evidence - Harvest + parser + simulation scripts and per-run JSON: `/Volumes/Ephemeral/scratch/shardbudget/` (20 main runs × 6 shard logs; per-file p90s are tight across runs, e.g. runtime_image 179.7–185.7s over 20 samples). - Variant simulation over all 20 runs (same deal code as shipped): current setup reproduces at 737s worst; new table + LPT → 701s; + split → 679s; + shard-1 typecheck → **607s worst**, per-shard makespans level at 594-595s (shard 1: 504s + 95s typecheck). - Shipped-deal check: union of the 6 slices == full selection (2341 files), partition exact. - Local layer: `backend/test.sh` over the seven changed/pinning test files — all green (runner pins 94, workflow contracts 14, allowlist pin 2, runtime_image trio 63+1+1). ## Notes for review - The typecheck dedup is a contract change to a documented invariant ("phases identical across shards"). The guard still gates every commit exactly once on the same tree; preflight (seconds) still runs on every shard. If this is rejected, the projected worst shard is 679s — over the 640s target and within 6% of the budget, and the residual fix (a 7th shard or a budget raise) lives in `.github/`, which this lane does not touch. - `test_cross_service_deploy_contract.py` (130s wall, now correctly weighted) is the next split candidate if walls creep again; not split here to keep the diff reviewable. - Failure-Class: none - UI-Evidence: none -- no UI changes ## Review - Round 1 (Luna, full): **SHIP** with one minor finding — the 360s shard-1 reservation also applied to changed-files runs where `needs-typecheck.sh` skips the check, handing shard 1's capacity to siblings for nothing (~570s vs ~556s projected max on such runs). Fixed in e0fc220: the boundary decision is computed once before the deal, and both the reservation and the typecheck step key off it (verified: with the check reserved → shard 1 empty in a tiny fixture; without → 7/6 even split; runner pin tests 94 + workflow contracts 14 green locally). - Empirical CI on this PR (full 2338-file suite through the new deal): shards green at 422 / 607 / 470 / 533 / 581 / 393s — worst 607s, matching the simulation, was 718–762s near-misses.
…pecheck Four near-misses against the 720s shard budget tonight (BasedHardware#23767 754/740s, BasedHardware#23771 762s, BasedHardware#23789 724s) with main at ~681s left ~5% headroom. Three causes, each fixed at its layer, measured from the six shard logs of the last 20 main-branch runs (40333043889..40458587600, per-file wall time from each file's ::group:: marker to its last path-bearing line + 0.7s tail): - Weights priced pytest time, not wall time. Per-file import/collection startup is what the scheduler actually consumes; the old table missed a 183s file entirely (unlisted) and underpriced a 130s file at 36.7s and the sub-2s default at 1.1s vs a measured 1.66s wall mean. Rebuilt as p90 wall seconds (1982 entries); DEFAULT_WEIGHT 1.66. - Slices launched alphabetically, so heavy files started late and serialized their shard's tail. Each shard's slice now keeps deal order, turning test.sh's four worker slots into a longest-processing-time schedule. - All six shards ran the identical full-tree pyright (~99s each; ~8m of runner time per main commit, ~99s of every shard's 720s budget). It is deterministic over the same checkout every shard sees, so only shard 1 runs it; its failure still fails the workflow for the commit, and the deal reserves shard 1's capacity (load[0] += 360) so all shards finish level. Simulated over all 20 runs with the shipped deal and scheduler: worst shard 607s (budget 720, target 640, was 718-762 observed; per-shard makespans 594-595s except shard 1's 504s). Runner pin tests updated to the new contract: shard-1-only typecheck, offset-aware deal, deal-ordered slices.
## What changed and why SCA-3688 retires the three inactive controls with terminal kill decisions. - DEC-BTR-001 removes live Parakeet window diarization configuration. The offline shape qualification harness explicitly opts into the existing speaker embedding path. - DEC-STT-006 removes the Soniox elapsed-axis experiment. The compact send map remains authoritative for placement, including when the wire ledger is disabled. Managed Soniox capture-axis diagnostics, the Modulate control measurement, and prerecorded Soniox are preserved. - DEC-STT-005 removes the dedicated Soniox reconnect ring and flag-only death typing. The strike-accounting fixes in #22734 and #23771 are on main. Shared window replay, cross-provider recovery, and the separate idle reopen path are preserved. Read-only production sampling confirmed inactive control values across listener, pusher and Cloud Run surfaces. Compact placement remains the incumbent path for both wire-ledger settings. Regenerated the runtime manifest and flag catalog from their sources. #25913 covers separate Soniox controls. ## Product invariants affected - INV-MEM-4 is selected for the listen receiver path. This change preserves conversation ownership and operates on inactive STT provider paths. ## How it was verified - Feature-flag registry check at 2026-11-22, 109 registry fixtures, and generated runtime manifest check passed. - Repository preflight passed 55 checks. The bounded pre-push gate passed backend type checking, its 40 selected unit files, and the OpenAPI compatibility check. GitHub CI covers the full selector. - The candidate passed 152 selected backend unit files, including the flag budget and reason-label ratchets, managed and legacy replay, live demand switching, real Soniox WebSocket closure, wire-ledger on/off placement, and offline speaker qualification under both legacy toggle values. ## Release ordering Land #26007 (SCA-3683) first. The source registry merges cleanly. Regenerate the catalog from the combined source after rebasing this PR. Release owns merge and rollout. ## UI evidence UI-Evidence: none -- backend STT and flag cleanup ## Failure class (fixes) Failure-Class: none Line-Count-Exception: backend/utils/stt/parakeet_window.py | 1545 -> 1547 | Explicit offline qualification argument keeps the live default disabled and preserves existing qualification coverage.
Recovery at 5%/25% could re-bench from a 30/60-outcome failure-share rule without the full-traffic CUSUM burst evidence. Ordinary rejection now needs 100 admitted, non-censored outcomes plus normal burst/breadth evidence. A fast path for a truly broken provider requires at least 20 outcomes, at least 25% attributable failures, and the same broad witness protection. Apply to every registry target.
no_text,first_text_deadline, andsend_queue_fullalready classify as censored; regression tests pin their exclusion.To retain the existing daily chronic-provider disruption budget with the larger sample, recovery re-benches add two cooldown exponents and cap at six hours; a full clean ramp to 100 clears strikes. A single full-traffic bench keeps its first five-minute recovery wait. Full-stage detection, promotion votes/dwell, vote caps and the automatic stage ladder remain intact. These rules follow lead rulings b5cc0a/92a89c/feea51. The first100-sample-only candidate failed the old chronic-outage budget; the final implementation preserves every daily budget assertion unchanged.
The guard ships on by default.
STT_ROUTING_RECOVERY_SAMPLE_GUARD_ENABLED=falserestores the previous rejection rules; no runtime config change is required for the fix.An explicit operator command now offers a dry run and an atomic per-target reset of every global/language gate, with a 30-day content-free Redis audit and warning-log receipt. A persistent content-free reset generation floor survives the normal healthy evidence key's900-second expiry. All dials capture the reset epoch before awaiting the handshake, including raw failed dials and both legacy/recovery paths. Connect failures still follow ordinary gate changes within an epoch, but old or missing epoch evidence cannot cross a reset. Serving refresh/cold writers restore the floor when evidence expires. Fairness/user data keeps its normal TTL. It never pins stage100 or bypasses account/capacity protection.
--stage 0 --applyreverses the release with a five-minute bench followed by normal recovery. The runbook documents commands, permissions, uncertain submission results and post-roll verification.Incident evidence supplied by op2/lead (aggregate only): Parakeet benched at 2026-10-26 15:27:01Z, global n=10,200/f=39 (0.38%), en n=16,485/f=264 (1.60%), score 11.122 after a timeout burst. Traffic first shifted to Modulate. Modulate's exact bench was 18:13:27Z, global n=4,176/f=310 (7.42%), score 12.196; en n=3,326/f=232 (6.98%), score 12.209. 18:18Z was Modulate's 5% re-entry, correcting the coarse chart timing. Lead ruling f52f21 treats Modulate's failure signal as real: recommend an immediate reset for Parakeet only, after the approved listen+pusher rollout completes. No production reads, resets or deploys performed by this lane. The root cause of the original Parakeet timeout burst remains unproven.
Validation:
backend/,BACKEND_PYTEST_WORKERS=4 BACKEND_UNIT_TEST_FILE_LIST=/Volumes/Ephemeral/scratch/sttbench/final-unit-files.txt bash test.sh: 531 tests passed across seven targeted suites (138 router, 21 reset, plus gate calibration/hardening/shadow/restart/settlement). Includes tiny trials, two-tier rejection, false-trip recovery to100, cooldown escalation/reset, censoring, all three target resets, stale votes/local benches, rollback, WATCH contention and unchanged chronic-outage budget assertions.data/run-2026-10-13-two-lane-nemotron/sttbench-final-calibration-2026-10-27.jsonl; replay driver/Volumes/Ephemeral/scratch/sttbench/verify_final_calibration.pycalls the existingtrial_daywith no monkeypatch. This is synthetic calibration, not production acceptance.bash backend/testing/e2e/run.sh -q -k 'listen_stt or listen_pusher_wire_contract' --tb=short: 20 passed; hermetic listen paths, no live service claims. Existing shutdown logger emitted a closed-stream warning after pytest succeeded.omi-heavyundernice -n 19. Replays use supplied aggregate history plus a synthetic 13-timeout burst; raw event chronology was unavailable, so this is mechanism evidence, not an exact production timeline replay.Single Luna review on a53bac8 found P1 reset fencing gaps (connect failure erased its generation; idle expiry could restore generation0). The correction adds14 behavioral regressions covering actual settlements, pre-reset generation0, all targets, real key expiry, new failures still benching, and a reset during raw handshake in both dialing modes. The corrected producer/health code passes 907 targeted tests across13 files plus the20-test listen E2E rerun. The existing post-commit metric fixture now injects its fault after the actual Redis commit rather than an internal identity-read count; its assertions remain intact. Earlier a53 CI's shard1 exceeded its wall budget (762s vs720s) after test completion; corrected-head CI remains required before merge.
Failure-Class: new