Repository navigation
feat(privacy): 60s-bounded privacy decision reuse with a runtime kill switch, plus decision-neutral shadow - #24622
Conversation
… switch Implements David's 2026-11-04 ruling: a cached privacy, deletion, tombstone or legal-hold decision may be reused for at most 60 seconds. - bpp_decision_cache: batch privacy generations reused across task attempts in a process, still certified per use by the in-transaction memo token (exact; the write fence rotates the token in every authority commit), expiring 60s after the walk started. ~5-6 reads -> 1 per hit. - privacy_ttl60: non-transactional legal-hold fence, tombstone and deletion-marker decisions reused for at most 60s from the start of the live read, no token read. Blocked/deleted/unavailable outcomes are never stored; transactional fences stay live. - Runtime kill switch ops_kill_switches/privacy_decision_cache, polled per process every 30s, fail closed. - Shadow labels within-bound staleness stale_within_ttl, separate from real mismatches; privacy_ttl_cache_total counter; Cloud Run GMP keep-lists export the privacy_*_total counters so shadow evidence is readable. All levers absent = off; behavior unchanged until configured. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ches FIRESTORE_READ_LEVERS on every service: privacy_checks_shadow 100, privacy_ttl60 100, bpp_decision_cache 100. With shadow on, live authority decides every privacy decision and the cached answer is only compared (privacy_shadow_checks_total / privacy_decision_mismatch_total), which is the 2h live-shadow step of David's 2026-11-04 privacy soak policy. Cost while shadowing: shadow wins over bpp_generation_memo, so batch privacy checks walk live and re-walk the candidate on a miss until enforcement (drop privacy_checks_shadow). Rollback: remove the three keys. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # backend/charts/backend-listen/dev_omi_backend_listen_values.yaml # backend/charts/backend-listen/prod_omi_backend_listen_values.yaml # backend/charts/pusher/dev_omi_pusher_values.yaml # backend/charts/pusher/prod_omi_pusher_values.yaml # backend/deploy/runtime_env.yaml # backend/deploy/runtime_env/_base.yaml # backend/deploy/runtime_env/prod.overlay.yaml # backend/docs/feature-flag-registry.md # backend/tests/unit/test_render_backend_runtime_env.py # backend/tests/unit/test_verify_pusher_config_references.py
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e660d0137d
ℹ️ 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".
| started = ttl_cache.DECISIONS.clock() | ||
| status = read() |
There was a problem hiding this comment.
Anchor deletion-status reuse to an authoritative read
When privacy_ttl60 and deletion_marker_cache are enabled, read() can return a Redis-cached absence up to 30 seconds old (or an older request-memoized result), but this code assigns it a fresh 60-second lifetime. For example, if both Redis writer invalidations fail, an absence cached just before deletion can be retrieved 29 seconds later and authorize access for another 60 seconds, exceeding the promised deletion-propagation bound. Shadow comparisons also treat that cached result as live authority. Bypass the inner caches when populating/comparing this TTL cache, or preserve the original authoritative-read timestamp and remaining lifetime.
Useful? React with 👍 / 👎.
|
|
||
|
|
||
| def _read_kill_flag() -> bool: | ||
| from database.account_deletion_marker import account_deletion_firestore_client |
There was a problem hiding this comment.
Move the new function-local imports to module scope
The new module imports account_deletion_firestore_client inside _read_kill_flag(), and likewise imports dependencies inside disabled() and enabled(). This directly violates the explicit import convention in backend/AGENTS.md: “All imports at module top level — never inside functions.” Move these imports to module scope, restructuring shared dependencies if necessary while keeping client construction lazy.
AGENTS.md reference: backend/AGENTS.md:L168-L168
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
11 issues found across 21 files
Confidence score: 3/5
account_deletion_marker.pycan still return stale deletion-marker data from the legacy request and Redis caches when the kill switch is disabled. Bypass those caches so rollback reads reach Firestore.account_deletion_marker.pycan keep a restored account blocked for up to 60 seconds because blocked statuses are cached. Cache only statuses thataccount_deletion_blocks_accesspermits.- The
bpp_decision_cachelever is enabled only indev_omi_backend_listen_values.yaml, not in the batch-pipeline-worker chart that runs the privacy path. Enable it there too so the rollout covers that worker. cloud_run_gmp_sync.yamlomits theprivacy_ttl_cache_disabledgauge, so GMP cannot verify the kill-switch state across processes. Add it to the keep-list.
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/charts/backend-listen/dev_omi_backend_listen_values.yaml">
<violation number="1" location="backend/charts/backend-listen/dev_omi_backend_listen_values.yaml:239">
P2: The `bpp_decision_cache` lever is enabled only in the backend-listen dev values. The batch-pipeline-worker chart, which runs `diarizer.batch_pipeline_runtime` and reaches `batch_pipeline_privacy`, still sets only `batch_privacy_memoize`. Confirm the worker chart also gets `bpp_decision_cache`, or the cache never runs where batch privacy checks execute.</violation>
</file>
<file name="backend/deploy/cloud_run_gmp_sync.yaml">
<violation number="1" location="backend/deploy/cloud_run_gmp_sync.yaml:44">
P2: The keep-list omits `privacy_ttl_cache_disabled`, the gauge that shows whether the privacy cache kill switch is set. Without it, the cross-process kill-switch state cannot be verified from GMP. Add it as a top-level alternative. The runbook's `privacy_conversations_walked_total` and `privacy_session_cycle_operations` families are also not kept; add them or confirm they are intentionally local-only.</violation>
</file>
<file name="backend/database/account_deletion_marker.py">
<violation number="1" location="backend/database/account_deletion_marker.py:77">
P3: This new helper adds five in-function imports, which backend/AGENTS.md prohibits. Move them to module top level if no circular import blocks it. Otherwise, note the reason in a comment.</violation>
<violation number="2" location="backend/database/account_deletion_marker.py:84">
P1: The kill switch still permits stale deletion-marker reads through the legacy request/Redis caches. Bypass those caches when the switch is disabled so the rollback path always reaches Firestore.</violation>
<violation number="3" location="backend/database/account_deletion_marker.py:107">
P2: The deletion-marker cache stores blocking statuses, so a restored account can remain blocked for up to 60 seconds. Store only statuses that `account_deletion_blocks_access` permits, leaving blocked outcomes live.</violation>
</file>
<file name="backend/database/privacy_ttl_cache.py">
<violation number="1" location="backend/database/privacy_ttl_cache.py:104">
P3: Move the function-local imports in this module to module scope to comply with `backend/AGENTS.md`; keep client construction inside `_read_kill_flag()` so it remains lazy.</violation>
<violation number="2" location="backend/database/privacy_ttl_cache.py:107">
P2: The kill switch only engages for a boolean `True`. A value written as `"true"` or `1` in the console is silently ignored and every cache stays on. Treat a present, non-false value as disabled, or log a warning when the value is not a boolean.</violation>
<violation number="3" location="backend/database/privacy_ttl_cache.py:116">
P2: Concurrent callers can bypass the poll interval because the lock is released before `_read_kill_flag()`. Serialize the read (or use an in-flight poll state) so one slow poll cannot trigger duplicate reads or overwrite a newer result.</violation>
</file>
<file name="backend/deploy/cloud_run_gmp_sidecar.yaml">
<violation number="1" location="backend/deploy/cloud_run_gmp_sidecar.yaml:19">
P2: The new GMP privacy allowlist drops `privacy_conversations_walked_total`, even though the application and sync worker emit it. Add that counter to both Cloud Run keep-list regexes so the privacy walk/read-cost telemetry is exported.</violation>
</file>
<file name="backend/deploy/runtime_env/prod.overlay.yaml">
<violation number="1" location="backend/deploy/runtime_env/prod.overlay.yaml:554">
P3: This prod overlay now enables `privacy_checks_shadow` and `privacy_ttl60` at 100%, while the adjacent rollout contract still says `privacy=0`. Update the comment (and any corresponding runbook wording) to match the deployed values, or set the levers to 0 if the documented rollout is intended.</violation>
</file>
<file name="backend/database/privacy_check_metrics.py">
<violation number="1" location="backend/database/privacy_check_metrics.py:188">
P2: Accepted within-TTL stale allows are still logged as WARNING `privacy shadow decision_mismatch`, and they use up the one-line-per-family-per-minute budget. A real mismatch in the same family within that minute goes unlogged. Return after the counter increment so these events are counted but not logged.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| from database.fsr_read_cache import plane_id | ||
|
|
||
| if not ttl_cache.enabled('privacy_ttl60', uid): | ||
| return read() |
There was a problem hiding this comment.
P1: The kill switch still permits stale deletion-marker reads through the legacy request/Redis caches. Bypass those caches when the switch is disabled so the rollback path always reaches Firestore.
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/account_deletion_marker.py, line 84:
<comment>The kill switch still permits stale deletion-marker reads through the legacy request/Redis caches. Bypass those caches when the switch is disabled so the rollback path always reaches Firestore.</comment>
<file context>
@@ -43,25 +43,72 @@ def get_user_deletion_wipe_status(uid: str, *, firestore_client: Any | None = No
+ from database.fsr_read_cache import plane_id
+
+ if not ttl_cache.enabled('privacy_ttl60', uid):
+ return read()
+ shadow = lever_enabled('privacy_checks_shadow', uid)
+ key = ('privacy_ttl', plane_id(client), uid, 'deletion_marker', '')
</file context>
| value: "1" | ||
| - name: FIRESTORE_READ_LEVERS | ||
| value: '{"action_items_page":100,"backfill_task_reads":100,"batch_privacy_memoize":0,"bpp_generation_memo":100,"candidates_page":100,"canonical_statuses_dedupe":100,"conversation_list_cursor":100,"deletion_marker_cache":100,"finjob_candidate_queries":100,"historical_scan_memo":100,"ledger_purge_coalesce":100,"mcp_conversation_cards_cache":100,"memory_list_index_window":0,"people_scan_dedupe":100,"queue_age_sample_budget":100,"request_read_dedupe":100,"serving_config_cache":100,"singleton_loops":100,"subscription_cache":100,"sync_snapshot_resolve_cache":100,"usage_month_cache":0,"usage_month_total":0}' | ||
| value: '{"action_items_page":100,"backfill_task_reads":100,"batch_privacy_memoize":0,"bpp_decision_cache":100,"bpp_generation_memo":100,"candidates_page":100,"canonical_statuses_dedupe":100,"conversation_list_cursor":100,"deletion_marker_cache":100,"finjob_candidate_queries":100,"historical_scan_memo":100,"ledger_purge_coalesce":100,"mcp_conversation_cards_cache":100,"memory_list_index_window":0,"people_scan_dedupe":100,"privacy_checks_shadow":100,"privacy_ttl60":100,"queue_age_sample_budget":100,"request_read_dedupe":100,"serving_config_cache":100,"singleton_loops":100,"subscription_cache":100,"sync_snapshot_resolve_cache":100,"usage_month_cache":0,"usage_month_total":0}' |
There was a problem hiding this comment.
P2: The bpp_decision_cache lever is enabled only in the backend-listen dev values. The batch-pipeline-worker chart, which runs diarizer.batch_pipeline_runtime and reaches batch_pipeline_privacy, still sets only batch_privacy_memoize. Confirm the worker chart also gets bpp_decision_cache, or the cache never runs where batch privacy checks execute.
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/charts/backend-listen/dev_omi_backend_listen_values.yaml, line 239:
<comment>The `bpp_decision_cache` lever is enabled only in the backend-listen dev values. The batch-pipeline-worker chart, which runs `diarizer.batch_pipeline_runtime` and reaches `batch_pipeline_privacy`, still sets only `batch_privacy_memoize`. Confirm the worker chart also gets `bpp_decision_cache`, or the cache never runs where batch privacy checks execute.</comment>
<file context>
@@ -236,7 +236,7 @@ env:
value: "1"
- name: FIRESTORE_READ_LEVERS
- value: '{"action_items_page":100,"backfill_task_reads":100,"batch_privacy_memoize":0,"bpp_generation_memo":100,"candidates_page":100,"canonical_statuses_dedupe":100,"conversation_list_cursor":100,"deletion_marker_cache":100,"finjob_candidate_queries":100,"historical_scan_memo":100,"ledger_purge_coalesce":100,"mcp_conversation_cards_cache":100,"memory_list_index_window":0,"people_scan_dedupe":100,"queue_age_sample_budget":100,"request_read_dedupe":100,"serving_config_cache":100,"singleton_loops":100,"subscription_cache":100,"sync_snapshot_resolve_cache":100,"usage_month_cache":0,"usage_month_total":0}'
+ value: '{"action_items_page":100,"backfill_task_reads":100,"batch_privacy_memoize":0,"bpp_decision_cache":100,"bpp_generation_memo":100,"candidates_page":100,"canonical_statuses_dedupe":100,"conversation_list_cursor":100,"deletion_marker_cache":100,"finjob_candidate_queries":100,"historical_scan_memo":100,"ledger_purge_coalesce":100,"mcp_conversation_cards_cache":100,"memory_list_index_window":0,"people_scan_dedupe":100,"privacy_checks_shadow":100,"privacy_ttl60":100,"queue_age_sample_budget":100,"request_read_dedupe":100,"serving_config_cache":100,"singleton_loops":100,"subscription_cache":100,"sync_snapshot_resolve_cache":100,"usage_month_cache":0,"usage_month_total":0}'
- name: FSR_QUEUE_AGE_PUBLISHER
value: "1"
</file context>
| sourceLabels: | ||
| - __name__ | ||
| regex: 'omi_(batch_record_pending_.*|record_seal_nojob_.*|enrichment_obligation_.*|finalization_byok_.*|listen_server_batch_suppression_total|listen_preview_batch_custody_total|delivery_outcome_total|people_scan_dedupe_total|pinecone_.*|playback_writes_total|sync_.*|journey_.*|client_journey_.*|owner_recognition_conversations_total|conversation_duration_seconds(_.*)?|conversation_relevance_decision_total|conversation_summary_vector_upserts_total|conversation_relevance_decision_total|firestore_documents_per_operation(_.*)?|capture_finalization_.*|queue_oldest_ready_.*|batch_pipeline_.*|batch_intake_outcome_total|batch_admission_sample_window_total|batch_ramp_heavy_owner_excluded_total|batch_shadow_.*|accept_to_summary_seconds(_.*)?|summary_terminal_total|summary_debt_.*|live_session_transcript_outcome_total|fallback_total|parakeet_request_seconds(_.*)?|firestore_billed_reads_by_(caller|origin)_total|firestore_caller_label_overflow_total|firestore_billed_writes(_by_caller)?_total|firestore_write_caller_label_overflow_total|firestore_ambiguous_commit_writes_total|firestore_noop_writes_by_caller_total|memory_released_projection_total|fsr_leader_lease_total|held_content_.*|held_recovery_pacing_.*|stt_cap_recovery_reconciliation_total|stt_cap_recovery_cohort_narrowed|stt_cap_cohort_.*|stt_cap_launch_config_errors.*|stt_cap_dispatch_decisions_total|stt_cap_provider_audio_seconds_total|legacy_sync_.*|legacy_dark_.*|jobstore_.*|capture_coverage_.*|capture_dedupe_shadow_total|capture_retry_cap_total|speaker_evidence_.*|speaker_evidence_confident_owner_total|lifecycle_refactor_shadow_total|executor_task_(active|queued)|clients_refactor_shadow_total|notes_refactor_shadow_total|notes_refactor_results_total|stt_language_gate_.*|prerecorded_vendor_.*|episode_compose_.*)|conversation_llm_input_dedupe_.*' | ||
| regex: 'omi_(batch_record_pending_.*|record_seal_nojob_.*|enrichment_obligation_.*|finalization_byok_.*|listen_server_batch_suppression_total|listen_preview_batch_custody_total|delivery_outcome_total|people_scan_dedupe_total|pinecone_.*|playback_writes_total|sync_.*|journey_.*|client_journey_.*|owner_recognition_conversations_total|conversation_duration_seconds(_.*)?|conversation_relevance_decision_total|conversation_summary_vector_upserts_total|conversation_relevance_decision_total|firestore_documents_per_operation(_.*)?|capture_finalization_.*|queue_oldest_ready_.*|batch_pipeline_.*|batch_intake_outcome_total|batch_admission_sample_window_total|batch_ramp_heavy_owner_excluded_total|batch_shadow_.*|accept_to_summary_seconds(_.*)?|summary_terminal_total|summary_debt_.*|live_session_transcript_outcome_total|fallback_total|parakeet_request_seconds(_.*)?|firestore_billed_reads_by_(caller|origin)_total|firestore_caller_label_overflow_total|firestore_billed_writes(_by_caller)?_total|firestore_write_caller_label_overflow_total|firestore_ambiguous_commit_writes_total|firestore_noop_writes_by_caller_total|memory_released_projection_total|fsr_leader_lease_total|held_content_.*|held_recovery_pacing_.*|stt_cap_recovery_reconciliation_total|stt_cap_recovery_cohort_narrowed|stt_cap_cohort_.*|stt_cap_launch_config_errors.*|stt_cap_dispatch_decisions_total|stt_cap_provider_audio_seconds_total|legacy_sync_.*|legacy_dark_.*|jobstore_.*|capture_coverage_.*|capture_dedupe_shadow_total|capture_retry_cap_total|speaker_evidence_.*|speaker_evidence_confident_owner_total|lifecycle_refactor_shadow_total|executor_task_(active|queued)|clients_refactor_shadow_total|notes_refactor_shadow_total|notes_refactor_results_total|stt_language_gate_.*|prerecorded_vendor_.*|episode_compose_.*)|conversation_llm_input_dedupe_.*|privacy_(checks|check_calls|check_reads|decision_mismatch|shadow_checks|memo_requests|ttl_cache)_total' |
There was a problem hiding this comment.
P2: The keep-list omits privacy_ttl_cache_disabled, the gauge that shows whether the privacy cache kill switch is set. Without it, the cross-process kill-switch state cannot be verified from GMP. Add it as a top-level alternative. The runbook's privacy_conversations_walked_total and privacy_session_cycle_operations families are also not kept; add them or confirm they are intentionally local-only.
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/cloud_run_gmp_sync.yaml, line 44:
<comment>The keep-list omits `privacy_ttl_cache_disabled`, the gauge that shows whether the privacy cache kill switch is set. Without it, the cross-process kill-switch state cannot be verified from GMP. Add it as a top-level alternative. The runbook's `privacy_conversations_walked_total` and `privacy_session_cycle_operations` families are also not kept; add them or confirm they are intentionally local-only.</comment>
<file context>
@@ -41,7 +41,7 @@ spec:
sourceLabels:
- __name__
- regex: 'omi_(batch_record_pending_.*|record_seal_nojob_.*|enrichment_obligation_.*|finalization_byok_.*|listen_server_batch_suppression_total|listen_preview_batch_custody_total|delivery_outcome_total|people_scan_dedupe_total|pinecone_.*|playback_writes_total|sync_.*|journey_.*|client_journey_.*|owner_recognition_conversations_total|conversation_duration_seconds(_.*)?|conversation_relevance_decision_total|conversation_summary_vector_upserts_total|conversation_relevance_decision_total|firestore_documents_per_operation(_.*)?|capture_finalization_.*|queue_oldest_ready_.*|batch_pipeline_.*|batch_intake_outcome_total|batch_admission_sample_window_total|batch_ramp_heavy_owner_excluded_total|batch_shadow_.*|accept_to_summary_seconds(_.*)?|summary_terminal_total|summary_debt_.*|live_session_transcript_outcome_total|fallback_total|parakeet_request_seconds(_.*)?|firestore_billed_reads_by_(caller|origin)_total|firestore_caller_label_overflow_total|firestore_billed_writes(_by_caller)?_total|firestore_write_caller_label_overflow_total|firestore_ambiguous_commit_writes_total|firestore_noop_writes_by_caller_total|memory_released_projection_total|fsr_leader_lease_total|held_content_.*|held_recovery_pacing_.*|stt_cap_recovery_reconciliation_total|stt_cap_recovery_cohort_narrowed|stt_cap_cohort_.*|stt_cap_launch_config_errors.*|stt_cap_dispatch_decisions_total|stt_cap_provider_audio_seconds_total|legacy_sync_.*|legacy_dark_.*|jobstore_.*|capture_coverage_.*|capture_dedupe_shadow_total|capture_retry_cap_total|speaker_evidence_.*|speaker_evidence_confident_owner_total|lifecycle_refactor_shadow_total|executor_task_(active|queued)|clients_refactor_shadow_total|notes_refactor_shadow_total|notes_refactor_results_total|stt_language_gate_.*|prerecorded_vendor_.*|episode_compose_.*)|conversation_llm_input_dedupe_.*'
+ regex: 'omi_(batch_record_pending_.*|record_seal_nojob_.*|enrichment_obligation_.*|finalization_byok_.*|listen_server_batch_suppression_total|listen_preview_batch_custody_total|delivery_outcome_total|people_scan_dedupe_total|pinecone_.*|playback_writes_total|sync_.*|journey_.*|client_journey_.*|owner_recognition_conversations_total|conversation_duration_seconds(_.*)?|conversation_relevance_decision_total|conversation_summary_vector_upserts_total|conversation_relevance_decision_total|firestore_documents_per_operation(_.*)?|capture_finalization_.*|queue_oldest_ready_.*|batch_pipeline_.*|batch_intake_outcome_total|batch_admission_sample_window_total|batch_ramp_heavy_owner_excluded_total|batch_shadow_.*|accept_to_summary_seconds(_.*)?|summary_terminal_total|summary_debt_.*|live_session_transcript_outcome_total|fallback_total|parakeet_request_seconds(_.*)?|firestore_billed_reads_by_(caller|origin)_total|firestore_caller_label_overflow_total|firestore_billed_writes(_by_caller)?_total|firestore_write_caller_label_overflow_total|firestore_ambiguous_commit_writes_total|firestore_noop_writes_by_caller_total|memory_released_projection_total|fsr_leader_lease_total|held_content_.*|held_recovery_pacing_.*|stt_cap_recovery_reconciliation_total|stt_cap_recovery_cohort_narrowed|stt_cap_cohort_.*|stt_cap_launch_config_errors.*|stt_cap_dispatch_decisions_total|stt_cap_provider_audio_seconds_total|legacy_sync_.*|legacy_dark_.*|jobstore_.*|capture_coverage_.*|capture_dedupe_shadow_total|capture_retry_cap_total|speaker_evidence_.*|speaker_evidence_confident_owner_total|lifecycle_refactor_shadow_total|executor_task_(active|queued)|clients_refactor_shadow_total|notes_refactor_shadow_total|notes_refactor_results_total|stt_language_gate_.*|prerecorded_vendor_.*|episode_compose_.*)|conversation_llm_input_dedupe_.*|privacy_(checks|check_calls|check_reads|decision_mismatch|shadow_checks|memo_requests|ttl_cache)_total'
# These eagerly initialized live-STT combinations dominate empty series
# on sync workers. Keep fallbacks from sync/summary/storage components.
</file context>
| regex: 'omi_(batch_record_pending_.*|record_seal_nojob_.*|enrichment_obligation_.*|finalization_byok_.*|listen_server_batch_suppression_total|listen_preview_batch_custody_total|delivery_outcome_total|people_scan_dedupe_total|pinecone_.*|playback_writes_total|sync_.*|journey_.*|client_journey_.*|owner_recognition_conversations_total|conversation_duration_seconds(_.*)?|conversation_relevance_decision_total|conversation_summary_vector_upserts_total|conversation_relevance_decision_total|firestore_documents_per_operation(_.*)?|capture_finalization_.*|queue_oldest_ready_.*|batch_pipeline_.*|batch_intake_outcome_total|batch_admission_sample_window_total|batch_ramp_heavy_owner_excluded_total|batch_shadow_.*|accept_to_summary_seconds(_.*)?|summary_terminal_total|summary_debt_.*|live_session_transcript_outcome_total|fallback_total|parakeet_request_seconds(_.*)?|firestore_billed_reads_by_(caller|origin)_total|firestore_caller_label_overflow_total|firestore_billed_writes(_by_caller)?_total|firestore_write_caller_label_overflow_total|firestore_ambiguous_commit_writes_total|firestore_noop_writes_by_caller_total|memory_released_projection_total|fsr_leader_lease_total|held_content_.*|held_recovery_pacing_.*|stt_cap_recovery_reconciliation_total|stt_cap_recovery_cohort_narrowed|stt_cap_cohort_.*|stt_cap_launch_config_errors.*|stt_cap_dispatch_decisions_total|stt_cap_provider_audio_seconds_total|legacy_sync_.*|legacy_dark_.*|jobstore_.*|capture_coverage_.*|capture_dedupe_shadow_total|capture_retry_cap_total|speaker_evidence_.*|speaker_evidence_confident_owner_total|lifecycle_refactor_shadow_total|executor_task_(active|queued)|clients_refactor_shadow_total|notes_refactor_shadow_total|notes_refactor_results_total|stt_language_gate_.*|prerecorded_vendor_.*|episode_compose_.*)|conversation_llm_input_dedupe_.*|privacy_(checks|check_calls|check_reads|decision_mismatch|shadow_checks|memo_requests|ttl_cache)_total' | |
| regex: 'omi_(batch_record_pending_.*|record_seal_nojob_.*|enrichment_obligation_.*|finalization_byok_.*|listen_server_batch_suppression_total|listen_preview_batch_custody_total|delivery_outcome_total|people_scan_dedupe_total|pinecone_.*|playback_writes_total|sync_.*|journey_.*|client_journey_.*|owner_recognition_conversations_total|conversation_duration_seconds(_.*)?|conversation_relevance_decision_total|conversation_summary_vector_upserts_total|conversation_relevance_decision_total|firestore_documents_per_operation(_.*)?|capture_finalization_.*|queue_oldest_ready_.*|batch_pipeline_.*|batch_intake_outcome_total|batch_admission_sample_window_total|batch_ramp_heavy_owner_excluded_total|batch_shadow_.*|accept_to_summary_seconds(_.*)?|summary_terminal_total|summary_debt_.*|live_session_transcript_outcome_total|fallback_total|parakeet_request_seconds(_.*)?|firestore_billed_reads_by_(caller|origin)_total|firestore_caller_label_overflow_total|firestore_billed_writes(_by_caller)?_total|firestore_write_caller_label_overflow_total|firestore_ambiguous_commit_writes_total|firestore_noop_writes_by_caller_total|memory_released_projection_total|fsr_leader_lease_total|held_content_.*|held_recovery_pacing_.*|stt_cap_recovery_reconciliation_total|stt_cap_recovery_cohort_narrowed|stt_cap_cohort_.*|stt_cap_launch_config_errors.*|stt_cap_dispatch_decisions_total|stt_cap_provider_audio_seconds_total|legacy_sync_.*|legacy_dark_.*|jobstore_.*|capture_coverage_.*|capture_dedupe_shadow_total|capture_retry_cap_total|speaker_evidence_.*|speaker_evidence_confident_owner_total|lifecycle_refactor_shadow_total|executor_task_(active|queued)|clients_refactor_shadow_total|notes_refactor_shadow_total|notes_refactor_results_total|stt_language_gate_.*|prerecorded_vendor_.*|episode_compose_.*)|conversation_llm_input_dedupe_.*|privacy_(checks|check_calls|check_reads|decision_mismatch|shadow_checks|memo_requests|ttl_cache)_total|privacy_ttl_cache_disabled' |
| if within: | ||
| reason = 'stale_within_ttl' |
There was a problem hiding this comment.
P2: Accepted within-TTL stale allows are still logged as WARNING privacy shadow decision_mismatch, and they use up the one-line-per-family-per-minute budget. A real mismatch in the same family within that minute goes unlogged. Return after the counter increment so these events are counted but not logged.
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/privacy_check_metrics.py, line 188:
<comment>Accepted within-TTL stale allows are still logged as WARNING `privacy shadow decision_mismatch`, and they use up the one-line-per-family-per-minute budget. A real mismatch in the same family within that minute goes unlogged. Return after the counter increment so these events are counted but not logged.</comment>
<file context>
@@ -148,14 +170,23 @@ def mode_scope(mode):
+ SHADOW_CHECKS.labels(family, ('within_ttl' if within else 'mismatch') if mismatch else 'match').inc()
if mismatch:
reason = 'stale_allow' if candidate == 'allow' else 'stale_block' if live == 'allow' else 'block_reason'
+ if within:
+ reason = 'stale_within_ttl'
DECISION_MISMATCH.labels(family, reason).inc()
</file context>
| if within: | |
| reason = 'stale_within_ttl' | |
| if within: | |
| DECISION_MISMATCH.labels(family, 'stale_within_ttl').inc() | |
| return # accepted within-TTL staleness: counted, never logged |
| with _kill_lock: | ||
| if _kill_state and _kill_state[0][0] > now: | ||
| return _kill_state[0][1] | ||
| try: |
There was a problem hiding this comment.
P2: Concurrent callers can bypass the poll interval because the lock is released before _read_kill_flag(). Serialize the read (or use an in-flight poll state) so one slow poll cannot trigger duplicate reads or overwrite a newer result.
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/privacy_ttl_cache.py, line 116:
<comment>Concurrent callers can bypass the poll interval because the lock is released before `_read_kill_flag()`. Serialize the read (or use an in-flight poll state) so one slow poll cannot trigger duplicate reads or overwrite a newer result.</comment>
<file context>
@@ -0,0 +1,147 @@
+ with _kill_lock:
+ if _kill_state and _kill_state[0][0] > now:
+ return _kill_state[0][1]
+ try:
+ off = _read_kill_flag()
+ except Exception:
</file context>
| else: | ||
| metrics.ttl_result('deletion_marker', 'miss') | ||
| # Box the value so a cached None (no marker) differs from a miss. | ||
| if ttl_cache.DECISIONS.put(key, (status,), started=started): |
There was a problem hiding this comment.
P2: The deletion-marker cache stores blocking statuses, so a restored account can remain blocked for up to 60 seconds. Store only statuses that account_deletion_blocks_access permits, leaving blocked outcomes live.
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/account_deletion_marker.py, line 107:
<comment>The deletion-marker cache stores blocking statuses, so a restored account can remain blocked for up to 60 seconds. Store only statuses that `account_deletion_blocks_access` permits, leaving blocked outcomes live.</comment>
<file context>
@@ -43,25 +43,72 @@ def get_user_deletion_wipe_status(uid: str, *, firestore_client: Any | None = No
+ else:
+ metrics.ttl_result('deletion_marker', 'miss')
+ # Box the value so a cached None (no marker) differs from a miss.
+ if ttl_cache.DECISIONS.put(key, (status,), started=started):
+ metrics.ttl_result('deletion_marker', 'store')
+ return status
</file context>
| if ttl_cache.DECISIONS.put(key, (status,), started=started): | |
| if not account_deletion_blocks_access(status) and ttl_cache.DECISIONS.put(key, (status,), started=started): |
| are never stored. Under privacy_checks_shadow the live read always decides | ||
| and the cached answer is only compared. | ||
| """ | ||
| from config.firestore_read_levers import lever_enabled |
There was a problem hiding this comment.
P3: This new helper adds five in-function imports, which backend/AGENTS.md prohibits. Move them to module top level if no circular import blocks it. Otherwise, note the reason in a comment.
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/account_deletion_marker.py, line 77:
<comment>This new helper adds five in-function imports, which backend/AGENTS.md prohibits. Move them to module top level if no circular import blocks it. Otherwise, note the reason in a comment.</comment>
<file context>
@@ -43,25 +43,72 @@ def get_user_deletion_wipe_status(uid: str, *, firestore_client: Any | None = No
+ are never stored. Under privacy_checks_shadow the live read always decides
+ and the cached answer is only compared.
+ """
+ from config.firestore_read_levers import lever_enabled
+ from database import privacy_check_metrics as metrics
+ from database import privacy_ttl_cache as ttl_cache
</file context>
| # carries people=5, memory=0, privacy=0 (finjob=5). | ||
| # Lead train: listen -> pusher -> Cloud Run; do not enable additional monthly readers here. | ||
| FIRESTORE_READ_LEVERS: {value: '{"action_items_page":100,"backfill_task_reads":100,"batch_privacy_memoize":0,"bpp_generation_memo":100,"candidates_page":100,"canonical_statuses_dedupe":100,"conversation_list_cursor":100,"deletion_marker_cache":100,"finjob_candidate_queries":100,"historical_scan_memo":100,"ledger_purge_coalesce":100,"mcp_conversation_cards_cache":100,"memory_list_index_window":0,"people_scan_dedupe":100,"queue_age_sample_budget":100,"request_read_dedupe":100,"serving_config_cache":100,"singleton_loops":100,"subscription_cache":100,"sync_snapshot_resolve_cache":100,"usage_month_cache":0,"usage_month_total":0}', category: rollout} | ||
| FIRESTORE_READ_LEVERS: {value: '{"action_items_page":100,"backfill_task_reads":100,"batch_privacy_memoize":0,"bpp_decision_cache":100,"bpp_generation_memo":100,"candidates_page":100,"canonical_statuses_dedupe":100,"conversation_list_cursor":100,"deletion_marker_cache":100,"finjob_candidate_queries":100,"historical_scan_memo":100,"ledger_purge_coalesce":100,"mcp_conversation_cards_cache":100,"memory_list_index_window":0,"people_scan_dedupe":100,"privacy_checks_shadow":100,"privacy_ttl60":100,"queue_age_sample_budget":100,"request_read_dedupe":100,"serving_config_cache":100,"singleton_loops":100,"subscription_cache":100,"sync_snapshot_resolve_cache":100,"usage_month_cache":0,"usage_month_total":0}', category: rollout} |
There was a problem hiding this comment.
P3: This prod overlay now enables privacy_checks_shadow and privacy_ttl60 at 100%, while the adjacent rollout contract still says privacy=0. Update the comment (and any corresponding runbook wording) to match the deployed values, or set the levers to 0 if the documented rollout is intended.
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/runtime_env/prod.overlay.yaml, line 554:
<comment>This prod overlay now enables `privacy_checks_shadow` and `privacy_ttl60` at 100%, while the adjacent rollout contract still says `privacy=0`. Update the comment (and any corresponding runbook wording) to match the deployed values, or set the levers to 0 if the documented rollout is intended.</comment>
<file context>
@@ -551,7 +551,7 @@ overlay:
# carries people=5, memory=0, privacy=0 (finjob=5).
# Lead train: listen -> pusher -> Cloud Run; do not enable additional monthly readers here.
- FIRESTORE_READ_LEVERS: {value: '{"action_items_page":100,"backfill_task_reads":100,"batch_privacy_memoize":0,"bpp_generation_memo":100,"candidates_page":100,"canonical_statuses_dedupe":100,"conversation_list_cursor":100,"deletion_marker_cache":100,"finjob_candidate_queries":100,"historical_scan_memo":100,"ledger_purge_coalesce":100,"mcp_conversation_cards_cache":100,"memory_list_index_window":0,"people_scan_dedupe":100,"queue_age_sample_budget":100,"request_read_dedupe":100,"serving_config_cache":100,"singleton_loops":100,"subscription_cache":100,"sync_snapshot_resolve_cache":100,"usage_month_cache":0,"usage_month_total":0}', category: rollout}
+ FIRESTORE_READ_LEVERS: {value: '{"action_items_page":100,"backfill_task_reads":100,"batch_privacy_memoize":0,"bpp_decision_cache":100,"bpp_generation_memo":100,"candidates_page":100,"canonical_statuses_dedupe":100,"conversation_list_cursor":100,"deletion_marker_cache":100,"finjob_candidate_queries":100,"historical_scan_memo":100,"ledger_purge_coalesce":100,"mcp_conversation_cards_cache":100,"memory_list_index_window":0,"people_scan_dedupe":100,"privacy_checks_shadow":100,"privacy_ttl60":100,"queue_age_sample_budget":100,"request_read_dedupe":100,"serving_config_cache":100,"singleton_loops":100,"subscription_cache":100,"sync_snapshot_resolve_cache":100,"usage_month_cache":0,"usage_month_total":0}', category: rollout}
FSR_USAGE_MONTH_TOTAL_EPOCH: {value: c2fs_20261026_r1, category: rollout}
# Batch ladder 2026-10-29 (lead ruling 12:15Z): pin shadow 25 so a Cloud Run deploy
</file context>
|
|
||
|
|
||
| def _read_kill_flag() -> bool: | ||
| from database.account_deletion_marker import account_deletion_firestore_client |
There was a problem hiding this comment.
P3: Move the function-local imports in this module to module scope to comply with backend/AGENTS.md; keep client construction inside _read_kill_flag() so it remains lazy.
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/privacy_ttl_cache.py, line 104:
<comment>Move the function-local imports in this module to module scope to comply with `backend/AGENTS.md`; keep client construction inside `_read_kill_flag()` so it remains lazy.</comment>
<file context>
@@ -0,0 +1,147 @@
+
+
+def _read_kill_flag() -> bool:
+ from database.account_deletion_marker import account_deletion_firestore_client
+
+ snapshot = account_deletion_firestore_client().collection(KILL_COLLECTION).document(KILL_DOCUMENT).get()
</file context>
…d Firestore read Luna r1 P1 on #24622: with deletion_marker_cache on, the existing Redis negative cache could return an already-aged absence after a marker write whose Redis invalidations failed. The 60s cache then restarted the clock on it, for up to ~89s of staleness. With privacy_ttl60 on, decisions and fills now come from a direct Firestore read, never through the Redis layer. The regression test fails without the fix. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
Importing account_deletion_marker from privacy_ttl_cache pulled fsr_read_cache, redis_db and transitively utils.cloud_tasks into the GPU batch worker's import closure (test_gpu_batch_retry_cap_does_not_reach_cloud_tasks). The kill-switch reader now uses database._client.get_data_plane_firestore_client, the same plane account_deletions lives on. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e23921a96
ℹ️ 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".
| with _kill_lock: | ||
| if _kill_state and _kill_state[0][0] > now: | ||
| return _kill_state[0][1] | ||
| try: | ||
| off = _read_kill_flag() |
There was a problem hiding this comment.
Coalesce concurrent kill-switch polls
When multiple worker threads reach a privacy check after the polling interval expires, they all pass the locked cache check and independently call _read_kill_flag() because the lock is released before the read and no in-flight poll is recorded. A concurrent 16-caller reproduction issued 16 Firestore reads instead of one. With these levers enabled fleet-wide, every polling boundary can generate redundant synchronous reads and occupy database workers, undermining the intended once-per-process polling bound. Make the refresh single-flight, with waiting callers reusing its result.
Useful? React with 👍 / 👎.
| TTL_CACHE = Counter( | ||
| 'privacy_ttl_cache_total', '60s-bounded privacy decision reuse (hit, miss, store)', ['family', 'result'] | ||
| ) |
There was a problem hiding this comment.
Export the new TTL counter from isolated sync workers
For jobs executed through utils/sync/worker_runtime.py, the supervisor's /metrics endpoint exports only counters retained by WorkerPrivacyMetrics. Its _snapshot() filters metric names against the explicit COUNTERS allowlist in utils/sync/worker_privacy_metrics.py, which does not include privacy_ttl_cache. Consequently, the new batch-cache hit/miss/store observations are discarded both during execution and when the child exits, leaving this worker plane without the telemetry needed to measure cross-attempt reuse. Add the new counter family to that exporter and its retention tests.
Useful? React with 👍 / 👎.
# Conflicts: # backend/config/firestore_read_levers.py
…44) (#24636) ## What One-line repair on main: set `backend/config/flag_budget.json` `count` from 243 to 244. ## Why #24631 (`SYNC_OPUS_RAW_FRAME_WRITES`) and f513b1d (`BATCH_PULL_BUSY_BORROW_ENABLED`) each added one name and bumped `count` from 242 to 243 from the same base. Once both merged, main had 244 names with `count` 243. `tests/unit/test_flag_budget.py::test_budget_file_declares_scope_and_count` (`count == len(names)`) has failed in every backend PR since 19:51Z; #24622's shard 3/8 failed on it. ## Verification `pytest tests/unit/test_flag_budget.py`: 24 passed. This includes the ceiling checks, so 244 stays within the budget's own limits. ## Failure class (fixes) Failure-Class: none A semantic merge race between two PRs that both edited a counter, not a recurring product failure class. ## Product invariants affected 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/24636?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/24636?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24636&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. -->
…; memory_list_index_window 25 (#24639) ## What Config only, one batched lever change: | Key | Change | Why | |---|---|---| | `FSR_SUBSCRIPTION_TTL_SECONDS` | 60 -> 55 (all services) | cl2-replay's verified privacy replay (1,049 faulted transitions, 2026-11-04 20:12Z) found that, with both invalidations lost, the Redis `EX 60` subscription/BYOK entry is still served at exactly +60.000s: 37 mismatches at 0s margin. 55s gives 0 with 5s margin. | | `action_items_ttl120` | 0 -> 5 | Ordinary lever from #24624: the version-bumped action-item page cache reuses pages for at least 120s instead of the deployed 30s. | | `memory_list_index_window` | 0 -> 25 | Back to the cohort that soaked 48h clean (#23536). The #24596/#24601 revert objected to the 0->100 jump, not the lever. | | `backend/docs/runbooks/external-list-reads.md` | wording | States the live 5% polling-cache cohort from #24623 (Luna r1 minor on #24623). | Luna r1 removed `lifecycle_record_pending_head` from this change: it cohorts on a single namespace key, so 5% would be off on every replica. A follow-up keys it per replica. This also satisfies lead2's enforce requirement for #24622 (`1104-b059ba`): the subscription TTL becomes 55s. The new privacy caches already use a strict `< 60.000s` bound. ## Rollout David's 2026-11-04 policy for ordinary read levers: 5% for 1-2h with the firestore-reads 5xx/latency guards, then 100% the same day in a follow-up. Rollback: set any key back to its previous value. ## Verification - `pytest tests/unit/test_render_backend_runtime_env.py tests/unit/test_verify_pusher_config_references.py tests/unit/test_firestore_read_levers.py tests/unit/test_backend_runtime_env_validator.py`: 294 passed. - `pytest tests/unit/test_fsr_s4_caches.py`: passes (TTL ceiling 60 unchanged; 55 is within it). - Local push gate ran with `BACKEND_UNIT_FILE_BUDGET_SECONDS=900` (host load ~50); CI keeps its own 300s budget. ## Product invariants affected - INV-MEM-4 (path match on `backend/deploy/runtime_env.yaml` only; no memory promotion behavior changes) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
…ead regression) (#24645) ## What `get_user_deletion_wipe_status` goes back to its pre-#24622 behavior, the shared Redis negative cache that writers fence by generation. The deletion marker no longer takes part in `privacy_ttl60`. The external-fence and tombstone families keep it. ## Why Measured on prod after #24622 served on Cloud Run (2026-11-04 22:13Z, `privacy_checks_shadow` on). `omi_firestore_billed_reads_by_caller_total` for `database.account_deletion_marker:_s4_read_deletion_status` was 53,867 per 10 min at 22:05Z and 530,315 per 10 min at 22:30Z, about +2.9M reads/h. With `privacy_ttl60` on, every marker decision read Firestore directly, which was Luna r1 P1's fix to avoid re-seeding a stale Redis negative. The per-process 60s cache only hit ~70% across Cloud Run instances (`privacy_ttl_cache_total{family="deletion_marker"}`: 485k hit / 208k miss per 10 min), while the shared Redis cache it bypassed had been holding this caller to ~1M reads/day. cl2-infracost set the runtime kill switch (`ops_kill_switches/privacy_decision_cache`) at 22:27:47Z; this PR is the durable fix. Shadow result for the deletion marker before the kill switch: 694k comparisons per 10 min, 0 mismatches. The correctness design was fine; the cost wasn't. ## Verification `pytest tests/unit/test_privacy_ttl_cache.py tests/unit/test_fsr_s4_caches.py tests/unit/test_account_deletion_auth_fence.py`: 126 passed. A new test pins that with `privacy_ttl60` on, the marker is served by the Redis negative cache (1 read across 5 calls) and never enters the process cache. ## Failure class (fixes) Failure-Class: none ## Product invariants affected 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/24645?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/24645?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24645&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. -->
…hes dark (#24650) ## What Config only. `privacy_checks_shadow`, `privacy_ttl60` and `bpp_decision_cache` go from 100 to 0 on every service. This ends the #24622 privacy shadow and leaves the 60s privacy caches dark. The code and its runtime kill switch stay. ## Why Measured on prod after #24622 served on Cloud Run (2026-11-04 22:13Z), using GMP `privacy_*` counters and `omi_firestore_billed_reads_by_caller_total`. **Correctness was fine.** There were 0 privacy mismatches (`stale_allow` / `block_reason`) across about 724k shadow comparisons in the first 10 min, of which 694k were deletion-marker, 25k batch and 4.4k external. The kill-switch guard tripped once, on 3 `stale_block` lines: the candidate was *more* restrictive, from a gate acquired between the two reads. **The savings aren't there on Cloud Run:** - `bpp_decision_cache` hit rate was about 0.4%. In a 30-min window, 81% of batch decisions had no memo token (`privacy_memo_requests_total{result="ineligible"}`), and the rest rotate on nearly every conversation write. Batch privacy reads didn't drop. - Deletion-marker reuse regressed reads 10x. It's fixed in #24645 and has been off via the kill switch since 22:27:47Z. - External-fence reuse hit about 83%, but the volume on Cloud Run is small. Fence and tombstone reuse would pay off on listen/pusher, whose listen leg is held. **Shadowing has a real cost.** `privacy_checks_shadow` turns off `bpp_generation_memo` enforcement, and shadow re-walks add about 9% of batch-privacy reads (`privacy_check_reads_total{mode="shadow"}`). That comes to roughly 15% of batch-privacy reads, about 1.4M reads/h at tonight's backlog. ## Rollback Set the three keys back to 100. The kill-switch document `ops_kill_switches/privacy_decision_cache` can stay set either way. ## Verification `pytest tests/unit/test_render_backend_runtime_env.py tests/unit/test_verify_pusher_config_references.py tests/unit/test_backend_runtime_env_validator.py tests/unit/test_firestore_read_levers.py`: 294 passed. ## Product invariants affected - INV-MEM-4 (path match on `backend/deploy/runtime_env.yaml` only; no memory promotion behavior changes) 🤖 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/24650?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/24650?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24650&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. -->
…ead regression) Measured after BasedHardware#24622 served on Cloud Run (2026-11-04 22:13Z, shadow on): account_deletion_marker:_s4_read_deletion_status billed reads went from 54k to 530k per 10 min. With privacy_ttl60 on, every marker decision read Firestore directly (the r1 P1 fix) instead of the shared Redis negative cache, and the per-process 60s cache only hit ~70% across Cloud Run instances. The runtime kill switch was set at 22:27:47Z. This restores get_user_deletion_wipe_status to its pre-BasedHardware#24622 behavior (Redis negative cache, generation-fenced by writers); the fence and tombstone families keep privacy_ttl60. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
…hes dark privacy_checks_shadow, privacy_ttl60 and bpp_decision_cache 100 -> 0 on every service. Measured on prod after BasedHardware#24622 served (2026-11-04 22:13Z): - Correctness: 0 privacy mismatches (deletion_marker 694k, batch 25k, external 4.4k shadow comparisons in the first 10 min). The only guard trips were stale_block (candidate more restrictive than live). - Value: bpp_decision_cache hit ~0.4%; 81% of batch decisions have no memo token and the rest rotate on nearly every conversation write. The deletion marker path regressed reads (fixed in BasedHardware#24645). External-fence and tombstone reuse is real but small on Cloud Run; its value would be on listen/pusher. - Cost of shadowing: privacy_checks_shadow turns off bpp_generation_memo enforcement, and the shadow re-walks add ~9% of batch privacy reads (~15% total, ~1.4M reads/h). The runtime kill switch has kept the caches off since 22:27:47Z. This removes the shadow cost and restores attempt-memo enforcement. Rollback: set the three keys back to 100. Co-Authored-By: Claude Opus 5.5 <[email protected]>
What
60-second-bounded reuse of privacy, deletion, tombstone and legal-hold decisions, per David's 2026-11-04 ruling (a cached decision may be reused for at most 60s, so a deletion, privacy change or legal hold takes effect everywhere within 60s). Three caches, each behind its own
FIRESTORE_READ_LEVERSkey (absent = off), plus one runtime kill switch:bpp_decision_cachebatch_pipeline_privacy.assert_batch_write_allowed(transactional batch intake/compute/projection)batch_privacy_write_fence), and the token read stays in the transaction's conflict set. Entries also expire 60s after the walk started.privacy_ttl60legal_holds.external_write_fence(non-transactional only),conversation_tombstones.is_deleted,account_deletion_marker.get_user_deletion_wipe_statusdatabase/privacy_ttl_cache.py: a thread-safe bounded LRU. Expiry is anchored to the monotonic instant the authoritative read started, so a slow read cannot extend the bound, and a read slower than 60s is never stored. Keys carry plane, uid, family and a hashed variant, so one conversation's absence never answers for another.ops_kill_switches/privacy_decision_cache{disabled: true}turns all three caches off in every process within 30s. Each process polls it at most once per 30s and only while one of the levers is on. If the switch can't be read, the caches count as disabled and every decision reads live. Gauge:privacy_ttl_cache_disabled.privacy_checks_shadow, live authority decides every time. The candidate is what the cache would have answered before the live read, and shadow costs no extra read for theprivacy_ttl60families.compare()now labels a stale allow whose cached entry is at most 60s oldstale_within_ttl: that is the accepted cost of the ruling, kept apart from real mismatches (stale_allow/stale_block/block_reason), and the kill-switch guard trips on real mismatches only.privacy_ttl_cache_total{family,result=hit|miss|store}is new. The Cloud Run GMP keep-lists (cloud_run_gmp_sidecar.yaml,cloud_run_gmp_sync.yaml) now export theprivacy_*_totalcounters. Before this,privacy_decision_mismatch_totalfrom Cloud Run (integration, sync, backend) never reached GMP, so the shadow evidence couldn't be read there.Why
The firestore-reads loop snapshot for 2026-11-04 16Z shows
batch_pipeline_privacy:readat about 3.2M reads/h on backend-integration and backend-sync. The fences (legal hold, deletion marker, tombstone) add about 1.75M reads/h across sync, listen and pusher. Coverage that hour was 0.70, so the true volume is higher. The earlier token-validated caches (#24402) still paid one read per decision (no saving for tombstones), and the batch memo was scoped to one task attempt.Writer fencing (93d4a1)
No new writer-fencing project is needed.
database/batch_privacy_write_fence.pyalready appends a token rotation to every commit that writesaccount_deletions,legal_holds,legal_hold_deletion_gates, users privacy fields, conversation authority fields ordeleted_conversations. That makes the batch reuse exact. The advisory caches rely on the 60s bound by ruling, not on the token.Review fixes (round 1)
privacy_ttl60on, decisions and fills come only from a direct Firestore read. The regression test fails without the fix.test_gpu_batch_retry_cap_does_not_reach_cloud_tasks. The kill-switch reader importedaccount_deletion_marker, which pulled Redis and Cloud Tasks into the GPU batch worker's import closure. It now usesdatabase._client.get_data_plane_firestore_client.Rollout (David's 2026-11-04 soak policy for privacy levers)
privacy_checks_shadow:100, privacy_ttl60:100, bpp_decision_cache:100on every service, so the roll that ships the code starts the live shadow. Shadow is decision-neutral: live authority decides every time. It costs reads while it runs, because shadow wins overbpp_generation_memoand batch re-walks the candidate on a miss.privacy_cachestage and the prod synthetic canary on dedicated test accounts), then 2h of live shadow at 100% with zero real mismatches.privacy_checks_shadow. A guard arms after one full lookback window and sets the kill-switch document on the first real mismatch.Verification
Synthetic transitions with the real readers and real writers (
data/run-2026-11-04-infracost/tools/privacy_canary.pyin omi-workspace): Firestore emulator, 8 synthetic uids x 20 iterations: 1,120 transitions, 4,640 probes, 0 mismatches, 320 within-bound stale answers, and hits on all four families. Prod data plane (prod-operator, synthetic uidsomi-privacy-canary-01..16only, auditdata/run-2026-11-04-infracost/canary-audit-prod.jsonl): 1,559 transitions, 0 mismatches. Every document created was deleted.Config contract tests (
test_render_backend_runtime_env.py,test_verify_pusher_config_references.py,test_firestore_read_levers.py): 143 passed.pytest tests/unit/test_privacy_ttl_cache.py: 20 passed. Covers the bound, fixed at 60s and anchored to read start, with no storing of reads slower than 60s. Also covers the LRU cap, tombstone reuse then deletion visible at 60s, key isolation by conversation and plane, a never-cached block on the external fence, transactional fences staying live, deletion-marker reuse with uncached errors, shadow keeping live authority and labelling within-bound staleness, batch reuse across attempts with one token read, misses after token rotation, 60s expiry and conversation-set keys, expected_generation, the lever off, and the kill switch (including fail-closed and the poll interval).Related suites
test_privacy_shadow_and_session.py test_bpp_generation_memo.py test_fsr_s4_caches.py test_account_deletion_auth_fence.py test_firestore_read_site_attribution.py test_firestore_read_levers.py test_attach_cloud_run_gmp_sidecar.py: 340 passed.Local push gate ran with
BACKEND_UNIT_FILE_BUDGET_SECONDS=900: at host load ~50,test_firestore_query_shapes.pyhit the default 300s wall twice (fixture setup alone took 202s; it passes 544/544 when run directly). CI keeps its own 300s budget.Product invariants affected
backend/deploy/runtime_env.yamlonly; no memory promotion behavior changes)Failure class (fixes)
Failure-Class: none
The
fix:commits repair review findings inside this PR's own new code before merge, not a shipped failure class.🤖 Generated with Claude Code