Repository navigation
perf(firestore): singleton lease fail-open rework + queue-age sample budget lever (dark, WQ1+WQ3) - #22142
Merged
Conversation
…case equals lever-off (dark) Loop: firestore-reads WQ1. singleton_loops is flagged OFF in prod (#22071) after the 2026-10-17 19-21Z fleet-wide acquisition starvation across two revision rolls; this rework is the precondition for re-ramping it. - takeover at tick expiry (Lua-side, tick PTTL as clock): a dead holder hands over within <=1 interval (<=300s) instead of the full lease TTL; only one admission per tick survives (tick SET NX inside the atomic script) - a pod wedged inside its callback fails open and runs the next invocation locally after the 900s max-hold cap (lever-off semantics) instead of skipping forever - SIGTERM release runs outside asyncio and the db executor so a starved shutdown hook cannot leave stale lease keys behind - lever-off path byte-for-byte unchanged; queue-age publisher handoff unchanged Verified: 53/53 targeted tests (42 s2 + 8 recovery + 3 real-Redis Lua) via BACKEND_UNIT_TEST_FILE_LIST; zcode glm-5.3 review SAFE (exec-flush-position-logic-lion-figure-force, all six claims re-verified, no real findings; 2 minors recorded: getsignal-None hardening unreachable under the pinned uvicorn launch, new skip outcome labels double-count on sum-by-loop dashboards). Author report: data/run-2026-10-16-firestore-reads/SOL-WQ1-lease-report.md (meta-repo). No lever config change in this PR.
…ready set every tick (dark) Loop: firestore-reads WQ3. durable_queue_age._sample_status_page re-scans the whole ready set on every publisher tick: measured 73.93M reads/day (backend-sync 71 pods + backfill 5 + backend 4 at 300s ticks, reconciled from snapshot 2026-10-18T05:00:38Z vs ~74M/day origin reads). New default-off lever queue_age_sample_budget: - 300s per-pod publish cache (FSR_QUEUE_AGE_MIN_PUBLISH_SECONDS), ages stamped at scan start, expiry re-checked under the lock; freshness lag <=600s + scan time - first-page early-stop when the full first page proves the oldest ready age strictly above the 21600s alert threshold (boundary-matched); small ages still require exhaustive scans; capped/malformed scans still omit the key (unknown, never 0) — malformed docs now force unknown even alongside valid rows - new omi_queue_age_sample_timestamp_seconds gauge makes stale publication detectable Lever-off path is instruction-identical (verified by review); 126 targeted tests pass incl. probe-counter proof 4250 -> 200 reads over five ticks; zcode glm-5.3 review SAFE (exec-cable-van-shiver-multiply-meat-three). KNOWN_LEVERS registration lands with the loop's config PR before any enable.
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. |
This was referenced Oct 18, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Oct 20, 2026
…and 7 ticks) (#22629) * config(firestore): re-enable six exonerated levers at 5% (guards in band 7 ticks) usage_month_cache, singleton_loops, queue_age_sample_budget, backfill_task_reads, historical_scan_memo, ledger_purge_coalesce: 0 -> 5. backend-sync/-backfill 5xx in band 11Z-17Z 2026-10-19 with all sync levers at 0 (drain finished); singleton lease rework (#22142) and queue-age code live on served image 4f43b2d; scope opener live (#22048). people_scan_dedupe stays 0 (no qualifying call site). set_levers.py replace-mode regeneration (16 sites, 6 files) incl. contract tests. * chore(firestore): regenerate flag registry after main merge (13-key literal, six levers at 5)
Git-on-my-level
added a commit
that referenced
this pull request
Oct 20, 2026
…x2 ticks at 5%) (#22851) verify 2026-10-20T09:00:37Z: all five reconcile loops acquired=0, skipped_owner~44/h for a full hour (08Z tick: lease metrics absent = scrape gap; 09Z present: publisher loop acquired=6 in the same scrape), starvation signature re-observed 4 days after WQ1 lease rework merged (#22142). Flag off per runbook pending lease root-cause; four 5xx-guard refs and the other 12 keys unchanged.
Git-on-my-level
added a commit
that referenced
this pull request
Oct 20, 2026
…et; singleton_loops 25% (#22929) ## Summary Re-graduate two proven Firestore read levers stuck below 100%, and restart `singleton_loops` at 25%. This changes only the `FIRESTORE_READ_LEVERS` literal: runtime_env `_base.yaml` → rendered `runtime_env.yaml`, listen + pusher dev/prod values, flag registry, and the two contract tests that pin the literal. Generated with `avo/firestore-reads/set_levers.py` as the complete 13-key literal. | Lever | From → to | Evidence | Predicted reads/day saved | |---|---|---|---| | `usage_month_cache` | 5 → 100 | −45.0M/day absolute at 100% on 10-17 (loop readout `readout-2026-10-17T20Z-absolute.json`). It was flagged off 10-18 on an ambiguous backend-sync 5xx guard that stayed elevated with the lever at 0, then ran at 5% from 10-20 05Z with guards in band. | **~35–39M**. Its caller `user_usage:get_monthly_usage_stats_since` is 43.2M/day now (listen 33.1M + backend 10.1M, 24h to 10-20T17Z) vs ~4.9M/day at 100% on 10-17. | | `queue_age_sample_budget` | 5 → 100 | At 5% since 10-20 05Z with no guard breach (WQ3, reviewed SAFE in #22142). | Unknown until measured. Caller `durable_queue_age:_sample_status_page` is 46.8M/day visible (listen 40.3M, backend 6.5M) plus the sync services. It overlaps `singleton_loops`; never sum the two. | | `singleton_loops` | 0 → 25 | At 100% on 10-17: −119M/day on its callers (ledger READOUT 2026-10-17T05:20Z). The 10-20T09Z flag-off (#22851) read `acquired=0 / skipped_owner>0` on listen. `fsr_admit` returns `skipped_owner` for a recovery loop only while the tick key is live, and only an admission sets it, so the holder ran on backend-sync, whose lease counter #22118 hid (fixed in the companion PR). 25% first per the loop runbook until lease evidence is visible on every service. | Unknown at 25%. Visible callers are 93M/day on listen + backend. Per-process cohorts mean savings scale with the cohort share. | Measurement line: the Firestore reads loop (`avo/firestore-reads`) grades each lever from the served revision. `usage_month_cache` is graded on absolute caller reads vs `baseline-2026-10-20T05-00Z.json` (`get_monthly_usage_stats_since` 1.24M reads/h on backend). Fleet total is `progress.py` HEADLINE (926M/day at 10-20T17Z). ## Lane / contract fs-regress (P1, two-lane rollout swarm 10-20), on behalf of the `firestore-reads` loop (work items WQ8, WQ3, WQ1 → WQ10). ## Product invariants affected INV-MEM-4: path match only. The lever literal appears in a file under the INV-MEM-4 glob; no memory promotion, consolidation or intake behavior changes. `historical_scan_memo` and the other memory-path levers keep their current values. ## Verification - `backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST` = `test_render_backend_runtime_env.py`, `test_verify_pusher_config_references.py`, `test_firestore_read_levers.py`, `test_fsr_s2_singleton_loops.py`, `test_fsr_wq3_queue_age_budget.py`, `test_fsr_s4_caches.py`: 70 passed (unit layer). - Precondition from the loop runbook for any `singleton_loops` enable: `FSR_QUEUE_AGE_PUBLISHER=1` in prod listen values, and `omi_queue_oldest_ready_age_seconds` present on listen (200 series) and Cloud Run (490) at 10-20 18:30Z (in-cluster Prometheus, `ro-prod`). - Not run: any deploy. Live effect is measured by the loop after the lead's train. ## Rollback Each lever is its own kill switch. `set_levers.py` with the previous literal (`usage_month_cache` 5, `queue_age_sample_budget` 5, `singleton_loops` 0), or revert this commit. The loop's hourly verify flags a lever off on a 5xx or lease breach. ## Deploy `FIRESTORE_READ_LEVERS` train order: **listen → pusher → Cloud Run** (the Cloud Run candidate check compares listen/pusher env against main). Ship together with or after the companion sync-GMP scrape PR, so the `singleton_loops` lease gate can see every holder. Owned by the rollout lead. Failure-Class: none 🤖 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/22929?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/22929?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F22929&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. -->
Git-on-my-level
added a commit
that referenced
this pull request
Oct 22, 2026
…canonical_statuses_dedupe 5->100 Firestore reads loop graduates (ramp5 clocks from 2026-10-21 ~23:20Z on backend-02083-stk; verify PASS on consecutive hourly ticks incl 14Z/15Z/16Z 2026-10-22): mcp_conversation_cards_cache 5->100, canonical_statuses_dedupe 5->100; singleton_loops 25->100 (lease rework #22142 live; all 6 loops acquiring, no max_hold fires 10-21..10-22). memory_list_index_window stays 25 (ramped 5->25 by #23310 on main for mobile Memories timeouts; graduation deferred). Literal via set_levers.py (REPLACE mode, complete 16-key object) on origin/main 8cd2c27; contract tests 121 green (test_render_backend_runtime_env + test_verify_pusher_config_references).
2 tasks done
Git-on-my-level
added a commit
that referenced
this pull request
Oct 22, 2026
…canonical_statuses_dedupe 5->100 (#23291) ## Summary Firestore reads loop config: graduate the proven levers on the served 16-key literal. - `mcp_conversation_cards_cache` 5 -> 100 - `canonical_statuses_dedupe` 5 -> 100 - `singleton_loops` 25 -> 100 - `memory_list_index_window` stays 25 (ramped 5->25 by #23310 for mobile Memories timeouts; graduation deferred, not part of this batch) Qualification: ramp5 clocks started 2026-10-21 ~23:20Z on train P (backend-02083-stk); verify PASS on consecutive hourly ticks including 14Z/15Z/16Z on 2026-10-22 (no lever UNSAFE/FALSIFIED on its pinned absolute grade). singleton_loops rides the #22142 lease rework: lease_1h shows all 6 loops acquiring (acquired 8-58/h each) with zero max_hold_exceeded across 10-21/10-22 ticks. Rebased on main 8cd2c27 (supersedes the stale head at 8a3e745 whose Backend Unit shard 2/6 failure test_sync_silent_failure.py::test_app_keeps_wals_retryable_on_failed_reconcile was main's red, fixed by the 13:58Z dream revert 9b9dcd3). Literal regenerated with set_levers.py (REPLACE mode, complete 16-key object); contract tests 121 green. ## Product invariants affected - INV-FSR-LEVERS: FIRESTORE_READ_LEVERS literal identical across _base.yaml, runtime_env.yaml, listen/pusher dev+prod values (contract tests pin consistency) - INV-FSR-SINGLETON: singleton_loops at 100 only while lease gate shows acquisitions and no max_hold breaches; flag-off config PR is the rollback - INV-MEM-4: config-only change to runtime_env rendering (levers cache percentages); no canonical-memory intake/promotion route is added or altered ## Test plan - [x] backend/tests/unit/test_render_backend_runtime_env.py + test_verify_pusher_config_references.py (121 passed) - [x] verify.py hourly ticks 14Z-16Z 2026-10-22 PASS (pinned absolute grades, FSR_SMOOTH_HOURS=12)
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.
Summary
Firestore reads loop work queue WQ1 + WQ3, shipped dark (every new path is behind a default-off lever or the already-off
singleton_loops; zero prod behavior change until the loop's config PR).WQ1 — singleton lease fail-open rework (
backend/utils/other/fsr_leader_lease.py,backend/main.pyloop region):singleton_loopswas flagged OFF in prod (#22071) after the 2026-10-17 19:00–21:00Z fleet-wide acquisition starvation across two revision rolls. This rework makes the lever's worst case equal to lever-off so it can be re-ramped:fail_open_localfamily).FSR_QUEUE_AGE_PUBLISHER) handoff semantics unchanged. Author root-caused via read-only prod telemetry: sustained skips + revision churn + isolated Redis errors; existing metrics cannot fully distinguish mutex poisoning from ownership rejection, so the fix covers all mechanisms (honest bounds in the report).WQ3 — queue-age sampling budget (
backend/database/durable_queue_age.py):_sample_status_pagere-scans the whole ready set every publisher tick — measured 73.93M reads/day (backend-sync 71 pods + backfill 5 + backend 4 at 300s ticks; reconciled from snapshot2026-10-18T05:00:38Z,durable_queue_age:_sample_status_page≈74M/day onusers/memory_outbox). New default-off leverqueue_age_sample_budget: 300s per-pod publish cache (FSR_QUEUE_AGE_MIN_PUBLISH_SECONDS) + first-page early-stop once the observed oldest ready age exceeds the alert threshold (21,600s). Semantics preserved: capped/malformed scans still omit the key (unknown, never 0); small ages still require exhaustive scans; above-threshold ages may be lower bounds; freshness lag ≤600s + scan time, with stale-publication telemetry. Integrator action before enabling: addqueue_age_sample_budgettoKNOWN_LEVERS.Product invariants affected
none — no invariant registry path is touched (
fsr_leader_lease.py,main.pyloop region,durable_queue_age.pyare not listed on any locked invariant; no config values change in this PR).How it was verified
test_fsr_s2_singleton_loops+ 8 recovery + 3 real-Redis Lua) viaBACKEND_UNIT_TEST_FILE_LISTthroughbackend/test.sh; zcode glm-5.3 review SAFE (exec-flush-position-logic-lion-figure-force) — all six author claims re-verified against the diff, reviewer independently re-ran the tests, launch environment checked (uvicorn 0.30.5, Dockerfile CMD), no real findings; 2 minors documented (getsignal-None hardening unreachable under the pinned launch; new skip labels double-count onsum by (loop)dashboards — flag to dashboard owners).BACKEND_UNIT_TEST_FILE_LIST; zcode glm-5.3 reviewexec-cable-van-shiver-multiply-meat-three(SAFE — all five claims verified, reviewer re-ran the 126 tests, no code fixes; integrator actions: addqueue_age_sample_budgetto KNOWN_LEVERS, wire freshness verification before enabling).Tests
test_fsr_wq1_lease_recovery.py), real-Redis Lua CAS/fencing (test_fsr_wq1_lease_lua.py), wedged-holder fail-open, SIGTERM release, lever-off equivalence (extendedtest_fsr_s2_singleton_loops.py).test_fsr_wq3_queue_age_budget.py).UI evidence
UI-Evidence: none — backend-only change, no user-facing surface.
Failure class (fixes)
Failure-Class: none
Rollout
Dark by construction: no
FIRESTORE_READ_LEVERSvalue changes here. The loop's later config PR (a) addsqueue_age_sample_budgettoKNOWN_LEVERS+ re-rampssingleton_loopsat 5% per the ramp5 rule (3h soak, lease-gate PASS), and (b) only then ramps WQ3's lever. Merging this PR does not start any deploy train; backend Cloud Run will pick it up with the next regular train.