config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package config loads and validates the per-project .awf/ configuration: a skeleton config.yaml plus per-target sidecar YAMLs and convention parts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsSingletonKind

func IsSingletonKind(kind string) bool

IsSingletonKind reports whether kind is an always-on singleton whose sidecar lives at <root>/<kind>.yaml and whose parts live under <root>/parts/<kind>/ (ADR-0021).

func MarshalSkeleton

func MarshalSkeleton(s Skeleton) ([]byte, error)

MarshalSkeleton renders a fresh config.yaml from s in the canonical awf format (two-space block style). It is the construction half of internal/config's ownership of config.yaml serialization (ADR-0026).

func SetArrayMember

func SetArrayMember(src []byte, key, name string, add bool) ([]byte, error)

SetArrayMember adds or removes name in the sequence under key in a config.yaml source, via a yaml.Node round-trip that preserves comments and every untouched key (ADR-0026). The edited sequence is normalized to block style, so a flow-style input (`key: [a, b]`) is accepted. Adding a member already present is a no-op; removing a member absent from the key (or a key absent on remove) errors. invariant: config-mutation-roundtrip

func ValidateDomainName

func ValidateDomainName(name string) error

ValidateDomainName reports whether name is a usable domain key: non-empty and free of path separators or "..". Shared by Validate and the `awf add domain` path so a freeform domain name is rejected the same way in both.

Types

type AuditConfig

type AuditConfig struct {
	BaseBranch          string   `yaml:"baseBranch"`
	AllowedTypes        []string `yaml:"allowedTypes"`
	AllowedScopes       []string `yaml:"allowedScopes"`
	SubjectMaxLength    *int     `yaml:"subjectMaxLength"`
	DependencyManifests []string `yaml:"dependencyManifests"`
	DiffThreshold       *int     `yaml:"diffThreshold"`
	DomainDocStaleness  *bool    `yaml:"domainDocStaleness"`
	UndocumentedDomain  *bool    `yaml:"undocumentedDomain"`
	UncommittedChanges  *bool    `yaml:"uncommittedChanges"`
}

AuditConfig tunes `awf audit` (ADR-0017). A nil *AuditConfig means all defaults; within it, a nil slice means "use the default", an explicit empty slice means "accept any / disabled" per field. Resolution and defaults live in internal/audit (audit.Resolve), which owns the audit domain semantics.

type CatalogTrim

type CatalogTrim struct {
	Skills *[]string
	Docs   *[]string
}

CatalogTrim optionally overrides which catalog skills/docs a scaffolded config enables (ADR-0029 catalog trim). A nil *CatalogTrim — or a nil dimension within it — means "no selection: keep the curated-core default"; a non-nil dimension is the verbatim, fully-deselectable enable set (an empty slice deselects all).

type Config

type Config struct {
	Prefix     string           `yaml:"prefix"`
	DocsDir    string           `yaml:"docsDir"`
	Vars       map[string]any   `yaml:"vars"`
	Skills     []string         `yaml:"skills"`
	Agents     []string         `yaml:"agents"`
	Hooks      []string         `yaml:"hooks"`
	Docs       []string         `yaml:"docs"`
	Domains    []string         `yaml:"domains"`
	Invariants *InvariantConfig `yaml:"invariants"`
	Audit      *AuditConfig     `yaml:"audit"`
	// contains filtered or unexported fields
}

Config is the skeleton config.yaml: global fields plus flat enable arrays. Presence of a name in Skills/Agents/Docs/Hooks enables that target; per-target data/sections/local live in sidecars, not here.

func Load

func Load(awfDir string) (*Config, error)

Load reads <awfDir>/config.yaml with the strict decoder, records awfDir as the sidecar/part resolution root, and defaults DocsDir.

func (*Config) PartPath

func (c *Config) PartPath(kind, target, section string) string

PartPath returns the convention part path for a section of a target.

func (*Config) Sidecar

func (c *Config) Sidecar(kind, name string) (Sidecar, error)

Sidecar reads <root>/<kind>/<name>.yaml; agents-doc lives at <root>/agents-doc.yaml. A missing file yields a zero Sidecar (publication-safe: empty data/sections).

func (*Config) Validate

func (c *Config) Validate() error

type InvariantConfig

type InvariantConfig struct {
	Disabled bool              `yaml:"disabled"`
	Sources  []InvariantSource `yaml:"sources"`
}

InvariantConfig configures language-agnostic invariant backing. A nil *InvariantConfig (key absent) means "unchecked"; Disabled is the explicit opt-out; a non-empty Sources enables enforcement.

type InvariantSource

type InvariantSource struct {
	Globs  []string `yaml:"globs"`
	Marker string   `yaml:"marker"`
}

InvariantSource pairs filename globs (matched against a file's basename) with the literal comment marker that prefixes a backing `invariant: <slug>` tag.

type SectionOverride

type SectionOverride struct {
	Drop bool `yaml:"drop"`
}

SectionOverride is a sidecar's per-section override. Body replacement is by convention part only; the field set is deliberately just Drop. invariant: no-replacewith

type Sidecar

type Sidecar struct {
	Data     map[string]any             `yaml:"data"`
	Sections map[string]SectionOverride `yaml:"sections"`
	Local    bool                       `yaml:"local"`
}

Sidecar holds a single target's non-prose configuration: structured render data, per-section overrides, and the local flag. It lives at <awfDir>/<kind>/<name>.yaml (agents-doc: <awfDir>/agents-doc.yaml). An absent sidecar is the zero Sidecar (publication-safe: empty data/sections).

type Skeleton

type Skeleton struct {
	Prefix     string            `yaml:"prefix"`
	Vars       map[string]string `yaml:"vars"`
	Skills     []string          `yaml:"skills"`
	Agents     []string          `yaml:"agents"`
	Hooks      []string          `yaml:"hooks"`
	Docs       []string          `yaml:"docs"`
	Invariants *InvariantConfig  `yaml:"invariants,omitempty"`
}

Skeleton is the input to MarshalSkeleton: the fields a freshly-scaffolded .awf/config.yaml carries. Vars is typed map[string]string (not map[string]any) so a nil/null var value is unrepresentable — the scaffold seeds each var with an empty string, which marshals as `x: ""`. A nil interface would marshal as `x: null` and decode back to a nil value that renders as "<no value>", tripping the publication-safe check (ADR-0026 Decision 3).

Jump to

Keyboard shortcuts

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