reconcile

package
v0.13.0 Latest Latest
Warning

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

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

Documentation

Overview

Package reconcile is the pure functional core for the server's gate/grant and execution-lifecycle state. It performs no I/O: Step takes an observed World plus a Signal and returns the new ChangeSet plus the minimal set of Actions the imperative shell must execute. See docs/superpowers/specs/2026-06-15-reconciler-core-design.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAllowed

func ApplyAllowed(g GateState) bool

ApplyAllowed is the fail-closed apply-gate verdict: only Clean or Satisfied permit apply; NotClassified, Pending, and Blocked deny it.

func DisplayStatus

func DisplayStatus(s Stack, g GateState) events.Status

DisplayStatus is the derived per-stack status shown in the UI/check run. The runner-told status wins when terminal (failed/moving); otherwise the gating overlay (gated/safe) is derived from the ChangeSet's GateState. This is the single source of the gated/safe distinction — it is never stored separately.

func Requester

func Requester(g GateState) string

Requester returns the leased requester identity for the gate ("" if none).

func Step

func Step(w World, s Signal) (ChangeSet, []Action)

Step is the one pure front door. Given the observed World and an incoming Signal it returns the new ChangeSet and the minimal Actions the shell must execute. Deterministic; no I/O; safe to call repeatedly.

func YieldsResult

func YieldsResult(a Action) bool

YieldsResult reports whether an action produces a GrantsObserved on the fixpoint loop (only RequestGrant does). The shell uses this to decide when the fixpoint has converged.

Types

type Action

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

Action is an effect the pure core wants performed but cannot do itself.

type ApplySucceeded

type ApplySucceeded struct{}

type BlockReason

type BlockReason string
const (
	ReasonDenied       BlockReason = "denied"
	ReasonExpired      BlockReason = "expired"
	ReasonRevoked      BlockReason = "revoked"
	ReasonSlotForeign  BlockReason = "slot_foreign_open" // another open PR holds the slot (⑥)
	ReasonSlotSelf     BlockReason = "slot_self"         // same PR, another env, holds the slot (⑥)
	ReasonBackendError BlockReason = "backend_error"
)

type Blocked

type Blocked struct {
	Targets []Target
	Lease   Lease
	By      Blocker
}

type Blocker

type Blocker struct {
	Reason BlockReason
	ByPR   int    // slot blocker's PR (0 if N/A)
	ByEnv  string // slot blocker's environment
}

Blocker explains why a gate is Blocked.

type ChangeSet

type ChangeSet struct {
	PR          int
	Environment string
	Exec        Execution
	Gate        GateState
}

ChangeSet is the reconciliation unit: one PR's work in one environment.

type Clean

type Clean struct{} // classified, zero gates → apply passes

type Collision

type Collision struct {
	ByPR          int
	ByEnv         string
	BySelf        bool // ByPR == this changeset's PR (different env)
	ByPRAbandoned bool // shell looked up the blocker PR's GitHub state (closed && !merged)
}

Collision describes a slot blocker the shell already resolved against GitHub.

type Execution

type Execution struct {
	ID     string
	Repo   string
	SHA    string
	LogURL string
	Phase  events.Phase
	Stacks []Stack
}

Execution is the plan/apply run for the ChangeSet (edge-triggered facts).

type GateState

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

GateState is a sum type: a gate is EXACTLY one of these.

type GateTick

type GateTick struct{ Grants []ObservedGrant }

GateTick is the periodic backstop re-observation; Grants is a full re-list of the changeset's targets. Processed identically to GrantsObserved.

type GrantsObserved

type GrantsObserved struct{ Grants []ObservedGrant }

GrantsObserved carries grant observations for THIS changeset: either the results of RequestGrant actions (fixpoint feedback) or a re-list. Grants not mentioned are left unchanged.

type Lease

type Lease struct{ Requester string }

Lease is the pooled requester identity leased once per ChangeSet. Empty Requester means undecided.

type NotClassified

type NotClassified struct{} // never planned → apply fails closed

type ObservedGrant

type ObservedGrant struct {
	Class     string
	Target    string
	Name      string              // backend-assigned id ("" if none)
	State     approval.GrantState // "" == no grant present for this changeset
	Requester string              // leased identity ("" if N/A)
	Collision *Collision          // set when a RequestGrant hit a SlotCollisionError
}

ObservedGrant is one grant fact the shell gathered for a (class,target).

type PRClosed

type PRClosed struct{}

type Pending

type Pending struct {
	Targets []Target
	Lease   Lease
}

type PostCommitStatus

type PostCommitStatus struct {
	State       string // "success" | "failure" | "pending"
	Description string
}

PostCommitStatus posts the commit status. Pure output; no result.

type PublishSSE

type PublishSSE struct{}

PublishSSE notifies the live-page hub that state changed. Pure output.

type RenderCheckRun

type RenderCheckRun struct {
	Terminal   bool
	Conclusion string // "success" | "action_required" | "failure" | "" (in-progress)
}

RenderCheckRun re-renders the GitHub check run from current state. Pure output; no result.

type RequestGrant

type RequestGrant struct {
	Class     string
	Target    string
	Requester string
}

RequestGrant asks the backend to ensure an open grant. It YIELDS a result (grant name + leased requester, or a Collision) the shell feeds back as a GrantsObserved signal. Requester pins the lease; "" lets the backend lease.

type RevokeGrant

type RevokeGrant struct {
	Class       string
	Target      string
	PR          int
	Environment string
}

RevokeGrant revokes the open grant for (class,target,PR,environment). Idempotent; produces no result. PR/Environment default to the changeset's when zero/empty but are set explicitly when revoking a foreign slot blocker.

type RunnerFinalize

type RunnerFinalize struct {
	Failed         bool
	ReportMarkdown string
	Projects       map[string]string            // stack path → grouping/target key
	Categories     map[string][]events.Category // stack path → matched categories
	Moving         []string                     // stack paths adopting via cross-state move
	Gates          []events.GateTarget          // (class,target) pairs needing approval
}

type RunnerInit

type RunnerInit struct{ Exec Execution }

type RunnerPhase

type RunnerPhase struct{ Phase events.Phase }

type RunnerUpdate

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

type Satisfied

type Satisfied struct {
	Targets []Target
	Lease   Lease
}

type Signal

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

Signal is the union of everything that can drive a ChangeSet.

type Stack

type Stack struct {
	Path       string
	Project    string
	RunStatus  events.Status // pending|running|planned|failed|moving (never gated/safe)
	Detail     string
	Categories []events.Category
}

Stack is one node. RunStatus holds ONLY the runner-told statuses; the gated/safe overlay is derived from the ChangeSet's GateState (see project.go).

type Target

type Target struct {
	Class     string
	Target    string
	GrantName string              // backend-assigned id; "" until created
	Grant     approval.GrantState // observed grant lifecycle; "" == no grant/absent
}

Target is one (class,target) gate and its observed grant.

type World

type World struct {
	Prior ChangeSet
}

World is the scoped, immutable snapshot the shell hands to Step. The prior ChangeSet is the current persisted state for (PR, Environment); observations ride on the Signal. The core performs no I/O.

Jump to

Keyboard shortcuts

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