Repository navigation
feat: isolate heavy owners from partial batch ramps - #23004
Conversation
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. |
…eline (off by default) (#23003) Legacy-served real uploads can now exercise the record pipeline without projecting or charging anything to the user. This catches empty-audio and held-recovery outcomes before the live ramp, using an independent owner-hash cohort and idle capacity in the existing GPU fleet. - Ship off: `BATCH_PIPELINE_SHADOW_PERCENT=0`. The lead enables 10% after the carrying train and watches the first hour; zero stops new GPU/paid work. - Shadow jobs never claim the legacy ledger, Redis progress/locks, owner scheduler rings or conversation documents. The shadow flag fences projection/publication, user allowance/accounting, live reuse and result persistence. Transcripts stay in memory; terminal records contain only hashed-owner outcomes. Audio retains owner encryption, privacy checks and bounded cleanup. - At most four idle offers use the existing pool. Busy/expired offers drop instead of entering a backlog. Shadow never waits behind ordinary GPU work; paid recovery runs outside pump lanes. - `BATCH_PIPELINE_SHADOW_PAID_RECOVERY_PER_HOUR=200` is an atomic shared UTC-hour cap across Modulate and Deepgram, with at-most-once provider reservations per unit. Exhaustion or unavailable spend authority records `shadow_paid_skipped` / outcome `paid_skipped`. - V1 inline uploads and V2 legacy claims use the same isolated handoff. The CPU env manifest and Helm chart expose the off/capped settings. Worker-only `BATCH_PIPELINE_SHADOW_RECOVERY_API_URL` targets the existing recovery role, with its OIDC audience and the GPU principal, so the terminal policy matches the record lane. Readout contract: - `omi_batch_shadow_outcome_total{outcome=recovered|empty|failed_held|error|dropped|paid_skipped,class=fresh|recent|deep}` - `omi_batch_shadow_speech_seconds_total{vad=worker|strict,class}` - `omi_batch_shadow_speech_loss_seconds_total{vad=worker|strict,class}` (whole-unit VAD speech when no words survive) - `omi_batch_shadow_gpu_seconds_total` - `omi_batch_shadow_paid_calls_total{provider=modulate|deepgram}` - `omi_batch_shadow_paid_audio_seconds_total{provider=modulate|deepgram}` Owner concentration comes from hashed `owner_key` terminal records / `event=batch_shadow_outcome owner_hash=...` logs, never a Prometheus owner label. The lead owns workspace `fleet_gate.sh --shadow`. At 10%, no extra GPU nodes are requested. Accepted audio depends on owner concentration and idle drops. As a conditional list-price scenario, per 100 eligible audio-hours, 10 shadow hours with 5% Modulate and 1% Deepgram duration cost about $0.0462 in paid recovery; all-duration two-provider recovery costs $3.42. The default 200-call shared cap and <=1h units give a conservative $62.40/hour list-price ceiling, not a measured vendor bill. Actual Modulate/Deepgram usage must be reconciled during the first hour. Rates, assumptions, retention and rollback are documented in [batch-pipeline-shadow.md](backend/docs/batch-pipeline-shadow.md). Services for the lead's train: backend sync upload hosts, the existing batch API/recovery target, batch-pipeline-worker, and backend/integration hosts that own shared deletion/retention. Carry the sync GMP collector config, which now retains the six shadow counters. Apply the four added shadow job/spend TTL policies using the existing retention operator tool. This PR does not deploy or enable the cohort. Lead ruling `dbc28b` requires staging-soak synthetic-corpus qualification on isolated staging (zero user-visible writes, cap, load drop) before production 10%. Validation: - Final 22-file suite: 945 focused unit/ASGI tests passed through `omi-heavy run -- nice -n 19 env BACKEND_UNIT_TEST_FILE_LIST=... bash backend/test.sh` after syncing main: real WAL decode and encrypted staging preserve legacy files; full worker path discards transcripts; private recovery route never publishes; cohort, cap, duplicate, kill, admission/load-drop and collector-retention cases. - `omi-heavy run -- nice -n 19 make runtime-image-source-closure`: all 19 registered images passed. - Real loopback Firestore emulator: all 3 concurrency tests passed (shared cap across replicas, duplicate-provider reservation, two uploads/one offer). No real GPU/provider invocation is claimed. - Grok full review and delta review completed; all reported findings addressed. R2's integration-role identity blocker is fixed and rendered principal/audience tests pass. Under the swarm's two-round cap, lead ruling `fc7e19` accepted the fixed delta with no third round, merge on green CI. - `make preflight` and metadata-only preflight pass on the merged head (after the shadow admission clients moved onto the database executor). The pre-push backend pyright lane then caught three shadow-module type errors; the type-only fix gives 0 errors, the 22-file suite passes again, and the full pre-push gate passed on the pushed head. - CI backend shards 4 and 5 then failed 22 sync upload tests with a 500: once tests replace `utils.sync` in `sys.modules`, the handler's lazy `shadow_intake` import raised. Both v1/v2 handoffs now go through one best-effort wrapper that logs `event=batch_shadow_intake outcome=error` and continues, so the shadow can never fail a legacy upload. `test_sync_cloud_tasks.py` (187) and `test_sync_v2.py` (182) pass with the 22-file suite; pyright 0 errors. - CI on the main-merged head then surfaced three more gaps, all fixed: live jobs persisted a meaningless `shadow: false` (changing the `deleted_merged_targets` golden), so live job documents now omit it and stay identical to main; the six shadow fire-and-forget sites are baselined in the background-task ratchet with their SIGKILL-safety reasons; the cohort migration tool inventories `batch-pipeline-shadow` as legacy-all (no env allowlist ever existed). 60 backend unit files (all `test_batch_pipeline*`, the CI-failing files and the earlier suite) pass; pyright 0 errors. - Known-red on main (`Backend unit guardrails` real-clock ratchet) was fixed by #23013 and merged in. - Follow-up under lead ruling `eab308`: once #23004 merges, apply the shared heavy-owner exclusion predicate (`batch_ramp_owner_load_v1`) before new shadow offers. Shadow-informed 30-minute holds count only matched-population windows after that. - No production account reads, GCP tier, deployment or live acceptance claimed. Process exceptions: - Cross-lane contract publication (`swarm/contracts.md`) came after implementation rather than before; final rows were published and the consumer lane acknowledged them. - Early heavy checks overlapped before the final serial validation. - Source inspection surfaced an existing allowlist fixture identifier in tool output. It is not repeated here and was not a production account read. - The original agent died on a model-capacity error mid-lane; a resume agent finished checks and publication from the committed state. Product invariants affected: INV-MEM-4. The changed runtime manifest enables no memory route; shadow publication fences prevent canonical intake or promotion from this experiment. Line-Count-Exception: backend/routers/sync.py | 3826 -> 3863 | Keep the minimal best-effort v1/v2 handoffs at the legacy ownership seams; the implementation lives in dedicated shadow modules. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…p-pipeline # Conflicts: # backend/deploy/cloud_run_gmp_sync.yaml # backend/tests/support/firestore_query_driver_registry.py
…23025) The summary-delivery unit suite crosses its unchanged 1-second call CPU guard when the banked-summary case first imports `database.conversations`. Two CI attempts failed at 1.01s and 1.05s, and the normal local runner reproduced 1.18s; all 19 assertions passed each time. Preload that real dependency in a module fixture so the CPU guard measures the merge logic. Import errors still fail setup, all assertions run unchanged, and there are no stubs, threshold, allowlist, production or workflow changes. This urgent independent test-only fix unblocks P19 #23004. Validation: the normal pinned `backend/test.sh` file-list run passed all 19 tests and its unchanged CPU guard under `omi-heavy run -- nice -n 19`, with four workers. Required `make preflight` passed 31 checks under the same wrapper. The earlier scratch-only preload probe is separate diagnostic evidence. Failure-Class: none Failure-Class-Reason: Test dependency setup only; no production behavior or failure-class contract changes. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/23025?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/23025?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23025&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. -->
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b87284e575
ℹ️ 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".
|
|
||
| from config.policy.ramp import OPEN_WINDOW_SECONDS, READ_LIMIT, exclusion_enabled, exclusion_reason, owner_load | ||
| from database._client import get_data_plane_firestore_client | ||
| from utils.sync.stage import current_stage |
There was a problem hiding this comment.
Keep stage resolution out of the database layer
database.batch_ramp imports utils.sync.stage, reversing the repository's required database/ → utils/ → routers/ dependency direction. Because this module is now imported by both conversation-lifecycle and batch-pipeline utilities, the reverse dependency also creates a circular-import hazard as either utility package evolves. Pass the stage into this helper or move the stage/collection-name contract into a lower-level config or database module instead.
AGENTS.md reference: backend/AGENTS.md:L161-L169
Useful? React with 👍 / 👎.
| if not isinstance(payload, dict): | ||
| return None | ||
| start, end = payload.get('audio_start_seconds'), payload.get('audio_end_seconds') | ||
| return end - start if nonnegative(start) and nonnegative(end) and end >= start else None |
There was a problem hiding this comment.
Treat zero-length audio bounds as unavailable
When an upload supplies equal start and end timestamps, this returns a known duration of zero even though the existing recording-target contract treats audio_end_seconds <= audio_start_seconds as an invalid interval. Because these query parameters are independent of the uploaded bytes, a large upload with equal bounds bypasses the fail-closed incoming-audio check and can enter the partial batch ramp without contributing any audio to the six-hour budget; require end > start so malformed point intervals route to legacy.
Useful? React with 👍 / 👎.
# Conflicts: # backend/deploy/cloud_run_gmp_sync.yaml
During a partial batch ramp, a single catch-up owner can dominate the hash cohort. New sync uploads and recording reservations now keep owners with more than 30 open items or six hours of waiting, active and incoming audio on legacy. Existing batch receipts and native recording owners retain their dispatcher and drain normally.
The shared pure predicate ships on, with
BATCH_PIPELINE_RAMP_EXCLUDE_HEAVY_OWNERS=offas its kill switch. Bounded metadata reads fail to legacy on unknown load.omi_batch_ramp_heavy_owner_excluded_total{reason}reports excluded admission decisions without account labels. Percent-zero explicit qualification and the separate 100%/heavy-owner step retain their existing semantics. No deploy, runtime env change or.githubedit is included.Validation: focused
backend/test.shrun viaomi-heavy run -- nice -n 19, with a path-list file and four workers: 899 tests passed across 15 owner-load, intake, native recording, live-preview, shadow, privacy, metric-retention, admission-regression, Firestore query and summary-delivery suites after integrating current main. Workspace rollout suite: 407 tests passed, including synthetic run-24/run-25 admission replay and the unchanged real-loss gate. Pinned Pyright reports zero errors. The owning slow-guardrail runner passed 2,047 tests. Review round two returned SHIP; the reviewed ramp predicate/reader are unchanged by the main integration. This is hermetic admission/query evidence; staging traffic soak and production acceptance remain lead-owned.Main includes the independently reviewed test-only repair #23025 for a cold database import charged to the unit call CPU guard. Its real-dependency fixture preserves all assertions and the 1-second budget; no budget or allowlist was changed.
Review fixes: unknown or invalid upload bounds fail closed to legacy, including desktop WALs without timestamps; existing legacy custody receives a legacy policy, while accepted batch custody keeps draining. Regression tests exercise the actual sync route and all three bounded metric reasons.
Product invariants: INV-DATA-1 — reads use the existing data-plane client and explicit stage namespaces. Accepted custody never transfers to legacy under a later owner-load decision.
Failure-Class: none
Failure-Class-Reason: This adds the approved typical-user admission cohort contract; no failure-class definition or workflow changes are introduced.
Line-Count-Exception: backend/routers/sync.py | 3863 -> 3881 | Keep the admission filter and durable-owner override at the existing sync route boundary.
Line-Count-Exception: backend/database/firestore_index_registry.py | 2187 -> 2196 | Declare both stage-qualified owner-load indexes in the existing registry authority.