Repository navigation
feat(mcp): read an agent's permission edges and self-change grants (abilityai/trinity-enterprise#991) - #4122
Conversation
Two read-only tools in tools/permissions.ts: - get_agent_permissions → GET /permissions?strict=true; edges only (the caller's roster is dropped), labelled observed_within so an edge outside the caller's view never reads as removed; a Docker fault stays an error. Access row: enforce on agent_name (self ∪ edge ∪ spawned). - get_agent_capability_grants → GET /capability-grants, verbatim. The route keeps its owner-tier scope (ruling T1 = A): the row is baselined on the OwnedAgentByName fence, not enforce, and a refused peer reads as refused, never as "no grants". No backend change, no write tools. Fixes the checkAgentEdge docstring (/permissions → /reach). Requirements note in requirements/mcp.md. Mutation: removing the createPermissionTools registration turns the three real-transport cases in permissions.test.ts red. Refs abilityai/trinity-enterprise#991 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…erver (ent#991) Recounted from the createServer() registration (inline auth on, the way the docs count): 175 tools across 39 modules, 170 operator + 3 connector + 2 sign-in. Written to every quoting site, which disagreed four ways (169, 168, 121, ~80): integrations/mcp-server.md, faq/mcp-and-api.md, user-docs README, getting-started/overview.md (x2), CLAUDE.md, AGENTS.md. The Tool Categories table gains the permissions.ts row and corrects three stale rows found by the recount: memory.ts 1→2 (search_memory), nevermined.ts 4→6, projects.ts 13→14. Key Tools gains get_agent_permissions / get_agent_capability_grants. Router # mcp: headers: agent_files.py names permissions.ts for the /permissions read; agent_config.py names it for the capability-grants GET, everything else there stays unexposed. Feature-flow notes in self-change-grants.md and agent-to-agent-collaboration.md; catalog row in architecture/mcp-server.md. T5 pin: src/mcp-server/src/tool-count-docs.test.ts holds line 3 (total, modules, operator) and the table sum/row count to the registration; editing line 3 to 174 turns it red. Refs abilityai/trinity-enterprise#991 Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
/validate-pr: APPROVE (Lane B, no schema)
Head 1dc0d7753 → dev. 18 files (+562/−16). Fixes abilityai/trinity-enterprise#991, which is a cross-tracker reference. The issue must be set to status-in-dev by hand after merge, because auto-promotion only works within the same repo.
| Check | Verdict |
|---|---|
| Commits / base / size | ✅ conventional, targets dev, 18 files |
| Requirements / arch / flows | ✅ requirements/mcp.md MCP-EDGES-GRANTS-READ, architecture/mcp-server.md catalog, both feature-flow notes, and both # mcp: router headers (Invariant #13) |
| Security §4.1–4.10 | ✅ no keys, emails, IPs, host paths or mode changes. The enterprise-docs guard pattern finds nothing in the added lines |
| Packaging | ➖ no new backend dir, no new env var |
| Structural review | ✅ /review + /cso --diff both ran (Fable): 0 critical, 0 supported findings |
| Merge gate (Tier 1) | ✅ every PR check green, including pytest (head) and regression diff. dev-ci on dev is success, and no issue is titled dev-ci red |
| Execution coverage | ✅ see below |
| Product fit | ✅ approved issue (status-ready), scope matches, read-only, no write tools |
Execution coverage (re-run independently in job-worktree.sh open --pr 4122)
npm test: 1080/1080, andtsc --noEmitis clean.- My own mutation, the production wiring: I deleted the
createPermissionTools(...)line inserver.ts. Eight tests went red: the access-policy totality, the T5 doc count, and the three real-transport gate cases. The composition root is pinned. /review's five mutations (strict flag, grants row class,observed_within, 404 rewrite, doc count) were each already shown red.tool-count-docs.test.tsis a guard. It reads the doc as text, but it compares that text against a livecreateServer()count, which is the allowed shape.
T1: the recorded narrowing of "its edges"
I agree with it. The issue's DoD says an agent key sees "itself, its edges and the agents it spawned". For grants, this PR stays at self ∪ spawned under agent keys. I think that is right, for three reasons:
- An edge means "may call", not "may manage" (ent#629). Letting an edge open a management-state read would bring back exactly the owner-equivalence class that
agent_may_reach(manage=True)closed. The route census also pins this route as "never through an edge". - The narrowing is honest. The access row is
baselinedon the realOwnedAgentByNamefence instead of anenforcerow that would over-claim. An out-of-scope target comes back as an explicit "Refused … not 'no grants'" error, so a reconciler cannot read invisible as absent. That is the property the issue exists for ("observed, never inferred"). - The DoD's purpose, a reconciler observing every row, is still met through a person-scoped key.
One note: T2 is a second, smaller narrowing against "a person key sees its reach". Grants under a person key stay owner/admin (ent#756), not any shared user. The PR body names only the agent-key narrowing. I agree with T2 too (it is an earlier explicit ruling), but the operator should know that both halves of the DoD sentence were narrowed for grants. For edges, the DoD is met literally on both key types.
Non-blocking
⚠️ (I1) The count pin can be skipped: thepaths:filter inmcp-server-test.ymlleaves outdocs/user-docs/integrations/mcp-server.md, so a docs-only count edit never runs the pin. Worth a one-line follow-up.- Suggestion: "all five capabilities" is hard-coded in the tool description.
CAPABILITIEShas five members today, so it is correct, but it will drift silently when a sixth is added. - The PR is still a draft. Its stated condition ("until its checks and validation are in") is now met.
- A sibling PR that adds a tool will go red on the count pin when it merges. That is by design, and the recovery is mechanical (described in the PR body).
🤖 Generated with Claude Code
Fixes abilityai/trinity-enterprise#991. Draft until its checks and validation are in.
What
src/mcp-server/src/tools/permissions.tswith two read-only tools over routes that already exist:get_agent_permissions: an agent's permission edges, always with?strict=true, so a Docker fault is an error and never an empty list. It carriesobserved_within: "caller_reach_with_container", so an edge the caller cannot see never reads as a removed edge.available_agentsis dropped.get_agent_capability_grants: an agent's self-change grants. A refused read is an explicit refusal, never "no grants".createServer(): 175 tools across 39 modules, written to every site that quotes them, with three wrong per-module rows corrected.src/mcp-server/src/tool-count-docs.test.tspins the documented count to the registered tools.No backend logic changed, no schema change, no write tools.
Rulings carried (orchestrator, on the operator's behalf)
client.tssplit (refactor: domain-split mcp-server client.ts (1,500 lines) and tools/agents.ts #1029) is deferred; this adds two methods to it.Review + security
/review(Fable, report-only): MERGEABLE, no critical findings. Five mutations each turned a pinning test red: the strict flag, the grants access row, theobserved_withinlabel, the 404 rewrite and the doc count./cso --diff: no supported findings.Informational, not fixed here: the MCP workflow's path filter excludes the doc page the count pin reads, so a docs-only count change does not run the test. Five other count sites stay hand-maintained.
Tests
cd src/mcp-server && npm test: 1080/1080,tsc --noEmitclean. Python suites covering the router headers and route census: 156 passed. The full unit island is left to CI.Before merge
docs/user-docs/integrations/mcp-server.mdplus one table row.Handoffs
/api/agents/permissions-edgesswallows Docker faults asedges: []. A fleet-wide edge tool needs a strict mode there first.get_agent_permissions_logicdoes not call the connector-scope check. MCP cannot reach it today.🤖 Generated with Claude Code