Skip to content

feat(grants): the Tools page's three read routes (piece 4, option A) - #1668

Merged
lilyshen0722 merged 3 commits into
mainfrom
wave/piece4-read-routes
Sep 11, 2026
Merged

lilyshen0722 merged 3 commits into
mainfrom
wave/piece4-read-routes

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Piece 4 of the connectors build, option A — the read routes named in docs/plans/tools-catalogue-room-grants.md §6 Sequencing, before the page. Assignment: Connectors v2 pod 67699. Reviewer: Vera clears the exact head.

Routes

  1. GET /api/pods/:podId/grants — every grant whose target is the pod or a seat in it (seat id ∈ pod members), gated by DMService.canViewPod, each row projected. Malformed id → 403, missing pod → 404. Mounted under /api/pods beside the pod routes (server.ts).
  2. GET /api/grants/:grantId/calls — ToolCall.listForGrant (limit ≤500, default 100) plus counts = COUNT(*) by outcome ({total, ok, refused, pending_approval, failed}; new ToolCall.countsForGrant). Pod target: canViewPod for a human or a seat on its runtime token (dualAuth). Seat target: only the granter (Connection owner) or that seat; membership never substitutes. Lines carry argsDigest, never args.
  3. GET /api/grants/:grantId — tightened to the explicit field list: grantId, installationId, target, tools, writeMode, budget, effectiveAudience, expiresAt, revokedAt, parentGrantId, rootGrantId, createdAt, grantedBy. Never connectionId, brokerId, audience, _id (Vera 67560/67568). grantedBy is resolved from the Connection's owner.

Named tests (backend/__tests__/unit/routes/grants.read.test.js, memory Mongo for RoomGrant; pod, connection and trail mocked at their module boundaries):

  • the pod grants list refuses a non-member
  • the trail refuses a non-member and never returns args
  • a seat grant's trail is visible only to its granter and the seat
  • GET /api/grants/:id returns the field list and never connectionId or brokerId
  • plus: seat-in-pod list shape with effective audience only; 404 + limit clamp; ToolCall.countsForGrant on pg-mem (ToolCall.counts.test.js).

Backend 18/18 across the grant suites (mcpGrants.test.js needs @modelcontextprotocol/sdk, absent from my local node_modules — CI has it), lint:ts 0 errors. No frontend changes in this PR; the page follows in its own wave/piece4-* branch once these are cleared.

🤖 Generated with Claude Code

https://claude.ai/code/session_016DspLEe1mFV94dPGCqA1u5

lilyshen0722 and others added 2 commits September 11, 2026 12:41
…he trail with counts, and a projected grant read

Tools plan §6 Sequencing (docs/plans/tools-catalogue-room-grants.md), piece 4
option A, the routes before the page:

- GET /api/pods/:podId/grants — every grant whose target is the pod or a
  seat in it, gated by DMService.canViewPod, each row in the explicit field
  list. Mounted beside the pod routes.
- GET /api/grants/:grantId/calls — the trail from ToolCall.listForGrant plus
  COUNT(*) by outcome (new ToolCall.countsForGrant). Gated by canViewPod on
  the target pod; a seat grant's trail goes only to the granter and that seat
  (dualAuth, so the seat reads on its runtime token). Every line carries
  argsDigest and never args.
- GET /api/grants/:grantId now returns the field list and nothing else —
  grantId, installationId, target, tools, writeMode, budget,
  effectiveAudience, expiresAt, revokedAt, parentGrantId, rootGrantId,
  createdAt, grantedBy (the Connection's owner). Never connectionId, brokerId
  or the raw audience snapshot (Vera 67560/67568).

Named tests: the pod grants list refuses a non-member; the trail refuses a
non-member and never returns args; a seat grant's trail is visible only to
its granter and the seat; GET /api/grants/:id returns the field list and
never connectionId or brokerId. Plus the seat-in-pod list shape, the 404 and
limit clamp, and countsForGrant on pg-mem.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DspLEe1mFV94dPGCqA1u5
…d gate the grant read like its trail

Two of Vera's blockers on #1668 (67727), one of them also Wren's 67721:

- pods.ts ends with `router.get('/:type/:id', getPodById)`, so with podRoutes
  mounted first `/api/pods/:podId/grants` answered as type=<podId>, id='grants'
  and podGrantsRouter was never reached. The list now mounts ahead of
  podRoutes in server.ts, and the suite mounts routes/pods in the same order
  with the controller stubbed so the shadowing would show: `GET
  /api/pods/:podId/grants is reachable with the pod routes mounted` (goes red
  with the order reversed, 3 of 7).
- A seat grant's read had no gate: ensureTargetAccess has no pod census for
  a seat, so a stranger in no pod read the tools and the granter with 200
  while the trail refused them. Both reads now share one gate — a pod grant
  belongs to the pod (canViewPod, human or seat on its token), a seat grant
  goes only to the granter and that seat — pinned by `a seat grant's read is
  gated like its trail`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DspLEe1mFV94dPGCqA1u5
@samxu01
samxu01 force-pushed the wave/piece4-read-routes branch from de691b8 to 3ce5219 Compare September 11, 2026 19:51
…unted

Mounts routes/pods after podGrantsRouter, the server.ts order, with the pod
controller stubbed so its `/:type/:id` catch-all would show: `GET
/api/pods/:podId/grants is reachable with the pod routes mounted` goes red
(3 of 8) with the order reversed. The test was written for the mount fix and
lost to a `git checkout` during its own mutation check before the commit.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DspLEe1mFV94dPGCqA1u5
@lilyshen0722
lilyshen0722 merged commit 46e8419 into main Sep 11, 2026
14 checks passed
samxu01 pushed a commit that referenced this pull request Sep 11, 2026
…ays free of GitHub crypto

After the rebase onto #1668, grants.read.test.js mounted routes/grants.ts
unmocked and the new resolveBrokerFor import pulled toolBrokerService →
githubAppService → jsonwebtoken at load, which throws on Node 26
(SlowBuffer is gone). The broker definitions are only needed when seeding
or projecting tools, so require them on first use.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
lilyshen0722 added a commit that referenced this pull request Sep 11, 2026
…erives brokerId (#1670)

* feat(tools): builtin GitHub tool Installable in the catalogue; mint derives brokerId

Piece 2 follow-up (tools plan §2, §6). The catalogue returned only channel
providers, so the Tools page had no not-yet row, no allow-list and no broker
to mint against (lily-shen 67719).

- seed-builtin-tools.ts upserts the builtin GitHub Installable at boot with one
  mcp-server component named for the broker (commonly-grant-broker) and
  enabledTools projected from TOOL_DEFINITIONS, never hand-written.
- GET /api/installables is one response, two lists: every entry carries
  list: 'channels' | 'tools'. A tool entry adds broker, tools (name, tier,
  irreversible) and the caller's own connected GitHub App connections
  (connectionId, owner, repo). No credential or Connection _id leaves the route.
- POST /api/grants reads brokerId from the seeded row and ignores the body's;
  a tool outside enabledTools is 400 invalid_tools, no seed row is 503
  broker_unavailable.
- V2ConnectorsPage filters list: 'tools' out of its rows.

Named tests: the builtin GitHub Installable enables exactly the broker's GitHub
tools; brokerId comes from the tool Installable, never the body; the mint
refuses a tool the Installable does not enable; the catalogue returns the
GitHub tool Installable with its tools, broker and the caller's connections, on
the tools list; a tool Installable in the catalogue never renders as a channel
row.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(grants): refuse a client-supplied brokerId at mint

Vera 67728: the field naming who holds the credential must not be
caller-written. A body carrying brokerId is now 400 invalid_broker; the
server still sets it from the seeded tool Installable. Named test: a
client-supplied brokerId is refused.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix(tools): load the broker definitions lazily so routes/grants.ts stays free of GitHub crypto

After the rebase onto #1668, grants.read.test.js mounted routes/grants.ts
unmocked and the new resolveBrokerFor import pulled toolBrokerService →
githubAppService → jsonwebtoken at load, which throws on Node 26
(SlowBuffer is gone). The broker definitions are only needed when seeding
or projecting tools, so require them on first use.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
samxu01 pushed a commit that referenced this pull request Sep 11, 2026
…ption A)

Tools plan §6: a second list under the channels in the same row grammar, one
row per RoomGrant the person can see (live · pulsing when used in the last
10 min · hollow when revoked or expired), the aside from the projected grant
(who granted it and when it ends, the agents allowed, the allow-list under its
write mode, what asks a person first, budget, two-click Revoke) and the trail
from the broker's rows — one muted mono line per ToolCall with the three
COUNT(*) numbers in display 22 / mono 11. Heading with the mono count, a
search field and a segment on the same line. 390 as the channels list.

SEAM (Wren 67724/67725): the not-yet row, the Add form and Change access wait
on the builtin GitHub Installable landing in GET /api/installables with its
McpServer.enabledTools; the server derives brokerId. Until then `catalog` is
empty and those controls do not render — nothing pretends to grant.

Reads only /api/pods/:podId/grants, /api/grants/:id/calls,
/api/registry/pods/:podId/agents (#1668). GitHub glyph added to the platform
set. Layout invariants: trail line is muted mono with no semantic colour;
counts are 22/11; the display titles reset under :lang(zh).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DspLEe1mFV94dPGCqA1u5
samxu01 pushed a commit that referenced this pull request Sep 12, 2026
…ption A)

Tools plan §6: a second list under the channels in the same row grammar, one
row per RoomGrant the person can see (live · pulsing when used in the last
10 min · hollow when revoked or expired), the aside from the projected grant
(who granted it and when it ends, the agents allowed, the allow-list under its
write mode, what asks a person first, budget, two-click Revoke) and the trail
from the broker's rows — one muted mono line per ToolCall with the three
COUNT(*) numbers in display 22 / mono 11. Heading with the mono count, a
search field and a segment on the same line. 390 as the channels list.

SEAM (Wren 67724/67725): the not-yet row, the Add form and Change access wait
on the builtin GitHub Installable landing in GET /api/installables with its
McpServer.enabledTools; the server derives brokerId. Until then `catalog` is
empty and those controls do not render — nothing pretends to grant.

Reads only /api/pods/:podId/grants, /api/grants/:id/calls,
/api/registry/pods/:podId/agents (#1668). GitHub glyph added to the platform
set. Layout invariants: trail line is muted mono with no semantic colour;
counts are 22/11; the display titles reset under :lang(zh).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DspLEe1mFV94dPGCqA1u5
lilyshen0722 added a commit that referenced this pull request Sep 12, 2026
…ption A) (#1669)

* feat(v2): Tools on the Connectors page — the granted half (piece 4, option A)

Tools plan §6: a second list under the channels in the same row grammar, one
row per RoomGrant the person can see (live · pulsing when used in the last
10 min · hollow when revoked or expired), the aside from the projected grant
(who granted it and when it ends, the agents allowed, the allow-list under its
write mode, what asks a person first, budget, two-click Revoke) and the trail
from the broker's rows — one muted mono line per ToolCall with the three
COUNT(*) numbers in display 22 / mono 11. Heading with the mono count, a
search field and a segment on the same line. 390 as the channels list.

SEAM (Wren 67724/67725): the not-yet row, the Add form and Change access wait
on the builtin GitHub Installable landing in GET /api/installables with its
McpServer.enabledTools; the server derives brokerId. Until then `catalog` is
empty and those controls do not render — nothing pretends to grant.

Reads only /api/pods/:podId/grants, /api/grants/:id/calls,
/api/registry/pods/:podId/agents (#1668). GitHub glyph added to the platform
set. Layout invariants: trail line is muted mono with no semantic colour;
counts are 22/11; the display titles reset under :lang(zh).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DspLEe1mFV94dPGCqA1u5

* feat(v2): Tools — the not-yet row, Add, Change access and Grant again from the catalogue (#1670), with direction-A marks

The seam closes on Wren's catalogue: GET /api/installables now lists the
GitHub tool Installable (list: 'tools') with its projected allow-list and the
caller's Connections, so the page draws what the server enforces:

- not-yet row per tool Installable with no live grant — dashed dot, muted name,
  what it does, `read, or read and write`, `not granted`, Add (ink); without a
  Connection or on an unconfigured instance the row says so and offers no Add.
- Add opens in the aside: room, connection (when more than one), a writeMode
  segment, the allow-list the mode admits (read → read tools; write modes →
  all), what asks first (the catalogue's irreversible tools under `write`),
  every non-internal seat in the room checked, expiry 7/30/90 days, Grant (ink).
  The mint body is the server's: connectionId, installationId, target, tools,
  writeMode, audience, expiresAt — never a brokerId (Vera 67728).
- Change access pre-fills from the grant (effectiveAudience, not the raw
  snapshot — Vera 67568) and is a new grant plus a revoke of the old one;
  Grant again on an expired/revoked row only mints.
- "what asks first" under `write` lists the catalogue's irreversible tools.
- direction A (Sam 2026-09-11): the grant's mode and a trail line's outcome
  carry a 14px mark with the word in `title`; the granted row no longer repeats
  the tool's description sentence.

glyphs.tsx is the same file #1671 adds (identical content, merges clean).

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DspLEe1mFV94dPGCqA1u5

* fix(v2): the Add form sends no installationId — the mint takes it from the Connection (#1677)

Vera 67821 via #1677: a grant on connection A must not be able to name
installation B, so the mint derives installationId from the Connection and
refuses a client-supplied one. The body is now exactly the six keys the route
takes — audience, connectionId, expiresAt, target, tools, writeMode — pinned
by key list, with brokerId and installationId both asserted absent.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DspLEe1mFV94dPGCqA1u5

* fix(v2): Tools — Revoke and Change access are the granter's; a failed revoke after Change access is retried alone; the trail says "awaiting a person"

Vera 67912 / Wren 67913 on 0368992:
- Revoke and Change access render only when grant.grantedBy is the viewer —
  the route 403s anyone else, so the page never draws a control the server
  would refuse. A member still reads the grant and its trail.
- Change access keeps the minted grant whatever happens next. If the revoke
  of the old grant fails, the aside says the old one is still live and offers
  "Revoke the old grant", which retries only the revoke — never a third mint.
- A trail line's outcome reads like the count: pending_approval → "awaiting a
  person" (the mark's title too).

Tests: "Revoke renders only for the granter"; the failed-revoke retry pins the
three POSTs as mint, revoke, revoke.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016DspLEe1mFV94dPGCqA1u5

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant