Skip to content

firestore-reads: enable batch_privacy_memoize 0->5 (WQ16, config-only) - #23554

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/firestore-reads-wq16-bpm5
Oct 25, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/firestore-reads-wq16-bpm5

Conversation

@Git-on-my-level

Copy link
Copy Markdown
Member

Summary

Config-only: enable batch_privacy_memoize at 5% in the prod FIRESTORE_READ_LEVERS literal. All 16 existing keys are byte-identical to the served literal on backend-02109-qzv; the only delta is the added "batch_privacy_memoize":5.

Behavior code already merged and served via #23072 (merge d90643d, ancestor of the serving release; memoized per-job privacy assertion). The lever key is in main KNOWN_LEVERS (firestore_read_levers.py:46). The lever has been dark at 0 since then; this PR makes it addressable at the cautious first ramp step.

Caller pool being addressed (loop snapshot baseline-2026-10-24T09-45Z-pre-bpm.json, 1h caller window, window_end 2026-10-24T08Z): database.batch_pipeline_privacy:read ~3.36M reads/h across backend-sync + backend-sync-backfill (not_found storms on other + lookups on users/conversations) ≈ 81M/day at 1hx24 — the top measured origin. Expected saving is unknown until the ramp readout; predicted 50M/day is the caller-pool hypothesis registered in the loop ledger, not a measurement.

Product invariants affected

  • INV-FSR-LEVERS — lever percentage changes only via this literal; absent keys remain 0/off; REPLACE-mode literal kept complete (17 keys) at all sites.
  • INV-READ-BUDGET — at 5% cohort the memoized path serves most per-write privacy reads from the per-job memo; off-cohort behavior is byte-identical to today.
  • INV-MEM-4 — required citation: this PR touches the locked runtime_env/charts path family this invariant guards. It changes only a Firestore read-lever percentage (read-path memoization of an existing per-write privacy assertion); it adds no promotion route, fast-track pass, or canonical-lineage change.

Verification

  • Literal consistency: all 54 literal occurrences under backend/ parsed and compared; every deployed-literal site (runtime_env/_base.yaml x12, rendered runtime_env.yaml x24, 4 listen/pusher chart values, flag registry, both pinned contract tests) equals the exact 17-key target; the 10 partial literals in test_fsr_s5_action_items.py are intentional single-lever fixtures, unchanged.
  • Contract tests: backend/.venv/bin/python -m pytest backend/tests/unit/test_render_backend_runtime_env.py backend/tests/unit/test_verify_pusher_config_references.py -q → 121 passed.
  • Loop-side pre-enable baseline pinned (post-code-serve, pre-enable): baseline-2026-10-24T09-45Z-pre-bpm.json, coverage 0.685, missing_services [].
  • No GCP write tier used; measurement used the read-only prod tier.

UI-Evidence: none — backend config only, no UI change.

Failure-Class: none

Rollout and rollback

Rollout: loop-owned lever config at 5%, then per the loop runbook ramp rule (verify PASS x2 ticks after 3h → 100% candidate; grades on absolute caller reads vs the pinned baseline). Deploy train order remains listen → pusher → Cloud Run (rollout lead owns the train). Rollback: revert this commit (or a follow-up config PR setting the key to 0), then the same train.

…>17 keys)

Top measured origin database.batch_pipeline_privacy:read ~3.36M reads/h
(~81M/day 1hx24, loop baseline-2026-10-24T09-45Z-pre-bpm.json, window_end
2026-10-24T08Z) storms per-write privacy reads on backend-sync/backfill.
Memoize code served since d90643d (#23072); key already in KNOWN_LEVERS.
All other 16 keys byte-identical to the served literal. Contract tests 121
pass; literal consistency checked at all 54 backend sites.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-25T00:40:53.410252Z 14c3e34 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level
Git-on-my-level merged commit 4013d75 into main Oct 25, 2026
58 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/firestore-reads-wq16-bpm5 branch October 25, 2026 04:41
Git-on-my-level added a commit that referenced this pull request Oct 25, 2026
…0.0068 vs ref 0.0010) (#23575)

## Summary

Firestore reads loop URGENT flag-off: `singleton_loops`,
`usage_month_cache`, `backfill_task_reads`, `historical_scan_memo`,
`ledger_purge_coalesce` **100 → 0**; the other 12 keys byte-identical to
the deployed literal (17 keys, incl. `batch_privacy_memoize:5` from
#23554). Generated with `avo/firestore-reads/set_levers.py`.

- Why now: loop verify UNSAFE at 08Z and 09Z on 2026-10-25 —
backend-sync 5xx rate **0.0034 (640 errs) at 08Z → 0.0068 (1239 errs) at
09Z** vs lever-free reference 0.0010 (roughly doubling hourly). All five
flagged levers are the 100%-pct levers verify grades against the
backend-sync guard. Evidence is ambiguous (the lead's op1custody train
served new backend-sync code ~05:37–06Z, same service), so per runbook
we flag off on breach anyway: if the 5xx rate persists at lever 0, the
levers are exonerated and re-enable at 5%.
- Off-path restores pre-lever behavior for all five levers (per-process
loops, uncached reads, per-task scans — worst case equals lever-off).
Reads cost of this flag-off is bounded and known: these callers regain
reads only until root cause lands.
- Rendered literal identical across `_base.yaml`, regenerated
`runtime_env.yaml`, listen/pusher dev+prod values, the flag registry
doc, and the two pinned contract tests. The literal keeps all 17 keys —
missing keys default OFF (`backend/config/firestore_read_levers.py`).

## Product invariants affected

- INV-MEM-4 — config-only lever rollout; no data-path, promotion or
authority change; each lever reverts to its pre-lever per-process
behavior at 0.
- INV-DATA-1 — no routing or ownership change; value-only edit of the
existing `FIRESTORE_READ_LEVERS` key.

## Test plan

- `backend/tests/unit/test_verify_pusher_config_references.py` +
`backend/tests/unit/test_render_backend_runtime_env.py` +
`backend/tests/unit/test_backend_runtime_env_validator.py`: **267
passed** locally (lane venv, this commit).
- Diff checked: exactly the 5 flagged keys 100→0 in every literal site;
all other 12 keys unchanged; 17 keys in both old and new literals.

## Rollout

1. Train order **listen → pusher → Cloud Run** (URGENT flag-off;
backend-sync 5xx doubling hourly at time of writing).
2. Lead handoff posted on merge; ramp clocks for untouched levers
unaffected (`batch_privacy_memoize` stays 5).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant