policy

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 6, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// APIVersion is matched exactly, exactly as an annotation record's is.
	APIVersion = api.Version

	// KindPolicy is the resource kind of a repository policy.
	KindPolicy = "Policy"

	ModeStrict = "strict"
	FileName   = ".koment/policy.yaml"
	SchemaURL  = api.SchemaBase + "policy.schema.json"
)
View Source
const LegacyVersion = 1

LegacyVersion is the only value the pre-v1alpha `version` field ever carried.

Variables

Functions

func Save

func Save(rootPath string, configured Policy) (returnedError error)

Save writes a validated policy atomically beneath the repository root.

Types

type Adapter

type Adapter string

Adapter names one generated agent instruction surface.

const (
	AdapterAgents   Adapter = "agents"
	AdapterClaude   Adapter = "claude"
	AdapterCopilot  Adapter = "copilot"
	AdapterCursor   Adapter = "cursor"
	AdapterCodex    Adapter = "codex"
	AdapterOpencode Adapter = "opencode"
)

type AgentsPolicy

type AgentsPolicy struct {
	Adapters   []Adapter   `yaml:"adapters"`
	Principles []Principle `yaml:"principles,omitempty"`
}

AgentsPolicy selects generated instruction adapters and the principles they state.

type CommentsPolicy

type CommentsPolicy struct {
	Mode           string      `yaml:"mode"`
	Intrinsic      []Intrinsic `yaml:"intrinsic"`
	GeneratedPaths []string    `yaml:"generatedPaths,omitempty"`
	VendoredPaths  []string    `yaml:"vendoredPaths,omitempty"`
}

CommentsPolicy configures strict classification and repository exclusions.

type Intrinsic

type Intrinsic string

Intrinsic names one class of source comment that may remain inline.

const (
	IntrinsicToolchain       Intrinsic = "toolchain-directive"
	IntrinsicGeneratedMarker Intrinsic = "generated-marker"
	IntrinsicUpstreamLink    Intrinsic = "upstream-link"
	IntrinsicDeprecated      Intrinsic = "deprecated"
	IntrinsicPublicAPI       Intrinsic = "public-api"
)

type Policy

type Policy struct {
	APIVersion string `yaml:"apiVersion"`
	Kind       string `yaml:"kind"`
	Spec       Spec   `yaml:"spec"`
}

Policy is the repository enforcement contract, shaped like every other committed koment resource (ADR 0121).

func Default

func Default() Policy

Default returns the strict policy installed for a new repository.

func Install

func Install(rootPath string) (Policy, bool, error)

Install writes the default policy only when none exists.

func Load

func Load(rootPath string) (configured Policy, returnedError error)

Load reads and strictly validates the repository policy.

func (Policy) Allows

func (p Policy) Allows(intrinsic Intrinsic) bool

Allows reports whether an intrinsic class is enabled.

func (Policy) Excludes

func (p Policy) Excludes(file string) bool

Excludes reports whether a generated or vendored path is outside enforcement.

func (Policy) States added in v1.1.0

func (p Policy) States() []string

States returns the wording of every principle this policy enables, in the order the vocabulary declares them so that a regenerated contract does not diff against itself.

func (Policy) Validate

func (p Policy) Validate() error

Validate rejects policy drift and unsupported bypasses.

type Principle added in v1.1.0

type Principle string

Principle names one extra rule the generated agent contract states. A principle is a claim a reviewer can check, not a preference.

const (
	PrincipleBackCompatEvidence Principle = "back-compat-evidence"
)

type Spec added in v1.1.0

type Spec struct {
	Comments CommentsPolicy `yaml:"comments"`
	Agents   AgentsPolicy   `yaml:"agents"`
}

Spec is everything the repository decided. A policy has no metadata because it is a singleton with no identity of its own: the file path is the name.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL