update

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 37 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultOperationDeadline = 30 * time.Minute
	DefaultLeaseDuration     = 2 * time.Minute
)
View Source
const ManagedEnvName = "COMPOZY_MANAGED"

ManagedEnvName overrides the install-method detector for managed package installs.

View Source
const OperationSchemaVersion = 1

Variables

View Source
var (
	ErrOperationBlocked       = errors.New("update: operation blocked")
	ErrOperationNotFound      = errors.New("update: operation not found")
	ErrOperationConflict      = errors.New("update: operation revision conflict")
	ErrExecutorFenced         = errors.New("update: executor fenced")
	ErrOperationNotCancelable = errors.New("update: operation is not cancelable")
)
View Source
var ErrNoCachedRelease = errors.New("update: cached release info not found")

Functions

func ApplyBinaryReplacement

func ApplyBinaryReplacement(
	sourcePath string,
	targetPath string,
	backupPath string,
	mode os.FileMode,
) error

ApplyBinaryReplacement atomically replaces a runtime binary and keeps a rollback copy.

func CheckRuntimeCompatibility

func CheckRuntimeCompatibility(compatibility Compatibility, installedApp InstalledApp) error

CheckRuntimeCompatibility enforces the coordinator's runtime-only backstop.

func DesktopRuntimeMatchesBundle

func DesktopRuntimeMatchesBundle(
	paths compozyconfig.HomePaths,
	runtimePath string,
	bundlePath string,
	metadata DesktopProvenanceMetadata,
) (bool, error)

DesktopRuntimeMatchesBundle verifies the installed bytes and release identity against a bundle.

func DesktopRuntimeNewerThanBundle

func DesktopRuntimeNewerThanBundle(
	paths compozyconfig.HomePaths,
	binaryPath string,
	bundleVersion string,
) (bool, error)

DesktopRuntimeNewerThanBundle preserves a verified runtime installed by a newer release.

func ManualDirectBinaryRecommendation

func ManualDirectBinaryRecommendation(releaseURL string, runtimeOS string) string

ManualDirectBinaryRecommendation returns the recovery path when in-place update is unavailable.

func NewExecutorGeneration

func NewExecutorGeneration() (string, error)

NewExecutorGeneration returns a random lease fence for one executor process.

func RestoreBinaryReplacement

func RestoreBinaryReplacement(backupPath string, targetPath string, mode os.FileMode) error

RestoreBinaryReplacement restores a runtime binary from a rollback copy.

func RuntimeOwnedByDesktopApp

func RuntimeOwnedByDesktopApp(paths compozyconfig.HomePaths, binaryPath string) bool

RuntimeOwnedByDesktopApp verifies the desktop ownership marker against the runtime bytes.

func ValidateReleaseArchive

func ValidateReleaseArchive(
	archivePath string,
	binaryName string,
	policy ArtifactPolicy,
) error

ValidateReleaseArchive checks one direct-update archive without applying its binary.

func WriteDesktopProvenance

func WriteDesktopProvenance(
	paths compozyconfig.HomePaths,
	binaryPath string,
	metadata DesktopProvenanceMetadata,
) error

WriteDesktopProvenance records that the desktop app installed the runtime binary.

Types

type Actor

type Actor string

Actor identifies the public surface that requested a transition.

const (
	ActorCLI    Actor = "cli"
	ActorDaemon Actor = "daemon"
	ActorWeb    Actor = "web"
	ActorShell  Actor = "shell"
)

type AppApplyRequest

type AppApplyRequest struct {
	RequestedBy Actor
	App         AppOperationState
	Holder      Holder
	Deadline    time.Time
}

AppApplyRequest binds a shell apply request to one verified artifact identity.

type AppApplyResult

type AppApplyResult struct {
	Target      Target      `json:"target"`
	Status      ApplyStatus `json:"status"`
	OperationID string      `json:"operation_id,omitempty"`
	Message     string      `json:"message"`
	Holder      *Holder     `json:"holder,omitzero"`
}

AppApplyResult reports durable acquisition, never a terminal install verdict.

type AppOperationState

type AppOperationState struct {
	ArtifactIdentity
	AttemptID           string         `json:"attempt_id"`
	Phase               OperationPhase `json:"phase"`
	DigestVerified      bool           `json:"digest_verified"`
	ConsecutiveFailures int            `json:"consecutive_failures"`
	WatchdogDeadline    time.Time      `json:"watchdog_deadline,omitzero"`
}

AppOperationState journals the desktop app track.

type AppTrackState

type AppTrackState struct {
	Status         Status `json:"status"`
	Running        bool   `json:"running"`
	CurrentVersion string `json:"current_version"`
	LatestVersion  string `json:"latest_version,omitempty"`
	ReleaseURL     string `json:"release_url,omitempty"`
	AttemptID      string `json:"attempt_id,omitempty"`
	LastError      string `json:"last_error,omitempty"`
	Message        string `json:"message"`
}

AppTrackState is present exactly when a desktop app is installed.

type AppliedBinary

type AppliedBinary struct {
	TargetPath      string
	BackupPath      string
	Version         string
	PreviousVersion string
	InstallMethod   InstallMethod
}

AppliedBinary describes one on-disk binary swap that still retains a rollback backup.

type ApplyObserver

type ApplyObserver func(context.Context, ApplyStep) error

ApplyObserver journals and fences one apply step before the manager performs it.

type ApplyStatus

type ApplyStatus string

ApplyStatus is the settings/app request acceptance vocabulary.

const (
	ApplyStatusAccepted ApplyStatus = "accepted"
	ApplyStatusBlocked  ApplyStatus = "blocked"
	ApplyStatusFailed   ApplyStatus = "failed"
)

type ApplyStep

type ApplyStep struct {
	Phase         OperationPhase
	Percent       int
	BackupPath    string
	Compatibility *Compatibility
}

ApplyStep reports the next journal phase immediately before its work begins.

type ArtifactIdentity

type ArtifactIdentity struct {
	FromVersion string `json:"from_version"`
	ToVersion   string `json:"to_version"`
	ReleaseTag  string `json:"release_tag"`
	Asset       string `json:"asset"`
	Digest      string `json:"digest"`
}

ArtifactIdentity binds an update step to one verified release artifact.

type ArtifactKind

type ArtifactKind string

ArtifactKind identifies the release artifact constrained by the update policy.

const (
	ArtifactKindArchive ArtifactKind = "archive"
	ArtifactKindBinary  ArtifactKind = "binary"
)

type ArtifactPolicy

type ArtifactPolicy struct {
	MaxArchiveBytes int64
	MaxBinaryBytes  int64
}

ArtifactPolicy defines the accepted size envelope for direct self-update artifacts.

func DefaultArtifactPolicy

func DefaultArtifactPolicy() ArtifactPolicy

DefaultArtifactPolicy returns the size envelope enforced by runtime updates and release publication.

type ArtifactSizeError

type ArtifactSizeError struct {
	Kind  ArtifactKind
	Size  int64
	Limit int64
}

ArtifactSizeError reports a release artifact outside the accepted size envelope.

func (*ArtifactSizeError) Error

func (e *ArtifactSizeError) Error() string

type BinaryApplier

type BinaryApplier interface {
	ApplyBinary(sourcePath string, targetPath string, backupPath string, mode os.FileMode) error
	RestoreBinary(backupPath string, targetPath string, mode os.FileMode) error
}

BinaryApplier atomically swaps the current executable with a verified replacement.

type BlockedError

type BlockedError struct {
	Operation Operation
}

BlockedError reports the live operation that prevented acquisition.

func (*BlockedError) Error

func (e *BlockedError) Error() string

func (*BlockedError) Unwrap

func (e *BlockedError) Unwrap() error

type BundleVerifier

type BundleVerifier interface {
	VerifyChecksums(ctx context.Context, checksumsPath string, bundlePath string) error
}

BundleVerifier verifies the signed checksum catalog before the archive checksum is trusted.

type CheckOptions

type CheckOptions struct {
	ForceRefresh           bool
	AllowCachedOnFailure   bool
	MinimumRefreshInterval time.Duration
}

CheckOptions customize one update status query.

type Compatibility

type Compatibility struct {
	RuntimeVersion string `json:"runtime_version"`
	MinAppVersion  string `json:"min_app_version"`
}

Compatibility is the signed two-field release compatibility contract.

type Config

type Config struct {
	HomePaths       compozyconfig.HomePaths
	CurrentVersion  string
	ExecutablePath  func() (string, error)
	ResolveSymlinks func(string) (string, error)
	Getenv          func(string) string
	Now             func() time.Time
	HTTPClient      *http.Client
	RuntimeOS       string
	RuntimeArch     string
	LookPath        func(string) (string, error)
	RunCommand      func(context.Context, string, ...string) (string, error)
	BundleVerifier  BundleVerifier
	BinaryApplier   BinaryApplier
	ArtifactPolicy  ArtifactPolicy
	OperationEvents OperationEventEmitter
}

Config builds one update manager bound to the current runtime.

type Coordinator

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

Coordinator executes and recovers one durable update operation.

func NewCoordinator

func NewCoordinator(cfg CoordinatorConfig) (*Coordinator, error)

NewCoordinator constructs a detached-operation executor.

func (*Coordinator) Run

func (c *Coordinator) Run(ctx context.Context, operationID string, executorGeneration string) error

Run executes or recovers one operation under its fenced executor generation.

type CoordinatorBinaryManager

type CoordinatorBinaryManager interface {
	RuntimeTargetPath() string
	Restore(AppliedBinary) error
	Finalize(AppliedBinary) error
}

CoordinatorBinaryManager supplies installed-runtime mutation and recovery.

type CoordinatorConfig

type CoordinatorConfig struct {
	Store          *OperationStore
	ReleaseManager CoordinatorReleaseManager
	BinaryManager  CoordinatorBinaryManager
	Runtime        CoordinatorRuntime
	LeaseDuration  time.Duration
	RenewInterval  time.Duration
	Now            func() time.Time
}

CoordinatorConfig wires the sole runtime-mutation executor.

type CoordinatorManager

type CoordinatorManager interface {
	CoordinatorReleaseManager
	CoordinatorBinaryManager
}

CoordinatorManager is the complete manager capability implemented by Manager.

type CoordinatorReleaseManager

type CoordinatorReleaseManager interface {
	ResolveReleaseByTag(context.Context, string) (*Release, error)
	ApplyReleaseObserved(context.Context, *Release, ApplyObserver) (AppliedBinary, error)
}

CoordinatorReleaseManager supplies verified release acquisition and application.

type CoordinatorRuntime

type CoordinatorRuntime interface {
	AcquireMutationLock(context.Context) (MutationLock, error)
	RestartDaemon(context.Context) error
	HealthCheck(context.Context) error
	InstalledApp(context.Context) (InstalledApp, error)
}

CoordinatorRuntime bridges process lifecycle operations owned outside internal/update.

type DesktopProvenanceMetadata

type DesktopProvenanceMetadata struct {
	AppVersion     string
	Channel        string
	RuntimeVersion string
}

DesktopProvenanceMetadata binds a desktop-owned runtime to its app release.

type Holder

type Holder struct {
	ProcessToken       string    `json:"process_token,omitempty"`
	PID                int       `json:"pid"`
	PIDStartTime       time.Time `json:"pid_start_time"`
	Surface            Actor     `json:"surface"`
	ExecutorGeneration string    `json:"executor_generation"`
	LeaseExpiresAt     time.Time `json:"lease_expires_at"`
}

Holder is the fenced lease for the sole active executor.

type InstallMethod

type InstallMethod string

InstallMethod reports how the running CompozyOS binary was installed.

const (
	InstallMethodDirectBinary InstallMethod = "direct-binary"
	InstallMethodHomebrew     InstallMethod = "homebrew"
	InstallMethodNPM          InstallMethod = "npm"
	InstallMethodAPT          InstallMethod = "apt"
	InstallMethodDNF          InstallMethod = "dnf"
	InstallMethodRPM          InstallMethod = "rpm"
	InstallMethodScoop        InstallMethod = "scoop"
	InstallMethodGoInstall    InstallMethod = "go-install"
	InstallMethodDesktopApp   InstallMethod = "desktop-app"
	InstallMethodUnknown      InstallMethod = "unknown"
)

type InstalledApp

type InstalledApp struct {
	Present bool
	Version string
}

InstalledApp preserves the difference between no desktop app and an app whose version is unreadable.

type Manager

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

Manager owns the CompozyOS self-update flow for the current runtime.

func NewManager

func NewManager(cfg *Config) (*Manager, error)

NewManager binds the update flow to the current CompozyOS runtime.

func (*Manager) AcquireOperation

func (m *Manager) AcquireOperation(ctx context.Context, request OperationRequest) (*Operation, error)

AcquireOperation publishes one verified update plan.

func (*Manager) AppRunning

func (m *Manager) AppRunning() (bool, error)

AppRunning reads only local desktop state; it never refreshes release metadata.

func (*Manager) ApplyRelease

func (m *Manager) ApplyRelease(ctx context.Context, release *Release) (AppliedBinary, error)

ApplyRelease downloads, verifies, extracts, and swaps in the supplied release.

func (*Manager) ApplyReleaseObserved

func (m *Manager) ApplyReleaseObserved(
	ctx context.Context,
	release *Release,
	observer ApplyObserver,
) (AppliedBinary, error)

ApplyReleaseObserved exposes real apply boundaries to the operation coordinator.

func (*Manager) Check

func (m *Manager) Check(ctx context.Context, opts CheckOptions) (State, *Release, error)

Check returns the current update state and the latest release metadata when available.

func (*Manager) CheckAll

func (m *Manager) CheckAll(ctx context.Context, opts CheckOptions) (MultiState, *Release, error)

CheckAll computes both installed tracks and the live operation from one release lookup.

func (*Manager) Finalize

func (m *Manager) Finalize(applied AppliedBinary) error

Finalize removes the preserved sibling backup after the full update flow succeeds.

func (*Manager) OperationStore

func (m *Manager) OperationStore() *OperationStore

OperationStore exposes the single journal authority to composition roots.

func (*Manager) PlanOperation

func (m *Manager) PlanOperation(
	ctx context.Context,
	actor Actor,
	targets []Target,
	holder Holder,
) (request OperationRequest, returnErr error)

PlanOperation verifies release identities and builds a durable acquisition request.

func (*Manager) PrimeInstallDetection

func (m *Manager) PrimeInstallDetection(ctx context.Context) error

PrimeInstallDetection resolves and memoizes the install method for this manager.

func (*Manager) Refresh

func (m *Manager) Refresh(ctx context.Context) (MultiState, error)

Refresh checks upstream at most once a minute across Settings clients. The shared check survives a disconnected client and completes within defaultHTTPTimeout.

func (*Manager) ResolveReleaseByTag

func (m *Manager) ResolveReleaseByTag(ctx context.Context, tag string) (*Release, error)

ResolveReleaseByTag fetches the immutable release identity recorded by an operation.

func (*Manager) Restore

func (m *Manager) Restore(applied AppliedBinary) error

Restore rolls back an applied binary swap using the preserved sibling backup.

func (*Manager) RuntimeTargetPath

func (m *Manager) RuntimeTargetPath() string

RuntimeTargetPath returns the concrete executable path owned by this manager.

func (*Manager) Snapshot

func (m *Manager) Snapshot(ctx context.Context) (MultiState, error)

Snapshot returns the cached live projection, tolerating a recorded upstream refresh error.

type MultiState

type MultiState struct {
	Aggregate Status            `json:"aggregate"`
	Operation *OperationView    `json:"operation"`
	Runtime   RuntimeTrackState `json:"runtime"`
	App       *AppTrackState    `json:"app"`
}

MultiState is the live host-global projection shared by settings and app status.

func ProjectMultiState

func ProjectMultiState(runtime State, app *AppTrackState, operation *Operation) MultiState

ProjectMultiState derives every live track and operation field from one computation.

type MutationLock

type MutationLock interface {
	Release() error
}

MutationLock is the short critical-section lock held only around the runtime swap.

type Operation

type Operation struct {
	SchemaVersion int                    `json:"schema_version"`
	ID            string                 `json:"operation_id"`
	RequestedBy   Actor                  `json:"requested_by"`
	Revision      int64                  `json:"revision"`
	Targets       []Target               `json:"targets"`
	ActiveTarget  Target                 `json:"active_target,omitempty"`
	Percent       int                    `json:"percent"`
	Runtime       *RuntimeOperationState `json:"runtime,omitzero"`
	App           *AppOperationState     `json:"app,omitzero"`
	Holder        *Holder                `json:"holder"`
	Waiting       WaitingState           `json:"waiting"`
	Deadline      time.Time              `json:"deadline"`
	StartedAt     time.Time              `json:"started_at"`
	UpdatedAt     time.Time              `json:"updated_at"`
	LastError     string                 `json:"last_error,omitempty"`
	Outcome       string                 `json:"outcome,omitempty"`
}

Operation is the sole durable mutation journal for one CompozyOS home.

type OperationEvent

type OperationEvent struct {
	Name               OperationEventName `json:"name"`
	OperationID        string             `json:"operation_id"`
	Revision           int64              `json:"revision"`
	Target             Target             `json:"target"`
	InstallMethod      InstallMethod      `json:"install_method"`
	FromVersion        string             `json:"from_version"`
	ToVersion          string             `json:"to_version"`
	Actor              Actor              `json:"actor"`
	ExecutorGeneration string             `json:"executor_generation,omitempty"`
	Outcome            string             `json:"outcome"`
	OccurredAt         time.Time          `json:"occurred_at"`
}

OperationEvent carries safe correlation fields for one journal transition.

type OperationEventEmitter

type OperationEventEmitter interface {
	EmitUpdateEvent(context.Context, OperationEvent)
}

OperationEventEmitter receives events at the transition call site.

func NewSlogOperationEventEmitter

func NewSlogOperationEventEmitter(logger *slog.Logger) OperationEventEmitter

NewSlogOperationEventEmitter writes canonical lifecycle events to structured logs.

type OperationEventName

type OperationEventName string

OperationEventName is the closed update lifecycle event vocabulary.

const (
	EventOperationAcquired       OperationEventName = "update.operation.acquired"
	EventOperationBlocked        OperationEventName = "update.operation.blocked"
	EventOperationWaiting        OperationEventName = "update.operation.waiting"
	EventOperationResumed        OperationEventName = "update.operation.resumed"
	EventOperationCanceled       OperationEventName = "update.operation.canceled"
	EventOperationCancelDeclined OperationEventName = "update.operation.cancel_declined"
	EventLeaseAcquired           OperationEventName = "update.lease.acquired"
	EventLeaseRenewed            OperationEventName = "update.lease.renewed"
	EventLeaseExpired            OperationEventName = "update.lease.expired"
	EventCheckCompleted          OperationEventName = "update.check.completed"
	EventDownloadProgress        OperationEventName = "update.download.progress"
	EventVerifyCompleted         OperationEventName = "update.verify.completed"
	EventSwapCompleted           OperationEventName = "update.swap.completed"
	EventRestartCompleted        OperationEventName = "update.restart.completed"
	EventHealthCompleted         OperationEventName = "update.health.completed"
	EventFinalized               OperationEventName = "update.finalized"
	EventRolledBack              OperationEventName = "update.rolled_back"
	EventAppStaged               OperationEventName = "update.app.staged"
	EventAppApplying             OperationEventName = "update.app.applying"
	EventAppInstallerHandoff     OperationEventName = "update.app.installer_handoff"
	EventAppVerified             OperationEventName = "update.app.verified"
	EventAppFailed               OperationEventName = "update.app.failed"
	EventOperationRecovered      OperationEventName = "update.operation.recovered"
)

type OperationPhase

type OperationPhase string

OperationPhase is the closed union of runtime and app journal phases.

const (
	PhasePending          OperationPhase = "pending"
	PhaseDownloading      OperationPhase = "downloading"
	PhaseVerifying        OperationPhase = "verifying"
	PhaseSwapping         OperationPhase = "swapping"
	PhaseRestarting       OperationPhase = "restarting"
	PhaseHealthChecking   OperationPhase = "health-checking"
	PhaseFinalized        OperationPhase = "finalized"
	PhaseRolledBack       OperationPhase = "rolled-back"
	PhaseFailed           OperationPhase = "failed"
	PhaseStaged           OperationPhase = "staged"
	PhaseApplying         OperationPhase = "applying"
	PhaseInstallerHandoff OperationPhase = "installer-handoff"
	PhaseRestarted        OperationPhase = "restarted"
	PhaseVerified         OperationPhase = "verified"
)

type OperationRequest

type OperationRequest struct {
	RequestedBy Actor
	Targets     []Target
	Runtime     *RuntimeOperationState
	App         *AppOperationState
	Holder      Holder
	Deadline    time.Time
}

OperationRequest contains release identities already verified at acquisition.

type OperationStore

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

OperationStore owns all reads and writes of the per-home update journal.

func NewOperationStore

func NewOperationStore(paths compozyconfig.HomePaths, events OperationEventEmitter) (*OperationStore, error)

NewOperationStore binds the journal to one CompozyOS home.

func (*OperationStore) Acquire

func (s *OperationStore) Acquire(ctx context.Context, request OperationRequest) (*Operation, error)

Acquire creates the sole operation or resumes an eligible dormant operation.

func (*OperationStore) Fence

func (s *OperationStore) Fence(
	ctx context.Context,
	operationID string,
	executorGeneration string,
	expectedRevision int64,
) error

Fence proves that a caller still owns the exact revision immediately before an irreversible side effect.

func (*OperationStore) HolderLive

func (s *OperationStore) HolderLive(holder *Holder) (bool, error)

HolderLive reports whether the lease still belongs to the recorded process identity.

func (*OperationStore) LatestArchivedApp

func (s *OperationStore) LatestArchivedApp(ctx context.Context) (*Operation, error)

LatestArchivedApp returns the newest terminal operation containing the app track.

func (*OperationStore) LatestArchivedRuntime

func (s *OperationStore) LatestArchivedRuntime(ctx context.Context) (*Operation, error)

LatestArchivedRuntime returns the newest terminal operation containing the runtime track.

func (*OperationStore) Read

func (s *OperationStore) Read(ctx context.Context) (*Operation, error)

Read returns the validated live operation, or nil when no operation exists.

func (*OperationStore) ReadArchived

func (s *OperationStore) ReadArchived(ctx context.Context, operationID string) (*Operation, error)

ReadArchived returns one terminal operation from the durable audit trail.

func (*OperationStore) RequestAppApply

func (s *OperationStore) RequestAppApply(ctx context.Context, request AppApplyRequest) (AppApplyResult, error)

RequestAppApply durably records a verified app asset and returns acceptance truth.

func (*OperationStore) Transition

func (s *OperationStore) Transition(
	ctx context.Context,
	operationID string,
	executorGeneration string,
	expectedRevision int64,
	transition Transition,
) (*Operation, error)

Transition applies one fenced compare-and-swap mutation to the live journal.

func (*OperationStore) VerifyAppArtifact

func (s *OperationStore) VerifyAppArtifact(
	ctx context.Context,
	operationID string,
	executorGeneration string,
	expectedRevision int64,
	attemptID string,
	path string,
) error

VerifyAppArtifact binds a shell attempt to the exact asset recorded in the operation.

type OperationView

type OperationView struct {
	ID           string         `json:"id"`
	Revision     int64          `json:"revision"`
	Targets      []Target       `json:"targets"`
	ActiveTarget Target         `json:"active_target,omitempty"`
	Phase        OperationPhase `json:"phase,omitempty"`
	Percent      int            `json:"percent"`
	Holder       *Holder        `json:"holder"`
	Waiting      WaitingState   `json:"waiting"`
	StartedAt    time.Time      `json:"started_at"`
	LastError    string         `json:"last_error,omitempty"`
}

OperationView is the transport-safe read projection of the durable journal.

type Release

type Release struct {
	Version     string
	ReleaseURL  string
	PublishedAt time.Time
	Assets      []ReleaseAsset
}

Release holds the metadata required to inspect or apply one release.

type ReleaseAsset

type ReleaseAsset struct {
	Name        string
	DownloadURL string
}

ReleaseAsset identifies one downloadable release artifact.

type RuntimeOperationState

type RuntimeOperationState struct {
	ArtifactIdentity
	InstallMethod   InstallMethod  `json:"install_method"`
	BackupPath      string         `json:"backup_path,omitempty"`
	Phase           OperationPhase `json:"phase"`
	DaemonRestarted bool           `json:"daemon_restarted"`
}

RuntimeOperationState journals the runtime track.

type RuntimeTrackState

type RuntimeTrackState struct {
	CheckedAt       *time.Time `json:"checked_at,omitempty"`
	Status          Status     `json:"status"`
	InstallMethod   string     `json:"install_method"`
	Managed         bool       `json:"managed"`
	CurrentVersion  string     `json:"current_version"`
	LatestVersion   string     `json:"latest_version,omitempty"`
	ReleaseURL      string     `json:"release_url,omitempty"`
	Recommendation  string     `json:"recommendation,omitempty"`
	RestoredVersion string     `json:"restored_version,omitempty"`
	DaemonRestarted bool       `json:"daemon_restarted"`
	Message         string     `json:"message"`
	LastError       string     `json:"last_error,omitempty"`
}

RuntimeTrackState is the complete runtime update projection.

type State

type State struct {
	Supported       bool       `json:"supported"`
	Managed         bool       `json:"managed"`
	InstallMethod   string     `json:"install_method"`
	CurrentVersion  string     `json:"current_version"`
	LatestVersion   string     `json:"latest_version,omitempty"`
	Available       bool       `json:"available"`
	Status          Status     `json:"status"`
	Recommendation  string     `json:"recommendation,omitempty"`
	ReleaseURL      string     `json:"release_url,omitempty"`
	CheckedAt       *time.Time `json:"checked_at,omitempty"`
	LastError       string     `json:"last_error,omitempty"`
	Message         string     `json:"message,omitempty"`
	RestoredVersion string     `json:"restored_version,omitempty"`
	DaemonRestarted bool       `json:"daemon_restarted"`
}

State is the transport-safe update status snapshot shared by CLI and API surfaces.

type Status

type Status string

Status reports the operator-facing update state.

const (
	StatusUpToDate    Status = "up-to-date"
	StatusAvailable   Status = "available"
	StatusAccepted    Status = "accepted"
	StatusApplying    Status = "applying"
	StatusStaged      Status = "staged"
	StatusUpdated     Status = "updated"
	StatusFailed      Status = "failed"
	StatusBlocked     Status = "blocked"
	StatusUnsupported Status = "unsupported"
	StatusCanceled    Status = "canceled"
)

func AggregateLiveStatus

func AggregateLiveStatus(statuses ...Status) Status

AggregateLiveStatus applies the frozen live status precedence.

func AggregateTerminalStatus

func AggregateTerminalStatus(statuses ...Status) Status

AggregateTerminalStatus applies the frozen CLI terminal precedence.

type Target

type Target string

Target identifies one install track in a host-global update operation.

const (
	TargetRuntime Target = "runtime"
	TargetApp     Target = "app"
)

func ErrorTarget

func ErrorTarget(err error) (Target, bool)

ErrorTarget returns the track carried by a planning error.

type TargetError

type TargetError struct {
	Target Target
	Err    error
}

TargetError identifies the update track that produced a planning failure.

func (*TargetError) Error

func (e *TargetError) Error() string

func (*TargetError) Unwrap

func (e *TargetError) Unwrap() error

type Transition

type Transition struct {
	Kind                 TransitionKind
	Actor                Actor
	Target               Target
	Phase                OperationPhase
	Percent              int
	Holder               *Holder
	BackupPath           string
	LastError            string
	Outcome              string
	AppWatchdogDeadline  *time.Time
	IncrementAppFailures bool
	ResetAppFailures     bool
}

Transition is the declarative input to the sole operation mutation API.

type TransitionKind

type TransitionKind string

TransitionKind identifies one journal mutation.

const (
	TransitionPhase        TransitionKind = "phase"
	TransitionProgress     TransitionKind = "progress"
	TransitionWaitForApp   TransitionKind = "wait-for-app"
	TransitionAcquireLease TransitionKind = "acquire-lease"
	TransitionRenewLease   TransitionKind = "renew-lease"
	TransitionRecover      TransitionKind = "recover"
	TransitionCancel       TransitionKind = "cancel"
	TransitionVerifyApp    TransitionKind = "verify-app-artifact"
)

type UIPhase

type UIPhase string

UIPhase is the fixed user-facing lifecycle vocabulary.

const (
	UIPhaseDownload   UIPhase = "download"
	UIPhaseVerify     UIPhase = "verify"
	UIPhaseInstall    UIPhase = "install"
	UIPhaseStart      UIPhase = "start"
	UIPhaseReadyCheck UIPhase = "ready-check"
	UIPhaseReady      UIPhase = "ready"
)

func PhaseForUI

func PhaseForUI(target Target, phase OperationPhase, percent int) (UIPhase, bool)

PhaseForUI maps every measurable operation edge to the fixed UI phase vocabulary.

type WaitingState

type WaitingState string

WaitingState identifies an operation that is durable but has no live holder.

const (
	WaitingNone   WaitingState = ""
	WaitingForApp WaitingState = "waiting-for-app"
)

Jump to

Keyboard shortcuts

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