Skip to content

test(batch): align harness with #22321 recovery contract - #22385

Merged
Git-on-my-level merged 1 commit into
mainfrom
fix/gauntlet-recovery-poll-contract
Oct 19, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
fix/gauntlet-recovery-poll-contract

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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 is held, prepared or running polls processing with a nonzero poll_after_ms, and terminal quarantine (failed_held) still reports failed. 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 asserted failed.

  • New _assert_recovery_pending checks for HTTP 200, processing, an integer poll_after_ms > 0 and no failed segments. It runs:
    • in _quarantine (state held, before dispatch), which covers every recovery scenario;
    • after the task is captured (prepared);
    • in batch-serving-kill-paid-call while the intent is running. That poll used to be recorded only; now it is asserted.
  • After recovery, the existing checks are unchanged: completed, projection, exactly one paid call, durable recovered, and late duplicates do not re-pay.
  • New scenario batch-empty-asr-recovery-failure covers the terminal leg. The paid STT fake is set to fail. Delivery returns failed_held, the job stays quarantined/failed_held, and the poll returns failed with poll_after_ms: 0, failed_segments == 1 and no result. A duplicate delivery returns 200, the paid call count stays at 1, and the poll still says failed.

2. Characterization goldens (#22203): empty_asr_terminal, privacy_fence_midflight, provider_failure_quarantine

These 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-segment paid_calls is unchanged everywhere. No fenced segment gains a paid call or a result.

  • empty_asr_terminal
    • Lifecycle and result-transition buckets shrink. For example, <1m / <5m prepared/running/recovered/client:completed become <30s, because up to 16 quarantines are dispatched per sweep instead of one.
    • final_result.log_sequence, late_capture and previous_segment_id change 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_quarantine
    • The log_sequence, late_capture and previous_segment_id values 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
    • Fenced owner-1 segments move from <1m / <5m to <30s quarantined recovery:prepared. Two segments that were purged before dispatch under the one-at-a-time sweep now reach prepared, and gain an unfinished_at_end task response. Paid calls stay 0, and they are still purged.
    • The extra held recover-task responses on fenced segments come from deliveries rejected by the privacy fence. The fence holds and no paid call is made.
    • Owner-2's seg-3/seg-4 swap log order (sequence 1 and 2, previous_segment_id). Their completion buckets move between <5m and <15m because their recovery tasks now queue alongside more concurrent recoveries; seg-4 sees two extra held deliveries before it runs. Owner-3's seg-5 moves the other way, from <15m to <5m.
    • Counters: recovery_held goes from 4 to 8 and recovery_tasks_enqueued from 18 to 27, because more candidates are dispatched per sweep. recovery_recovered stays at 6. The request_scoped drain counts rise to match. The final job_states are unchanged (committed: 4).

3. Simulator provider_exhaustion_window (#22201)

The test asserted quarantine_projection_p95_seconds > 300 and the verdict quarantine_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:

  • the cohort still has at least 20 quarantines (it has 132);
  • p95 < 300 s;
  • the paid-call invariants are unchanged (one call per quarantine, at least 95% recovered);
  • the one terminal failed_held stays visible. unrecovered_quarantines == failed_held and the verdict is GATE_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 reports failed. I added a note that recovery-pending states poll processing.
  • READMEs for both harnesses are updated.
  • The unit tests that fix(batch): dispatch bounded quarantine recovery batches and keep recovery polls pending #22321 already updated (test_batch_pipeline_intake.py, quarantine and recovery) pass. test_pipeline_sim.py still references quarantine_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

  • Worktree on origin/main 0d8e1258 plus this commit.
  • Before the change, on clean main, all 4 unit failures reproduced locally.
  • 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.
  • Local gauntlet, backend/testing/sync_cloud_tasks_stack/run.sh --only batch on the Firestore emulator: all 9 batch scenarios pass, including the new failure scenario.

🤖 Generated with Claude Code

View guided diff Turn on auto-fix

#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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 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-19T05:09:36.158063Z b3c4079 PR opened
ℹ️ 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: 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

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

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 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 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 501f906 into main Oct 19, 2026
62 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/gauntlet-recovery-poll-contract branch October 19, 2026 05:35
apoorvdarshan added a commit to apoorvdarshan/omi that referenced this pull request Oct 19, 2026
kodjima33 pushed a commit that referenced this pull request Oct 19, 2026
…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]>
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