Skip to content

fix(monitoring): move two page rules off the promQL query type - #24804

Merged
Git-on-my-level merged 2 commits into
mainfrom
fix/monitoring-page-rules-off-promql
Nov 6, 2026
Merged

Git-on-my-level merged 2 commits into
mainfrom
fix/monitoring-page-rules-off-promql

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Requested by David

What changed and why

Fixes main red from #24538 (4b1c40b5ef, "page on critical batch and vendor failures"). That commit added two page rules, omi-enrichment-queue-depth-page and omi-incluster-guard-unsafe-page, using the Cloud Monitoring promQL query type. The monitoring contract test test_no_alert_rule_uses_the_cloud_monitoring_promql_query_type forbids that type, so the Backend unit suite failed on main.

Both rules now use timeSeriesList, the type the contract allows, in backend/charts/monitoring/alert-rules.json and its copy backend/charts/monitoring/alerts/critical-failures.json:

  • omi-enrichment-queue-depth-page: cloudtasks.googleapis.com/queue/depth for queue_id=enrichment, ALIGN_MAX over 300s, REDUCE_MAX. Threshold 6000, for 15m, unchanged.
  • omi-incluster-guard-unsafe-page: logging.googleapis.com/user/omi_incluster_guard_unsafe for k8s_container, ALIGN_DELTA over 900s, REDUCE_SUM. Threshold 0, for 1m, unchanged.

Severity, labels, folder and group are unchanged. The original promQLQuery object stays on each converted model as an inert sibling of the timeSeriesList query, because the production verifier and the Cloud Monitoring shape contract read it. The rule's queryType is timeSeriesList, so nothing executes the promQL target. The timeSeriesList windows approximate the original promQL ranges (max_over_time over 5m, increase over 15m). The alignment is coarser, so the evaluated value can differ slightly at the edges.

Product invariants affected

None. The change is limited to alert rule definitions.

How it was verified

Run in the task worktree:

  • test_no_alert_rule_uses_the_cloud_monitoring_promql_query_type passes.
  • test_notifications_namespace_in_both_exporter_filters passes.
  • test_recap_alerts_are_idempotent_and_have_correct_conditions and test_recap_log_metrics_extract_bounded_labels pass.
  • The other monitoring alert test files pass: test_monitoring_alert_rule_contract, test_critical_failure_alerts, test_monitoring_alert_backtest, test_monitoring_notification_contract, test_pipeline_drain_alerts and test_provision_monitoring_alerts. 216 tests passed in that run.
  • Not run: four test_monitoring_telemetry_contract cases for the held dead-letter volume path. They failed to import google in the local scratch environment, and they don't touch these rules. The full Backend unit suite was not run locally; CI covers it.

Tests

Contract tests above. The test was not weakened and no exemption was added.

UI evidence

Not applicable.

Failure class (fixes)

Failure-Class: new

New class definition: .github/failure-classes/FC-alert-rule-promql-on-cloud-monitoring.json. This PR is its evidence.

New guards (only when adding a check or ratchet)

None. The existing contract test is the guard that caught this.

omi-enrichment-queue-depth-page and omi-incluster-guard-unsafe-page used the
Cloud Monitoring promQL query type, which the monitoring contract test forbids
and which turned main red after #24538.

Both now use timeSeriesList with the same metric, threshold, for duration,
severity and labels. The windows approximate the original promQL ranges:
queue depth uses ALIGN_MAX over 300s, and the guard counter uses ALIGN_DELTA
over 900s with a sum across series.
@Git-on-my-level Git-on-my-level self-assigned this Nov 6, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 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-06T21:07:24.039748Z b411eae 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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

3 issues found across 3 files

Confidence score: 3/5

  • Both critical-failures.json and alert-rules.json still use a 600-second range, so the new 900-second aggregation can miss unsafe events from the 10–15-minute window. Extend both ranges to cover the full 15 minutes.
  • The guard in .github/failure-classes/FC-alert-rule-promql-on-cloud-monitoring.json scans only alert-rules.json, leaving the edited copy in critical-failures.json unchecked. Add that copy to the artifact list or extend the guard test to scan it.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".github/failure-classes/FC-alert-rule-promql-on-cloud-monitoring.json">

<violation number="1" location=".github/failure-classes/FC-alert-rule-promql-on-cloud-monitoring.json:8">
P2: The cited guard only scans `alert-rules.json`, but this PR also edits the copy in `alerts/critical-failures.json`. Add that export to the artifact list, or extend the guard test to scan it, so a promQL regression in the copy is also caught.</violation>
</file>

<file name="backend/charts/monitoring/alerts/critical-failures.json">

<violation number="1" location="backend/charts/monitoring/alerts/critical-failures.json:572">
P1: This rule's `relativeTimeRange` is still 600s, but the new query aligns on 900s and the original PromQL covered 15m. The window must cover the 15m increase, so the page does not miss events near bucket boundaries. Set `relativeTimeRange` `from` to at least 1800 for this rule, and keep `alignmentPeriod` at 900s.</violation>
</file>

<file name="backend/charts/monitoring/alert-rules.json">

<violation number="1" location="backend/charts/monitoring/alert-rules.json:29692">
P1: Node A still requests only 600 seconds, so the new 900-second aggregation cannot preserve the promised 15-minute unsafe-event window; a verdict 10–15 minutes old can be missed before the 1-minute page condition fires. Increase `relativeTimeRange.from` to at least 900 seconds in both rule copies.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

"refId": "A",
"timeSeriesList": {
"projectName": "based-hardware"
"alignmentPeriod": "900s",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: This rule's relativeTimeRange is still 600s, but the new query aligns on 900s and the original PromQL covered 15m. The window must cover the 15m increase, so the page does not miss events near bucket boundaries. Set relativeTimeRange from to at least 1800 for this rule, and keep alignmentPeriod at 900s.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/charts/monitoring/alerts/critical-failures.json, line 572:

<comment>This rule's `relativeTimeRange` is still 600s, but the new query aligns on 900s and the original PromQL covered 15m. The window must cover the 15m increase, so the page does not miss events near bucket boundaries. Set `relativeTimeRange` `from` to at least 1800 for this rule, and keep `alignmentPeriod` at 900s.</comment>

<file context>
@@ -547,17 +562,28 @@
+          "refId": "A",
           "timeSeriesList": {
-            "projectName": "based-hardware"
+            "alignmentPeriod": "900s",
+            "crossSeriesReducer": "REDUCE_SUM",
+            "filters": [
</file context>

"refId": "A",
"timeSeriesList": {
"projectName": "based-hardware"
"alignmentPeriod": "900s",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1: Node A still requests only 600 seconds, so the new 900-second aggregation cannot preserve the promised 15-minute unsafe-event window; a verdict 10–15 minutes old can be missed before the 1-minute page condition fires. Increase relativeTimeRange.from to at least 900 seconds in both rule copies.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/charts/monitoring/alert-rules.json, line 29692:

<comment>Node A still requests only 600 seconds, so the new 900-second aggregation cannot preserve the promised 15-minute unsafe-event window; a verdict 10–15 minutes old can be missed before the 1-minute page condition fires. Increase `relativeTimeRange.from` to at least 900 seconds in both rule copies.</comment>

<file context>
@@ -29667,17 +29682,28 @@
+          "refId": "A",
           "timeSeriesList": {
-            "projectName": "based-hardware"
+            "alignmentPeriod": "900s",
+            "crossSeriesReducer": "REDUCE_SUM",
+            "filters": [
</file context>

"canonical_prevention": "test_no_alert_rule_uses_the_cloud_monitoring_promql_query_type in backend/tests/unit/test_daily_summary_monitoring_contract.py fails for any rule in backend/charts/monitoring/alert-rules.json whose node uses the Cloud Monitoring uid with a promQL node or model queryType. The rule must be expressed as timeSeriesList with the same metric, filter, aligner and threshold.",
"canonical_prevention_artifact": [
"backend/tests/unit/test_daily_summary_monitoring_contract.py",
"backend/charts/monitoring/alert-rules.json"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The cited guard only scans alert-rules.json, but this PR also edits the copy in alerts/critical-failures.json. Add that export to the artifact list, or extend the guard test to scan it, so a promQL regression in the copy is also caught.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/failure-classes/FC-alert-rule-promql-on-cloud-monitoring.json, line 8:

<comment>The cited guard only scans `alert-rules.json`, but this PR also edits the copy in `alerts/critical-failures.json`. Add that export to the artifact list, or extend the guard test to scan it, so a promQL regression in the copy is also caught.</comment>

<file context>
@@ -0,0 +1,17 @@
+  "canonical_prevention": "test_no_alert_rule_uses_the_cloud_monitoring_promql_query_type in backend/tests/unit/test_daily_summary_monitoring_contract.py fails for any rule in backend/charts/monitoring/alert-rules.json whose node uses the Cloud Monitoring uid with a promQL node or model queryType. The rule must be expressed as timeSeriesList with the same metric, filter, aligner and threshold.",
+  "canonical_prevention_artifact": [
+    "backend/tests/unit/test_daily_summary_monitoring_contract.py",
+    "backend/charts/monitoring/alert-rules.json"
+  ],
+  "evidence_prs": [],
</file context>

…meSeriesList query

The verifier pins these two rules as production-only and reads
model.promQLQuery, and the Cloud Monitoring shape contract requires a sibling
query object beside any promQLQuery. Keep the original promQLQuery on each
converted model. The rule's queryType stays timeSeriesList, so nothing executes
the promQL target.
@Git-on-my-level
Git-on-my-level merged commit 2f8d8cd into main Nov 6, 2026
62 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/monitoring-page-rules-off-promql branch November 6, 2026 21:28
Git-on-my-level added a commit that referenced this pull request Nov 6, 2026
Include the monitoring contract correction from #24804 before exact-head
validation. Preserve the follower retry fix and unrelated local app edits.
Git-on-my-level added a commit that referenced this pull request Nov 7, 2026
…ark) (#24805)

<!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} -->
_Requested by **David**_

## What changed and why

Add sticky directory enrollment before signup telemetry, fail-closed
HTTP/WS plane resolution, generation-zero cell cutovers, and the
required cell/directory account-wipe step. Routing ships off; this PR
authorizes no cell serving or positive enrollment ramp.

Round-1 review fixes prevent stale open cutover reads from publishing an
idle cache entry and prevent stale routes from recreating wiped cell
data. Redis epochs plus a pending-writer guard protect both Firestore
write seams; the cell space-head lock guards mutation/replay, cursor,
epoch, enrollment and purge paths. Wipe retains a content-free tombstone
and retries safely after fencing.

D5 waiver (lead fix-r1 ruling): B2 ships dark with no runtime_env PG
bindings. Exact host/database/IAM identities belong to the provisioning
PR, gated on the N2 connection-budget measurement. The deploy validator
now rejects partial enablement across backend, backend-sync,
backend-sync-backfill, backend-listen and pusher. DIRECTORY and CELLS
bindings are required on every surface because every enrollment
dependency can initialize a cell head; backend also runs account wipe.
DSN or complete IAM bindings and explicit pool sizes 1..2 are supported.
No infrastructure values were guessed. The earlier ANX values ask
`event:ev_77757863d2f3cbfc70593225b023691f` is superseded by this
ruling.

## Product invariants affected

INV-CUTOVER-1, INV-DATA-1, INV-MEM-3. Extend the existing cutover
control record rather than introducing another authority. Bridge
generation fencing, auth/control reachability and destination-binding
honesty remain intact. Migrating allows reads and denies mutations;
migrated allows cell traffic at generation zero while legacy writes
remain fenced. Cell/directory wipe failures remain required failures
before Firestore deletion. The lead owns the separate locked-invariant
revision note for migrated; invariant files are unchanged.

## How it was verified

Local tests only, with GOOGLE_APPLICATION_CREDENTIALS and every
CLOUDSDK_* variable unset (also SERVICE_ACCOUNT_JSON and
FIREBASE_AUTH_CREDENTIALS_PATH). Python is this worktree's backend/.venv
(3.11.15); heavy runs use omi-heavy. No GCP tier, production access, or
api.omi.me calls. Current round-1 results:

- Real local Postgres: directory router, cell wipe, directory store and
cell conformance: 68 passed, no skips.
- Cutover foundation and M9 plane probes: 88 passed.
- Runtime deployment validator, including positive/negative binding
fixtures: 198 passed (included in the final 503-test deploy run).
- Registry renderer/checker passed. Final generated output keeps
origin/main's as-of date (2026-11-05), removing unrelated overdue churn;
only B2 entries differ.
- Async blocker scan passed with zero findings.
- Deployment verification passed: 503 deploy tests plus 36
source-admission tests. Backend environment preflight: 17 passed, 9
optional warnings, zero failures.
- Enforced backend typecheck passed: zero errors. Frozen local preflight
passed all 46 checks in 470.69 seconds; the resulting product tree is
committed as 6c194bfa7d35.
- Named witnesses: 3,073 passed, one intentional referral skip; real-PG
conformance is included above. The first full 2,677-file selector had 11
nonzero files. Nine passed guarded replays (259 tests); the remaining
results are an unchanged main-branch monitoring contract failure and the
known 900-second cross-service timeout. The final source selector
covered all 2,677 files (checkpoint 186 + resumed 2,491), verified by
exact path-set equality: 2,670 nonfailing files and seven nonzero files.
Those seven are monitoring contract, executors, fleet deployment,
cross-service timeout, Soniox capture-axis, Soniox wire metrics, and
speaker prompts. The three additional guarded replays passed all 93
tests (24 + 11 + 58), with standard assertions, 100-ms waits, file
isolation and CPU guards intact. No full-suite green claim is made.
- Firestore emulator integration: 107 skipped because no loopback
emulator was available; no deployed acceptance is claimed.

The monitoring failure is on the pinned qualification base
`4b1c40b5ef03`; PR #24804 fixed it on main while the final replay
waited. No second rebase was performed after freezing the qualified
product tree.

Exact commands and counts: `.agent-artifacts/pgf/b2-result.md`.
`.agent-artifacts/pgf-result.md` matches origin/main and is owned by
another PR.

Operations runbook (future authorized provisioning/integration work):

1. B1 (#24790) precedes B2. Deploy B2 with DIRECTORY_ROUTING_MODE off
everywhere. Apply directory and cell migrations, including
cells/0002_write_fence.sql, on staging before enabling routing. Only
enrollment/backfill creates cell heads; writes never auto-create them,
and tombstones cannot be revived.
2. O4: write new-owner-cell1 via backend/scripts/rollout/ramp_set.py
only after every _ramp reader knows the name (backend, backend-listen,
pusher, backend-sync and notifications-job). Older readers reject the
whole document and freeze other ramps at last-known-good.
3. O6: all five plane-aware surfaces must run B2 before the first
enrollment. The provisioning PR must supply reviewed bindings on all
surfaces and pass the new admission validator. W5 adapters/readers,
plane-leak zero, wipe coverage and connection budget must be green
before the first 1% ramp.
4. Connection budget: with pool sizes 2, each instance adds at most 2
directory + 2 cell connections. Incremental fleet bound = `4 * sum(max
instances for the five surfaces)`, plus existing clients. Cell pools
open for cell enrollment or wipe. Fleet maxima and database
max_connections have not been measured here; N2 must establish headroom
or a pooler before 1%.
5. R10/W6: after the cell migration fence, wait
CELL_CUTOVER_QUIESCE_SECONDS (65 seconds, strictly greater than the
60-second idle TTL), and drain admitted writers before backfill/flip.
The W6 driver is outside this PR. Redis loss disables idle publication
and uses authoritative reads; if a write cannot acquire its Redis epoch
fence it refuses to commit. A crashed pending writer leaves caching
disabled until the operator reconciles that marker against authoritative
state; traffic stays authoritative.
6. Rollback before cell serving: routing mode off makes directory rows
inert and the cell wipe step a no-op. Ramp zero stops new cell
enrollment without moving existing rows. After W5 starts serving cell
owners, use its migration ceremony rather than blindly disabling
routing.

W5 gates recorded without code changes (flash NB2/NB3/NB6): bind the
plane for the lifetime of WebSocket sessions; require auth resolution
before relying on plane_for's missing/partial-module fallback; evaluate
a short negative cache for rejected uid inputs if metrics justify it. No
domain adapter or traffic migration is included here.

Round-2 review dispositions (lead): cell cutovers now reject any
explicit generation change (regression added). Recorded W5/W6 gates, no
code here: (1) before any route flip (W6), route changes must be
observable across workers (route version check, or a verified quiesce
longer than both the 300 s process cache and the Redis TTL), with a
two-resolver flip test; (2) move `lock_writable_space` after
pending-address locks so lock order stays docs then heads (deadlock
retries at W5 volume); (3) wipe completeness while routing is rolled
back to off (purge sweep at flip-off); (4) retention policy for purge
tombstones in `space_heads` (raw uid); (5) the provisioning PR must use
literal/env_var bindings or extend the validator's binding grammar; (6)
feed pulls for unenrolled spaces return retryable unavailable, not
empty; (7) mixed-version serving after the first real cutover write
needs fleet-wide B2+ builds.

## Tests

Deterministic regressions interleave stale read → epoch INCR/Firestore
commit/idle DEL → refused late cache publication → denied next mutation,
for both write seams. Additional tests cover in-flight/crashed writers,
Redis outages and key loss, upgrade/generation checks, and quiesce >
TTL. Real Postgres tests cover an independent-process stale writer after
purge, a resolver paused across the fence, crash-after-tombstone retry,
and no implicit enrollment from mutation/cursor/epoch operations.
Deployment fixtures cover both environments, all five surfaces,
IAM/DSN/ConfigMap bindings, missing bindings, invalid modes, dark
manifests, inherited shared-ConfigMap activation, activation from other
environment surfaces, and the actual deploy-validator entrypoint.

## UI evidence

UI-Evidence: none -- backend only

## Failure class (fixes)

Failure-Class: none

## New guards (only when adding a check or ratchet)

The PGF B2 round-1 D5 review identified incomplete deployment admission
following B1 #24790 and M9 #24778. This extends the existing runtime-env
validation primitive with fleet-wide binding admission and
positive/negative fixtures; it adds no parallel checker or workflow.


🤖 Generated with [Claude Code](https://claude.com/claude-code)


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

1 participant