Skip to content

perf(batch): dark per-row finish backoff for projection replay - #25122

Merged
Git-on-my-level merged 6 commits into
mainfrom
lane/jobstate-cut
Nov 11, 2026
Merged

Git-on-my-level merged 6 commits into
mainfrom
lane/jobstate-cut

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Dark: cut projection replay reads with a per-row finish backoff (A-1)

Requested by lead2 (job-state polling vs event dequeue, 648669): the 23–26% no-move cut as one dark PR,
kill switch through the normal path. Source packet:
data/run-2026-11-08-pipeline-refactor/findings-jobstate-vs-dequeue-20261111.md.

What changed and why

The projection finish page re-reads and re-fences every persisted/ready result on every serving tick
whether or not anything changed. That replay is most of the projection family: 287.0M reads/day for 495,593
completed projections = 579 reads per completion
, about 89× what a first projection needs (findings §3.2).
95–99% of it is replay of already-projected work.

This adds a durable per-row next-attempt clock, so a walk that changed nothing is not re-read every tick:

  • New additive result fields projection_finish_due_at (epoch seconds) and projection_finish_backoff_step.
  • The finish page asks for projection_state in (persisted, ready) and projection_finish_due_at <= now.
  • A no-change walk defers the row 60 s → 300 s → 900 s (capped). The deferral is a fenced transaction:
    it re-reads the row and refuses if projection_state moved.
  • Every projection_state write stamps the clock as due now in the same transaction (session receipts and
    part summaries, quarantine hold/restore, release, sibling wake, completion). A state move is therefore never
    deferred, and no obligation waits on a stale clock.
  • The pending assignment page is untouched, so new work is never delayed.
  • The range filter must lead the ordering (Firestore serves a range filter on the first ordered field only), so
    this page gets its own composite index (projection_state, projection_finish_due_at, committed_at, __name__)
    and a (due_at, committed_at, key) cursor. The legacy page, its cursor and its index are unchanged.
  • A row written before the lever carries no clock, and a range filter cannot see a missing field. The first pass
    after enablement is therefore the unfiltered legacy page, which stamps those rows; only then does the page
    filter. Each process does that one survey pass (today's read cost) and then saves.

Read path only: no projection output, routing, UI, credential/IAM or workflow change. Alternate job-store backends mirror the Firestore projection-page contract.

Line-Count-Exception: backend/utils/batch_pipeline/projection.py | 1722 -> 1751 | every new decision
(page selection, the one survey pass, defer-or-skip, and closing the survey only after its page is durably
stamped) lives in backend/utils/batch_pipeline/projection_finish_backoff.py; the frozen file gains the
survey/deferral call, the blocked/error stamp in a finally, the one post-loop survey close, and the finish
reads/completion counters so the sweep's error/count/logging path is untouched.

Kill switch, default, rollback

  • BATCH_PROJECTION_FINISH_BACKOFF_ENABLED, default OFF (KILL_SWITCHES → False, read through
    config.policy.kill_switch; registry row config/feature-flags.yaml lifecycle rollout, fail: closed,
    owner firestore-lead).
  • OFF is byte-identical to today: same query (ORDER BY committed_at, __name__, same cursor), no field is
    written, and the sweep makes the legacy next(limit=size) call unchanged.
  • Rollback: one env flip to false/0. The fields are additive and unread when off, and the next tick is
    the legacy page. No backfill, no data migration, no index removal.

Scope items not in this PR (named follow-ups)

  • Leader election for the polling sweep — not a small independent change. The queue-age gauges are already
    leader-elected (batch_metrics_oldest_leader defaults to 100); the remaining 20.9M+4.1M reads/day on
    oldest/oldest_retry are the up-to-500-doc policy-hold walk, i.e. a gauge cache/aggregate, not election.
  • lifecycle_record_pending_head lever on for the emitters — not config-only in this repo's sense: the
    lever is already at 5% on backend services, and the emitters that miss it are the GKE worker fleet, whose
    FIRESTORE_READ_LEVERS comes from the deployment overlays. Turning it on changes production behaviour at
    deploy instead of staying dark, and its correctness proof was not read (findings §6.8). It should ride its own
    PR with its own percentage ramp.

Metric

Primary: reads per completed projection =
sum(increase(omi_firestore_billed_reads_by_caller_total{caller=~"database.batch_pipeline_projection.*|database.batch_pipeline_store:projection_page"}[24h]))
÷ sum(increase(omi_batch_pipeline_correctness_transitions_total{event="projection_completed"}[24h])).
Today 579; target after A-1 116–261. Expected saving 55–80% of the 287.0M/day pool = 158–230M
reads/day ≈ $85–124/day
at the $0.54/M marginal read price.

Guards (all must stay flat): omi_batch_timeliness_new_over_sla_units{leg="projection"} (395,407 today, must
not rise), omi_batch_projection_obligation_oldest_age_seconds (2,068,400 s, must not rise),
projection_completed within ±2%, summary-debt legs unchanged, omi_firestore_caller_label_overflow_total
flat.

Parity evidence (identical output)

backend/tests/unit/test_batch_projection_finish_backoff.py::test_same_output_with_the_flag_on_and_off runs the
same result log through the real sweep twice, flag off and flag on, and asserts identical sweep counts and an
identical walk order on the second tick, after the survey, so the flag-on run exercises the clock-filtered
page rather than only the unfiltered first pass. Other tests in that file prove:

  1. flag off: the finish page passes no clock filter (due_before absent), no field is written, no deferral call;
  2. escalation 60 → 300 → 900 → capped 900, with the step pinned;
  3. a deferred row leaves the page until its clock passes, then returns;
  4. a state write carries the clock as due now (session ready, quarantine hold) and retired otherwise, and the
    same write is unchanged when the lever is off;
  5. the deferral fence refuses a row whose state moved on;
  6. the assignment page is never filtered, even with a future clock on a pending row;
  7. an already-projected row still replays and is counted, not lost;
  8. flipping the switch off mid-run restores the legacy page on the next tick;
  9. a row that predates the lever is surveyed and stamped before filtering;
  10. the due page's filter/order/cursor shapes and the declared index for both namespaces.

The Firestore query-shape guard re-recorded projection_page with the new due_before parameter and confirms
every serving shape is covered by the checked-in manifest (test_firestore_query_shapes: 572 passed). The
FirestoreStore.projection_page digest pin was re-reviewed for the typed cursor parameter and the new
due_before argument: the adapter gained that parameter and forwards it unchanged, no query/read/bound changed,
and the forwarded shape is still the recorded driver.

Tests

Original qualification, before the CI correction below, with GCP credentials unset (env -u GOOGLE_APPLICATION_CREDENTIALS -u SERVICE_ACCOUNT_JSON), through
bin/omi-heavy run --, base origin/main 72d5dfdc671a, earlier head 21a9ba6357bb1b2021ea46c533353cb52303335b. The fix-batch rerun at
a9c89fac5105 is in the section below.

Suite Result
finish/assignment pages: test_batch_pipeline_sweep_owner_chain, test_batch_pipeline_serving_config, test_batch_pipeline_owner_chain_projection, test_batch_pipeline_owner_drain, test_batch_pipeline_followup_reads, test_batch_pipeline_projection, test_batch_pipeline_quarantine, test_batch_pipeline_quarantine_recovery, test_batch_projection_privacy_hold, test_batch_pipeline_projection_release, test_batch_projection_finish_backoff, test_firestore_query_shapes, test_flag_budget, test_batch_unit_policy, test_reconcile_firestore_indexes 1708 passed
polling sweep + registry/deploy sources: test_batch_pipeline_scheduler, test_batch_pipeline_metrics, test_batch_pipeline_serving, test_batch_pipeline_timeliness, test_batch_timeliness_all_time, test_lifecycle_alarm_metrics, test_config_refactor_w6, test_runtime_env_sources, test_batch_held_contract, test_vad_cache_ttl_config, test_omi_flags 543 passed
parity file on its own: test_batch_projection_finish_backoff 15 passed
backend formatter (scripts/backend-python-format --check) clean
backend Pyright strict boundary (backend/scripts/typecheck.sh) 0 errors (was 5 in the touched files before the typing fixes)
full normal pre-push (git push, runs the pre-push hook: scripts/pr-preflight --lane local, typecheck and the changed-file suite) see the push output in the thread

Product invariants affected

none — read-path only, kill switch OFF by default.

UI evidence

UI-Evidence: none -- backend read-path only

Failure class

Failure-Class: none

This is a dark read-path lever with a kill switch, not a fix for a failing behaviour: the defect it removes
(per-tick replay of already-projected rows) is cost, not correctness, and the default-OFF path is byte-identical.

Rollback: one env flip (BATCH_PROJECTION_FINISH_BACKOFF_ENABLED=false). No backfill, no data change, no index
removal; the next tick is the current page.

CI correction (2026-11-11)

Earlier head: 600b44baeb044221d555a96686d82f1421a363b4 (parent 21a9ba6357bb1b2021ea46c533353cb52303335b).

  • Reconcile the reviewed ProjectionSession.persist lifecycle inventory with the actual summary-state payload introduced alongside the finish clock. Keep the lifecycle guard unchanged.
  • Match FirestoreStore.projection_page in PostgresStore, SimStore and PgSimStore: the typed cursor, due_before, states/defaults, due-clock ordering, inclusive seed cursors, stable continuation cursors and 200-row bound. PgSim forwards the whole contract. No protocol exclusion.
  • Regression coverage checks the evaluated signatures, PgSim forwarding and real local Sim/Postgres projection paging, including a removed cursor source, missing/future clocks, pending assignment, ties and page bounds.

Fresh local validation used the worktree's own Python 3.11 environment, stripped inherited GCP/GOOGLE/GCLOUD/CLOUDSDK/FIREBASE credentials, private HOME/config/cache/temp and disabled metadata discovery, through bin/omi-heavy run --. All source changes are confined to these two fixes and their tests.

Check Result
Exact lifecycle node + exact store node for all three backends 4 passed
Full lifecycle inventory, store protocol parity, Postgres locking and finish parity 1,859 passed (including 73 protocol cases and 12 finish-backoff cases)
Finish/assignment pages (query battery listed separately) 1,133 passed
Polling sweep and registry/deploy-source contracts 543 passed
Full seven-file query/index battery, including slow checks 855 passed, including all 572 query-shape cases
Projection-page conformance on Sim and real local Postgres 28 passed; 206 unrelated/backend cases deselected
Pinned formatter 6 files unchanged
backend/scripts/typecheck.sh 0 errors
Normal full pre-push Passed on the correction head: 43 shared checks; zero typecheck errors; 855 query/index cases plus 124 selected unit cases; integration-only cases deselected and qualified separately above
Single push and its mandatory pre-push hook Passed; one normal push, mandatory hook green (43 shared checks, zero typecheck errors, 855 query/index cases plus 124 selected unit cases)

The requested original /Volumes/Ephemeral/... checkout was absent on this host. The same branch was recreated from the exact published head under /Volumes/scratch/worktrees/omi/omi-lane-jobstate-cut-upstream-keep-clean; no rebase or merge was performed. Local checks establish static/synthetic behavior; remote CI and deployed behavior remain separate. Stop after this correction for delta-only review; no merge or deploy.

Fix batch (2026-11-12)

Earlier head: a9c89fac5105321db955e6f0f600c2a972ae2fb4 (parent 600b44baeb044221d555a96686d82f1421a363b4).
One push, no merge, no deploy. Non-test diff: 97 lines (under the 150-line cap).

Finding-by-finding resolution from the three pre-reviews:

Finding Resolution
P0 blocked/error survey row is never stamped and becomes invisible to the filtered page _sweep_finish now calls settled from a finally for every walked row, including ProjectionBlocked/BatchPrivacyBlocked and generic errors. A failed row read passes state=None; defer_finish then stamps only a row still in persisted/ready, so a completed or pending row is untouched. A deferral failure is logged as outcome=defer_error and does not break the sweep. The ResultLog double now excludes a missing clock from a range filter, matching Firestore. New test: test_a_blocked_survey_row_is_stamped_so_the_filtered_page_can_see_it.
P1 ghost-hold repair moves a row to ready without the clock reconcile_batch_projection_ghost_holds.py now writes projection_finish_state_fields('ready', time.time()) in the same CAS update. New test: test_apply_stamps_the_finish_clock_when_the_lever_is_on.
P1 kill switch resolves ON in serve mode BATCH_PROJECTION_FINISH_BACKOFF_ENABLED added to the default_on exclusion set. New test: test_default_off_switches_stay_off_in_serve_mode covers every default-off switch under CAPTURE_COVERAGE_MODE=serve.
P1 surveyed never resets, so OFF→ON strands rows written while off FinishBackoff.page clears surveyed on every lever-off tick, so the next enable surveys again. New test: test_reenable_after_rollback_surveys_rows_written_while_off.
P1 guards cannot detect the delay Added omi_batch_projection_finish_reads_total and omi_batch_projection_finish_completed_total, incremented in _sweep_finish, and a OmiBatchProjectionFinishReadsPerCompletion PrometheusRule (ratio > 1200 for 15m; baseline ~579). The oldest-age/over-SLA guards are documented as saturated and unable to see a sub-900 s delay in batch-pipeline-serving.md and the rule annotation.
P2 session.py writes pending without clearing the clock The privacy-replay pending write now includes projection_finish_state_fields('pending', now), which deletes both fields when the lever is on.
P2 "clears both fields" transaction assertion checks presence The test now drives a real acknowledge completion and asserts both fields are firestore.DELETE_FIELD in the transaction patch.
P2 digest review note says "annotation only" Corrected to state that the adapter gained due_before and forwards it unchanged.
P2 no due_before coverage in the discovery test New test_due_before_mode_resets_the_cursor_and_seeds_on_the_clock exercises the real ProjectionDiscovery mode switch, clock seed and legacy-cursor reset.
P2 parity test only compares the first tick; double treats a missing clock as due The parity test now runs two ticks and compares the filtered second tick; the double excludes a missing clock.

Fresh local validation at a9c89fac5105, GCP credentials unset, through bin/omi-heavy run --:

Check Result
Finish/assignment pages (15 files, including the query battery) 1,708 passed
Polling sweep + registry/deploy sources (11 files) 543 passed
Full query-shape battery (test_firestore_query_shapes + test_firestore_outside_query_contract) 603 passed
Parity/lifecycle/store nodes (test_batch_projection_finish_backoff, test_batch_pipeline_owner_chain_projection, test_batch_pipeline_sweep_owner_chain, test_batch_pipeline_quarantine, test_jobstore_protocol_parity, test_lifecycle_state_table_writers) 1,936 passed
Pinned formatter clean
backend/scripts/typecheck.sh 0 errors
Normal full pre-push passed (shared checks, formatter, changed-file suite)

Merge-main (2026-11-12)

Earlier head: aaa3cc23a96ef9144d2cde54445aeec0b42a3401 (merge of origin/main 245f8174b1793ecfc1c121d1c66f7375df9b3909 into a9c89fac5105321db955e6f0f600c2a972ae2fb4).
Branch: lane/jobstate-cut.

Merge-main resolution under lead2 1c606e: one content conflict in backend/testing/pipeline_sim/postgres_store.py, where both sides added imports. Both are kept — this PR's PROJECTION_DISCOVERY_STATES and main's sql helper — and the rest of the file auto-merged. No change to the reviewed behavior: the patch against origin/main is unchanged at 33 files, +1114 / -70, and no .github/ workflow, UI, credential/IAM, prod data/config or model-name change is included.

Fresh local validation at aaa3cc23a96ef, GCP credentials unset, through bin/omi-heavy run --:

Check Result
Finish/assignment pages (15 files, including the query battery) 1,708 passed
Polling sweep + registry/deploy sources (11 files) 543 passed
Full query-shape battery (test_firestore_query_shapes + test_firestore_outside_query_contract) 603 passed
Parity/lifecycle/store nodes (test_batch_projection_finish_backoff, test_batch_pipeline_owner_chain_projection, test_batch_pipeline_sweep_owner_chain, test_batch_pipeline_quarantine, test_jobstore_protocol_parity, test_lifecycle_state_table_writers) 1,952 passed
backend/scripts/typecheck.sh 0 errors
Normal full pre-push passed (shared checks, formatter, changed-file suite)

Stop after this merge-main for delta-only review; no merge, no deploy.

Fix 3 (2026-11-12)

Earlier head: 948505243f61eb4598893aac807a826d43d51fc0 (parent aaa3cc23a96ef9144d2cde54445aeec0b42a3401).
Branch: lane/jobstate-cut. One push, no merge, no deploy. Non-test diff: 27 added / 3 removed lines.

Delta finding from Luna a25211 (1111-29a26e-review.md): projection_finish_backoff.py:34 marked the survey
complete on a short page before those rows were processed. If stamping a legacy row failed, _sweep_finish logged
the deferral error and continued; the row then carried no projection_finish_due_at, and Firestore omits rows
where a ranged field is missing, so that obligation could vanish from finish discovery until restart.

Resolution: the survey no longer closes inside page(). A short survey page only records that the legacy walk
ended (survey_short); the sweep closes the survey from survey_done() after the page's rows are processed, and
settled() marks stamp_failed when defer_finish raises before re-raising to the existing defer_error log.
A failed stamp therefore leaves the survey open, the next tick stays on the unfiltered legacy page, and the row is
re-discovered. The lever-off path clears both flags exactly as it already cleared surveyed.

New test: test_a_stamp_failure_keeps_the_survey_open_for_the_next_tick — one row's stamp raises, the survey
stays open, that row carries no clock, and the next tick's unfiltered page walks and stamps it.

Fresh local validation at 948505243f61, GCP credentials unset, through bin/omi-heavy run --:

Check Result
Finish/assignment pages (15 files, including the query battery) 1,709 passed
Polling sweep + registry/deploy sources (11 files) 543 passed
Full query-shape battery (test_firestore_query_shapes + test_firestore_outside_query_contract) 603 passed
Parity/lifecycle/store nodes (test_batch_projection_finish_backoff, test_batch_pipeline_owner_chain_projection, test_batch_pipeline_sweep_owner_chain, test_batch_pipeline_quarantine, test_jobstore_protocol_parity, test_lifecycle_state_table_writers) 1,953 passed
backend/scripts/typecheck.sh 0 errors

Normal full pre-push (the pre-push hook run against the same head, GCP credentials unset): 46 shared checks
passed, backend typecheck 0 errors, pinned formatter clean, and the selected changed-file unit suite green
(17 + 21 + 73 + 15 + 39 + 37 + 190 passed). CI remains the full test authority.

Stop after this fix for delta-only review; no merge, no deploy.

Fix 4 (2026-11-12)

Head: fe48e389dcbb828d7560b512cc19f8e40bca3e43 (parent 948505243f61eb4598893aac807a826d43d51fc0).
Branch: lane/jobstate-cut. One push, no merge, no deploy. Non-test diff: 20 added / 9 removed lines.

Delta finding from Luna 0e012d (1111-f7eb48-review.md): projection_finish_backoff.py:46-51 read the stamp
failure only for the page that reported it and cleared it after every page. A failure on a full survey page
had already advanced discovery past that row, so a later short page closed the survey and the clock-filtered page
then could not see the still-unstamped row (Firestore omits a row whose ranged field is missing) until restart.

Resolution: the failure is now tracked per row (unstamped) for the whole survey instead of a per-page flag, and
a short page that ends the walk with an unstamped row does not close the survey: it restarts the unfiltered walk
from the front (finish_discovery.after = None, seeded = False) so the row is rediscovered and stamped. A row
that is re-stamped, or that moves on before its stamp, leaves the set. The lever-off path clears the set exactly
as it already cleared surveyed.

New test: test_a_stamp_failure_on_a_full_page_restarts_the_whole_survey — pagination on, three rows, page size
two, one row's stamp raises on the first page. The short page that follows is asserted not to close the
survey, and the next tick is asserted to walk that row again and stamp it. The test fails on 948505243f61 and
passes here.

Fresh local validation at fe48e389dcb, GCP credentials unset, through bin/omi-heavy run --:

Check Result
Finish/assignment pages (15 files, including the query battery) 1,710 passed
Polling sweep + registry/deploy sources (11 files) 543 passed
Parity/lifecycle/store nodes (test_batch_projection_finish_backoff, test_batch_pipeline_owner_chain_projection, test_batch_pipeline_sweep_owner_chain, test_batch_pipeline_quarantine, test_jobstore_protocol_parity, test_lifecycle_state_table_writers) 1,954 passed
Survey/backoff file alone (test_batch_projection_finish_backoff) 16 passed
backend/scripts/typecheck.sh 0 errors
Pinned formatter (scripts/backend-python-format --check) clean, 27 files unchanged
Normal full pre-push passed on the pushed head: 66 hook steps (46 manifest checks), typecheck 0 errors, formatter clean, selected changed-file unit suite green (21 + 73 + 16 + 39 + 37 + 190 passed)

CI remains the full test authority. Stop after this fix for delta-only review; no merge, no deploy.

View guided diff Turn on auto-fix

Git-on-my-level and others added 6 commits November 11, 2026 22:48
The projection finish page re-reads and re-fences every persisted/ready
result on every serving tick whether or not anything changed. That replay is
287.0M reads/day across the projection callers (579 reads per completed
projection, about 89x what a first projection needs).

Add a durable per-row next-attempt clock (`projection_finish_due_at`, plus an
escalation step), written only when `BATCH_PROJECTION_FINISH_BACKOFF_ENABLED`
is on. A walk that changed nothing defers the row 60 s, then 300 s, then 900 s
(capped); the page asks for states in (persisted, ready) and a clock that has
passed. The pending assignment page is untouched, so new work is never
delayed, and every projection_state write stamps the clock as due now in the
same transaction, so no obligation waits on a stale one.

The range filter must lead the ordering, so that page gets its own composite
index (projection_state, projection_finish_due_at, committed_at, __name__)
and a (due_at, committed_at, key) cursor. Rows written before the lever carry
no clock, so the first pass after enablement is the unfiltered legacy page,
which stamps them.

OFF is the current query shape with no field writes. Rollback is one env flip,
no backfill, and no projection output, job store or Postgres route changes.

Also satisfies the strict Pyright boundary for the touched files (the cursor
parameter is typed, the summary state is normalized for the field helper, and
the new store/cursor locals carry annotations) and re-reviews the digest pin
for `FirestoreStore.projection_page`: the adapter body changed only in that
annotation, and the forwarded shape is still the recorded driver.
Stamp the finish clock on the blocked/error survey path, reset the survey
on OFF->ON, keep the lever default-off in serve mode, stamp the ghost-hold
repair, clear the clock on the privacy-replay pending write, and add a
finish reads-per-completion guard. Tighten the test doubles to Firestore
semantics and cover the filtered parity path.
The survey flipped `surveyed` as soon as the legacy page came back short,
before those rows were stamped. A failed `defer_finish` was logged as a
deferral error and the loop moved on; the row then carried no clock, and the
filtered page cannot see a missing field, so that obligation vanished from
finish discovery until restart.

The survey now records that the short page was reached and closes only from
`survey_done()` at the end of the sweep, which is skipped when any stamp raised.
The next tick stays on the unfiltered legacy page and re-discovers the row.
A full survey page advances discovery past the row whose stamp failed, so
clearing the failure after that page let a later short page close the survey
behind an unstamped row; the clock-filtered page cannot see a row without a
clock, so that obligation vanished until restart.

The failure is now tracked per row for the whole survey, and a short page
that ends the walk with an unstamped row restarts the unfiltered walk from
the front so the row is discovered again.
@Git-on-my-level
Git-on-my-level merged commit 7688c61 into main Nov 11, 2026
76 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/jobstate-cut branch November 11, 2026 19:45
Git-on-my-level added a commit that referenced this pull request Nov 21, 2026
…scrape (#25145)

## What

Export the two projection finish guard counters on the
backend-integration GMP scrape and the in-cluster Prometheus bridge.

`OmiBatchProjectionFinishReadsPerCompletion` is the only movable guard
on the projection finish-backoff lever
(`BATCH_PROJECTION_FINISH_BACKOFF_ENABLED`, #25122): threshold 1200,
baseline ~579 reads per completion. Its ratio needs both
`omi_batch_projection_finish_reads_total` and
`omi_batch_projection_finish_completed_total`. The projection sweep runs
on backend-sync and backend-integration. The existing Cloud Run GMP keep
rule already admits both counters. The missing sync exporter prefixes
prevented the in-cluster Prometheus bridge from importing them.

- `backend/deploy/cloud_run_gmp_sync.yaml`: document that the existing
`__name__` keep regex covers both counters.
-
`backend/charts/monitoring/prometheus-stackdriver-exporter/{prod,dev}_sync_omi_cloud_run_metrics_exporter.yaml`:
import both families. The checked-in guard is a `PrometheusRule`; the
in-cluster Prometheus imports backend-integration through this bridge.
Production has no live alert route for this guard, so qualification must
prove the ratio is computable rather than claim active alerting.
-
`backend/tests/unit/test_projection_finish_guard_metrics_are_scraped.py`:
derives the names from the producer registrations and pins them against
both filters, the alert expression, the metric inventory, and the test
selector.
- `backend/charts/monitoring/batch-projection/README.md`: documents the
export requirement.

Scrape/config only: no flag flips, no deploy, no runtime change.
`BATCH_PROJECTION_FINISH_BACKOFF_ENABLED` is untouched.

## Verification

- `backend/.venv/bin/python -m pytest
tests/unit/test_projection_finish_guard_metrics_are_scraped.py
tests/unit/test_monitoring_telemetry_contract.py
tests/unit/test_timeliness_metrics_are_scraped.py
tests/unit/test_monitoring_alert_backtest.py
tests/unit/test_monitoring_alert_rule_contract.py
tests/unit/test_attach_cloud_run_gmp_sidecar.py` — all pass locally.
- Deploy-lane readback (cl2-deploy, not this PR) must show both counters
present in the backend-integration scrape with non-null values and the
alert baseline computable.

## Main integration validation

Current head: `2a952b746a9b04f1b445b578523cf7f8e2141688`, integrated
with main at `d9be505b41a79ca7d7e2d3ab0d4558f0f5bd4278`.

- The merge kept main's HPA contract test refactor from
`2c0451b5b5146ca4adf4d8b7cf30388dbe41c4c5` for the sole conflict. The
other eight files preserve the reviewed additions and deletions.
- All 124 targeted tests and the bounded repository pre-push gate passed
on M1. The shallow checkout deferred the 90-day failure-class history
check.
- Guarded admission requires Luna's carry-forward check and passing
required CI at this head. The rollout lead conditionally authorized the
three monitoring Helm upgrades. Release owns the three rollback
revisions, live diffs at merged main, and dispatch window clear of
production Prometheus guards. SCA-1799 remains open pending serving and
counter readback.

### Prior integration receipts

Earlier integration commit: `6fab6d70c8e050e02d8b232508f2254fbfbc7408`,
integrated with main at `ce9e045e2f2fc5c99944aa1ab98d20ed249a252e`.

- **R28 release handoff.** The overnight manager's decision on SCA-1799
(comment `01a1fa1e-1489-76e9-9073-03da580d956d`, delegation
`event:ev-838b55485a1d03458a8c`) closed the two review rounds and
directed the refreshed head to Release. Luna's SHIP at
`6d1d73d68fdda8a3f6a5e4e475a72f27f53d27be` is the review of record.
SCA-3420 tracks the remaining test-maintenance findings.
- **Verification at the refreshed head.** The repository pre-push gate
and 124 targeted tests passed (8 projection finish, 59 HPA, 57
telemetry). Required GitHub CI passed, including the [backend unit
suite](https://github.com/BasedHardware/omi/actions/runs/44790145809/job/136483452651)
and [Mobile Release
Eligibility](https://github.com/BasedHardware/omi/actions/runs/44790145076/job/136475913213).
Release reported [no connector
findings](#25145 (comment))
and a clear release hold reader for SCA-3425.
- **Prior release gates.** Release owns guarded merge admission. The R28
production handoff covers the sync exporter. Production rollout remains
gated on confirmation of the monitoring workflow's scope or a reviewed
sync-only route. SCA-1799 remains open pending production serving and
counter readback.

Earlier integration commit: `6655885a68d94237420beb1af8e34c78e0584820`,
based on clean main integration
`58994ac2d5aa880272a8d1669b7b983cc93fbdd5`. It retains the merged #25473
Stripe initialization repair and the finish-counter contract / exact AST
selection.

Owner disposition `01a1e538-98fb-7846-a271-76f374358b8b` authorizes the
isolated HPA test correction: each owned source now has an independent
selection assertion; a module-scoped fixture supplies the complete real
discovered inventory. No production selector/runner, marker, guard,
allowlist, assertion or Helm contract was changed.

- **M1 equivalence proof passed:** baseline enumeration and owned
assignments are AST-identical; the same ordered, multiplicity-preserving
21 owned paths come from the full 27-source enumeration. Actual
parameter collection matches. The module-scoped fixture invokes real
discovery once and returns its exact full object, equal to independent
discovery: 2,923 paths. Other contract functions and the selection
assertion are AST-identical.
- **M1 validation at `c710ead1d1924917d4870cc71068753eed56364c`: exit 0;
470 passed across nine files, zero failures/skips or CPU-guard
warnings/failures.** Python 3.11.15, Helm v4.2.3; full HPA file 59
passed, including all 21 independent selector cases and every Helm
render. The prior eight-file affected set also passes with file
isolation and unchanged 1.00s CPU limit.
- Command:
`BACKEND_UNIT_TEST_FILE_LIST="$PWD/selected-tests-c710ead1.txt"
omi-workspace/bin/omi-heavy run --timeout 600 -- bash
omi/backend/test.sh`.
- [Full guarded worker
log](https://multica-01.tail76ea03.ts.net/api/attachments/01a1e53c-185e-7b51-830e-98173b672138/download)
and [source/inventory
proof](https://multica-01.tail76ea03.ts.net/api/attachments/01a1e53c-1856-729a-b5b2-bc2329750edb/download),
issue receipt `01a1e53c-1867-7d41-b9d6-768178a495be`.
- Diff hygiene and lightweight AST equivalence checks passed on control;
no backend suites/builds/type checkers ran there.
- Completed [backend CI at
`c710ead1`](https://github.com/BasedHardware/omi/actions/runs/43909722101):
shard 2/8 passes; shard 5/8 and aggregate fail on unrelated
`tests/unit/test_mcp_conversation_detail_paging.py::test_walk_1200_segments_once_with_one_existing_read_per_page`
(1.12s CPU > unchanged 1.00s limit). Stopped at this different blocker;
no paging-test repair or blind rerun.
- Repo Checks also rejected formatting in the HPA helper. `6655885a`
applies the repository's pinned formatter only (complete Python AST
identical to worker-tested `c710ead1`); formatter check and diff hygiene
pass. No worker rerun is claimed for this formatting-only head. Its
[backend CI
run](https://github.com/BasedHardware/omi/actions/runs/43912099995) was
pending when that receipt was recorded.
- **Prior release disposition.** At that head, the owner/22:00Z
qualification hold was still in place. Exact-head CI, Release
qualification and the original cl2-deploy production scrape readback
were still required.
- That validation round stopped before merge and deploy. Its
test-correction inverse was to revert the isolated HPA change. $0
booked.

## Rollback

Revert the PR. Allowlist-only change; no runtime behavior.

Failure-Class: FC-metric-dropped-by-scrape-allowlist

Tracks SCA-1799. Closure requires production readback.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/25145?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>
<!-- End of auto-generated description by cubic. -->
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