publisher

package
v0.46.1 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Overview

Package publisher constructs immutable output plans and coordinates project rendering.

Package publisher owns application-level output publication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigReferencePresentation

func ConfigReferencePresentation(key string, model *ConfigReference, status string) (presentation.Document, error)

ConfigReferencePresentation maps the typed reference into Collection. The reference model remains project-owned; presentation owns only the grammar.

func IsLocalDocTemplate

func IsLocalDocTemplate(templateID string) bool

IsLocalDocTemplate is the bounded recognition policy outer composition passes to uninstall.

func NewFilesystemReader

func NewFilesystemReader(root string) outputplan.TreeReader

NewFilesystemReader opens the ordinary working-tree reader used by Publisher.

func ReplaceLocalDocumentBody added in v0.44.0

func ReplaceLocalDocumentBody(output []byte, body string) ([]byte, error)

ReplaceLocalDocumentBody replaces only the adopter-owned body of a rendered configured local document. The marker recognition and framing policy stay with the same boundary owner used by ordinary in-place readback.

Types

type Backup

type Backup struct {
	Path  string // project-relative file that was overwritten
	Bak   string // project-relative backup copy (.awf-bak[.N])
	Index bool   // the file is the generated ADR/domain index (ownership-takeover note)
}

Backup records a foreign file preserved before sync overwrote its path.

type Change

type Change struct {
	Path  string
	Cause string
}

Change records a sync-written file whose rendered bytes differ from the prior lock's or whose required mode was corrected, with the cause the lock's hashes able to attribute: "template" (the upstream template source moved), "config" (the project's effective inputs - vars, sidecar, parts - moved), "template+config" (both), "internal" (hashes unmoved: a non-hashed input such as the binary's version stamp), "regenerated" (a generated index, which carries no hashes to attribute), or "added" (no prior entry). The provenance triage signal for reviewing a large sync diff - upstream churn vs the project's own inputs.

type ConfigKeyRow

type ConfigKeyRow struct {
	Path, Type, Default, Description, Availability, Current string
}

ConfigKeyRow renders one config.yaml key or sidecar field in the config reference: a `configKeys` row always carries a resolved Current value, a `sidecarFields` row never does (there is no project-relative live value for a sidecar's own field), and the static catalog-only model leaves Current empty on every row.

type ConfigReference

type ConfigReference struct {
	ConfigKeys    []ConfigKeyRow
	VarEntries    []VarRow
	SidecarFields []ConfigKeyRow
	DataKeys      []DataKeyRow
}

ConfigReference is the typed presentation model for `awf config`: the four dedicated collections PrintConfigReference renders, produced either with live project state (ConfigReferenceModel) or catalog-only (StaticConfigReference). It is the typed counterpart to the map[string]any shape configReferenceData still builds for the doc generator - a renamed field here is a compile error, never a silently empty render.

func StaticConfigReference

func StaticConfigReference() (ConfigReference, error)

StaticConfigReference projects configspec (plus catalog-wide potential consumers) into the same typed collections the live model uses, minus live project state - the pre-adoption fallback `awf config` prints outside an adopted tree.

type DataKeyRow

type DataKeyRow struct {
	Artifact, Key, Description, State string
}

DataKeyRow renders one per-artifact data key. State reports its observable catalog/project layering state.

type Effect added in v0.41.0

type Effect struct {
	Kind     string
	Path     string
	Recovery string
}

Effect is one committed filesystem fact and its stable retry or recovery action.

type InitAuthority

type InitAuthority struct{ InitializedWithVersion string }

InitAuthority is the explicit provenance supplied only by first adoption.

type Layout

type Layout struct {
	DocsDir    string
	Docs       map[string]string // catalog name -> output path (inv: layout-docs-full-catalog)
	Singletons map[string]string // template key -> output path
	DomainsDir string
}

Layout is the fixed, awf-given docs layout in typed form for Go consumers. These paths are not configurable through the project tree. templateMap projects it into the .layout template namespace (templates read a map, not unexported struct fields) and into the per-file ConfigHash. The mandatory-singleton paths are not struct fields: they derive from the catalog doc collection in templateMap (ADR-0061).

type OutputInput

type OutputInput struct {
	Path string
	Role outputplan.ArtifactRole
}

OutputInput records one semantic input consumed by a declared output.

type OutputNode

type OutputNode struct {
	Path                string
	Recipe              OutputRecipe
	Policy              outputplan.Policy
	Declarers           []string
	DeclarerProjections []string
	DependsOn           []string
	ConsumedInputs      []OutputInput
	ObservedTemplateID  string
	// contains filtered or unexported fields
}

OutputNode is one path in the deterministic internal output plan.

type OutputPlan

type OutputPlan struct {
	Nodes []OutputNode
}

OutputPlan is the single desired-output authority consumed by rendering, sync, manifest/prune, checks, and planned-output reporting.

type OutputRecipe

type OutputRecipe struct {
	TemplateID, TemplateHash, ConfigHash string
	Policy                               outputplan.Policy
	Encoder                              artifactregistry.AgentDialect
	Provenance                           string
}

OutputRecipe is the normalized, output-affecting declaration used for collision diagnostics and configuration hashes. Target identity is kept on OutputNode declarers rather than here, so compatible shared outputs coalesce.

type PartialError added in v0.41.0

type PartialError struct {
	Result Result
	Cause  error
}

PartialError reports a failed publication after one or more committed effects.

func (*PartialError) Error added in v0.41.0

func (e *PartialError) Error() string

func (*PartialError) Unwrap added in v0.41.0

func (e *PartialError) Unwrap() error

type ProjectSession added in v0.46.0

type ProjectSession interface {
	Root() string
	Roots() resident.Roots
	Config() *config.Config
	Reader() outputplan.TreeReader
	Catalog() *catalog.Catalog
	Targets() []artifactregistry.Target
}

ProjectSession is the read-only project selection consumed by Publisher. The concrete authority owner is project.Session.

type Publisher

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

Publisher is the sole output-plan construction and rendering coordinator. One Publisher is one immutable operation: all readers share its one derived universe, and publication may be attempted only once.

func New

func New(session ProjectSession, version string) *Publisher

New composes a Publisher from one authoritative project Session.

func (*Publisher) BuildConfigReference

func (p *Publisher) BuildConfigReference() (ConfigReference, error)

BuildConfigReference derives the live configuration reference from this operation's files.

func (*Publisher) EffectiveSkills added in v0.46.0

func (p *Publisher) EffectiveSkills() (map[string]bool, error)

EffectiveSkills returns the operation's frozen effective skill projection.

func (*Publisher) GeneratedOutput added in v0.46.0

func (p *Publisher) GeneratedOutput() (generatedcheck.AdditionalInput, error)

GeneratedOutput returns the operation's frozen generated-output input.

func (*Publisher) Glossary added in v0.46.0

func (p *Publisher) Glossary() (glossarycheck.Input, error)

Glossary returns the operation's frozen glossary input.

func (*Publisher) InitCollisions

func (p *Publisher) InitCollisions() ([]string, error)

InitCollisions uses the path-only definition projection. In particular it must remain safe before init prompts: probing a foreign path is not an authoritative render pass and never executes a template.

func (*Publisher) InitCollisionsAt added in v0.46.0

func (p *Publisher) InitCollisionsAt(root string) ([]string, error)

InitCollisionsAt probes only the supplied filesystem paths. It intentionally builds definitions, not an operation plan, so initialization can refuse a foreign file before prompting or executing a render closure.

func (*Publisher) Initialize added in v0.41.0

func (p *Publisher) Initialize(seed InitAuthority) (Result, error)

Initialize derives and publishes a first adoption in one transaction.

func (*Publisher) InitializeLeased added in v0.41.0

func (p *Publisher) InitializeLeased(ctx context.Context, lease *filesystem.Lease, seed InitAuthority) (Result, error)

InitializeLeased derives and publishes first-adoption output under the operation's pre-authority lease.

func (*Publisher) Pitfalls added in v0.46.0

func (p *Publisher) Pitfalls() (pitfall.Corpus, error)

Pitfalls returns the operation's frozen pitfall corpus. These narrow accessors share Plan's cached derivation rather than starting a second planning pass.

func (*Publisher) Plan

func (p *Publisher) Plan() (outputplan.Plan, error)

Plan returns the one immutable desired-output plan for this operation.

func (*Publisher) PreflightLocalDoc

func (p *Publisher) PreflightLocalDoc(doc config.LocalDoc) error

PreflightLocalDoc validates one candidate against the complete output inventory.

func (*Publisher) ResidentMarker added in v0.46.0

func (p *Publisher) ResidentMarker(name string) (outputplan.Output, error)

ResidentMarker selects a resident marker from this operation's one plan.

func (*Publisher) SyncLeased added in v0.41.0

func (p *Publisher) SyncLeased(ctx context.Context, lease *filesystem.Lease) (Result, error)

SyncLeased derives and publishes under a lease acquired before mutable authority loading by the operation owner.

type RenderedFile

type RenderedFile struct {
	Path         string
	Content      string
	TemplateID   string
	TemplateHash string
	ConfigHash   string
	// RegenChecked excludes this file from the frozen-OutputHash compare; its
	// drift is checked by regeneration instead (ADR-0100). Set on the generated
	// indexes and on any file carrying an in-place-editable section.
	RegenChecked bool
	// Policy declares all lifecycle checks for this path. It replaces
	// template-name and filename inference at plan consumers.
	Policy outputplan.Policy
	// Declarer identifies the producer requesting this output.
	Declarer           string
	DeclarerProjection string
	Encoder            artifactregistry.AgentDialect
	Provenance         render.CommentStyle

	// ConsumedInputs records provenance at the render seam. Definitions own
	// output identity and dependencies; observed inputs stay coupled to the
	// closure that actually consumed them.
	ConsumedInputs     []OutputInput
	ObservedTemplateID string
	// contains filtered or unexported fields
}

type Result

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

Result records only mutations committed before the terminal outcome.

func (Result) Backups

func (r Result) Backups() []Backup

func (Result) Changes

func (r Result) Changes() []Change

func (Result) Effects added in v0.41.0

func (r Result) Effects() []Effect

func (Result) HasCommittedEffects added in v0.41.0

func (r Result) HasCommittedEffects() bool

HasCommittedEffects reports whether publication crossed a mutation boundary. It lets a composing operation retain Publisher's owner-rendered partial outcome without depending on Publisher's concrete effect representation.

func (Result) Mutation

func (r Result) Mutation() (presentation.Mutation, error)

Mutation maps this semantic result to the central presentation grammar.

func (Result) PartialMutation added in v0.41.0

func (r Result) PartialMutation() (presentation.Mutation, error)

PartialMutation presents every committed effect and its recovery action.

func (Result) Pruned

func (r Result) Pruned() []string

type VarRow

type VarRow struct {
	Key, Description, Availability, State, Consumers string
}

VarRow renders one catalog var. State is the three-way live var state (set, empty, absent); it is empty in the static catalog-only model.

Jump to

Keyboard shortcuts

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