Agent-readable docs index: /llms.txt. Full docs in one file: /llms-full.txt. Download /docs.zip to grep all markdown files locally.

Policies and Rules

A Dmint policy is a static, declarative JSON document that defines which AI-agent tool calls are allowed, denied, or require human approval. The evaluator is deterministic: it never calls an LLM and never learns from traffic.
Policy rule matches? │ ▼ DENY > APPROVAL_REQUIRED > ALLOW │ └── no rule matches ──► DENY (DMT_DEFAULT_DENIED)

Policy Structure

A policy contains an array of rules. Every rule has a lowercase effect, an exact tool selector, an exact action selector, and optional scoping fields:
policy.json
{ "rules": [ { "effect": "allow", "tool": "database", "action": "query", "resource": "public.*", "resource_kind": "identifier" }, { "effect": "approval_required", "tool": "database", "action": "update", "resource": "public.accounts", "constraints": { "properties": { "amount": { "type": "number", "maximum": 50000 } } } }, { "effect": "deny", "tool": "database", "action": "drop", "resource": "*" } ] }
Validate the file before deploying it:
dmint verify-policy policy.json dmint check -p policy.json -t database.query -r "public.users" dmint policy-digest policy.json
verify-policy is offline and deterministic. policy-digest prints the domain-separated SHA-256 digest used for policy provenance.

The Three Rule Effects

EffectMeaning
allowPermit execution if every matching rule’s conditions and constraints pass.
denyReject execution immediately. The protected function never runs.
approval_requiredPersist one pending request and stop. No tool execution occurs until a trusted human approves the exact request.
Effects are lowercase only. ALLOW, APPROVAL_REQUIRED, and DENY are rejected by the loader and verify-policy.
All three effects are represented by the runtime enum Decision.ALLOW, Decision.DENY, and Decision.APPROVAL_REQUIRED.

Precedence Is Fixed, Not Sequential

Rules are not evaluated first-match-wins. Dmint collects every rule whose selectors, conditions, and constraints match, then applies this fixed precedence:
1. DENY (highest priority) 2. APPROVAL_REQUIRED 3. ALLOW (lowest priority)
Ordering in the JSON file has no effect. A matching deny overrides every matching approval_required and allow; a matching approval_required overrides a matching allow.
This is deliberate: a policy author cannot accidentally widen access by placing an allow before a deny.
If no rule matches, or if a matching rule’s constraint fails, the result is DENY:
CaseDecisionCode
A deny rule matchesDENYDMT_POLICY_DENIED
No rule matchesDENYDMT_DEFAULT_DENIED
A matching rule’s constraints failDENYDMT_CONSTRAINT_VIOLATION
A matching approval_required rule exists (and no deny wins)APPROVAL_REQUIREDDMT_APPROVAL_REQUIRED
Constraint failures do not “fall through” to another rule. If a request matches an allow rule but violates its constraints, Dmint denies the request. To express different handling for different argument ranges, use distinct capabilities (for example billing.issue_small_refund and billing.issue_large_refund) selected by trusted host code, as the tutorial demonstrates.

Selectors

tool and action

  • An exact, case-sensitive string matches the request’s tool or action.
  • "*" is a whole-field wildcard. It matches any tool or action.
  • Partial wildcards such as "read_*" are not supported; use exact values or "*".
Wildcard rules participate in the same fixed precedence as exact rules. A wildcard deny therefore overrides any more specific allow.

resource

The resource selector is optional.
Omitted or NO_RESOURCE"*"Exact string / pattern
Matches only requests with no resourceMatches any resourceMatches the request resource according to resource_kind
A global deny or approval rule must use "resource": "*". Writing Rule.deny("database", "drop") without a resource does not deny resource-bearing calls; it only matches no-resource calls.
Supported resource_kind values are exact, path, url, host, and identifier. The default is derived from the resource value: no-resource for omitted, any for "*", exact for a string. Set case_sensitive only where the chosen kind supports it.

agent_id

agent_id optionally narrows a rule to one principal. Omit it to match every principal.

conditions

Conditions evaluate only against the host-supplied TrustedContext. They never read model output or request arguments.
{ "effect": "approval_required", "tool": "cloud", "action": "deploy", "conditions": [ { "field": "environment", "operator": "equals", "value": "production" } ] }
Supported operators: equals, notEquals, in, contains, startsWith, and endsWith.

constraints

Constraints validate a rule’s argument values. They can be attached to allow and approval_required rules; attaching constraints to a deny rule is rejected. A matching rule with failing constraints produces DENY (DMT_CONSTRAINT_VIOLATION) before any effect is applied.

Complete Example

policy.json
{ "rules": [ { "effect": "allow", "tool": "filesystem", "action": "read_file", "resource": "/var/log/*", "resource_kind": "path" }, { "effect": "approval_required", "tool": "database", "action": "update", "resource": "*", "constraints": { "properties": { "amount": { "type": "number", "maximum": 50000 } } } }, { "effect": "deny", "tool": "*", "action": "*", "resource": "*" } ] }
In this policy the final wildcard deny overrides the first two rules for every request. It is a backstop only if it is intended to make the policy deny everything; usually a catch-all deny is omitted because unmatched requests already fail closed. Prefer an explicit deny for the specific dangerous capabilities you want to document.

Policy Provenance

Every pending approval records the policy version and digest that produced the decision. If the policy changes before the request is retried, Dmint rejects the approval with DMT_APPROVAL_POLICY_INVALID and invalidates the record. This prevents an approval granted under one policy from authorizing execution under another.
Use policy-digest in deployment tooling and pin the value with expected_policy_digest when loading a policy from a remote URL.

Verification Checklist

  1. Run dmint verify-policy policy.json after every edit.
  2. Use lowercase effects.
  3. Put "resource": "*" on any global deny or approval rule.
  4. Do not rely on rule order.
  5. Remember that constraint failure is a deny, not an else branch.
  6. Keep policy.json under version control and rotate its digest deliberately.

Production Policy Templates

Instead of authoring policies from scratch, Dmint provides 7 verified production templates for common operational domains:
  • shell: Safe terminal commands (git, pytest, npm test) allowed; service management (systemctl, docker) approval-gated; destructive commands (rm -rf /, dd, mkfs) denied.
  • filesystem: Path-scoped workspace reads allowed; write operations approval-gated; credentials (.env*, *.key, *.pem, /etc/*) denied.
  • postgres: SELECT and EXPLAIN allowed; mutations and DDL approval-gated; DROP TABLE and TRUNCATE denied.
  • github: Issues and PR reads allowed; PR and issue creation approval-gated; repo deletion and force push denied.
  • stripe: Customer/charge lookups allowed; billing transactions approval-gated; payouts and secret keys denied.
  • aws: Resource inspection allowed; provisioning approval-gated; deletion and termination denied.
  • kubernetes: Pod and log observation allowed; rollouts and scaling approval-gated; cluster deletion denied.
Load templates programmatically via from dmint.templates import get_template_policy, list_templates. See the Policy Templates Reference for full JSON schemas and deduplication rules.