Documentation
¶
Overview ¶
Package candidate stores versioned, immutable candidate content without runtime execution dependencies.
Index ¶
- Constants
- Variables
- type Activation
- type Binding
- type Component
- type ComponentOrigin
- type ComponentRef
- type CopyPlan
- type CopyRequest
- type CopyResult
- type Discovery
- type Draft
- type Edit
- type Frozen
- type Manifest
- type Operation
- type PreviewCopyRequest
- type Slot
- type Store
- func (s *Store) Copy(ctx context.Context, id string, expected uint64, request CopyRequest) (CopyResult, error)
- func (s *Store) Create(ctx context.Context) (Draft, error)
- func (s *Store) Discover() Discovery
- func (s *Store) Draft(ctx context.Context, id string) (Draft, error)
- func (s *Store) Edit(ctx context.Context, id string, expected uint64, edits []Edit) (Draft, error)
- func (s *Store) Fork(ctx context.Context, digest string) (Draft, error)
- func (s *Store) Freeze(ctx context.Context, id string, expected uint64) (*Frozen, error)
- func (s *Store) Load(ctx context.Context, digest string) (*Frozen, error)
- func (s *Store) PreviewCopy(ctx context.Context, id string, expected uint64, request PreviewCopyRequest) (CopyPlan, error)
- func (s *Store) Validate(ctx context.Context, id string, expected uint64) error
- type Surface
- type Validator
Constants ¶
const ( // AlwaysOn exposes standing instructions. AlwaysOn Activation = "always_on" // OnDemand exposes discoverable resources when requested. OnDemand Activation = "on_demand" // ChildContext exposes instructions in an approved child context. ChildContext Activation = "child_context" // Inline installs supported behavior in the execution loop. Inline Activation = "inline" // Put adds or replaces a component. Put Operation = "put" // Delete removes a component. Delete Operation = "delete" )
Variables ¶
var ( // ErrRevision reports an optimistic revision conflict. ErrRevision = errors.New("candidate: stale revision") // ErrFrozen reports an attempted edit to a frozen draft. ErrFrozen = errors.New("candidate: draft is frozen") // ErrNotFound reports an unknown draft, snapshot or component. ErrNotFound = errors.New("candidate: not found") )
var ErrCopyPlan = errors.New("candidate: copy plan does not match; preview again")
ErrCopyPlan requires a fresh preview when copy confirmation does not match.
Functions ¶
This section is empty.
Types ¶
type Activation ¶
type Activation string
Activation describes when a host binding exposes a component.
type Component ¶
type Component struct {
Name string `json:"name"`
Slot string `json:"slot"`
MediaType string `json:"media_type"`
Data []byte `json:"data"`
Dependencies []string `json:"dependencies,omitempty"`
}
Component is a byte submission, never a reference to a live file or directory.
type ComponentOrigin ¶
type ComponentOrigin struct {
// Name is unchanged from the selected source component.
Name string `json:"name"`
// SourceCandidate is the immediate source manifest SHA-256.
SourceCandidate string `json:"source_candidate"`
// SourceDigest is the exact component byte SHA-256.
SourceDigest string `json:"source_digest"`
}
ComponentOrigin identifies the immediate frozen source of a current component.
type ComponentRef ¶
type ComponentRef struct {
Name string `json:"name"`
Slot string `json:"slot"`
MediaType string `json:"media_type"`
Digest string `json:"digest"`
Size int64 `json:"size"`
Dependencies []string `json:"dependencies,omitempty"`
}
ComponentRef records the identity and explicit dependency edges of one component.
type CopyPlan ¶
type CopyPlan struct {
Digest string `json:"digest"`
Version int `json:"version"`
DraftID string `json:"draft_id"`
Revision uint64 `json:"revision"`
// DestinationDigest binds complete destination content and existing origins.
DestinationDigest string `json:"destination_digest"`
SurfaceDigest string `json:"surface_digest"`
BaselineDigest string `json:"baseline_digest"`
SourceCandidate string `json:"source_candidate"`
Selected []string `json:"selected"`
// Closure includes selected roots and every transitive source dependency.
Closure []ComponentRef `json:"closure"`
// Replace lists every existing destination name that would be overwritten.
Replace []string `json:"replace"`
}
CopyPlan describes the complete proposed import before any draft mutation. Digest confirms all fields, including destination content and collision names.
type CopyRequest ¶
type CopyRequest struct {
SourceCandidate string `json:"source_candidate"`
Components []string `json:"components"`
Replace []string `json:"replace"`
PlanDigest string `json:"plan_digest"`
}
CopyRequest explicitly confirms one preview's complete closure and replacements.
type CopyResult ¶
type CopyResult struct {
Draft Draft `json:"draft"`
PlanDigest string `json:"plan_digest"`
Selected []string `json:"selected"`
Closure []string `json:"closure"`
}
CopyResult retains the applied preview identity and the updated owned draft.
type Discovery ¶
type Discovery struct {
Surface Surface `json:"surface"`
BaselineDigest string `json:"baseline_digest"`
Baseline []ComponentRef `json:"baseline"`
}
Discovery describes the registered surface and its authorized baseline.
type Draft ¶
type Draft struct {
ID string `json:"id"`
Revision uint64 `json:"revision"`
FrozenDigest string `json:"frozen_digest,omitempty"`
Components []Component `json:"components"`
Origins []ComponentOrigin `json:"origins,omitempty"`
}
Draft is a complete editable snapshot and optimistic revision.
type Frozen ¶
type Frozen struct {
// contains filtered or unexported fields
}
Frozen retains immutable content; all accessors return owned values.
func (*Frozen) Closure ¶
Closure returns sorted transitive dependencies including the selected names.
func (*Frozen) Components ¶
Components returns owned bytes and metadata.
type Manifest ¶
type Manifest struct {
Version int `json:"version"`
SurfaceID string `json:"surface_id"`
SurfaceVersion string `json:"surface_version"`
SurfaceDigest string `json:"surface_digest"`
BaselineDigest string `json:"baseline_digest,omitempty"`
Bindings []Binding `json:"bindings"`
Components []ComponentRef `json:"components"`
Origins []ComponentOrigin `json:"origins,omitempty"`
}
Manifest is the canonical versioned identity of a complete content snapshot.
type PreviewCopyRequest ¶
type PreviewCopyRequest struct {
SourceCandidate string `json:"source_candidate"`
Components []string `json:"components"`
}
PreviewCopyRequest selects roots whose full source dependency closure is previewed.
type Slot ¶
type Slot struct {
Name string `json:"name"`
Activation Activation `json:"activation"`
Operations []Operation `json:"operations"`
MediaTypes []string `json:"media_types"`
MaxBytes int64 `json:"max_bytes"`
MaxComponents int `json:"max_components"`
Binding Binding `json:"binding"`
Capabilities []string `json:"capabilities,omitempty"`
}
Slot declares an application capability and its content limits.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is a durable, surface-scoped candidate store. One host-owned Store must own writes to a directory. Methods serialize goroutines; cross-process writer coordination and authorization of the directory remain host responsibilities. Validators must not call back into the Store.
func Open ¶
func Open(ctx context.Context, dir string, surface Surface, baseline []Component, validators ...Validator) (*Store, error)
Open registers an authorized byte baseline, or reopens an identical scope. Source directories are not accepted. The host supplies retained bytes and re-registers its validators on reopen; validator code is not serialized.
func (*Store) Copy ¶
func (s *Store) Copy(ctx context.Context, id string, expected uint64, request CopyRequest) (CopyResult, error)
Copy applies exactly one confirmed preview in one atomic draft revision. PlanDigest confirms the whole closure; Replace confirms every name collision. The host must recheck its operation grants before calling this method.
func (*Store) Discover ¶
Discover returns owned surface and baseline metadata, including supported bindings, limits, capabilities, activation and authorized component dependencies.
func (*Store) Edit ¶
Edit applies a validated batch atomically at the expected revision. Host validation failure leaves the draft unchanged, allowing the caller to repair it.
func (*Store) Freeze ¶
Freeze validates and retains the current revision as immutable content. Repeating a successful freeze at the same revision returns the same identity.
func (*Store) Load ¶
Load verifies and returns an immutable snapshot in this scope. Digest and content corruption fail explicitly; absent evidence is never empty content.
func (*Store) PreviewCopy ¶
func (s *Store) PreviewCopy(ctx context.Context, id string, expected uint64, request PreviewCopyRequest) (CopyPlan, error)
PreviewCopy returns the full proposed dependency closure without changing the draft. It does not reserve or persist a plan. The host must authorize the operation.