Skip to content

feat(review): wire the Discord anomaly-alerter into the ops cron tick - #8946

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-8905
Jul 26, 2026
Merged

feat(review): wire the Discord anomaly-alerter into the ops cron tick#8946
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
bitfathers94:fix/issue-8905

Conversation

@bitfathers94

Copy link
Copy Markdown
Contributor

feat(review): wire the Discord anomaly-alerter into the ops cron tick

runAnomalyAlerts (src/review/alerts.ts) was fully built and unit-tested but
imported nowhere -- no cron handler referenced it, so the Discord anomaly
channel sat dead while ops-wire's structured-log + PagerDuty path fired on
every ops-alerts tick.

Add src/review/alerts-wire.ts: a thin host adapter that builds the operator
agent-config from env (GITHUB_APP_SLUG-or-loopover slug, the DISCORD_WEBHOOK_URL
secret ref) and injects the native ops-port health/calibration snapshots the
operator dashboard already reads, then calls runAnomalyAlerts. Invoke it from
the same isOpsEnabled branch of the ops-alerts job that calls runOpsAlerts, so
the Discord channel fires alongside PagerDuty on the real cron tick.

The adapter fails safe (swallows a top-level error to a structured log),
mirroring runOpsAlerts' 'never throws into the queue' contract: alerts.ts
writes throttle-claim rows, so a storage error is possible, and an alerting
side-channel must never break the cron. It self-gates on a configured
DISCORD_WEBHOOK_URL, so an operator who has not wired a channel pays nothing.

Closes #8905

Validation

Verified locally on this branch before opening:

  • npm run typecheck
  • npx turbo run build:tsc build:verify
  • npm run test:coverage — patch coverage 100.0% of changed lines

runAnomalyAlerts (src/review/alerts.ts) was fully built and unit-tested but
imported nowhere -- no cron handler referenced it, so the Discord anomaly
channel sat dead while ops-wire's structured-log + PagerDuty path fired on
every ops-alerts tick.

Add src/review/alerts-wire.ts: a thin host adapter that builds the operator
agent-config from env (GITHUB_APP_SLUG-or-loopover slug, the DISCORD_WEBHOOK_URL
secret ref) and injects the native ops-port health/calibration snapshots the
operator dashboard already reads, then calls runAnomalyAlerts. Invoke it from
the same isOpsEnabled branch of the ops-alerts job that calls runOpsAlerts, so
the Discord channel fires alongside PagerDuty on the real cron tick.

The adapter fails safe (swallows a top-level error to a structured log),
mirroring runOpsAlerts' 'never throws into the queue' contract: alerts.ts
writes throttle-claim rows, so a storage error is possible, and an alerting
side-channel must never break the cron. It self-gates on a configured
DISCORD_WEBHOOK_URL, so an operator who has not wired a channel pays nothing.

Closes JSONbored#8905
@bitfathers94
bitfathers94 requested a review from JSONbored as a code owner July 26, 2026 13:59
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.62%. Comparing base (ad5f3bf) to head (09c460f).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8946      +/-   ##
==========================================
+ Coverage   90.56%   90.62%   +0.06%     
==========================================
  Files          96       98       +2     
  Lines       22490    22666     +176     
  Branches     3884     3933      +49     
==========================================
+ Hits        20367    20542     +175     
  Misses       1945     1945              
- Partials      178      179       +1     
Flag Coverage Δ
backend 99.43% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/queue/job-dispatch.ts 99.40% <100.00%> (ø)
src/review/alerts-wire.ts 100.00% <100.00%> (ø)

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 26, 2026
@loopover-orb

loopover-orb Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-26 14:17:10 UTC

4 files · 1 AI reviewer · no blockers · readiness 93/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds a thin adapter (alerts-wire.ts) that builds an AlertAgentConfig from env, injects health/calibration deps via the existing ops.ts computers, and calls the already-built-but-unwired runAnomalyAlerts from the ops-alerts cron branch alongside runOpsAlerts. The wiring is straightforward and correctly gated behind isOpsEnabled, fails safe with a try/catch that logs and swallows errors (matching the stated contract), and is well covered by two new test files exercising slug fallback, dep delegation, and error handling. The 'discordNotify: true' with actual gating deferred to the webhook secret inside runAnomalyAlerts is a slightly indirect but documented and tested pattern.

Nits — 5 non-blocking
  • src/review/alerts-wire.ts:38 uses console.error directly rather than any shared structured-logger the rest of the codebase might use — verify this matches the convention used by runOpsAlerts' own error path.
  • The truncation to 200 chars in `String(error).slice(0, 200)` (src/review/alerts-wire.ts:38) is a magic number with no named constant, though it's a minor stylistic point.
  • The adapter always sets `features: { discordNotify: true }` and relies entirely on runAnomalyAlerts' internal webhook check to gate — a comment clarifies this, but it's a slightly fragile contract if that internal gate ever changes; consider asserting this via an integration test that omits DISCORD_WEBHOOK_URL entirely.
  • Consider adding a test (or confirming an existing one in alerts.ts's own suite) that verifies the wired adapter truly no-ops end-to-end when DISCORD_WEBHOOK_URL is unset, not just that runAnomalyAlerts is called.
  • If a shared structured-log helper exists elsewhere (e.g., for orb_installed_repos_sync_failed), consider reusing it here for consistency instead of raw console.error+JSON.stringify.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #8905
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 41 registered-repo PR(s), 32 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor bitfathers94; Gittensor profile; 41 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR wires runAnomalyAlerts into the same isOpsEnabled branch of the ops-alerts cron job that calls runOpsAlerts via a fail-safe adapter, and adds a dedicated test (ops-alerts-cron-wire.test.ts) confirming both runOpsAlerts and runAnomalyAlerts fire on the same tick.

Review context
  • Author: bitfathers94
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: TypeScript
  • Official Gittensor activity: 41 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Start here: Triage stale or unlinked PRs.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask &lt;question&gt; answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat &lt;question&gt; answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LoopOver approves — the gate is satisfied and CI is green.

@loopover-orb
loopover-orb Bot merged commit dc9fb98 into JSONbored:main Jul 26, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(review): wire the fully-built Discord anomaly-alerting module into the real cron path

1 participant