Skip to main content
An environment policy is a YAML file that declares compliance requirements for artifacts running in a Kosli environment. You pass the file to kosli create policy to create or update a policy. For concepts, workflow, and enforcement, see Environment Policies.
Prefer to build a policy interactively? Use the Policy builder to assemble a valid policy file in your browser and copy the YAML.

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:
  • flow is missing for any artifact reported without provenance.
  • flow.tags.<key> is missing for a tag the flow does not have.
The comparison operators (==, !=, <, >, <=, >=), 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

  • _schema is the only required field. All other fields are optional and use server defaults when omitted.
  • An attestation rule must not have both name and type set 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

Last modified on September 7, 2026