scaffold

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package scaffold renders module artifacts deterministically from a schema-validated module_facts.json (ADR-0027 Decision 1: "agents emit facts, a deterministic templater renders CUE"). Given the same facts and the same repo templates, Render always produces byte-identical output — that property is gate G0.

Index

Constants

View Source
const FactsSchemaVersion = "1.0.0"

FactsSchemaVersion is the version this package renders. It is written into scaffolded artifacts and checked on load.

Variables

This section is empty.

Functions

func Render

func Render(f *Facts) (map[string]string, error)

Render turns validated facts into the module's artifacts, keyed by path relative to the module directory. Output is deterministic: same facts → byte-identical files (gate G0).

Types

type Facts

type Facts struct {
	FactsSchemaVersion string          `json:"facts_schema_version"`
	Slug               string          `json:"slug"`
	DisplayName        string          `json:"displayName"`
	Description        string          `json:"description"`
	Rationale          string          `json:"rationale,omitempty"`
	Layer              string          `json:"layer"`
	Maturity           string          `json:"maturity,omitempty"`
	Core               *bool           `json:"core,omitempty"`
	ToolClass          string          `json:"tool_class,omitempty"`
	Requires           *FactsRequires  `json:"requires,omitempty"`
	Placement          *FactsPlacement `json:"placement,omitempty"`
	Services           []FactsService  `json:"services"`
}

Facts is the constrained input the promotion-drafter emits. It is the only LLM-authored surface; everything the templater renders is a pure function of these facts plus the repo templates.

func LoadFacts

func LoadFacts(data []byte) (*Facts, error)

LoadFacts unmarshals and validates a module_facts.json document.

func LoadFactsWithCatalog

func LoadFactsWithCatalog(data, catalog []byte) (*Facts, error)

LoadFactsWithCatalog resolves referenced images before normal validation.

type FactsAccessPolicy

type FactsAccessPolicy struct {
	OuterAuth string `json:"outerAuth"`
	AppAuth   string `json:"appAuth,omitempty"`
}

FactsAccessPolicy is the auth posture for a routed service.

type FactsHealthCheck

type FactsHealthCheck struct {
	Type     string `json:"type"` // "http" | "command"
	Path     string `json:"path,omitempty"`
	Port     int    `json:"port,omitempty"`
	Scheme   string `json:"scheme,omitempty"`
	Command  string `json:"command,omitempty"`
	Interval string `json:"interval,omitempty"`
	Timeout  string `json:"timeout,omitempty"`
	Retries  int    `json:"retries,omitempty"`
}

FactsHealthCheck is either an HTTP probe (path+port) or a shell command.

type FactsImageSource

type FactsImageSource struct {
	ModuleRef    string `json:"moduleRef"`
	ComponentRef string `json:"componentRef"`
}

FactsImageSource selects an immutable image from the compiled CUE catalog. A referenced service never maintains its own image or tag.

type FactsInfra

type FactsInfra struct {
	Docker            *bool  `json:"docker,omitempty"`
	Network           string `json:"network,omitempty"`
	DockerSocket      bool   `json:"dockerSocket,omitempty"`
	PersistentStorage bool   `json:"persistentStorage,omitempty"`
	MinMemory         string `json:"minMemory,omitempty"`
	Arch              string `json:"arch,omitempty"`
}

FactsInfra declares infrastructure requirements.

type FactsOSV

type FactsOSV struct {
	Ecosystem string `json:"ecosystem"`
	Name      string `json:"name"`
}

FactsOSV is the secondary advisory source.

type FactsPlacement

type FactsPlacement struct {
	LocalOnly         *bool `json:"localOnly,omitempty"`
	Standard          *bool `json:"standard,omitempty"`
	ManagedServerless bool  `json:"managedServerless,omitempty"`
}

FactsPlacement is the module placement eligibility. managed_serverless stays false unless the facts prove eligibility (and never with dockerSocket).

type FactsRequiredService

type FactsRequiredService struct {
	MinVersion string   `json:"minVersion,omitempty"`
	Provides   []string `json:"provides,omitempty"`
	Optional   bool     `json:"optional,omitempty"`
}

FactsRequiredService is a dependency on another module.

type FactsRequires

type FactsRequires struct {
	Services       map[string]FactsRequiredService `json:"services,omitempty"`
	Infrastructure *FactsInfra                     `json:"infrastructure,omitempty"`
}

FactsRequires declares dependency + infrastructure needs.

type FactsResources

type FactsResources struct {
	Memory    string  `json:"memory"`
	MemoryMax string  `json:"memoryMax,omitempty"`
	CPUs      float64 `json:"cpus,omitempty"`
}

FactsResources are container limits.

type FactsSecurity

type FactsSecurity struct {
	NoNewPrivileges *bool    `json:"noNewPrivileges,omitempty"`
	CapDrop         []string `json:"capDrop,omitempty"`
	ReadOnly        bool     `json:"readOnly,omitempty"`
	Tmpfs           []string `json:"tmpfs,omitempty"`
}

FactsSecurity is the hardening block; house defaults are enforced on render.

type FactsService

type FactsService struct {
	Name         string             `json:"name"`
	Type         string             `json:"type"`
	Image        string             `json:"image"`
	Tag          string             `json:"tag,omitempty"`
	ImageSource  *FactsImageSource  `json:"imageSource,omitempty"`
	Required     *bool              `json:"required,omitempty"`
	Needs        []string           `json:"needs,omitempty"`
	Routed       bool               `json:"routed,omitempty"`
	Traefik      *FactsTraefik      `json:"traefik,omitempty"`
	Networks     []string           `json:"networks,omitempty"`
	AccessPolicy *FactsAccessPolicy `json:"accessPolicy,omitempty"`
	HealthCheck  *FactsHealthCheck  `json:"healthCheck,omitempty"`
	Resources    *FactsResources    `json:"resources,omitempty"`
	Security     *FactsSecurity     `json:"security,omitempty"`
	Volumes      []FactsVolume      `json:"volumes,omitempty"`
	Environment  map[string]string  `json:"environment,omitempty"`
	Upstream     *FactsUpstream     `json:"upstream,omitempty"`
	Subdomain    *FactsSubdomain    `json:"subdomain,omitempty"`
}

FactsService is one container the module deploys.

type FactsSubdomain

type FactsSubdomain struct {
	Key    string `json:"key"`
	Nested string `json:"nested"`
	Flat   string `json:"flat"`
}

FactsSubdomain is the domain-computation routing key.

type FactsTraefik

type FactsTraefik struct {
	Rule string `json:"rule"`
	Port int    `json:"port"`
}

FactsTraefik carries routing coordinates for a routed service.

type FactsUpstream

type FactsUpstream struct {
	GitHub        string    `json:"github,omitempty"`
	RegistryImage string    `json:"registryImage,omitempty"`
	Track         string    `json:"track,omitempty"`
	PinLine       string    `json:"pinLine,omitempty"`
	OSV           *FactsOSV `json:"osv,omitempty"`
}

FactsUpstream carries ADR-0028 watch coordinates.

type FactsVolume

type FactsVolume struct {
	Source      string `json:"source"`
	Target      string `json:"target"`
	Type        string `json:"type,omitempty"` // "volume" | "bind"
	ReadOnly    bool   `json:"readOnly,omitempty"`
	Backup      bool   `json:"backup,omitempty"`
	Description string `json:"description,omitempty"`
}

FactsVolume is a mount with a backup classification.

Jump to

Keyboard shortcuts

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