update

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package update implements verified binary staging and managed rollout messages.

Index

Constants

View Source
const GatewaySender = "@gateway"
View Source
const MaxBinarySize int64 = 128 << 20

Variables

This section is empty.

Functions

func AssetName

func AssetName(os, arch string) string

func Download

func Download(ctx context.Context, client *http.Client, url, token, path string, asset Asset) error

func DownloadPreferred added in v0.5.1

func DownloadPreferred(ctx context.Context, repository, version, gateway, token, path string, asset Asset) error

DownloadPreferred uses GitHub only for the exact authenticated gateway asset. Gateway storage remains a complete fallback, including for development builds.

func InspectExecutable

func InspectExecutable(ctx context.Context, path string) (buildinfo.Info, error)

func IsCurrent

func IsCurrent(info buildinfo.Info, version string, asset Asset) bool

IsCurrent skips replacement of an already running version, even when a rebuild changes its timestamp or checksum. Matches remains strict for binary validation.

func Matches

func Matches(info buildinfo.Info, asset Asset) bool

func SaveBinary

func SaveBinary(reader io.Reader, path string, asset Asset) error

SaveBinary never publishes incomplete or unverified data.

func ShortError

func ShortError(err error) string

func ValidDigest

func ValidDigest(value string) bool

func ValidateExecutable

func ValidateExecutable(ctx context.Context, path, version string, asset Asset) error

func ValidatedExecutable added in v0.5.7

func ValidatedExecutable(ctx context.Context, path, version string, asset Asset) (buildinfo.Info, error)

ValidatedExecutable reads compatibility only after authenticating the bytes.

func Verify

func Verify(path string, asset Asset) error

Verify checks the actual bytes on every call. File metadata is not evidence of integrity: contents can change without changing size or modification time.

func VerifyReleaseManifest added in v0.4.0

func VerifyReleaseManifest(ctx context.Context, repository, tag string, manifest, proof []byte) error

VerifyReleaseManifest authenticates the exact downloaded bytes against the release workflow at the exact tag. TUF supplies Sigstore's rotating trust roots.

Types

type Asset

type Asset struct {
	OS     string `json:"os"`
	Arch   string `json:"arch"`
	File   string `json:"file"`
	Size   int64  `json:"size"`
	SHA256 string `json:"sha256"`
}

type Command

type Command struct {
	ID          string    `json:"id"`
	Version     string    `json:"version,omitempty"`
	Asset       Asset     `json:"asset,omitempty"`
	LeaseUntil  time.Time `json:"leaseUntil,omitempty"`
	ReleaseRepo string    `json:"releaseRepo,omitempty"`
}

type Deployment

type Deployment struct {
	ID           string    `json:"id"`
	Manifest     Manifest  `json:"manifest"`
	Source       string    `json:"source"`
	Phase        string    `json:"phase"`
	Error        string    `json:"error,omitempty"`
	UpdatedAt    time.Time `json:"updatedAt"`
	Participants []string  `json:"participants,omitempty"`
	Deferred     []string  `json:"deferred,omitempty"`
	Contract     int       `json:"contract,omitempty"`
	InFlight     []string  `json:"inFlight,omitempty"`
	GatewayState string    `json:"gatewayState,omitempty"`
}

type Manifest

type Manifest struct {
	Version   string    `json:"version"`
	CreatedAt time.Time `json:"createdAt"`
	Assets    []Asset   `json:"assets"`
}

func (Manifest) Asset

func (m Manifest) Asset(os, arch string) (Asset, bool)

func (Manifest) ID

func (m Manifest) ID() string

func (Manifest) Validate

func (m Manifest) Validate() error

type PruneResult

type PruneResult struct {
	Blobs  int
	Staged int
}

type Repository

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

func OpenRepository

func OpenRepository(dir string) (*Repository, error)

func (*Repository) BeginInstall

func (r *Repository) BeginInstall(id string, participants []string) error

func (*Repository) Blob

func (r *Repository) Blob(hash string) string

func (*Repository) Current

func (r *Repository) Current() *Deployment

func (*Repository) NodeInstall added in v0.5.7

func (r *Repository) NodeInstall(id, node string, pending bool) error

NodeInstall durably records commit intent, or clears it only after a fresh applied/resumed or explicit failed/resumed acknowledgement. Disconnection is not an acknowledgement and must not unlock publication.

func (*Repository) Pin

func (r *Repository) Pin(assets []Asset) func()

Pin keeps assets available while a release is downloaded and published.

func (*Repository) Prune

func (r *Repository) Prune(ctx context.Context, id string, retained []string) (PruneResult, error)

Prune removes obsolete gateway binaries only after durable rollout completion. Callers must serialize invitation creation and deployment selection with it.

func (*Repository) Publish

func (r *Repository) Publish(manifest Manifest, source string) (*Deployment, error)

func (*Repository) SetDeferred added in v0.5.1

func (r *Repository) SetDeferred(id string, deferred []string) error

SetDeferred records unavailable participants without claiming their updates succeeded. The selected manifest remains available when they reconnect.

func (*Repository) SetGatewayState added in v0.5.7

func (r *Repository) SetGatewayState(id, state string) error

func (*Repository) SetPhase

func (r *Repository) SetPhase(id, phase string, cause error) error

func (*Repository) Upload

func (r *Repository) Upload(reader io.Reader, asset Asset) error

func (*Repository) VerifyPinned added in v0.2.0

func (r *Repository) VerifyPinned(assets []Asset) (func(), error)

VerifyPinned hashes binaries without holding the repository mutex. The returned release function keeps cleanup from deleting them until their durable reference is published. Pins do not authorize unverified bytes.

type Selection added in v0.5.1

type Selection struct {
	ID          string   `json:"id"`
	Manifest    Manifest `json:"manifest"`
	ReleaseRepo string   `json:"releaseRepo,omitempty"`
}

Selection exposes software metadata without cross-fleet rollout identities.

type Status

type Status struct {
	Software       buildinfo.Info `json:"software"`
	StagedSoftware buildinfo.Info `json:"stagedSoftware,omitzero"`
	ID             string         `json:"id,omitempty"`
	State          string         `json:"state"`
	Busy           bool           `json:"busy"`
	Paused         bool           `json:"paused"`
	LeaseUntil     time.Time      `json:"leaseUntil,omitempty"`
	Error          string         `json:"error,omitempty"`
	SeenAt         time.Time      `json:"seenAt"`
}

type Updater

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

Updater stages gateway-published binaries and applies them under an idle reservation. It is part of the node service, not an AI agent or a separate execution role.

func NewUpdater

func NewUpdater(options UpdaterOptions) (*Updater, error)

func (*Updater) Receive

func (a *Updater) Receive(kind string, data []byte)

Receive is called only for messages authenticated as originating at the gateway.

func (*Updater) Run

func (a *Updater) Run(ctx context.Context)

func (*Updater) Snapshot

func (a *Updater) Snapshot() Status

type UpdaterOptions

type UpdaterOptions struct {
	Gateway, Token, Dir string
	CacheDir            string // Empty selects the OS machine-wide download cache.
	Software            buildinfo.Info
	Busy                func() bool
	Pause               func() bool
	Resume              func()
	Report              func(context.Context, Status) error
	Apply               func(string) error
}

UpdaterOptions supplies node-owned work admission and restart callbacks.

Jump to

Keyboard shortcuts

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