state

package
v0.6.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CodeCorrupt  = "state_corrupt"
	CodeSchema   = "state_schema_unsupported"
	CodeIdentity = "state_identity_mismatch"
)

Stable refusal codes for state decode/validate. All name external repair as the sole next action; the split exists because a future schema and a mismatched identity are diagnosed differently by an operator.

View Source
const SchemaVersion = 1

Variables

This section is empty.

Functions

func Encode

func Encode(s State) ([]byte, error)

Types

type Mutator

type Mutator func(*State) error

type Projection

type Projection struct {
	Change     string `json:"change"`
	Schema     int    `json:"schemaVersion"`
	Stage      string `json:"stage"`
	Condition  string `json:"condition"`
	Revision   uint64 `json:"revision"`
	NextAction string `json:"nextAction"`
}

type State

type State struct {
	SchemaVersion  int                        `json:"schemaVersion"`
	Change         string                     `json:"change"`
	Stage          string                     `json:"stage"`
	Condition      string                     `json:"condition"`
	Revision       uint64                     `json:"revision"`
	Approvals      []json.RawMessage          `json:"approvals"`
	Tasks          map[string]json.RawMessage `json:"tasks"`
	CreatedBy      string                     `json:"createdBy"`
	LastTransition string                     `json:"lastTransition"`
	Extensions     map[string]json.RawMessage `json:"extensions,omitempty"`
}

func Decode

func Decode(data []byte, expectedChange string) (State, error)

func Initial

func Initial(change, creationID string) State

func Mutate

func Mutate(path, expectedChange string, expectedRevision uint64, mutate Mutator) (State, error)

Mutate takes only the change lock. Callers needing a root lock must acquire it first: root before change is the global lock order.

path is <change>/state.json, so the change folder is its directory and the one change lock is the one corepath derives from it, the same file corepath.Owner.ChangeLock names and every other state writer takes.

func (State) Project

func (s State) Project() Projection

func (State) Validate

func (s State) Validate(expectedChange string) error

Jump to

Keyboard shortcuts

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