⚖️ Rules and Approvals

Who May Reach Whom, and What Needs a Person

One rules file per host decides who may message or call your agents and people, and which changes to an agent need a person's approval. Every refusal says why.

Where the rules live

Each host has one rules file, ~/.aimaestro/policy.json. Each host checks its own rules: the sender's host before it sends, and the recipient's host before it delivers. A refusal from the other host comes back to the sender as it is.

With no file, nothing changes: every person may reach every agent, and every agent may message every agent.

The rules apply on every path a message takes: AMP messages (/api/v1/route, including messages from people and from other providers), amp-send on the same machine (it goes through the route), the dashboard and its API, the chat, the companion, device input and calls.

A rules file

{
  "version": 2,
  "default": "allow",
  "rules": [
    {
      "id": "payroll-finance-only",
      "effect": "deny",
      "from": "*",
      "to": "agent:payroll",
      "actions": ["message", "call"],
      "except": [{ "from": "team:finance" }, { "from": "person:alice" }],
      "note": "Payroll answers the finance team only"
    },
    {
      "id": "deletes-need-manager",
      "effect": "ask",
      "from": "*",
      "to": "agent:*",
      "actions": ["agent.delete"],
      "approvers": ["rel:manager"],
      "proof": "signed",
      "expires": "2h",
      "note": "Deleting an agent needs its manager's signed approval"
    }
  ],
  "tests": [
    { "from": "person:bob", "to": "agent:payroll", "action": "message", "expect": "deny" }
  ]
}

A refused message is not delivered, and the sender gets the reason, for example: "person:bob may not message agent:payroll: … Payroll answers the finance team only".

The fields of a rule

FieldMeaning
idA stable name (a-z, 0-9, -), unique in the file. Reasons and logs use it.
effectallow, deny or ask.
from, toA subject, or a list of subjects (any of them).
actionsThe actions the rule covers. Left out: messages and calls.
exceptA list of { from, to, actions }. The rule does not apply when one entry matches.
bothAlso match the other direction.
approversRequired on an ask: who may approve.
proofany (default) or signed: the approval must be a signed reply, not a click in the dashboard.
expiresOn an ask: how long it waits for an answer (30m, 2h, 1d). 30 minutes when left out.
modeenforce (default) or audit: record what the rule would do, but do not apply it. Also allowed at the top of the file, for every rule.
notePlain text, shown in the reason.

At the top of the file: version, default (allow or deny), mode, tests, and logAllows (also record allowed decisions).

Subjects

PatternMatches
*Every person and every agent. AI Maestro itself always passes.
person:*, person:<id>All people, or one person. A person the host cannot name (the dashboard) matches only person:* and *.
agent:*, agent:<name>, agent:<name>@<host>All agents, one agent on any host, or one agent on one host.
team:<name>The agents in a team.
host:<id>Everyone on that host.

Approvers use the same patterns, plus rel:manager (the target agent's manager: its human manager, else its manager agent) and rel:owner (its owner). The sender never approves its own request.

Actions

ActionChecked when
messageA message is sent, on every send path.
callA call starts.
agent.createAn agent is created.
agent.deleteAn agent is deleted.
agent.moveAn agent moves to another host.
agent.modeAn agent's permission mode goes up (for example to full autonomy), on wake or in its settings.
secret.grantAn agent gets a vault credential it could not use before (its credential or its fallback list).

The actions with a dot are governance actions. They are checked in the code that does the action, on the agent's host, so the dashboard, the API and the agents CLI all meet the same rules. A rule without actions, and the file's default, cover messages and calls only: a governance action is governed only by a rule that names it.

How a decision is made

  1. Every rule that applies is found. The order of rules in the file does not matter.
  2. If any of them says deny, the answer is deny. Otherwise, if any says ask, a person must approve. Otherwise, if any says allow, it is allowed.
  3. If no rule applies, the file's default decides (allow unless the file says deny).
  4. Rules in audit mode never change the answer. The reason ends with what they would have done, and the decision log records it.

A file in the older version 1 format (first match wins) still loads, and it gives the same decisions.

Approvals

An ask holds the message as an AMP quarantine entry (reason policy), as the Agent Messaging Protocol describes. The sender gets HTTP 202 with status: "quarantined", and the message is not delivered until someone approves.

  • Each reviewer gets a signed approval request in their mailbox, and a push when their phone is paired.
  • A reviewer approves or rejects in Settings > Approvals, through the API (POST /api/v1/quarantine/{id}/approve or /reject), or by replying to the request with a signed message whose context is { "decision": "approve", "quarantine_id": "qtn_…" }.
  • With "proof": "signed", only the signed reply counts.
  • An approval releases that one message, once. For a call or a governance action, it lets the next identical request through, once.
  • A request expires after 30 minutes, or the rule's expires. The sender gets a signed notice when it is approved, rejected or expired.

Checking your rules

  • GET /api/policy shows this host's rules, the lint warnings (an allow that a deny always covers, a rule that repeats another) and the result of each test in the file.
  • GET /api/policy/check?from=person:alice&to=agent:payroll&action=message answers "why", across every host that decides, without recording anything.
  • Each host keeps a decision log, ~/.aimaestro/policy/decisions.jsonl: one line per refusal, ask and audit hit, with both parties and the rule ids, never the message.
  • The Doctor's policy and policy-approvals checks report a broken file, lint warnings, failing tests and stuck approvals.

A missing, broken or deleted file

  • Each time the file loads, a copy is saved next to it, policy.json.last-good.
  • A file that does not load (bad JSON, an unknown field value) keeps the last version that loaded in force until it is fixed.
  • A deleted file also keeps that saved version in force. To remove every rule, save the file with an empty list: { "version": 2, "rules": [] }.
  • A host that never had a rules file has no rules.

Limits

  • AI Maestro has no login: the network is the trust boundary. A click in the dashboard is recorded as "an unverified person". Use "proof": "signed" when an approval must come from a known person.
  • Agents on one host run as the same operating-system user. The rules stop mistakes and misled agents that use the normal tools. They cannot stop a program that edits files directly. To keep groups of agents apart, give each group its own host or container.

The full specification is docs/SPEC-POLICY-RULES.md. What changed in each version is in the changelog.