Rules
Where: Rules in the sidebar (#/rules); a specific rule at
#/rules/<rule_id>. Rule ids cited elsewhere in the app (on proposals, gap
reports and Maturity) link here.

Rules is the inventory of the policy your proposals are judged against. It is read-only. Rules are authored as Rego in Git: the constitution arrives as a signed bundle, and your own rules come from your platform repo. This screen shows what your runner actually loaded.
What you see
- The gate, as a strip: Agent drafts → OPA evaluates → allow → PR / deny → re-propose → You approve.
- + Draft a rule with the Coordinator, which opens the Workspace chat.
- The list (left): a search box (rule id, description, package or
category), a source filter (All, Constitution, Overlay; a
source appears only if it has rules) and a kind filter (All,
Structural, Behaviors). Each row shows the rule id, a
constitutionoroverlaypill and the description. - The detail (right):
- the rule id, source pill and a provenance badge (Open · Apache-2.0 for the constitution, Your overlay for yours) and the description;
- impact tiles (proposals blocked, services affected, last fired), currently showing dashes;
- Enforced outcome · Rego: the rule’s Rego source;
- Paired recipe: a placeholder, with the tooling categories the rule would cover.
What it means
The constitution is the set of rules TruStacks authors, signs and
publishes from the public, Apache-2.0
trustacks-policy
repository. Every proposal must satisfy it. It is not waivable.
Your overlay is rules your team adds. Overlay denies are added to the
constitution’s denies, so an overlay can only make the gate stricter, never
looser. From runner 0.2.14 the runner enforces this: every overlay rule must
be package overlay.<name>, and an overlay that reaches outside
data.overlay is rejected, with no verdict, until it is fixed. Earlier
runners did not check. The full rules are in
the constitution reference.
Your rule’s scope is enforced, from policy 1.11.0 / runner 0.2.21. A
rule’s denies count only when the proposal’s tier is in its tier_scope
and its target kind is in its target_kinds, so a ["prod"] rule no longer
needs to check input.context.target.tier itself. A missing or invalid
scope means “any”: the rule still enforces. A rule scoped to a specific tier
or kind is skipped where there is no deployment target, such as the repo
audit, so a repo-audited rule uses ["any"]. Constitution rules keep their
own logic. See
Where your rule applies.
Overlay rules are enforced on every proposal but do not count toward your Maturity headline, which is computed from constitution rules alone. What only your rules ask for shows on Maturity under Your rules. An overlay rule that reuses a constitution rule id, or a reserved namespace, is dropped from the inventory (and logged by the runner).
The kind filter separates two families:
- Structural rules check the shape of a proposal: it only writes to allowed paths, has no path traversal, includes a workflow, a Helm chart or Kustomization as the renderer requires, an ArgoCD Application, and that ArgoCD points at your canonical platform repo.
- Behaviors rules check how the emitted artifacts behave: the workflow has a test step and a lint step, production ArgoCD Applications use manual sync, containers run as non-root, and actions are pinned to commit SHAs. These are also the evidence behind the behavior rows on Maturity.
Your overlay rules are filed by the kind their rule_metadata declares
(structural or behavior). A rule that predates the
metadata schema and declares no
kind is filed as before, by whether it lists practice dimensions, and
carries a warning saying so.
Some rules never deny and only feed the score (for example, whether image scanning is declared). The constitution reference lists every rule.
Where the list comes from. Each runner reports the rules it loaded. The control plane serves that list; it never reaches into your cluster to ask.
What to do here
- When a proposal is denied, click the cited rule id to read exactly what it checks.
- Use the search to answer “is there a rule for X?” before writing one.
- Pair this screen with Overview → Policy in force, which shows how often each rule actually refused a proposal.
- To add a rule, see Add your own rule.
Add your own rule
You land a rule the way you land any other change: a pull request on your platform repo that a person on your team reviews and merges. The Coordinator drafts it, TruStacks checks it and opens the PR, and you decide whether it merges.
1. Ask for the rule
In the Workspace chat (or + Draft a rule with the
Coordinator on this screen), type /rule new followed by what the rule
should deny, in plain English, or by a rule id of your choice:
/rule new deny workflows without explicit permissionsThe Coordinator drafts the rule and its test cases: at least one input the
rule must deny and one it must allow. It writes the cases as data, and
TruStacks turns them into rules/<rule_id>/<rule_id>_test.rego, so a draft
can’t arrive without both kinds of case. The Coordinator sees the rules
already in rules/ in your platform repo, with their descriptions, so it
doesn’t redraft one you have.
What a rule can see. The gate judges each proposal on what it carries:
- the files the proposal writes (path, content, language) and its explanation (summary, blast radius, rollback, cited rules);
- the deployment target (name, tier
dev,uatorprod, kind), the renderer, the CI system and the platform repo URL; - the tooling categories your Stack file declares.
Anything else, such as a ticket number in another system or the state of an external service, is outside what the gate can see. When you ask for that, the Coordinator says so and drafts the closest rule the gate can check instead. For example: the prod deploy job requires an approval environment, not a ServiceNow ticket exists.
2. TruStacks checks every draft
Each draft is formatted with opa fmt and placed in a copy of your
platform repo’s whole rules/ tree, as it would be after the merge. Then it
goes through the same checks, in the same sandbox, the runner applies when
it loads your rules:
- the rule id meets the naming standard
and the package is
overlay.<rule_id>(the dot as an underscore); - no symlinks, within the size cap, and confined to
data.overlay; - it compiles together with the constitution and your other rules, under the runner’s restricted builtins (no network, no environment);
rule_metadatanames the rule, and no other rule uses the same package or rule id;rule_metadatadeclares every required field, with values in the schema:kind,required_tooling_categories,practice_dimensionsfor a behavior rule,tier_scopeandtarget_kinds;opa testpasses over the wholerules/tree.
A draft that fails goes back to the Coordinator with the errors, and the
Coordinator revises it, up to 3 tries. The chat narrates each check:
checked the draft: it compiles in the runner’s sandbox and passes its N
tests, or the draft failed its checks, so I’m revising it. A passing
draft’s checks include rule_metadata declares kind behavior and its
scope (or structural). The finished draft shows the
rule, its _test.rego under the cases it was tested against, and a line
Checked by TruStacks listing what passed. A draft that never passes is
shown as it is, can’t be proposed, and says why.
3. Check what it would have blocked
Under the draft, Would it have blocked my recent proposals? replays your Application’s recent proposals through the policy engine with and without the draft. See Check what a draft would have blocked.
4. Propose as PR
Propose as PR opens one pull request on your platform repo with:
rules/<rule_id>/<rule_id>.regoandrules/<rule_id>/<rule_id>_test.rego, exactly as checked;.trustacks/opa-capabilities-v1.15.2.json, the runner’s own list of allowed OPA builtins;- the first time, a CI job for the CI system your Stack file declares,
which runs
opa fmt,opa checkandopa testoverrules/on every change, with the capabilities file, the runner’s OPA version (checked against its release checksum) and an empty environment. It needs no secret.
| CI system | The job TruStacks adds |
|---|---|
| GitHub Actions | .github/workflows/trustacks-rules.yaml |
| Azure Pipelines | azure-pipelines/trustacks-rules.yml |
| GitLab CI | .gitlab/ci/trustacks-rules.yml |
If the job or the capabilities file is already in the repo, it is left alone. Before it opens the PR, the runner clones your platform repo at its default branch and checks the files again, as they will land.
The PR body says what the rule denies, why, what kind of rule it is and
where it applies (its tiers and, when it names them, its target kinds),
what was checked, and any setup still left to you. The kind is given in
plain words with the kind the rule declares beside it: a
posture rule (kind: structural) checks what your Stack file declares,
a practice rule (kind: behavior) judges how a change’s files behave,
and any other structural rule (kind: structural) checks the shape of a
change.
- GitHub: make the
opa test rules/check required on your default branch. GitHub only offers the check after it has run once, so do this after the PR’s first run. - Azure DevOps: register the pipeline, run it once, then add it as a required build validation policy on your default branch.
- GitLab: TruStacks never creates or edits your root
.gitlab-ci.yml. The PR body gives you theinclude:line to add (or the whole file, if the repo has none), and asks you to turn on Pipelines must succeed for merge requests.
The chat shows the PR link. Clicking Propose as PR again for the same draft shows the PR that is already open; it doesn’t open a second one.
5. Merge it
A person on your team reviews and merges the PR. TruStacks never merges it,
and nothing in this flow merges itself. From the next run after the merge (a
proposal or a gap analysis), the runner reads rules/ from the default
branch and enforces the rule. It appears on this screen as Your overlay.
Every time it loads your rules, the runner checks them again: confined to
data.overlay, compiles with the constitution, within the size cap, and
rule_metadata values within the schema. CI
doesn’t do the confinement and constitution checks; the runner does. If
anything fails, none of your rules load for that run, the constitution still
applies, and the reason is recorded. Every verdict records the commit your
rules were read from. The full rules, including the branch the runner reads,
are in
the constitution reference.
Your rules in the repo audit
Each analysis of a service also audits the
service repo’s own Dockerfiles, CI workflows and ECS task definitions,
whoever wrote them. A rule of yours is part of that audit when its
rule_metadata declares "subjects": ["proposal", "repo"]. A repo has no
deployment target, so from policy 1.11.0 / runner 0.2.21 the audit only
runs a rule whose tier_scope and target_kinds are both ["any"]. The audit
reads rules/ from your Application’s platform repo at the commit its
environment-profile.yaml was read from, with the same checks as a
proposal; a signed overlay bundle still takes precedence. Its denials
arrive on Signals as findings that read Your overlay
rule <rule_id> (the platform repo’s rules/ at <commit>) denies this file
in the repository itself. The audit never fails the analysis. Details are
in the constitution reference.
Without the chat: the rule CLI
You can also write the rule yourself in a checkout of your platform repo, as
rules/<rule_id>/<rule_id>.rego and rules/<rule_id>/<rule_id>_test.rego
with package overlay.<name>. Scaffold it with trustacks rule new, then
check it with trustacks rule test and trustacks rule lint, which use the
same restricted builtins the runner uses. Declare the full
rule metadata; lint refuses a rule
without it:
package overlay.acme_requires_explicit_workflow_permissions
import rego.v1
rule_metadata := {
"acme.requires_explicit_workflow_permissions": {
"description": "Workflows must declare top-level permissions explicitly",
"kind": "structural",
"required_tooling_categories": [],
"practice_dimensions": [],
"tier_scope": ["any"],
"target_kinds": ["any"],
"subjects": ["proposal", "repo"],
},
}
rule_index := rule_metadata
deny contains msg if {
some f in input.proposal.files
startswith(f.path, ".github/workflows/")
not regex.match(`(?m)^permissions:`, f.content)
msg := {
"rule_id": "acme.requires_explicit_workflow_permissions",
"message": sprintf("workflow %s must declare top-level permissions: explicitly", [f.path]),
}
}"subjects": ["proposal", "repo"] also makes the rule part of the
repo audit: each analysis judges the
service repo’s own workflows with it, not only TruStacks’ proposals. See the
Rule CLI. Rules are Rego only: put lists inside the
rule, not in JSON or YAML data files beside it. Open the pull request
yourself; merging it enforces the rule from the next run, the same as a
proposed one.
The policy authoring workshop walks through a rule end to end in a local development environment.
How it connects
- Every proposal is judged against these rules; denials cite them by id.
- Every analysis audits the service repo’s
own delivery files with the rules that declare
repoinsubjects, yours included. See Your rules in the repo audit. - Gap analyses and Maturity use each rule’s metadata (the categories and behaviors it scores).
- The bundle a runner loads, and whether it was verified, is described in the Policy in force reference.
Beta limits
- Source needs a recent runner. Rego source is reported by runner 0.2.14 and later (and pre-releases from 0.2.14-rc24). Runners 0.2.14-rc21 to rc23 report which rules they enforce but not the Rego, and the detail says so and suggests upgrading on Runners. Runners older than that report no rules.
- Impact tiles and paired recipes are not built. They are labeled coming soon. For real denial counts, use the Overview.
- Your overlay needs runner 0.2.17. Earlier hosted runners load no rules from your platform repo, so they show constitution rules only.
- Propose as PR needs runner 0.2.18. With an older runner, the chat says No connected runner can open a rule’s PR yet. Upgrade your runner. See Runners. Drafts are checked by the runner, so a draft written before the upgrade can’t be proposed; draft it again.
- A draft is written in one pass. You can’t refine a draft turn by turn.
- Declared metadata needs runner 0.2.19. From that release every new
draft declares its
kind,tier_scopeandtarget_kinds, and the repo audit applies your rules. A rule already inrules/without them keeps loading, with a warning. The warning is in your runner’s policy state report and on the Rules API; the Rules page doesn’t show it. - “deny → re-propose” in the gate strip describes the loop, not an automatic retry: after a deny, someone starts a new proposal.
- If the list is empty, the empty state refers to
make policy-bundle, which is a local-development command. On the hosted service, an empty list usually means your runner is older than the rule-reporting release; upgrade it.