Appearance
0001. Authorisation model: gate, resource check, grants as a ceiling
Status: accepted. Applies to crates/kernel (bus) and crates/authz (Cedar).
Context
Every command and query goes through the bus and is authorised by Cedar. The input of a request is untrusted: it can name any record, and it cannot prove who owns that record. People act through a role in a tenant (owner, admin, member). API clients and agents act through per-action grants. The System actor runs platform jobs.
Decision
Two checks per request.
- Gate. Before the handler runs, the bus asks Cedar whether the actor may run the action at all. The resource is the tenant (
resource is Tenant). Actors without a membership in the request's tenant are denied before Cedar runs. Unknown tenants get the same denial. - Resource check. The handler loads what it acts on and calls
ctx.authorize(&ResourceRef), which is evaluated withresource is Resource(kind, tenant, owner). The bus refuses to commit a handler that never made this check, unless the handler declaresTENANT_SCOPED = true(it acts on the tenant as a whole, so the gate is the whole decision).
- Gate. Before the handler runs, the bus asks Cedar whether the actor may run the action at all. The resource is the tenant (
Grants are action-level, and they are a ceiling. A grant lets a client or agent pass the gate for that action. Base
forbidpolicies deny any action outside a client's or agent's grants, whatever a module permits. Modulepermits must scope their principal. The loader rejects an unconstrained principal, a bareprincipal is ApiClientorprincipal is Agentwithout a condition, andprincipal is System. The system principal is named explicitly (principal == System::"system").Clients and agents need explicit resource policies. A grant opens the gate only. At the resource level a client or agent is allowed only where a module policy names that principal type for that resource kind. A grant for
sample.note.editdoes not let a client edit someone else's note.Sensitive actions need confirmation from agents, API clients and anyone using the MCP door.
context.confirmedis true only when the MCP door dispatched the attempt after redeeming its one-time confirmation (Bus::dispatch_json_confirmed, refused for any other door); it is recorded on every audit entry. What that step does and does not prove is in ADR 0003.context.dooris only trustworthy as "mcp" or not "mcp". Theclilabel is declared by the client (a header on the GraphQL endpoint), so policies must never comparecontext.doorto anything but"mcp".Managers are row-level only. A
Resourcemay carrymanager(the person its owner reports to, set by the handler from the loaded row withResourceRef::managed_by), so a module can let managers act on or read their reports' records. AFieldnever carries it: the schema has nomanageronFieldandorbit_piiclears it before a field check, so a field policy readingresource.managerfails validation at startup (andresource has manageris always false on a field). Giving managers any personal field needs its own ADR.
Consequences
- A forgotten resource check fails at runtime and in the allow/deny harness, not silently.
- Module authors write two kinds of policy: gate policies (who may attempt) and resource policies (on what). The loader enforces the scoping rules above at startup.
- Clients and agents start with no resource access in a module until that module opts in.
Future
MCP agents acting for a person will carry on_behalf_of. Their effective access will be the intersection of the person's role-based permissions and the agent's grants. This will be modelled as an extra principal attribute and a base ceiling, not as a widened grant.