build

package
v2.22.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package build owns local file materialization evaluation.

Index

Constants

View Source
const MaterializationSchemaVersion = 1

MaterializationSchemaVersion identifies the persisted manifest format.

Variables

View Source
var (
	// ErrMaterializationNotFound indicates that no committed manifest exists.
	ErrMaterializationNotFound = errors.New("materialization not found")
	// ErrMaterializationRecovery indicates that an incomplete commit could not be recovered.
	ErrMaterializationRecovery = errors.New("materialization recovery failed")
)

Functions

func ComparisonKey

func ComparisonKey(path string) string

ComparisonKey returns the canonical path used for equality and locking.

func IdentityKey

func IdentityKey(path string) string

IdentityKey returns the canonical path used to identify one materialization.

func ResolvePath

func ResolvePath(raw, base string, output bool) (string, error)

ResolvePath returns an absolute path with existing ancestors resolved.

Types

type FileSnapshot

type FileSnapshot struct {
	Name   string `json:"name"`
	Path   string `json:"path"`
	Size   int64  `json:"size"`
	Digest string `json:"digest"`
}

FileSnapshot is a verified regular-file content snapshot.

func Snapshot

func Snapshot(name, path string) (FileSnapshot, error)

Snapshot hashes a stable regular-file snapshot.

type Materialization

type Materialization struct {
	SchemaVersion      int            `json:"schemaVersion"`
	MaterializationKey string         `json:"materializationKey"`
	CommitID           string         `json:"commitId"`
	DAGName            string         `json:"dagName"`
	StepID             string         `json:"stepId"`
	RecipeDigest       string         `json:"recipeDigest"`
	Fingerprint        string         `json:"fingerprint"`
	Inputs             []FileSnapshot `json:"inputs,omitempty"`
	Output             FileSnapshot   `json:"output"`
	ProducerRun        ir.DAGRunRef   `json:"producerRun"`
	ProducerAttemptID  string         `json:"producerAttemptId,omitempty"`
	CompletedAt        time.Time      `json:"completedAt"`
}

Materialization records one committed build output.

type MaterializationCommit

type MaterializationCommit struct {
	StagingPath      string
	FinalPath        string
	Manifest         Materialization
	PreserveManifest bool
}

MaterializationCommit describes publication of a staged output and its manifest state.

type MaterializationLock

type MaterializationLock interface {
	Release() error
}

MaterializationLock protects all paths involved in one evaluation.

type MaterializationStore

type MaterializationStore interface {
	Get(ctx context.Context, key string) (*Materialization, error)
	AcquirePaths(ctx context.Context, requests []PathLockRequest) (MaterializationLock, error)
	Commit(ctx context.Context, lock MaterializationLock, req MaterializationCommit) error
}

MaterializationStore persists manifests and coordinates path access.

type PathKeyResolver

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

PathKeyResolver caches filesystem comparison behavior for one planning or evaluation pass.

func NewPathKeyResolver

func NewPathKeyResolver() *PathKeyResolver

NewPathKeyResolver creates a path comparison key resolver.

func (*PathKeyResolver) ComparisonKey

func (r *PathKeyResolver) ComparisonKey(path string) string

ComparisonKey returns the canonical path used for equality and locking.

type PathLockMode

type PathLockMode string

PathLockMode identifies how a materialization path is protected.

const (
	PathLockShared    PathLockMode = "shared"
	PathLockExclusive PathLockMode = "exclusive"
)

type PathLockRequest

type PathLockRequest struct {
	Key  string
	Mode PathLockMode
}

PathLockRequest requests protection for one canonical filesystem path.

type PrepareRequest

type PrepareRequest struct {
	DAG                  *ir.DAG
	Step                 ir.Step
	DAGRunID             string
	AttemptID            string
	WorkingDir           string
	RunWorkDir           string
	Shell                []string
	Environment          map[string]string
	HasSecrets           bool
	NoReuse              bool
	Dry                  bool
	Deferred             bool
	ControlDependencyRan bool
	ControlTokens        map[string]string
}

PrepareRequest contains resolved runtime information used before execution.

type Session

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

Session holds path locks and one ready-node materialization decision.

func Prepare

func Prepare(ctx context.Context, store MaterializationStore, request PrepareRequest) (*Session, error)

Prepare acquires path locks for a ready node before its preconditions run.

func (*Session) Close

func (s *Session) Close(staging string) error

Close releases path locks and removes an uncommitted staging file.

func (*Session) Commit

func (s *Session) Commit(ctx context.Context, staging string) error

Commit verifies an attempt and publishes its materialization.

func (*Session) Evaluate

func (s *Session) Evaluate(ctx context.Context) error

Evaluate snapshots inputs and selects execution or reuse after preconditions pass.

func (*Session) HasPathOutput

func (s *Session) HasPathOutput() bool

HasPathOutput reports whether the session stages and publishes an output.

func (*Session) InputPaths

func (s *Session) InputPaths() map[string]string

InputPaths returns final input paths scoped to the step.

func (*Session) Metadata

func (s *Session) Metadata() ir.BuildExecution

Metadata returns the current persisted decision metadata.

func (*Session) NewAttempt

func (s *Session) NewAttempt(retry int) (map[string]string, string, error)

NewAttempt allocates a fresh absent sibling staging path.

func (*Session) PublishedOutputs

func (s *Session) PublishedOutputs() map[string]string

PublishedOutputs returns final path outputs after reuse or commit.

func (*Session) Reused

func (s *Session) Reused() bool

Reused reports whether executor execution is unnecessary.

func (*Session) SetResolvedRecipe

func (s *Session) SetResolvedRecipe(step ir.Step, environment map[string]string)

SetResolvedRecipe supplies the execution fields used by the reuse decision. It must be called before Evaluate.

Jump to

Keyboard shortcuts

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