ADR-0041: The command declaration: a capability with its toolset, exposure, route and surfaces, in a static catalog¶
Status: Accepted Date: 2026-11-01 Deciders: Alex Nodeland Implements: RFC-0014's P2, P3 and P4, and its first Tracking item (#916); beside ADR-0032
Context¶
RFC-0014 makes every action a person can take in portalr a command, declared once, which portalr, an MCP or ACP client and a browser agent all reach. RFC-0011's capability registry already declares the part the enforcer needs: name, version, schemas, tier, effects, reversibility, gate, limits and risk class (ADR-0032). A surface needs more:
- the toolset a client turns on;
- whether a read is also a resource;
- portalr's route that a result links to;
- the surfaces a command is offered on.
The parity test, the schemas and the docs must read every package's commands without a database.
Decision¶
lattice_core.commands, no extra, importing only the standard library, pydantic andlattice_core.capabilities:Commandis aCapabilityplustoolset,exposure,route,resourceandsurfaces, as RFC-0014 gives it. It is refused unless:- its capability is a
commandcapability; - its name is
<package>.<name>, one dot, lowercase, digits and underscores, whose tool name fits MCP's 64 characters; - a resource exposure names its URI template, and a URI template is exposed as a resource;
- it is offered on some surface.
- its capability is a
ToolsetandSurfaceare RFC-0014's literals, andexposureistool,resource,bothorNotExposedwith a reason, which the parity test asks for.Commandsis a package's static catalog,commands(), with no I/O and no scope.WatchandResourceChangedare what a bound provider answers for resources that change.tool_name(name)is the MCP tool name,<package>_<name>.catalog(*catalogs)composes catalogs by name, and refuses two commands of one name or of one tool name, such asa_b.canda.b_c.CONTRACT = "1.0.0"andschemas/commands.v1.json, as the other contracts have.
- A breaking change is a new command,
<package>.<name>_v2, beside the old one, which is deprecated in its description and kept for a release (RFC-0014's P4). - Each package's catalog comes in its own change: grantr's and artifactr's first (RFC-0014's phase 1), each a
commandsmodule, published asschemas/<package>.commands.json. So does the parity test.
Options considered¶
Option A: A command is a capability plus surface metadata (chosen)¶
Pros: one type for the enforcer and every surface. A command is called only through the enforcer, so grantr, integrations, tiers, limits, taint, approval and audit hold for it as for any capability. Cons: a capability that is no command, such as a connector's action, has no toolset or route until something declares one.
Option B: Metadata held by portr¶
Cons: portalr and the parity test would read portr's tables to know what a command is, and a package's commands would be declared in two places.
Consequences¶
- Easier: a package declares a command once, and the enforcer, portr, portalr's client and the docs each read what they need of it.
- Harder: a command's name and tool name are public. Renaming one is a new command and a deprecation, and
lattice:breakssees each catalog once it is published. - To revisit: whether a capability other than a command (a connector's action, an MCP server's tool) is ever offered through a toolset, which would generalize
Command.
Action items¶
-
lattice_core.commandsand its schema, tested. - grantr's and artifactr's catalogs,
grantr.commandsandartifactr.commands, with their schemas. - The parity test,
tests/test_parity.py, andx-lattice-commandon every operation (RFC-0014's P13).
Amendment (2026-11-01)¶
Command gains tenant_wide, false by default, and lattice_core.commands moves to contract 1.1.0 (ADR-0044). A tenant-wide command, such as artifactr.list_workspaces or any of grantr's, is called with a scope that names no workspace and is checked on the tenant. It is refused if its route or its resource names {workspace}.