MAQPNADocs

maqpna policy compile

Compile policies to Cedar, CEL, Rego or AgentCore that decide exactly as MAQPNA does, or refuse what cannot be expressed

Govern-o json | yaml

Synopsis#

maqpna policy compile --to cedar|cel FILE|DIR... [--out FILE] [--namespace NS] [-o json]
maqpna policy compile --to rego FILE|DIR... [--package maqpna.authz] [--bundle-out DIR] [--out FILE] [-o json]
maqpna policy compile --to agentcore --manifest GATEWAY.json FILE|DIR... [--schema-out FILE] [--out FILE] [-o json]

Description#

From the help of maqpna policy:

Policy files: ToolPolicy custom resources (YAML or JSON, several per file, or a List) and the operator-rendered policies.json bundle are both accepted. ToolPolicies are rendered with the operator's own renderer (pkg/policyload), so a test evaluates exactly what the gateway would load. A ToolPolicy that the operator would refuse to publish (bad regex, timezone, Cedar, ...) is an error.

Suite mode: policy test DIR runs every maqpna-test.yaml under DIR (FILE runs that suite). A suite is:

  apiVersion: maqpna.com/v1alpha1
  kind: PolicyTest
  name: coder                      # optional
  policies: [../policies/]         # files or dirs, relative to the suite
  defaults: {namespace: team-a, agent: coder, user: [email protected]}
  cases:                           # one tool call each
    - name: prod writes blocked
      server: kubernetes
      tool: delete
      args: {namespace: prod-eu}
      expect: deny
      expectRule: k8s-no-prod-mutations
  tasks: []                        # optional multi-step tasks (maqpna eval format)

Exit status 3 when a case fails (or, with --require-tests, a policy file is not covered by any suite).

compile translates the policies to Cedar (MAQPNA's Cedar schema, config/cedar/maqpna.cedarschema) or to one CEL expression over a "request" map that evaluates to allow, require_approval or deny, so other platforms can enforce the same decisions. The result decides exactly as MAQPNA does, or compile refuses: a construct the target cannot express (when, schedule, sinks, scopes, toolLabels, toolPins, embedded Cedar; for Cedar also '?' globs and globs over groups or taints) is an error naming the rule. What the target does not enforce (rate limits; for CEL, approval requirements; argMatch type caveats) is printed as a warning.

--to rego compiles to one Rego v1 module for OPA whose "decision" rule is the object MAQPNA's own Rego backend reads ({"action", "policy", "rule", "reason", "approval"}), over the input the gateway sends its OPA sidecar (policy.ExternalInput): run it with OPA standalone, or as the gateway's OPA sidecar (gateway.json policy.rego.url .../v1/data/maqpna/authz/decision). Approval requirements are carried. Rego also compiles character classes that cannot match '/'. --bundle-out DIR writes an OPA bundle (.manifest rooted at the package).

--to agentcore compiles for AWS Bedrock AgentCore Policy: one Cedar statement per AgentCore policy (-o json lists name, description and statement for CreatePolicy), against AgentCore's schema (OAuthUser principal with JWT claims as tags, one action per gateway tool, the gateway ARN as resource, the tool's typed input as context.input). The manifest gives the gateway ARN and, per MAQPNA server, the AgentCore target and its MCP tools with input schemas; server and tool conditions are decided per tool at compile time. Session taints, the substrate and (unless "approvalAsDeny") require_approval have no AgentCore counterpart and are refused.

push --to agentcore compiles the same way and reconciles the result into an AgentCore policy engine (AWS credentials from the environment, IRSA or EKS Pod Identity). It lists the engine's policies, plans creates, updates and deletes for the ones this owner pushed (name prefix maqpna_ and an owner marker in the description), and prints the plan with each statement's SHA-256. Policies MAQPNA did not create are never changed; a name taken by one is reported as a conflict. --apply executes the plan, tightening changes first; a rerun with the same policies changes nothing.

Flags#

FlagTypeDescriptionDefault
--bundle-outstringrego: also write an OPA bundle (.manifest and <package path>/policy.rego) to DIRnone
--manifeststringagentcore: the gateway manifest (gatewayArn, targets with their MCP tools; see docs/integrations/policy-export.md)none
--namespacestringnamespace of ToolPolicies without metadata.namespacedefault
--outstringwrite the compiled policy to FILE (default: stdout)none
--packagestringrego: the module's package (query data.<package>.decision)maqpna.authz
--schema-outstringagentcore: also write the Cedar schema AgentCore derives from the manifest, for local validationnone
--tostringtarget: cedar, cel, rego or agentcorenone

The global flags (--context, -o, --no-color, ...) work with every command.

Examples#

# Enforce the same decisions elsewhere: compile to Cedar, CEL or Rego
maqpna policy compile --to cedar policies/ --out maqpna.cedar
maqpna policy compile --to cel policies/coder.yaml -o json
maqpna policy compile --to rego policies/ --bundle-out opa-bundle/
maqpna policy compile --to agentcore --manifest gateway-manifest.json policies/ -o json

What happens when you run it#

  • Prints a table by default; -o json or -o yaml print the data, and --jq EXPR filters the JSON.

Exit codes#

CodeMeaning
0success
1error (the message says what failed, with a hint when there is one)
2usage error: unknown flag, missing argument or bad value; the synopsis is printed
3a check failed, a change is blocked, or a result did not match (tamper, policy mismatch) (not used by this command)