execution

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package execution is the pure event-sourced domain core for one execution's lifecycle (init → phase → per-stack ticks → terminal). It follows the Decider pattern: Decide emits Events, Evolve folds them into a State. No I/O, no store imports — a pure leaf package, mirroring internal/claims. The aggregate is scoped per execution id (stream "run:<execID>"); it carries NO gate state (the gate lives in the (pr,env) aggregate in internal/reconcile).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalEvent

func MarshalEvent(e Event) (string, []byte, error)

MarshalEvent serializes a domain Event to a neutral (typeTag, JSON) pair. The tag is the variant's Go type name. Keep this switch and UnmarshalEvent in sync with the Event variants in state.go (the round-trip-every-variant test enforces it).

func MarshalSnapshot

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

MarshalSnapshot serializes a folded State to JSON.

Types

type Edge

type Edge struct {
	From string
	To   string
}

Edge is a directed edge between two stacks.

type Event

type Event interface {
	// contains filtered or unexported methods
}

Event is a past-tense domain fact produced by Decide and folded by Evolve.

func Decide

func Decide(s State, sig Signal) []Event

Decide maps a Signal to the past-tense domain facts it produces. Pure: no I/O, no time.Now(). All business logic lives here; Evolve only folds.

func UnmarshalEvent

func UnmarshalEvent(tag string, data []byte) (Event, error)

UnmarshalEvent reverses MarshalEvent.

type Failed

type Failed struct{}

type PhaseChanged

type PhaseChanged struct {
	Phase       events.Phase
	Label       string
	Pct         *int
	ID          string
	PR          int
	Repo        string
	SHA         string
	Environment string
	Context     string
	LogURL      string
}

type ReportAnnotate

type ReportAnnotate struct {
	Projects   map[string]string
	Categories map[string][]events.Category
	Counts     map[string]events.Counts
	Moving     []string
}

ReportAnnotate annotates stacks with project, categories, counts, and moving state.

type ReportFail

type ReportFail struct{}

ReportFail marks the run terminally failed (fails-open innocent stacks in Evolve).

type ReportInit

type ReportInit struct{ Exec State }

ReportInit registers the execution and its changed subgraph.

type ReportPhase

type ReportPhase struct {
	Phase       events.Phase
	Label       string
	Pct         *int
	ID          string
	PR          int
	Repo        string
	SHA         string
	Environment string
	Context     string
	LogURL      string
}

ReportPhase narrates a lifecycle phase transition.

type ReportSucceed

type ReportSucceed struct{}

ReportSucceed marks the run terminally succeeded.

type ReportSupersede

type ReportSupersede struct{ By string }

ReportSupersede marks this execution as superseded by another.

type ReportTick

type ReportTick struct {
	Stack  string
	Status events.Status
	Detail string
}

ReportTick ticks a single stack's runner-told status.

type Signal

type Signal interface {
	// contains filtered or unexported methods
}

Signal is the union of everything that can drive an execution's State.

type Stack

type Stack struct {
	Path       string
	Project    string
	RunStatus  events.Status
	Detail     string
	Categories []events.Category
	Counts     *events.Counts
}

Stack is one node. RunStatus holds ONLY the runner-told status; the gated/safe overlay is derived elsewhere (the (pr,env) gate aggregate's projection).

type StackStatusChanged

type StackStatusChanged struct {
	Stack  string
	Status events.Status
	Detail string
}

type StacksAnnotated

type StacksAnnotated struct {
	Projects   map[string]string
	Categories map[string][]events.Category
	Counts     map[string]events.Counts
	Moving     []string
}

type Started

type Started struct{ Exec State }

type State

type State struct {
	ID            string
	Repo          string
	SHA           string
	LogURL        string
	PR            int
	Environment   string
	Context       string
	Phase         events.Phase
	ProgressLabel string
	ProgressPct   *int
	Status        string
	SupersededBy  string
	Stacks        []Stack
	Edges         []Edge
}

State is the folded lifecycle of ONE execution.

func Empty

func Empty() State

Empty is the initial state for the fold (an unseen execution stream).

func Evolve

func Evolve(s State, e Event) State

Evolve applies a single domain Event to a State, returning the new state. Total (never panics on any state/event combination), pure, deterministic — the fold half of the Decider pattern.

func UnmarshalSnapshot

func UnmarshalSnapshot(b []byte) (State, error)

UnmarshalSnapshot reverses MarshalSnapshot.

type Succeeded

type Succeeded struct{}

type Superseded

type Superseded struct{ By string }

Jump to

Keyboard shortcuts

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