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

artifact

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package artifact defines executable Piglet component plans and artifact records. pig additive (D18): Piglet builds record exact component realization and materialization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateBinaryLink(resolution, binary Record) error

ValidateBinaryLink verifies that one Piglet Binary record references the exact supplied resolution record and repeats its derived graph identities.

func ValidatePlan

func ValidatePlan(plan Plan) error

ValidatePlan verifies a decoded plan's vocabulary, ordering, identities, and digest.

func ValidateRecord

func ValidateRecord(record Record) error

ValidateRecord verifies a decoded Piglet record's canonical shape and digest.

Types

type Artifact

type Artifact struct {
	Digest   string `json:"digest"`
	Size     int64  `json:"size"`
	FileName string `json:"fileName"`
}

Artifact identifies a built Piglet artifact without coupling it to a local path.

type Binary

type Binary struct {
	ResolutionDigest      string              `json:"resolutionDigest"`
	GraphDigest           string              `json:"graphDigest"`
	ResourceClosureDigest string              `json:"resourceClosureDigest"`
	ComponentPlanDigest   string              `json:"componentPlanDigest"`
	Target                string              `json:"target"`
	PigVersion            string              `json:"pigVersion"`
	PigSourceRevision     string              `json:"pigSourceRevision"`
	PigSourceDigest       string              `json:"pigSourceDigest"`
	Builder               string              `json:"builder"`
	BuilderIdentity       string              `json:"builderIdentity"`
	Toolchains            map[string]string   `json:"toolchains"`
	Artifact              Artifact            `json:"artifact"`
	Verification          Verification        `json:"verification"`
	Environment           *EnvironmentBinding `json:"environment,omitempty"`
}

Binary is the immutable payload of a piglet-binary record.

type BinaryInput

type BinaryInput struct {
	Target            string
	PigVersion        string
	PigSourceRevision string
	PigSourceDigest   string
	Builder           string
	BuilderIdentity   string
	Toolchains        map[string]string
	Artifact          Artifact
	Verification      Verification
	Environment       *EnvironmentBinding
}

BinaryInput contains produced-artifact facts before resolution identities are derived.

type Component

type Component struct {
	Kind            ComponentKind       `json:"kind"`
	Name            string              `json:"name"`
	Origin          Origin              `json:"origin"`
	Language        string              `json:"language,omitempty"`
	Realization     Realization         `json:"realization"`
	Materialization Materialization     `json:"materialization"`
	Runtime         *RuntimeRequirement `json:"runtime,omitempty"`
}

Component is one resolved executable/runtime member of an immutable Piglet plan.

func (Component) ID

func (c Component) ID() string

ID returns the stable kind/name identity used for ordering and duplicate checks.

type ComponentInput

type ComponentInput struct {
	Kind              ComponentKind
	Name              string
	Origin            Origin
	Language          string
	Fusible           bool
	IsolationRequired bool
	External          bool
	Materialization   Materialization
	Runtime           *RuntimeRequirement
}

ComponentInput contains resolver/build facts used to choose executable component realization.

type ComponentKind

type ComponentKind string

ComponentKind identifies an executable/runtime Piglet component class.

const (
	// ComponentKindExtension is a Pig extension.
	ComponentKindExtension ComponentKind = "extension"
	// ComponentKindMCP is an MCP process or remote service adapter.
	ComponentKindMCP ComponentKind = "mcp"
	// ComponentKindHook is an executable hook.
	ComponentKindHook ComponentKind = "hook"
)

type EnvironmentBinding

type EnvironmentBinding struct {
	Identity    string `json:"identity"`
	ImageDigest string `json:"imageDigest"`
}

EnvironmentBinding pairs an artifact with its required runtime environment.

type InputPin

type InputPin struct {
	Kind    string `json:"kind"`
	Name    string `json:"name"`
	Source  string `json:"source"`
	Version string `json:"version,omitempty"`
	Digest  string `json:"digest"`
	Package string `json:"package,omitempty"`
	Plugin  string `json:"plugin,omitempty"`
}

InputPin is one exact Resource or dependency identity in a Piglet resolution.

type Materialization

type Materialization string

Materialization describes where one component's executable/runtime closure is supplied.

const (
	// MaterializationBinary carries the component in the Piglet Binary.
	MaterializationBinary Materialization = "binary"
	// MaterializationRelease supplies the component from the managed Piglet release.
	MaterializationRelease Materialization = "release"
	// MaterializationAgentEnvironment supplies the component from agentEnv.
	MaterializationAgentEnvironment Materialization = "agentEnv"
	// MaterializationExternal requires an explicit external mapping.
	MaterializationExternal Materialization = "external"
)

type Origin

type Origin struct {
	Source  string `json:"source"`
	Version string `json:"version,omitempty"`
	Digest  string `json:"digest"`
	Package string `json:"package,omitempty"`
	Plugin  string `json:"plugin,omitempty"`
}

Origin is the exact source identity of one Piglet component.

type Plan

type Plan struct {
	Components []Component `json:"components"`
	Digest     string      `json:"digest"`
}

Plan is the deterministic executable component realization plan for one resolved Piglet.

func BuildPlan

func BuildPlan(inputs []ComponentInput) (Plan, error)

BuildPlan validates resolver facts, chooses realization, and returns a stable plan.

type Realization

type Realization string

Realization describes how one Piglet component executes.

const (
	// RealizationFused registers a compatible Go factory in-process.
	RealizationFused Realization = "fused"
	// RealizationSubprocess starts the component through Pig's extension host.
	RealizationSubprocess Realization = "subprocess"
	// RealizationExternal connects to a separately managed service.
	RealizationExternal Realization = "external"
)

type Record

type Record struct {
	Kind           RecordKind  `json:"kind"`
	Piglet         string      `json:"piglet"`
	ReleaseVersion string      `json:"releaseVersion,omitempty"`
	CreatedAt      string      `json:"createdAt"`
	Resolution     *Resolution `json:"resolution,omitempty"`
	Binary         *Binary     `json:"binary,omitempty"`
	Digest         string      `json:"digest,omitempty"`
}

Record is the first-production Piglet record envelope.

func NewBinaryRecord

func NewBinaryRecord(piglet, releaseVersion string, createdAt time.Time, resolution Record, input BinaryInput) (Record, error)

NewBinaryRecord binds one built Piglet Binary to an exact resolution record.

func NewResolutionRecord

func NewResolutionRecord(piglet, releaseVersion string, createdAt time.Time, input ResolutionInput) (Record, error)

NewResolutionRecord validates and canonicalizes one Piglet source resolution.

func ParseRecord

func ParseRecord(data []byte) (Record, error)

ParseRecord decodes one closed Piglet record document and verifies its canonical payload and digest.

type RecordKind

type RecordKind string

RecordKind is the closed vocabulary for first-production Piglet records.

const (
	// RecordKindResolution pins Piglet source, Resource closure, and executable planning.
	RecordKindResolution RecordKind = "piglet-resolution"
	// RecordKindBinary identifies one built Piglet Binary.
	RecordKindBinary RecordKind = "piglet-binary"
	// RecordKindImage identifies one built Piglet Image.
	RecordKindImage RecordKind = "piglet-image"
)

type Resolution

type Resolution struct {
	SourceDigest          string     `json:"sourceDigest"`
	EffectiveDigest       string     `json:"effectiveDigest"`
	GraphDigest           string     `json:"graphDigest"`
	ResourceClosureDigest string     `json:"resourceClosureDigest"`
	Inputs                []InputPin `json:"inputs"`
	ComponentPlan         Plan       `json:"componentPlan"`
}

Resolution is the immutable payload of a piglet-resolution record.

type ResolutionInput

type ResolutionInput struct {
	SourceDigest    string
	EffectiveDigest string
	Inputs          []InputPin
	ComponentPlan   Plan
}

ResolutionInput contains source-resolution facts before derived digests are calculated.

type RuntimeRequirement

type RuntimeRequirement struct {
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
	Target  string `json:"target,omitempty"`
}

RuntimeRequirement identifies a language or native runtime needed by a component.

type Verification

type Verification struct {
	Policy string   `json:"policy"`
	Passed bool     `json:"passed"`
	Checks []string `json:"checks"`
}

Verification is the mandatory verification result attached to an artifact.

Jump to

Keyboard shortcuts

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