Skip to content

SCA-2012: store the fresh result class and publish the delivery guard - #25224

Merged
Git-on-my-level merged 3 commits into
mainfrom
agent/m1-studio-codex-sol/e6f1320e5e73
Nov 13, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
agent/m1-studio-codex-sol/e6f1320e5e73

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Fresh results now retain their admitted class when committed, and the maintenance leader publishes the share still pending projection in the 10–20 minute commit window. No scheduling, projection, enrichment or release behavior changes. SCA-2012 (fresh-first step 1/5). Includes the round-one contract fixes for the registered guard kill switch and reviewed merge-writer payload. 319 changed non-test lines.

Implementation

  • The merge transaction copies only exact job True to results.fresh_capture; missing stamps become False.
  • Two count aggregations per minute, an optional ratio, sample age, default-on kill switch, and 120-second stale expiry. Scrapes do no IO and do not wait for count RPCs.
  • Generated prod/dev indexes and a planning read budget. No alert changes. The ops kill switch is registered in the feature-flag catalog.

Reader declaration (before implementation)

#25210 remains open, so the complete declaration is in backend/docs/listen_pusher_pipeline/changes/2026-11-13-fresh-delivery-guard.md. The merge transaction is the sole class writer; the guard is its only new semantic reader. The audit covers backend/ result consumers and shared services on current main; no existing reader routes on unknown fields or this result field. Deployed image SHAs still need release-owner confirmation.

Readers / adapters Existing interpretation; service scope
utils/batch_pipeline/{merge,scheduler,provider_stt}.py; database/batch_pipeline_{coalescing,paid_attempt,recognizer_receipts,terminal_empty,artifact_missing,speech_redrive}.py; database/{batch_final_pass,batch_voice_evidence}.py Result existence, sequence or explicit receipt/artifact fields; backend-integration, sync handlers and GKE batch-worker/diarizer runtime import these shared modules. Job-level class reads remain job reads.
utils/batch_pipeline/{projection,projection_drain,projection_discovery,projection_followup,projection_repair,voice_evidence}.py; database/batch_pipeline_{projection,projection_session,projection_privacy,projection_release,privacy}.py Projection state, binding, predecessor, privacy and named receipts; serving/backend-integration. Discovery uses store queries; extra metadata is ignored.
utils/batch_pipeline/{retention,held_dead_letter,held_coverage}.py; database/batch_pipeline_{store,purge,conversation_purge,quarantine_recovery}.py Cleanup, recovery and metadata stock/age queries use named fields; shared serving/worker paths. Erasure selects its retained metadata explicitly.
utils/batch_pipeline/{enrichment,metrics}.py, database/outbox* Enrichment consumes its outbox/job priority and projection receipt, not this result field; existing metrics select receipt/state/age fields.
database/jobstore/{dual_store,postgres_store,codec,backfill}.py; database/batch_pipeline_shadow_hook.py Generic document copy/encoding and parity may carry or compare the new field. Typed Postgres queries select explicit existing fields; no ordering or routing decision uses it. DualStore delegates count client/namespace to its Firestore primary.
testing/pipeline_sim/{store,postgres_store,sim,trace,scorer,policy_invariants}.py; testing/{batch_replay,store_fixtures,sync_cloud_tasks_stack}; unit MemoryStore Dict/document adapters preserve arbitrary fields; assertions and traces select named fields. Transition traces select named fields; final-result snapshots contain the full row, so goldens are regenerated with only the added fresh_capture boolean.
scripts/{batch_pipeline_held_disposition,batch_pipeline_terminal_empty,batch_pipeline_artifact_missing,batch_pipeline_speech_redrive,reconcile_batch_projection_ghost_holds,redrive_staging_inputs}.py; replay/owner-lab metadata tools Operator and test readers inspect named custody/projection fields; no unknown-field routing. Artifact paths named results are encrypted blobs, a separate namespace from result-row metadata.

Cost and rollback

Two count RPCs/sample: approximately max(1, ceil(total/1000)) + max(1, ceil(pending/1000)) billed reads, normally 2/minute or 2,880/day per leader. The extra advisory leader check reads the existing lease once per maintenance invocation. A registered planning envelope of 100,000 rows/count gives 200 reads/sample/environment (576,000/day across prod/dev); it is an estimate, not a throughput cap. No document/content streaming. BATCH_PIPELINE_FRESH_GUARD_ENABLED=off suppresses count queries and all four gauges. The unconditional row field rolls back by revert; existing stamps have no other semantic reader.

Review round 1 fixes

The guard now calls the registered policy kill-switch helper (with read logging suppressed), preserving default-on and off/false/0/no behavior in off, shadow and serve parser modes. Its helper-backed flag-budget entry has an owner and review date; the budget's seeded/replacement limit remains unchanged. The merge writer declaration is updated in backend/tests/support/lifecycle_writer_inventory.py, which is imported by lifecycle_state_table.py on this branch.

Validation

  • R1: required three-file suite: 134 passed, including all off spellings and default-on semantics in off/shadow/serve parser modes.
  • R1: all 45 make preflight checks and all 5 PR metadata checks pass after merging current main.
  • R1 final combined run after merging main: 2,141 passed across the required three files plus flag budget, stage env ratchet, policy and lifecycle writer suites.
  • R1: registered helper budget, policy boundary, batch-stage env ratchet and lifecycle writer declarations checked; current main merged preserving all flag registrations.
  • Required three-file pytest command: 106 passed initially; final expanded run including serving, simulator scenarios and concurrent scraper coverage: 178 passed.
  • Firestore index guard: all 7 files pass (including query-driver and generated-manifest coverage).
  • Characterization suite: 23 passed after regenerating goldens. All 14 changed golden files were structurally compared with HEAD: the only changes are added final_result.fresh_capture booleans. No other trace behavior changed.
  • make preflight: 45 checks passed on the committed tree. PR metadata validation: 5 checks passed. Normal commit formatter left all 9 Python files unchanged.

Live acceptance outstanding

Release owner must deploy indexes and this code to backend-integration AND the GKE batch worker. Then record two timestamped ro-prod count comparisons at least 30 minutes apart (within 1 percentage point), and sample age under 120 s for one hour, on SCA-2012. This PR performs no production reads, writes, deploys or activations. Merging is not completion of the issue.

Product invariants affected

none — additive internal metadata and count-only observability; no user-facing behavior changes.

Pipeline tuning disclosure

No capacity, scheduling, hold/release, routing or pipeline-state changes. Sampling constants define measurement only (60 s cadence, inclusive 10–20 minute cohort, 120 s visibility expiry); existing pipeline capacity settings are unchanged.

View guided diff Turn on auto-fix

Failure-Class: none

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-13T18:21:37.081858Z adb514d New commits
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: adb514d23d

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if self.metrics:
# Explicit reconcile bypasses the periodic lease; the guard never does.
if self._leads(True):
self.metrics.fresh_guard.refresh(self.store)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep fresh-guard count RPCs off the metrics request path

When projection-pump and read-only-metrics modes are disabled, backend/routers/batch_pipeline.py::metrics awaits service.reconcile_async(periodic=True), which reaches this synchronous refresh on the maintenance leader. Consequently, a scrape that encounters a due sample waits for both Firestore count RPCs (each with a 10-second timeout), rather than just collecting cached gauges. Slow count queries therefore delay the entire metrics response and can cause scrape timeouts, losing unrelated metrics as well. The collector concurrency test bypasses this HTTP path, so it does not establish that actual scrapes avoid waiting. Run sampling from supervision independently of scrape-triggered reconciliation.

Useful? React with 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit 6262a2b into main Nov 13, 2026
68 checks passed
@Git-on-my-level
Git-on-my-level deleted the agent/m1-studio-codex-sol/e6f1320e5e73 branch November 13, 2026 20:43
Git-on-my-level added a commit that referenced this pull request Nov 13, 2026
#25224 and #25226 each added a name; the merged file declared 277.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 15, 2026
SCA-2012's live samples exceeded the 120-second age budget after PR
#25224 deployed. Sampling ran only at the start of general maintenance,
and the serving supervisor waited for that entire pass before ticking
again. A deterministic test holds cleanup in flight for 180 simulated
seconds and reproduces the stale gauge.

Current integration head: `fdfb46738ae61a513eb1f081bcf58131e1b5a918`, a
normal merge of main `d1fb900e5b` into the previously reviewed commit
`8def546556dd20f13f6a835d75a1be13550d10a2`. This incorporates the
CPU-test repair #25312 (merge
`8614ee4cad335ca13da7df9e17875012f3985077`) that blocked the previous
candidate. The merge completed without conflicts or additional source
edits. Main's allowance-hold maintenance and all other current-main
changes are retained; the fresh guard still has its independent timer
and stored-class count cohort. Luna independently reviewed this current
integration commit and posted REVIEW: SHIP on SCA-2012 at 2026-11-15
00:20:47 UTC. The subsequent merge-stage receipt confirms all eight
backend shards, emulator proofs, and the hermetic merge gate passed on
this commit.

The guard now has an independent 20-second supervised timer on the
shared DB executor, using the same maintenance leader lease. All callers
retain the existing nonblocking overlap lock and 60-second count-start
cadence. The timer is owned by the serving runtime and stopped with it;
projection-pump-only instances do not run it. Query failures and stale
samples still remove counts/ratio, and scrapes do no IO. This
establishes and corrects a scheduling defect; raw production ages alone
do not prove it was the sole cause of every breach.

The new count-only `backend/scripts/fresh_guard_cohort.py` replaces the
prescribed external `projection_cohort.py` for this acceptance check: it
selects stored `fresh_capture == True` and the inclusive commit window,
not fresh_first/capture age. It requires the matching read-only tier. A
sample-timestamp gauge exposes the exact pre-RPC window anchor for
equivalent comparisons; it expires with the counts. No documents, audio
or content are read, and failed/empty windows have no healthy ratio.

Failure-Class: new

New class: FC-observer-cadence-coupled-to-maintenance. Prevention is
independent bounded supervision while preserving leader election,
overlap coalescing and sample expiry. The reusable regression artifact
stalls real maintenance while exercising the real guard on a
deterministic clock.

Stored-state contract: no field/writer change.
`OrderedMerge.commit_next` remains the sole result-class writer. Runtime
reader remains the maintenance-leader guard; the only added semantic
reader is the count-only acceptance CLI. Existing
merge/projection/discovery/drain/enrichment/recovery/shadow/simulator/worker
readers retain their semantics. No provider, hold/release, predecessor,
privacy, erasure, hard-3, alert or index-shape change.

Cost: unchanged count pair, roughly one read per 1,000 index entries per
count (minimum two reads per pair). The timer adds up to three existing
maintenance-lease checks per minute per serving replica. Each
independent acceptance comparison costs a separate count pair. Its new
query site has a declared planning envelope of 200 reads/comparison at
100,000 rows and 4,000/day at 20 comparisons; these are estimates, not
runtime caps or booked savings. No new collection or lease role.

Validation on `fdfb46738ae61a513eb1f081bcf58131e1b5a918`:

- Nine isolated files through `backend/test.sh` under `bin/omi-heavy`,
offline/simulator-only: 359 passed. Covers the stalled-maintenance
regression, count comparison CLI, serving/config, fresh merge and
provider membership, delivered-share contract, and repaired erasure
deployment tests.
- All 42 local preflight checks passed, including the Firestore index
guard's 591 query-shape tests.
- Normal bounded pre-push gate passed; no hooks bypassed.
- Luna's exact-commit REVIEW: SHIP: 2026-11-15 00:20:47 UTC. Merge-stage
CI receipt: 2026-11-15 00:40:07 UTC, all eight backend shards, emulator
proofs, and the hermetic merge gate green.
- No endpoint changed; exercised the real collector/count builders
against synthetic metadata and the real maintenance path with cleanup
blocked. No production action/read or live acceptance claim.

Release owner must admit the correction through the existing train and
verify collector retention of the new anchor gauge. Acceptance still
requires two equivalent count comparisons at least 30 minutes apart
within one percentage point, plus a complete healthy sample-age hour,
after the admitted release. Revert through the release train or use the
existing controlled guard kill switch; no data rollback. Live acceptance
remains open on SCA-2012; SCA-2063 owns release coordination.
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