Help us shape the future of Go! Take the 2026 Go Developer Survey

cascade

package
v2.219.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package cascade is the absorbed v1 composer: it composes AGENTS.COMPOSE.md doctrine sources into COMPOSED files, wires harness load-point symlinks, and emits the compiled repository plan convergence consumers read.

Index

Constants

View Source
const (
	DeliveryInline = "inline"
	DeliveryImport = "import"
)

Inline copies a source body in; import emits an `@path` pointer so a source the repository cascade also delivers loads once. See docs/cascade.md.

View Source
const (
)

Variables

This section is empty.

Functions

func AppendixRoles

func AppendixRoles(cfg *Config) ([]string, error)

AppendixRoles returns every distinct role slug the appendix scopes a block to, sorted. Cascade never loads a person, so a caller that has one checks these.

func Check

func Check(paths Paths, stdout, stderr io.Writer) int

Check verifies on-disk outputs match a fresh compose; drift prints a unified diff and fails, mirroring the v1 pre-commit hook.

func Compose

func Compose(
	sources []string,
	overrides map[string]string,
	appendix []AppendixBlock,
	role string,
) (string, error)

Compose concatenates source bodies under the banner, each fenced by its source path, then the appendix blocks bound to role. See docs/cascade.md.

func ComposeParts

func ComposeParts(
	sources []string,
	overrides map[string]string,
	appendix []AppendixBlock,
	role string,
) (string, string, error)

ComposeParts returns the source body and the role's appendix separately, because a bundle rewrites the body. See docs/cascade.md. agent-compose#6987.

func ComposePartsDelivered

func ComposePartsDelivered(
	sources []string,
	overrides map[string]string,
	appendix []AppendixBlock,
	role string,
	delivery string,
) (string, string, error)

ComposePartsDelivered is ComposeParts with the source delivery mode chosen. Every source is import-eligible; ComposePartsScoped narrows that.

func ComposePartsScoped

func ComposePartsScoped(
	sources []string,
	overrides map[string]string,
	appendix []AppendixBlock,
	role string,
	delivery string,
	importable map[string]bool,
) (string, string, error)

ComposePartsScoped limits import delivery to importable, keyed by absolute path; a nil set imports every source. Rationale: docs/cascade.md.

func ConfiguredSources

func ConfiguredSources(cfg *Config) map[string]bool

ConfiguredSources keys the named `sources` entries by absolute path. Only these can be delivered twice, so only these answer to `source_delivery`.

func DefaultLoadPoints

func DefaultLoadPoints() (map[string]string, error)

DefaultLoadPoints is each cascade harness's home native instructions path from the layouts table. Config opts others in.

func DefaultSkillLoadPoints

func DefaultSkillLoadPoints() (map[string]string, error)

DefaultSkillLoadPoints mirrors DefaultLoadPoints for skills. A harness reads only its own table entry; see docs/projection.md.

func GatherSources

func GatherSources(cfg *Config) ([]string, []string)

GatherSources resolves explicit entries in listed order, then discovered root entries sorted; duplicates collapse to first occurrence.

func OperatingBase

func OperatingBase(cfg *Config, harness, role string) (string, error)

OperatingBase renders the base for one harness and role: the load point's own sources, plus each appendix block bound to that role.

func OperatingBaseParts

func OperatingBaseParts(cfg *Config, harness, role string) (string, string, error)

OperatingBaseParts splits that render into sources and appendix, for a caller that rewrites the sources before rendering them. See ComposeParts.

func RenderRepositoryPlan

func RenderRepositoryPlan(cfg *Config, projects string) (string, error)

RenderRepositoryPlan compiles repository policy from trusted operating roots. It never infers availability from doctrine paths or harness load points.

func ResolveConfiguredPath

func ResolveConfiguredPath(value, configPath, home string) string

ResolveConfiguredPath expands one host-config path against its config file and injectable home directory.

func ResolveLoadPoints

func ResolveLoadPoints(cfg *Config) (map[string]string, error)

ResolveLoadPoints merges config overrides over the defaults; falsy values (null, false, empty) opt a harness out entirely.

func ResolveSkillLoadPoints

func ResolveSkillLoadPoints(cfg *Config) (map[string]string, error)

ResolveSkillLoadPoints merges config overrides over the skill defaults, with the same falsy opt-out as ResolveLoadPoints.

func Run

func Run(paths Paths, opts RunOptions, stdout, stderr io.Writer) int

Run composes and wires symlinks; absent config is a documented no-op.

func SelectByScope

func SelectByScope(sources []string, machineScopes []string, filtering bool) []string

SelectByScope keeps sources whose scopes intersect the machine's; nil machine scopes disables filtering, and untagged sources drop under it.

func ValidateSources

func ValidateSources(cfg *Config) error

ValidateSources refuses a named source that cannot carry doctrine. Discovered `roots` entries stay lenient, because nothing declared those. docs/cascade.md.

Types

type AppendixBlock

type AppendixBlock struct {
	Fence string
	Body  string
	Roles []string
}

AppendixBlock is a resolved entry: provenance fence, body, binding roles.

func GatherAppendix

func GatherAppendix(cfg *Config) ([]AppendixBlock, []string)

GatherAppendix resolves entries in listed order, returning the error strings GatherSources uses so a missing file warns rather than aborts.

type AppendixEntry

type AppendixEntry struct {
	Text  string   `yaml:"text"`
	Path  string   `yaml:"path"`
	Roles []string `yaml:"roles"`
}

AppendixEntry is one configured tail block: exactly one of Text or Path, and an empty Roles list makes it global.

type Config

type Config struct {
	Scopes               *scopeList          `yaml:"scopes"`
	Sources              []string            `yaml:"sources"`
	Roots                []string            `yaml:"roots"`
	LoadPoints           map[string]RawValue `yaml:"load_points"`
	PersonPolicy         string              `yaml:"person_policy"`
	PersonSource         string              `yaml:"person_source"`
	PersonalityLibraries []string            `yaml:"personality_libraries"`
	RosterSources        []string            `yaml:"roster_sources"`
	SkillLoadPoints      map[string]RawValue `yaml:"skill_load_points"`
	SkillCatalogManifest string              `yaml:"skill_catalog_manifest"`
	SkillRequests        []string            `yaml:"skill_requests"`
	OperatingContext     []string            `yaml:"operating_context"`
	SourceDelivery       string              `yaml:"source_delivery"`
	Appendix             []AppendixEntry     `yaml:"appendix"`
	Telemetry            *telemetry.Config   `yaml:"telemetry"`

	// Kept so a relative appendix path resolves against the config file.
	SourcePath string `yaml:"-"`
}

func LoadConfig

func LoadConfig(path string) (*Config, error)

LoadConfig reads one host config and fills the defaults that make a short file enough. See docs/cascade.md "Host config defaults".

type Paths

type Paths struct {
	Config       string
	Composed     string
	ProjectsRoot string
	Home         string
}

Paths carries the injectable filesystem anchors so tests never touch the real home; DefaultPaths resolves the live locations.

func DefaultPaths

func DefaultPaths() Paths

type RawValue

type RawValue struct {
	// contains filtered or unexported fields
}

RawValue keeps a load-point value's truthiness: null and false opt a harness out, a non-empty string sets its path.

func (*RawValue) UnmarshalYAML

func (r *RawValue) UnmarshalYAML(node *yaml.Node) error

type RunOptions

type RunOptions struct {
	DryRun  bool
	Reapply bool
	Verbose bool
}

RunOptions controls preview, forced application, and layout reporting.

Jump to

Keyboard shortcuts

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