Repository navigation
fix(ops): prepare gated batch-100 sync and backfill caps - #23973
Git-on-my-level wants to merge 4 commits into
Conversation
…ire100) Batch at 100% takes consented mobile off per-segment sync; the sync cap becomes regression protection over the collapsed residual, and the paused backfill (22/54 cohorts) only needs its fresh-reconciliation load. - backend-sync: max 50 -> 20 (live measured 140-165k req/h on ~19 instances at ~7.4k req/h each; cap = 35% headroom over the high residual case), min 5 -> 3 (60 concurrent finalization handlers still exceed the 10-24 sizing rationale) - backend-sync-backfill: redis_guard ceiling 40 -> 10 (24h mean 6.0 / peak 7.5 instances at 12-16k req/h; fleet paused) - rightsizing pins updated to the post-change contract Apply via config-train after the batch live100 gate, with the live commands and guards in data/run-2026-10-13-two-lane-nemotron/retire100-changeset-2026-10-29.md (lead applies; the service-level maxScale annotation must move with the ops value or the next train re-fights it).
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. |
… r1) Luna round 1 on #23973 (P1): test_drift_check.py pinned the redis_guard ceiling at 40 and reads prod.yaml, so the ceiling change fails the shard. Pin follows the config: ceiling 10, with the retire100 rationale.
Replace stale instance sizing with the 72-hour read-only measurements and make the backfill controller-bound pin exact. Retain proposed retirement values for the lead's batch-100 window, with no claim they are safe at 25%.
…#24216) Redelivered sync tasks currently warm rollout cohorts even when they cannot run work, and long Dream sweeps hold the fresh Cloud Run fleet. This change removes those no-op cohort reads, carries retry history back from a valid sequencer claim, routes Dream sweeps to backfill, and declares the syncwall capacity/rate cuts. Changes: - Warm cohorts after the locked job's terminal/convergence checks. Stale epochs, migrated deliveries, lock conflicts and terminal cleanup keep their existing outcomes. `begin_job` returns the prior Redis job snapshot in its DB executor leaf; the necessary Redis read remains there, while the separate route executor dispatch disappears. Cohort-only timeouts retain the original queue-owned 409 after a confirmed lock release; uncertain release uses the existing safe continuation. Paid pipeline timeout behavior, run-lock re-reads, retry counts, five attempts and the final terminal check remain authoritative. - Route the production Dream sweep scheduler to backend-sync-backfill with its matching sync-jobs OIDC audience. Keep Dream cadence, drain, canary and behavior intact. - Declare backend-sync max 40 (from 50), keeping min 5, and sync-jobs-fresh rate 15 (from 25), keeping concurrency 160 and retry/backoff settings. Mirror the fresh queue source rate in staging to preserve the existing parity contract. Validation: - Targeted backend CI harness: 1,549 passed across 19 files, one deselected. - Follow-up through the same harness: all 40 tests in the three failed CI guard modules passed after the scope/expectation corrections; 236 adjacent cohort/publication tests also passed. - Final handler contract suite: 206 passed, including cohort-read/budget expiry, direct/sequenced delivery and confirmed/uncertain lock release. - Hermetic sync Cloud Tasks stack: all 11 sync scenarios passed, including real loopback admission/delivery, emulator persistence, Redis fencing, terminal duplicates and retries. Provider leaves are deterministic. - `make preflight`: all 38 selected checks passed, including async/import/runtime-image source closure, Firestore guards, route policies, lifecycle and documentation checks. Rollout is lead-owned. This PR does not apply live settings or deploy. Deploy the worker changes to backend-sync and backend-sync-backfill, reconcile the Dream scheduler, and apply the ops config separately. Review fresh latency/backlog after cap 40 before applying queue smoothing. Restore cap 50/rate 25 or the prior worker revision for rollback. Coordination: #23973 proposes a later retirement cap 20/min 3 and backfill ceiling 10; its cap hunk and sizing test conflict with this intermediate max 40/min 5. Audio-merge is intentionally excluded per the lead's ruling because it has no prod ops entry and #24215 changes its load. The meta-repo sentinel expectation needs a lead update. No listen/pusher env or workflow changes. Cap-hold is deliberately unchanged per the lead's custody ruling. Its sweep still has a 900-second cooperative owner-work budget, plus provider and storage tails, so these requests continue to hold the hot fleet for up to roughly 15 minutes before trailing IO completes. A hard sub-300-second response must not leave paid work exposed to revision retirement; durable request-owned continuation on the same service is deferred follow-up. The background-work ratchet and its baseline remain intact. Failure-Class: none These are performance and scheduling changes; the timeout correction preserves the pre-existing response contract within this unmerged optimization. Existing durable custody, retry and mutation authorities are preserved. No production account data was read or changed. Line-Count-Exception: backend/routers/sync.py | 4147 -> 4166 | Preserve the cohort timeout retry contract with confirmed lock release and shared bounded continuation cleanup. Follow-up validation: the exact CI slow-guardrail harness passed 2,050 tests. The cohort timeout matrix now triggers the established budget context from inside the stub, avoiding tiny real-clock deadlines. Production source is unchanged from Luna R2-reviewed `17411d7b`; lead ruling `237a5e` accepts this test-only follow-up without another review round. Source queue rate 15 does not apply during merge or the normal code train; manual Config Train must wait for the lead's cap-40 peak decision.
…24303) ## Problem and change backend-sync is pinned at its service cap of 40 instances (syncdiet, 2026-11-01): bursty hot instances keep the autoscaler at the cap, so the instance saving from #24264 (hourly re-poll of long-stuck custody deferrals, ~45k fewer sync-jobs/run deliveries per hour) only lands through a lower cap. This PR changes the ops source of truth only: `backend/deploy/ops/prod.yaml` `cloud_run.backend-sync.max_instances` 40 → 30 (min stays 5), and pins `test_cloud_run_rightsizing_pins.py` to (5, 30). **Merging applies nothing.** `config_train.yml` is `workflow_dispatch` only. Backend deploys live-resolve the sync maxScale, so no train reverts the live value either way. Expected: −10 instances × 24 h × $0.1789/inst-h ≈ **−$43/day** (syncdiet's instance-based rate), visible only after the apply. ## Apply (lead, after the gates) Gates (syncdiet §1, lead ruling 92aecb), each held for 1 h: 1. #24264 has served ≥ 7 h. It is in train fbc7973 (image digest `d1024bc3e84f`, serving since 2026-11-01 19:11:16Z), so the earliest apply time is **02:11Z 11-02**. 2. sync-jobs-fresh `task_attempt_delays` p95 < 2 s. 3. backend-sync request latency p95 ≤ 12 s. 4. backend-sync `max_request_concurrencies` p95 ≤ 13.5. 5. The size-121 (`{"status":"deferred"}`) share of sync-jobs/run 200s < 10%. Read-only checker (ro-prod, aggregates only), held outside the repo: `python3 -I /Volumes/Ephemeral/scratch/margin20/g1_gates.py --census`. Baselines by the same method: gate 4 = 13.4 (16–17Z 11-01), 17.4 (18–19Z), 18.7 (19:28–20:28Z). Gate 4 may not clear on a Sunday evening. Apply, canonical path: ``` gh workflow run config_train.yml -R BasedHardware/omi -f environment=prod -f mode=plan -f ref=main # plan must show only: backend-sync run.googleapis.com/maxScale 40 -> 30 gh workflow run config_train.yml -R BasedHardware/omi -f environment=prod -f mode=apply -f ref=main ``` Break-glass equivalent: `infra/rollout/bin/cr_apply.sh backend-sync --max=30`. The service-level annotation is the authoritative cap (the sentinel reads it), and `--max` creates no revision. The sentinel's hard-coded sync target (`sentinel/scripts/cloud_run_state.py` `TARGETS`) still reads 80, which is already stale against live 40. The lead updates it to 30 at apply. ## Rollback `cr_apply.sh backend-sync --max=40`, which takes minutes. Then revert this PR (or set 40) so the next config-train keeps it. Roll back on any of: attempt-delay p95 > 2 s for 15 min, latency p95 > 12 s for 15 min, or sync-jobs-fresh depth above 2× its pre-apply hour. ## Relation to #23973 #23973 edits the same key. Its body describes 5/50 → 3/20, but main is now 5/40, and the author holds it until fresh qualification. It must not merge as-is. If it is revived after this PR, rebase it onto 5/30. G1 does not depend on it. ## Validation `backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST` = test_cloud_run_rightsizing_pins.py, test_config_train.py, test_drift_check.py: 88 passed (4 + 52 + 32), run through `bin/omi-heavy` with no GCP credentials. The bounded pre-push gate passed. Owns: this PR only. Review: Luna, via review.sh. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/24303?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/24303?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24303&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.
2 issues found across 3 files
Confidence score: 2/5
- In
backend/deploy/ops/prod.yaml,config_traincan apply the cap of 20 even though mean and latest demand are already around 46 and 50. Keep the existing 50/5 values until fresh demand and queue qualification support the lower cap. - In
backend/deploy/ops/prod.yaml,config_traincan clamp this service to 10 despite mean, latest, and peak demand being about 12.6, 14, and 17. Keep the existing ceiling until the qualification gate is enforced.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/deploy/ops/prod.yaml">
<violation number="1" location="backend/deploy/ops/prod.yaml:79">
P1: `config_train` can apply this cap directly, but the recorded mean (~46) and latest demand (~50) already exceed 20, and the workflow has no sizing gate. Keep the existing 50/5 values until fresh demand and queue qualification, or enforce qualification as an apply precondition.</violation>
<violation number="2" location="backend/deploy/ops/prod.yaml:109">
P1: `config_train` can clamp this service to 10, while the recorded mean (~12.6), latest demand (14), and peak (17) all exceed that ceiling; the workflow does not enforce the qualification gate. Keep the existing ceiling of 40 until fresh demand and queue qualification, or enforce qualification as an apply precondition.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| # single-revision peak 17. Cap 10 is not safe at that observed demand. | ||
| # Coordinate the redis_guard runtime ceiling before applying this bound. | ||
| # Rollback: ceiling 40 (live cap 16). | ||
| max_instances: {owner: redis_guard, floor: 8, ceiling: 10} |
There was a problem hiding this comment.
P1: config_train can clamp this service to 10, while the recorded mean (~12.6), latest demand (14), and peak (17) all exceed that ceiling; the workflow does not enforce the qualification gate. Keep the existing ceiling of 40 until fresh demand and queue qualification, or enforce qualification as an apply precondition.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/deploy/ops/prod.yaml, line 109:
<comment>`config_train` can clamp this service to 10, while the recorded mean (~12.6), latest demand (14), and peak (17) all exceed that ceiling; the workflow does not enforce the qualification gate. Keep the existing ceiling of 40 until fresh demand and queue qualification, or enforce qualification as an apply precondition.</comment>
<file context>
@@ -92,10 +98,15 @@ cloud_run:
+ # single-revision peak 17. Cap 10 is not safe at that observed demand.
+ # Coordinate the redis_guard runtime ceiling before applying this bound.
+ # Rollback: ceiling 40 (live cap 16).
+ max_instances: {owner: redis_guard, floor: 8, ceiling: 10}
backend-integration:
env:
</file context>
| max_instances: {owner: redis_guard, floor: 8, ceiling: 10} | |
| max_instances: {owner: redis_guard, floor: 8, ceiling: 40} |
| max_instances: 20 | ||
| min_instances: 3 |
There was a problem hiding this comment.
P1: config_train can apply this cap directly, but the recorded mean (~46) and latest demand (~50) already exceed 20, and the workflow has no sizing gate. Keep the existing 50/5 values until fresh demand and queue qualification, or enforce qualification as an apply precondition.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/deploy/ops/prod.yaml, line 79:
<comment>`config_train` can apply this cap directly, but the recorded mean (~46) and latest demand (~50) already exceed 20, and the workflow has no sizing gate. Keep the existing 50/5 values until fresh demand and queue qualification, or enforce qualification as an apply precondition.</comment>
<file context>
@@ -70,8 +70,14 @@ cloud_run:
+ # Floor 3 provides 60 concurrent handlers, down from 100 at floor 5;
+ # qualify queue latency/backlog as well as instance demand before apply.
+ # Rollback: 50/5.
+ max_instances: 20
+ min_instances: 3
backend-sync-backfill:
</file context>
| max_instances: 20 | |
| min_instances: 3 | |
| max_instances: 50 | |
| min_instances: 5 |
|
Superseded by #24977 (retire approved November 9 controls; the retire-pipeline work continued there). Per lead2 ruling 664fd6 (dropped-work audit 2026-11-09, item 14). Branch kept. Closing as superseded. |
Problem and change
Prepare the batch-100 retirement candidate: backend-sync service min/max 5/50
to 3/20; backend-sync-backfill redis_guard bound 8..40 to 8..10. Keep every env
value, queue setting, image, concurrency and resource limit unchanged.
Pin the exact controller owner/floor/ceiling and the source-model values.
Current sizing: HOLD until fresh qualification
Read-only ro-prod Cloud Monitoring, 72h ending 2026-11-01 04:57Z:
sync peak 171,329 requests/hour, 3,153/minute, active-instance mean 46.0,
latest 49-50, single-revision peak 51; backfill peak 18,007/hour, 403/minute,
active mean 12.6, latest 14, single-revision peak 17. Total service peaks
100/32 include simultaneous revisions and must not be sized as one revision.
The earlier ~19/~6-instance model is stale. Caps 20/10 have negative headroom
against today's active demand and are not cleared at 25%. Even linear scaling
from a 25% rung to a 36-37% residual gives ~21-22 sync instances from 49-50;
that is an inference, not a load test, and does not qualify cap 20.
Lead must qualify stable batch-100 demand, request latency/errors and fresh/
backfill queue age/backlog before applying either cap. Floor 3 supplies 60
warm concurrent sync handlers, versus 100 at floor 5. The redis_guard runtime
must also respect ceiling 10; source bounds alone do not constrain an external
controller between config-train runs. This PR is source preparation, not an
instruction to apply the unsafe candidate today. Do not book the old $120-150/day
sync/backfill saving until fresh qualification and billing evidence exist.
Scope and rollout
Merged current origin/main without rewriting branch history. #24210's exact
prod/backend-sync-only usage_month_cache=100 and usage_month_total=100 exception,
its epoch, renderer and contract test are byte-identical to main. All other
hosts retain their prior levers. The renderer's complete 91-test contract passes.
This diff has no listen/pusher env, source or chart change and does not require
a listen/pusher roll. Apply is Cloud Run scale configuration only, lead-owned
via the canonical cr_apply helper after the sizing gate. Match both service
and revision scaling annotations to avoid precedence drift. Rollback restores
sync 5/50, backfill live cap 16, and source ceiling 40.
Validation
backend/test.sh file-isolated shard: rightsizing 4 + config-train 51 + drift 32
2 xfailed. The first run hit its 120s wall limit under host load; the documented
300s timeout passed. Selected local PR preflight, environment doctor and the
ordinary pre-push gate passed. No merge, deploy, cloud write or account-data read.
Ordered apply/rollback and corrected cost assumptions:
omi-workspace data/run-2026-10-13-two-lane-nemotron/swarm/state/refs/retireprep-2026-11-01.md.
Failure-Class: none