config

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package config loads and validates .agent-memory/meta/manifest.yaml. The manifest holds operational settings (budgets, staging TTL, security flags, git policy, per-category approval overrides) — distinct from the per-category structural rules in internal/schema.

See docs/patterns/configuration-loading.md and design doc v0.4.1 §26.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteDefault

func WriteDefault(path, projectName string) error

WriteDefault writes the recommended manifest to path, with Project.Name set to projectName. Used by `agent-memory init` (T1.10).

func WriteManifest

func WriteManifest(path string, m *Manifest) error

WriteManifest serialises m to path atomically.

Types

type AllowlistLimitsSpec

type AllowlistLimitsSpec struct {
	MaxBytesPerFile   int `yaml:"max_bytes_per_file,omitempty"`
	MaxRegionsPerFile int `yaml:"max_regions_per_file,omitempty"`
	MaxBytesPerRegion int `yaml:"max_bytes_per_region,omitempty"`
}

AllowlistLimitsSpec caps how much content allowlist-marker regions can cover in a single file. A limit of 0 means "disabled".

The allowlist mechanism is intentionally a per-region escape hatch for documenting token formats (`ghp_AaBbCc...example, not real`). Without limits, a malicious or careless agent could wrap multi-KB regions around real credentials and bypass the scanner entirely. These caps keep allowlists in their intended size range.

Defaults (DefaultManifest):

MaxBytesPerFile:   1024 — five 200-byte format examples fit comfortably
MaxRegionsPerFile: 10   — more regions usually signals over-escaping
MaxBytesPerRegion: 512  — single largest region; a token + surrounding prose

type ApprovalPolicy

type ApprovalPolicy struct {
	Decisions       schema.ApprovalMode `yaml:"decisions"`
	Conventions     schema.ApprovalMode `yaml:"conventions"`
	Modules         schema.ApprovalMode `yaml:"modules"`
	PitfallsReplace schema.ApprovalMode `yaml:"pitfalls_replace"`
	PitfallsAppend  schema.ApprovalMode `yaml:"pitfalls_append"`
	Archive         schema.ApprovalMode `yaml:"archive"`
	Current         schema.ApprovalMode `yaml:"current"`
	CurrentShared   schema.ApprovalMode `yaml:"current_shared"`
	Sessions        schema.ApprovalMode `yaml:"sessions"`
	Index           schema.ApprovalMode `yaml:"index"`
}

ApprovalPolicy maps category / operation kinds to ApprovalMode. The distinction between "pitfalls_append" and "pitfalls_replace" lives here (not in schema) because it's per-operation, not per-file.

type Archive

type Archive struct {
	Enabled            bool `yaml:"enabled"`
	StaleThresholdDays int  `yaml:"stale_threshold_days"`
}

Archive holds archival-compaction settings.

type Budgets

type Budgets struct {
	BootstrapChars    int `yaml:"bootstrap_chars"`
	FetchContextChars int `yaml:"fetch_context_chars"`
	MaxFileChars      int `yaml:"max_file_chars"`
}

Budgets caps various character / line budgets used by fetch_context and the size validator.

type Concurrency

type Concurrency struct {
	LockTTLSeconds     int `yaml:"lock_ttl_seconds,omitempty"`
	WaitTimeoutSeconds int `yaml:"wait_timeout_seconds"`
}

Concurrency holds lock-related tunables.

LockTTLSeconds is accepted from legacy v0.4 manifests but intentionally IGNORED by the v0.4.1 lock implementation. v0.4.1 §11 replaced TTL-based locking with OS-level advisory locks (gofrs/flock); the kernel handles release on process death, so application-level TTL has nothing to enforce. The field is tagged omitempty so fresh manifests don't carry it forward.

type Eval

type Eval struct {
	BenchmarkCorpusURL string `yaml:"benchmark_corpus_url,omitempty"`
}

Eval is optional and used by the M8 benchmark runner.

type Git

type Git struct {
	TrackLocal           bool   `yaml:"track_local"`
	TrackSessions        bool   `yaml:"track_sessions"`
	AutoStageChanges     bool   `yaml:"auto_stage_changes"`
	AutoCommit           bool   `yaml:"auto_commit"`
	CommitMessagePrefix  string `yaml:"commit_message_prefix"`
	MergeDriverInstalled bool   `yaml:"merge_driver_installed"`
}

Git holds git-integration settings.

type LocalState

type LocalState struct {
	PerBranch                 bool `yaml:"per_branch"`
	SharedFileEnabled         bool `yaml:"shared_file_enabled"`
	CleanupOrphansWarningDays int  `yaml:"cleanup_orphans_warning_days"`
}

LocalState holds per-branch local-state behaviour.

type Manifest

type Manifest struct {
	Version     string      `yaml:"version"`
	Project     Project     `yaml:"project"`
	Budgets     Budgets     `yaml:"budgets"`
	Updates     Updates     `yaml:"updates"`
	Staging     Staging     `yaml:"staging"`
	Security    Security    `yaml:"security"`
	Git         Git         `yaml:"git"`
	Archive     Archive     `yaml:"archive"`
	Concurrency Concurrency `yaml:"concurrency"`
	LocalState  LocalState  `yaml:"local_state"`
	Sessions    Sessions    `yaml:"sessions"`
	Eval        Eval        `yaml:"eval,omitempty"`
}

Manifest is the deserialisation target for manifest.yaml.

func DefaultManifest

func DefaultManifest() *Manifest

DefaultManifest returns the recommended manifest from design doc §26.1.

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

LoadManifest reads manifest.yaml from path. Missing fields are filled from DefaultManifest — yaml.v3 merges into the pre-populated struct, so users can override just the fields they care about.

func (*Manifest) Validate

func (m *Manifest) Validate() error

Validate checks basic invariants on m:

  • Version is non-empty.
  • Every approval mode is a recognised ApprovalMode.
  • Budgets and TTL values are positive.

Heavier semantic checks (e.g., that Index is server_only) live in the downstream code that consumes the manifest, not in the loader.

type Project

type Project struct {
	Name string `yaml:"name"`
	Root string `yaml:"root"`
}

Project identifies the repository the manifest belongs to.

type Security

type Security struct {
	SecretScan                    bool                `yaml:"secret_scan"`
	RejectUntrustedDurableUpdates bool                `yaml:"reject_untrusted_durable_updates"`
	PIIScan                       bool                `yaml:"pii_scan"`
	PIIScanEmail                  bool                `yaml:"pii_scan_email,omitempty"`
	AllowlistLimits               AllowlistLimitsSpec `yaml:"allowlist_limits,omitempty"`
}

Security holds security-engine policy.

type Sessions

type Sessions struct {
	PerBranch bool `yaml:"per_branch"`
}

Sessions holds session-recording behaviour.

type Staging

type Staging struct {
	TTLSeconds int `yaml:"ttl_seconds"`
}

Staging holds staging-directory policy.

type Updates

type Updates struct {
	Approval ApprovalPolicy `yaml:"approval"`
}

Updates holds the per-operation approval overrides.

Jump to

Keyboard shortcuts

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