Skip to content

perf(firestore): default the unread list projection writer off - #24240

Merged
Git-on-my-level merged 2 commits into
mainfrom
lane/fswrites-list-projection-off
Nov 1, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
lane/fswrites-list-projection-off

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Decision PR for the rollout lead (bus 65693f / 941502). It turns the list-projection writer (#23394) off by default until its reader ramps.

Measured by the write probe (#24218) on 2026-11-01 (Sunday, 15-minute window scaled per day), the list-projection version and row writes are:

  • Cloud Run: 1.87M/day, 13.6% of all Cloud Run writes.
  • Listen: 2.11M/day, 45.7% of listen's writes.
  • Pusher: not on the probe yet.

So that is ≈4.0M writes/day, about $5.5/day on a Sunday and likely $8-10 on weekdays (weekday volume ran about 1.9x). Every conversation update carries one version write and one row write. On listen, for example:

  • update_conversation_segments: 0.38M source / 0.38M version / 0.33M row per day.
  • update_conversation_finished_at: 0.33M / 0.33M / 0.33M per day.

Nothing reads them:

  • OMI_LIST_VERSION_EPOCH is empty everywhere. Its ramp (owner: two-lane lead, due 2026-10-24) never started.
  • utils/list_version_check.py and the MCP card reader in database/released_memory_projection.py both require the epoch.
  • No code reads the *_list_rows collections.

Change:

  • config/list_projection.writer_enabled() and the matching read in released_memory_projection.py now default to false. Explicit true still turns the writer on.
  • A code default reaches every writer process (Cloud Run, listen, pusher, workers, jobs) in one place. A per-service env would need a dozen declarations to stay consistent.
  • Registry entry: rollout, default off, owner two-lane lead, review_by 2026-11-15.
  • Ramp plan in the registry:
    1. Set true on every writer service and revision.
    2. Wait until no revision without it serves.
    3. Run the existing epoch ramp (5% → 100%).
    4. If the reader ramp is dropped, remove the writer.

Catch-up on re-enable (lead d8fd89 / 12:48Z conditions)

Stale rows and versions never serve:

  • Versions. A version is a random token in the list ETag scope, which also includes the epoch. While the writer is off, ListVersionCheck.start returns before reading any version, whatever the epoch. The new test covers this for both families, with and without an epoch.

  • Re-enable order:

    1. Set the writer true on every writer service.
    2. Wait until no revision without it serves.
    3. Set a fresh OMI_LIST_VERSION_EPOCH.

    A fresh epoch changes every ETag, so a validator issued before or during the gap can never match. The first conditional request after the new epoch reads the source and issues a new tag. Existing coverage: test_list_projection.py "new-rollout-after-writer-gap" asserts 200 after a gap.

  • Rows. *_list_rows are a migration substrate that no code reads, and a partial legacy update can never mark a row ready. Any future row reader must backfill or prove coverage after a writer gap. Re-enabling alone does not make them complete.

Would the epoch reader save more reads than these writes cost?

Not shown, and not measurable today:

  • Read-probe origins in a Sunday hour: /v1/conversations 758k, /v1/dev/user/action-items 602k, /v1/action-items 236k. That is about 38M reads/day, about $17/day at $0.461/M.
  • That is the ceiling, reached only if every list GET were conditional and unchanged. Each conditional request also adds one version read.
  • No Dart client sends If-None-Match. With the epoch empty, /v1/conversations emits no lp0 tag for HTTP caches to revalidate.
  • The writes cost about $5.5 on a Sunday and $8-10 on a weekday whether or not any of that saving appears.
  • To measure it before any ramp, this PR adds omi_list_conditional_requests_total{origin, validator} (3 origins × present/absent). If the present share on these routes is high, the ramp case can be made with numbers.

Product invariants affected

Verification

All runs used backend/test.sh under bin/omi-heavy + nice -n 19, at the unit layer:

  • test_list_projection (20), test_memory_change_head (50), test_released_memory_projection (27), test_conversation_smart_merge_audit_sdk (26), and the other files that reference the projection collections or installer: all pass.
  • Tests that assert projection writes now set OMI_LIST_PROJECTION_WRITER_ENABLED=true explicitly.
  • scripts/check_feature_flag_registry.py: OK.

Live check after deploy: omi_firestore_billed_writes_total{collection=~"users/(list_serving_versions|conversation_list_rows)"} goes to ~0, and fleet write_count drops by about the same amount.

Rollback

Set OMI_LIST_PROJECTION_WRITER_ENABLED=true fleet-wide, or revert.

Failure-Class: none

🤖 Generated with Claude Code

With OMI_LIST_VERSION_EPOCH never set, nothing reads the list projection
rows or versions, yet the writer added a version and a row write to every
conversation/action-item commit: ~4.0M writes/day on 2026-11-01 (write
probe; 1.9M Cloud Run + 2.1M listen, pusher unmeasured). Default it off;
turning it back on is a fleet-wide flip before the epoch ramp (registry).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

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 ⚠️ Failed 2026-11-01T12:47:47.648164Z
We couldn’t complete this review. Comment @codex review to try again.
2815434 PR opened
ℹ️ 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

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@cubic-dev-ai cubic-dev-ai 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.

2 issues found across 8 files

Confidence score: 4/5

  • backend/docs/list-serving-projection.md still says the writer is enabled by default, which could lead operators to follow incorrect rollout or rollback steps. Update the guide to match the new default-off behavior.
  • backend/database/released_memory_projection.py treats an empty OMI_LIST_PROJECTION_WRITER_ENABLED value as enabled, so declaring the variable without a value can turn the writer on unexpectedly. Parse only explicit enabled values as true.
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/database/released_memory_projection.py">

<violation number="1" location="backend/database/released_memory_projection.py:162">
P3: An empty `OMI_LIST_PROJECTION_WRITER_ENABLED=` is treated as enabled, while unset is treated as disabled. The default-off intent breaks if the variable is ever declared with an empty value. Consider parsing an explicit truthy set (for example `in {'1', 'true', 'on', 'yes'}`) so only explicit opt-in enables the writer and reader. Apply the same change in `config/list_projection.py`.</violation>
</file>

<file name="backend/config/list_projection.py">

<violation number="1" location="backend/config/list_projection.py:14">
P2: The deployment guide still tells operators that the writer is on by default, contradicting this new default-off behavior. Update `backend/docs/list-serving-projection.md` so rollout and rollback instructions describe the writer as off until the fleet-wide enablement and reader epoch ramp.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

# (fswrites, 2026-11-01): with no reader, the version and row writes were
# ~4M Firestore writes/day that nothing read. Turning the writer back on is a
# fleet-wide flip followed by full writer convergence before any epoch is set.
return os.getenv('OMI_LIST_PROJECTION_WRITER_ENABLED', 'false').strip().lower() not in {'0', 'false', 'off'}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The deployment guide still tells operators that the writer is on by default, contradicting this new default-off behavior. Update backend/docs/list-serving-projection.md so rollout and rollback instructions describe the writer as off until the fleet-wide enablement and reader epoch ramp.

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/config/list_projection.py, line 14:

<comment>The deployment guide still tells operators that the writer is on by default, contradicting this new default-off behavior. Update `backend/docs/list-serving-projection.md` so rollout and rollback instructions describe the writer as off until the fleet-wide enablement and reader epoch ramp.</comment>

<file context>
@@ -7,4 +7,8 @@
+    # (fswrites, 2026-11-01): with no reader, the version and row writes were
+    # ~4M Firestore writes/day that nothing read. Turning the writer back on is a
+    # fleet-wide flip followed by full writer convergence before any epoch is set.
+    return os.getenv('OMI_LIST_PROJECTION_WRITER_ENABLED', 'false').strip().lower() not in {'0', 'false', 'off'}
</file context>

conversations = len(parent) == 3 and parent[2] == 'conversations' and surface == 'mcp_cards'
card_coverage = bool(os.environ.get('OMI_LIST_VERSION_EPOCH', '').strip()) and os.environ.get(
'OMI_LIST_PROJECTION_WRITER_ENABLED', 'true'
'OMI_LIST_PROJECTION_WRITER_ENABLED', 'false'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P3: An empty OMI_LIST_PROJECTION_WRITER_ENABLED= is treated as enabled, while unset is treated as disabled. The default-off intent breaks if the variable is ever declared with an empty value. Consider parsing an explicit truthy set (for example in {'1', 'true', 'on', 'yes'}) so only explicit opt-in enables the writer and reader. Apply the same change in config/list_projection.py.

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/database/released_memory_projection.py, line 162:

<comment>An empty `OMI_LIST_PROJECTION_WRITER_ENABLED=` is treated as enabled, while unset is treated as disabled. The default-off intent breaks if the variable is ever declared with an empty value. Consider parsing an explicit truthy set (for example `in {'1', 'true', 'on', 'yes'}`) so only explicit opt-in enables the writer and reader. Apply the same change in `config/list_projection.py`.</comment>

<file context>
@@ -159,7 +159,7 @@ def projected_stream_list(query: Any, budget: Any = None, *, surface: str, _sour
         conversations = len(parent) == 3 and parent[2] == 'conversations' and surface == 'mcp_cards'
         card_coverage = bool(os.environ.get('OMI_LIST_VERSION_EPOCH', '').strip()) and os.environ.get(
-            'OMI_LIST_PROJECTION_WRITER_ENABLED', 'true'
+            'OMI_LIST_PROJECTION_WRITER_ENABLED', 'false'
         ).strip().lower() not in {'0', 'false', 'off'}
         eligible = (
</file context>

…unt list validators

Lead conditions for #24240: a test that readers never consult a version
with the writer off (epoch empty or set), and sizing for the epoch reader.
Add omi_list_conditional_requests_total{origin,validator} so the share of
list GETs that could ever be answered 304 is measured before any ramp.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit d9f5804 into main Nov 1, 2026
64 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/fswrites-list-projection-off branch November 1, 2026 14:42
Git-on-my-level added a commit that referenced this pull request Nov 1, 2026
…tay in the doc (#24251)

## Summary
Stops every audio, transcription and lifecycle PR from editing the same
8,791-line doc.

`backend/AGENTS.md` told every audio, transcription,
conversation-lifecycle, speaker or listen/pusher change to update
`backend/docs/listen_pusher_pipeline.mdx` in the same PR. Between 10-18
and 11-01:
- **165 fleet PRs** edited that file;
- **77 of them had to merge `main` back in**, and each catch-up re-ran
the pre-push gate and a full CI cycle (shipspeed baseline, conflict hot
spots).

The new rule:
- **Change notes** (what changed, why, rollout and flag state, evidence)
go in
`backend/docs/listen_pusher_pipeline/changes/YYYY-MM-DD-<slug>.md`, one
new file per change. Concurrent PRs never touch the same note.
- **Contracts stay in the pipeline doc**: env vars and defaults, wire
and payload fields, ordering and idempotency guarantees, sequence
diagrams. Tests (for example `tests/unit/test_vad_cache_ttl_config.py`)
and the flag registry cite that file, so contract edits still happen
there.
- Notes are folded into the doc periodically by one docs-only PR.

The `backend/AGENTS.md` rule is shortened to stay inside its
`agents-md-lean` byte budget; the detail lives in `changes/README.md`.

## Rollout / merge notes
- Docs and agent instructions only. No runtime, workflow or deploy
change.
- **Merge after the 23:00Z train** (lead 9a266d): five vroute lanes and
#24238/#24240 are editing the pipeline doc today.

🤖 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/24251?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/24251?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24251&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