Skip to content

feat(mcp): read an agent's permission edges and self-change grants (abilityai/trinity-enterprise#991) - #4122

Merged
vybe merged 2 commits into
devfrom
feature/ent991-mcp-edges-grants
Oct 31, 2026
Merged

vybe merged 2 commits into
devfrom
feature/ent991-mcp-edges-grants

Conversation

@vybe

@vybe vybe commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes abilityai/trinity-enterprise#991. Draft until its checks and validation are in.

What

  • New src/mcp-server/src/tools/permissions.ts with 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 carries observed_within: "caller_reach_with_container", so an edge the caller cannot see never reads as a removed edge. available_agents is dropped.
    • get_agent_capability_grants: an agent's self-change grants. A refused read is an explicit refusal, never "no grants".
  • Tool counts recounted from 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.ts pins 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)

  • Grants stay owner-tier. An agent key reads itself and agents it spawned, and an edge peer is refused. This is narrower than the issue's "its edges". A person key stays owner or admin (ent#756), which is narrower than "its reach". No read widens in this PR, and whether either should change is left to the operator. The edges read meets the issue's wording on both key types.
  • Permissions payload is edges only. Hidden edges are labelled rather than counted.
  • The client.ts split (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, the observed_within label, 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 --noEmit clean. Python suites covering the router headers and route census: 156 passed. The full unit island is left to CI.

Before merge

  • A sibling PR adding an MCP tool goes red on the count pin at merge. Recovery is the three numbers on line 3 of docs/user-docs/integrations/mcp-server.md plus one table row.
  • abilityai/trinity-enterprise#1007 (items 1, 6, 7) stacks on this branch.

Handoffs

  • /api/agents/permissions-edges swallows Docker faults as edges: []. A fleet-wide edge tool needs a strict mode there first.
  • get_agent_permissions_logic does not call the connector-scope check. MCP cannot reach it today.

🤖 Generated with Claude Code

Trinity Agent (trinity) and others added 2 commits October 31, 2026 00:19
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]>

@trinity-ability trinity-ability 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.

/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, and tsc --noEmit is clean.
  • My own mutation, the production wiring: I deleted the createPermissionTools(...) line in server.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.ts is a guard. It reads the doc as text, but it compares that text against a live createServer() 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:

  1. 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".
  2. The narrowing is honest. The access row is baselined on the real OwnedAgentByName fence instead of an enforce row 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").
  3. 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: the paths: filter in mcp-server-test.yml leaves out docs/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. CAPABILITIES has 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

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.

2 participants