Skip to content

feat(broker): the hosted-MCP catalogue entry, its projection and drift (TASK-172) - #1993

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

lilyshen0722 merged 1 commit into
mainfrom
kai/task172-entry

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Slice 2 of docs/plans/hosted-mcp-connection-scope.md §10, built to §3: the catalogue entry, its projection and drift. TASK-172, build Kai, gate Vera.

What lands

backend/integrations/hostedMcp/entries.ts — the catalogue. One module per vendor lives beside it and is listed there; v1 lists none (Linear is step 7, and every other candidate waits on its own docs). The lookup is pure so a caller's lookup is testable against a fixture catalogue, and two collisions that would otherwise be silent are checked at module load: an entry id that is not a usable tool namespace (a dot would make two entries indistinguishable in a list of <entry>.<tool> names) and two entries pinning the same namespaced name (a grant's allowlist and the trail are matched on it).

backend/services/hostedMcpEntryService.ts — the entry-owned half of a ToolDefinition:

  • entryToolProjections(entry) yields the name, the entry's description, the write mode, irreversible and the pinned inputSchema, carrying connectionType: 'hosted-mcp' and entryId. A write maps to write-with-confirm, so a hosted write reaches the same single park every other tool's park is (toolBrokerService.callTool), not a second one.
  • assessEntryTools(entry, upstream) implements §3's table per pinned tool: missing upstream → tool_unavailable; inputSchema differing from the pin → tool_drift; readOnlyHint withdrawn or destructiveHint set since the pin → tool_drift; otherwise ok. An upstream tool the entry does not pin produces no assessment at all, which is §3's "never offered and never callable, and that is not an error".
  • createHostedMcpDriftCache caches that comparison per row behind a TTL, because the spec says the upstream list "MAY vary by the authorization presented on the request" — a list fetched for one member proves nothing about another. A vendor outage is provider_unavailable and is never cached: §9 leaves the row alone on a 5xx/timeout, so a failed fetch must not become a window in which every tool reads as unchanged.

toolBrokerService.ts — ToolDefinition.connectionType gains 'hosted-mcp' and an optional entryId. Type-only: no runtime behaviour changes for any tool that ships today.

What this slice deliberately does not do

  • No call on a projected tool. Forwarding to the vendor's tools/call needs the row's decrypted credential, which is §4's intake (step 3), and ToolConnection is still GitHub-shaped, so attaching call here would mean casting a connection type that does not exist yet. entryToolProjections returns Omit<ToolDefinition, 'call'>.
  • getToolDefinitions() is unchanged. With no entries in the catalogue there is nothing to merge, so this slice changes no tool list, no grant and no call. It is inert at runtime until step 3 supplies the caller and step 4 resolves a hosted row by _id.
  • Not here: the connect routes, credentialFor and the refresh fence, the mint, the trail column, removal. Steps 3–6, and TASK-147's per-removal-path witness still belongs immediately before the mint admits the type.

The four arms §10 names, and the ones they needed

an upstream tool not in the entry is never offered · the upstream description never reaches an agent · a pinned tool missing upstream is refused tool_unavailable · a pinned tool whose schema changed upstream is refused tool_drift

Each refusal carries an acceptance control, or an over-strict check would pass as "safe": the missing-tool arm also asserts the same tool is ok when present; the schema arm asserts a key reordering is not drift (which is what a JSON.stringify comparison would have called drift) while array order is, with exact canonical spellings so a canonicalizer that flattened arrays into keyed objects is caught by assertion rather than by two equally-wrong spellings comparing equal; the annotation arm asserts a tool that tightened (readOnlyHint gained, destructiveHint lost) is ok. One pinned tool is deliberately renamed (read_issue / upstream get_issue) so the lookup is witnessed as keyed on upstreamName and the refusal detail names the tool the vendor removed.

Evidence

Head 4ae5c4d1, base 4e39c999, four files, +656 −1.

what result
new suite 13 tests, 0 failed
instrument baseline asserted on every ledger run: suites=1, tests=13, failed=0 (a mutation that fails to load the suite cannot score as a kill — the first ledger run had two such mutants and both were reported as not applied-to-a-witness, i.e. not kills)
ledger /tmp/kai-172s2-ledger.py 21 mutations, 21 applied, 21 killed, NO SURVIVORS, NO NO-REPORT, NO NAMED-ARM MISSES, restores byte-equal to HEAD
ledger instruments jest for the 20 behavioural mutations; tsc --noEmit -p tsconfig.typescheck.json for the one type-only edit (M21), whose runtime behaviour is identical either way and which no test can therefore witness
regression 16 suites / 140 tests / 0 failed / 0 runtime errors — every suite importing toolBrokerService, grantBrokerProjectionService, the definition map or the grants routes
npm run tsc:check clean at head
lint-diff vs origin/main copies added=0 removed=0 as a rule+message multiset on toolBrokerService.ts, warnings included; both new files 0 findings

Two ledger findings worth reading: M19/M20 were first assigned to the tsc runner and came back survivors, because their effect is on runtime comparison and the compiler is indifferent — the instrument was wrong for the claim, not the code. M14's label named an arm that did not fail after the projection assertions moved, and the ledger failed itself on the named-arm miss rather than counting the kill; the label was corrected, not the classifier.

Disclosed

Gate: Vera.

…t (TASK-172)

Slice 2 of docs/plans/hosted-mcp-connection-scope.md §10, per §3.

An entry is server-owned data in this repo: the tool names, descriptions,
schemas and classes an agent and a grant are checked against. Its projection
is the entry-owned half of a ToolDefinition; `call` is absent by construction
because forwarding to the vendor needs the row's decrypted credential, which
belongs to §4's intake.

Drift is assessed against one upstream tools/list taken with the row's own
credential and cached per row behind a TTL. A pinned tool that is gone is
tool_unavailable; one whose pinned schema or annotations moved toward write is
tool_drift. An upstream tool the entry does not pin is never offered, which is
not an error. A vendor outage is provider_unavailable and is never cached, so a
failed fetch cannot become a window in which every tool reads as unchanged.

ToolDefinition.connectionType gains 'hosted-mcp' and an optional entryId. That
is a type-only edit: its witness is tsc:check, not a test.
@lilyshen0722

Copy link
Copy Markdown
Contributor Author

Author self-audit of 4ae5c4d1, looking for the classes this row has already bitten on (a guard whose key differs from production's key; a premise asserted in a comment but not held anywhere). Two premises checked, no defect found, nothing changed:

  1. The invariant check composes the same key production does. assertHostedMcpEntries builds ${entry.id}.${tool.name}; hostedMcpToolName (hostedMcpEntryService.ts:107) builds exactly that. So the uniqueness check is over the string a grant will actually store, not a parallel spelling of it.
  2. The drift cache's safety argument is held by an index, not by hope. createHostedMcpDriftCache keys on row.connectionId alone and justifies it with "a row belongs to exactly one entry". That is IntegrationSchema.index({ createdBy: 1, 'config.entryId': 1 }, { unique: true, partialFilterExpression: { type: 'hosted-mcp' } }) — models/Integration.ts:430-433. A row therefore cannot be re-pointed at a second entry, so a cached assessment cannot be served for a different vendor's tool list.

One conservatism worth naming rather than fixing: a pin carrying inputSchema: {} against an upstream that omits the field compares {} vs null and refuses as tool_drift. Since pins are taken from a real tools/list at step 7, an omission afterwards is a vendor-side change and refusing is the safe reading — recording it so it is not later mistaken for a bug.

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Sep 29, 2026
Merged via the queue into main with commit fc615c0 Sep 29, 2026
16 checks passed
samxu01 pushed a commit that referenced this pull request Sep 30, 2026
…ange (TASK-181)

Written by sprint-review, a Commonly agent.
Pod thread: https://commonly.me/v2/pods/6a692a1be833c668acdb84cf (message 76019)

ux-lead's non-blocking note on their own part 5, verified before applying.
My sample was `git log --no-merges -60` — 60 first-parent squash positions
on main. Describing it as "#1988-#2053" restated a positional count as a
numeric range, and that range holds 66 merged PRs: the six extras (#1990,
#1991, #1993, #1994, #1996, #1997) are each absent from the 60 and sit at
first-parent positions 61-69, confirmed per PR.

Reworded positionally rather than patching 60 to 66, because the sample was
never a number range and a re-run drifts: the same command today spans
#1988-#2054, #2054 having merged after faf43bb. "60 consecutive squash
commits ending at faf43bb" is re-derivable; a number range is not the thing
that was measured.

The 8 of 8 is the same eight PRs on either set, so no figure moves.

Numbering guard green: 50 rules, 1..50, 52 citations resolve, no lead moved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
lilyshen0722 added a commit to thantiklermcirony/commonly that referenced this pull request Oct 9, 2026
…things are equal (TASK-181) (Team-Commonly#2055)

* docs(review): rule 50 — a fixture supplying only the input where two things are equal (TASK-181)

Written by sprint-review, a Commonly agent.
Pod thread: https://commonly.me/v2/pods/6a692a1be833c668acdb84cf (message 75951)

Filed by sprint-impl from my own generalisation in Team-Commonly#1982's artifact loop,
with the rider-or-rule call left to me. It earns its own number: rule 41's
test asks whether every check the adjacent rule sends you to run passes
here, and for rule 17 all of them do — the fixture calls the real function
with a real catalog, so the shape is genuine and only the discriminating
value is missing.

Demonstrated rather than argued, two arms on `localizeWindow`:
  A. clamp removed, test as it stands  -> 1 failed / 3 total (line 31)
  B. same mutant, only `minutes(1)` cut -> 3 passed / 3 total, GREEN
30s is 0.5min and Math.round(0.5) === 1, so the fixture's only sub-minute
input cannot see the deletion. Totals hold at 3, so neither is a rule-46
collapse. BASE 3/3, RESTORED 3/3.

Two citations in the filed row were wrong and are corrected here: the clamp
landed in Team-Commonly#1981 (79f5cb4), not Team-Commonly#1980, and the killing case is 1ms, not
the 30s originally proposed in that gate.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(review): rule 50 — the discriminating input can be present and dismissed

Written by sprint-review, a Commonly agent.
Pod thread: https://commonly.me/v2/pods/6a692a1be833c668acdb84cf (message 75959)

A second citation for rule 50, earned by its own author within the hour, and
a variant the first draft did not name: the distinguishing case was PRESENT
in the fixture and got filed as an anomaly.

Gating Team-Commonly#2054 I tested `landed == PR title + " (#N)"` across nine squashes,
got 8 of 9, and explained the ninth as a presser overwriting the subject
box. The untested rival was `landed == tip commit subject`. The repo is set
to COMMIT_OR_PR_TITLE: one commit defaults to the COMMIT's subject, 2+ to
the PR title. That column splits the nine perfectly by commit count (4/4 and
5/5), and over the last 60 squashes, where the two texts diverge on a
one-commit PR, the commit subject wins 8 of 8 and the title 0 of 8.

Eight rows agreed with both readings because their candidate strings were
identical. Team-Commonly#2031 was the only row carrying information, and I discarded it.
Caught by ux-lead, who ran the column I skipped.

Numbering guard green: 50 rules, 1..50, 52 citations resolve, no lead moved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(review): rule 50's Team-Commonly#1982 citation — one PASS, and the input caught it

Written by sprint-review, a Commonly agent.
Pod thread: https://commonly.me/v2/pods/6a692a1be833c668acdb84cf (message 75951)

@ux-lead's two corrections on Team-Commonly#2055, both verified here before applying.

1. `07873c19` carried ONE PASS, not two. Enumerated the review list: my CODE
   GATE PASS (22:38:13Z) and ux-lead's UX-GATE FAIL (22:50:18Z), both at that
   head. The two PASSes exist at the NEXT head `83408e61`, after the fix — the
   original sentence conflated the two heads.

2. "ux-lead's render caught what the suite could not" was wrong about the
   mechanism, and wrong in the direction that matters for this rule. Measured:
   BASE 22/22; reverting line 527 to the pre-fix `pod: targetLabel` gives
   1 failed / 21 passed / 22 total; RESTORED 22/22. The suite CAN see it. What
   it lacked at gate time was the seat-target grant, and the test carrying that
   input was added BY the fix (`83408e61`, +24 lines), its own comment calling
   it "the fix's own control".

That is the rule stating itself: the instrument was never blind, the fixture
had no input on which the two readings differ. Sentence replaced with the
literal text ux-lead proposed.

Numbering guard green: 50 rules, 1..50, 52 citations resolve, no lead moved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(review): rule 50 — five corrections from ux-lead's gate (TASK-181)

Written by sprint-review, a Commonly agent.
Pod thread: https://commonly.me/v2/pods/6a692a1be833c668acdb84cf (message 76014)

All five applied with ux-lead's literal text; the two testable ones were
reproduced here first.

1. "every mutation" was false. Arm C, `Math.max(2, …)` on arm B's fixture:
   2 failed / 1 passed / 3 total (BASE and RESTORED 3/3). The equal-only
   fixture greens mutations that ERASE the difference, not every mutation
   of the line.
2. The clamp came in with `d331c11ea` (created localizeRelativeTime.ts,
   +106, diff contains the clamp), not `79f5cb48d` (+51, test file only).
   `git log -S` over the clamp string on main returns Team-Commonly#1981's squash; within
   the branch it is d331c11. 79f5cb4 is the pin and carries the 1ms
   measurement, and is now cited as that.
3. The Team-Commonly#1982 figure regained its head, `faf43bb2` — dropped when I applied
   ux-lead's earlier text.
4. The zh gloss inverted its source: the author's own account says
   `None == None` read as "untranslated in zh", not "already translated".
5. "Eight rows agreed with both readings" was wrong. On my own table only
   three do (Team-Commonly#2015, Team-Commonly#2046, Team-Commonly#2048); the other five agree with the title
   reading alone. Corrected, and the 60-squash anchor now names its window
   (Team-Commonly#1988-Team-Commonly#2053 up to faf43bb).

Numbering guard green: 50 rules, 1..50, 52 citations resolve, no lead moved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* docs(review): rule 50 — the 60 is a positional sample, not a number range (TASK-181)

Written by sprint-review, a Commonly agent.
Pod thread: https://commonly.me/v2/pods/6a692a1be833c668acdb84cf (message 76019)

ux-lead's non-blocking note on their own part 5, verified before applying.
My sample was `git log --no-merges -60` — 60 first-parent squash positions
on main. Describing it as "Team-Commonly#1988-Team-Commonly#2053" restated a positional count as a
numeric range, and that range holds 66 merged PRs: the six extras (Team-Commonly#1990,
Team-Commonly#1991, Team-Commonly#1993, Team-Commonly#1994, Team-Commonly#1996, Team-Commonly#1997) are each absent from the 60 and sit at
first-parent positions 61-69, confirmed per PR.

Reworded positionally rather than patching 60 to 66, because the sample was
never a number range and a re-run drifts: the same command today spans
Team-Commonly#1988-Team-Commonly#2054, Team-Commonly#2054 having merged after faf43bb. "60 consecutive squash
commits ending at faf43bb" is re-derivable; a number range is not the thing
that was measured.

The 8 of 8 is the same eight PRs on either set, so no figure moves.

Numbering guard green: 50 rules, 1..50, 52 citations resolve, no lead moved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5 <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