Repository navigation
test(batch): align harness with #22321 recovery contract - #22385
Conversation
#22321 made quarantined units with held/prepared/running recovery poll as processing with a nonzero hint (terminal quarantine still reports failed), and bounded recovery dispatch to 16 candidates per sweep. Three harnesses still pinned the pre-#22321 behavior and fail on main: - Sync Cloud Tasks gauntlet batch-empty-asr-recovery asserted 'failed' while recovery was pending. It now asserts processing + nonzero poll_after_ms at held, prepared and (serving-kill scenario) running, then completed. A new batch-empty-asr-recovery-failure scenario pins the terminal leg: a failing paid call settles failed_held, polls failed with poll_after_ms 0, and a duplicate delivery never re-pays. - Characterization goldens regenerated via PIPELINE_GOLDEN_UPDATE=1; every diff is the dispatch batch size (with BATCH_PIPELINE_RECOVERY_DISPATCH_BATCH_SIZE=1 the regenerated traces equal the old goldens byte for byte). - provider_exhaustion_window now asserts the fixed p95 (< 300 s, was ~1500 s) and that the one terminal paid failure fails the gate as unrecovered_quarantine. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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: b3c4079dd2
ℹ️ 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".
| assert sample['verdict'] == 'GATE_FAIL quarantine_projection_p95_over_5m' | ||
| # Bounded recovery dispatch (#22321) drains the quarantine cohort inside the gate's 300 s p95. | ||
| # The single-candidate sweep it replaced measured ~1500 s here. | ||
| assert sample['quarantine_projection_p95_seconds'] < 300 |
There was a problem hiding this comment.
Pin the recovery dispatch size for this simulation
When BATCH_PIPELINE_RECOVERY_DISPATCH_BATCH_SIZE is present in the caller's environment (for example, set to 1 to compare the former behavior), SimRuntime._patched() neither overrides nor restores it because the key is absent from sim.DEFAULT_FLAGS and this scenario's flags. The production config therefore consumes the ambient value, and the commit message confirms that size 1 produces a roughly 1500-second p95, so this new assertion and the regenerated characterization goldens fail despite the simulation claiming explicit, deterministic inputs. Add the intended value (16) to DEFAULT_FLAGS or the scenario's flag overrides.
Useful? React with 👍 / 👎.
| assert sample['quarantine_projection_cohort_count'] >= 20 # above the gate's low-sample floor | ||
| assert sample['quarantine_projection_p95_seconds'] > 300 | ||
| assert sample['verdict'] == 'GATE_FAIL quarantine_projection_p95_over_5m' | ||
| # Bounded recovery dispatch (#22321) drains the quarantine cohort inside the gate's 300 s p95. |
There was a problem hiding this comment.
Match the simulator query limit to production
This test attributes the improved latency to #22321's default 16-candidate dispatch, but the patched SimRuntime._recovery_candidates() still clamps limit to 10, whereas the real database.batch_pipeline_quarantine_recovery.recovery_candidates() now permits up to 64. Consequently the new assertion and regenerated goldens model only 10 dispatches per serving pass and can bless timing and completion ordering that differ from production's 16-wide default; update the fake's cap and regenerate the expectations.
AGENTS.md reference: backend/AGENTS.md:L225-L225
Useful? React with 👍 / 👎.
…22385) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…2320) * fix(merge): complete merges of conversations that overlap in time Merging conversations that overlap in time sorts the merged transcript by start, so the sources' lines interleave. The correction transfer that runs after the merge expected each source's lines as one block in merge order, so its captured-speech check failed for every such merge, with or without transcript corrections. The merge rolled back, the sources came back unmerged, and no failure message reached the user. The merge now returns where each source line landed, and the transfer checks the captured speech and moves correction anchors through that map. Merges whose sources do not overlap keep the same layout as before. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci: run with ci:full Co-Authored-By: Claude Opus 5.5 <[email protected]> * test(merge): cover corrections on both overlapping sources and equal-start ordering Review follow-up. Both tests drive the real perform_merge_async and the real correction transfer with the same fakes as the existing overlap test. - Corrections on both overlapping sources land on their own merged lines, both sources are sealed, and undoing one source's correction through its moved receipt restores only that line. - Lines from different sources with the same merged start keep source order (the stable sort), and a correction on the later source's tied line stays on that line. Co-Authored-By: Claude Opus 5.5 <[email protected]> * ci: re-run now that main's pipeline goldens are fixed (#22385) Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Since #22321 (merge
4e897552) landed, main fails in three test harnesses. Each one still pinned the pre-#22321 behavior. #22321's contract is intended: a quarantined unit whose recovery isheld,preparedorrunningpollsprocessingwith a nonzeropoll_after_ms, and terminal quarantine (failed_held) still reportsfailed. It also adds bounded recovery dispatch (BATCH_PIPELINE_RECOVERY_DISPATCH_BATCH_SIZE, default 16). This PR changes only the tests, goldens and docs. It does not change product code.Fixing these unblocks #22376 (2 worker replicas), which is red only because of these failures. The same failures also show up on #22373.
1. Sync Cloud Tasks Stack Gauntlet:
batch-empty-asr-recovery(runs 39198374815, 39198865655)The failure was
StackFailure: quarantined job reported 'processing' while recovery was pending. The scenario from #22208 assertedfailed._assert_recovery_pendingchecks for HTTP 200,processing, an integerpoll_after_ms > 0and no failed segments. It runs:_quarantine(stateheld, before dispatch), which covers every recovery scenario;prepared);batch-serving-kill-paid-callwhile the intent isrunning. That poll used to be recorded only; now it is asserted.completed, projection, exactly one paid call, durablerecovered, and late duplicates do not re-pay.batch-empty-asr-recovery-failurecovers the terminal leg. The paid STT fake is set tofail. Delivery returnsfailed_held, the job staysquarantined/failed_held, and the poll returnsfailedwithpoll_after_ms: 0,failed_segments == 1and no result. A duplicate delivery returns 200, the paid call count stays at 1, and the poll still saysfailed.2. Characterization goldens (#22203):
empty_asr_terminal,privacy_fence_midflight,provider_failure_quarantineThese were regenerated only through the documented path,
PIPELINE_GOLDEN_UPDATE=1 python -m pytest tests/unit/test_pipeline_characterization.py.Attribution check: with
BATCH_PIPELINE_RECOVERY_DISPATCH_BATCH_SIZE=1(the pre-#22321 one-candidate sweep), the regenerated traces equal the old goldens byte for byte for all three. Every line below is therefore caused by #22321's bounded dispatch and nothing else. Per-segmentpaid_callsis unchanged everywhere. No fenced segment gains a paid call or a result.empty_asr_terminal<1m/<5mprepared/running/recovered/client:completedbecome<30s, because up to 16 quarantines are dispatched per sweep instead of one.final_result.log_sequence,late_captureandprevious_segment_idchange for seg-1/seg-2 (owner-1) and seg-3/seg-4/seg-5 (owner-2). Recoveries now finish in a different order, and ordered merge assigns each owner's log sequence in completion order. Each owner still has a gap-free chain with one head.provider_failure_quarantinelog_sequence,late_captureandprevious_segment_idvalues for owner-3's seg-5/6/7 are re-chained for the same reason: recovery completion order changed. The outcome and the paid calls are identical.privacy_fence_midflight<1m/<5mto<30s quarantined recovery:prepared. Two segments that were purged before dispatch under the one-at-a-time sweep now reachprepared, and gain anunfinished_at_endtask response. Paid calls stay 0, and they are stillpurged.heldrecover-task responses on fenced segments come from deliveries rejected by the privacy fence. The fence holds and no paid call is made.previous_segment_id). Their completion buckets move between<5mand<15mbecause their recovery tasks now queue alongside more concurrent recoveries; seg-4 sees two extrahelddeliveries before it runs. Owner-3's seg-5 moves the other way, from<15mto<5m.recovery_heldgoes from 4 to 8 andrecovery_tasks_enqueuedfrom 18 to 27, because more candidates are dispatched per sweep.recovery_recoveredstays at 6. Therequest_scopeddrain counts rise to match. The finaljob_statesare unchanged (committed: 4).3. Simulator
provider_exhaustion_window(#22201)The test asserted
quarantine_projection_p95_seconds > 300and the verdictquarantine_projection_p95_over_5m, which documented the old discovery defect. The p95 is now 89.7 s (it was 1512.5 s with batch size 1). The test now asserts:failed_heldstays visible.unrecovered_quarantines == failed_heldand the verdict isGATE_FAIL unrecovered_quarantine. That same failed_held exists with batch size 1; there it was masked because the p95 gate failed at an earlier poll.Other encodings of the old expectation
backend/docs/batch-pipeline-worker.md"Terminal quarantine and the visible gap" said quarantine reportsfailed. I added a note that recovery-pending states pollprocessing.test_batch_pipeline_intake.py, quarantine and recovery) pass.test_pipeline_sim.pystill referencesquarantine_projection_p95_over_5m, but that is the scorer's own gate-order unit test on synthetic samples, it is unaffected and it passes.Verification
origin/main0d8e1258plus this commit.pytest tests/unit/test_pipeline_characterization.py test_pipeline_sim_scenarios.py test_pipeline_sim.py test_pipeline_sim_revision.py test_batch_pipeline_intake.py test_batch_pipeline_quarantine_recovery.py test_batch_pipeline_quarantine.py: 150 passed.backend/testing/sync_cloud_tasks_stack/run.sh --only batchon the Firestore emulator: all 9 batch scenarios pass, including the new failure scenario.🤖 Generated with Claude Code