Skip to content

feat(broker): the mint admits hosted-mcp, and reads the row's own entry (TASK-172 slice 3c-1) - #2002

Merged
lilyshen0722 merged 1 commit into
mainfrom
kai/task172-mint
Sep 29, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
kai/task172-mint

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

TASK-172 slice 3c-1 — the mint admits hosted-mcp, and reads the row's own entry

Step 4's second half, first piece (§5, §7): a room grant — the row that says
what a seat may call — must be mintable against a hosted-MCP connection, and the
tool list it enables must be the one belonging to that row's catalogue entry.

Cut from main (87c73258) — it reads config.entryId, which 3a writes, and
needs slice 2's findHostedMcpEntry, both landed. It is a sibling of 3b (#2001),
not stacked on it
: the two touch disjoint files.

The rebase is worth one line for what it dropped. This branch also carried two
fixes to 3a's own route and callback suite that had already landed inside 3a's
squash, so both replayed as already applied and were skipped rather than
re-applied — witnessed rather than assumed: after resolving each conflict in
favour of main, the staged tree was byte-identical to main (git diff --cached
empty), which is the only thing that justifies a skip. One commit survives, and it
is the whole delta below: 4 files, +275 / −10.

What lands

file
backend/services/installable/toolInstallables.ts +44 −10 resolveBrokerFor takes the CONNECTION and an injectable entry list
backend/routes/grants.ts +32 −? the hosted branch: connection checks, the row-id identity, the write refusal
backend/__tests__/unit/services/toolInstallables.test.js +89 3 → 8 arms
backend/__tests__/unit/routes/grants.mint.test.js +120 7 → 14 arms, with a withCatalog(entries, run) fixture

The shape, and why

resolveBrokerFor now keys on the connection, not the type. It used to take
connectionType: string and return the one catalogue row seeded for
github-app. A hosted row's tool list is ENTRY-keyed (config.entryId), so
keying the lookup on the type alone would let a grant on one vendor's row enable
another vendor's tools — scope §7's mix-up, one layer down. The entry list is a
parameter defaulted to HOSTED_MCP_ENTRIES so the branch is testable against
a fixture catalogue while the live list is still empty in v1, and so a test can
push a fixture entry and witness the real default resolution path.

brokerId stays the single GRANT_BROKER_ID. grantBrokerProjectionService
selects a seat's grants by that one constant, so a per-entry broker id would mint
a grant the seat never sees — a silent "no tools" rather than an error.

A hosted grant's installationId and connection id are the ROW's _id.
The row has neither of the GitHub installation-id slots, and an _id is never
reused, so the TASK-148 class (a grant matching a re-created row by an external
id) cannot arise for this type.

The mint refuses a hosted row that is not connected or holds no credential
(isConnected + a credentialRef), rather than minting a grant whose first call
fails.

A hosted write grant is refused (write_requires_confirm). Scope §5a: a
hosted write counts as the member's own act only when it parks for approval,
and a write grant runs non-write-classified calls without parking. So the
refusal is a hosted && conjunct on the existing path, and the arms carry a
positive control: a github-app row still mints write, which is what
distinguishes "the guard was widened to refuse hosted writes" from "the guard
refuses writes".

Evidence

  • Two suites, (2, 22) — 5 new service arms and 7 new mint arms, 0 failed,
    0 runtime errors. tsc:check exit 0. eslint on both sources identical to
    base
    (9 warnings / 0 errors either side — the pre-existing count, measured by
    swapping the base file in place and diffing the error multiset).
  • Mutation ledger /tmp/kai-172s3c-ledger.py: 10 mutations (M01–M10),
    baseline (2, 22), NO SURVIVORS, NO NAMED-ARM MISSES, NO NOT-APPLIED, NO
    COMPILER REFUSALS.
    The refusal arms are written so that the widened guard is
    what fails them: a connected hosted row reaching 503 broker_unavailable
    proves the type check admits hosted rows at all, where a 403
    connection_mismatch would only prove the new branch was reached.

Disclosed gap — the broker half of step 4 is deliberately absent

resolveConnection in backend/services/toolBrokerService.ts still resolves
{ type: 'github-app', installationId } only, and ToolConnection is
GitHub-shaped. Widening it here would add a branch with no consumer:
ToolDefinition.call is a REQUIRED field, the hosted projection
(entryToolProjections) omits it by construction, and the broker looks a call up
as TOOL_DEFINITIONS[input.tool] — so no hosted tool can be registered in that
literal record until an entry can carry a call. The honest unit is therefore
one atomic slice: the entry projections with call (which need 3b's
credentialFor and the vendor request) plus the resolveConnection branch
and the widened union. That is recorded on the row, and it is why §10's implied
step order in docs/plans/hosted-mcp-connection-scope.md is corrected there
rather than followed here.

…ry (TASK-172)

Scope §7's mint half. A hosted-mcp row has no installationId slot, so the
row's `_id` IS the grant's installationId for that type; the grant may name
only tools from the row's own catalogue entry; and `write` is refused there,
because §5(a)'s rule holds only if no grant on the row can run a non-read call
without parking. The type was previously refused three times over at the mint,
so none of this could be reached before.

- `resolveBrokerFor` now takes the CONNECTION rather than its type. A
  github-app connection still reads the seeded catalogue row; a hosted-mcp
  connection reads its catalogue entry, because there is one entry per vendor
  and keying on the type would let a grant on one vendor's row name another
  vendor's tool. The entry list is a parameter, so the lookup is testable
  against a fixture catalogue while `HOSTED_MCP_ENTRIES` is empty in v1.
- `brokerId` stays the single `GRANT_BROKER_ID`. That is load-bearing rather
  than cosmetic: `grantBrokerProjectionService` selects a seat's grants by that
  one value, so a per-entry broker id would make the grant invisible to the
  seat it was minted for.
- The mint requires `connected`, no `revokedAt` and a `credentialRef` for this
  type, and refuses `write` with `write_requires_confirm`.

The signature change forced one existing arm to move: it called
`resolveBrokerFor('github-app')` and now passes `{ type: 'github-app' }`.

Arms: +12 (5 in the tool-Installable suite, 7 in the mint suite), including two
positive controls that a refusal arm would otherwise be missing — a connected
hosted row whose mint fails only on the catalogue, and a github-app row that
still mints `write`. Ledger: 10 mutations over both files, all killed by the
arm that names their claim, no survivors, no named-arm misses, no compiler
refusals. tsc clean; eslint identical to base (9 warnings / 0 errors either
side).

Not in this increment: the broker's hosted branch in `resolveConnection` (the
`_id`-only resolution and the widened `ToolConnection`), the per-entry tool
Installable the catalogue page reads, and the vendor `call` the intake slice
owns. None of them is reachable while the catalogue is empty.
@lilyshen0722
lilyshen0722 added this pull request to the merge queue Sep 29, 2026
@lilyshen0722
lilyshen0722 removed this pull request from the merge queue due to a manual request Sep 29, 2026
@lilyshen0722
lilyshen0722 added this pull request to the merge queue Sep 29, 2026
Merged via the queue into main with commit 12b2011 Sep 29, 2026
16 checks passed
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