Skip to content

M31A policies are TOML files parsed by the core policy engine. The loader is packages/core/src/policy/toml-loader.ts; evaluation is in policy-engine.ts and config.ts.

File discovery ​

ScopePath
Built-in defaults<core package>/policies/
User~/.m31a/policies/
Workspace<project>/.m31a/policies/
System/adminmacOS /Library/Application Support/M31A/policies, Windows C:\ProgramData\m31a\policies, Linux /etc/m31a/policies
Extension<extension>/policies/
UI "always allow"auto-saved.toml in user or workspace policies directory

A policy path may be a directory (only files ending in .toml are read, non-recursively) or a single .toml file. Missing paths contribute no rules. Additional paths come from policyPaths, adminPolicyPaths, --policy, and --admin-policy.

Minimal rule ​

toml
[[rule]]
toolName = "glob"
decision = "allow"
priority = 100

Rule fields ​

FieldTypeNotes
toolNamestring or arrayRequired. * matches all tools; arrays expand into one rule per name.
decisionstringRequired. allow, deny, or ask_user.
priorityintegerRequired, 0..999; converted to tier + priority / 1000.
subagentstringMatches subagent identity.
mcpNamestringConverts the rule to a fully-qualified MCP tool name.
argsPatternstringRE2-compatible regex matched against stable JSON of tool arguments.
commandPrefixstring or arrayOnly with run_shell_command; mutually exclusive with argsPattern and commandRegex.
commandRegexstringSame restrictions as commandPrefix.
modesarrayOptional filter: default, autoEdit, yolo, plan.
interactivebooleantrue = interactive sessions only, false = non-interactive only.
toolAnnotationstableEvery key/value must match the tool's annotations.
allowRedirectionbooleanCamelCase wins; deprecated allow_redirection accepted.
allowCommandSubstitutionbooleanCamelCase wins; deprecated form accepted.
denyMessagestringMessage shown when the rule denies a call.

Example rules ​

toml
# Allow all read-only search tools in every mode.
[[rule]]
toolName = ["glob", "grep_search", "read_file", "list_directory"]
decision = "allow"
priority = 100
modes = ["default", "autoEdit", "plan"]

# Permit a narrowly scoped shell command.
[[rule]]
toolName = "run_shell_command"
commandPrefix = "git status"
decision = "allow"
priority = 220

# Block a destructive command pattern with a helpful message.
[[rule]]
toolName = "run_shell_command"
argsPattern = "(?s).*rm\\s+-rf.*"
decision = "deny"
priority = 300
denyMessage = "Destructive removal is blocked by workspace policy."

Tier precedence ​

Rules are sorted by descending effective priority and the first matching rule wins. Priority bands encode scope strength:

TierScope
1.xBuilt-in defaults
2.xExtensions
3.xWorkspace
4.xUser
5.xAdmin

So admin rules outrank user rules, which outrank workspace, extension, and built-in rules. Generated rules occupy known slots: excluded MCP servers 4.9, --exclude-tools 4.4, confirmation-required 4.35, --allowed-tools 4.3, core tools 4.25, trusted MCP 4.2, allowed MCP 4.1, and "Always Allow" 3.95 (workspace band).

Match semantics ​

  • Tool names match exactly, by wildcard, or through legacy aliases.
  • For invoke_agent, the subagent name is injected as a virtual alias so rules can target a specific agent.
  • mcpName identity is checked strictly against server metadata.
  • No matching rule means ask_user interactively and deny non-interactively. In yolo mode the default becomes allow.
  • Shell commands also pass redirection and command-substitution checks.
  • Extensions cannot contribute allow or YOLO rules.

Safety checkers ​

Policies may also define [[safety_checker]] entries with a [safety_checker.checker] sub-table:

  • type = "in-process" with name of allowed-path, conseca, or plan-mode-command-guard,
  • type = "external" with any command name,
  • optional required_context and config.

Sandbox policy ​

A separate schema in ~/.m31a/policies/sandbox.toml controls process sandbox behavior with [modes.plan|default|accepting_edits] sections (network, readonly, approvedTools, optional allowOverrides, yolo) and a [commands] table keyed by normalized command. The packaged fallback is sandbox-default.toml.

Inspecting and testing ​

bash
m31a --policy ./policies --policy ./more-policies

In-app, use /policies list to see effective rules. Start in a scratch workspace with a deny rule before deploying a policy broadly.

Next steps ​

See Policy evaluation, Approval modes, and Hook events.

Built with VitePress. Powered by NVIDIA NIM.