Skip to content

config: repair Firestore read train scopes and start people dedupe at 5% - #23797

Merged
Git-on-my-level merged 3 commits into
mainfrom
lane/firestore-reads-flagoff-wq25-1027
Oct 27, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
lane/firestore-reads-flagoff-wq25-1027

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Summary

Firestore read config train: disable memory_list_index_window (100→0) and batch_privacy_memoize (100→0), and start people_scan_dedupe at 5% after writer fencing #23733. The prior read loop graded the first two levers flat/WEAK or FALSIFIED; turning them off is not a measured dollar saving. No source query, authority, transcription, speaker, price, Free benefit, or audio-retention behavior is changed here.

Every declaration is a complete 19-key replacement JSON literal. finjob_candidate_queries stays at 5. All four production Cloud Run service overrides now carry the same three changes as listen/pusher; they previously masked them.

Monthly-total enable/epoch split — explicit, no scope expansion

Surface usage_month_total FSR_USAGE_MONTH_TOTAL_EPOCH
Prod backend, backend-sync, backend-sync-backfill, backend-integration 100 c2fs_20261026_r1
Base, listen/pusher (dev and prod), jobs, desktop backend, all dev services 0 v1

This preserves the existing qualified Cloud Run reader scope. The inherited PR accidentally copied the Cloud Run 100 literal into previously disabled surfaces while retaining v1. That expansion is removed. Disabled readers cannot initialize/re-stamp ready totals. Epochs are not made globally identical by enabling unqualified readers.

Declarations: backend/deploy/runtime_env/_base.yaml, prod.overlay.yaml, four listen/pusher chart values; generated runtime manifest and registry remain synchronized. The regression test checks complete literals, effective Cloud Run rendering, both chart environments, and the enable/epoch split.

Product invariants affected

Verification

  • Focused suite through backend/test.sh, BACKEND_UNIT_TEST_FILE_LIST naming test_render_backend_runtime_env.py and test_verify_pusher_config_references.py, BACKEND_PYTEST_WORKERS=4, under nice / omi-heavy. 119 passed on the final repair (91 renderer/scope + 28 pusher binding tests).
  • make preflight: 44 passed; normal pre-push gates passed, including both-environment runtime validation and type checking (0 errors). Final pushed head: 52661d092a9c07ff5454f627aa0268037edc6b85; 60 terminal green checks, 0 pending/failed/cancelled, independently checked at 10:50Z on 10-27; all 12 workflow runs completed successfully.
  • Luna's first round found a stale linked monthly-total runbook and a missing-declaration skip in the new test. Both are corrected; same-session delta returned SHIP. Review execs: exec-corn-celery-front-snack-genuine-quiz and exec-cement-normal-thank-shoe-live-magnet.
  • No production reads, writes, applies, merges, or deploys needed for this repair. Config rendering is the measured layer; no live-product acceptance or realized savings claimed.

Lead-owned ship/ramp plan

  1. After the batch entry/soak ends (~11:30Z on 10-27) and lead admission, ship listen → pusher → Cloud Run. Read back actual serving artifacts plus complete per-surface literal/epoch before each next step. All changes remain source-only until the lead ships them.
  2. Keep people at 5. Start its clock only after the last relevant surface serves the config. Hold ≥3 hours and two clean evaluator ticks; require no privacy/deletion violations, speaker/transcript/Free-benefit changes, 5xx or live-p95 regression. Lead expands people to 100 with complete literals on the same surfaces, targeted by 10-28 12:00Z; record a blocker if gates fail. Kill switch: people→0 everywhere applicable, preserving all other keys and the monthly split.
  3. Additional monthly-total scope is a separate qualification. By 10-28 12:00Z, lead attests every actual writer/revision/job/operator path, drains old writers, then aligns new readers to c2fs_20261026_r1 while still at 0 before considering 5. Otherwise record the qualification blocker and leave them off. After two hours with zero synthetic equivalence mismatches and no accounting/Free allowance, contention, 5xx or p95 regression, lead may expand the qualified scope to 100 by 10-29 12:00Z. Never enable a v1 reader against shared production totals. This PR does not enact that expansion.
  4. Monthly-total rollback: readers→0, maintenance stays on. If an old writer runs, keep readers off until all writers qualify and choose a new common epoch before re-enabling. See backend/docs/monthly-usage-totals.md.
  5. Compare absolute caller reads and replacement reads/writes/seed scans against 10-24/25; confirm D+1 billing export before booking net dollars. Realized savings from this repair: $0.

Lead picks up URL, exact head, MERGE READY state and evidence from data/run-2026-10-12-subscription-overhaul/reports/fsown-owner-1027.md; no lead-bus post. Merge/deploy/apply remain with the Infra Rollout Coordinator.

…rify FALSIFIED x4 / WQ21 blocked audit), enable people_scan_dedupe 0->5 (WQ20 served)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 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-27T10:40:43.374874Z 52661d0 New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a6980c09f2

ℹ️ 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".

Comment thread backend/deploy/runtime_env/_base.yaml Outdated
value: '1'
FIRESTORE_READ_LEVERS:
value: '{"action_items_page":100,"backfill_task_reads":100,"batch_privacy_memoize":100,"candidates_page":100,"canonical_statuses_dedupe":100,"deletion_marker_cache":100,"finjob_candidate_queries":5,"historical_scan_memo":100,"ledger_purge_coalesce":100,"mcp_conversation_cards_cache":100,"memory_list_index_window":100,"people_scan_dedupe":0,"queue_age_sample_budget":100,"request_read_dedupe":100,"serving_config_cache":100,"singleton_loops":100,"subscription_cache":100,"usage_month_cache":100}'
value: '{"action_items_page":100,"backfill_task_reads":100,"batch_privacy_memoize":0,"candidates_page":100,"canonical_statuses_dedupe":100,"deletion_marker_cache":100,"finjob_candidate_queries":5,"historical_scan_memo":100,"ledger_purge_coalesce":100,"mcp_conversation_cards_cache":100,"memory_list_index_window":0,"people_scan_dedupe":5,"queue_age_sample_budget":100,"request_read_dedupe":100,"serving_config_cache":100,"singleton_loops":100,"subscription_cache":100,"usage_month_cache":100,"usage_month_total":100}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Update the production Cloud Run overrides with the new levers

For production Cloud Run, this base edit is overridden by the unchanged FIRESTORE_READ_LEVERS literals in backend/deploy/runtime_env/prod.overlay.yaml at lines 456, 776, 1140, and 1476. The generated manifest consequently still sets batch_privacy_memoize:100, memory_list_index_window:100, and people_scan_dedupe:0 for backend, sync, backfill, and integration (lines 2925, 3287, 3658, and 4015). Deploying this commit therefore leaves the two intended kill switches on and never starts the people-scan cohort on those production services, while GKE receives different settings. Update the production overrides and regenerate the manifest so the rollout reaches those services, as required by the backend runtime-env alignment contract.

AGENTS.md reference: backend/AGENTS.md:L157-L157

Useful? React with 👍 / 👎.

@Git-on-my-level Git-on-my-level changed the title config: flag off memory_list_index_window + batch_privacy_memoize (verify FALSIFIED), enable people_scan_dedupe 0->5 (WQ20 served) config: repair Firestore read train scopes and start people dedupe at 5% Oct 27, 2026
@Git-on-my-level
Git-on-my-level merged commit e260615 into main Oct 27, 2026
64 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/firestore-reads-flagoff-wq25-1027 branch October 27, 2026 13:07
Git-on-my-level added a commit that referenced this pull request Oct 27, 2026
)

## Summary

During the 10-22/25 Firestore surges, maintenance scans multiplied
across replicas; the 10-25 spike followed a lever rollback. The 10-22
exact revision trigger remains unproven. Day-aligned counters attribute
576M and 510M extra reads to the queue sampler and three finalization
sweeps, rather than sync-job redrive processing. Keep the existing
maintenance admission lease on by default in production independently of
the `singleton_loops` cohort, with
`FSR_MAINTENANCE_COORDINATION_ENABLED=false` as the explicit
coordination kill switch.

Redis keys/Lua, scan cadence, takeover bounds, local recovery on Redis
failure, transactional job claims and designated queue publisher are
unchanged. Non-production, including stage-prod staging, retains legacy
cohort qualification unless explicitly overridden. Other Firestore
levers retain their current behavior. No runtime-env/config literal,
index, workflow, account-data or retention changes.

This is a recurrence guard: current singleton100 already coordinates
production, so steady-state new realized savings are **$0**. Comparable
observed scanner regrowth is about $219–271 per incident at
$0.43–0.47/M; recurrence frequency and monthly avoided spend are
unknown. WQ21 privacy memo and WQ24 funded aggregate shortcuts are
excluded because their correctness gates did not pass; WQ22 is already
in #23686. No partial authorization/quota cache ships.

## Validation

-
`BACKEND_UNIT_TEST_FILE_LIST=/Volumes/Ephemeral/scratch/fsown/scan-tests.txt
BACKEND_PYTEST_WORKERS=4 nice -n 10 bash backend/test.sh`, through
workspace `bin/omi-heavy`: 68 passed across the scan-storm guard,
existing singleton/recovery and Redis Lua suites.
- Real queue sampler with five replicas and ten ticks: 1000 document
reads with coordination explicitly off, 200 with it on, with the same
empty legacy lever literal. Fixed-loop tick, fail-open, publisher
eligibility and takeover tests pass.
- Feature flag registry check passed; Full `make preflight`: 36 checks
passed (366.85s). Exact-head CI is verified separately before MERGE
READY.
- Independent Luna full-diff review through agentctl found staging uses
stage prod; corrected production detection and added staging/preview
regression profiles. Existing-session Luna delta **SHIP**, no new
actionable findings (`exec-yard-device-motion-guard-episode-voyage`,
continuation key `fsown-luna-delta-1027a`).

## Ship and rollback (lead only)

No merge/deploy/apply by this lane. No apply request during the batch
entry/soak through ~11:30Z. Lead deploys source in its allowed train,
first verifying healthy designated `FSR_QUEUE_AGE_PUBLISHER=1` and fresh
queue-age samples. Compare lease outcomes, finalization recovery/queue
freshness, errors and live p95 before/after; verify the runtime-reported
release SHA for each serving artifact. Setting
`FSR_MAINTENANCE_COORDINATION_ENABLED=false` via the regular lead-owned
runtime procedure restores prior per-replica execution and can raise
spend. See `backend/docs/runbooks/firestore-spend-guard.md`.

#23797 remains owned by the lead and untouched. Finjob5→100 requires a
separate complete-literal lead config change after soak; READY index
metadata alone is not a production apply.

## Product invariants affected

none

## Failure class

Failure-Class: none


## CR train #2 integration (2026-10-27)

Merged `origin/main` at `8da0ca9e1b7867cb9719a33225c3d9371713356a` into
`lane/fsown` with merge commit
`eb963fcfca4106bdc8c718f7c308624116c3034a`; no rebase or force-push. The
two conflicts were documentation/registry additions: retain fleet
coordination and main's server-batch documentation, new batch flags and
newer default-off Soniox idle-reselect declaration; regenerate the
registry. No production-code conflict. #23797's scoped literals and
#23803's metrics collector remain identical to main.

Affected tests through `backend/test.sh`, explicit nine-file
`BACKEND_UNIT_TEST_FILE_LIST`, `BACKEND_PYTEST_WORKERS=4`, under `nice`
/ `omi-heavy`: **458 passed**, one slow test deselected by the standard
harness. Final exact-head CI and `mergeable,mergeStateStatus,headRefOid`
are recorded in `reports/fsown-owner-1027.md`. Lead retains
merge/deploy/apply authority.
Git-on-my-level added a commit that referenced this pull request Oct 27, 2026
## Summary

Retain two unsuperseded structural Firestore query optimizations from
orphan #23442; merge current main into the existing lane history. The
public-catalog and request-cohort cache changes are removed. No query
policy, transcription, speaker labels, Free benefits, legacy price,
raw-audio custody or authority checks change.

- **Smart merge:** use the declared device composite only for
explicit-device, unbounded discarded-barrier lookups. Keep the global
finite six-row predecessor window, missing/empty-device behavior,
deleted barriers, transaction snapshot and unrelated-error propagation.
Missing-index errors fall back to the original query. Device or citation
IDs exceeding 1,500 UTF-8 bytes keep their original scans because
Firestore truncates indexed field values; no new identifier input
restriction is introduced.
- **KG pruning:** query native `memory_ids` reverse citations for at
most **30 distinct IDs** before mutations. Larger retractions keep one
original full scan so overlapping chunks cannot amplify billed reads.
Retain the full surviving-node and orphan-edge cleanup, including
unrelated dangling edges. No side collection, backfill or new
application writes.
- Independent switches default on; `FSR_SMART_MERGE_PARTITION=off` and
`FSR_KG_CITATION_INDEX=off` restore their original paths.
- Main's new donor rebasing, open-loop/retirement behavior, #23797's
scoped literals, #23801's maintenance guard and #23803's collector
changes are preserved.

## Four-part decision / economics

10-26 fleet caller data already captured in the fsown report; $0.43–0.47
per million reads × 30 days. These are **opportunity ceilings, not
forecasts or booked savings**.

| Original part | Observed caller reads/day | Monthly evidence | Result
|
| --- | ---: | --- | --- |
| Smart-merge device barrier | 16,749,388 | Entire pool $216.07–236.17;
upside capped at $236.17, eligible barrier fraction/off-device
selectivity unknown | KEEP; main still scans broadly then filters device
in Python |
| KG reverse citations | 8,915,616 | Entire pool $115.01–125.71;
first-scan-only upside capped at $62.86. Fixture-equivalent $55.83–61.02
only if its graph shape holds fleet-wide | KEEP; main still performs the
first full node scan; bulk traffic remains legacy |
| Public catalog single-flight | 1,538,759 | Entire pool only
$19.85–21.70; incremental miss coalescing unmeasured; $0 assigned |
DROP; main already has 30s list single-flight and 600s Redis backing;
limited upside does not justify extending shared-cache dependency |
| Request cohort snapshot | 2,616,546 (old + renamed callers) | Entire
pool $33.75–36.89; $0 additional assigned | DROP; main already shares
observations and clamps their original 60s deadline, while this request
memo did not recheck expiry |

Retained gross upside cap **$299.03/month**, not a point forecast.
Composite storage, empty-query floors, fallback overhead and the actual
request/graph mix remain unmeasured; net savings may be zero or
negative. **New verified/realized savings: $0**, until lead serving plus
D+1 net billing against the 10-24/25 baseline.

Track old and new callers together:
`smart_merge:find_preceding_conversations` → `smart_merge:collect`
(including unchanged finite reads);
`knowledge_graph:prune_memory_citations_from_kg` plus
`knowledge_graph:_citation_nodes`. New origins are
`task:smart_merge_partition_lookup` and `task:kg_citation_prune`. Caller
renaming is not saving.

## Integration and validation

- Merge commit `f923e4862f1240b52c429f5705f091558f2a90f3` parents:
existing PR head `789db126e73be7c01465af90e4f7f5277c3fce56` and main
`5f2caea10a67fcd2dbc52347aff08c9f0ac5fdab`. Follow-up
`f240ea8dbe01b2f061fbbb9aa5ce56be6f75070c` caps bulk KG reads. Final
source `4174839ab5f0c0bc06eda0a4e81b96b66931980a` preserves scans for
identifiers beyond index bounds, with ASCII and multibyte boundary
tests. No rebase/force-push/stash. Original divergent local lane work is
preserved.
- **1,019 passed**, one standard slow deselection, across an explicit
14-file list through `backend/test.sh`, `BACKEND_UNIT_TEST_FILE_LIST`,
`BACKEND_PYTEST_WORKERS=4`, `nice -n10` and `omi-heavy`. Includes all
seven Firestore guards, offline SDK query serialization,
global-window/deleted-barrier/transaction fallback, finalizer/donor
integration, identical KG cleanup, and bulk read non-amplification.
- Synthetic mechanisms: indexed barrier 121→1 returned rows with the
same relevant barrier; KG 206→106 reads with identical final graph; bulk
KG remains 4→4 reads. None establishes fleet savings.
- Own Luna review: SHIP on f240; final index-bound delta review and
normal pre-push/CI receipts are tracked at the top of
`reports/fsown-owner-1027.md` before MERGE READY.

## Lead-owned index / ship gate

A ro-prod **metadata-only** check found 221 composites and **no matching
device index**. The lead must clear the standard additive index prebuild
auth/environment approvals and verify
`conversations_smart_merge_device_preceding` READY before serving this
source. Production prebuild approval is a lead gate, not lane authority.
Do not ship through the missing-index fallback to bypass the readiness
gate. Native KG array-index availability also retains the standard
guard/fallback contract.

Once readiness and source CI are clean, the lead merges and ships
through its normal source train, watches missing-index/fallback/query
latency, smart-merge barrier equivalence, KG cleanup, 5xx and live p95,
and rolls either switch off on a regression. Compare matched caller
windows and D+1 total reads/writes/storage before booking dollars. This
lane performs no deploy/apply, prod write, approval or access change,
and does not close the PR.

## Product invariants affected

- INV-MEM-4 — graph pruning remains derived cleanup; privacy/deletion
authority and authoritative promotion/funding checks retain their
existing paths.

Line-Count-Exception: backend/database/firestore_index_registry.py |
2247 -> 2266 | Declare the partition query beside the original query in
the single index authority; preserve generated manifest ownership.

Failure-Class: FC-merge-across-discarded-rows
Git-on-my-level added a commit that referenced this pull request Oct 28, 2026
…: 5xx breach NOT lever-caused) (#23913)

## Summary

Firestore read config train — **revert of #23888** (the 2026-10-28
5xx-guard flag-off), per the lead's 2026-10-28T13:04Z ruling (bus
e54718) after the RCA in
`data/run-2026-10-13-two-lane-nemotron/swarm/state/refs/1028-audiomerge-rca.md`:
the backend-sync 5xx breach is **NOT lever-caused** — 100% of the
audio_merge 500s are `playback source manifest changed` in
`playback_identity.resolve_sources`, continuous for 2+ days across ~40
revisions with no lever in that path. This restores the exact pre-#23888
`FIRESTORE_READ_LEVERS` literal everywhere (git revert -m 1 of merge
d04e3ce, byte-identical restoration).

Restored to their prior values: `singleton_loops`, `usage_month_cache`,
`backfill_task_reads`, `historical_scan_memo`, `ledger_purge_coalesce`,
`people_scan_dedupe`, `queue_age_sample_budget` (all 100),
`finjob_candidate_queries` (5), `usage_month_total` (100 Cloud Run only
— monthly-total split restored, epochs unchanged). Unchanged from the
flag-off state: the eight SUPPORTED levers stay 100;
`memory_list_index_window` and `batch_privacy_memoize` stay 0 (verify
FALSIFIED, #23797).

## Monthly-total split — restored

`usage_month_total` returns to 100 on Cloud Run only with the qualified
`c2fs_20261026_r1` epoch declarations, exactly as qualified by the P3
owner (op1, bus 04:16Z 10-26). The flag-off had dissolved the split by
setting every reader to 0; this restores readers-on per the split
design.

## Product invariants affected

- INV-MEM-4 — keep privacy/deletion authority checks unchanged; this
restores previously reviewed cache/dedupe lever values to their
pre-flag-off state.
- INV-DATA-1 — existing configuration keys and data planes; no routing
or ownership change.

## Verification

- `git revert -m 1 d04e3ce` on origin/main fab07e2 — clean
auto-merge, 11 files, no drift on `backend/deploy/runtime_env*` or
`backend/charts` since d04e3ce (path-scoped log empty).
- Restored literal spot-check: 19 keys — 8 flagged levers back to 100,
`finjob_candidate_queries` 5, `usage_month_total` 100,
`memory_list_index_window` 0, `batch_privacy_memoize` 0.
- Focused suite + CI on this head (pending; same test pair passed at the
#23888 parent).

## Lead-owned ship plan

Per lead ruling e54718: if this revert lands **before** the paired25
listen roll, the flag-off is net zero deploy — the roll from the new
main tip carries the restored literal and the sealed excluded delta
(d04e3ce) is superseded. Train order unchanged (listen → pusher → Cloud
Run). Companion change: the loop's 5xx guard is being updated (workspace
repo `avo/firestore-reads/measure.py`) to exclude the
Cloud-Tasks-retried internal route `/v2/audio-merge-jobs/run` from the
5xx signal so this baseline noise cannot re-trip the guard.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/23913?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/23913?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23913&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. -->
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