Skip to main content

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​

FieldTypeDefault / Behavior
versionstringPolicy schema version identifier (for example "1").
default_decisionstring"deny" (fail-closed) or "allow". Unmatched jobs default to "deny".
tierstringOptional bundle scope tier: "global", "workflow", or "job".
selectorPolicySelectorOptional {workflow_id, job_id, session_id} scope when tier is "workflow" or "job".
rulesPolicyRule[]Ordered list of pre-dispatch policy rules (first match wins).
input_policyInputPolicyConfigControls pre-execution input content scanning (enabled, fail_mode, max_scan_bytes).
input_rulesInputPolicyRule[]Pre-execution scanner / pattern / scope rules.
require_humanRequireHumanThresholdDowngrades low-confidence / low-severity input "deny" findings to "require_human".
output_policyOutputPolicyConfigControls post-execution output scanning (enabled, fail_mode).
output_rulesOutputPolicyRule[]Post-execution redact / quarantine / deny rules.
tenantsmap[string]TenantPolicyPer-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 globs
  • topics (string[]) — job topic globs
  • capabilities (string[]) — required worker capabilities
  • risk_tags (string[]) — server-derived or request risk tags
  • requires (string[]) — required capability tokens
  • pack_ids (string[]) — installed pack IDs
  • actor_ids / actor_types (string[]) — caller principal IDs and types
  • agent_risk_tiers / agent_data_classifications (string[]) — agent identity risk/clearance
  • labels (map[string]string), label_allowlist (map[string][]string), label_threshold (map[string]float64)
  • secrets_present (*bool) — matches when secret detector flags secret material
  • predicate (string) & delegation (*DelegationMatch) & mcp (MCPPolicy)

Input & Output Rules (InputPolicyRule / OutputPolicyRule)​

Both share scanner and pattern fields:

  • Input Decisions: "deny" | "require_approval" (subject to require_human downgrade 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, plus scope (ScopeConfig) on input rules and has_error on 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):

  1. Invariant DENY / REQUIRE_APPROVAL / REQUIRE_HUMAN rules are prepended at the front of merged.Rules so first-match evaluation short-circuits before any pack or team allow rule can bypass them.
  2. Invariant ALLOW rules are appended at the back so explicit pack-level deny rules still win.
  3. Invariant output_rules are 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 versioned PolicyBundleSnapshot, 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.yaml and cordumctl policy verify --in config/safety.yaml.
Verify in source →
  • core/infra/config/safety_policy.go — Canonical SafetyPolicy, PolicyRule, InputPolicyRule, and OutputPolicyRule structs
  • core/controlplane/gateway/policybundles/types.go — Policy Studio request/snapshot payloads
  • core/controlplane/gateway/policybundles/invariants.go — ApplyInvariants precedence logic