Documentation
¶
Index ¶
- Constants
- Variables
- func CIContextKV() []output.DomainKV
- func CollectTargetsByKind(cfg *config.Config, kind string) []config.TargetConfig
- func ExecutorPreflightWithWriter(w io.Writer, rootDir string, opts runner.Options, color bool) runner.ExecutionReport
- func RenderContractPanel(w io.Writer, unrendered []trace.Emission, color bool)
- func RenderExecutorSection(w io.Writer, report runner.ExecutionReport, opts runner.Options, color bool, ...)
- func RenderExitReason(w io.Writer, f *FailureDetail)
- func RunLint(ctx context.Context, appCfg *config.Config, rootDir string, isCI bool, ...) (string, error)
- type FailureDetail
- type Phase
- type PhaseResult
- type Pipeline
- type PipelineContext
- type PostBuildHook
Constants ¶
const FailureDetailFile = ".stagefreight/failure-detail.json"
FailureDetailFile is the well-known path (relative to rootDir) where the inner build writes FailureDetail for the outer crucible to pick up.
Variables ¶
var ErrContractViolation = errors.New("contract violation: unrendered emissions")
ErrContractViolation is returned when one or more emissions were never rendered. A contract violation means the UI did not surface all execution truth. CI must treat this as a hard failure — exit code 5 by convention.
var ErrDryRunExit = errors.New("dry-run exit")
ErrDryRunExit is a sentinel returned by DryRunGate to signal a clean exit. Pipeline.Run recognizes this and returns nil after rendering a partial summary.
Functions ¶
func CIContextKV ¶
CIContextKV returns the code identity KV pairs for the ContextBlock. Exactly two items: Commit SHA and Branch or Tag. Pipeline, Runner, Platforms, and Registries are NOT here — they belong to their owning domain panels (DomainExecution, DomainPlan, DomainResult).
func CollectTargetsByKind ¶
func CollectTargetsByKind(cfg *config.Config, kind string) []config.TargetConfig
CollectTargetsByKind returns all targets matching the given kind.
func ExecutorPreflightWithWriter ¶ added in v0.6.0
func ExecutorPreflightWithWriter(w io.Writer, rootDir string, opts runner.Options, color bool) runner.ExecutionReport
renderRunnerSection renders the DomainExecution panel box. Row order is fixed: identity → separator → substrate → separator → health → [findings]. Rule 8: substrate rows always present when fact exists. Rule 10: info-severity findings never appear as finding rows. ExecutorPreflightWithWriter is the exported equivalent of the cmd-package executorPreflight helper, for callers that own their own io.Writer (e.g. crucible). Runs substrate assessment, renders the Executor panel to w, persists to cistate. Returns the report so callers can inspect Health and abort on Unhealthy.
func RenderContractPanel ¶ added in v0.6.0
RenderContractPanel renders the enforcement panel when unrendered emissions exist. Called at end of Pipeline.Run() — never by phase code. Groups unrendered emissions by domain for operator readability.
func RenderExecutorSection ¶ added in v0.6.0
func RenderExecutorSection(w io.Writer, report runner.ExecutionReport, opts runner.Options, color bool, elapsed time.Duration)
RenderExecutorSection renders the DomainExecution panel box. Exported for callers that need to render without running preflight (e.g. tests).
func RenderExitReason ¶
func RenderExitReason(w io.Writer, f *FailureDetail)
RenderExitReason renders the operator-facing Exit Reason box. Single-line when command + exit code + reason fit in ~80 chars, two-line otherwise. Exported so the outer crucible path can call it.
func RunLint ¶ added in v0.6.0
func RunLint(ctx context.Context, appCfg *config.Config, rootDir string, isCI bool, color bool, verbose bool, w io.Writer) (string, error)
RunLint delegates to the pre-build lint implementation. Called by runUniversalLint in ci_runners — decouples runner layer from lint internals.
Types ¶
type FailureDetail ¶
type FailureDetail struct {
Command string // "docker push cr.pcfae.com/prplanit/stagefreight:dev-ff98a93"
ExitCode int // 1
Reason string // "HTTP 500 (registry)"
Stderr string // raw stderr for --verbose
}
FailureDetail captures operator-meaningful error context for the Exit Reason section.
func ReadFailureDetail ¶
func ReadFailureDetail(rootDir string) *FailureDetail
ReadFailureDetail loads a FailureDetail written by a crucible child. Returns nil if the file doesn't exist or can't be parsed.
type Phase ¶
type Phase struct {
Name string
Run func(pc *PipelineContext) (*PhaseResult, error)
}
Phase is a named unit of pipeline work.
func BannerPhase ¶
func BannerPhase() Phase
BannerPhase renders the StageFreight banner and code identity block. Code panel: Commit + Branch/Tag only. No pipeline, runner, platforms, or registries — those belong to their domain panels (Execution, Plan, Result).
func ConfigPhase ¶ added in v0.6.0
func ConfigPhase(report config.ConfigReport) Phase
ConfigPhase renders the DomainConfig panel from a ConfigReport. Always present — surfaces the "Explain" layer of config resolution. Status is "partial" when preset resolution failed or was incomplete.
Emission-driven: all config truth is emitted to pc.Trace first. Panel renders exclusively from pc.Trace.ForDomain("config"). The global contract check at end of Pipeline.Run catches anything not rendered.
func DryRunGate ¶
func DryRunGate(renderPlan func(pc *PipelineContext)) Phase
DryRunGate checks pc.DryRun and, if true, calls renderPlan then returns ErrDryRunExit.
func ExecutorPreflightPhase ¶ added in v0.6.0
ExecutorPreflightPhase runs execution substrate checks and renders the Executor section. This is the DomainExecution panel — it absorbs Pipeline ID, Runner name, engine detection, and substrate health from the former ContextBlock.
Skip conditions: crucible child pass (pass-2 substrate is not meaningful to report).
type PhaseResult ¶
type PhaseResult struct {
Name string
Status string // "success", "failed", "skipped"
Summary string // one-line detail
Elapsed time.Duration
Details map[string]string // optional structured metadata
Failure *FailureDetail // operator-facing error context; nil on success
}
PhaseResult is what each phase reports for the summary table.
type Pipeline ¶
type Pipeline struct {
Phases []Phase
Hooks []PostBuildHook
}
Pipeline orchestrates build phases and hooks.
func (*Pipeline) Run ¶
func (p *Pipeline) Run(pc *PipelineContext) error
Run iterates phases in order. On phase error (and StopOnPhaseError): renders partial summary, returns error. On ErrDryRunExit: renders partial summary, returns nil (clean exit). Then runs hooks conditionally (nil Condition = always run; errors recorded, not fatal). Finally renders summary table from pc.Results.
type PipelineContext ¶
type PipelineContext struct {
Ctx context.Context
RootDir string
Config *config.Config
Writer io.Writer
Color bool
CI bool
Verbose bool
SkipLint bool
DryRun bool
Local bool
PipelineStart time.Time
BuildPlan *build.BuildPlan // set by build planning phases when applicable; nil for pipelines with no build plan
Results []PhaseResult // accumulated by pipeline runner
// Trace is the truth emission collector for this pipeline run.
// All inputs, decisions, mutations, and side effects emit through it.
// Panels render from it; enforcement validates completeness at end of run.
// Never nil — initialized by Pipeline.Run if not set by caller.
Trace *trace.Collector
// Scratch is a state bag for command-specific data flowing between phases.
// Keys are package-scoped conventions (e.g., "binary.steps", "docker.engine").
// Cross-package pipeline state uses typed fields above, not Scratch.
Scratch map[string]any
}
PipelineContext is the shared state bag threaded through all phases.
type PostBuildHook ¶
type PostBuildHook struct {
Name string
Condition func(pc *PipelineContext) bool
Run func(pc *PipelineContext) (*PhaseResult, error)
}
PostBuildHook is optional post-build work with a condition gate. nil Condition means "always run".