Skip to content

feat(api): REST + CLI mirror for contributor notifications (#6745) - #7018

Merged
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jeffrey701:rest-cli-notifications-6745
Jul 17, 2026
Merged

feat(api): REST + CLI mirror for contributor notifications (#6745)#7018
loopover-orb[bot] merged 1 commit into
JSONbored:mainfrom
jeffrey701:rest-cli-notifications-6745

Conversation

@jeffrey701

Copy link
Copy Markdown
Contributor

Summary

Adds the REST + CLI mirror for the loopover_list_notifications and loopover_mark_notifications_read MCP tools, closing the last gap in the /v1/contributors/:login/* read family for a contributor's own notification feed.

  • GET /v1/contributors/:login/notifications — returns the badge notification feed ({ login, unreadCount, notifications }), self-scoped via requireContributorAccess, reusing listNotificationDeliveriesForRecipient + buildNotificationFeed — the exact path LoopoverMcp.listNotifications takes.
  • POST /v1/contributors/:login/notifications/read — marks the contributor's delivered notifications read via markNotificationDeliveriesRead; an absent/empty body marks all, a validated ids array marks those. Returns { login, marked }.
  • CLI: loopover-mcp notifications and loopover-mcp notifications-read [--id <id>]..., mirroring the sibling contributor commands' login resolution (--login / active session / LOOPOVER_LOGIN / GITHUB_LOGIN) and --json contract.
  • OpenAPI: registers both paths plus the NotificationFeed / NotificationsMarked schemas; openapi.json regenerated.

Why

The route file already framed contributor notifications as an MCP-parity gap the REST leg was never built for, while every sibling read (/profile, /decision-pack, /open-pr-monitor) already has a REST + CLI surface. This brings notifications to the same parity, reusing the existing repository + feed-builder functions with no new business logic.

Validation

  • npm run typecheck, npm run ui:openapi:check, npm run command-reference:check, npm run docs:drift-check — all green.
  • test/unit/routes-notifications.test.ts (12 cases) drives 100% line + branch coverage on both new routes: feed shape and unread count, exclusion of still-pending rows, mark-all vs mark-by-id, malformed-body 400, the auth guard (unauthenticated + shared-mcp-token 403 per fix(mcp): scope GITTENSORY_MCP_TOKEN read access to the operator allowlist, not just write/manage #2455), and output parity with both MCP tools for identical input.
  • test/unit/mcp-cli-notifications.test.ts (12 cases) covers the CLI: --json byte-parity with the route, plain-text rendering, --id forwarding vs mark-all, login resolution, ANSI-escape sanitization of API-chosen text, and self-documentation in --help / completion.

Closes #6745

@jeffrey701
jeffrey701 requested a review from JSONbored as a code owner July 17, 2026 18:04
@superagent-security

Copy link
Copy Markdown
Contributor

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

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.73%. Comparing base (9171769) to head (58ec675).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #7018   +/-   ##
=======================================
  Coverage   93.72%   93.73%           
=======================================
  Files         690      690           
  Lines       68560    68580   +20     
  Branches    18743    18746    +3     
=======================================
+ Hits        64261    64281   +20     
  Misses       3302     3302           
  Partials      997      997           
Flag Coverage Δ
shard-1 43.63% <40.00%> (-0.01%) ⬇️
shard-2 36.96% <30.00%> (+0.05%) ⬆️
shard-3 33.15% <40.00%> (+<0.01%) ⬆️
shard-4 34.72% <40.00%> (+0.48%) ⬆️
shard-5 31.45% <90.00%> (-0.45%) ⬇️
shard-6 45.80% <40.00%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
src/api/routes.ts 94.89% <100.00%> (+0.03%) ⬆️
src/openapi/schemas.ts 100.00% <100.00%> (ø)
src/openapi/spec.ts 99.47% <100.00%> (+<0.01%) ⬆️

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

loopover-orb Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-17 18:14:53 UTC

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

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds a straightforward REST + CLI mirror for the existing loopover_list_notifications / loopover_mark_notifications_read MCP tools, reusing listNotificationDeliveriesForRecipient, buildNotificationFeed, and markNotificationDeliveriesRead with no new business logic. The route handlers correctly gate on requireContributorAccess, the mark-read body is validated with a bounded ids array (max length + max count), and the CLI wiring (login resolution, --json, --id repeatable flag, sanitized terminal output) mirrors sibling commands. Tests assert parity between REST, CLI, and the MCP tool outputs for identical input, and CI is green across typecheck/openapi/docs-drift checks.

Nits — 5 non-blocking
  • src/api/routes.ts:3363 hardcodes the feed limit of 50 inline; consider a named constant alongside MAX_NOTIFICATION_MARK_READ_IDS for consistency.
  • The GET /notifications route has no pagination or limit query param, unlike some other list endpoints in this family — worth confirming that's intentional given the fixed limit of 50.
  • packages/loopover-mcp/bin/loopover-mcp.js: notificationsCli's plain-text loop silently ignores items with an unrecognized status; fine today since only 'delivered'/'read' exist, but flag if a third status is ever added.
  • Consider extracting the mark-read body limits (50, 400) into named constants for readability, mirroring MAX_NOTIFICATION_DELIVERY_ID_LENGTH.
  • If GET /notifications is meant to eventually support pagination, note that in the route's doc comment now to avoid a breaking response-shape change later.

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 #6745
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: 141 registered-repo PR(s), 69 merged, 32 issue(s).
Contributor context ✅ Confirmed Gittensor contributor jeffrey701; Gittensor profile; 141 PR(s), 32 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Linked issue satisfaction

Addressed
The diff adds both GET /v1/contributors/:login/notifications and POST /v1/contributors/:login/notifications/read routes reusing requireContributorAccess exactly like the profile/decision-pack routes, plus CLI subcommands (notifications, notifications-read) with matching login resolution, and includes unit tests asserting parity with the corresponding MCP tools.

Review context
  • Author: jeffrey701
  • 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: 141 PR(s), 32 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.

🟩 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 447ee82 into JSONbored:main Jul 17, 2026
16 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.

REST + CLI mirror for contributor notifications (list + mark-read)

1 participant