# Policy file

Describes Keryn 0.5.2 and keryn-rules 0.8.0.

> The policy-as-code format, generated from its JSON Schema, with the bundled templates.

Source: https://keryn.dev/docs/reference/policy/

A policy turns an AI-BOM into a pass, a warning or a failure: which providers and components are allowed, what needs review, what a change against the base may add. Use it with `keryn scan --policy <file>` or `keryn policy check <bom.json> --policy <file>`, and validate it with `keryn policy lint <file>`.

Schema: [`https://keryn.dev/schemas/policy/v1.json`](https://keryn.dev/schemas/policy/v1.json).

> **Caution: Reference mapping only**
> Templates that name a framework (EU AI Act, NIST AI RMF, ISO/IEC 42001) carry a `references:` block that points readers to clauses. The engine ignores it. A passing policy run is not a compliance determination; what a framework requires of a system is a question for counsel and your assessor.

## Keys

| Key | Type | Required | Description |
|---|---|---|---|
| `apiVersion` | `"keryn.dev/policy/v1"` | yes |  |
| `rules` | array of object | yes |  |
| `aiUsage` | array of object |  | Organization AI coding-tool rules evaluated against attribution evidence in keryn attribution scan. |
| `waivers` | array,null |  |  |
| `name` | string |  |  |
| `description` | string |  |  |
| `references` | array,null |  | Framework references for the document as a whole: framework, clause id, URL. Documentation only, ignored by the engine; a reference is a pointer for readers and never a compliance determination. |
| `release` | object,null |  | D-16 release decision. `require_signature: true` makes an unsigned Go a Hold (exit 1) until a person runs `keryn decide sign`; the signature is a record in .keryn/releases.jsonl. |
| `licenses` | object,null |  | The licence of every locked dependency (keryn scan) against SPDX lists. A package passes when at least one choice its expression offers (`MIT OR GPL-3.0-only`) uses only licences that are not denied and, with `allow`, all allowed. Violation rule ids: licenses.deny, licenses.allow (error), licenses.unknown (per `unknown`). Waivable like any rule; component = `&lt;ecosystem>:&lt;name>@&lt;version>`, or `&lt;ecosystem>:&lt;name>` for every version. |
| `changes` | object,null |  | What a prompt or model change found against a base (`--base`, the LSP base) does: `allow` (default) nothing, `review` a warning violation, `block` an error violation. Violation rule ids: changes.prompt, changes.model; waivable like any rule (component = the head component's key). Without a base there are no changes to judge. |

## Templates

Copy one, edit the provider lists (the ones shown are placeholders), then lint it.

### agent-tools.yml

```yaml
# Reference mapping only; not a compliance determination.
# The references block names framework clauses a reader may want to consult next to the rules below. The engine ignores it.
# Provider and name lists are placeholders: edit them to your organisation before use.
apiVersion: keryn.dev/policy/v1
name: agent-tools
description: Agent frameworks, MCP servers and LLM gateways - guardrail required beside an agent framework, MCP and gateway components surfaced for review.
references:
  - {framework: "NIST AI RMF 1.0", id: "MANAGE 3.1", title: "AI risks and benefits from third-party resources are regularly monitored", url: "https://doi.org/10.6028/NIST.AI.100-1"}
  - {framework: "NIST AI RMF 1.0", id: "MEASURE 2.7", title: "AI system security and resilience are evaluated", url: "https://doi.org/10.6028/NIST.AI.100-1"}
  - {framework: "EU AI Act", id: "Article 14", title: "Human oversight", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
  - {framework: "EU AI Act", id: "Article 15", title: "Accuracy, robustness and cybersecurity", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
  - {framework: "ISO/IEC 42001:2023", id: "8.1", title: "Operational planning and control", url: "https://www.iso.org/standard/81230.html"}
rules:
  - id: agents-need-guardrails
    description: Agent frameworks require a guardrail library
    severity: warning
    references: {owasp_llm: [LLM01, LLM06], owasp_agentic: [ASI01, ASI02]}
    match: {category: agent-framework}
    requires: {category: guardrail}
  - id: mcp-servers-reviewed
    description: MCP components are listed for review (tool access widens what an agent can do)
    severity: info
    references: {owasp_llm: [LLM06], owasp_agentic: [ASI02]}
    match: {category: mcp}
    deny: true
  - id: llm-gateways-reviewed
    description: LLM gateway components are listed for review (they hold provider keys and route traffic)
    severity: info
    references: {owasp_llm: [LLM03]}
    match: {category: llm-gateway}
    deny: true
  - id: no-remote-code-models
    description: trust_remote_code must not be enabled
    severity: error
    references: {owasp_llm: [LLM03], cwe: [CWE-829]}
    match: {category: risk-flag}
    deny: true
changes: {prompt: review, model: review}
```

### baseline.yml

```yaml
# Reference mapping only; not a compliance determination.
# The references block names framework clauses a reader may want to consult next to the rules below. The engine ignores it.
# Provider and name lists are placeholders: edit them to your organisation before use.
apiVersion: keryn.dev/policy/v1
name: baseline
description: Starting point for an AI inventory policy - approved providers, no remote-code model flags, no open AI services, prompt and model changes reviewed.
references:
  - {framework: "NIST AI RMF 1.0", id: "GOVERN 1.6", title: "Mechanisms are in place to inventory AI systems", url: "https://doi.org/10.6028/NIST.AI.100-1"}
  - {framework: "NIST AI RMF 1.0", id: "MAP 4.1", title: "Approaches for mapping AI technology and legal risks of its components, including third-party software", url: "https://doi.org/10.6028/NIST.AI.100-1"}
  - {framework: "EU AI Act", id: "Article 11", title: "Technical documentation", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
  - {framework: "ISO/IEC 42001:2023", id: "7.5", title: "Documented information", url: "https://www.iso.org/standard/81230.html"}
rules:
  - id: approved-llm-providers
    description: Only approved model providers may be referenced
    severity: error
    references: {owasp_llm: [LLM03]}
    match: {kind: library, category: llm-sdk}
    allowOnly: {field: name, values: [openai, anthropic]}
  - id: no-remote-code-models
    description: trust_remote_code must not be enabled
    severity: error
    references: {owasp_llm: [LLM03, LLM04], cwe: [CWE-829]}
    match: {category: risk-flag}
    deny: true
  - id: no-unauthenticated-ai-on-the-network
    description: A self-hosted AI service observed on the network must not answer without authentication
    severity: error
    references: {owasp_llm: [LLM02, LLM06], cwe: [CWE-306]}
    match: {basis: observed-on-network, attributes: {authState: no_auth_observed}}
    deny: true
changes: {prompt: review, model: review}
```

### eu-ai-act-refs.yml

```yaml
# Reference mapping only; not a compliance determination.
# The references block names framework clauses a reader may want to consult next to the rules below. The engine ignores it.
# Provider and name lists are placeholders: edit them to your organisation before use.
apiVersion: keryn.dev/policy/v1
name: eu-ai-act-refs
description: Baseline rules annotated with pointers into Regulation (EU) 2024/1689 for readers who work with it. Whether the Act applies to a system, and what it requires, is a legal question for counsel.
references:
  - {framework: "EU AI Act", id: "Article 9", title: "Risk management system", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
  - {framework: "EU AI Act", id: "Article 11", title: "Technical documentation", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
  - {framework: "EU AI Act", id: "Article 12", title: "Record-keeping", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
  - {framework: "EU AI Act", id: "Article 13", title: "Transparency and provision of information to deployers", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
  - {framework: "EU AI Act", id: "Article 14", title: "Human oversight", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
  - {framework: "EU AI Act", id: "Article 15", title: "Accuracy, robustness and cybersecurity", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
  - {framework: "EU AI Act", id: "Article 25", title: "Responsibilities along the AI value chain", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
rules:
  - id: approved-llm-providers
    description: Only approved model providers may be referenced
    severity: error
    references: {owasp_llm: [LLM03]}
    match: {kind: library, category: llm-sdk}
    allowOnly: {field: name, values: [openai, anthropic]}
  - id: no-remote-code-models
    description: trust_remote_code must not be enabled
    severity: error
    references: {owasp_llm: [LLM03, LLM04], cwe: [CWE-829]}
    match: {category: risk-flag}
    deny: true
  - id: no-unauthenticated-ai-on-the-network
    description: A self-hosted AI service observed on the network must not answer without authentication
    severity: error
    references: {owasp_llm: [LLM02, LLM06], cwe: [CWE-306]}
    match: {basis: observed-on-network, attributes: {authState: no_auth_observed}}
    deny: true
  - id: agents-need-guardrails
    description: Agent frameworks require a guardrail library
    severity: warning
    references: {owasp_llm: [LLM01, LLM06]}
    match: {category: agent-framework}
    requires: {category: guardrail}
changes: {prompt: review, model: review}
```

### iso-42001-refs.yml

```yaml
# Reference mapping only; not a compliance determination.
# The references block names framework clauses a reader may want to consult next to the rules below. The engine ignores it.
# Provider and name lists are placeholders: edit them to your organisation before use.
apiVersion: keryn.dev/policy/v1
name: iso-42001-refs
description: Baseline rules annotated with pointers into ISO/IEC 42001:2023 clauses for readers who work with it. The standard is paid; read it from the publisher.
references:
  - {framework: "ISO/IEC 42001:2023", id: "6.1.2", title: "AI risk assessment", url: "https://www.iso.org/standard/81230.html"}
  - {framework: "ISO/IEC 42001:2023", id: "7.5", title: "Documented information", url: "https://www.iso.org/standard/81230.html"}
  - {framework: "ISO/IEC 42001:2023", id: "8.1", title: "Operational planning and control", url: "https://www.iso.org/standard/81230.html"}
  - {framework: "ISO/IEC 42001:2023", id: "8.2", title: "AI risk assessment", url: "https://www.iso.org/standard/81230.html"}
rules:
  - id: approved-llm-providers
    description: Only approved model providers may be referenced
    severity: error
    references: {owasp_llm: [LLM03]}
    match: {kind: library, category: llm-sdk}
    allowOnly: {field: name, values: [openai, anthropic]}
  - id: no-remote-code-models
    description: trust_remote_code must not be enabled
    severity: error
    references: {owasp_llm: [LLM03, LLM04], cwe: [CWE-829]}
    match: {category: risk-flag}
    deny: true
  - id: no-unauthenticated-ai-on-the-network
    description: A self-hosted AI service observed on the network must not answer without authentication
    severity: error
    references: {owasp_llm: [LLM02, LLM06], cwe: [CWE-306]}
    match: {basis: observed-on-network, attributes: {authState: no_auth_observed}}
    deny: true
changes: {prompt: review, model: review}
```

### nist-ai-rmf-refs.yml

```yaml
# Reference mapping only; not a compliance determination.
# The references block names framework clauses a reader may want to consult next to the rules below. The engine ignores it.
# Provider and name lists are placeholders: edit them to your organisation before use.
apiVersion: keryn.dev/policy/v1
name: nist-ai-rmf-refs
description: Baseline rules annotated with pointers into NIST AI RMF 1.0 (NIST AI 100-1) for readers who work with it.
references:
  - {framework: "NIST AI RMF 1.0", id: "GOVERN 1.1", title: "Legal and regulatory requirements involving AI are understood, managed, and documented", url: "https://doi.org/10.6028/NIST.AI.100-1"}
  - {framework: "NIST AI RMF 1.0", id: "GOVERN 1.6", title: "Mechanisms are in place to inventory AI systems", url: "https://doi.org/10.6028/NIST.AI.100-1"}
  - {framework: "NIST AI RMF 1.0", id: "GOVERN 6.1", title: "Policies and procedures address AI risks associated with third-party entities", url: "https://doi.org/10.6028/NIST.AI.100-1"}
  - {framework: "NIST AI RMF 1.0", id: "MAP 4.1", title: "Approaches for mapping AI technology and legal risks of its components, including third-party software", url: "https://doi.org/10.6028/NIST.AI.100-1"}
  - {framework: "NIST AI RMF 1.0", id: "MEASURE 2.7", title: "AI system security and resilience are evaluated", url: "https://doi.org/10.6028/NIST.AI.100-1"}
  - {framework: "NIST AI RMF 1.0", id: "MANAGE 3.1", title: "AI risks and benefits from third-party resources are regularly monitored", url: "https://doi.org/10.6028/NIST.AI.100-1"}
rules:
  - id: approved-llm-providers
    description: Only approved model providers may be referenced
    severity: error
    references: {owasp_llm: [LLM03]}
    match: {kind: library, category: llm-sdk}
    allowOnly: {field: name, values: [openai, anthropic]}
  - id: no-remote-code-models
    description: trust_remote_code must not be enabled
    severity: error
    references: {owasp_llm: [LLM03, LLM04], cwe: [CWE-829]}
    match: {category: risk-flag}
    deny: true
  - id: no-unauthenticated-ai-on-the-network
    description: A self-hosted AI service observed on the network must not answer without authentication
    severity: error
    references: {owasp_llm: [LLM02, LLM06], cwe: [CWE-306]}
    match: {basis: observed-on-network, attributes: {authState: no_auth_observed}}
    deny: true
  - id: agents-need-guardrails
    description: Agent frameworks require a guardrail library
    severity: warning
    references: {owasp_llm: [LLM01, LLM06], nist_ai_rmf: [MANAGE]}
    match: {category: agent-framework}
    requires: {category: guardrail}
changes: {prompt: review, model: review}
```

### prompt-change-review.yml

```yaml
# Reference mapping only; not a compliance determination.
# The references block names framework clauses a reader may want to consult next to the rules below. The engine ignores it.
# Provider and name lists are placeholders: edit them to your organisation before use.
apiVersion: keryn.dev/policy/v1
name: prompt-change-review
description: Prompt and agent-instruction changes against a base need review; model swaps are blocked until reviewed. Runs only with a base (keryn scan --base, keryn policy check --base).
references:
  - {framework: "NIST AI RMF 1.0", id: "MANAGE 4.1", title: "Post-deployment AI system monitoring plans are implemented, including mechanisms for capturing and evaluating input from users, and for change management", url: "https://doi.org/10.6028/NIST.AI.100-1"}
  - {framework: "EU AI Act", id: "Article 12", title: "Record-keeping", url: "https://eur-lex.europa.eu/eli/reg/2024/1689/oj"}
  - {framework: "ISO/IEC 42001:2023", id: "8.1", title: "Operational planning and control", url: "https://www.iso.org/standard/81230.html"}
rules: []
changes: {prompt: review, model: block}
```

### example-org.yml

```yaml
# Example organisation policy over an AI-BOM. `references` names the framework ids a rule relates to (OWASP LLM Top 10
# 2025, OWASP Agentic Top 10 2026, CWE, NIST AI RMF 1.0, MITRE ATLAS): a pointer for readers who work in those frameworks.
# The engine ignores it, and passing this policy is not a conformance claim under OWASP, NIST AI RMF, ISO 42001 or any regulation.
apiVersion: keryn.dev/policy/v1
rules:
  - id: approved-llm-providers
    description: Only approved model providers may be referenced
    severity: error
    references: {owasp_llm: [LLM03], nist_ai_rmf: [GOVERN, MAP]}
    match: {kind: library, category: llm-sdk}
    allowOnly: {field: name, values: [openai, anthropic]}
  - id: no-remote-code-models
    description: trust_remote_code must not be enabled
    severity: error
    references: {owasp_llm: [LLM03, LLM04], owasp_agentic: [ASI04, ASI05], cwe: [CWE-829]}
    match: {category: risk-flag}
    deny: true
  - id: agents-need-guardrails
    description: Agent frameworks require a guardrail library
    severity: warning
    references: {owasp_llm: [LLM01, LLM06], owasp_agentic: [ASI01, ASI02], nist_ai_rmf: [MANAGE]}
    match: {category: agent-framework}
    requires: {category: guardrail}
  - id: no-hardcoded-open-weights
    description: Model identifiers must come from approved providers
    severity: warning
    references: {owasp_llm: [LLM03], nist_ai_rmf: [MAP]}
    match: {kind: model, category: model}
    allowOnly: {field: provider, values: [openai, anthropic]}
  - id: no-unauthenticated-ai-on-the-network
    description: A self-hosted AI service observed on the network must not answer without authentication
    severity: error
    references: {owasp_llm: [LLM02, LLM06], cwe: [CWE-306], nist_ai_rmf: [MANAGE]}
    match: {basis: observed-on-network, attributes: {authState: no_auth_observed}}
    deny: true
```
