Skip to content

fix(monitoring): export projection finish guard counters on the sync scrape - #25145

Merged
Git-on-my-level merged 10 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m5-mbp-opencode-deepseek-v4-1/c1a610f3cd7f
Nov 21, 2026
Merged

Git-on-my-level merged 10 commits into
BasedHardware:mainfrom
Git-on-my-level:agent/m5-mbp-opencode-deepseek-v4-1/c1a610f3cd7f

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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 and Mobile Release Eligibility. Release reported no connector findings 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 and source/inventory proof, 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: 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 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.

View guided diff

…scrape

OmiBatchProjectionFinishReadsPerCompletion is the only movable guard on the
projection finish-backoff lever (threshold 1200, baseline ~579), and 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, but neither name matched the sync GMP
keep rule, so both counters were dropped at ingestion and the guard read no
data.

Keep both names in backend/deploy/cloud_run_gmp_sync.yaml and in the dev/prod
sync Stackdriver exporter prefixes, because the alert is a PrometheusRule
evaluated by the in-cluster Prometheus, which sees backend-integration only
through that bridge. Pin the names against both filters with a unit test that
derives them from the producer registrations, and document the export
requirement in the batch-projection monitoring README.

Scrape/config only: no flag flips, no deploy, no runtime change.

Failure-Class: FC-metric-dropped-by-scrape-allowlist
Co-authored-by: multica-agent <[email protected]>
@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-21T22:00:33.072776Z 2a952b7 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.

Git-on-my-level added a commit that referenced this pull request Nov 14, 2026
…4) (#25225)

SCA-2024: Replace the per-process projection finish survey with a
bounded, resumable stamping pass and shared versioned completion marker.
New replicas use filtered discovery immediately once maintenance
finishes; until then, serving keeps the legacy page without per-row
stamp transactions.

Persisted/ready transitions maintain clock fields regardless of the read
lever, including backend-listen request paths and operator scripts. All
Store backends expose marker readiness; Postgres/simulation require
their own control marker, so Firestore maintenance cannot enable
filtering over an uncertified population. The runbook records the writer
audit, read budgets, deployment order, rollback and re-enable gates.

The bounded integration repair merges approved main `6262a2b82e`
(including SCA-1993 / #25220) and refreshes only the usage-month
full-map snapshot hashes and the pending patch's context. Served runtime
inputs, qualification code, assertions, monthly defaults, epochs, TTLs
and activation authority are unchanged. The pending patch still proposes
exactly six 0->5 lever values on the same three services and is excluded
from ordinary composition. Published commit history is preserved. The
integration conflict in Firestore budget registrations retains both
main's new fresh-delivery entry and this PR's two existing entries
unchanged.

Validation:

- Current connector finding
[discussion_r4568217716](#25225 (comment))
is fixed by moving only the CLI test import and clock-entry helper test
import to their module import blocks. Non-import ASTs are identical;
monkeypatches and all assertions remain unchanged. Each complete
affected file passes in a separate `backend/test.sh` run: **11 + 17
passed**. Existing module-stub and import-time side-effect checks pass
over the full tree (2,998 test files and 2,592 production files, zero
violations).
- Earlier bounded repair consumes the owner's `flag-budget-count.patch`:
`count` 277→278 is the only changed JSON value. Duplicate-rejecting
parsing confirms 278 unique registered names, 161 seeded/replacement
slots and 117 owned exceptions. SCA-2012 added the fresh-guard entry
without updating this summary; all registrations, owners, expiries,
scope, defaults and both Firestore budgets are preserved.
- Reproduced shard 3 locally: **1 failed / 23 passed** before repair.
After repair, the combined registry/scope/runtime/qualifier sweep passes
**571 tests**, including all 24 flag-budget and 107 qualifier tests;
three historical cross-service replay cases retain their existing opt-in
skips. The separate feature-flag registry suite passes **109 tests**.
Test assertions and selectors are unchanged.
- Reproduced the exact shard-1 integration failure: old branch
`777515b3b1` passes 107 qualification tests; integration with approved
main yields 3 failures / 104 passes; the two-artifact repair restores
**107 passes**.
- Earlier integration head: **380 passed** across qualification, Store
parity, owner-drain parity, finish backfill and finish backoff.
- `make preflight`: **44 checks passed**, including Firestore
query/index checks; composed runtime manifest is current.
- Previous repaired head `777515b3b1` cleared CI emulator proofs and
shard 2. Its local emulator evidence was 40 passed with one pre-existing
throughput skip; no isolation, privacy, custody or timeout guard was
relaxed.
- New CI is required. Aggregate unit failure is downstream of its failed
shard, not an additional failure or a waiver.

Two Multica review rounds are already complete. The SCA-2073 owner
ruling permits bounded integration repair through the capped release
route; this new head remains at the current issue step for owner
scope/freshness reconciliation. No third review or author-side reviewer
is requested. Exact-head hosted green CI and existing finding
dispositions remain release gates. Production rolls belong to the
rollout lead. No production/cloud/account reads or writes, activation,
scan/stamp, deployment, installation, credentials change or GitHub merge
performed. Re-enable still requires all writers deployed and stamping
complete, #25145 / SCA-1799 merged/deployed, and nonzero GMP values for
both finish-read and completion counters; matched-window savings and a
zero-missing-clock census remain post-deployment acceptance.

Writer evidence: [request-path and job/script
audit](https://github.com/BasedHardware/omi/blob/agent/m1-studio-codex-sol/be1f6c00b122/backend/docs/runbooks/projection-finish-writer-audit.md).

## Product invariants affected

none

Failure-Class: none

Pipeline-Tuning: no active numeric tuning. Existing retry delays,
serving page sizes and cadence are unchanged. The existing offline
monthly proposal remains two 0->5 values on three services; this repair
only updates its context to approved config literals, without applying
it.


Body-waived: historical local-receipt lines above name earlier heads of
this PR (777515b, 2c13d4c); current head
bc6c99845ff8fcc3d9aacc1ac5e03bc45a65b19 is the origin/main merge-in with
conflict-resolution-only delta per SCA-2175, with hosted CI green at
that head.
multica-agent and others added 9 commits November 14, 2026 11:09
Preserve enrichment and finalization scrape entries and both regression selectors while retaining the projection finish guard counters.

Co-authored-by: multica-agent <[email protected]>
Resolve only the sync GMP keep-regex conflict by retaining main verbatim: its grouped finish-counter expression already exports both guard counters. Preserve the bridge exports and focused regression coverage.

Co-authored-by: multica-agent <[email protected]>
Retain both adjacent finish-guard and SCA-2280 comments. Preserve main scrape semantics and incorporate the merged SCA-2279 cold-import fixes for the two named unit failures. Worker verification remains required.

Co-authored-by: multica-agent <[email protected]>
Integrate merged BasedHardware#25473 via current main without manual conflict resolution or duplicate repair. Preserve exact finish-counter contract and bounded AST test correction.

Co-authored-by: multica-agent <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 3beb9a8 into BasedHardware:main Nov 21, 2026
63 checks passed
Git-on-my-level added a commit that referenced this pull request Nov 23, 2026
…20) (#26117)

## What

Simplify
`backend/tests/unit/test_projection_finish_guard_metrics_are_scraped.py`
(SCA-3420), addressing the two non-blocking findings from the SCA-1799
review of #25145.

The previous version derived the guard counter names by scanning
top-level `PROJECTION_FINISH_*` assignments in the producer AST, and
asserted the literal `'> 1200'` in the alert expression. A non-counter
constant with that prefix, or a deliberate threshold retune, would fail
the test for the wrong reason.

- `GUARD_COUNTERS` pins the two ratio inputs
(`omi_batch_projection_finish_reads_total`,
`omi_batch_projection_finish_completed_total`) once; every scrape,
bridge, inventory and alert assertion derives from it.
- `counter_registrations()` is a narrow registration lookup: it collects
the literal name from every `Counter('name', ...)` call in
`utils/batch_pipeline/metrics.py` regardless of assignment shape, and
`test_producer_registers_each_guard_counter_once` fails on missing,
renamed or duplicated registrations.
- `test_alert_ratio_consumes_both_guard_counters` asserts the alert's
`omi_batch_projection_finish_*` inputs equal `GUARD_COUNTERS` exactly,
and that the expression keeps a numeric `>` bound — no literal
threshold.

Test-only. Alert behavior and the 1200 threshold are unchanged; the
Cloud Run keep/drop rules, dev/prod bridge prefixes, metric inventory
and changed-file selector coverage are preserved.

## Verification

- `backend/.venv/bin/python -m pytest
tests/unit/test_projection_finish_guard_metrics_are_scraped.py` — 8
passed.
- Mutation checks against the real files (each reverted after):
- `reads` dropped from the GMP keep regex → bridge test fails (dev and
prod).
- `reads` prefix removed from the prod bridge yaml → prod bridge test
fails.
  - `completed` omitted from the alert expression → alert test fails.
- `reads` registration renamed in the producer → registration test
fails.
  - A duplicated `completed` registration → registration test fails.
  - Threshold `> 1200` → `> 2200` → suite still passes (decoupled).
- Pre-push bounded gate: full backend unit suite (1965 tests), format
check, and 37 contract checks all pass locally; CI remains the full
authority.


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

2 participants