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.

Specification

_schema
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.
# yaml-language-server: $schema=https://kosli.mintlify.app/schemas/policy/v1.json
_schema: https://kosli.mintlify.app/schemas/policy/v1
artifacts
object
Rules applied to artifacts in an environment snapshot. Omitted keys use server defaults.

Attestation types

ValueDescription
genericGeneric attestation
junitJUnit test results
snykSnyk security scan
pull_requestPull request evidence
jiraJira ticket reference
sonarSonarQube analysis
*Matches any built-in or custom type
custom:<name>A custom attestation type (e.g., custom:coverage-metrics)

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.
if: ${{ flow.tags.risk-level == "high" and matches(artifact.name, "^prod:.*") }}

Operators

OperatorCategoryExample
==Comparisonflow.name == "runner"
!=Comparisonflow.tags.risk-level != "high"
<Comparisonflow.tags.priority < 3
>Comparisonflow.tags.priority > 1
<=Comparisonflow.tags.risk-level <= 2
>=Comparisonflow.tags.risk-level >= 2
andLogicalflow.name == "a" and artifact.name == "b"
orLogicalflow.name == "a" or flow.name == "b"
notLogicalnot flow.tags.risk-level == "high"
inMembershipflow.name in ["runner", "saver"]
Parentheses control precedence: ${{ flow.name == 'prod' and (flow.tags.team == "a" or artifact.name == 'svc') }}.

Contexts

flow
object
Information about the Kosli flow the artifact belongs to.
artifact
object
Information about the artifact being evaluated.

Functions

FunctionDescriptionExample
exists(arg)Returns true if arg is not null.${{ exists(flow) }}
matches(input, regex)Returns true if input matches the regular expression.${{ matches(artifact.name, "^datadog:.*") }}

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

# yaml-language-server: $schema=https://kosli.mintlify.app/schemas/policy/v1.json
_schema: https://kosli.mintlify.app/schemas/policy/v1

artifacts:
  provenance:
    required: true
    exceptions:
      - if: ${{ matches(artifact.name, "^datadog:.*") }}

  trail-compliance:
    required: true

  attestations:
    - name: security-scan
      type: snyk
    - name: pull-request
      type: pull_request
      if: ${{ flow.tags.risk-level == "high" }}
    - name: coverage
      type: custom:coverage-metrics

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:
# yaml-language-server: $schema=https://kosli.mintlify.app/schemas/policy/v1.json
_schema: https://kosli.mintlify.app/schemas/policy/v1

See also

Last modified on April 9, 2026