Repository navigation
fix(batch): back off owners stopped by the privacy fence too - #24752
Conversation
After #24747 served, its refusal fall-through re-fences assignment and the fence raises BatchPrivacyBlocked, so the walk stops 'privacy_blocked'. The #24743 backoff only matched 'blocked_privacy_*', so those owners were re- picked every pass: owner drain fell from 4.3 to 0.2 rows/s (2026-11-06 05:16-05:26Z). Treat 'privacy_blocked' as a privacy stop and record its head version. Scheduling only. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 3 files
Confidence score: 5/5
- The drain assertion in
backend/tests/unit/test_batch_pipeline_owner_drain.pydepends on the process-level privacy-backoff kill switch, so it may fail depending on the test environment. SetPROJECTION_DRAIN_PRIVACY_BACKOFFexplicitly before requesting the drain.
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/tests/unit/test_batch_pipeline_owner_drain.py">
<violation number="1" location="backend/tests/unit/test_batch_pipeline_owner_drain.py:1057">
P3: This assertion depends on the process-level privacy-backoff kill switch being enabled. Set `PROJECTION_DRAIN_PRIVACY_BACKOFF` explicitly before requesting the drain so the regression test remains hermetic when the supported switch-off configuration is present.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| await settle(projector) | ||
| assert counter._value.get() == before + 1 | ||
| assert not drains.delayed and not drain_timers | ||
| assert BURST in drains.delayed and len(drain_timers) == 1 |
There was a problem hiding this comment.
P3: This assertion depends on the process-level privacy-backoff kill switch being enabled. Set PROJECTION_DRAIN_PRIVACY_BACKOFF explicitly before requesting the drain so the regression test remains hermetic when the supported switch-off configuration is present.
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/tests/unit/test_batch_pipeline_owner_drain.py, line 1057:
<comment>This assertion depends on the process-level privacy-backoff kill switch being enabled. Set `PROJECTION_DRAIN_PRIVACY_BACKOFF` explicitly before requesting the drain so the regression test remains hermetic when the supported switch-off configuration is present.</comment>
<file context>
@@ -1051,7 +1054,7 @@ async def test_generic_privacy_stop_is_counted_as_other(monkeypatch, drain_timer
await settle(projector)
assert counter._value.get() == before + 1
- assert not drains.delayed and not drain_timers
+ assert BURST in drains.delayed and len(drain_timers) == 1
</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.md` in the prescribed `omi-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). Existing `privacy_checks_shadow` selects 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. No `privacy_negative_lookup_shadow` lever remains. The retired `batch_privacy_memoize` slot pays for the new lever: remove `BatchPrivacyMemo`, 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 shared `FIRESTORE_READ_LEVERS` env 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.py` and `test_batch_pipeline_pump.py` both pass in the file-isolated `test.sh` runner. Merged current `origin/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`, through `omi-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. - Loopback-only Firestore emulator: `tests/integration/test_bpp_generation_fence_emulator.py -m integration -q`: **78 passed** on the net-zero revision, through `omi-heavy`. - Separate loopback replay emulator process: `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. - Final mandatory push guards passed: **53 repository checks**, runtime-env validation, format/source closure, bounded unit selection, and type checking with **0 errors**. PR metadata names INV-MEM-4. The standard type checker still reports existing warnings; no production access was used. 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:100` and existing `privacy_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 existing `privacy_checks_shadow:10` during 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: 0` immediately restores live lookup enforcement; also set `privacy_checks_shadow: 0` to 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.
Problem
After #24747 served (train cl2d-1106c, 2026-11-06 05:13Z) the projection owner drain collapsed: rows advanced 4.3/s -> 0.2/s (backend-integration rev 01590-qzf, 05:16-05:26Z). Productive
endturns fell 540 -> 11 per window. Therefusal_no_longer_appliesstops were gone, replaced byprivacy_blocked(507 per 10 min). #24747's fall-through retries assignment, and the assignment fence raisesBatchPrivacyBlocked, so the walk stopsprivacy_blocked. The #24743 backoff only matchedblocked_privacy_*, so those owners were re-picked every pass and starved the drain. Prod-safety flagged exactly this as a #24747 follow-up. The trip (PROJECTION_PRIVACY_REFUSAL_RESUME=off) is requested.Fix
is_privacy_stop(): the drain backoff (and its stop bookkeeping) coversprivacy_blockedas well asblocked_privacy_*, for zero-progress turns only. Productive turns are never delayed.blocked_head(result id + update_time) onBatchPrivacyBlockedtoo, so the backoff can re-check that exact row early, as it already does forProjectionBlockedprivacy stops.PROJECTION_DRAIN_PRIVACY_BACKOFF.Failure-Class: none
(A scheduling gap between two kill-switched features, found by the post-train gate.)
Tests
PRIVACY_STOPSnow includesprivacy_blocked(defers, then retries via the TTL path); the fence stop is counted underotherAND backed off; a new walk test provesblocked_headis recorded forBatchPrivacyBlocked. Via test.sh: test_batch_pipeline_owner_drain.py 112 passed; test_batch_pipeline_projection.py 64 passed.Risk / rollback
Scheduling only. Rollback:
PROJECTION_DRAIN_PRIVACY_BACKOFF=offor revert. Once this serves,PROJECTION_PRIVACY_REFUSAL_RESUMEcan be re-enabled and measured again.Evidence: omi-workspace
data/run-2026-11-05-omi-pipeline/posttrain-gate-24747.txt.🤖 Generated with Claude Code