Summary
The ops-anomaly scanner's own SQL query is broken — 396 events, escalating (first seen 3 days ago, still firing this hour). This is the same src/review/ops-wire.ts pipeline referenced when discussing extending anomaly detection for other correctness bugs, so it's worth fixing before relying on it further.
Evidence (Sentry)
GITTENSORY-1H — ops_anomaly_repo_error: Failed query: select json_extract("metadata_json", '$.pullNumber'), count(*) from "ai_usage_events" where ("ai_usage_events"."feature" = ? and "ai_usage_events"."created_at" >= ? and json_extract("ai_... (truncated in Sentry's title). First seen 2026-07-08, last seen 2026-07-11 (1 hour ago), substatus escalating. One captured event tags repo: vouchdev/vouch — not one of the three gated repos (gittensory/metagraphed/awesome-claude) — worth confirming whether that's a real registered repo, stale/test data, or a symptom of the same query bug producing a garbage repo label.
Root cause (Sentry Seer — plausible, verify the specific query)
Seer's summary: "Replace json_extract-based ai_usage_events query with an audit_events LIKE query, matching the working findHottestReviewTargetForRepo pattern." Find findHottestReviewTargetForRepo (or its sibling findHottestInconclusiveReviewTargetForRepo, both imported into src/review/ops-wire.ts) as the known-working reference pattern, and find the broken query (likely a different helper feeding computeOpsStats/runOpsAlerts) to bring in line with it.
Requirements
- Fix the malformed query so the ops-anomaly scan runs cleanly for every repo, every scan tick.
- Investigate the
vouchdev/vouch repo tag — confirm whether it's a real tracked repo or a data artifact, and note the finding either way.
- Since this pipeline emits
gittensory_ops_anomaly_total (a Prometheus counter with its own alert rule, GittensoryOpsAnomalyDetected) — confirm this SQL failure isn't ALSO silently suppressing real anomaly detections for whichever repos it fails on.
Deliverables
Summary
The ops-anomaly scanner's own SQL query is broken — 396 events, escalating (first seen 3 days ago, still firing this hour). This is the same
src/review/ops-wire.tspipeline referenced when discussing extending anomaly detection for other correctness bugs, so it's worth fixing before relying on it further.Evidence (Sentry)
GITTENSORY-1H —
ops_anomaly_repo_error: Failed query: select json_extract("metadata_json", '$.pullNumber'), count(*) from "ai_usage_events" where ("ai_usage_events"."feature" = ? and "ai_usage_events"."created_at" >= ? and json_extract("ai_...(truncated in Sentry's title). First seen 2026-07-08, last seen 2026-07-11 (1 hour ago), substatusescalating. One captured event tagsrepo: vouchdev/vouch— not one of the three gated repos (gittensory/metagraphed/awesome-claude) — worth confirming whether that's a real registered repo, stale/test data, or a symptom of the same query bug producing a garbage repo label.Root cause (Sentry Seer — plausible, verify the specific query)
Seer's summary: "Replace json_extract-based ai_usage_events query with an audit_events LIKE query, matching the working findHottestReviewTargetForRepo pattern." Find
findHottestReviewTargetForRepo(or its siblingfindHottestInconclusiveReviewTargetForRepo, both imported intosrc/review/ops-wire.ts) as the known-working reference pattern, and find the broken query (likely a different helper feedingcomputeOpsStats/runOpsAlerts) to bring in line with it.Requirements
vouchdev/vouchrepo tag — confirm whether it's a real tracked repo or a data artifact, and note the finding either way.gittensory_ops_anomaly_total(a Prometheus counter with its own alert rule,GittensoryOpsAnomalyDetected) — confirm this SQL failure isn't ALSO silently suppressing real anomaly detections for whichever repos it fails on.Deliverables
vouchdev/vouchfinding.