Repository navigation
fix: fence batch scheduler pulls and spread control shards - #23927
Merged
Merged
Conversation
Acquire per-shard pull ownership before entering queue/job transactions, spread equal-service candidates across workers, and keep followers read-only. Retain priority, duration fairness, privacy, cap and job-token fences. Failure-Class: FC-unowned-scheduler-shard-writes
Acquire per-shard pull ownership before entering queue/job transactions, spread equal-service candidates across workers, and keep followers read-only. Retain priority, duration fairness, privacy, cap and job-token fences. Failure-Class: FC-unowned-scheduler-shard-writes
Acquire per-shard pull ownership before entering queue/job transactions, spread equal-service candidates across workers, and keep followers read-only. Retain priority, duration fairness, privacy, cap and job-token fences. Failure-Class: FC-unowned-scheduler-shard-writes
Acquire per-shard pull ownership before entering queue/job transactions, spread equal-service candidates across workers, and keep followers read-only. Retain priority, duration fairness, privacy, cap and job-token fences. Failure-Class: FC-unowned-scheduler-shard-writes
Acquire per-shard pull ownership before entering queue/job transactions, spread equal-service candidates across workers, and keep followers read-only. Retain priority, duration fairness, privacy, cap and job-token fences. Failure-Class: FC-unowned-scheduler-shard-writes
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. |
Git-on-my-level
added a commit
that referenced
this pull request
Oct 29, 2026
…taxonomy, shard spread, boundary geometry, real claim) (#23946) ## Summary David, 10-29 (simtests lane): tonight's batch wedges were deterministic and testable, but no test covered the property that failed. This PR adds the five CI invariants from tonight's brief, wired into the existing backend unit suite (no new workflow), plus the minimal product fix one of them demands. **The wedge class still live on main:** a committed result or manifest that violates the payload contract raised `ValueError` through `assign_parts` with no disposition. The owner-chain walk retries a chain head forever, so a permanently invalid payload at the head froze every later capture behind it — the same head-of-line shape as #23932's unhandled record-target conflict, and the deterministic driver behind the #23926 EOF-span refusals (4,952 refusals on one revision). The fix takes the held disposition for the closed set of payload-contract `ValueError`s, exactly like a structural assignment conflict: quarantine receipt, watermark advance, recovery owns the unit, audio retained. The Firestore commit-contention `ValueError` shape stays retryable. ## The five invariants 1. **Poison-head matrix** (`test_pipeline_sim_poison_head.py`): for every failure kind the projection walk can raise — all 16 bounded assignment-conflict subtypes plus the unlabeled fallback, five payload-contract `ValueError` sites (duration mismatch, split duration, no words, missing VAD spans, corrupt source manifest), the contention-shaped `ValueError`, ambiguous generation, and a busy claim — inject it permanently at an owner's chain head. Advancing kinds quarantine-hold within K=2 walk attempts (watermark moves, later units project, audio retained); wait kinds stay in a bounded, observable pending state. Would have caught #23932 and the payload wedge. 2. **Exception-taxonomy coverage contract** (`test_batch_projection_exception_taxonomy.py`): AST-scans the walk's callee modules for constructor-raise sites; a new raise class without a `TAXONOMY` disposition fails the suite with instructions, and every injectable kind must appear in the poison-head matrix. Also pins the strike-rule sets (the one deliberately unclassified subtype, `bridge_source_not_tombstone`, waits on every lane). 3. **Multi-worker shard-spread sim** (`test_batch_pipeline_shard_spread.py`): `SpreadMemoryStore` models the real spread-mode candidate semantics (service primary, worker affinity on ties, exclusions, pull claims) plus Firestore write-write behavior — a control write on a shard committed by another puller after this puller's candidate read aborts. Six real `Scheduler`s over twelve shards from a shared per-round snapshot: writes spread (no shard > 2x mean, no round piles onto one document), every job leases exactly once with unique tokens, claims fence every pull, and stale-write contention stays far under the legacy no-affinity shape (measured 24 vs 240 aborts on this workload). Invisible with one simulated worker (#23927). 4. **Boundary-geometry property tests** (`test_batch_pipeline_boundary_geometry.py`): the ±1-sample boundaries of every duration fence — EOF VAD spans at each sample of the decode tolerance (#23926), measured-VAD tolerance, bound worker receipts, word clocks at EOF, manifest slices at the capture edge, and the projection payload's 0.1 s duration tolerance including its deterministic float asymmetries (nominal −0.1 s passes where +0.1 s rejects, one float ulp past the fence). 5. **Real-claim rule** (`test_projection_followup_real_claim_rule.py`): the projection_followup suite must keep at least one non-skipped test exercising the REAL `projection_claim` against fakeredis — the stubbed claim hid #23928's cross-Context token reset. ## Self-testing (definition of done) Layer: backend unit shard — the exact CI changed-file selection from `scripts/select_backend_unit_tests.py` for this diff (18 files, including the Firestore guard set the selector attaches to the `projection.py` change): ``` BACKEND_UNIT_TEST_FILE_LIST=<selection> BACKEND_PYTEST_WORKERS=4 bash backend/test.sh # green, exit 0, duration guard clean ``` Discrimination evidence (each invariant fails against the bug it exists for): - poison-head payload kinds fail without the parent fix's disposition; - the shard-spread sim was measured against `BATCH_SHARD_SPREAD_ENABLED=false`: 240 stale-write aborts and 49 one-lease rounds vs 24 aborts and 13 rounds with spread — the legacy flag also zeroes the claim counter; - the boundary sweep pins the exact clamp/reject sample where #23926's fence flipped. ## Review Round 1 (Luna, FIX-FIRST) — one P1: the result-load phase sat outside the disposition, so a corrupt committed artifact (invalid envelope, oversized body, bad reference — or valid JSON that is not an object reaching `payload.get` as an `AttributeError`) still wedged the chain head. Fixed: the load phase is inside the contract try, and a non-object body is normalized to the contract `ValueError`. Two new poison-head kinds pin it (`payload:corrupt-artifact`, `payload:non-object-result`). Round 2 (Luna, FIX-FIRST) — two P1s, both fixed: - The pre-loop catch lacked the `payload_contract_violation` gate: a contention-shaped `ValueError` from the load seam's Firestore-backed authorization would have quarantined a valid capture. Both catches now gate through the discriminator, and the `contention-value-error` poison kind injects at the load seam to pin it. - A correctly-sized artifact with altered ciphertext fails `AESGCM.decrypt` as `InvalidTag`, not `ValueError` — it escaped the disposition. `InvalidTag` is now part of the contract class set (`payload:tampered-artifact` pins it; the unit-level discriminator test asserts it). `artifacts.py` joined the taxonomy scan; `PermissionError`/`TimeoutError` entries document the authorization-wait and transient classes. Failure-Class: FC-unresolved-head-blocks-projection Line-Count-Exception: backend/utils/batch_pipeline/projection.py | 1504 -> 1558 | payload-contract quarantine disposition: one discriminator helper plus one catch per assign path section, mirroring the #23932 structural-conflict handlers; review rounds added the load-phase cover and the InvalidTag class UI-Evidence: none -- reason: no web/admin/app paths touched.
YinkaAdepoju
pushed a commit
to YinkaAdepoju/omi
that referenced
this pull request
Oct 29, 2026
Tonight's batch failures were deterministic and testable, but no test covered the property that failed. Five invariants, wired into the existing backend unit suite (no new workflow): 1. Poison-head matrix (test_pipeline_sim_poison_head.py): for every failure kind the projection walk can raise — all 16 assignment-conflict subtypes plus the unlabeled fallback, five payload-contract ValueErrors, contention-shaped ValueError, ambiguous generation, busy claim — inject it permanently at an owner's chain head. Advancing kinds quarantine-hold within K=2 walk attempts (watermark moves, later units project, audio retained); wait kinds stay in a bounded, observable pending state. Would have caught BasedHardware#23932 and the payload wedge fixed in the parent commit. 2. Exception-taxonomy coverage contract (test_batch_projection_exception_taxonomy.py): AST-scans the walk's callee modules for constructor-raise sites; a new raise class without a TAXONOMY disposition fails the suite, and every injectable kind must appear in the poison-head matrix. 3. Multi-worker shard-spread sim (test_batch_pipeline_shard_spread.py): SpreadMemoryStore models the real candidate semantics (service primary, worker affinity on ties, exclusions, pull claims) plus Firestore write-write behavior (a control write on a shard committed after the puller's candidate read aborts). Six real Schedulers over twelve shards from a shared per-round snapshot: writes spread (no shard > 2x mean, no round piles onto one document), every job leases exactly once, claims fence every pull, stale-write contention stays far under the legacy no-affinity shape (measured 24 vs 240 on this workload). Invisible with one simulated worker (BasedHardware#23927). 4. Boundary-geometry property tests (test_batch_pipeline_boundary_geometry.py): the +-1-sample boundaries of every duration fence — EOF VAD spans at each sample of the decode tolerance (BasedHardware#23926), measured-VAD tolerance, bound worker receipts, word clocks at EOF, manifest slices at the capture edge, and the projection payload's 0.1s duration tolerance including its deterministic float asymmetries (0.9 passes where 1.1 rejects). 5. Real-claim rule (test_projection_followup_real_claim_rule.py): the projection_followup suite must keep at least one non-skipped test exercising the REAL projection_claim against fakeredis — the stubbed claim hid BasedHardware#23928's cross-Context token reset. Local verification (layer: backend unit shard, the exact CI changed-file selection from scripts/select_backend_unit_tests.py for this diff — 18 files): BACKEND_UNIT_TEST_FILE_LIST=<selection> bash backend/test.sh — green, duration guard clean. Failure-Class: FC-unresolved-head-blocks-projection
Git-on-my-level
added a commit
that referenced
this pull request
Nov 30, 2026
…#26676) ## What changed and why Port PL-144 from Plan A into the existing batch Store conformance suite. Two worker identities choose different equal-service shards. Lower virtual service and higher job priority still win against affinity. A live pull claim lets an eligible alternate proceed. The busy-prefix test also verifies one bounded widening from 16 to 64 candidates. The same test drives the production scheduler over the in-memory simulator, old Firestore and the replacement Postgres Store. The existing emulator job runs the simulator and Firestore legs. Rollback is a revert of the test commit. Source [#23927](#23927). ## Product invariants affected none ## How it was verified - `OMI_REQUIRE_STORE_BACKENDS=all` with the loopback Firestore emulator and local Postgres. `pytest -q -m integration tests/integration/test_store_conformance.py -k 'pl144 or candidate or refills_saturated'` passed all 30 selected cases, with zero skips or xfails. - The normal pre-push gate passed, including the 37-check local preflight. Failure-Class: FC-unowned-scheduler-shard-writes <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/26676?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/26676?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F26676&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. --> 🤖 Generated with [Claude Code](https://claude.com/claude-code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Batch workers all selected the same minimum-service control shard and wrote it even when no job could be leased. Three replicas amplified Firestore contention instead of draining work.
This change acquires a separate token-fenced pull claim before entering each shard's queue/job transaction. Followers only read the hint/claim and try another candidate; the winning transaction verifies ownership and releases it atomically. Equal-service candidates use worker affinity, with virtual service still the primary fairness key. Strict priority and the existing privacy, capacity, GPU and job lease fences remain in place.
BATCH_SHARD_SPREAD_ENABLEDships on. Rollback:worker.shardSpreadEnabled=falsein worker Helm values. Static contention logs nameoperation=batch_claim|batch_pull shard=scheduler_NN, without user or worker IDs. A failed pull leaves its claim for bounded 30-second expiry. Simulator and Postgres adapters implement the same store interface; no schema or workflow change.Failure-Class: new
Validation (serial, through
omi-heavyandnice -n 19):backend/test.shwith an explicitBACKEND_UNIT_TEST_FILE_LISTand one file worker: 14 targeted files, 787 tests passed, one deselected. Includes existing duration/user fairness, two-worker throughput, privacy/cap/job fencing, query inventory, flags, chart, simulator and Postgres interface contracts.backend/testing/sync_cloud_tasks_stack/run.sh --only batch: all ten process-level batch scenarios passed after the main refresh, including recovery, SIGTERM/kill, privacy and two-worker drain. The same harness now runs the new five-case concurrency regression in CI, using the existing emulator and workflow.OMI_PR_BODY_FILE=<body> make preflight: 39 checks passed. Normal pre-push checks are retained.Claim acquisition adds one bounded read/CAS and atomic release per successful pull; deployed Firestore cost/throughput are still unmeasured. A lost CAS returns busy without a retrying claim transaction. The emulator bound covers transaction retries; conditional-CAS busy returns are separate static telemetry.
Lead owns merge and the
gcp_diarizer.ymlworker deploy. No production access or deployment by this lane. Emulator evidence does not establish deployed throughput or recovery of existing projection debt. Live acceptance must verify worker source/digest, per-shard contention and custody/wedge progress before restoring scale.