Definition
An approval gate is a policy decision that stops an agent action before execution and releases it only after an authorized person approves that specific request. In Cordum the decision is REQUIRE_APPROVAL. See also human-in-the-loop.
Key takeaways
- Gate before dispatch. An approval recorded after the action ran is incident documentation.
- Gate by risk: allow reads, constrain bounded work, hold irreversible actions, deny what should never happen.
- Bind each approval to the exact request and the policy version, and re-check both when the approval is used.
- Make approve calls and retries idempotent, so a timeout never runs an action twice.
- Keep the evidence: who approved, which rule required it, and how long the action waited.
Where the gate sits
A gate only works if the agent cannot route around it. Framework-level approvals pause a tool call inside the agent process. Microsoft Agent Framework, for example, marks a tool with approval_mode="always_require" and by default binds the approval response to the pending request; its documentation warns that turning that binding off "can let a fabricated or replayed response approve a privileged tool call." Binding matters wherever the gate lives.
An out-of-process gate keeps the decision outside the agent: the agent asks, a policy engine decides, and only an approved request is released. Cordum holds the action at three enforcement points:
| Surface | Where the action is held | How the agent continues |
|---|---|---|
| Coding agents (Claude Code via Cordum Edge) | PreToolUse hook, before the tool runs | The hook returns a Claude-compatible deny with an approval_ref. After approval, the agent retries the same action. |
| MCP tool calls | Cordum MCP server, before the call reaches the tool | JSON-RPC error -32099 carries the approval ID. The same call succeeds once it is approved. |
| Platform jobs | Gateway submit check, before the job is published | The job is stored as APPROVAL_REQUIRED and not published. Approval releases it to the scheduler. |
Step 1: Classify actions by risk
Approval is the most expensive decision you have, because it spends a person's attention. Reserve it for actions that are hard to undo, and give everything else a cheaper decision.
| Action class | Decision | Approver | Rule below |
|---|---|---|---|
| Reads: search, list, describe | ALLOW | None | reads-allow |
| Bounded work: egress to known hosts, staging changes | ALLOW_WITH_CONSTRAINTS | None; limits enforced | egress-constrained |
| Production writes, deploys, git push to shared branches | REQUIRE_APPROVAL | Service owner or on-call engineer | prod-write-require-approval |
| Payments, treasury transfers, access grants | REQUIRE_APPROVAL | Finance or treasury approver; two approval steps for two-person rules | payments-require-approval |
| Never acceptable: secret reads, destructive shell commands | DENY | Nobody | claude-code.deny-secret-reads |
Cordum also has THROTTLE for rate problems, such as an agent retrying the same mutation in a loop (rate-based velocity rules need an Enterprise license). It answers "how often", not "whether".
Step 2: Write the rules as policy
For coding agents, start from the Edge pack. This rule holds git push until someone approves it; Edge classifies the shell command into command.family before the rule is evaluated.
# examples/cordum-edge-pack/overlays/policy.fragment.yaml (excerpt)
rules:
- id: claude-code.require-approval-for-vcs-push
match:
topics:
- job.edge.action
capabilities:
- exec.shell
risk_tags:
- git
labels:
"command.family": git_push
decision: require_approval
reason: "Publishing repository state with git push requires approval."Platform jobs use the same schema. This policy covers the risk tiers from step 1, including the treasury case:
version: approvals-v1
default_decision: deny
rules:
# First match wins: keep specific rules above broad ones.
- id: reads-allow
match:
topics: ["job.*.read", "job.*.list"]
decision: allow
- id: payments-require-approval
match:
topics: ["job.payments.*", "job.treasury.*"]
decision: require_approval
reason: "Money movement needs a named approver."
- id: prod-write-require-approval
match:
risk_tags: ["write"]
labels:
env: production
decision: require_approval
reason: "Production writes need service-owner approval."
constraints:
budgets:
max_runtime_ms: 300000
- id: egress-constrained
match:
capabilities: ["net.http"]
decision: allow_with_constraints
reason: "Outbound HTTP only to approved hosts."
constraints:
sandbox:
network_allowlist: ["api.github.com"]- First match wins. Keep
default_decision: denyso an unmatched action is not silently allowed. The Edge demo pack usesdefault_decision: allow; do not copy that into production. - Match semantics.
risk_tagsmatches when any tag overlaps,labelsmust all match exactly, andcapabilitiesmust contain the job's capability. - Version.
versionbecomes the prefix of the policy snapshot ID, which is what approvals bind to in step 6. - Constraints survive approval. A
require_approvalrule can carryconstraints; the approved job still runs inside them. - Where the rules live. On every tier, the policy file (
SAFETY_POLICY_PATH,config/safety.yamlby default) and pack fragments load. Admin-authored policy bundles managed through the API need a Team or Enterprise license.
Test a rule before rollout. Simulation evaluates a request against the loaded policy without running it:
curl -s --cacert "$CORDUM_TLS_CA" \
-H "X-API-Key: $CORDUM_API_KEY" -H "X-Tenant-ID: $CORDUM_TENANT_ID" \
-H "Content-Type: application/json" \
-X POST "$CORDUM_GATEWAY/api/v1/policy/simulate" \
-d '{"topic": "job.treasury.transfer", "meta": {"capability": "payments.transfer", "risk_tags": ["payment", "write"]}}' \
| jq '{decision, ruleId, reason}'
# {
# "decision": "DECISION_TYPE_REQUIRE_HUMAN",
# "ruleId": "payments-require-approval",
# "reason": "Money movement needs a named approver."
# }Step 3: Hold the action before it runs
For platform jobs, the gateway evaluates policy at submit time, before it stores or publishes anything. The outcomes are explicit:
- Deny:
403, and the job is recorded as denied. - Throttle:
429withRetry-After: 30. - Require approval:
200withstatus: approval_required. The job is stored asAPPROVAL_REQUIREDwith its decision record (rule, reason, policy snapshot, request hash) and is not published to the scheduler.
export CORDUM_GATEWAY=https://localhost:8081
export CORDUM_TLS_CA=./certs/ca/ca.crt
export CORDUM_TENANT_ID=default
export AGENT_API_KEY="replace-with-the-agent-key"
curl -s --cacert "$CORDUM_TLS_CA" \
-H "X-API-Key: $AGENT_API_KEY" -H "X-Tenant-ID: $CORDUM_TENANT_ID" \
-H "Content-Type: application/json" \
-X POST "$CORDUM_GATEWAY/api/v1/jobs" \
-d '{
"topic": "job.treasury.transfer",
"prompt": "Pay invoice INV-0042 to Acme Supplies",
"capability": "payments.transfer",
"risk_tags": ["payment", "write"],
"idempotency_key": "pay-inv-0042",
"context": {"amount": 25000, "currency": "USD", "vendor": "Acme Supplies"}
}'
# 200 OK
# {"job_id": "…", "reason": "Money movement needs a named approver.", "status": "approval_required"}If the tenant uses a topic registry, the topic must be registered, or the gateway returns 400 unknown_topic. Keep POLICY_CHECK_FAIL_MODE at its default, closed, so a Safety Kernel outage rejects jobs instead of letting them through.
Coding agents under Edge
Claude Code hooks cannot block for long, so Edge uses deny-and-retry. A REQUIRE_APPROVAL decision returns a deny with an approval_ref; a reviewer approves it in Cordum (or calls POST /api/v1/edge/approvals/{approval_ref}/approve), and the agent retries the same action. Edge approvals expire after 20 minutes by default, and callers can only shorten that.
Do not rely on inline waiting with the defaults. CORDUM_AGENTD_INLINE_APPROVAL_WAIT_TIMEOUT defaults to 30 seconds, longer than Claude Code's 5-second hook deadline; when the hook times out, Claude Code fails open without a warning. Keep the wait under 5 seconds, disable it, or use deny-and-retry.
Step 4: Give the reviewer a decision brief
A reviewer who cannot see what the action does will either block everything or approve everything. Put the decision in front of them with the rule that triggered it:
export REVIEWER_API_KEY="replace-with-the-reviewer-key"
# Pending items only (the list includes resolved ones by default)
curl -s --cacert "$CORDUM_TLS_CA" \
-H "X-API-Key: $REVIEWER_API_KEY" -H "X-Tenant-ID: $CORDUM_TENANT_ID" \
"$CORDUM_GATEWAY/api/v1/approvals?include_resolved=false" \
| jq '.items[0] | {job, decision, policy_rule_id, policy_snapshot, approval_status, decision_summary}'
# More context for one item
curl -s --cacert "$CORDUM_TLS_CA" \
-H "X-API-Key: $REVIEWER_API_KEY" -H "X-Tenant-ID: $CORDUM_TENANT_ID" \
"$CORDUM_GATEWAY/api/v1/approvals/$JOB_ID/context" \
| jq '{blast_radius, prior_approvals, policy_snapshot_summary, time_remaining_ms}'{
"job": { "id": "…", "state": "APPROVAL_REQUIRED", "topic": "job.treasury.transfer" },
"decision": "REQUIRE_APPROVAL",
"policy_rule_id": "payments-require-approval",
"policy_snapshot": "approvals-v1:4c1e…",
"approval_status": "pending",
"decision_summary": {
"title": "Approve 25000 USD request with Acme Supplies",
"why": "Money movement needs a named approver.",
"amount": 25000,
"currency": "USD",
"vendor": "Acme Supplies"
}
}decision_summary is built from the job's context. Fields such as amount, currency and vendor become the title, and the policy reason becomes the "why". The context endpoint adds up to 10 prior approvals for the same topic and the time left before the job's deadline, next to the blast radius (from the job's labels), rollback hint and policy summary that every queue item carries. Have your agents send the business facts a reviewer needs; a bare prompt makes a poor brief.
Step 5: Approve with separation of duties
# Approve (or POST .../reject with the same body)
curl -s --cacert "$CORDUM_TLS_CA" \
-H "X-API-Key: $REVIEWER_API_KEY" -H "X-Tenant-ID: $CORDUM_TENANT_ID" \
-H "Content-Type: application/json" \
-X POST "$CORDUM_GATEWAY/api/v1/approvals/$JOB_ID/approve" \
-d '{"reason": "Matches PO-7781 and the vendor master", "note": "Checked by treasury"}'
# 200 {"job_id": "…", "trace_id": "…"}
# Same call again: 200 {"approved_at": …, "approved_by": "…", "job_id": "…", "status": "already_approved", "trace_id": "…"}
# With the agent's key: 403 {"code": "self_approval_denied", "error": "self-approval not permitted", "status": 403}
# CLI equivalent
cordumctl approval job "$JOB_ID" --approve- Approving needs the
jobs.approvepermission or the admin role. Give agents keys without it. - The approver cannot be the submitter: the gateway compares identities and returns
403 self_approval_denied. MCP approvals use the same guard. reasonandnoteare redacted and length-limited before they are stored, so a pasted secret does not end up in the record.- For two-person rules, such as a large treasury transfer, use two approval steps in a workflow. Multi-approver gates need a Team license; approval steps that depend on each other (custom chains) need Enterprise. Community supports a single approver per gate.
Step 6: Bind the approval to the request and the policy
An approval is a statement about one request under one policy. If either changes, the approval should stop working. Cordum checks both wherever the approval is used:
- Request hash. The decision record stores a hash of the request. On approve, the gateway re-hashes the stored request inside a transaction; a mismatch returns
409 approval_stale_request. - Policy snapshot. If the policy changed since submission, the gateway re-evaluates the request against the current policy as the original requester. If the result is still allow, allow with constraints, or require approval, the approval proceeds with the refreshed snapshot and an audit entry records the refresh. Otherwise it returns
409 approval_stale_snapshot. - Pending approvals. The scheduler's reconciler invalidates pending approvals whose request hash or policy snapshot no longer matches, so stale items leave the queue.
- Dispatch. The scheduler skips its own policy check only when the hash and the approved snapshot both match. Otherwise it emits
approval.revision_mismatchand runs a full check. - Edge and MCP. Edge binds approvals to the action hash, input hash and policy snapshot, and each approval is consumed once. MCP approvals store a SHA-256 of the arguments and are consumed once.
Snapshot comparisons use the base policy hash, so a config-overlay change alone does not invalidate approvals. Workflow approval steps are gates in the workflow definition rather than policy decisions, so snapshot binding does not apply to them.
| 409 code | Cause | What to do |
|---|---|---|
| approval_stale_request | The stored request no longer hashes to the approved value. | Submit a new request; it gets its own approval. |
| approval_stale_snapshot | The policy changed and the request no longer passes it (for example, it is now denied), or the original requester cannot be resolved. | Follow the new decision. Do not force the old approval. |
| approval_retryable_lock | Another approve or repair call holds the job lock. | Retry; the response carries retryable: true. |
| approval_already_resolved | The job already left the approval state. | Read the job state; nothing to do. |
| approval_terminal_run | The workflow run that owns the approval already finished. | Start a new run if the work is still needed. |
Step 7: Make approvals and retries idempotent
Approval flows break under retries: a timed-out approve call, an agent that resubmits, a worker restart.
- Submit with an idempotency key. A retry with the same
idempotency_keyreturns the existingjob_idandapproval_required, so the reviewer sees one item, not three. - Approve is idempotent. Approve runs under a per-job lock. A repeat call returns
already_approvedwith the original approver; a concurrent call gets409 approval_retryable_lockand should retry. - Approved work is not lost. If a job is approved before a worker can take it, the pending replayer dispatches it later.
- Make the side effect idempotent too. Scheduler retries can run an approved job again after a worker failure. Pass the job ID as the idempotency key to the payment or deploy API, so the second run is recognized as a duplicate.
Step 8: Keep the evidence and measure the queue
Every gate leaves records: the submit decision (safety.decision with require_approval), the approval or rejection (safety.approval, or the Edge and MCP equivalents) with the approver's identity, and the policy version in force. They land in the same hash-chained audit stream; the AI agent audit trail guide covers verification, retention and SIEM export.
Then measure the queue, because a slow gate gets bypassed:
# Approval outcomes and time to approve, per rule, for the last 30 days
curl -s --cacert "$CORDUM_TLS_CA" \
-H "X-API-Key: $CORDUM_API_KEY" -H "X-Tenant-ID: $CORDUM_TENANT_ID" \
"$CORDUM_GATEWAY/api/v1/governance/approvals/analytics?window=30d&group_by=rule" \
| jq '{summary: (.summary | {total, approved, rejected, expired, p50, p90}), groups: [.groups[] | {key, total, p90_seconds}]}'A rule with a high approval rate and long waits is a candidate for constraints instead of a human. A rule with many rejections is catching real problems; keep it, and fix the agent behavior behind it.
When agents act for other agents
If one agent hands work to another, the job can carry a delegation token (delegation_token). With CORDUM_DELEGATION_POLICY_ENABLED=true, rules can match on the chain under match.delegation (max_depth, issuers, required_scope, forbid_delegated), and the scheduler re-checks the token before dispatch, so a token revoked or expired after approval still stops the job. See the delegation docs.
Tradeoffs
- Latency. Every gate adds a human wait. Gate irreversible actions only, and watch p90 time to approve per rule.
- Policy churn. Strict binding means policy releases invalidate pending approvals. Batch policy changes and tell reviewers when they ship.
- Rubber-stamping. A busy queue trains reviewers to click approve. Cut volume by tightening rules before adding reviewers.
- Approval is not a sandbox. An approved action runs with whatever credentials it has. Keep least privilege and constraints in place.
- Fail-open settings.
POLICY_CHECK_FAIL_MODE=open, Edgeobservemode, orenforcewithoutCORDUM_AGENTD_FAIL_CLOSEDlet actions through when Cordum is unavailable. Choose that deliberately.