Skip to content

config(firestore): flag off singleton_loops + the four backfill-guarded levers - #22071

Merged
Git-on-my-level merged 1 commit into
mainfrom
lane/firestore-reads-flagoff-singleton
Oct 18, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
lane/firestore-reads-flagoff-singleton

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Summary

Firestore reads loop emergency flag-off config: five FIRESTORE_READ_LEVERS values → 0, other seven levers unchanged (batch-1 seven at 100%).

  • singleton_loops (100 → 0): loop verify graded UNSAFE at 2026-10-17T20:00Z — all five reconcile loops showed acquired=0 max_hold=0 for consecutive hours (lease admission starvation). Off-path restores the pre-lever per-process reconcile loops. Reviewed SAFE by zcode glm-5.3 (exec-erupt-ordinary-quote-scrap-observe-reject); the starvation window coincides with the sync owners' revision rolls (config(sync): disable expiry retirement in prod (undelivered-recording incident) #22061/fix(sync): retain expired obligations in durable redrive custody (dark) #22063 at 18:20Z/20:26Z) and leases fully recovered at 21–23Z, but the off decision stands pending lease rework (see decision-2026-10-18T00Z-flagoff-five.md).
  • backfill_task_reads (5 → 0), historical_scan_memo (5 → 0), ledger_purge_coalesce (5 → 0), people_scan_dedupe (5 → 0): their shared 5xx guard service backend-sync-backfill runs at ~8% error rate (2737 errs/h at 22Z vs the 1.46% reference; trend 630 → 2737/h from 15Z to 22Z through the sync owners' sequencer-rework deploys). The guard exemption for that service expires 2026-10-18T01:00Z and instructs "do not extend without new evidence" — the rate is not exoneration evidence, and per loop judgment rules ambiguous evidence ⇒ flag off; re-enable at 5% after the service recovers and the absolute readout shows a real drop. At 5% with scopes inert these levers remove ~0 reads (23Z verify: INCONCLUSIVE/-0.1M/day), so this is operationally near-free.
  • Combined verified savings of the remaining seven levers (all SUPPORTED, absolute vs pre-ramp base): ~568M reads/day.

Config only, generated with avo/firestore-reads/set_levers.py; the rendered literal is identical across _base.yaml, regenerated runtime_env.yaml, listen/pusher dev+prod values, the flag registry doc, and the two pinned contract tests. Note the literal keeps all twelve keys — missing keys default OFF (backend/config/firestore_read_levers.py), so the seven graduated levers must stay explicit at 100 (r2 review catch, fixed).

Product invariants affected

  • INV-MEM-4 — config-only lever rollout; no data-path, promotion or authority change; every lever here reverts to its pre-lever 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 pass locally (79 tests).

Rollout

  1. Train order listen → pusher → cloud-run; Cloud Run promotion and the shared backend GKE resources are one environment-scoped mutation domain (gcp_backend.yml), so the train must complete once started. Pusher prod rides the exact-main dev-qualification path per config(firestore): ramp singleton_loops to 100% #21971 policy (dev auto-deploy re-fires on this merge; last prod pusher roll 04:11Z, pre-batch-2 — pusher's env defaulting missing keys off matches this literal's explicit 0s). Desktop-backend untouched (traffic pinned).
  2. ⚠️ Merging this PR starts that mutation domain — the loop announces the merge on the lane card before landing and rolls listen immediately.
  3. Post-train: re-baseline; tick verify gates continue on the seven active levers.

Review chain (zcode glm-5.3): r1 exec-erupt-ordinary-quote-scrap-observe-reject SAFE (singleton-only draft); r2 exec-print-tortoise-fire-panda-sustain-enforce FIX-REQUIRED (caught replace-mode literal dropping the seven graduated levers → fixed with the complete 12-key literal + rebase onto b325c77); r3 re-review of the fixed commit.

View guided diff Turn on auto-fix

…ed levers

FIRESTORE_READ_LEVERS: singleton_loops 100 -> 0, backfill_task_reads/
historical_scan_memo/ledger_purge_coalesce/people_scan_dedupe 5 -> 0; the
seven graduated levers stay 100 (missing keys default OFF, so the literal
must stay complete). Generated with avo/firestore-reads/set_levers.py.

- singleton_loops: verify UNSAFE at 2026-10-17T20:00Z (five reconcile loops
  acquired=0, lease starvation); starvation window coincides with sync-owner
  revision rolls #22061/#22063 (18:20Z/20:26Z) and leases recovered by 21Z,
  off stands pending lease rework (decision-2026-10-18T00Z-flagoff-five.md).
- The four 5% levers: shared guard service backend-sync-backfill exempt only
  until 2026-10-18T01:00Z with 5xx at 7-8%/h and rising (630->2737/h 15Z-22Z)
  through sync-owner sequencer rework; evidence ambiguous -> off per loop
  judgment rules; re-enable at 5% after recovery exonerates.

Reviewed by zcode glm-5.3: r1 exec-erupt-ordinary-quote-scrap-observe-reject
(singleton-only, SAFE); r2 exec-print-tortoise-fire-panda-sustain-enforce
caught replace-mode literal dropping the seven graduated levers (FIX-REQUIRED,
fixed by restoring the complete 12-key literal + rebase onto #22066).
Contract tests 79/79 green.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 18, 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-18T00:10:50.708758Z 4435c12 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 b9c608f into main Oct 18, 2026
62 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/firestore-reads-flagoff-singleton branch October 18, 2026 00:26
Git-on-my-level added a commit that referenced this pull request Oct 18, 2026
…budget lever (dark, WQ1+WQ3) (#22142)

* perf(firestore): singleton lease fail-open rework — starvation worst case equals lever-off (dark)

Loop: firestore-reads WQ1. singleton_loops is flagged OFF in prod (#22071) after the
2026-10-17 19-21Z fleet-wide acquisition starvation across two revision rolls; this
rework is the precondition for re-ramping it.

- takeover at tick expiry (Lua-side, tick PTTL as clock): a dead holder hands over
  within <=1 interval (<=300s) instead of the full lease TTL; only one admission
  per tick survives (tick SET NX inside the atomic script)
- a pod wedged inside its callback fails open and runs the next invocation locally
  after the 900s max-hold cap (lever-off semantics) instead of skipping forever
- SIGTERM release runs outside asyncio and the db executor so a starved shutdown
  hook cannot leave stale lease keys behind
- lever-off path byte-for-byte unchanged; queue-age publisher handoff unchanged

Verified: 53/53 targeted tests (42 s2 + 8 recovery + 3 real-Redis Lua) via
BACKEND_UNIT_TEST_FILE_LIST; zcode glm-5.3 review SAFE
(exec-flush-position-logic-lion-figure-force, all six claims re-verified, no real
findings; 2 minors recorded: getsignal-None hardening unreachable under the pinned
uvicorn launch, new skip outcome labels double-count on sum-by-loop dashboards).
Author report: data/run-2026-10-16-firestore-reads/SOL-WQ1-lease-report.md (meta-repo).
No lever config change in this PR.

* perf(firestore): queue-age sample budget lever — stop rescanning the ready set every tick (dark)

Loop: firestore-reads WQ3. durable_queue_age._sample_status_page re-scans the whole
ready set on every publisher tick: measured 73.93M reads/day (backend-sync 71 pods
+ backfill 5 + backend 4 at 300s ticks, reconciled from snapshot
2026-10-18T05:00:38Z vs ~74M/day origin reads).

New default-off lever queue_age_sample_budget:
- 300s per-pod publish cache (FSR_QUEUE_AGE_MIN_PUBLISH_SECONDS), ages stamped at
  scan start, expiry re-checked under the lock; freshness lag <=600s + scan time
- first-page early-stop when the full first page proves the oldest ready age
  strictly above the 21600s alert threshold (boundary-matched); small ages still
  require exhaustive scans; capped/malformed scans still omit the key (unknown,
  never 0) — malformed docs now force unknown even alongside valid rows
- new omi_queue_age_sample_timestamp_seconds gauge makes stale publication
  detectable

Lever-off path is instruction-identical (verified by review); 126 targeted tests
pass incl. probe-counter proof 4250 -> 200 reads over five ticks; zcode glm-5.3
review SAFE (exec-cable-van-shiver-multiply-meat-three). KNOWN_LEVERS registration
lands with the loop's config PR before any enable.
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