kosli create policy to create or update a policy. For concepts, workflow, and enforcement, see Environment Policies.
Specification
string
required
Version identifier and JSON Schema URL for the policy format. The final path segment must match
/v{n} where n is a supported major version. Currently only v1 is supported.object
Rules applied to artifacts in an environment snapshot. Omitted keys use server defaults.
Attestation types
Policy expressions
Expressions are boolean conditions evaluated against flow and artifact context. They are wrapped in${{ }} and can appear in if and exceptions[].if fields.
Operators
Parentheses control precedence:
${{ flow.name == 'prod' and (flow.tags.team == "a" or artifact.name == 'svc') }}.
Contexts
object
Information about the Kosli flow the artifact belongs to.
object
Information about the artifact being evaluated.
Functions
Missing values
A value is missing when the context does not supply it. This is common rather than exceptional:flowis missing for any artifact reported without provenance.flow.tags.<key>is missing for a tag the flow does not have.
==, !=, <, >, <=, >=), the membership operator in, and the functions exists() and matches() all evaluate to false when either operand is missing. A missing operand is not an error — the comparison is simply not satisfied.
To branch on whether a value is present at all, test it with exists() rather than relying on a comparison against it.
Constraints
_schemais the only required field. All other fields are optional and use server defaults when omitted.- An attestation rule must not have both
nameandtypeset to*. - Expressions must evaluate to a boolean. An invalid expression causes a policy evaluation error.
Example
Editor validation
The_schema URL resolves to a JSON Schema for the environment policy format. To enable inline validation and autocomplete in VS Code (requires the YAML extension) and other schema-aware editors, add a yaml-language-server directive:
See also
- Policy builder — build a policy file interactively in the browser
- Environment Policies — concepts, workflow, and enforcement
kosli create policy— create or update a policykosli attach-policy— attach a policy to an environmentkosli assert artifact— enforce policies on an artifact- Terraform: kosli_policy — manage policies via Terraform