Forgecroft Docs
Guides / Governance

Policy Sets

Group Rego policies into sets scoped to your organization, projects, or individual workspaces.

What Is a Policy Set?

A policy set is a named collection of Rego policies with a shared enforcement mode and scope.

Scope Hierarchy

Policy sets can be scoped to three levels:

ScopeApplies ToCreation Requirement
Org (global)All workspaces in the orgOrg owner or admin role
ProjectWorkspaces within a projectwrite access at project scope
WorkspaceSingle workspacewrite access at workspace scope

Only one scope level should be set. If workspace_id is provided, project_id must match the workspace’s parent project.

Creating a Policy Set

POST /policy-sets
{
  "name": "production-safety",
  "description": "Policies for production workspaces",
  "enforcement": "mandatory",
  "profile": "terraform",
  "project_id": "proj-uuid"
}
FieldTypeRequiredDefaultDescription
namestringYesMust be unique within scope
descriptionstringNoHuman-readable description
enforcementstringNomandatorymandatory or advisory
source_typestringNodbdb (policies stored in DB) or git (policies from Git)
profilestringNoterraformterraform, kubernetes, security, or custom
project_idUUIDNoProject scope
workspace_idUUIDNoWorkspace scope
git_pathstringNoUsed when source_type is git

Adding Policies

POST /policy-sets/{id}/policies
{
  "name": "no-destroy-prod",
  "description": "Prevent destroying production databases",
  "rego_source": "package forgecroft.policy\n\ndeny[msg] { ... }"
}

The Rego source is validated by compiling it and running against a stub input. It must:

  1. Contain package forgecroft.policy
  2. Have at least one of deny or require_approval rules
  3. deny must return an array of strings
  4. require_approval must return an array of objects

Updating a Policy Set

PATCH /policy-sets/{id}
{
  "enforcement": "advisory",
  "enabled": false
}

Mutable fields: enforcement, enabled, description, profile. At least one field must be provided.

Deleting a Policy Set

DELETE /policy-sets/{id}

Requires admin access at the set’s scope (stricter than write). Global sets require org owner/admin.

Effective Role

When listing or getting policy sets, the response includes effective_role based on your access:

Git-Sourced Policy Sets

Set source_type: "git" and provide git_path to load policies from a Git repository instead of storing them in the database. This is useful for:

Listing Policy Results for a Run

GET /runs/{runId}/policy-results

Returns all policy evaluation results for a specific run, including which policies passed or failed and their violations.