runstate

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 0 Imported by: 0

Documentation

Overview

Package runstate normalizes supervisor lifecycle status for consumers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsTerminalStatus

func IsTerminalStatus(status string) bool

IsTerminalStatus reports whether a consumer-facing status is terminal.

func IsTurnComplete

func IsTurnComplete(status, phase string) bool

IsTurnComplete reports whether a raw supervisor status and phase identify a completed turn. It uses the same normalization as Translate so callers do not need to reproduce the running/terminal-phase race handling.

Types

type Action

type Action string

Action tells an await loop what to do after an observation.

const (
	ActionContinue   Action = "continue"
	ActionResnapshot Action = "resnapshot"
	ActionExit       Action = "exit"
)

type Decision

type Decision struct {
	State  State
	Action Action
}

Decision is the state machine result for a snapshot or event wakeup.

type Machine

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

Machine derives await decisions from authoritative snapshots. Its zero value is ready to use.

func (*Machine) ObserveEvent

func (m *Machine) ObserveEvent(event string) Decision

ObserveEvent treats lifecycle events as wakeups only. State-relevant and lag notifications request an authoritative snapshot; no event, including a lag notification, changes state or directly exits the await loop.

func (*Machine) ObserveSnapshot

func (m *Machine) ObserveSnapshot(snapshot Snapshot) Decision

ObserveSnapshot replaces the machine state with the state derived from the supplied snapshot. The update is idempotent for a repeated snapshot.

type Snapshot

type Snapshot struct {
	Status            string
	Phase             string
	PendingPermission bool
}

Snapshot contains the authoritative lifecycle fields used to decide whether an await operation keeps waiting or returns.

type State

type State string

State is the normalized state of an awaited run.

const (
	StateActive            State = "active"
	StateDone              State = "done"
	StateFailed            State = "failed"
	StateTimeout           State = "timeout"
	StateKilled            State = "killed"
	StatePendingPermission State = "pending_permission"
)

type Translation

type Translation struct {
	Status       string
	Phase        string
	TurnComplete bool
}

Translation is the consumer-facing lifecycle state derived from a raw supervisor status and phase.

func Translate

func Translate(status, phase string) Translation

Translate normalizes a raw supervisor status and phase. An idle runtime is complete only when its phase is terminal. A running runtime stays running even when terminal phase metadata arrives before active-attempt cleanup finishes.

Jump to

Keyboard shortcuts

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