Documentation
¶
Overview ¶
Package core defines the abstract interfaces for Platform Factory's domain.
Package core defines the abstract interfaces for Platform Factory's domain.
Index ¶
- Constants
- Variables
- func CanTransition(from, to Phase) bool
- func DeriveID(domain string, parts ...string) string
- func IsValidCapability(capability string) bool
- func ValidOperationID(id OperationID) bool
- func ValidateCapability(capability string) error
- type ArtifactDeclaration
- type ArtifactDescriptor
- type ArtifactDigest
- type ArtifactReference
- type BuildPlan
- type CacheMount
- type CacheStageKeyInputs
- type CacheStore
- type CapabilitySet
- type Command
- type DeploymentSpec
- type Descriptor
- type EvidenceBundle
- type ImageReference
- type Input
- type Mount
- type NetworkPolicy
- type NetworkRelay
- type OperationID
- type OperationJournal
- type OperationRecord
- type OperationStatus
- type Output
- type Phase
- type Pipeline
- type PluginFamily
- type PluginID
- type PluginManifest
- type PluginPermissions
- type PolicyDecision
- type RecordIndex
- type ResourceLimits
- type RuntimeSpec
- type RuntimeState
- type SandboxPolicy
- type SecretReference
- type Stage
- type TransitionRule
- type WorkloadID
- type WorkloadSpec
Constants ¶
const ( PipelineAPIVersion = "platform-factory.dev/v1" PipelineLegacyAPIVersion = "secure-oci.dev/v1" PipelineBetaAPIVersion = "platform-factory.dev/v1beta1" PipelineBetaLegacyAPIVersion = "secure-oci.dev/v1beta1" PipelineAlphaAPIVersion = "platform-factory.dev/v1alpha1" PipelineAlphaLegacyAPIVersion = "secure-oci.dev/v1alpha1" // APIVersion aliases the oldest accepted wire identifier for internal tests // and fixtures. Domain validation accepts all compatibility versions. APIVersion = PipelineAlphaAPIVersion LegacyAPIVersion = PipelineAlphaLegacyAPIVersion )
Variables ¶
var ErrOperationIndeterminate = errors.New("operation outcome is indeterminate; re-observe external state")
ErrOperationIndeterminate means a mutation may have happened but no durable terminal observation exists. Callers must observe external state before any retry.
Functions ¶
func CanTransition ¶
CanTransition reports whether from -> to is an allowed transition.
func DeriveID ¶
DeriveID returns a domain-separated, deterministic identity. Domain names are versioned by callers; NUL framing prevents ambiguous part boundaries.
func IsValidCapability ¶
IsValidCapability is a convenience function that returns true if the capability is valid.
func ValidOperationID ¶
func ValidOperationID(id OperationID) bool
ValidOperationID rejects values that cannot safely identify a journal record. The same validation applies to every journal adapter.
func ValidateCapability ¶
ValidateCapability checks if a capability string is valid for use in a manifest. This is exported for use by other packages that need to validate capabilities.
Types ¶
type ArtifactDeclaration ¶
type ArtifactDescriptor ¶
type ArtifactDescriptor struct {
Digest ArtifactDigest `json:"digest,omitempty"`
}
func (ArtifactDescriptor) Validate ¶
func (a ArtifactDescriptor) Validate() error
type ArtifactDigest ¶
type ArtifactDigest string
type ArtifactReference ¶
type BuildPlan ¶
type BuildPlan struct {
WorkloadID WorkloadID `json:"workload_id,omitempty"`
}
type CacheMount ¶
type CacheStageKeyInputs ¶
type CacheStageKeyInputs struct {
EngineVersion string
Stage Stage
BaseDigest string
InputDigests []string
Platform string
}
CacheStageKeyInputs is the core-owned input to deterministic stage-key computation. Concrete cache implementations consume this contract without leaking their types back into the domain.
type CacheStore ¶
type CacheStore interface {
// Put streams content into the cache and returns a descriptor.
// Identical content is deduplicated.
Put(r io.Reader) (Descriptor, error)
// Get retrieves cached content by digest.
// Returns nil reader if not found.
Get(digest string) (io.ReadCloser, error)
// StageKey computes a deterministic cache key for a stage's inputs.
StageKey(inputs CacheStageKeyInputs) (string, error)
// GetRecord retrieves a cached record by key.
GetRecord(key string, out any) (bool, error)
// PutRecord stores a record under a key.
PutRecord(key string, value any) error
// Verify checks that a cached blob's content matches its digest.
Verify(digest string) error
}
CacheStore is the interface that pipeline stages use to store and retrieve content-addressed build artifacts. It abstracts the concrete implementation in internal/cache, allowing internal/executor to depend only on this interface.
type CapabilitySet ¶
type CapabilitySet struct {
Capabilities []string `json:"capabilities,omitempty"`
}
type DeploymentSpec ¶
type DeploymentSpec struct {
Runtime RuntimeSpec `json:"runtime,omitempty"`
}
func (DeploymentSpec) Validate ¶
func (d DeploymentSpec) Validate() error
type Descriptor ¶
Descriptor identifies a stored blob by its content digest and size.
type EvidenceBundle ¶
type EvidenceBundle struct {
Artifacts []ArtifactDescriptor `json:"artifacts,omitempty"`
}
func (EvidenceBundle) Validate ¶
func (e EvidenceBundle) Validate() error
type ImageReference ¶
type NetworkPolicy ¶
type NetworkPolicy string
const ( NetworkNone NetworkPolicy = "none" NetworkResolve NetworkPolicy = "resolve" NetworkFull NetworkPolicy = "full" )
type NetworkRelay ¶
type NetworkRelay interface {
// ServeRelay exchanges length-prefixed DNS datagrams over a connected,
// message-oriented transport. It is the host side of the resolve-only
// sandbox data plane.
ServeRelay(ctx context.Context, conn net.Conn) error
// GetUpstream returns the configured upstream resolver address.
GetUpstream() netip.AddrPort
// GetTimeout returns the configured timeout for DNS operations.
GetTimeout() int64
// GetMaxInflight returns the maximum number of concurrent DNS requests.
GetMaxInflight() int
}
NetworkRelay is the interface for network forwarding capabilities. It abstracts the concrete DNSForwarder implementation in internal/networking, allowing internal/executor to depend only on this interface.
type OperationID ¶
type OperationID string
type OperationJournal ¶
type OperationJournal interface {
Lookup(OperationID) (OperationRecord, bool)
Start(OperationID, string) (bool, error)
Complete(OperationID) error
Fail(OperationID) error
}
OperationJournal is the single idempotency persistence port. Start is an atomic claim: exactly one caller may receive started=true for an ID/scope.
type OperationRecord ¶
type OperationRecord struct {
ID OperationID
Status OperationStatus
Scope string
}
OperationRecord contains only replay-safe identity and state. Plugin output and provider errors are deliberately excluded because both may contain secrets or other untrusted data.
type OperationStatus ¶
type OperationStatus string
OperationStatus is the durable state of a logical mutation.
const ( OperationStarted OperationStatus = "started" OperationCompleted OperationStatus = "completed" OperationFailed OperationStatus = "failed" )
type Phase ¶
type Phase string
Phase is the canonical workload state shared by every backend.
const ( PhaseDeclared Phase = "Declared" PhasePlanned Phase = "Planned" PhaseBuilding Phase = "Building" PhaseBuilt Phase = "Built" PhasePublishing Phase = "Publishing" PhasePublished Phase = "Published" PhaseDeploying Phase = "Deploying" PhaseRunning Phase = "Running" PhaseStopping Phase = "Stopping" PhaseStopped Phase = "Stopped" PhaseDeleting Phase = "Deleting" PhaseDeleted Phase = "Deleted" PhaseFailed Phase = "Failed" // PhaseUnknown is not a terminal or working state - it means the // authoritative external system (containerd/KubeVirt/Kubernetes) // could not be reached to confirm what the real state is. A caller // observing Unknown must re-query rather than assume the last phase. PhaseUnknown Phase = "Unknown" )
type Pipeline ¶
type Pipeline struct {
APIVersion string `json:"api_version"`
Name string `json:"name"`
RequiredCapabilities []string `json:"required_capabilities,omitempty"`
Inputs []Input `json:"inputs,omitempty"`
Stages []Stage `json:"stages"`
Outputs []Output `json:"outputs,omitempty"`
}
Pipeline is the private canonical model consumed by pipeline domain services. Public API versions are wire DTOs and are converted at composition boundaries.
type PluginFamily ¶
type PluginFamily string
PluginFamily groups plugins for discovery; routing uses capabilities.
const ( PluginFamilyLanguage PluginFamily = "language" PluginFamilyAnalyzer PluginFamily = "analyzer" PluginFamilyBuild PluginFamily = "build" PluginFamilyRuntime PluginFamily = "runtime" PluginFamilyDeployment PluginFamily = "deployment" PluginFamilyCapability PluginFamily = "capability" )
type PluginManifest ¶
type PluginManifest struct {
ID PluginID `json:"id" yaml:"id"`
Version string `json:"version" yaml:"version"`
ProtocolVersion int `json:"protocol_version" yaml:"protocol_version"`
Family PluginFamily `json:"family" yaml:"family"`
Capabilities []string `json:"capabilities,omitempty" yaml:"capabilities,omitempty"`
Permissions PluginPermissions `json:"permissions,omitempty" yaml:"permissions,omitempty"`
}
PluginManifest declares a plugin's identity, protocol, capabilities, and permissions.
func (PluginManifest) HasCapability ¶
func (m PluginManifest) HasCapability(capability string) bool
HasCapability reports whether the manifest declares it can perform capability. The core asks this - never a plugin-identity check - to decide whether to route an operation to a plugin at all.
func (PluginManifest) SupportsProtocol ¶
func (m PluginManifest) SupportsProtocol(hostSupported ...int) bool
SupportsProtocol reports whether the manifest's declared protocol version is one the host negotiating against it understands. Hosts should refuse a protocol version they do not support.
func (PluginManifest) Validate ¶
func (m PluginManifest) Validate() error
Validate checks the manifest is well-formed: every required field is present, the declared family is one this codebase recognizes, and there are no duplicate capability entries (a duplicate is always either a copy-paste mistake or an attempt to make a capability look more heavily supported than it is - reject it rather than silently dedup, so the author sees the mistake).
type PluginPermissions ¶
type PluginPermissions struct {
Network []string `json:"network,omitempty" yaml:"network,omitempty"`
Filesystem []string `json:"filesystem,omitempty" yaml:"filesystem,omitempty"`
Secrets []string `json:"secrets,omitempty" yaml:"secrets,omitempty"`
}
PluginPermissions is the least-privilege declaration a manifest makes: every capability accessed outside the plugin's own confined workspace must be named here, not assumed. An empty PluginPermissions is the correct declaration for a plugin that needs none of these - the zero value is deliberately the most restrictive one, not "unspecified."
type PolicyDecision ¶
type PolicyDecision struct {
Allowed bool `json:"allowed"`
}
type RecordIndex ¶
type RecordIndex map[string]map[string]Descriptor
RecordIndex maps stage keys to their output descriptors.
type ResourceLimits ¶
type RuntimeSpec ¶
type RuntimeSpec struct {
Kind string `json:"kind,omitempty"`
}
func (RuntimeSpec) Validate ¶
func (r RuntimeSpec) Validate() error
type RuntimeState ¶
type RuntimeState struct {
Phase Phase `json:"phase,omitempty"`
}
RuntimeState is a workload's canonical state - see statemachine.go for the Phase values it may hold and the transitions between them. This is the single state every backend (containerd, KubeVirt, Kubernetes, Docker, Podman) translates its own native state into; none of them invent their own meaning for what "running" means.
func (RuntimeState) TransitionTo ¶
func (s RuntimeState) TransitionTo(to Phase) (RuntimeState, error)
TransitionTo returns a new RuntimeState with Phase set to to, if the move from s.Phase is allowed. s itself is never mutated. An empty s.Phase is treated as PhaseDeclared's starting point implicitly only when to is PhaseDeclared itself (a freshly-declared workload has no prior phase to transition from); every other case requires an explicit, valid current phase.
type SandboxPolicy ¶
type SecretReference ¶
type Stage ¶
type Stage struct {
ID string `json:"id"`
DependsOn []string `json:"depends_on,omitempty"`
Base *ImageReference `json:"base,omitempty"`
Command Command `json:"command"`
Env map[string]string `json:"env,omitempty"`
Mounts []Mount `json:"mounts,omitempty"`
Secrets []SecretReference `json:"secrets,omitempty"`
Caches []CacheMount `json:"caches,omitempty"`
Inputs []ArtifactReference `json:"inputs,omitempty"`
Outputs []ArtifactDeclaration `json:"outputs,omitempty"`
Network NetworkPolicy `json:"network,omitempty"`
Resources ResourceLimits `json:"resources,omitempty"`
Sandbox SandboxPolicy `json:"sandbox,omitempty"`
}
type TransitionRule ¶
TransitionRule documents one allowed state change: whether it's safe to repeat verbatim after a crash (Idempotent), and what a caller must do to compensate for a partial attempt before it may retry (Compensation, empty when no cleanup is needed).
func LookupTransition ¶
func LookupTransition(from, to Phase) (TransitionRule, bool)
LookupTransition returns the rule governing from -> to, if that transition is allowed.
type WorkloadID ¶
type WorkloadID string
type WorkloadSpec ¶
type WorkloadSpec struct {
ID WorkloadID `json:"id,omitempty"`
Version string `json:"version,omitempty"`
}
func (WorkloadSpec) Validate ¶
func (s WorkloadSpec) Validate() error