candidate

package
v2.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 19 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package candidate stores versioned, immutable candidate content without runtime execution dependencies.

Index

Constants

View Source
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

View Source
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")
)
View Source
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 Binding

type Binding struct {
	ID      string `json:"id"`
	Version string `json:"version"`
}

Binding identifies a host installation contract; it is not executable code.

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 Edit

type Edit struct {
	Operation Operation
	Name      string
	Component Component
}

Edit declares exactly one named put or delete operation.

type Frozen

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

Frozen retains immutable content; all accessors return owned values.

func (*Frozen) Closure

func (f *Frozen) Closure(names []string) ([]string, error)

Closure returns sorted transitive dependencies including the selected names.

func (*Frozen) Components

func (f *Frozen) Components() []Component

Components returns owned bytes and metadata.

func (*Frozen) Digest

func (f *Frozen) Digest() string

Digest returns the canonical SHA-256 manifest digest.

func (*Frozen) Manifest

func (f *Frozen) Manifest() Manifest

Manifest returns an owned manifest.

func (*Frozen) Read

func (f *Frozen) Read(name string) ([]byte, error)

Read returns the named component bytes.

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 Operation

type Operation string

Operation is a permitted slot mutation.

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) Create

func (s *Store) Create(ctx context.Context) (Draft, error)

Create starts a new draft from the registered baseline.

func (*Store) Discover

func (s *Store) Discover() Discovery

Discover returns owned surface and baseline metadata, including supported bindings, limits, capabilities, activation and authorized component dependencies.

func (*Store) Draft

func (s *Store) Draft(ctx context.Context, id string) (Draft, error)

Draft returns an owned editable snapshot.

func (*Store) Edit

func (s *Store) Edit(ctx context.Context, id string, expected uint64, edits []Edit) (Draft, error)

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) Fork

func (s *Store) Fork(ctx context.Context, digest string) (Draft, error)

Fork starts a new draft from a frozen snapshot in this scope.

func (*Store) Freeze

func (s *Store) Freeze(ctx context.Context, id string, expected uint64) (*Frozen, error)

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

func (s *Store) Load(ctx context.Context, digest string) (*Frozen, error)

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.

func (*Store) Validate

func (s *Store) Validate(ctx context.Context, id string, expected uint64) error

Validate checks the current revision using core and host validators.

type Surface

type Surface struct {
	ID            string `json:"id"`
	Version       string `json:"version"`
	MaxTotalBytes int64  `json:"max_total_bytes"`
	Slots         []Slot `json:"slots"`
}

Surface is the versioned host declaration of editable content.

type Validator

type Validator func(context.Context, []Component) error

Validator checks host-specific content, activation and semantic dependencies. Each invocation receives an owned snapshot. It must not reenter the Store.

Jump to

Keyboard shortcuts

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