policy

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MIT Imports: 10 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 (
	Version    = 1
	ModeStrict = "strict"
	FileName   = ".koment/policy.yaml"
	SchemaURL  = "https://raw.githubusercontent.com/janpuc/koment/main/schema/policy.schema.json"
)

Variables

This section is empty.

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"
)

type AgentsPolicy

type AgentsPolicy struct {
	Adapters []Adapter `yaml:"adapters"`
}

AgentsPolicy selects generated instruction adapters.

type CommentsPolicy

type CommentsPolicy struct {
	Mode           string      `yaml:"mode"`
	Intrinsic      []Intrinsic `yaml:"intrinsic"`
	GeneratedPaths []string    `yaml:"generated_paths,omitempty"`
	VendoredPaths  []string    `yaml:"vendored_paths,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 {
	Version  int            `yaml:"version"`
	Comments CommentsPolicy `yaml:"comments"`
	Agents   AgentsPolicy   `yaml:"agents"`
}

Policy is the version-1 repository enforcement contract.

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) Validate

func (p Policy) Validate() error

Validate rejects policy drift and unsupported bypasses.

Jump to

Keyboard shortcuts

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