Repository navigation
test(monitoring): pin finish guard inputs, not producer shape (SCA-3420) - #26117
Merged
Merged
Conversation
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]>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_COUNTERSpins 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 everyCounter('name', ...)call inutils/batch_pipeline/metrics.pyregardless of assignment shape, andtest_producer_registers_each_guard_counter_oncefails on missing, renamed or duplicated registrations.test_alert_ratio_consumes_both_guard_countersasserts the alert'somi_batch_projection_finish_*inputs equalGUARD_COUNTERSexactly, 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.readsdropped from the GMP keep regex → bridge test fails (dev and prod).readsprefix removed from the prod bridge yaml → prod bridge test fails.completedomitted from the alert expression → alert test fails.readsregistration renamed in the producer → registration test fails.completedregistration → registration test fails.> 1200→> 2200→ suite still passes (decoupled).