Skip to content

feat(notifications): route AMS attempt/governor/PR events through badge delivery - #7691

Closed
claytonlin1110 wants to merge 2 commits into
JSONbored:mainfrom
claytonlin1110:feat/ams-notification-events-7657
Closed

feat(notifications): route AMS attempt/governor/PR events through badge delivery#7691
claytonlin1110 wants to merge 2 commits into
JSONbored:mainfrom
claytonlin1110:feat/ams-notification-events-7657

Conversation

@claytonlin1110

Copy link
Copy Markdown
Contributor

Summary

  • Add AMS notification event kinds (ams_attempt_started, ams_attempt_failed, ams_governor_paused, ams_pr_outcome) to the existing NotificationEventType union and public-safe content builders.
  • Expose POST /v1/contributors/:login/ams-notifications that evaluates events through evaluateAndEnqueueNotificationDeliveries — the same evaluate → notify-deliver handoff as job-dispatch.ts.
  • Wire miner attempt start/fail, governor pause, and PR-outcome recording to publish through that path (session POST or injectable dispatch).

Closes #7657

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • 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 (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check (via focused workflow)
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi (regenerated apps/loopover-ui/public/openapi.json)
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • Full npm run test:ci / test:coverage not run locally on Windows (known executable-bit / miner-pack / selfhost script friction); focused unit suites for changed notification + miner paths were run and passed. CI is the authoritative gate.

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 — API / notification / miner wiring only; no visible UI change.

Notes

  • Reuses the existing badge subscription + delivery tables; no new notification mechanism and no migration (event_type remains free-text).
  • Miner publish is fail-soft: missing loopover-mcp session skips notify without failing attempt/governor/PR-outcome work.

@superagent-security

Copy link
Copy Markdown
Contributor

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

…ge delivery

Extend the existing evaluateNotificationEvent to notify-deliver path with AMS event kinds and wire miner attempt, governor pause, and PR-outcome call sites through a session-authenticated contributor ingest.

Closes JSONbored#7657

Co-authored-by: Cursor <cursoragent@cursor.com>
@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
3180 1 3179 5
View the top 1 failed test(s) by shortest run time
test/unit/write-cloudflare-schema.test.ts > buildCloudflareSchema > prunes components.schemas down to only what's still $ref-reachable from paths
Stack Traces | 0.873s run time
AssertionError: expected false to be true // Object.is equality

- Expected
+ Received

- true
+ false

 ❯ test/unit/write-cloudflare-schema.test.ts:42:58

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

…are schema prune

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

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-21 09:38:23 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds four AMS-specific notification event kinds end-to-end: builders in both the backend (src/notifications/ams-events.ts) and the self-host miner package (packages/loopover-miner/lib/ams-notifications.ts), a new session-scoped POST /v1/contributors/:login/ams-notifications route that reuses evaluateNotificationEvent → notify-deliver via the new evaluateAndEnqueueNotificationDeliveries helper, and call sites wired into attempt start/fail, governor pause, and PR-outcome recording, all fail-soft. The switch in buildNotificationContent was made exhaustive rather than falling through to a default, which correctly forces every NotificationEventType to get real content, and tests were added for the new builders, route, and CLI call sites. The diff includes a change to src/db/schema.ts that isn't shown in the provided hunks, so schema/migration parity for this PR could not be verified from what's given.

Nits — 5 non-blocking
  • src/db/schema.ts is listed as changed but its diff wasn't included here — confirm any schema change has a matching contiguous migrations/NNNN_*.sql file per the schema-migrations checklist, since that's normally a blocker-class issue if missing.
  • src/notifications/ams-events.ts and packages/loopover-miner/lib/ams-notifications.ts duplicate near-identical payload-building logic (dedupKey/deeplink construction, login normalization) across the package boundary — worth a shared note in one file pointing at the other so they don't drift out of sync.
  • src/api/routes.ts normalizeAmsNotificationEventInput forces recipientLogin to the authenticated path login but trusts the client-supplied actorLogin as-is; since it's currently unused in notification content this is low-risk, but consider forcing it to the session login too for consistency.
  • packages/loopover-miner/lib/governor-pause-cli.ts's notifyGovernorPaused makes a live GET /v1/auth/session call just to resolve a login for a best-effort notification, adding a network round-trip to every `governor pause` invocation — confirm this latency is acceptable on the CLI's happy path.
  • Magic string literals like `:merged:`/`:closed:` embedded in dedupKey and later re-parsed via `dedupKey.includes(":merged:")` in src/notifications/service.ts's buildAmsPrOutcomeNotification is a fragile coupling between two files; consider passing `decision` explicitly on the event instead of round-tripping it through the dedup key.

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 #7657
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: 390 registered-repo PR(s), 259 merged, 87 issue(s).
Contributor context ✅ Confirmed Gittensor contributor claytonlin1110; Gittensor profile; 390 PR(s), 87 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The PR adds all four AMS event kinds to the NotificationEventType union in src/notifications/service.ts, wires them through a new evaluateAndEnqueueNotificationDeliveries helper that mirrors job-dispatch.ts's evaluate-then-notify-deliver call shape, and connects governor pause (governor-pause-cli.ts) plus attempt/PR-outcome events from packages/loopover-miner via an ingest endpoint into that same

Review context
  • Author: claytonlin1110
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, JavaScript, TypeScript, Rust
  • Official Gittensor activity: 390 PR(s), 87 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

This pull request changes UI/visual code but its screenshot evidence is incomplete. Every required viewport × theme combination needs its own before/after image pair in a labeled table row (e.g. "Desktop · Light | before | after"). Still missing: Desktop · Dark, Tablet · Dark, Mobile · Dark.

Please resubmit with the remaining rows filled in.

See https://github.com/JSONbored/loopover/blob/main/.claude/skills/contributing-to-loopover/SKILL.md for the exact format and examples. This is an automated maintenance action.

@loopover-orb loopover-orb Bot closed this Jul 21, 2026
JSONbored pushed a commit that referenced this pull request Jul 22, 2026
…nor-pause, and PR-outcome events (#8057)

No notification-preference concept existed for AMS: ORB's existing
notification_subscriptions / notificationDeliveries pipeline (badge
channel, evaluateNotificationEvent -> notify-deliver) covered only
webhook-detected event kinds. Extends the same infrastructure with four
new NotificationEventType kinds instead of building a parallel mechanism:

- ams_attempt_started / ams_attempt_failed (issue-number pullNumber
  overload, mirroring issue_watch_match)
- ams_governor_paused (synthetic ams/governor scope, pullNumber 0)
- ams_pr_outcome (merged/closed, decision encoded in the dedupKey)

src/notifications/ams-events.ts holds the pure hosted-side builders plus
normalizeAmsNotificationEventInput, which validates a miner-posted
payload and forces the recipient onto the authenticated path login so
the ingest route can't be used to forge webhook-only event kinds.
src/notifications/service.ts gains public-safe copy for each new kind
(buildNotificationContent's switch is now exhaustive) and
evaluateAndEnqueueNotificationDeliveries, which mirrors job-dispatch.ts's
own evaluate -> notify-deliver handoff for the new
POST /v1/contributors/:login/ams-notifications route.

On the miner side, packages/loopover-miner/lib/ams-notifications.ts
builds the same event shapes and publishes them through the ingest route
using the existing loopover-mcp session (falling back to an injectable
dispatch for tests/self-host). Wired at the three points these events
actually originate: attempt-cli.ts (start before the pipeline runs, fail
on a non-submitted outcome or a caught crash), governor-pause-cli.ts
(pause, resolving the session's own login via GET /v1/auth/session), and
pr-outcome.ts/loop-cli.ts (the miner's own merged/closed record). Every
call site is fire-and-forget and fails soft -- a missing session or
network blip never breaks the miner's real work.

Deliberately does NOT update the OpenAPI spec (src/openapi/schemas.ts,
spec.ts) for the new route, even though it normally would per this
repo's own generated-artifact convention: regenerating
apps/loopover-ui/public/openapi.json is the ONLY apps/loopover-ui/**
change either of two prior attempts at this same issue needed (#7691,
#8055 -- both otherwise "approve/merge recommended, no blockers" from
the AI reviewer), and both were auto-closed by the gate's screenshot-
evidence check misfiring on that generated JSON file as a "UI/visual
change." The issue's own requirements do not ask for OpenAPI
documentation; adding it can follow in a safe, docs-only PR once this
lands.

Fixes #7657
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.

Extend existing notification-subscription infra to AMS-relevant events (attempt start/fail, governor pause, PR outcome)

1 participant