Skip to content

feat(jobstore): dark mirror census, erasure and serving parity (C) - #25147

Closed
Git-on-my-level wants to merge 436 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m1-studio-codex-sol/d473f26eb038
Closed

Git-on-my-level wants to merge 436 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m1-studio-codex-sol/d473f26eb038

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

What changed and why

SCA-1807 package C extends the dark Firestore-to-Postgres mirror census to pull claims and merge holds, adds executable comparisons through the actual serving read methods, and makes cold-copy erasure independent of mirror mode and namespace admission. Explicit namespace admission defaults empty; the existing staging fence still refuses production. Firestore remains the only claimant/writer; no D reverse copier or serving writer is added.

Query observation is separately opt-in, uses a bounded queue, and emits counts only. Frozen emulator/PG fixtures cover every serving read, empty results, ties, null/missing values, cursors, owner-serialized phantoms and deliberate drift. Capture repair_lineage retains its existing Firestore-only retention boundary; this is explicitly a full-field serving gate, not normalized away by the new checker.

Product invariants affected

none

How it was verified

  • Locked Python 3.11 macOS environment via backend/scripts/sync-python-deps.sh.
  • Design's exact seven-file test.sh unit set: 196 passed; additional seam/staging/projection and conversation-erasure tests: 123 passed.
  • Real loopback Firebase emulator and disposable socket-only Postgres, OMI_REQUIRE_STORE_BACKENDS=all, exact nine-file design matrix: 490 passed, 10 skipped, 3 strict xfailed, 5 failed. The five failures are the existing Firestore enrichment outbox timing/coalescing and wake-exception contract failures; unchanged base faec7c5 reproduces all five. No skips/xfails are hidden or changed to pass.
  • make preflight: all 41 checks passed; the normal push hook also enforces final-head checks and backend typing.
  • Independent review completed in two rounds; round 2 cleared product commit 7e11cad with no P0/P1/P2 blockers. The subsequent commit classifies both values of the pure-observation argument in the existing Firestore query test driver and corrects the instrumentation control’s registry classification to a permanent configuration switch. The final typing-only follow-up adds a local alias for the same bounded connection context manager; it changes no runtime behavior. No third independent review was requested. Final SHA, terminal logs and preflight result are attached to SCA-1807.

No live shadow evidence, activation, deployment, migration, privacy serialization proof or savings is claimed. Source savings: $0. SCA-1697 retains D ownership; staging sizing/RC2, production admission, repair lineage retention, cross-store privacy, full-field live parity and settled billing remain gates. Details: backend/docs/jobstore-dark-parity.md.

Update 2026-11-14: main merged in, new owner (SCA-2288)

This PR now belongs to SCA-2288 (Postgres as a discovery index beside Firestore; David's ruling of 2026-11-14 is on SCA-1959 and SCA-2288). SCA-1807 was folded away; the original author no longer pushes here.

Two commits on top of the reviewed head 43ddb2ee26a9:

  • 117b10be02b1 merges origin/main (27abe5bbf8f6). Three textual conflicts, each resolved by keeping both sides: MIRRORED_TABLES (main added allowance_holds in SCA-2195: park allowance-held recordings outside active sweeps #25281; this branch added pull_claims and merge_holds) and two test files where both sides appended tests.
  • 09eb5eab3071 covers what main added after this branch was cut. The executable parity census gains ready_owners, allowance_owners, allowance_page, projection_finish_backfill_complete, fresh_first_pending and fresh_first_ready_pending, each with frozen emulator and Postgres cases. Erasure of the Postgres copy now removes the owner's allowance_holds row by key; before this it was found only when the hold document named its owner, and the erasure test now uses a hold document that does not.

Verified on 09eb5eab3071, loopback Firestore emulator plus a throwaway Postgres, OMI_REQUIRE_STORE_BACKENDS=all: test_jobstore_purge_postgres, test_dual_store_firestore_postgres, test_dual_store_postgres, test_store_conformance, test_recovery_custody_conformance: 423 passed, 7 skipped (cases not applicable to a backend). Unit test_jobstore_dual_store, test_jobstore_protocol_parity: 177 passed. The earlier verification section above describes head 43ddb2ee26a9 and its base, not this head; the full nine-file design matrix was not re-run on this head.

Independent review of 09eb5eab3071 (gpt-6-luna, read-only) returned FIX with three findings, all fixed in 21f3a4f3080d:

  • Erasure of a copy that nothing refreshes re-copied GPU reservation rows, which name the leased segment until release; such a copy now has those rows deleted during erasure. A live mirror is unchanged.
  • The projection-finish backfill, added on main after this branch was cut, commits outside Store.run and did not refresh the mirror; it now does.
  • The frozen parity fixtures gain a completed backfill marker, a second ready owner and a second parked row, with cursor cases.

Verified on 21f3a4f3080d, same setup and the same five integration files: 427 passed, 7 skipped. Unit (finish backfill, dual store, protocol parity, shadow seams): 214 passed.

Review round 2 of 21f3a4f3080d closed the backfill and fixture findings and kept the GPU one open for a live mirror (a dropped copy of the release would leave the erased segment's id in Postgres). 6e0f28ce8783 fixes it at the root: the copy never holds gpus.segment_id (UNMIRRORED_TABLE_FIELDS), comparisons compare what the copy is meant to hold, and the cold-copy special case from 21f3a4f3080d is removed.

22d3e4e792c4 re-pins the reviewed body digest of backfill_table (the pre-push Firestore index guard caught the changed body; the function still issues no query of its own). 2754ac3b8dd3 narrows a type in the serving-parity comparison so the backend type check passes; no behaviour change. Verified for 6e0f28ce8783: the five integration files, 429 passed, 7 skipped, run before one more fixture case (get of a GPU row) was added; the two files changed after that (test_dual_store_firestore_postgres, test_jobstore_purge_postgres) were re-run on the final tree, 108 passed. Unit (finish backfill, dual store, protocol parity, shadow seams, postgres locking): 225 passed.

Review round 3 closed the GPU finding and found that the serving-parity get comparison stripped the field from both sides, so a stale Postgres row would read as a match. 73b4c9799a58 strips the primary side only, with a frozen case that proves a stale row is a mismatch.

Verified on the final head 73b4c9799a58: the five integration files, 432 passed, 7 skipped. Unit, including the Firestore query-shape guard: 767 passed.

CI on 73b4c9799a58 failed one unit shard in test_reason_label_enums.py: the serving-parity counter took a plain string as its outcome label. ad8c13c81d2c declares the four existing outcomes as an enum passed through reason_label(); values are unchanged. The other seven unit shards and the emulator proofs passed on 73b4c9799a58.

Still dark: no namespace is admitted by default, JOBSTORE_SHADOW_QUERY_PARITY is off, and nothing here serves a read from Postgres. Review asked for: the merge delta and the commits after it (09eb5eab3071, 21f3a4f3080d, 6e0f28ce8783, 22d3e4e792c4, 2754ac3b8dd3, 73b4c9799a58, ad8c13c81d2c).

Tests

Regression and frozen-query cases extend test_dual_store_firestore_postgres.py, test_jobstore_purge_postgres.py and test_store_conformance.py. Golden harness claim forwarding now exercises the same mirror seam as production. No authoritative behavior or golden outputs change.

UI evidence

UI-Evidence: none -- backend source only

Failure class

Failure-Class: none

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 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-14T19:41:24.370119Z 21f3a4f 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: 43ddb2ee26

ℹ️ 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 store is None:
return 0
try:
return store.purge_owner_now(owner_id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Limit ungated erasure to rows already retained in Postgres

With a fully configured PG target but empty namespace admission or disabled mirroring, a conversation purge now reaches this call even for a namespace that has never been mirrored. owner_rows() unconditionally seeds owner, queue and shared scheduler addresses, and copy_current() upserts their surviving Firestore documents even when PG has no corresponding rows. Consequently, purging an empty cold copy creates new copies of surviving owner/queue data and other owners' shared control state; this can also copy batch_pipeline_prod outside staging despite its admission fence. Keep erasure independent of admission, but reconcile only already-retained rows rather than creating new copies.

Useful? React with 👍 / 👎.

Comment on lines +66 to +67
conn.execute(f'SET LOCAL statement_timeout = {max(1, int(budget * 1000))}')
yield conn

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 Enforce the remaining deadline before each PostgreSQL statement

For serving methods that execute multiple SQL statements, this sets a per-statement timeout only once, not an observation-wide budget. PostgresStore.held_merge_owners() executes its marker query followed by up to 100 first_pending_in() queries on this connection, so individually successful statements can continue well after rpc_deadline expires. The final deadline check correctly prevents a match, but only after the parity worker and shared pool connection have been occupied far beyond the configured budget, backlogging observations and consuming mirror/purge capacity. Check and apply the remaining deadline before each statement, or enforce observation-wide cancellation.

Useful? React with 👍 / 👎.

Git-on-my-level and others added 28 commits November 13, 2026 22:51
Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… place

Review round 1: the newest rows were read and their cursor saved before the
main query ran, so a main-query failure skipped that half page until the
window came round again.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…A-1961)

The first real daily run after BasedHardware#25188 reached the Soniox balance puller and
failed loading used_usd: the vendor's decimal has more than nine fractional
digits and BigQuery rejected it as an invalid NUMERIC (job exit 1).

parse_balance now renders balances through numeric_usd: half-up to nine
decimals (the policy the derived daily spend already uses), plain decimal
notation, short values unchanged, and a value outside the NUMERIC range is an
invalid_response skip. The loader re-renders the artifact values too, so an
artifact written by an older image cannot reach the table unnormalized. All
money fields in the snapshot path are covered (used_usd, available_usd); the
derived usd already quantized.

Tests: parametrized renderings (more than nine digits, half rounding, exponent
notation, range limit) and a loader regression that checks every money string
sent to BigQuery against the NUMERIC text pattern.

Failure-Class: none

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Mechanical conflict repair only; the source SHIP (cap) at bd65fdd is
preserved.

- alerts/firestore.json: keep both main's new omi-firestore-caller-overflow
  rule and this branch's omi-firestore-unattributed-reads and
  omi-firestore-unattributed-reads-blind rules. Our two rules are byte-identical
  to the pre-repair head; every main rule is preserved.
- metric-inventory.prod.json: union the gmp-cloud-run scoped metrics and
  evidence (main's caller-overflow families plus
  firestore_googleapis_com:document_read_count); captured_at is the later of
  the two.
- gmp-query-migration-inventory.json: regenerated from the merged alert
  sources (query_consumers 280).
- alert-rules.json: auto-merged and validated against the split sources (234
  definitions).

No workflow, trigger, permission, deployment, credential or runtime change.
The existing workflow-trigger diff is untouched and still held.

Co-authored-by: multica-agent <[email protected]>
- numeric_usd range-checks after rounding, so a value just under 10**29 that
  rounds up to 10**29 is an invalid_response skip, not an invalid NUMERIC.
- The derived daily spend renders through numeric_usd(pad=True): a zero delta
  is "0.000000000" (it was "0E-9"), and the share is divided and rounded at
  60 digits so a 29-integer-digit delta cannot raise InvalidOperation under
  the default 28-digit context. Output shape for normal values is unchanged.
- load_vendor_balance treats an out-of-range artifact as a bounded skip
  (stderr reason, nothing created or loaded), the same rule as the puller,
  instead of failing the daily job.

Tests cover each case.

Failure-Class: none

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…or restarts if it never wraps

Review round 2 on 1a06b86:
- Blocker: with half a page, the main cursor may never reach the newest row under
  sustained arrivals, so rows before every process's start point went unread. A main
  cursor that has not wrapped for 30 minutes now restarts at a random point.
- Should-fix: a still-pending recent row was re-offered on every tick of the window.
  The recent read is now stateless (random start each tick) and offers a row once
  per process; the window default drops from 900 to 120 seconds.
- The sweep test that pins queries per tick now expects the second query.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
… exact (SCA-1961)

Round-2 review finding: daily_deltas subtracted under the default 28-digit
Decimal context, which rounds a one-day delta of 99999999999999999999999999999.999999999
to 1E29; numeric_usd then rejected it after the snapshot was already written.
The difference now runs at 60 digits, like the share and the rounding.

Test: a one-day delta at the NUMERIC maximum stays exact.

Failure-Class: none

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
backend/AGENTS.md requires all imports at module top level; the new
vendor-balance tests imported re inside three function bodies. No behavior
change.

Refs SCA-1961
…; offers remembered for two windows

Review round 3 on 4d722a7:
- Blocker: a uniformly random restart point almost never lands on the head of the
  log, so its first rows could stay unread under unending arrivals.
- Should-fix: the once-per-process offer bound assumed the commit stamp is never
  ahead of the process clock.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…A-1961) (BasedHardware#25217)

## What

The Soniox balance snapshot now renders its money fields to BigQuery's
NUMERIC contract before the load, so the daily finops job's first real
snapshot no longer fails.

## Why

After BasedHardware#25188 gave `pull_vendor_balance.py` a real entry point, the first
production run (`finops-unit-cost-job-8fqt6`, 2026-11-13 15:39Z) reached
the puller and failed loading `used_usd`: the vendor's decimal has more
than nine fractional digits and BigQuery rejected it with `Invalid
NUMERIC value`. The job exited 1 after one retry;
`omi_finops.vendor_balance_snapshot` was created but holds 0 rows.
Tracked as SCA-1961; the Soniox line on Omi TV needs two good snapshots.

## Change

- `numeric_usd()` in `pull_vendor_balance.py`: half-up to nine decimals
(the policy the derived daily spend already uses and the README
documents), plain decimal notation (never exponent), short values keep
their digits (`12.5` stays `12.5`), and a value outside NUMERIC's 29
integer digits becomes an `invalid_response` skip instead of a load
error.
- `parse_balance` uses it for both `used_usd` and `available_usd`. The
derived `usd` column already quantized to nine places.
- `load_vendor_balance` re-renders the artifact's values through the
same function, so an artifact written by an older image cannot reach
BigQuery unnormalized.
- README: one sentence on the policy.

No schema, schedule, secret, IAM or job-config change.

## Tests

- `pytest backend/tests/unit/test_finops*.py`: 279 passed, including new
parametrized renderings (more than nine digits, half rounding, exponent
notation, 29-digit limit, short values unchanged) and a loader
regression that checks every money string sent to BigQuery against the
NUMERIC text pattern, with 16-digit vendor-like decimals.

## Rollout

Needs the finops job image rebuilt through its existing workflow
(release request SCA-1895 / SCA-1961). The release owner verifies the
first scheduled snapshot; the measured Soniox line needs a second one
the next day.

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/25217?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/25217?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25217&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
The uptime sidecar emits each day as epoch milliseconds (a number), but the
panel declared the date column as a plain "timestamp", which the Infinity
datasource parses to null. With every date null the time series could not place
a point and read "Data outside time range" even though the query returned seven
daily rows. Verified read-only against the live board's query: type
timestamp gives null dates, timestamp_epoch gives 11-06 through 11-12.

Board JSON regenerated; a test pins the column type.

Failure-Class: none

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…asedHardware#25218)

## What

Omi TV's "Uptime by journey" now declares its date column as epoch
milliseconds, so the chart plots its days instead of reading "Data
outside time range".

## Why

The uptime sidecar (`stats_proxy.py`, applied on prod 2026-11-13 15:22Z)
emits each day as epoch milliseconds, a number. The panel declared the
column as `timestamp`, which the Infinity datasource parses to null.
Every date came back null, so the time series could not place a point;
the board showed "Data outside time range" and "Zoom to data" while the
query returned seven daily rows. David reported it from the live board.

## Evidence

Read-only, through Grafana's query API against the live board (Business
org, omi-tv-v2 v14): the same target with column type `timestamp`
returns seven null dates; with `timestamp_epoch` it returns 2026-11-06
through 2026-11-12.

## Change

One column type in `web/admin/grafana/build_wall_dashboard.py` (an
`UPTIME_DATE` constant used only by this panel), board JSON regenerated,
and an assertion in `test_build_wall_dashboard.py` pinning the type. No
other panel changes; the other `date` columns carry ISO dates and stay
`timestamp`.

## Tests

`python3 web/admin/grafana/test_build_wall_dashboard.py`: 18 passed (the
checked-in board equals the builder output).

## Rollout

Merging applies the board automatically (job
`provision-prod-ops-dashboards`, Business org, no approval). The history
behind the chart is whatever Prometheus holds (retention 10 days, so
about seven daily points today); this change does not add history.

Failure-Class: none

🤖 Generated with [Claude Code](https://claude.com/claude-code)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/25218?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/25218?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25218&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
…owners yield (BasedHardware#25213)

## What

Two changes so a fresh result is projected promptly while a projection
backlog drains:

1. Discovery: each assignment discovery tick also reads up to half a
page from the newest 120 seconds of commits, so a new result is usually
seen within its first two minutes however long the backlog (an estimate,
below; not a per-row guarantee).
2. Owner drain: newly requested owners get a turn before backlog owners.

## Why

On 2026-11-13 about 250,000 old results were committed in three hours
(the provider backlog release, stopped by BasedHardware#25204). Projection drains
owners from one FIFO queue, 8 at a time per process, and a turn runs up
to 120 seconds. Measured in production (result metadata and log counts
only):

- Sample of 20,000 pending results at 15:34Z: 74% captured over a day
earlier; 651 owners; the top 100 hold 82%.
- Of results committed 10–20 minutes earlier, 56% were unprojected
(about 0.2% before the incident); 26% of those committed 60–70 minutes
earlier.
- Half of the waiting under-1h rows (1,290 of 2,587) belong to 198
owners with no older rows of their own. They wait only for other owners'
turns.
- Projection is about 1,000 rows a minute against about 575 a minute of
normal inflow at that hour, so the backlog needs hours to drain. Fresh
results should not be late for all of it.

- Discovery pages pending results oldest first, 100 rows per 20-second
tick per process, and a GPU-route commit has no other wake (the worker
pump has no commit callback). With 154,000 pending rows, 35 processes
pass a given row about once in 15 minutes. That matches the measured
delay.
- Owner-drain turn lines, 5-minute sample at about 15:45Z: turns that
ran to the 120-second deadline were 51 of 1,140 turns but 58% of slot
time, and advanced about 0.43 rows a second each.

## Change

**Discovery** (`backend/utils/batch_pipeline/projection_discovery.py`,
assignment discovery only). Each tick also reads up to half a page from
the newest `BATCH_PIPELINE_PROJECTION_RECENT_DISCOVERY_SECONDS` (default
120) of commits.

- No cursor (the offer memory below is the only state): the read starts
at a random point in the window each tick and reads oldest first.
Replicas draw their start points independently, so they can land on
different rows (nothing forces them to); a restarted process behaves
like any other.
- A process offers a row from this read once. The entry is kept for two
windows, longer than the row stays in the window. A row still pending
after that is offered by the main cursor, as before.
- Rows read here count against the page, so the page holds no more rows;
the main cursor gets the rest (at least half). The tick makes one more
Firestore query than before (two instead of one for the pending page).
- A main cursor that has not reached the newest row for 30 minutes
(`MAIN_PASS_SECONDS`) starts again: one time in eight at the oldest
pending row, otherwise at a uniform random point between it and now.
This closes a gap review found: when rows arrive as fast as a cursor
reads, no cursor wraps, and rows before every process's start point are
never paged. The gap exists on `main` too, at twice the arrival rate.
- Same query and index as the main cursor, with a start point. A failed
recent query costs only that half page; rows read before a failed main
query are not recorded as offered, so they stay eligible for a later
recent read (which starts at a new random point and may not reach them
on the next tick).

Expected coverage, from the numbers above and not measured: with about
170–330 rows committed per 20-second tick and 35 processes each reading
50 from a random point of a window holding six ticks of rows, one tick
misses a given new row with probability about e^(-35×50/(6×rows per
tick)), 18–41% today. Over the six ticks a row spends in the window that
is about e^(-35×50/rows per tick), under 1% today and about 7% at twice
today's commit rate. It assumes uniform arrivals and independent draws.

**Owner drain** (`backend/utils/batch_pipeline/projection_drain.py`).
Per process; no new read, no new stored state, no index.

- A newly requested owner's first turn runs
`BATCH_PIPELINE_OWNER_DRAIN_FIRST_TURN_SECONDS` (default 15, about one
step) instead of 120.
- An owner whose productive turn ends with rows left is a backlog owner.
It keeps 120-second turns but waits in its own queue; newly requested
owners launch first.
- A backlog turn ends at its next step boundary (`stop=yield`) when a
newly requested owner is waiting and no slot is free: one backlog turn
per waiting owner, and never the last backlog turn running.
- If no backlog owner is running, one goes ahead after four rounds of
new owners, so the backlog cannot be starved.

Unchanged: order inside one owner (commit order under the assignment
fence and the owner claim), discovery, claim-aware admission, privacy
and live-target backoff. An owner's fresh row behind that same owner's
backlog still waits for it.

Details:
`backend/docs/listen_pusher_pipeline/changes/2026-11-13-projection-fresh-owner-turns.md`.

## Rollout

Ships on. Both are scheduling changes inside one process, each with an
off value: `BATCH_PIPELINE_OWNER_DRAIN_FIRST_TURN_SECONDS=0` restores
the single FIFO queue and 120-second turns;
`BATCH_PIPELINE_PROJECTION_RECENT_DISCOVERY_SECONDS=0` restores the
single discovery cursor and removes the 30-minute restart. Deploy:
`backend-integration` only (the surface that runs the projection owner
drain).

Must stay clean after deploy: projected rows per minute not lower than
before (the backlog keeps draining); enrichment 200s per minute flat.
Expected to improve: share of under-1h captures committed 10–20 minutes
earlier that are unprojected.

## Known limits

- The main cursor advances at as little as half its speed while recent
rows fill their half of the page, so a backlog row that depends on
discovery alone (not on its owner's running drain) is found later.
Owners already draining are not affected. The 30-minute restart is
random: one restart in eight begins at the oldest row, the others at a
uniform point, so every stretch of the log has a chance of being read in
each period. That is not a guarantee for any single row, and how long a
row can wait has not been measured.
- A row is offered by the recent read once per process run, so up to 35
times fleet-wide when fewer than 50 rows are pending in the window, plus
once for each process that restarts while the row is in the window. The
bound assumes the commit stamp is no more than one window ahead of the
process clock (entries are kept for two windows). Offers per tick stay
within the page size, as before; each offer reads the row's job and
result, and repeated owners are coalesced per process and by the owner
claim across processes.
- It does not help an owner whose fresh row sits behind that owner's own
backlog (about half of the waiting fresh rows today).
- A long chain's read-ahead is per turn, so a backlog turn that yields
early discards it; under constant arrival of new owners, backlog turns
get shorter and the backlog drains somewhat slower.
- Classification is per process and resets on restart: after a deploy
every backlog owner takes one 15-second first turn before it is known as
backlog.

## Tuning disclosure

- BATCH_PIPELINE_OWNER_DRAIN_FIRST_TURN_SECONDS new: 15 (0 = off, max
120)
- BACKLOG_OWED_TURNS new: 4
- BATCH_PIPELINE_PROJECTION_RECENT_DISCOVERY_SECONDS new: 120 (0 = off,
max 3600)
- MAIN_PASS_SECONDS new: 1800
- MAIN_RESTART_HEAD_SHARE new: 0.125
- offer memory new: two windows (240 s at the default)

No new pipeline state and nothing new stored. New process memory only:
in the owner drain, the backlog queue and two sets of owner ids; in
discovery, the ids and offer times of rows the recent read offered
(about 150 a minute at most; an entry stops suppressing after two
windows and is removed when the map next passes 4,096 entries, so older
entries can sit in memory until then) and the time the main pass began.

## Product invariants affected

none

## Failure class (fixes)

Failure-Class: FC-backlog-release-shares-lane-with-fresh-work

Second fix in this class: the first (BasedHardware#25204) stopped the unmetered
release; this one gives fresh work its own place in the projection stage
the release filled.

## Tests

```
cd backend
.venv/bin/python -m pytest tests/unit/test_batch_pipeline_projection_discovery.py tests/unit/test_batch_pipeline_owner_drain.py \
  tests/unit/test_batch_pipeline_sweep_owner_chain.py tests/unit/test_pipeline_sim_projection_drain.py tests/unit/test_flag_budget.py -q
```

New in `tests/unit/test_batch_pipeline_owner_drain.py`: a light owner
queued behind three heavy owners finishes before any heavy owner gets a
second turn, and every chain still projects whole and in order; new
owners launch before queued backlog owners and the backlog is still owed
a turn; a backlog turn yields only for a waiting new owner without a
free slot, one per waiting owner, never the last one; the off value; the
setting's bounds. The existing FIFO fairness test now pins the off
value.

New in `tests/unit/test_batch_pipeline_projection_discovery.py`: a new
commit is on the first page behind a 400-row backlog and the page is no
larger; the main cursor visits every backlog row while a full half page
of new commits arrives on every tick; a row that stays pending is
offered by the recent read once in 20 minutes of ticks, and once more by
a restarted process; rows already offered still count against the page
(query limits 50 and 50); each tick reads from a different point; the
off value keeps one cursor and no restart; a failed recent query costs
only its half; rows read before a failed main query are not recorded as
offered and are offered again when a later read reaches them (shown with
a fixed start point, striping on and off); a main cursor that has not
wrapped for 30 minutes restarts and one that wraps does not; one restart
in eight begins at the oldest row; setting bounds.


`tests/unit/test_batch_pipeline_sweep_owner_chain.py::test_pending_page_skips_receipts_and_follow_ups_still_run`
pinned one query for the pending page; it now pins two, with limits 50
and 100. That test was already failing on the first pushed heads of this
branch and neither the pre-push gate nor CI ran it.

## Review

Independent review (Luna). Round 1 on `cc4a583`: FIX, one should-fix (a
failed main query moved the recent cursor); the owner drain passed
checks A to G. Round 2 on `1a06b86`, against the contract (SCA-1960):
FIX. Blocker: with half a page, the main cursor may never wrap under
sustained arrivals, so rows before every process's start point could go
unread. Should-fix: a still-pending recent row could be re-offered up to
45 times per process per window. Note: one more query per tick. I also
found that the round-2 design would have left every process's recent
cursor at the window floor under today's load. The recent read was
rewritten (no cursor, one offer per row per process run) and the
30-minute restart added.

Round 3 on `4d722a7`: FIX. It confirmed the restart's gating, the page
and query counts, the off value, the failed-query paths and unchanged
order inside an owner. Blocker: a uniformly random restart point almost
never lands on the head of the log, so the oldest rows could still go
unread under unending arrivals. Should-fix: the once-per-process bound
assumed aligned clocks and no restarts; several statements in this
description were stale or too strong. Response: one restart in eight now
begins at the oldest row; offer entries are kept for two windows; the
description is corrected. The rollout owner ruled the 1-in-8 head
restart acceptable as probabilistic coverage (SCA-1960); a cursor that
guarantees every row is read is assigned to the metered-release PR.

Narrow confirmation on `b30e6be`: the code matches the ruling (head
restart, gating, two-window offer memory in filter and prune, nothing
recorded on a failed main query), tests prove their names, no security,
privacy, custody or data-loss risk. Its verdict was FIX for two
sentences in this description: the retry after a failed main query was
stated as next-tick, and the memory statement ignored that pruning only
runs above 4,096 entries. Both are corrected above; no code change
followed, so the head is unchanged. A description-only pass on the same
head confirmed both and asked for one more wording change (replicas can,
not do, land on different rows), made above. The reviewer proposed
always restarting at the oldest row; that was not taken because every
process would then re-read the same first rows each period and nothing
past them.

Not tested here: production behaviour, the coverage estimate above, and
the effect on the backlog's drain rate.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
…dHardware#25214)

Restore owner-scoped waiting recording inventory after same-account reauthentication while preserving accepted jobs, source audio, manual holds and account isolation.

Verified with targeted custody regressions, native iOS simulator persistence, seeded journeys, full Flutter CI and Android emulator acceptance. Automatic code review completed without findings on c35145b. Mobile release and original customer recording recovery remain separately tracked.
Git-on-my-level and others added 14 commits November 14, 2026 23:03
…ance-hold tests

entitlement() now imports utils.subscription at its call boundary. The first
test to reach it paid that one-time import (0.66 s locally, 1.11 s under the
pre-push guard) against the 1.00 s per-test CPU budget. Test-only; no budget,
assertion or allowlist change.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…alarm (SCA-2117) (BasedHardware#25262)

The 2026-11-13 Japanese provider-STT miss went unseen for about a week
because every batch delivery signal was fleet-wide or counted from the
commit side. A provider unit that never leaves `vendor_held` has no
result row, so a commit-based ratio cannot see it. This adds the missing
signal: **of recordings admitted, the share whose transcript reached the
user within the 5-minute target, split by STT route and language**, with
a per-language baseline alarm.

## Contract

### Done-true

- Backfilled data shows the 2026-11-13 Japanese dip on the Japanese row:
`python -m scripts.batch_pipeline_delivered_share_report --project
based-hardware --from 2026-11-13T00:00Z --to 2026-11-14T00:00Z --step
900 --baseline-from 2026-11-06T00:00Z --baseline-to 2026-11-12T00:00Z`
  prints the per-cell table and the firing cells.
- The alarm fires in a drill: `python -m
scripts.batch_pipeline_delivered_share_report --drill` runs the hermetic
simulator healthy and with the Japanese provider route down, prints
`provider/ja 36/36 1.000` then `0/36 0.000`, and reports `FIRING
provider/ja`. Pinned by
`tests/unit/test_batch_pipeline_delivered_share_contract.py`.
- Core Features gains the row **Did the user get a transcript?** reading
the new gauges.

Production acceptance belongs to the release owner after independent
exact-head review: retained 2026-11-13 Japanese dip, deployed Core
Features signal read, and live alarm drill. The synthetic drill does not
close acceptance. No additional production reads until the operator
query budget is declared.

### Must-not-change

- Admission, merge order, projection order, delivery, retention and
privacy are unchanged. `ProjectionStore.acknowledge` already updates the
result row and already reads the job row; this adds one job write
carrying a first-delivery timestamp and a boolean. No new transaction,
retry or fence.
- `enqueued_at`, `stt_route`, `policy` and `projection_binding` are only
read.
- No transcript, audio, user id or email is read, stored, printed or
exported. The sample reads job metadata only; the report prints counts.
- Missing, failed or empty samples never produce a healthy zero. A
failed page clears counts and ratio; counts expire at scrape time after
600 s.
- The Postgres batch store is untouched: monitoring-only read of the
Firestore job namespace the serving leader already owns.

### New state and its readers

| Field | Writer | Readers |
| --- | --- | --- |
| `jobs.delivered_at` | `ProjectionStore.acknowledge`, same transaction
as `projection_state=completed` |
`utils/batch_pipeline/delivered_share`, the report script |
| `jobs.delivered_in_target` | same | same; only `True` is a positive
delivery signal |

Both are additive. Rows written before this change carry neither, so the
live share reads zero delivery for one cohort after deploy and then
recovers. No older reader selects an unknown field. Rollback is a
revert; the fields become inert.

## Tuning

MIN_VOLUME new: 20 admitted units per 15-minute cohort. No prior value
existed because this cell is new; below the floor the alarm cannot fire,
and the drill's 36-unit Japanese cohort clears it.

## Sampling cost

`delivered_share_page` walks `{namespace}_jobs` for the census
vocabulary minus `record_pending`, admitted 20 to 5 minutes ago, ordered
by `enqueued_at`, capped at 5,000 metadata rows. One page per 300 s on
the maintenance leader. The at-cap cost is 1,440,000
reads/day/environment; the normal 2026-11 cohort is ~2,800 units
(~800k/day). The read budget is declared in
`.github/firestore-collection-budgets.json`. A saturated page sets
`omi_batch_pipeline_delivered_share_truncated` and covers the oldest
rows only.

`BATCH_PIPELINE_DELIVERED_SHARE_ENABLED=off` (also false/0/no) stops the
page and hides every gauge. Default on, helper-backed, with a
flag-budget entry.

## Alert

`omi-batch-delivered-share-language` (agent tier, 30m pending,
`omi-tier-silent`): a cell fires when its share is below 70% of its own
7-day peak while at least 20 units were admitted in the cohort. The
peak, not an average, keeps a sustained dip from lowering the baseline
under itself for the length of the outage; after seven days of a total
outage the baseline decays and the runbook requires a human update.

## Verification

Local unit tests: query shape and driver registration, aggregation,
language/route bounding, delivery stamp (including replay stickiness),
acknowledge job write, collector cadence/expiry/kill switch, backfill
receipt fallback, alert and dashboard contracts, flag budget, Firestore
index manifest, and the hermetic drill.

Failure-Class: none


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/25262?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/25262?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25262&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->

## Review fixes under SCA-2249

The exact-head review at `6fe54735a2` found that configurable backfill
steps could overlap or skip the fixed 900-second query cohort, and that
selecting whole receipt-part maps exceeded the declared metadata
boundary. This revision rejects every step except 900 and requires
nonempty target and baseline ranges aligned to UTC quarter hours before
creating a client. Historical cohorts count `[start, end)`, including
boundary admissions exactly once.

Receipt reads select only completion state, summary persisted timestamp
and part count. A legacy completed receipt without a summary timestamp
gets a second read selecting explicit
`projection_parts.<index>.persisted_at` leaves. Part keys are numeric
strings, so the literal `projection_parts.persisted_at` mask would miss
them. Unsupported counts or incomplete timestamp leaves abort the
report. The declared upper bound is now two result reads per unstamped
job; no conversation/speaker identifiers, whole receipt maps, audio or
transcript payloads are selected. The operator must still declare the
full target and baseline query budget before production reads.

The failed CI shards on `6fe54735a2` were diagnosed from run
43602269386:
- Shard 7/8: the newly appended combined alert object lacked the split
export's indentation, violating the existing byte-identity contract.
Copied its exact split representation; alert semantics are unchanged.
- Shard 4/8: assertions passed, but cold projection-fixture setup
consumed 1.06 seconds in the test call, exceeding the existing 1-second
CPU guard. Setup now uses a pytest fixture. The same real
acknowledge/replay operations and all assertions remain, with no
duration-limit or allowlist change.

Focused validation for `6cfd272d0976487db4e13b944788fd544e25e6a5`: 36
backfill contract tests (including the simulator drill), 17
delivered-share tests, and 8 notification contract tests passed. The
acknowledge test also passed in isolation with the CPU guard enabled.
Tests pin rejected steps/partial target and baseline windows before
client creation, adjacent-cohort boundaries, SDK field-mask projection
excluding unrelated receipt fields, and fail-closed incomplete legacy
receipts.

SCA-2249's posted ruling is to fix exactly these findings and ship
without another review; it does not waive production acceptance. No
manual nightly/whole-CI rerun, production read, credential change, merge
or deployment was performed. Release-owner acceptance remains the
retained 2026-11-13 Japanese dip, deployed Core Features signal and live
alarm drill. Preserve blocked state until those are evidenced.

Push validation: all selected preflight checks, type checking (zero
errors), and the bounded pre-push gate passed on
`6cfd272d0976487db4e13b944788fd544e25e6a5` using the locked worktree
environment with no gate overrides. GitHub reports the published head
mergeable; its new CI run is not used as production acceptance.

## Current-main integration correction

CI run 43607943059 failed shard 3/8 at
`test_budget_file_declares_scope_and_count`: its merged test tree
contained 284 flag names but declared 283. Both branch and main
separately declared 283 names correctly; a clean merge-tree reproduction
confirmed that the independent additions combined without updating the
shared count. Merged main `ef42ee8f44e0dd47afd4f2f2e583716499be45be`
without conflicts and reconciled the count to 284. All 24 flag-budget
tests pass. No test or budget threshold was weakened. The SCA-2249
review ruling and release-owned production acceptance remain unchanged.

Published head `3a2e440054677906ff438257f69fa76427375f70`: normal
selected preflight, type checking, and bounded pre-push gate passed
without overrides. GitHub reports this head mergeable. New CI results
have not been collected. Hold renewed through 2026-11-14T18:00:00Z for
release-owner production acceptance.
Two union conflicts, both sides kept: .github/firestore-collection-budgets.json
(allowance entries and delivered-share entries) and
backend/database/batch_pipeline_indexes.py (allowance and delivered-share
index requirements). No product logic changed by hand.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…-sol/83bd59235279

# Conflicts:
#	backend/config/flag_budget.json
…tegration

The finish-backoff lever is being turned on for backend-integration, the
only service that runs the projection finish sweep, now that the one-time
stamping pass has completed (BasedHardware#25225, BasedHardware#25287) and the finish counters
export from that service (BasedHardware#25291). Repo config did not declare the lever
at all, so the next deploy would have dropped a hand-set value.

Declare BATCH_PROJECTION_FINISH_BACKOFF_ENABLED=true for prod
backend-integration only, regenerate runtime_env.yaml, and move the
renderer pin: present and true on prod backend-integration, absent on
every other service and environment.

Kill switch: BATCH_PROJECTION_FINISH_BACKOFF_ENABLED=false.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…t rollout

The deployment secret-boundary check requires every rendered binding to be
classified; add BATCH_PROJECTION_FINISH_BACKOFF_ENABLED to the config list.
Use the rollout category, matching its lifecycle in config/feature-flags.yaml.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…he sweep path

Review SCA-2270: backend-sync mounts the batch router with a worker audience,
so its reconcile and batch metrics routes can run the same finish sweep even
with serving disabled. Declare the same value there so both hosts of the code
path agree.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…Hardware#25281)

Allowance-exhausted recordings repeatedly cycle through retry and
pending-work scans without being eligible to run. This change parks
current allowance holds outside active discovery and releases them in
capture order after an entitlement generation changes, through normal
admission.

Issue: [SCA-2195](mention://issue/01a1d951-19dc-70b3-a76f-00a9e585429d)
Failure-Class: new

**Published:** `209d1147328c4b9d44764df9b983e91a7e304b70` was pushed
normally to this PR's existing branch at 2026-11-14 14:50Z using
existing authentication. The complete bounded pre-push gate passed on M1
Studio: 48 preflight checks, zero type errors (existing warnings), 795
selected unit passes / 86 existing expected failures, all subsequent
hook steps and formatting. No source edits, force push or hook bypass.
External CI has started and is pending; no green CI or SHIP is claimed.
SCA-2197 round 2 of 2 proceeds on this exact published head with the
assigned non-Sol DeepSeek V4.1 Flash reviewer. New commits invalidate
its verdict.

## Behavior and review scope

- Current `held / allowance_exhausted` GPU retries enter
`allowance_held`; recordings, obligations and history remain durable.
Fair-use, provider, decisionless, allowed and real worker-failure
recovery retain existing behavior.
- Retry due scans, pending predecessors/fresh selection, retry-age
samples, queue-age and timeliness active-state membership exclude parked
rows. Held stock has its own hourly leader-only COUNT gauge and census
entry, with monitoring exports.
- Projection assignment/finish/follow-up and privacy projection sweeps
already read result receipts that parked jobs have never produced.
Quarantine/dead-letter, provider/vendor, record-pending, input-retention
and artifact-cleanup sweeps retain their own state predicates. Explicit
privacy erasure still includes held recordings.
- Owner discovery hashes commercial and referral authority, effective
entitlement/time transitions, UTC month and the UTC day when the
optional backfill daily cap is enabled. Usage counters remain outside
the generation. Both transient usage reasons retry before
acknowledgement. Durable claims/cursors release oldest first through
normal admission.
- Shared CAS transitions live in the database layer; the controller
imports are acyclic and at module scope. Conversation purge
decrements/retire held-owner counts transactionally, including shadow
refresh and repeat deletion.
- The candidate integrates main `c13e510`, preserves owner cursor and
allowance maintenance, both index families and metric exports, and
regenerates the manifest. Cursor migration is **0007**; allowance
indexes are **0008**. Migration loading is contiguous 1–8.
- Migration dry-run prints counts only. Apply is resumable, idempotent
and rechecks per-row CAS/privacy fences. Full sweep/version/migration
details: `backend/docs/runbooks/batch-allowance-parking.md`.

Kill switch: **`BATCH_ALLOWANCE_PARK_ENABLED=off`** on
backend-integration and every GPU worker. Default is on unless
explicitly off. Rollback restores retry membership and retry clocks in
bounded pages; retain the new controller until parked stock reaches
zero. Discovery is limited to 20 owners per 30 seconds (about 55 minutes
at 2,202 continuously held owners); rollback is gradual at up to 12,000
rows/hour.

## Final candidate validation

On `209d1147328c4b9d44764df9b983e91a7e304b70`, synthetic data and local
stores:

- Allowance integration with **all three stores required**: **62 passed,
four applicability skips**, including all 12 forty-held-row cases, mixed
versions, migration resume/CAS/failure and ordered release.
- Provider proof with simulator, Firestore emulator and real isolated
Postgres required: **54 passed, no skips**. Both selector modes assert
that privacy/predecessor races actually ran.
- Parked-job purge emulator regression: **one passed**, including repeat
deletion.
- Allowance authority/reset, measured read budgets, jobstore migration
and serving configuration unit suites: **117 passed**.
- Metadata-aware preflight: **all 48 checks passed**, including all
seven Firestore guard files, 588 query-shape cases, changed collection
budgets and runtime image contracts.
- M1 Studio normal publication gate on this exact head: **48 preflight
checks passed**, including all seven Firestore guard files and 588
query-shape cases; **zero type errors** (existing warnings); selected
unit suites **795 passed / 86 existing expected failures**. All
post-unit hook steps completed and 38 changed Python files passed the
pinned formatter. Git push exited successfully. The worker's three-store
and focused receipts above remain earlier exact-head evidence; those
integration proofs were not rerun during publication. Full external CI
remains pending.

Connector dispositions for independent verification: #4572885182
promotional generation; #4572885186 reverse-layer import; #4572885189
module-scope/cycle; #4573177946 daily reset; #4573177949 transient
usage; #4573177954 purge counts. All six have candidate fixes and
passing relevant regressions; threads remain open for the independent
reviewer.

## Dry-run and release gates

Approved ro-prod metadata preview completed 11:53:22Z: **1,027,058**
scanned; **998,102** retry/current allowance candidates; **28,956**
active retries remain (273 fair-use, 28,683 not currently held); overdue
retry would fall from 1,005,149 to **28,939**. Merge-pending projects
2,815,875 → 1,817,773. Second local application changes **zero**;
production writes **zero**. Estimated reads including prior aborted
aggregation ceiling: about 1.071M, within approved 2.5M. This paged
preview is not atomic; real fences can reduce applies. Eligibility is
unchanged, so no duplicate production scan.

Measured release reads are 9/16/24 per row and migration 6/8/12 for no
conversation/ordinary/two-redirect profiles. Planning reserve is 64
reads/row, 6,406/page, <65M for a 1M-row release burst plus metadata,
and 64M for a separate 1M-row migration; combined <129M. This is
headroom, not an enforced maximum. Longer redirects, contention, shadow
refresh and repeated/daily bursts require remeasurement and budget
acceptance.

Independent exact-head review, required CI, READY indexes and
rollout-lead acceptance of the budget/latency/rollback must precede the
first default-on deployment or apply. The release owner deploys the
backend controller before GPU writers and applies the reviewed migration
after explicit go. **Never enable
`BATCH_PIPELINE_PROVIDER_BACKLOG_RELEASE_ENABLED`.** No merge, deploy,
apply, activation or capacity action was performed.

Production acceptance remains open: both serving planes, automatic
release for an entitled test owner, and matched full-day retry/requeue,
reads per completed audio-hour and over-SLA evidence on SCA-2173. The
constructed forty-held-row proof does not clear every production stalled
owner; SCA-2015 owns residual head-shape verification.
…tegration (BasedHardware#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 BasedHardware#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 BasedHardware#25225 and BasedHardware#25287;
- the finish counters export from backend-integration since Train 1
(BasedHardware#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)
…tion (BasedHardware#25268)

Provider backlog release must stay bounded independently of fresh work.
This integrates the existing hourly commit gate with current main,
preserving the merged transactional fresh selection, conditional owner
cursor/revision, stalled-head fallback, privacy/custody fences and
projection predecessor chain.

Integrated head: `e2906c45b3606b175b14dc525bf7562377d4beab`. Main
merged: `c5cf5a2b3dd2c3b3b638a562d066dafd92334753`. Successor of
`7bc3c7299a5e9eb1f2a16a653b819f043cf1910e`; its SHIP/CI do not apply to
this head. The only merge conflict was the flag registry: preserve both
meter and delivered-share entries and record count 285. Delivered-share
code, indexes, serving and dashboards match current main. Feature diff:
213 changed non-test lines. The automated P2 at predecessor 42a7077 is
confirmed and corrected: gate age/reach now sample the injected drain
clock AFTER transactional gate retrieval, on each retry. The predecessor
SHIP does not apply. Pipeline lead extended the cap by one narrow
confirmation and posted gpt-6-luna SHIP at this head. Normal successor
hooks passed; the single CI retry must finish green before readiness.

## Behavior and scope

The default-on meter reads an uncached six-field gate (`state`,
`rate_per_hour`, `reach_seconds`, `window`, `tokens_used`, `updated_at`)
inside the fresh-selection transaction. Missing, malformed, stale (180
seconds), closed, exhausted and out-of-reach gates refuse backlog. Only
the heartbeat determines the budget hour; merge token writes preserve
`updated_at`. Fresh commits neither read the gate nor spend tokens. A
metered result carries `backlog_release: true`.

Merge current main into the existing branch; no rebase. Integration
fixes update the merged flag count and explicitly select legacy
meter-off behavior in rollback/characterization fixtures. New
cross-store conformance covers token/result atomicity, fresh
independence and privacy refusal. Removed unrelated cursor budget
entries so the budget diff covers only the new gate collections. No
controller, heartbeat writer or migration is included: cursor 0007 is
retained; unmerged parking/0008 is separate.

## Service/version contract and release request

Ship CLOSED. Create no gate document, keep
`BATCH_PIPELINE_PROVIDER_BACKLOG_RELEASE_ENABLED=false` on all
committers and do not increase any rate. Absent/closed gate or rate zero
commits no provider backlog. Default-on code enforcement is not
activation.

Readers/writers: `OrderedMerge` on Cloud Run `backend-integration` and
GKE batch worker reads all six fields and updates only window/tokens,
preserving the heartbeat. Firestore/Postgres/simulator generic adapters
transport it. Postgres remains dark; actual Postgres acceptance remains
deferred under SCA-1959. Older versions ignore the document and obey the
legacy release switch. Result projection ignores the new result marker
and retains predecessor/privacy fencing. PR 4 must provide a single
fenced heartbeat writer and preserve current-hour token usage.

Rollback: `BATCH_PIPELINE_BACKLOG_RELEASE_METER_ENABLED=false` restores
the legacy default-off release switch; keep the provider release switch
false throughout rollback to prevent unmetered release. Before any
opening, Release must record actual serving revisions/images for BOTH
committing services. Parent SCA-2015 owns the release request and live
acceptance; this PR does not merge, deploy or authorize opening.

## Cost and limits

One global document serializes backlog commits. Added cost: one uncached
gate read per backlog attempt, one write per released row. For a ready
held head/no fresh rows: nine baseline reads and four writes on release;
seven reads/zero writes on refusal. Add up to two depth watermark reads,
commit-time privacy reads, cursor/owner discovery and transaction
retries. Explicit legacy false skips the gate read. Collection budgets
are planning envelopes, not measured/enforced limits. Observed process
counters may undercount lost replies/exits; durable tokens remain
authoritative. Reach uses capture end; zero is unlimited.

## Validation and confirmation

Pipeline lead's cap extension at17:48Z authorized exactly ONE narrow
independent confirmation, already launched by the lead from m5.
**VERDICT: SHIP e2906c4**, actual model
`gpt-6-luna` via agentctl review pool, posted17:54Z on SCA-2251 comment
`01a1db32-2683-7b10-884d-e94f9e0a50a4`. No BLOCKER or SHOULD-FIX. Narrow
diff `42a7077b35b3..e2906c4`, three files +65/-9. No extra
author-side reviewer or full review launched.

Confirmed by independent reviewer: post-read/post-parse sampling on
every retry; raising clock aborts without token/result; no
wall/monotonic mix; heartbeat-derived budget hour/token preservation;
fresh unchanged. Four new deterministic regressions fail under
predecessor sampling and pass now; reviewer focused suite57 passed.
Author canonical batch691 passed; actual
sim/Firestore-emulator/local-Postgres conformance60 passed, zero skips.
Normal hooks46 checks, zero type errors (existing warnings), push exit0
with zero leftover owned processes. Assertions, timing budgets and
allowlists unchanged.

Change-note assumption (nonblocking reviewer note): elapsed time must
not move backwards between drain start and post-read evaluation.
Production uses `time.monotonic()`, which satisfies it. A synthetic
backwards-moving clock could make a gate appear younger and is outside
this injected-clock contract. Recorded here and in the attached release
change-note addendum; no code/source commit changes the reviewed SHA.

CI disclosure: first attempt had two untouched CPU misses:
upload-coalescing supervisor1.08s and monthly-switch billing1.10s
against unchanged1.00s. Pipeline lead reran the failed job ONCE,
matching the permitted retry. That retry must pass at this exact head
before readiness; no further retry, threshold/assertion/allowlist change
or source edit authorized here. Existing timing-class follow-up is
separate from this PR.

Train2 merge order: BasedHardware#25281 first, then BasedHardware#25268. Any resulting mechanical
main merge needs the lead's confirmation at the new SHA; this SHIP does
not carry to a successor. Existing release request SCA-2262 only.
Provider release stays false, no gate creation/rate change. Actual
serving and live acceptance remain parent/release-owned.

Failure-Class: FC-backlog-release-shares-lane-with-fresh-work
Merges origin/main (27abe5b) into the package C branch of PR BasedHardware#25147.

Three textual conflicts, each resolved by keeping both sides:
- dual_store.py MIRRORED_TABLES: main added allowance_holds (BasedHardware#25281); this
  branch added pull_claims and merge_holds.
- test_store_conformance.py and test_jobstore_protocol_parity.py: both sides
  appended tests at the same place.

The merged tree fails test_every_serving_read_is_in_the_executable_parity_census:
main added Store reads after this branch was cut. The next commit covers them.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…parity and erasure

Main gained Store reads and one mirrored table after package C was cut
(BasedHardware#25281 allowance parking, the fresh gate, ready-owner discovery, the
finish backfill marker). The executable parity census must name every
serving read, and erasure of the Postgres copy must reach every mirrored
table.

- serving_parity: add ready_owners, allowance_owners, allowance_page and
  projection_finish_backfill_complete to the Store census, and
  fresh_first_pending and fresh_first_ready_pending to the transaction
  census. Frozen emulator and Postgres cases compare each one, empty and
  populated, including an allowance-parked row and its owner hold.
- dual_store.owner_rows: erase the owner's allowance_holds row by key, as
  merge_holds already is. The row was found only when the document named
  its owner; the erasure test now uses a hold document that does not.

Verified on this head with a loopback Firestore emulator and a throwaway
Postgres, OMI_REQUIRE_STORE_BACKENDS=all: test_jobstore_purge_postgres,
test_dual_store_firestore_postgres, test_dual_store_postgres,
test_store_conformance and test_recovery_custody_conformance: 423 passed,
7 skipped (cases not applicable to a backend). Unit: test_jobstore_dual_store
and test_jobstore_protocol_parity, 177 passed.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@mintlify

mintlify Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Preview approval required

This pull request comes from a fork, so Mintlify won't build a preview until someone with write access approves commit ad8c13c.

Approve preview

@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: 09eb5eab30

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

with bounded.read_connection() as conn:
# Locks match the real transaction read; never flush buffered writes.
return getattr(PostgresTransaction(bounded, conn), query)(*args, **kwargs)
return getattr(bounded, query)(*args, **kwargs)

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 marker observations on the bounded connection path

When the observed query is projection_finish_backfill_complete, its implementation calls self.run() (postgres_store.py:570), which acquires self.pool.connection() directly rather than using _ParityPostgresStore._read_conn(). Consequently, this observation can initiate IAM refresh or connection establishment, wait the default 30 seconds for a pool slot, and execute SQL without the observation's statement timeout—even after its deadline. The final deadline check only reports the error after the parity worker and shared pool have been occupied. Route run()-based serving reads through the bounded observation transaction as well.

Useful? React with 👍 / 👎.

# Only Firestore claims. Its CAS bypasses run(), so refresh the cold copy after success.
acquired = self.primary.acquire_pull_claim(shard, token, now, ttl)
if acquired:
self.refresh([('pull_claims', shard)])

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 Preserve successful claims when mirror startup fails

If the mirror worker cannot start—for example, threading.Thread.start() raises RuntimeError under thread exhaustion—refresh() lets _ensure_worker()'s exception escape here after the Firestore claim has already succeeded. Scheduler._pull_shard() then never reaches the transaction that releases that claim (scheduler.py:523-532), so the pull fails and the shard remains busy until its 30-second expiry solely because the best-effort mirror failed. Isolate this post-claim refresh failure just as DualStore.run() isolates _after_commit(), and preserve the authoritative acquisition result.

Useful? React with 👍 / 👎.

Git-on-my-level and others added 5 commits November 15, 2026 02:19
…rged mirror

Review of 09eb5ea (gpt-6-luna, read-only) returned FIX with three findings.

- Erasure of a copy nothing refreshes kept GPU reservations. Purge leaves a
  physical GPU reservation in Firestore until release, and the reservation
  names the leased segment. Owner erasure re-copied every GPU row, so a copy
  with mirror writes stopped kept the reservation of an erased segment and
  never saw its release. Such a copy now has its GPU rows deleted during
  erasure (read_current_without_reservations). A live mirror is unchanged:
  it copies the release. The cold-copy erasure test fails without this.
- The projection-finish backfill (added on main after this branch was cut)
  stamps results rows and its control marker in a Firestore transaction
  outside Store.run and did not refresh the mirror, so Postgres kept the old
  clocks and marker. It now calls mirror_refresh for the marker and the page.
- The frozen parity fixtures could not catch a marker read that always
  answers False, or a broken page after a cursor: they seeded no completed
  marker, one ready owner and one parked row. They now seed a completed
  marker, a second ready owner and a second parked row, with cursor cases.

Verified on this head, loopback Firestore emulator plus a throwaway Postgres,
OMI_REQUIRE_STORE_BACKENDS=all, the same five integration files: 427 passed,
7 skipped. Unit (finish backfill, dual store, protocol parity, shadow seams):
214 passed.

Failure-Class: none
Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ent id

Review round 2 of 21f3a4f (gpt-6-luna) closed the backfill and fixture
findings and kept the GPU one open for a live mirror: purge re-copies the
primary's active reservation, and if the copy of its later release is
dropped (the mirror queue is bounded and best effort), Postgres keeps the
erased segment's id. Reading the scheduler shows the release keeps
segment_id as well, so the id lives in the reservation row until the GPU
is leased again.

Rather than special-case when to delete the row, the copy no longer holds
the field at all: UNMIRRORED_TABLE_FIELDS drops gpus.segment_id on every
copy, and comparisons (mirror read parity, convergence, backfill census,
the serving-parity get) compare what the copy is meant to hold. Nothing
reads a reservation's segment from Postgres while Firestore is the
authority. A copy written before this change reads as stale and is
re-copied without the field. The cold-copy special case added in
21f3a4f is removed, since there is nothing left for erasure to miss.

Verified on this head, loopback Firestore emulator plus a throwaway
Postgres, OMI_REQUIRE_STORE_BACKENDS=all, the same five integration files:
passed with 7 skipped (see the PR body for the count on the final head).
Unit (finish backfill, dual store, protocol parity, shadow seams, postgres
locking): 225 passed.

Failure-Class: none
Co-Authored-By: Claude Fable 5.2 <[email protected]>
6e0f28c passes the table to compare() inside backfill_table, which
changes its pinned body digest. The skip was re-reviewed: the function
still issues no Firestore query of its own (it consumes _pages), so the
skip reason stands and only the digest moves.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…ing fields

query_value returns a list for most reads and a document only for get.
The field stripping added in 6e0f28c applies to documents; say so in
the type so the backend type check passes. No behaviour change: get
returns a document or an empty one.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
…rimary side only

Review round 3 of 6e0f28c (gpt-6-luna) closed the GPU reservation
finding and found that the serving-parity get comparison stripped
gpus.segment_id from both sides, so a Postgres row copied before the
field became Firestore-only would read as a match. It now strips the
primary side only, as dual_store.compare does, so such a row is a
mismatch. A frozen emulator and Postgres case proves it.

Verified on this head, loopback Firestore emulator plus a throwaway
Postgres, OMI_REQUIRE_STORE_BACKENDS=all, the five integration files:
432 passed, 7 skipped. Unit, including the Firestore query-shape guard:
767 passed.

Failure-Class: none
Co-Authored-By: Claude Fable 5.2 <[email protected]>

@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: 21f3a4f308

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

self._query_queue.put_nowait((name, deepcopy(args), deepcopy(kwargs)))
with self._lock:
if self._query_worker is None or not self._query_worker.is_alive():
self._query_worker = threading.Thread(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Use the managed executor lifecycle for query observations

When JOBSTORE_SHADOW_QUERY_PARITY=on, this starts an unmanaged daemon whose _drain_queries() loop has no shutdown path. backend/AGENTS.md expressly says “Never ad-hoc Thread/ThreadPoolExecutor”; this new worker also bypasses the executor concurrency metrics and shutdown handling in utils/executors.py. Dispatch bounded observation jobs through the managed executor/background-task infrastructure rather than adding a permanent thread outside that lifecycle.

AGENTS.md reference: backend/AGENTS.md:L270-L270

Useful? React with 👍 / 👎.

@@ -289,8 +319,61 @@ def __init__(
self._tracker: threading.Thread | None = None

def __getattr__(self, name: str) -> Any:
# due / oldest / oldest_retry / control_candidate / quarantine_fenced / projection_* / client / namespace
return getattr(self.primary, name)
from database.jobstore.serving_parity import STORE_QUERIES

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Move the new parity imports to module scope

The new observer code introduces function-local imports here and in _observe_query(), _drain_queries(), and query_value(), contrary to backend/AGENTS.md's explicit “All imports at module top level — never inside functions” rule. Extract the shared census constants to break the new dual_store/serving_parity dependency cycle, allowing the added imports to live at module scope rather than hiding dependencies inside normal attribute dispatch.

AGENTS.md reference: backend/AGENTS.md:L168-L168

Useful? React with 👍 / 👎.

return 0 # shadow refused (unconfigured or no driver): the mirror never ran here
return store.purge_owner_now(owner_id)
primary = FirestoreStore(namespace) if namespace.startswith('batch_pipeline_test_') else _ErasurePrimary(namespace)
store = _configured_copy(primary)

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 Share a bounded pool across uncached erasure calls

When a configured retained target is purged after restarting with mirroring disabled, _SHADOWED remains empty and every concurrent call creates its own Pool(size=2), then closes it in finally. The semaphore limits each pool independently, so the 20-worker erasure_executor can open 20 PostgreSQL connections per process instead of sharing the previous namespace pool's two-slot budget. This bypasses the connection-storm protection documented in connection.py and can exhaust the retained target during deletion bursts. Reuse an admission-independent erasure pool or enforce a shared process-wide connection budget.

Useful? React with 👍 / 👎.

Comment thread backend/database/jobstore/dual_store.py Outdated
store = _configured_copy(primary)
if store is None:
return 0
store.cold = True

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 Preserve active GPU copies when the local mirror cache is empty

If a deletion process has not populated _SHADOWED, this marks the target cold even when the namespace is admitted and another process is actively mirroring it. _reconcile_owner() then uses read_current_without_reservations() for every GPU row returned by owner_rows()'s namespace-wide scan, so purging one owner deletes unrelated owners' reservation copies from PostgreSQL while they remain valid in Firestore. Those rows can remain absent until their next GPU mutation, invalidating census and parity results. Do not infer target-wide mirror inactivity from a process-local cache miss; preserve unrelated reservations in this path.

Useful? React with 👍 / 👎.

CI on 73b4c97 failed Backend unit shard 7/8 in
tests/unit/test_reason_label_enums.py: compare_serving_query passed a
plain string as the outcome label of omi_jobstore_serving_parity_total.
Metric outcome labels must be members of a closed enum passed through
reason_label(). ServingParityOutcome names the four outcomes the function
already produced (unknown, match, mismatch, error); the values are
unchanged. The other seven unit shards and the emulator proofs passed on
73b4c97.

Verified locally: test_reason_label_enums, the Firestore query-shape guard
and the jobstore unit files, 809 passed.

Failure-Class: none
Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Replaced by #25323: the same commits on a new branch, head ad8c13c81d2c. This PR was opened on 2026-11-12, and the UI author approval guard compares against the base commit recorded then; with main merged in, that comparison exceeds the guard's 300-file limit and fails closed. Review history and verdicts are summarised in #25323. To undo: reopen this PR and close #25323.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @Git-on-my-level 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Git-on-my-level added a commit that referenced this pull request Nov 15, 2026
…CA-2288) (#25323)

## Current merge candidate and disposition — 2026-11-15

Current head: `6a0fe352db1220059456488b2ac752420ebd1c44`.

The m5 author remains the sole branch writer. This CI-refresh commit has
the same complete source tree
(`1ff77c8991d37e33879fd78b14717b85b2993155`) as lineage-fix commit
`e9eb225342c66f01cded3c61e4d52372c1955c8e`. The fix normalizes only
table-specific primary-side exceptions and preserves omitted intake
`repair_lineage` as a serving mismatch; its regression covers matching
without lineage and mismatching with it.

SCA-2339's RULING on SCA-2288 at 2026-11-15 00:37:42Z is **fix exactly
this and ship without another review**. It supersedes the older review
requests recorded below; it is not a claim of a new reviewer SHIP at
this head. Local results reported by the author: 824 unit/guard passes;
433 integration passes, 7 skipped. Terminal candidate CI at 04:47Z
passed all eight backend unit shards, the Backend unit suite, emulator
proofs, Hygiene and the configured required checks. Synthetic candidate
`e822681f9bda222a806e926d6d5104b764d354fe` includes repaired main.

This is a dark-mirror source handoff through normal release-owner
merge/train controls. Production admission and activation remain
separate. Copy-TTL retirement and owner-resolved cohort wiring remain
production-readiness requirements; no production namespace is admitted
by this handoff. No live evidence or savings is claimed. All older
commit/test/review receipts below are historical and do not identify the
current candidate.

> Replaces #25147: the same commits on a new branch. #25147 was opened
on 2026-11-12, and the UI author approval guard compares against the
base commit GitHub recorded then; with main merged in, that comparison
exceeds the guard's 300-file limit and fails closed. Against current
main this change is 26 files. Review history and verdicts carry over and
are summarised below.

## What changed and why

SCA-1807 package C extends the dark Firestore-to-Postgres mirror census
to pull claims and merge holds, adds executable comparisons through the
actual serving read methods, and makes cold-copy erasure independent of
mirror mode and namespace admission. Explicit namespace admission
defaults empty; the existing staging fence still refuses production.
Firestore remains the only claimant/writer; no D reverse copier or
serving writer is added.

Query observation is separately opt-in, uses a bounded queue, and emits
counts only. Frozen emulator/PG fixtures cover every serving read, empty
results, ties, null/missing values, cursors, owner-serialized phantoms
and deliberate drift. Capture repair_lineage retains its existing
Firestore-only retention boundary; this is explicitly a full-field
serving gate, not normalized away by the new checker.

## Product invariants affected

none

## How it was verified

- Locked Python 3.11 macOS environment via
backend/scripts/sync-python-deps.sh.
- Design's exact seven-file test.sh unit set: 196 passed; additional
seam/staging/projection and conversation-erasure tests: 123 passed.
- Real loopback Firebase emulator and disposable socket-only Postgres,
OMI_REQUIRE_STORE_BACKENDS=all, exact nine-file design matrix: 490
passed, 10 skipped, 3 strict xfailed, 5 failed. The five failures are
the existing Firestore enrichment outbox timing/coalescing and
wake-exception contract failures; unchanged base
faec7c5 reproduces all five. No
skips/xfails are hidden or changed to pass.
- `make preflight`: all 41 checks passed; the normal push hook also
enforces final-head checks and backend typing.
- Independent review completed in two rounds; round 2 cleared product
commit 7e11cad with no P0/P1/P2
blockers. The subsequent commit classifies both values of the
pure-observation argument in the existing Firestore query test driver
and corrects the instrumentation control’s registry classification to a
permanent configuration switch. The final typing-only follow-up adds a
local alias for the same bounded connection context manager; it changes
no runtime behavior. No third independent review was requested. Final
SHA, terminal logs and preflight result are attached to SCA-1807.

No live shadow evidence, activation, deployment, migration, privacy
serialization proof or savings is claimed. Source savings: $0. SCA-1697
retains D ownership; staging sizing/RC2, production admission, repair
lineage retention, cross-store privacy, full-field live parity and
settled billing remain gates. Details:
backend/docs/jobstore-dark-parity.md.

## Update 2026-11-14: main merged in, new owner (SCA-2288)

This PR now belongs to SCA-2288 (Postgres as a discovery index beside
Firestore; David's ruling of 2026-11-14 is on SCA-1959 and SCA-2288).
SCA-1807 was folded away; the original author no longer pushes here.

Historical integration: two commits on top of previously reviewed commit
`43ddb2ee26a9`:

- `117b10be02b1` merges origin/main (`27abe5bbf8f6`). Three textual
conflicts, each resolved by keeping both sides: `MIRRORED_TABLES` (main
added `allowance_holds` in #25281; this branch added `pull_claims` and
`merge_holds`) and two test files where both sides appended tests.
- `09eb5eab3071` covers what main added after this branch was cut. The
executable parity census gains `ready_owners`, `allowance_owners`,
`allowance_page`, `projection_finish_backfill_complete`,
`fresh_first_pending` and `fresh_first_ready_pending`, each with frozen
emulator and Postgres cases. Erasure of the Postgres copy now removes
the owner's `allowance_holds` row by key; before this it was found only
when the hold document named its owner, and the erasure test now uses a
hold document that does not.

Verified on `09eb5eab3071`, loopback Firestore emulator plus a throwaway
Postgres, `OMI_REQUIRE_STORE_BACKENDS=all`:
`test_jobstore_purge_postgres`, `test_dual_store_firestore_postgres`,
`test_dual_store_postgres`, `test_store_conformance`,
`test_recovery_custody_conformance`: 423 passed, 7 skipped (cases not
applicable to a backend). Unit `test_jobstore_dual_store`,
`test_jobstore_protocol_parity`: 177 passed. The earlier verification
section above describes historical commit `43ddb2ee26a9` and its base,
not the current candidate; the full nine-file design matrix was not
re-run on this head.

Independent review of `09eb5eab3071` (gpt-6-luna, read-only) returned
FIX with three findings, all fixed in `21f3a4f3080d`:

- Erasure of a copy that nothing refreshes re-copied GPU reservation
rows, which name the leased segment until release; such a copy now has
those rows deleted during erasure. A live mirror is unchanged.
- The projection-finish backfill, added on main after this branch was
cut, commits outside `Store.run` and did not refresh the mirror; it now
does.
- The frozen parity fixtures gain a completed backfill marker, a second
ready owner and a second parked row, with cursor cases.

Verified on `21f3a4f3080d`, same setup and the same five integration
files: 427 passed, 7 skipped. Unit (finish backfill, dual store,
protocol parity, shadow seams): 214 passed.

Review round 2 of `21f3a4f3080d` closed the backfill and fixture
findings and kept the GPU one open for a live mirror (a dropped copy of
the release would leave the erased segment's id in Postgres).
`6e0f28ce8783` fixes it at the root: the copy never holds
`gpus.segment_id` (`UNMIRRORED_TABLE_FIELDS`), comparisons compare what
the copy is meant to hold, and the cold-copy special case from
`21f3a4f3080d` is removed.

`22d3e4e792c4` re-pins the reviewed body digest of `backfill_table` (the
pre-push Firestore index guard caught the changed body; the function
still issues no query of its own). `2754ac3b8dd3` narrows a type in the
serving-parity comparison so the backend type check passes; no behaviour
change. Verified for `6e0f28ce8783`: the five integration files, 429
passed, 7 skipped, run before one more fixture case (`get` of a GPU row)
was added; the two files changed after that
(`test_dual_store_firestore_postgres`, `test_jobstore_purge_postgres`)
were re-run on the final tree, 108 passed. Unit (finish backfill, dual
store, protocol parity, shadow seams, postgres locking): 225 passed.

Review round 3 closed the GPU finding and found that the serving-parity
`get` comparison stripped the field from both sides, so a stale Postgres
row would read as a match. `73b4c9799a58` strips the primary side only,
with a frozen case that proves a stale row is a mismatch.

Historical validation on commit `73b4c9799a58`: the five integration
files, 432 passed, 7 skipped. Unit, including the Firestore query-shape
guard: 767 passed.

CI on `73b4c9799a58` failed one unit shard in
`test_reason_label_enums.py`: the serving-parity counter took a plain
string as its outcome label. `ad8c13c81d2c` declares the four existing
outcomes as an enum passed through `reason_label()`; values are
unchanged. The other seven unit shards and the emulator proofs passed on
`73b4c9799a58`.

The board review on SCA-2288 of `ad8c13c81d2c` found that observing
`projection_finish_backfill_complete` went through `PostgresStore.run()`
(its own connection and a `FOR UPDATE` on the control marker).
`b067fc016e8f` reads the marker on the observer's bounded connection
with a plain read, with a unit test that fails on a serving transaction,
a new connection or `FOR UPDATE`. Verified on `b067fc016e8f`: unit and
guard files 824 passed; the five integration files 432 passed, 7
skipped.

The second look on SCA-2288 (Kimi, historical review commit
`b067fc016e8f`) found that the serving-parity `get` comparison also
removed `repair_lineage` from the primary side, so an intake with
lineage compared equal to a copy without it. `e9eb225342c6` takes off
only the GPU reservation's segment id; a frozen case proves the lineage
omission stays a mismatch. Verified on `e9eb225342c6`: unit and guard
files 824 passed; the five integration files 433 passed, 7 skipped.

Still dark: no namespace is admitted by default,
`JOBSTORE_SHADOW_QUERY_PARITY` is off, and nothing here serves a read
from Postgres. Historical review scope (superseded by the SCA-2339
ruling below): the merge delta and the commits after it (`09eb5eab3071`,
`21f3a4f3080d`, `6e0f28ce8783`, `22d3e4e792c4`, `2754ac3b8dd3`,
`73b4c9799a58`, `ad8c13c81d2c`).

## Tests

Regression and frozen-query cases extend
test_dual_store_firestore_postgres.py, test_jobstore_purge_postgres.py
and test_store_conformance.py. Golden harness claim forwarding now
exercises the same mirror seam as production. No authoritative behavior
or golden outputs change.

## UI evidence

UI-Evidence: none -- backend source only

## Failure class

Failure-Class: none
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.

3 participants