Skip to content

test(monitoring): pin finish guard inputs, not producer shape (SCA-3420) - #26117

Merged
Git-on-my-level merged 1 commit into
mainfrom
agent/m1-studio-devin-swe-2/5d5d67b04d55
Nov 23, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
agent/m1-studio-devin-swe-2/5d5d67b04d55

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

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.

View guided diff Turn on auto-fix

The scrape contract test scanned top-level PROJECTION_FINISH_*
assignments and asserted the literal '> 1200', so a non-counter constant
with that prefix or a deliberate threshold retune would fail it for the
wrong reason. Replace both with the actual contracts: the two ratio
inputs are pinned once, each must be registered by exactly one
Counter(...) call anywhere in the producer (missing, renamed and
duplicated registrations all fail), and the alert must read exactly
those names while keeping some numeric bound. Scrape, inventory and
selector coverage is unchanged; alert behavior and threshold untouched.

Co-authored-by: multica-agent <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 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-23T10:46:07.933199Z 8373980 PR opened
ℹ️ 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
Git-on-my-level merged commit c150ea8 into main Nov 23, 2026
69 checks passed
@Git-on-my-level
Git-on-my-level deleted the agent/m1-studio-devin-swe-2/5d5d67b04d55 branch November 23, 2026 11:26
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