Skip to content

fix(batch): dispatch bounded quarantine recovery batches and keep recovery polls pending - #22321

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/sol-recovery-sweep
Oct 19, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/sol-recovery-sweep

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Quarantine recovery previously dispatched one candidate per 20-second reconciliation pass, limiting one integration instance to about 3/min regardless of queue concurrency. Dispatch up to 16 candidates per pass (configurable 1–64), retain the global cursor, and rotate allowlisted cohorts under the same global bound. RecoveryStore.start, durable paid-intent tokens, privacy fences, and ordered merge retain their existing authority.

Recoverable quarantines (held, prepared, running) now report processing with a nonzero poll hint. Terminal held failures still report failed. The poll route maps BatchPrivacyBlocked to the same HTTP 409/code/body as upload.

Validation:

  • PR test(backend): virtual-clock batch-pipeline capacity simulation #22201 virtual-clock provider_exhaustion_window, seed 1: 132 quarantines and 132 paid calls both before/after; quarantine-to-projection p95 1,512.5s → 89.7s. Batch-size=1 rollback reproduces 1,512.5s. The unmerged sim was loaded externally; its modeled query limit was updated from 10 to 64 to match the real query. The overall after-run still fails the separate unrecovered-quarantine gate (one held job), so this is not a claim that every gate passes.
  • nice -n 19 targeted unit tests: 108 recovery/intake/quarantine cases plus 13 status-route cases passed. Firestore query guards: 479 shape cases and 30 outside-contract cases passed.
  • Owned loopback Firestore emulator: 3 passed (pagination, existing capture-order projection, new 17-unit recovery case). The new case dispatches 16 then 1, races duplicate start transactions, settles in reverse order and checks ordered merge, then calls the real poll HTTP route before/after the privacy generation fence. Provider leaves are synthetic.
  • Shared local preflight: 33 checks passed. All heavy checks ran through bin/omi-heavy run -- nice -n 19.

Rollback: set BATCH_PIPELINE_RECOVERY_DISPATCH_BATCH_SIZE=1. Existing recovery enablement and inline kill switch remain effective. No workflow changes, merge, deploy, production account data, or GCP access.

Product invariants affected

none

Failure-Class: none
Failure-Class-Reason: The primary defect is a bounded dispatcher configured below its downstream capacity; the poll changes restore the batch recovery protocol's pending/error mapping. Existing definitions do not describe that combined recovery contract. Regression guards cover bounded paging, cohort fairness, paid-start races, ordered merge, and HTTP privacy mapping.

Line-Count-Exception: backend/routers/sync.py | 2948 -> 2956 | Catch the typed privacy fence at the existing HTTP boundary and share the upload response; moving this route would broaden a recovery-only fix.

View guided diff Turn on auto-fix

@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-19T02:49:20.479184Z 7fa9acf 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.

@Git-on-my-level
Git-on-my-level merged commit 4e89755 into main Oct 19, 2026
63 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/sol-recovery-sweep branch October 19, 2026 04:13
Git-on-my-level added a commit that referenced this pull request Oct 19, 2026
#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]>
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