Repository navigation
perf(privacy): add WQ26-fenced negative lookup cache - #24751
Conversation
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.
1 issue found across 14 files
Confidence score: 3/5
backend/docs/runbooks/privacy-check-shadow.mdrelies on a denominator that the GKE worker endpoint does not expose, so the all-plane shadow-hit metrics will be incomplete. Register the privacy collectors in the worker’s custom registry.
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/docs/runbooks/privacy-check-shadow.md">
<violation number="1" location="backend/docs/runbooks/privacy-check-shadow.md:110">
P1: The GKE worker endpoint does not expose `privacy_negative_lookup_total`, so PodMonitoring cannot provide the all-plane shadow-hit denominator claimed here. Register the privacy collectors in the worker’s custom registry (and verify the parent aggregation) before treating worker coverage as qualification evidence.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| candidate NOT_FOUND; a live document is always a mismatch, even within TTL. | ||
| The denominator for qualification is shadow **hits**, not cold misses. Both | ||
| Cloud Run keep-lists retain it; GKE PodMonitoring retains application counters | ||
| without a name keep-list, and isolated workers fold the counter across exits. |
There was a problem hiding this comment.
P1: The GKE worker endpoint does not expose privacy_negative_lookup_total, so PodMonitoring cannot provide the all-plane shadow-hit denominator claimed here. Register the privacy collectors in the worker’s custom registry (and verify the parent aggregation) before treating worker coverage as qualification evidence.
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/docs/runbooks/privacy-check-shadow.md, line 110:
<comment>The GKE worker endpoint does not expose `privacy_negative_lookup_total`, so PodMonitoring cannot provide the all-plane shadow-hit denominator claimed here. Register the privacy collectors in the worker’s custom registry (and verify the parent aggregation) before treating worker coverage as qualification evidence.</comment>
<file context>
@@ -80,6 +80,48 @@ overrides can only shorten that ceiling. Rollouts use the declared reader levers
+candidate NOT_FOUND; a live document is always a mismatch, even within TTL.
+The denominator for qualification is shadow **hits**, not cold misses. Both
+Cloud Run keep-lists retain it; GKE PodMonitoring retains application counters
+without a name keep-list, and isolated workers fold the counter across exits.
+
+Proposed ramp after the lead verifies writer-fence coverage on every plane:
</file context>
Problem
The recorded 2026-11-06 ~04:50Z Phase 1a measurement found ~2,073 NOT_FOUND reads/s out of 3,834 privacy reads/s: conversation tombstones 829/s, account deletion markers 695/s, missing conversations 549/s. Source:
firestore-phase1-1a-0450Z.mdin the prescribedomi-workspace/data/run-2026-11-05-omi-pipeline/run record. These are dated recorded measurements, not a fresh production measurement or a forecast of savings. The prescribed scout report records the 2026-11-04 Redis-bypass seeding regression (54k to 530k reads/10 min), which ruled out reviving that path.Change and invariant
A cached NOT_FOUND must never hide a tombstone, account deletion, legal hold, or newly existing conversation. The process-local 50,000-entry LRU stores only real NOT_FOUND reads, keyed by client/plane, uid and exact document path, with the owner's WQ26 memo token and server revision including nanoseconds. Each reuse requires that same decision to have re-read the token inside the same transaction and compared it identically. The owner token remains in Firestore's conflict set; TTL is a second 60-second bound, measured before the live absence read. No Redis, speculative seeding, positive rows or authorization decisions enter this cache. Missing/malformed tokens, full-row exports and nontransactional calls stay live.
The existing Commit fence already rotates tokens atomically for all writer families, including metadata-only conversation CREATE and merge-upsert. Added regression coverage for those create shapes and extended the actual-writer emulator matrix to run with negative lookup caching as well as generation memoization. Legal holds retain their existing external-fence policy; their writes invalidate the lookup hints.
Net-zero flags (lead2 ruling 258db3 (03)): the sole new lever is
privacy_negative_lookup_cache(0 off, positive percent selects the candidate cohort). Existingprivacy_checks_shadowselects shadow mode within that cohort; shadow takes precedence and always reads live, bypassing generation-memo hits to gather evidence. With the new lever 0, existing decision-shadow behavior stays unchanged. Noprivacy_negative_lookup_shadowlever remains.The retired
batch_privacy_memoizeslot pays for the new lever: removeBatchPrivacyMemo, its store/projection caller plumbing, snapshot-only replay instrumentation/assertions, and all runtime/worker chart literals (including the worker's former 100% value). The live authority walk and the WQ26 generation memo remain. Tests retain retired-key/off-path, ordering, retry and denial-parity guards. The flag registry records the replacement; the sharedFIRESTORE_READ_LEVERSenv budget slot has no separate per-sublever budget entries. Known lever inventory: exactly one added and one retired.Identifier-free hit/miss/mismatch counters are on both Cloud Run GMP keep-lists and survive isolated sync-worker exits/SIGKILL. The GPU worker registers the counter on its private registry, and a real pod-parent endpoint test verifies each child's series is retained once. No negative-cache cohort is enabled; runtime config changes only remove the retired lever.
Validation
CI follow-up: removed the obsolete WQ12-only monkeypatch from
test_direct_transaction_reads_are_named; production code is unchanged. Grep plus an AST scan found no other retired store patch targets.test_batch_pipeline_contention_errors.pyandtest_batch_pipeline_pump.pyboth pass in the file-isolatedtest.shrunner. Merged currentorigin/main(PR #24752) and included its owner-drain tests in the same selection.BACKEND_UNIT_TEST_FILE_LIST=... BACKEND_PYTEST_WORKERS=3 bash backend/test.sh, throughomi-heavy: 1046 passed across 26 files, one slow test deselected by the standard runner. Covers privacy/cache/fence/memo, WQ12 retirement, store/projection ordering and retries, read/write budgets, flag/stage ratchets, config/chart rendering, replay unit contracts, GMP retention and real GPU-worker/pod metrics endpoints.tests/integration/test_bpp_generation_fence_emulator.py -m integration -q: 78 passed on the net-zero revision, throughomi-heavy.tests/integration/test_replay_harness_privacy_firestore.py -m integration -q: 21 passed, including the retired-snapshot/generation-memo baseline and runtime-config cases. Together the emulator files passed 99 tests. Files run in separate pytest processes; an exploratory combined-file run was discarded after exposing shared-process contamination.Invariant: INV-MEM-4 remains unchanged. Runtime manifest edits remove only the retired read-dedupe lever; canonical promotion authority and its routing are untouched.
Risk, rollout and rollback
Privacy-critical read suppression depends on complete WQ26 writer coverage. Standalone/external writers bypassing the fence remain a rollout blocker. Shadow moves the token read ahead of the lookup families and intentionally gives up generation-memo savings for sampled owners; measure absolute reads by plane. Production savings and all-plane coverage have not been verified in this code-only lane. No GCP credential tier was used; no production access, merge or deploy.
Owner: lead2. After verifying writer artifacts on every plane: hours 0–2 set
privacy_negative_lookup_cache:100and existingprivacy_checks_shadow:100(shadow only); gate = zero mismatches on >=10,000 shadow hits (actual compared lookups), all serving planes represented and no scrape gaps. Hours 2–4 enforce 10%, hours 4–6 enforce 50%, hour 6 onward enforce 100%, each advancement owned by lead2 after a clean preceding two-hour window. Set existingprivacy_checks_shadow:10during enforcement; it wins overlapping cohorts. Insufficient samples extend the window. Any mismatch stops the ramp and requires writer investigation and shadow requalification.Rollback:
privacy_negative_lookup_cache: 0immediately restores live lookup enforcement; also setprivacy_checks_shadow: 0to restore the exact previous read path. No data migration or Redis invalidation. The existing default/percentage semantics are used as requested; this PR does not enable enforcement before shadow qualification.Failure-Class: none
This is a read-reduction feature with a new correctness guard; no previously shipped authorization policy is changed.