Policy Bundle Schema Reference
Cordum Safety Kernel policies and policy studio bundles share the SafetyPolicy schema (core/infra/config/safety_policy.go). Policies can live in a local signed config/safety.yaml file or in managed Redis bundles under /api/v1/policy/bundles (core/controlplane/gateway/policybundles).
Top-Level SafetyPolicy Fields
| Field | Type | Default / Behavior |
|---|---|---|
version | string | Policy schema version identifier (for example "1"). |
default_decision | string | "deny" (fail-closed) or "allow". Unmatched jobs default to "deny". |
tier | string | Optional bundle scope tier: "global", "workflow", or "job". |
selector | PolicySelector | Optional {workflow_id, job_id, session_id} scope when tier is "workflow" or "job". |
rules | PolicyRule[] | Ordered list of pre-dispatch policy rules (first match wins). |
input_policy | InputPolicyConfig | Controls pre-execution input content scanning (enabled, fail_mode, max_scan_bytes). |
input_rules | InputPolicyRule[] | Pre-execution scanner / pattern / scope rules. |
require_human | RequireHumanThreshold | Downgrades low-confidence / low-severity input "deny" findings to "require_human". |
output_policy | OutputPolicyConfig | Controls post-execution output scanning (enabled, fail_mode). |
output_rules | OutputPolicyRule[] | Post-execution redact / quarantine / deny rules. |
tenants | map[string]TenantPolicy | Per-tenant allow/deny topic lists, repo hosts, concurrency caps, and MCP overrides. |
PolicyRule Schema
version: "1"
default_decision: deny
rules:
- id: require-approval-prod-kubectl
tier: global
match:
topics: ["job.k8s.*"]
capabilities: ["deploy"]
risk_tags: ["production"]
agent_risk_tiers: ["high", "critical"]
labels:
env: "prod"
# Optional: MCP sub-match inside PolicyMatch.mcp
mcp:
deny_tools: ["cordum_revoke_*"]
velocity:
max_requests: 5
window_seconds: 60
key: "tenant:topic"
decision: require_approval # allow | deny | require_approval | allow_with_constraints | throttle
reason: "Production cluster mutations require human sign-off."
constraints:
budgets:
max_runtime_ms: 30000
max_retries: 2
sandbox:
isolated: true
fs_read_only: ["/etc"]
toolchain:
allowed_tools: ["kubectl_get"]
allowed_commands: ["kubectl get"]
diff:
max_files: 10
deny_path_globs: ["**/.env*", "**/prod/**"]
redaction_level: "strict"
remediations:
- id: use-dry-run
title: "Run plan/dry-run instead"
summary: "Submit against the read-only validation topic first."
replacement_topic: "job.k8s.dry_run"
replacement_capability: "plan"
add_labels:
dry_run: "true"
remove_labels: ["mutating"]
Supported match Fields (PolicyMatch)
tenants(string[]) — tenant ID globstopics(string[]) — job topic globscapabilities(string[]) — required worker capabilitiesrisk_tags(string[]) — server-derived or request risk tagsrequires(string[]) — required capability tokenspack_ids(string[]) — installed pack IDsactor_ids/actor_types(string[]) — caller principal IDs and typesagent_risk_tiers/agent_data_classifications(string[]) — agent identity risk/clearancelabels(map[string]string),label_allowlist(map[string][]string),label_threshold(map[string]float64)secrets_present(*bool) — matches when secret detector flags secret materialpredicate(string) &delegation(*DelegationMatch) &mcp(MCPPolicy)
Input & Output Rules (InputPolicyRule / OutputPolicyRule)
Both share scanner and pattern fields:
- Input Decisions:
"deny"|"require_approval"(subject torequire_humandowngrade thresholds:min_severity_for_deny,min_confidence_for_deny,downgrade_when_prompt_only). - Output Decisions:
"allow"|"deny"|"quarantine"|"redact". - Shared Matchers:
tenants,topics,capabilities,risk_tags,scanners,content_patterns,keywords,content_types,detectors(secret_leak,pii,code_injection,custom),max_input_bytes/max_output_bytes,input_size_gt/output_size_gt, plusscope(ScopeConfig) on input rules andhas_erroron output rules.
SecOps Invariant Bundle (secops/invariants)
Managed Policy Studio bundles merge alphabetically with pack overlays, except for the special secops/invariants bundle (core/controlplane/gateway/policybundles/invariants.go):
- Invariant DENY / REQUIRE_APPROVAL / REQUIRE_HUMAN rules are prepended at the front of
merged.Rulesso first-match evaluation short-circuits before any pack or teamallowrule can bypass them. - Invariant ALLOW rules are appended at the back so explicit pack-level
denyrules still win. - Invariant
output_rulesare prepended so quarantine/redact floors cannot be relaxed by pack overlays.
Policy Studio API & Signing
PUT /api/v1/policy/bundles/{id}(PolicyBundleUpsertRequest:content,enabled,author,message) — upserts a YAML bundle and signs it with the configured policy signing key.POST /api/v1/policy/publish(PolicyPublishRequest:bundle_ids,author,message,note) — merges, validates, creates a versionedPolicyBundleSnapshot, and pushes it to Safety Kernel.POST /api/v1/policy/rollback(PolicyRollbackRequest:snapshot_id,author,message,note) — restores a prior snapshot.- CLI signing for file-based bundles:
cordumctl policy sign --in config/safety.yamlandcordumctl policy verify --in config/safety.yaml.
Verify in source →
core/infra/config/safety_policy.go— CanonicalSafetyPolicy,PolicyRule,InputPolicyRule, andOutputPolicyRulestructscore/controlplane/gateway/policybundles/types.go— Policy Studio request/snapshot payloadscore/controlplane/gateway/policybundles/invariants.go—ApplyInvariantsprecedence logic