Repository navigation
feat(batch): writer-generation fence + attempt-authorization memo for batch_pipeline_privacy (firestore-reads WQ26) - #23894
Merged
Conversation
…laration, reportAttributeAccessIssue in new fence files Type-level only: narrow Optional before .isoformat, rename inner wrapped in stacked decorators, import grpc Status from the correct module. Semantics unchanged; sync.py untouched. Focused: fence 56, memo 25. Pyright 0 errors.
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. |
Retain the sync account-deletion predicate alongside attempt scoping, the canonical absent-consent default, and the current batch admission/deadline and retention behavior. Refresh retry and emulator fixture seams for main. Cover absent consent and explicit opt-out across live/memo authorization.
Include the concurrent transcript/sync assignment integration at 814dd41 without rewriting published fence commits. Keep fence and memo semantics unchanged and verify the real assignment writer against the emulator again.
Git-on-my-level
added a commit
that referenced
this pull request
Nov 1, 2026
…guous commits Luna r1 P2: a Commit that applies but loses its response (DeadlineExceeded, Unavailable) was uncounted. Count those writes on a separate unlabelled omi_firestore_ambiguous_commit_writes_total so the main counters stay exact for known outcomes and the ambiguity is visible. op now separates merge (mask, no precondition: set(merge=True)) from update (exists=true precondition). Commit-boundary fences such as the batch privacy token (#23894) fence every upsert but not masked updates, so sizing them needs the split. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ites Luna (f773647) P2: sync assignment wrote private_cloud_sync_enabled (and any other unchanged authority field) into every update payload, so the commit-boundary fence rotated the owner's batch-privacy token even when nothing the privacy decision reads had changed. The assignment now omits an authority field whose value equals this transaction's read of the row. An update names only the fields it replaces, so the stored row is identical; a concurrent change aborts the transaction; a field absent from the row is never omitted (absent consent means enabled). A real authority change still rotates. The field set now lives once in batch_privacy_attempt and the fence uses the same object. P3: FirestoreTransaction.flush's 450-write budget now counts the one token write per owner that its record_lane_owner conversation patches add. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Advance a controlled admission clock at the selected dependency return, and assert that the selected boundary was reached before checking refusal and absence of a compute token. Keep the separate real executor timeout and partial-receipt test unchanged. This avoids assuming that all prerequisite executor stages enter within 50ms on a loaded shared host; correct early expiry previously failed worker cleanup.
…vacy fence Skip the new transport fence as probe plumbing and classify its bounded authority/token collections. Real SDK transport regressions cover atomic Commit and BulkWriter composition, original caller attribution, and one source write plus the added token. Collection labels drop synthetic owner/document IDs.
Git-on-my-level
added a commit
that referenced
this pull request
Nov 2, 2026
#24402) ## What changed and why Add measurement and after-live shadow comparisons for repeated privacy checks, plus default-off token-validated batch/session/negative reuse. Count checks, allow/block reasons, point reads, conversation walks and completed 60-second listen/pusher intervals. Labels and sampled mismatch logs contain no identifiers. Build on the writer-generation fence now merged in #23894: cover speaker-only consent changes and flattened BatchWrite arguments, reject implicit authority state loss before any RPC, and validate tokens against server revisions. Keep its shared authority-field export, unchanged-field suppression, write-budget reservation and regression coverage. Cache hints re-read durable authority on every decision; Redis invalidation alone never authorizes a negative. Transactional external fences and full-row snapshot consumers remain live. Nontransactional provider-STT retains the admission-write deferral from 1219b0e. No query/list or memory tombstone changes, deletion TTL increase, workflow change, deployment or flag flip. ## Product invariants affected No locked catalog paths are intentionally changed. Preserve account/data-plane authority, absent-cloud-consent-means-enabled, and transactional conflict sets. Line-Count-Exception: backend/routers/listen/runtime.py | 1505 -> 1509 | Attach census to the existing runtime and offload its two bounded lifecycle operations; implementation stays in its own module. Line-Count-Exception: backend/routers/pusher.py | 1891 -> 1893 | Import and apply session scope at the existing websocket entry; implementation stays in its own module. Line-Count-Exception: backend/utils/sync/pipeline.py | 3965 -> 3967 | Scope the shared coordinator entry so inline and Cloud Tasks jobs both participate in shadow; the attempt implementation stays in its own module. ## Verification and review status Tree: lane/ic-privacy, head de85db4 (integration 32b42d0 plus follow-ups). All tests use omi-heavy and nice -n 19. backend/test.sh with targeted file list: **571 passed** across writer, memo, privacy-contract, legal hold, tombstone, cache and listen regressions. Real loopback Firestore matrix: **49 passed**, including all writer families, mixed atomic/bulk state-loss refusal, stale purge finish and subtree erasure. Full hermetic listen/sync harness at the **default 120s budget: 185 passed, 3 skipped, 2 expected failures**. Emulator listener cleanup verified. Earlier local runs hit 120s, and one diagnostic 300s run had a CancelledError at the unchanged reconnect test's context exit before timeout. Its isolated default rerun and subsequent full runs passed. All failed receipts are retained; no checked-in timeout or skip changed. Integration also preserved every main-only test added by #23894. At integration 32b42d0, function/class ASTs across 10 privacy modules matched reviewed e962; two only added the shared constant/alias from main. The later follow-up changes counters and attempt entry scope, not live authority decisions or token validation. Luna rounds 1/2 found authority loss and a missing pusher census; corrected. Lead approval ee01ec authorized one final delta review of e962. Round 3 returned **FIX-FIRST** for a hypothetical raw purging=false update outside the canonical generation-checked finish API. Rebuttal: the only production purging=false write is inside transactional finish_privacy_purge, which compares generations; the real-emulator stale-finish test confirms an older finish cannot reopen a newer purge. An explicit raw authority change rotates the token and affects live policy identically with caching off; no stale memo survives it. The token hook does not decide whether a caller completed cleanup. Lead ruling **3c079e** accepted that scope rebuttal and authorized marking ready after exact-head CI is green. The formal Luna round-three verdict remains FIX-FIRST; it is not relabeled SHIP. **Boundary for future changes:** writes to generation/blocked/purging must stay inside the canonical generation-checked transactional authority APIs; any new raw-SDK state writer requires a fresh privacy review and ownership regression. Final-head backend CI is required after conflict repair; security-only checks on the conflicted e962 head are not that evidence. Cubic follow-up closes inline sync attempt coverage and counts cached deletion calls/decisions plus the artifact protection read. Targeted 198 tests and full default-budget hermetic harness (185 passed, 3 skipped, 2 expected failures) pass. Live decision/token validation logic is unchanged. The runbook now names the exact mismatch metric, the combined session lever's two-family baseline and rollback, transactional read boundaries and reproducible verification commands. Its fixed managed 30-second ceiling needs no runtime TTL knob. P3 lazy import cleanup and the pre-existing serial bulk Commit performance risk are tracked for infracost by 2026-11-03T12:00Z; measure bulk latency/contention before all-plane writer qualification, preserving per-item source/token atomicity and partial failure semantics. Pusher census was already fixed and tested in round 1. The pusher ticker now uses the WS-scoped task helper, interruptible stop event, bounded drain and fixed-message failure reporting. Its first complete interval includes setup; listen resets after bootstrap, so each has its own baseline. The backwards-clock regression is valid: subtracting two seconds from now changes age from threshold+1 to threshold-1. Shadow's extra live artifact protection read is deliberate and metered; infracost must include it in shadow economics. No GCP access, production account data or live vector/backfill operations. ## Default-off ramp and deployment order Owner: **infracost**; the rollout lead merges/deploys. Deploy **listen → pusher → Cloud Run serving writers** (backend, sync, backfill, desktop and other writers) **→ jobs/operator producers**. Qualify this final writer implementation everywhere, including speaker-only consent and flattened bulk coverage; #23894 alone is not the complete writer qualification. No new reader lever is enabled by this PR. Record each slice's own pre-ramp baseline. Enable privacy_checks_shadow across all planes for **at least 14 days**, with **zero unexplained privacy_decision_mismatch_total**, actual eligible hits, no unresolved shadow errors and the scope's 30% repeat-key hit-rate bar. Infracost owns expansion and the first enforcement decision is due **14 days after shadow reaches all planes**. After qualification, remove shadow before ramping bpp_generation_memo, legal_hold_fence_cache, and tombstone_negative_cache separately to **5% → PASS on two ticks → 100%**, against that slice's own baseline. privacy_session_token enables both external-fence and tombstone candidates in a session, even with the family levers off; grade it against both baselines and coverage, and roll it back on either family's regression. Shadow wins if both modes are present. Any unexplained mismatch blocks expansion. Rollback: new shadow/enforcement levers off restores the original live read sequence; mandatory writer tokens remain. The scope's **$45–58/day is an estimate**, not measured savings. Warm external fences may replace two authority reads with one token read; tombstones still pay a token read and cold candidates add reads. Do not book the original slice 3 savings. Include token writes/contention and vendor spend in the net readout. Redis-only zero-read reuse is excluded; strict writer fencing is a separate proposal requiring fault-injection evidence and measured/explicitly estimated savings. Details: backend/docs/runbooks/privacy-check-shadow.md. Tracking: https://anx.scalingforever.com/o/david-zhang/w/omi/r/card:session-privacy-counters-writer-tokens ## UI evidence UI-Evidence: none -- backend privacy checks only. ## Failure class Failure-Class: none
Git-on-my-level
added a commit
that referenced
this pull request
Nov 3, 2026
…ver manifest (#24455) ## What changed and why Sets `bpp_generation_memo:100` in `FIRESTORE_READ_LEVERS` everywhere the lever map is declared: listen and pusher chart values (dev and prod), the desktop backend, and every Cloud Run service and job in `runtime_env/_base.yaml` and `prod.overlay.yaml`. All other lever values are unchanged, including prod backend-sync's `usage_month_cache`/`usage_month_total` override. The rollout lead is setting the same value live on the serving services after train cost2-1103 (listen and pusher at fa73bb8). This PR makes the manifest match so the next deploy does not drop it. The memo stops `batch_pipeline_privacy` from re-reading privacy inputs on every task attempt. That caller is the largest Firestore reader at about 6.1M reads/h on backend-integration and backend-sync. Its writer fence (#23894) and follow-up (#24402) are on main and in the serving images. Expected saving (estimate): **-$28 to -$43/day**. It will be read back from the Firestore reads loop caller counter after the live set. Rollback: set `bpp_generation_memo` to 0 in the lever map (live env edit, no image change), or revert this PR. ## Product invariants affected - INV-MEM-4: not affected. The changed deploy manifest is a locked path, but only the Firestore read lever map changes; memory intake and promotion routes are untouched. - Privacy enforcement for batch units. The memo only reuses a decision for the same task-attempt generation, and the writer fence invalidates it when privacy inputs change (`backend/database/batch_pipeline_privacy.py`). Failed reads never publish partial decisions (`test_failed_reads_never_publish_partial_decisions`). No user-visible change. ## How it was verified - Manifest rewritten with the Firestore reads loop's `set_levers.py`, then `compose_runtime_env.py` and `render_feature_flag_registry.py --as-of 2026-11-02` regenerated the outputs. - `backend/test.sh` with `test_render_backend_runtime_env.py`, `test_verify_pusher_config_references.py`, `test_bpp_generation_memo.py` and `test_bpp_generation_fence.py`: 98 + 32 + 91 + 28 passed. ## Tests Updated pinned literals in `test_render_backend_runtime_env.py` (including the per-host expected map) and `test_verify_pusher_config_references.py`. ## UI evidence None (backend config only). 🤖 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/24455?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/24455?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24455&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. -->
YinkaAdepoju
pushed a commit
to YinkaAdepoju/omi
that referenced
this pull request
Nov 3, 2026
…ver manifest Sets bpp_generation_memo:100 in FIRESTORE_READ_LEVERS for listen, pusher, the desktop backend, every Cloud Run service and job (base and prod overlay), so the manifest matches the live lever the rollout lead sets and the next deploy does not drop it. The writer fence (BasedHardware#23894) and its follow-up (BasedHardware#24402) are on main and in the serving images. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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
Add a writer-generation fence and a task-attempt authorization memo for batch privacy checks. Authority writes rotate an opaque token in the same Firestore Commit; each authorizing transaction reads that token and its server revision before reusing a decision. The memo is bounded to 1024 entries and closes at attempt exit. Full-row snapshot consumers retain live reads.
The fence is always on in writer processes. The
bpp_generation_memoreader lever remains absent/off; this PR changes no runtime literal. Reader enablement requires a separate change after all writer services, revisions and maintenance producers converge on the fence. Same-document source/token writes need staging or an authorized production canary before broad rollout. Reader rollback: disable the lever. Writer rollback: disable all readers first, then revert the fence.Current main through
b3dc000c577b4fe5b1ebfab777f32bd040e71b9dis merged without rewriting history. The integration counts deferred outbox writes and owner-token writes together in the 450-write budget, preserves original write-probe caller attribution through the fence, and classifies authority/token collections using fixed labels. Keep the current sync account-deletion predicate, absent-means-enabled cloud-sync consent, repair retention rules and batch admission deadlines.Validation
2026-11-02 readiness refresh at
8a6ad3fc399d69a41da3ff41bcc6f90759f87cf1: three probe/fence files passed 210 tests; canonical hermetic E2E passed 185 tests, 3 skipped, 2 expected failures with the documented 300s local outer budget. Original nine-file coverage passed 241 distinct cases across the initial run and focused admission rerun. The parameterized late-return test now advances a controlled clock at the selected dependency boundary; the existing real-executor timeout test remains unchanged. All checks use the repository harness under omi-heavy/nice 19. Fresh normal pre-push, CI and Luna delta review remain gates before recommendation.Latest integration head
60c535f28547c73e7e410ae5ce971b5263fb6d7aadditionally merges main's Pinecone qualification change cleanly; the two affected migration/fence files passed 108 tests through the same harness. The earlier probe/E2E paths are unchanged by that incoming-main merge.Normal pre-push gates passed at that head. Independent canonical Luna round 2 delta returned SHIP, no findings on 2026-11-02, verifying the combined write budget, caller attribution and late-return coverage. Fresh exact-head CI remains the final merge-readiness gate; fleet coverage/canary requirements below remain deploy gates.
Historical validation from the previous published revision:
backend/test.sh, usingBACKEND_UNIT_TEST_FILE_LISTand four workers: 480 passed, including fence/memo/privacy, tombstones, speaker enrollment, live/serving, admission and the newly integrated transcript/Home tests.backend/testing/e2e/run.sh: 180 passed, 5 skipped.make preflight: 37/37 checks passed; the required pre-push hook also completed 54/54 checks before the fast-forward push to the existing branch.bin/omi-heavyatnice -n 19. No production data, mutations, deploy or reader enablement.The existing reviewed fence semantics are unchanged. This integration refresh needed no new Grok round under the assigned brief. Earlier review caveats and detailed atomicity proof remain in
.agent-brief/WQ26-sol-report-1027c.md.Current cost evidence
Read-only
ro-prodaggregate metrics refreshed at 2026-11-01T05:59:50Z show 137.98M bpp reads in 24h across Cloud Run (95.43M sync, 37.09M backfill); all four expected caller-metric services are present. A separate GKE aggregate was only about 2.8k/day. Last 3h scaled to a daily run rate: 174.91M; last 1h: 169.30M. These are origin-read measurements, not realized savings.Production-project billing export on Oct 29–30 gives $0.46144/M reads, valuing that 24h origin at $63.67/day. The repeated-path test reductions (store 100→24; artifact decision-only 100→44; full-row export 100→100) imply $35.66–$48.39/day gross potential only if traffic has those hit patterns. Added fence writes cost about $1.385/M at the same billing basis; eligible traffic share, hit rate, write amplification and net savings still need a fenced-fleet canary. No net saving is claimed.
Added writes and contention (fswrites, 2026-11-01)
Luna's notes at
f773647are fixed incda54a27:private_cloud_sync_enabledand the other conversation authority fields into every update payload, so the fence rotated the token even when nothing changed. Assignment now omits an authority field equal to this transaction's read of the row. An omitted field is the committed value, and a concurrent change aborts the transaction. A field absent from the row is never omitted, because absent consent means enabled. A real authority change still rotates. Fence and writers share one field set (batch_privacy_attempt.CONVERSATION_AUTHORITY_FIELDS).FirestoreTransaction.flushnow counts the one token write per owner that itsrecord_lane_ownerpatches add.tests/unit/test_bpp_fence_write_budget.py(4), plus the 69 related unit files, all passing.Sizing comes from real counts, and the PR does not ship before them:
2026-11-02 14:39Z ro-prod aggregate refresh observed 1,910,961 queried source writes/24h and 100,312.6/1h. This is an observed source-counter envelope, not an exact token-write forecast or fleet bound: it includes metadata writes that do not rotate tokens and repeated writes for the same owner. Four Cloud Run probes are present; listen/pusher coverage and maintenance producers remain unproven, and previously unclassified collections cannot be inferred idle from zero series. Lead owns this remaining sizing/canary gate and the fleet deploy; no net saving is claimed.
The fswritesr caller-based estimate narrows the observed Cloud Run scope to at most
1.30M added token writes/day at the measured traffic mix ($1.80/day using the earlier $1.385/M billing basis). Its ~1.77M/day estimate at batch 100% assumes admission's average share was ~30% during the window; the likely lower figures depend on unmeasured no-op rates. These estimates omit listen/pusher and maintenance traffic, so they do not close the fleet bound. Measure actual token writes and per-caller contention during the writer canary before any reader enablement; lead sets the canary decision from complete coverage.op(create, update, merge, set, delete) and caller.merge,set,createanddelete, which includesrecord_user_platform's merge every 10 min per active user per platform;set,merge,createanddelete;updatecommits from the callers that write authority fields: batch admission (record_lane_owner), sync assignment, and donor redirects.Contention: the token joins every authority transaction for its owner. Transactions on different conversations of the same owner that each change authority now conflict on one document (sustained limit about 1 write/s per document). Sync (per-uid lease) and batch owner drains are serial per owner. The cross-service overlap (listen create, sync, batch, pusher) is what to watch. Measure it as the Aborted/contention rate on those callers at the canary, before readers.
Order:
bpp_generation_memoreader at 5%, then 100%.Product invariants affected
Failure-Class: none
This is a read-cost optimization with privacy-fence and integration regression coverage, rather than an instance of a recorded production failure class.
Line-Count-Exception: backend/routers/sync.py | 3736 -> 3738 | batch-privacy attempt authorization import and decorator on the existing sync entrypoint; no route logic expansion.
Line-Count-Exception: backend/utils/sync/assignment.py | 1497 -> 1515 | Omit unchanged conversation authority fields inside the existing assignment transaction so no-op updates do not rotate generation tokens; share the authoritative field set with the privacy fence.