config

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 12 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

Overview

Package config parses and validates the committed Orch configuration at .orchestrator/config.toml (PRD §17), then layers on the machine-local override file at config.local.toml when present. The overlay is restricted to a closed set of preference keys; any policy-bearing key set locally is rejected (see overlay.go).

Index

Constants

View Source
const LocalOverridePath = ".orchestrator/config.local.toml"

LocalOverridePath is the repo-relative location of the machine-local override file. When present, Load layers it onto the committed configuration, restricted to a closed set of preference keys (PRD §17; see overlay.go).

View Source
const Path = ".orchestrator/config.toml"

Path is the repo-relative location of the committed configuration.

Variables

View Source
var ErrNotInitialized = errors.New("not initialized: " + Path + " not found (run `orch init` to set up this repository)")

ErrNotInitialized reports a missing committed configuration file.

Functions

func HasLocalOverride

func HasLocalOverride(repoRoot string) bool

HasLocalOverride reports whether the machine-local override file exists under repoRoot.

func PreferenceKeys

func PreferenceKeys() []string

PreferenceKeys returns every dotted leaf key classified classPreference in leafClasses, sorted — the exact key set config.local.toml may set. interview.NextConfigureLocal's configure-local question IDs are drift-pinned against this list (the closed 30-leaf policy/preference table, decision 18).

func RemoveLocal

func RemoveLocal(repoRoot string) error

RemoveLocal deletes repoRoot's config.local.toml. A missing file is not an error, so RemoveLocal is idempotent — a re-applied "clear every override" apply must succeed even if a prior attempt already removed the file.

func Render

func Render(c *Config) ([]byte, error)

Render renders c as byte-stable canonical TOML: every value is written out explicitly, including PRD-defaulted concurrency.max_subagents and merge.strategy, so the committed file never leaves a policy value implicit. Section order is fixed (schema/revision header, concurrency, merge, memhub, metrics, then claude before codex — EnabledHosts' and the interview's own question-sequence order), only enabled hosts get a [hosts.X] table, and output uses LF line endings and %q string quoting throughout.

Render is a hand-written template rather than toml.Encoder specifically so golden-file tests can byte-compare its output and so field order never depends on struct reflection order. It does not validate c — Parse(Render(c)) is the round-trip a caller runs as its own self-check (interview.materialize does exactly this before ever proposing the bytes as a file).

func RenderLocal

func RenderLocal(overrides map[string]string) ([]byte, error)

RenderLocal renders overrides as sparse canonical config.local.toml content: only the given keys are written, in render.go's fixed section order restricted to the sections a preference key can ever belong to (concurrency, metrics, then claude before codex host role tables in roleOrder), with the same %q string quoting, LF line endings, and byte-stable output Render itself guarantees. Every key must be one PreferenceKeys lists; concurrency.max_subagents must parse as an integer >= 1 and metrics.enabled as a strconv.ParseBool string — the same materialize-grade ingestion checks interview.materialize applies to free-text committed-config answers, duplicated here since config must not import interview.

overrides must not be empty: an override file that overrides nothing is the trivial case callers handle with RemoveLocal instead, so RenderLocal treats it as a caller error rather than silently rendering just the header.

Self-check: the rendered bytes are re-decoded and every key reclassified through leafClasses; the result must equal overrides' key set exactly, or RenderLocal fails closed rather than hand a caller bytes MergeLocal would itself reject.

func Revision

func Revision(c *Config) (string, error)

Revision computes c's content-addressed revision identifier: "sha256:" followed by the first 12 hex characters of the SHA-256 of c's semantic content. It marshals a shadow copy of c with ConfigRevision and Overrides cleared first — the revision cannot depend on the value it is computing, and Overrides is the machine-local audit trail (PRD §17), orthogonal to the committed content this identifies — so Revision is insensitive to both and sensitive to every other field.

This mirrors PlanDoc.Digest's precedent (internal/run/plandoc.go), restricted to a short, human-typeable prefix: the revision is an audit label surfaced in issues, PRs, and `orch status`, not a security boundary, so the shorter, collision-tolerant form is the right trade here. `orch configure` (task 16) recomputes it identically.

func WriteLocal

func WriteLocal(repoRoot string, data []byte) error

WriteLocal atomically writes data to repoRoot's config.local.toml: a temp file in the same directory, synced, then renamed over the destination (internal/state.write's shape, which also replaces atomically on Windows). On any failure the existing file, if any, is left untouched and the temp file is removed on a best-effort basis.

Types

type Concurrency

type Concurrency struct {
	MaxSubagents int `toml:"max_subagents"`
}

Concurrency caps concurrent subagents (PRD §14; default 3).

type Config

type Config struct {
	SchemaVersion  int         `toml:"schema_version"`
	ConfigRevision string      `toml:"config_revision"`
	Concurrency    Concurrency `toml:"concurrency"`
	Merge          Merge       `toml:"merge"`
	Memhub         Memhub      `toml:"memhub"`
	Metrics        Metrics     `toml:"metrics"`
	Hosts          Hosts       `toml:"hosts"`

	// Overrides lists, sorted, the dotted keys applied from
	// config.local.toml. It is the audit surface for PRD §23: which
	// exact model/effort values are in effect must always be visible.
	// Empty (nil) when no local override file exists or it sets
	// nothing. Never itself read from either TOML file.
	Overrides []string `toml:"-"`
}

Config is the root of the committed configuration schema, after any machine-local overlay has been merged in.

func Load

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

Load reads, parses, and validates the committed configuration under repoRoot, then merges in any machine-local overlay from config.local.toml (PRD §17). It never returns a partial Config: on any parse or validation failure the returned Config is nil.

func MergeLocal

func MergeLocal(committed *Config, localTOML []byte) (*Config, error)

MergeLocal merges localTOML's permitted preference keys onto committed. committed has already been fully validated on its own and is never mutated in place: the returned Config is a distinct value, and any Host it modifies is a fresh copy (PRD §17 — local overrides never weaken mandatory workflow policy, and the committed file's own meaning must not change underfoot). Any policy-bearing key, any key naming a host not enabled in committed, or any unknown key in localTOML is a fail-closed error naming every violation found.

This is applyLocalOverride's merge body, split out so interview.NextConfigureLocal can run the exact same classification and post-merge validation as an anti-forgery self-check over freshly-rendered bytes, without writing them to disk first.

func Parse

func Parse(data []byte) (*Config, error)

Parse decodes, defaults, and validates the configuration encoded in data: unknown keys are rejected, PRD-specified defaults are applied for keys the document omits, and the result must pass validate() before it is returned. It never returns a partial Config: on any decode or validation failure the returned Config is nil.

Parse is loadCommitted's extracted body (this is the one place the decode/default/validate sequence lives), so any in-memory TOML can be parsed the same way the committed file is: interview.materialize round-trips its generated bytes through Parse as a self-check before ever proposing them as a file, without writing anything to disk.

func (*Config) EnabledHosts

func (c *Config) EnabledHosts() []string

EnabledHosts returns the names of the configured hosts in stable order.

type Host

type Host struct {
	Roles Roles `toml:"roles"`
}

Host is a per-host model/effort profile (PRD §10).

type Hosts

type Hosts struct {
	Codex  *Host `toml:"codex"`
	Claude *Host `toml:"claude"`
}

Hosts holds one profile per enabled host. A nil host is not enabled.

type Memhub

type Memhub struct {
	Mode string `toml:"mode"`
}

Memhub selects the integration mode (PRD §20). There is no default: the mode is policy-bearing and must be chosen explicitly.

type Merge

type Merge struct {
	Strategy string `toml:"strategy"`
}

Merge selects the repository merge strategy (PRD §16; default squash).

type Metrics

type Metrics struct {
	Enabled bool `toml:"enabled"`
}

Metrics enables optional local metrics (PRD §21; off by default).

type RoleProfile

type RoleProfile struct {
	Model  string `toml:"model"`
	Effort string `toml:"effort"`
}

RoleProfile pins an exact model version and reasoning effort.

type Roles

type Roles struct {
	Architect       RoleProfile `toml:"architect"`
	Scout           RoleProfile `toml:"scout"`
	Implementer     RoleProfile `toml:"implementer"`
	Specialist      RoleProfile `toml:"specialist"`
	Reviewer        RoleProfile `toml:"reviewer"`
	ReviewDowngrade RoleProfile `toml:"review_downgrade"`
}

Roles maps every PRD §9 role, plus the safe review downgrade, to an exact model and effort. All six are required for an enabled host.

Jump to

Keyboard shortcuts

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