policy_ref. Bundles are versioned and immutable: a published name@version always resolves to the exact same Rego, so a sandbox config can pin a policy that can never silently change underneath it.
This page covers the admin side — publishing bundles, referencing them, managing the registry, and setting a non-bypassable account-wide floor. For writing the Rego itself, see Authoring custom policy. For curated, framework-aligned bundles you can enable without writing any Rego, see Governance Packs.
Custom policy bundles build on declaw’s non-bypassable platform floor (which already blocks living-off-the-land commands, kernel-module loading, and cloud-metadata/IMDS access). Every bundle is compile-checked against that floor at publish time. A bundle can only add denials — it can never relax the platform defaults.
Publish a bundle
POST /admin/accounts/<account_id>/policy-bundles with a name, a version, and the Rego modules that make up the bundle:
Validation rules
- Compile-checked. The modules are compiled together with the platform floor at publish time, so a bundle that does not compile is rejected with
400before it is stored — never at sandbox-create time. - Size limit. A bundle’s canonical bytes may not exceed 1 MiB. Larger bundles are rejected at publish (they would otherwise be unresolvable on the read path).
- Versions are immutable. A
name@versionis write-once. Re-publishing the same content is idempotent (returns the samecontent_hash), but re-publishing aname@versionwith different content returns409 Conflict— the existingsha256_refis included in the error so you can see what is already pinned there. To ship a change, publish a new version (acme-baseline@v4).
Reference a bundle from a sandbox
A sandbox references a bundle throughcustom_policy.policy_ref. There are three reference forms, all resolving against declaw-controlled storage only (there is no arbitrary URL fetch):
Resolution precedence
Aname@version ref is resolved at sandbox-create time as follows:
- Look up
(your account, name, version)in the registry. - If not found, fall back to the shared
platformaccount (this is how built-in governance packs resolve, and how a platform team can publish org-wide baselines once). - If still not found, the create fails with
400(a genuinely missing ref is a client error, not a server error).
content_hash is then fetched from the content-addressed store and the Rego is appended to the sandbox’s policy. sha256: and blob: refs skip the registry entirely and read the object directly.
Versioned name vs. sha256 — which to use. Use
name@version for production: it is account-scoped, readable, and the natural unit you bump and roll out. Use sha256:<hex> when you need an absolute immutable pin — the content address can never resolve to anything but those exact bytes, even if a registry pointer is later deleted or repointed. (The sha256: and blob: forms are content-addressed-global by design: they read the dedicated, non-tenant-writable policy bucket and ignore the account, so confidentiality of policy text under these forms rests on hash opacity, not access control — hashes are not secrets. For per-account isolation, use name@version.)Manage published bundles
name, version, content_hash, policy_ref, sha256_ref, and created_at. A missing bundle returns 404.
Set an account-wide policy floor
To enforce a policy on every sandbox an account creates — with no per-sandbox change and no way for a sandbox to opt out — set the account floor:
You can set
policy_ref, inline_rego, or both — an enabled floor needs at least one. Inline Rego is compile-validated synchronously (a broken module returns 400 here); a policy_ref is validated lazily at sandbox-create time, since the referenced bundle may be published independently.
The floor is non-bypassable. The account floor is merged into every sandbox’s policy as an additional module at create time. A sandbox’s own
custom_policy can add rules on top, but it cannot remove or override the account floor — bundle denials are additive and tighten-only.Related
- Authoring custom policy — writing the Rego gates (
cmd,net,content,lifecycle) that go into a bundle. - Governance Packs — curated, framework-aligned bundles (OWASP, NIST, EU AI Act, …) you can enable without writing Rego.
- Compliance reporting — per-account denial evidence grouped by control, framework, and gate.