Skip to content

feat(ams): page PagerDuty on miner kill-switch trips - #7685

Closed
jsdevninja wants to merge 4 commits into
JSONbored:mainfrom
jsdevninja:feat/ams-kill-switch-pagerduty
Closed

feat(ams): page PagerDuty on miner kill-switch trips#7685
jsdevninja wants to merge 4 commits into
JSONbored:mainfrom
jsdevninja:feat/ams-kill-switch-pagerduty

Conversation

@jsdevninja

Copy link
Copy Markdown
Contributor

Summary

  • Add pure buildMinerKillSwitchPagerDutyAlert in the engine kill-switch detector so trip payloads stay IO-free and shared.
  • On ledger trip, miner recordMinerKillSwitchTransition fires PagerDuty Events API v2 (same LOOPOVER_ENABLE_PAGERDUTY / PAGERDUTY_ROUTING_KEY pattern as ORB); resumes stay silent.
  • Hosted notifyMinerKillSwitchPagerDuty reuses triggerPagerDutyIncident (severity floor + cooldown). Runbook Detection section documents the automated page.

Closes #7666

Scope

  • The PR title follows type(scope): short summary Conventional Commit format.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (Closes #7666).

Validation

  • git diff --check
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • Focused validation: engine kill-switch tests, miner-governor-kill-switch, notify-pagerduty, and kill-switch-incident-runbook (all green). Full test:ci left to CI.

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

UI Evidence

N/A — docs runbook text + backend/miner alerting only; no visible UI chrome.

Notes

  • Analogues: src/review/ops-wire.ts paging on ops_anomaly; src/services/notify-pagerduty.ts Events API v2.

Wire kill-switch engage through the existing Events API v2 path so trips are not ledger-only; resumes stay silent.

Co-authored-by: Cursor <cursoragent@cursor.com>
@jsdevninja
jsdevninja requested a review from JSONbored as a code owner July 21, 2026 08:06
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.55%. Comparing base (6ac7109) to head (9743ba9).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7685   +/-   ##
=======================================
  Coverage   88.55%   88.55%           
=======================================
  Files         725      725           
  Lines       76188    76222   +34     
  Branches    22680    22693   +13     
=======================================
+ Hits        67466    67500   +34     
  Misses       7680     7680           
  Partials     1042     1042           
Flag Coverage Δ
shard-1 31.06% <16.66%> (-0.01%) ⬇️
shard-2 35.10% <22.22%> (-0.01%) ⬇️
shard-3 31.11% <0.00%> (-0.02%) ⬇️
shard-4 40.74% <8.33%> (-0.02%) ⬇️
shard-5 38.03% <88.88%> (+0.02%) ⬆️
shard-6 31.10% <8.33%> (-0.02%) ⬇️

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

Files with missing lines Coverage Δ
...ckages/loopover-engine/src/governor/kill-switch.ts 100.00% <100.00%> (ø)
...ackages/loopover-miner/lib/governor-kill-switch.ts 100.00% <100.00%> (ø)
src/services/notify-pagerduty.ts 100.00% <100.00%> (ø)

Exercise every notify/env/error branch under vitest so patch coverage clears the 99% gate.

Co-authored-by: Cursor <cursoragent@cursor.com>
Collapse sync/async failure handling into shared helpers and Promise.resolve so Codecov patch does not miss branches under sharded merges.

Co-authored-by: Cursor <cursoragent@cursor.com>
@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 21, 2026
@loopover-orb

loopover-orb Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Caution

🛑 LoopOver review result - reject/close recommended

Review updated: 2026-07-21 08:59:32 UTC

10 files · 1 AI reviewer · 1 blocker · CI green · clean

🛑 Suggested Action - Reject/Close

Review summary
Adds a pure buildMinerKillSwitchPagerDutyAlert detector in loopover-engine (returns null unless the transition is an actual trip into an active scope), then wires it into the miner's recordMinerKillSwitchTransition via an injectable, best-effort notify hook, and adds a parallel hosted notifyMinerKillSwitchPagerDuty in src/services/notify-pagerduty.ts that reuses triggerPagerDutyIncident for severity/cooldown/audit. The trip/no-trip branch logic is sound and well covered (trip vs resume vs same-scope, global-fleet fallback, sync/async throw/reject paths), and the miner-side page is genuinely fire-and-forget so it can't block the ledger write. The one open question is whether the newly-added hosted notifyMinerKillSwitchPagerDuty is actually invoked anywhere in the AMS kill-switch trip flow — the diff only adds the function and its unit test, with no visible call site.

Blockers

  • src/services/notify-pagerduty.ts:224 adds `notifyMinerKillSwitchPagerDuty` but the diff contains no call site wiring it into the hosted AMS kill-switch trip path, so unless an unshown file already calls it, the 'Hosted notifyMinerKillSwitchPagerDuty reuses triggerPagerDutyIncident' half of the PR description is dead code — please point to the caller or wire it in.
Nits — 5 non-blocking
  • src/services/notify-pagerduty.ts:4-5 imports directly from `../../packages/loopover-engine/src/governor/kill-switch.js` (source path, not the `@​loopover/engine` package barrel), while packages/loopover-miner/lib/governor-kill-switch.ts consistently imports from `@​loopover/engine` — worth using the package entrypoint here too so the src/ layout of loopover-engine isn't a load-bearing import path for a consumer outside the package.
  • The miner-side `notifyMinerKillSwitchPagerDuty` (governor-kill-switch.ts:76) duplicates most of `triggerPagerDutyIncident`'s Events API POST body/headers/timeout by hand instead of sharing a small serialization helper with src/services/notify-pagerduty.ts — acceptable given the stated 'miner has no Worker Env/D1' constraint, but the two payload builders will drift if the Events API contract ever changes.
  • Unlike the hosted path, the miner's notify has no severity floor or cooldown, so a flapping repo scope will fire an Events API call on every single trip (relying solely on PagerDuty's own dedup_key coalescing) — worth a one-line callout in the runbook alongside the existing PagerDuty section.
  • PAGERDUTY_EVENTS_URL, the 200-char message truncation, and the 5000ms timeout are duplicated as raw literals between governor-kill-switch.ts and notify-pagerduty.ts instead of being shared constants — minor DRY nit given they're intentionally independent modules.
  • Confirm (and if missing, add) the caller of the hosted `notifyMinerKillSwitchPagerDuty` in the AMS trip-recording path, or clarify in the PR description that it's not yet wired and is being added ahead of that integration.

Why this is blocked

  • src/services/notify-pagerduty.ts:224 adds `notifyMinerKillSwitchPagerDuty` but the diff contains no call site wiring it into the hosted AMS kill-switch trip path, so unless an unshown file already calls it, the 'Hosted notifyMinerKillSwitchPagerDuty reuses triggerPagerDutyIncident' half of the PR description is dead code — please point to the caller or wire it in.
📋 Copy for AI agents — paste into your coding agent
Fix the following blocker(s) from this PR review:

1. src/services/notify-pagerduty.ts:224 adds \`notifyMinerKillSwitchPagerDuty\` but the diff contains no call site wiring it into the hosted AMS kill-switch trip path, so unless an unshown file already calls it, the 'Hosted notifyMinerKillSwitchPagerDuty reuses triggerPagerDutyIncident' half of the PR description is dead code — please point to the caller or wire it in.

Decision drivers

  • ❌ Code review — 1 blocker (1 reviewer)
  • ❌ Gate result — Blocking (Repo-configured hard blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7666
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: 203 registered-repo PR(s), 127 merged, 37 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jsdevninja; Gittensor profile; 203 PR(s), 37 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR wires kill-switch trips in both the engine's pure alert builder and the miner's transition recorder to fire PagerDuty pages, explicitly reusing the hosted notify-pagerduty.ts's triggerPagerDutyIncident (with its severity floor, cooldown, and dedup-key) rather than building a separate alerting mechanism, and updates the runbook's Detection section accordingly. Test coverage mocks fetch/Pager

Review context
  • Author: jsdevninja
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: not available
  • Official Gittensor activity: 203 PR(s), 37 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
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.

Visual preview
Route Viewport Before (production) After (this PR's preview) Diff
/ desktop before /
before /
after /
after /
/ mobile before / (mobile)
before / (mobile)
after / (mobile)
after / (mobile)

Click any thumbnail to open the full-size screenshot. Before = production · After = this PR's preview deploy.

Scroll preview
Route Before (production) After (this PR's preview)
/ before / (scroll)
before / (scroll)
after / (scroll)
after / (scroll)

A short scroll-through clip (desktop) — click either thumbnail to open the full animation. Evidence for scroll-linked behavior a single screenshot can't show.

🟩 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 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

LoopOver is closing this pull request on the maintainer's behalf (AI reviewers agree on a likely critical defect: src/services/notify-pagerduty.ts:224 adds `notifyMinerKillSwitchPagerDuty` but the diff contains no call site wiring it into the hosted AMS kill-switch trip path, so unless an unshown file already calls it, the 'Hosted notifyMinerKillSwitchPagerDuty reuses triggerPagerDutyIncident' half of the PR description is dead code — please point to the caller or wire it in.). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

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.

Wire real PagerDuty alerting into AMS kill-switch trips (currently ledger-only, no paging)

1 participant