Skip to content

test(backend): preserve projection discovery across old and new stores - #25555

Merged
Git-on-my-level merged 3 commits into
mainfrom
lane/parity-pl606
Nov 24, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
lane/parity-pl606

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Projection discovery must not hide owed work when the replacement job store adopts independent follow-up clocks. Add shared Store conformance for PL-606/607/608 and select it in the existing emulator proof runner. The standalone scripts/projection_discovery_emulator_test.py path matches both existing event filters, so future test-only edits run that lane too.

  • Future follow-ups are filtered before the page budget, including the exact due boundary. Legacy discovery retains unclocked receipts.
  • Async exclusion applies only to finish-clock discovery. Independent follow-up and rollback queries retain those obligations.
  • Equal-clock siblings survive cursor-row completion or rescheduling. Fixed-cutoff passes finish despite future-tail growth and revisit behind-cursor inserts on wrap.

The assertions pin accepted clock field names, drain states and the negative sentinel independently of implementation constants. The tests run the same public query calls against the old Firestore emulator, replacement Postgres and simulator. The production Store query interface is already the shared primitive; this matrix qualifies it rather than adding another implementation. No runtime source, policy, index, configuration or workflow changes. Firestore's separate exact-preimage deferral writer and serving-loop restart scheduling are outside this query-only proof.

Verification

  • All required Store backends: 24 passed, zero skips/xfails. PostgreSQL uses an owned loopback Docker container because native macOS shared-memory IDs are exhausted.
  • Three in-process negative controls fail at assertions: unfiltered discovery (2), shared async exclusion (2), lost equal-clock siblings (4). Final unchanged-source matrix passes again.
  • Full existing emulator runner: 28 groups pass. The sole failure is local lifecycle preflight refusing reachable ADC before execution; the guard is retained and clean CI must qualify it.
  • make preflight: all 37 selected checks pass. PR-body preflight: 12 checks pass after correcting the declaration to a single token. Normal push gates pass, including zero whole-backend type errors and 1,898 selected unit tests. Current CI is reported by the PR checks.
  • Commands: omi-heavy run -- python3 2026-11-17-run-proof.py (loopback Firestore + owned PostgreSQL container, OMI_REQUIRE_STORE_BACKENDS=all); under that wrapper, .venv/bin/python -m pytest -q -p no:cacheprovider scripts/projection_discovery_emulator_test.py and PYTHON=.venv/bin/python bash scripts/run-emulator-proofs.sh.

KB acceptance: backend-target-architecture plans A/C; durable harvest and ledger published for 2026-11-17. No live/serving, savings, migration or cutover claim. Do not merge as part of the daily port task.

Product invariants affected

none

Failure-Class: none
Failure-Class-Reason: test-only shared qualification of existing contracts; no runtime repair

🤖 Generated with Claude Code

Git-on-my-level and others added 2 commits November 16, 2026 20:53
Cover PL-606, PL-607 and PL-608 through one old/new Store matrix.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use a real result-ready job and remove the redundant repeated-query assertion.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 19, 2026
## Change

Ordered merge and source-alias fallback now stamp an idempotent
projection obligation on the committed result in the same transaction.
The segment key and owner log sequence identify the revision. Serving
offers an immediate, bounded post-commit hint, and one strict lease
holder per namespace scans lost wakes in kind, due time, and document ID
order. A delivery claims the revision, runs the existing fenced
projector, then settles from the canonical result state. Predecessor,
sibling, timeout and error deferrals retain the obligation with a
bounded clock and a disposition. Multipart receipts, content ledger
completion, hourly usage, retained audio and privacy checks use the
existing authority.

This removes downstream job/policy probes and projection attempts for
covered rows from legacy assignment, finish and follow-up sweeps while
the backstop has recently succeeded and is keeping up. Legacy pages
retain their raw Firestore reads, cursor and overlap measurements. The
existing finish classifier (#25314), follow-up due-clock marker, overlap
measurement (#25596), refused-head recovery (#25623), and raw keyset
conformance (#25555) retain their separate responsibilities.

## Mixed versions and rollback

Older writers, including GPU image `ef42ee8`, leave unstamped rows
eligible for every legacy path. Older readers may consume a stamped
result through the existing receipt and accounting fences. Current
GPU-side commits rely on the elected due scan because the GPU process
has no projector. No cross-process wake transport or historical backfill
is needed for coverage. Fenced held release and privacy resume rearm a
result and invalidate its prior token. New writers with the switch off
mark a reactivated row for legacy discovery while keeping its previous
scheduling metadata. An expired or stalled backstop restores
compatibility attempts, even for stamped rows.

Set `BATCH_PROJECTION_OUTBOX=false` on the participating readers and
writers to restore the full legacy discovery paths and stop new
obligations and claims. Existing result and receipt data stay available.
Set it to true to resume after both stage-specific indexes are READY and
the due query is confirmed. Release qualification compares matched
completion, partial latency, oldest obligation, failures and read/write
telemetry across the actual serving roster.

The outbox supervisor starts on projection-serving roles when its switch
is on. A batch-serving process continues outbox discovery when the
dedicated pump and legacy projection sweep are both off. The due-page
loop has a 5-second interval, a MAX_PENDING initial 200-key bound, and a
MAX_SCAN_LAG initial 60-second coverage limit. Both follow-up queues
share the existing per-process slot budget. Its claim expires after 180
seconds. Existing serving and projection-pump cadence and page
configuration are preserved. A missed wake, process loss or leader
change returns unclaimed debt to discovery. A canonical hold parks it
until an existing release or privacy resume. Persisted and ready
receipts honor a future `projection_followup_due_at`. Unsuccessful
finish then uses the configured follow-up backoff on the outbox clock,
with a 60-second fallback if the setting is zero. Outbox delivery skips
the legacy durable deferral write.

## Expected saving

**Inferred, unmeasured in serving.** The design baseline measured
overlapping 339.56M follow-up-origin and 222.08M serving-origin reads in
the 24 hours ending 2026-11-18 13:16Z. Those totals include useful work.
The avoided share is the expensive downstream attempts of covered rows,
and the two baselines cannot be added. Embedding the metadata adds zero
document writes at merge. One claim plus one settlement at the recorded
1.516M daily commits implies about 3.03M scheduling writes/day if every
commit follows that path, before retries and lease writes. Index cost
and net read savings need a matched serving measurement.

## Panel and verification

Scope panel `scope-20261118t145338-00de` returned three answers.
Accepted its writer audit, per-row revision witness, strict lease and
post-page token check, due deferral, existing receipt/privacy fences,
three-store parity, existing age gauge, rollback and cost measurement.
Chose embedded result fields because they avoid a new merge write and
preserve the existing purge and retention lifecycle. Deferred a physical
Firestore legacy page cut, fleet backfill, additional election switch,
and cross-process wake transport. A successful per-row witness keeps old
and mixed-mode writers eligible without a fleet cutover. The scope
command emitted a dossier without F-numbered findings, so its
review-only triage CLI had no calls to record.

- `cd backend && .venv/bin/python -m pytest -q
tests/unit/test_firestore_query_shapes.py --tb=short` — 611 passed.
- `bash backend/scripts/check_runtime_env_compose.sh`, `python3
scripts/check_feature_flag_registry.py`, and `cd backend &&
.venv/bin/python scripts/generate_firestore_indexes.py` — passed.

- Focused backend pytest files for the outbox, serving, leader,
discovery and follow-up desync — 201 passed.
- `OMI_REQUIRE_STORE_BACKENDS=all .venv/bin/python -m pytest -q
tests/integration/test_store_conformance.py -k projection_outbox`
(loopback Firestore and an owned PostgreSQL 16 container) — 3 passed,
one per store.
The fixture pins scheduler elapsed time alongside its synthetic
timestamps so local load cannot expire the setup claim.

- `.venv/bin/python -m pytest -q
tests/integration/test_batch_pipeline_projection_followup_firestore.py`
(loopback Firestore) — 13 passed, including lost wake/ack, duplicate
delivery, privacy, predecessor, and multipart restart.
- `.venv/bin/python -m pytest -q tests/unit/test_flag_budget.py` — 26
passed. `.venv/bin/python -m testing.pipeline_sim projection-drain
--rows 300 --owners 12` — all three projection modes preserved ordering
and completed assignment.
- Dev and prod `backend/scripts/validate-backend-runtime-env.py` and
deployment-setting classification — passed.

- The normal pre-push PR preflight passed all 52 selected static,
metadata and Firestore guard checks. The local hook used the approved
900-second per-file wall budget after a host-load timeout.

- Whole-backend Pyright passed with zero errors in the normal push hook.
The loopback Store conformance and 13 Firestore tests were repeated
after the typed Store interface correction.
- The outbox unit and background-task ratchet rerun passed 12 tests,
including graceful worker shutdown. The runtime manifest validator
passed 295 tests, and the async blocker gate reported zero selected
findings.
- `cd backend && .venv/bin/python -m pytest -q
tests/unit/test_batch_pipeline_projection_outbox.py` — 6 passed after
adding the mixed-switch reactivation assertion. The three-store
conformance and 13-test Firestore replay rerun also passed with the
fixed scheduler test clock.

### Round 2 review and CI repairs

Review panel `review-20261118t202810-030a` (FIX-FIRST), CLI triage
`F1=accept F2=accept F3=accept`.

- F1 starts elected outbox discovery independently of the dedicated pump
and legacy sweep on a batch-serving process. Projection and
first-summary policy stamping stay on owning roles. The outbox hands off
predecessor work and index flushes after the delivery claim scope.
- F2 proves a stale oldest due row clears the coverage witness,
successful scans renew it near expiry, and scans leave a fresh witness
alone.
- F3 enforces the follow-up due time and configured backoff on outbox
delivery. The outbox is the sole durable retry-clock writer for those
deliveries.
- CI on `d1195ac4cc7` found a stale ghost-hold assertion, a stale pump
fixture and Store protocol expectations, and scheduler-only fields
leaking into the characterization and provider-STT behavior goldens. The
integration assertion now pins the ghost-hold outbox clock. The
simulator trace excludes the internal kind and retry reason, with the
outbox details checked directly by replay and conformance tests.
- Hosted unit shard 7 on `0be3b03fd7e` caught the shadow-store guard
pointing at the public wrapper. It now asserts that the cached
constructor wraps the only Firestore store. All 23 cases in
`test_jobstore_shadow_seams.py` passed locally.
- Hosted Sync Cloud Tasks `batch-happy` on `0be3b03fd7e` exposed an
admission process stamping projection policy when neither serving role
was enabled. The startup gate now preserves projection-serving role
ownership even while the outbox remains independent of legacy sweeps.
- Round 5 incorporates
[#25778](#25778), which removed
the paused jobstore retirement carrier. The migration runner requires
contiguous numbers, so the unchanged outbox index SQL occupies
`0010_projection_outbox_due.sql`. Production Postgres target bindings
remain absent and outbox projection stays on Firestore during the pause.
The main branch’s staging isolation fence stays in place.
- `08352903c14` also fences the delivery claim at canonical transaction
read and before fair-use dispatch, preserves mixed-store discovery
parity, and reserves queue space for lost wakes.

- Ran each of nine focused unit files in its own pytest process from
`backend` using `.venv/bin/python -m pytest -q tests/unit/<file>.py
--tb=short`. All 559 cases passed across outbox, serving, pump,
follow-up clock, job-store parity and migrations, provider STT,
characterization, and the background-task ratchet.
- The role-bound startup change passed the 178 focused serving, pump,
and outbox cases. The local `batch-happy` gauntlet passed against
Firestore and Redis with its original owning-role and effect assertions.
The first local full-batch attempt stopped before scenarios at the
serving startup deadline under host load. The focused rerun increased
only the local startup wait.
- Discovery, overlap, and dual-store focused unit files added 150
passes. The final typed parity adapter was exercised again with 156
protocol-parity and 78 dual-store passes.
- `make preflight` passed all 52 selected manifest checks, including the
index and collection guards, feature flags, and runtime composition. The
normal push hook also passed whole-backend Pyright with zero errors and
all 40 selected unit files.
- Loopback Firestore pytest proofs passed 16 in
`test_batch_pipeline_projection_followup_firestore.py` and 37 in
`test_batch_projection_ghost_holds_firestore.py`. One ghost-hold
throughput assertion was intentionally skipped because emulator speed
depends on host load.
- `OMI_REQUIRE_STORE_BACKENDS=all .venv/bin/python -m pytest -q
tests/integration/test_store_conformance.py -k projection_outbox` passed
all three backends. `test_jobstore_migrations_postgres.py` added three
native PostgreSQL 16 passes. A supplemental full run was interrupted at
193 passes and two skips after a Docker connection stall reproduced by a
standalone PostgreSQL connection. The targeted rerun used the native
test fixture.
- `.venv/bin/python -m testing.pipeline_sim projection-drain --rows 300
--owners 12` preserved projection and chain ordering in all three modes.

### Hosted verification at `6d2551733d9`

The full Sync Cloud Tasks and Listen Pusher gauntlets, Backend Emulator
Proofs, and unit shard 7 all passed. The backend unit suite remains red
solely on two CPU-duration guard violations. Pytest reported 39 and 297
passing tests in the two files, respectively. [Hermetic
E2E](https://github.com/BasedHardware/omi/actions/runs/44468718109),
[emulator
proofs](https://github.com/BasedHardware/omi/actions/runs/44468718162),
[backend unit
suite](https://github.com/BasedHardware/omi/actions/runs/44468718334).

-
`test_monitoring_adapter_hpa_contract.py::test_hpa_and_adapter_changes_select_this_contract`
used 1.02 s of CPU against the 1.00 s limit. It used 0.65 s in the
preceding hosted run and 0.59 s in the local rerun with the same guard.
[Hosted shard
2](https://github.com/BasedHardware/omi/actions/runs/44468718334/job/135372906740).
-
`test_backend_runtime_env_validator.py::test_control_sync_routing_validates_deployed_values_without_changing_manifest[all]`
used 1.04 s against the same limit. It used 0.92 s in the preceding
hosted run and 0.62 s in the local rerun. [Hosted shard
5](https://github.com/BasedHardware/omi/actions/runs/44468718334/job/135372906741).
- The two cases, their test selector, runtime manifest and validator are
identical to the preceding PR head, which passed both hosted shards. The
intervening diff restores projection-serving ownership and updates the
store-construction guard. [Previous unit
run](https://github.com/BasedHardware/omi/actions/runs/44461717687).

## Product invariants affected

- INV-MEM-4. The runtime manifest declares a projection scheduling
switch. Canonical memory admission and the projection receipt, ledger
and accounting authority stay on their existing paths.

Failure-Class: FC-unresolved-head-blocks-projection

Line-Count-Exception: backend/utils/batch_pipeline/projection.py | 1871
-> 1914 | Projection owns coverage-aware discovery and dispatches outbox
snapshots through its existing fenced receipt methods.




<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/25724?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/25724?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F25724&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. -->

Implemented by a delegated agent for the batch owner-state program.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

REVIEW: SHIP

Reviewed at head 2f9ab46. No actionable findings. The change adds test-only Store conformance for independent follow-up/finish clocks, due-boundary filtering, and cursor progress, and selects it in the existing emulator proof runner. No production runtime path is changed.

@Git-on-my-level Git-on-my-level left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

REVIEW: SHIP

Manual review at head a902fea. No actionable findings. The diff adds only shared Store conformance coverage and its existing proof-runner entry; the rebase preserves main's proof groups and introduces no production read/write path. The focused three-backend matrix and relevant PR checks are reported green. The panel could not launch because the Multica issue has no resolvable PR association.

@Git-on-my-level
Git-on-my-level merged commit 221c000 into main Nov 24, 2026
67 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/parity-pl606 branch November 24, 2026 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant