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

Policy Schema Specification

This document provides the formal specification for policy definitions evaluated by Dmint Core and generated by the dmint CLI (dmint create-policy / dmint create-mcp-policy).

Core Runtime Policy Mapping

Dmint Core's runtime engine evaluates deterministic policy mappings loaded via Policy.from_mapping().
The direct runtime schema requires {"rules": [...]}:
policy.json
{ "rules": [ { "effect": "allow", "tool": "postgres", "action": "query", "resource": "*" }, { "effect": "approval_required", "tool": "postgres", "action": "update", "resource": "*" }, { "effect": "deny", "tool": "postgres", "action": "drop", "resource": "*" } ] }
Core Runtime Strictness: Dmint Core strictly rejects unknown top-level keys (PolicyError: unknown policy field). Do not include metadata fields such as $schema, name, description, or policy_version in the dictionary passed to Policy.from_mapping(). If your deployment stores human metadata in policy files, that metadata must be stripped or extracted before passing the object into Policy.from_mapping().

Top-Level Fields

FieldTypeRequiredDescription
rulesarrayYesNon-empty array of rule objects evaluated sequentially using fail-closed semantics.
strict_argumentsbooleanNoOptional policy-wide flag (default false). When true, argument constraints default additionalProperties to false across all rules.
tool_schemasobjectNoOptional mapping of <tool>.<action> capability names to pinned SHA-256 JSON Schema digests.

Rule Object Fields

Each element in the rules array defines an authorization rule for an agent action:
FieldTypeRequiredDescription
effectstringYesDecision effect: "allow", "deny", or "approval_required".
toolstringYesTool identifier or namespace (e.g. "postgres", "filesystem", "ledger").
actionstringYesSpecific action or method name (e.g. "query", "transfer", "read").
resourcestringNoTargeted resource string or wildcard ("*"). Defaults to matching requests with no resource concept if omitted.
resource_kindstringNoDeterministic matching engine kind: "exact", "path", "url", "host", or "identifier". Defaults to "exact" if omitted. Unknown values are rejected with PolicyError.
case_sensitivebooleanNoCase sensitivity for resource matching (defaults to true). Only supported for "path" and "exact" kinds; rejected on "host", "url", and "identifier". Set to false on case-insensitive filesystems (macOS, Windows).
agent_idstringNoOptional agent identifier to restrict this rule to a specific agent identity.
conditionsarrayNoOptional trusted context conditions evaluated against environmental attributes.

Resource Matching & Kind Semantics

  • Any Resource ("resource": "*"): Matches any resource specified in the tool request.
  • Exact & Command Prefix/Suffix Matching (resource_kind: "exact" or omitted): Matches the exact string (rule == request.resource), and also supports bounded command prefix/suffix wildcards ("docker *", "rm -rf /*", "* | sh") for shell rules.
  • Path Globs (resource_kind: "path"):
    • * matches characters within a single path segment (does not cross /).
    • ** matches zero or more complete path segments across slashes (e.g. /workspace/**/*.py).
    • Single-character ? is not supported.
    • Path matching is case-sensitive by default. On case-insensitive filesystems (macOS, Windows), configure case_sensitive=False.
  • Identifier Globs (resource_kind: "identifier"):
    • * matches alphanumeric and delimiter characters [A-Za-z0-9_.-]*.
    • Leading and trailing whitespace is rejected.
  • Fail-Closed Pre-Check: If an incoming request's resource cannot be legally normalized for any applicable rule kind in the policy (e.g., path root escape /../, NUL byte \x00, backslash \, encoded traversal %2f/%2e%2e, userinfo in URLs), policy evaluation immediately returns DENY with code DMT_RESOURCE_INVALID before any rule matching.
  • Omission: Omitting "resource" means the rule only matches requests that have no resource concept at all. It does not mean "any resource".

RFC 8785 Numeric Canonicalization

Strict Numeric Representation: Dmint uses deterministic RFC 8785 (JCS) JSON canonicalization to compute cryptographic request fingerprints. Non-finite floats (NaN, Infinity, -Infinity) and integers outside the IEEE 754 safe integer range ([-2^53 + 1, 2^53 - 1]) are strictly rejected with CanonicalizationError (DMT_CANONICALIZATION_ERROR). In parameter constraints (type: "integer"), whole floats like 5000.0 are rejected so integer fields require exact Python int values.

JSON Schema (Core Runtime)

dmint-policy.schema.json
{ "$schema": "https://json-schema.org/draft/2020-12/schema", "title": "DmintPolicy", "type": "object", "required": ["rules"], "additionalProperties": false, "properties": { "strict_arguments": { "type": "boolean" }, "rules": { "type": "array", "minItems": 1, "items": { "type": "object", "required": ["effect", "tool", "action"], "additionalProperties": false, "properties": { "effect": { "type": "string", "enum": ["allow", "deny", "approval_required"] }, "tool": { "type": "string", "minLength": 1 }, "action": { "type": "string", "minLength": 1 }, "resource": { "type": "string" }, "resource_kind": { "type": "string", "enum": ["exact", "path", "url", "host", "identifier"] }, "case_sensitive": { "type": "boolean", "default": true }, "agent_id": { "type": "string" }, "conditions": { "type": "array", "items": { "type": "object", "required": ["field", "operator", "value"], "additionalProperties": false, "properties": { "field": { "type": "string" }, "operator": { "type": "string", "enum": ["equals", "notEquals", "in", "contains", "startsWith", "endsWith"] }, "value": {} } } }, "constraints": { "type": "object", "additionalProperties": false, "properties": { "type": { "type": "string", "enum": ["object"] }, "required": { "type": "array", "items": { "type": "string" } }, "additionalProperties": { "type": "boolean" }, "properties": { "type": "object", "additionalProperties": { "type": "object", "additionalProperties": false, "properties": { "type": { "type": "string", "enum": ["string", "number", "integer", "boolean", "array", "object"] }, "minimum": { "type": "number" }, "maximum": { "type": "number" }, "exclusiveMinimum": { "type": "number" }, "exclusiveMaximum": { "type": "number" }, "minLength": { "type": "integer", "minimum": 0 }, "maxLength": { "type": "integer", "minimum": 0 }, "pattern": { "type": "string" }, "enum": { "type": "array", "minItems": 1 }, "minItems": { "type": "integer", "minimum": 0 }, "maxItems": { "type": "integer", "minimum": 0 }, "items": { "type": "object" }, "required": { "type": "array", "items": { "type": "string" } }, "additionalProperties": { "type": "boolean" }, "properties": { "type": "object" } } } } } } } } } } }