Repository navigation
fix(deploy): persist Firestore lever cuts of 2026-11-14 (SCA-2173) - #25277
Conversation
Co-authored-by: multica-agent <[email protected]>
Codex Review Summary: ✅ CompletedThis 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. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
FIX — reviewed PR #25277 at exact head de6c8913e1a1a09e35d2f0fe6e115593cad7e5fb (13-file diff). The replacement head has not appeared: both GitHub metadata and the remote PR ref still identify this SHA. This verdict does not certify a future commit.
The smallest config/test fix is to enable the two monthly readers on prod backend as ordered, regenerate artifacts/fixtures, and update the stale renderer contract without weakening it. See backend/deploy/runtime_env/prod.overlay.yaml:576 (backend still 0/0) and backend/tests/unit/test_render_backend_runtime_env.py:1393–1410 (old monthly scope, pending-head and privacy/timeliness pins). Merge current main as requested by SCA-2176, then rerun the checks at the resulting SHA. Also correct the PR's “shadow setting changes only sampling” characterization.
- Service applicability. All five keys have reachable runtime consumers on each of backend-integration, backend-sync and backend; none is intrinsically a no-op on any of those three. They run the shared
main:app(backend/Dockerfile:63);main.py:148mounts the role, whose default is all (app_roles.py:156). Users/support/sync/batch routes mount atapp_roles.py:222–244. This establishes code reachability, not live traffic or an always-running sampler.
| Key | integration | sync | backend | Runtime consumer |
|---|---|---|---|---|
| usage_month_cache | yes, 100 | yes, 100 | yes, currently 0 | database/user_usage.py:602–623,651,667 → database/fsr_read_cache.py:284 |
| usage_month_total | yes, 100 | yes, 100 | yes, currently 0 | database/user_usage.py:654,670 → database/monthly_usage_totals.py:220 |
| lifecycle_record_pending_head | yes | yes | yes | database/lifecycle_metrics_queries.py:31; utils/batch_pipeline/metrics.py:438–443 |
| batch_timeliness_leader | yes | yes | yes | utils/batch_pipeline/metrics.py:506; database/batch_pipeline_store.py:1030 |
| privacy_checks_shadow | yes | yes | yes | database/batch_pipeline_privacy.py:94–107,323–335; database/privacy_negative_cache.py:173 |
The metric paths are reachable through routers/batch_pipeline.py:285–299 → utils/batch_pipeline/serving.py:226,382–398. Integration/backend have serving disabled (prod.overlay.yaml:838,1178), so they have no automatic serving loop; that does not make the mounted metrics/reconcile callers dead. Parsing/cohort behavior is config/firestore_read_levers.py:106–123.
- User-visible/admission effects. Monthly levers preserve policy and intended totals, but are not merely display-independent number-source switches.
utils/subscription.py:1439,1568–1584 feeds usage into remaining allowance and managed/on-device decisions; users/support expose it (routers/users.py:1416,1506;routers/support.py:53). Cache hits can therefore alter the observed balance and threshold timing. Cache TTL defaults to and is capped at 60 seconds, anchored before the durable fetch, with writer invalidation/generation fences (database/fsr_read_cache.py:175,180–186,284–359). Redis read/validation failure or an active writer falls through to the durable fetch; publish failure still returns the fetched value. It never serves an expired entry as an error fallback. With total=100, a ready schema/epoch-validated aggregate supplies totals/day-cutoffs; an unready aggregate may be rebuilt transactionally (a derived-data write), and exceptions/malformed sources fall back to the unchanged hourly query (database/monthly_usage_totals.py:163–208,220–248;database/user_usage.py:651–691). The aggregate has no TTL freshness window: correctness depends on atomic writer maintenance/invalidation (monthly_usage_totals.py:64–77). With both levers off, the hourly query runs directly. If that final read fails or usage is untrusted, the allowance resolver closes to the local path (utils/subscription.py:1571,1582–1584). Not every admission path uses these readers:utils/funded_processing.py:81usesdatabase/funded_usage_session.py:21–59.
Privacy nuance: shadow=0 does not introduce different allow/deny criteria, but it does change which path supplies authorizing evidence. With existing negative-cache/generation-memo levers on, it permits certified reuse instead of compulsory live shadow comparisons (database/batch_pipeline_privacy.py:94–107,323–335; database/batch_privacy_negative_cache.py:25–54). Token reads remain in the transaction conflict set (batch_pipeline_privacy.py:199–238); missing certification reads live. It is inaccurate to describe this as disabling telemetry alone.
-
Timeliness. No pipeline scheduling/admission/release gate is controlled by this key. It elects the timeliness metrics role in the data namespace (
utils/batch_pipeline/metrics.py:506–524). Two qualifications: it also caps pre-epoch backlog metric counts at 10,000 (database/batch_pipeline_store.py:1030), and enables the separately switched companion count path (metrics.py:524,560). “Exactly one process” is not unconditional: leases fail open on storage error or disabled lease election (utils/batch_pipeline/leader.py:69–72,107–115). Projection work precedes metrics independently (serving.py:213–226). -
Generated parity/checks. Both
python3 backend/deploy/compose_runtime_env.py --checkandpython3 backend/deploy/generate_read_lever_manifest.py --checkpass at this SHA;git diff --checkpasses. Generated output matches its inputs, including the wrong-for-Train-1 backend monthly 0/0 (runtime_env.yaml:3517;firestore_read_levers_manifest.json:2431), versus sync/integration 100/100 (runtime_env.yaml:3974,4875). Generator parity does not prove the requested values. Targetedbackend/test.shrun: 574 passed, 1 failed, the specified prod renderer contract. All four requested/config-related files were included. -
Protected scope. No custody, erasure, legal-hold implementation or provider backlog-release flag is edited. The provider flag remains default-off at
backend/config/batch_pipeline.py:648. However, privacy authorization read-path selection changes as detailed above; unchanged decision policy is the defensible statement, not “privacy decisions untouched” in an implementation sense. The reviewed diff also does not add a runtimeBATCH_PROJECTION_FINISH_BACKOFF_ENABLED=falsepin: the existing code default is false (backend/config/policy/kill_switches.py:29), and the worker omission assertion remains (backend/tests/unit/test_batch_pipeline_chart.py). The issue description's claimed pin is absent at this head.
Read-only review completed; no pushes, merges, deployments or production access. A new head needs its own exact-SHA verification before SHIP.
…(SCA-2222 Train 1) - backend prod literal now pins usage_month_cache/total=100 alongside backend-integration and backend-sync, per the SCA-2222 Train 1 ruling that the same five SCA-2173 lever values ride backend-sync and backend. - backend-sync-backfill keeps its ec191a row 3 pins (pending head 5, timeliness leader 0, privacy shadow 100); the earlier change to it is reverted so the PR does not move a surface the ruling did not name. - test pins updated with the SCA-2173/SCA-2222 citation; pending 5% monthly-reader patch preimage refreshed; registry doc regenerated.
Git-on-my-level
left a comment
There was a problem hiding this comment.
FIX — re-review of exact head a5ce0b89c2467de16488ae086c9cf63ac1bb2228, limited to the follow-up delta and my open points. Runtime config and the renderer contract are fixed; two evidence/wording corrections remain.
-
Backend monthly readers: resolved. Prod backend now has all five requested values at
backend/deploy/runtime_env/prod.overlay.yaml:576: monthly cache/total=100, pending head=100, timeliness=100, privacy shadow=0. Sync/integration match (:952,1702). Backfill intentionally retains monthly=0/0, pending head=5, timeliness=0, shadow=100 (:1337), as directed in this thread. The existing runtime consumers and the 60-second cache/fallback/admission qualifications from my first review still apply; this delta changes no reader implementation. -
Renderer contract: resolved.
backend/tests/unit/test_render_backend_runtime_env.py:1395–1413 cites SCA-2173/SCA-2222, pins the three services explicitly, and preserves the backfill exception and other hosts. I reran all four files throughbackend/test.sh: 575 passed. Both generator--checkcommands andgit diff --checkpass at this SHA. The rendered per-service values and manifest surface maps agree with source. -
PR-body shadow wording: still open. Its INV-MEM-4 paragraph still says “changes only its sampling percentage.” With
privacy_negative_lookup_cacheandbpp_generation_memoenabled, shadow=0 also selects certified reuse for authorizing reads:backend/database/batch_pipeline_privacy.py:94–107,323–335 andbackend/database/batch_privacy_negative_cache.py:25–54. Replace the sentence with: “Privacy TTL remains disabled. Setting privacy_checks_shadow=0 disables live shadow comparisons and permits the existing token-certified memo/negative-lookup paths to supply authorization evidence; allow/deny policy is unchanged.” This is a description correction, not a request to change the approved lever values. -
Manifest evidence regression from restoring backfill.
backend/deploy/generate_read_lever_manifest.py:49still says timeliness=100 on “all four Cloud Run services”; the generatedbackend/deploy/firestore_read_levers_manifest.json:4repeats it. That is now false: backfill is intentionally 0. Change the generator note to name backend, backend-sync and backend-integration at 100 and backend-sync-backfill at 0, then regenerate the manifest. Generator checks currently pass because they reproduce the stale prose. -
Scope: the follow-up changes declarations, generated evidence, fixtures and assertions; it adds no custody, erasure, legal-hold, privacy-policy or provider-backlog-release implementation changes. The previous qualifications remain: privacy authorization read-path selection changes; timeliness is advisory metrics election plus capped/companion counts, with fail-open leases, and does not gate pipeline work.
Smallest change to SHIP: correct the PR-body sentence and the generator's resolved note, regenerate the manifest, and rerun both generator checks. No further runtime-value change is requested. No push, merge, deployment or production access performed.
… note (SCA-2173) The RESOLVED note said "all four Cloud Run services" at batch_timeliness_leader 100, which stopped being true when backend-sync-backfill kept its ec191a row 3 pins. Name backend, backend-sync and backend-integration at 100 and backend-sync-backfill at 0. Regenerated manifest only; no runtime value change.
Git-on-my-level
left a comment
There was a problem hiding this comment.
SHIP — final re-review at exact PR #25277 head 6cb36ca4dc809439401150c94d118c273ae4346e. Both remaining FIX items are resolved.
backend/deploy/generate_read_lever_manifest.py:49now names worker/backend/backend-sync/backend-integration at timeliness=100 and backend-sync-backfill at 0; the regenerated note atbackend/deploy/firestore_read_levers_manifest.json:4agrees.- The PR body now uses the requested wording: shadow=0 disables live comparisons and permits existing token-certified memo/negative-lookup paths to supply authorization evidence; allow/deny policy is unchanged.
- Verified the entire delta from
a5ce0b89c2467de16488ae086c9cf63ac1bb2228: only those two note changes. Runtime values, renderer contract, manifest surface maps and application code are unchanged. The three target services retain all five requested values; backfill retains its explicitly approved exception. - At this exact SHA, both generator
--checkcommands andgit diff --checkpass. The prior independently run 575 passing tests remain applicable; I did not repeat them for this prose-only delta.
No open findings. The earlier review's qualifications still apply: monthly cache results can affect balance/admission threshold timing within the 60-second cache TTL; privacy changes authorization evidence reuse; timeliness is advisory metrics election plus capped/companion counts and does not gate pipeline work. This delta changes none of those behaviors or the custody, erasure, legal-hold or provider-backlog-release implementation.
Read-only review complete. No push, merge, deployment or production access.
…tegration (#25307) ## Why `BATCH_PROJECTION_FINISH_BACKOFF_ENABLED` is being turned on for prod backend-integration on the push captain's go (SCA-2222, SCA-2166, 2026-11-14), applied by the release executor as a config-only revision. Repo config did not declare the lever at all, so the next deploy rendered from the repo would drop it. That is what happened to five hand-set Firestore lever values at 13:45Z today (fixed by #25277). This PR makes the repo say what production is meant to run. Both conditions of the runbook's re-enable bar that could be met from code are met: - the one-time stamping pass completed at 12:46Z (read-only preview: complete, 0 missing), using #25225 and #25287; - the finish counters export from backend-integration since Train 1 (#25291): `omi_batch_projection_finish_reads_total` read 46,459 in ten minutes at 16:44Z with `omi_batch_projection_finish_completed_total` at 0. ## What changed - `backend/deploy/runtime_env/prod.overlay.yaml`: `BATCH_PROJECTION_FINISH_BACKOFF_ENABLED: 'true'` (category rollout) for `backend-integration`, which runs the finish sweep, and for `backend-sync`, which can reach the same sweep through its authenticated reconcile and batch metrics routes (review SCA-2270; its finish counters read 0 in production today, so this is consistency, not a second saving). - `backend/deploy/runtime_env.yaml`: regenerated. - `config/deployment-setting-classification.json`: the binding is classified as config. - `backend/docs/feature-flag-registry.md`: regenerated. - `backend/tests/unit/test_render_backend_runtime_env.py`: the pin moves from "absent everywhere" to "true on prod backend-integration and backend-sync, absent on every other service and environment". ## What did not change No code path. No other service: prod backend and backend-sync-backfill render an empty `BATCH_PIPELINE_WORKER_AUDIENCE`, so the authenticated reconcile route that reaches the sweep cannot be invoked on them. No dev environment. The code default stays off. ## Tests `tests/unit/test_render_backend_runtime_env.py` and `tests/unit/test_backend_runtime_env_validator.py`: 364 passed. Both generator `--check` commands pass. ## Rollout Rides the next backend train; until then the release executor's config-only revision carries the value. Proof after the flip, posted on SCA-2173: finish reads per ten minutes before and after, completions, fresh commits per ten minutes not below half the 15:12-15:42Z baseline, and no rise in over-SLA or unfinished projections. Kill switch: `BATCH_PROJECTION_FINISH_BACKOFF_ENABLED=false` restores the legacy finish page immediately. ## Product invariants affected - INV-MEM-4 Named because `backend/deploy/runtime_env.yaml` changes. This PR adds one batch-projection binding for backend-integration and touches no memory intake, consolidation, promotion or privacy TTL setting; INV-MEM-4 behaviour is unchanged. Failure-Class: FC-deploy-literal-reverts-operator-value 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Persist the 2026-11-14 SCA-2173 Firestore lever settings so later Cloud Run trains retain the approved cuts, and prevent the next GKE worker train from disabling the timeliness leader.
The prod batch worker and the prod Cloud Run services pin
batch_timeliness_leader=100andlifecycle_record_pending_head=100, and setprivacy_checks_shadow=0.backend-sync-backfillkeeps its ec191a row 3 pins (batch_timeliness_leader=0,privacy_checks_shadow=100,lifecycle_record_pending_head=5). Integration, sync and backend pin both monthly usage levers at 100 (SCA-2222 Train 1); backfill and the worker keep both at 0. All other effective levers, epochs, and finish-backoff settings are preserved.Regenerate runtime env, read-lever evidence, and the feature-flag catalog using repository generators. Refresh pinned expectations and the inactive pending 5% proposal against current values; its target remains 5%, with refreshed preimages.
Product invariants affected
Validation
make preflight: all 46 checks passed ona5ce0b89c2.--checkcommands (compose_runtime_env.py --check,generate_read_lever_manifest.py --check) passed after merging currentorigin/main(7966062a6c).test_render_backend_runtime_env.py,test_backend_runtime_env_validator.py,test_batch_pipeline_chart.py, andtest_qualify_usage_month.py: 575 passed.6cb36ca4dc809439401150c94d118c273ae4346e.Independent review
Luna review of commit
311bdc1e5c2cb88e6c9f7526af859b9920baa4abagainstorigin/mainc40fda41b067— no findings. The manifest resolves the prod leader discrepancy while retaining the unrelated unresolved differences. The backoff kill switch remains absent from worker values, and its test assertion remains. The SCA-2222 Train 1 follow-up only retargets the prod Cloud Run literals and their pins; reviewer rangenerate_read_lever_manifest.py --checkandgit diff --check; both passed.Privacy TTL remains disabled. Setting privacy_checks_shadow=0 disables live shadow comparisons and permits the existing token-certified memo/negative-lookup paths to supply authorization evidence; allow/deny policy is unchanged. No customer data or production resources are written.
Failure-Class: none
This persists approved operational settings; no missing co-host gate or application behavior is introduced. Rollback is reverting this config PR and regenerating artifacts. Release owner merges via merge commit; values ride each surface's next train. No deployment is requested today.