terminaldecision

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package terminaldecision contains deterministic coordination fixtures for terminal-decision platform tests. Fixtures only expose barriers; callers advance them and own any goroutines used by the test.

Index

Constants

View Source
const (
	TerminalAllowStop = "allow_stop"
	TerminalCancelled = "cancelled"
	TerminalContinued = "continued"
	TerminalClosed    = "closed"
	TerminalDrained   = "drained"

	SettlementB1            = "b1_settled"
	SettlementB1AfterB2     = "b1_settled_after_b2"
	SettlementB1Unsettled   = "b1_unsettled"
	SettlementDrained       = "request_drained"
	SettlementNotApplicable = "not_applicable"

	CleanupNone               = "none"
	CleanupCancelled          = "cancelled"
	CleanupOverlayDeactivated = "overlay_deactivated"
	CleanupGenerationClosed   = "generation_closed"

	PolicySnapshotUnchanged = "snapshot_unchanged"
	PolicyOldSnapshot       = "old_snapshot"
	PolicyNewSnapshot       = "new_snapshot"

	StepB1Settlement = "b1_settlement"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Barrier

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

Barrier is a caller-driven two-phase gate. Arrive and Release are idempotent, so a replayed schedule step cannot panic by closing a channel.

func NewBarrier

func NewBarrier() *Barrier

NewBarrier returns a closed-only coordination gate.

func (*Barrier) Arrive

func (b *Barrier) Arrive()

Arrive publishes that the guarded operation reached the gate.

func (*Barrier) Arrived

func (b *Barrier) Arrived() <-chan struct{}

Arrived is closed after Arrive is called.

func (*Barrier) Release

func (b *Barrier) Release()

Release permits the guarded operation to continue.

func (*Barrier) Released

func (b *Barrier) Released() <-chan struct{}

Released is closed after Release is called.

type CancellationSchedule

type CancellationSchedule struct {
	Fixture
	Provider, Cancel, Continuation *Barrier
}

CancellationSchedule exposes the provider, cancellation, and continuation gates for a cancellation-wins race.

func CancellationRaceSchedule

func CancellationRaceSchedule() CancellationSchedule

CancellationRaceSchedule returns the cancellation-wins schedule.

type ContinuationSchedule

type ContinuationSchedule struct {
	Fixture
	B2Admission, B2Publication, B1Settlement *Barrier
}

ContinuationSchedule exposes B2 admission/publication and B1 settlement gates for both pre-publication and post-publication failure paths.

func B2AdmissionFailureSchedule

func B2AdmissionFailureSchedule() ContinuationSchedule

B2AdmissionFailureSchedule models failure before B2 publication.

func B2PublishedSettlementSchedule

func B2PublishedSettlementSchedule() ContinuationSchedule

B2PublishedSettlementSchedule models B2 becoming current before B1 settlement reports success or loss.

func ContinuationSchedules

func ContinuationSchedules() []ContinuationSchedule

ContinuationSchedules returns both B1/B2 ordering schedules.

type Event

type Event struct {
	Kind  EventKind
	Value string
}

Event is one terminal, settlement, cleanup, or policy result.

type EventKind

type EventKind uint8

EventKind identifies one bounded outcome category recorded by a fixture.

const (
	TerminalEvent EventKind = iota
	SettlementEvent
	CleanupEvent
	PolicyEvent
	StepEvent
)

type Fixture

type Fixture struct {
	Name           string
	Recorder       *Recorder
	Expected       Outcome
	ExpectedEvents []Event
}

Fixture is shared bookkeeping for named schedules, not a scheduler.

func (*Fixture) Record

func (f *Fixture) Record(kind EventKind, value string) error

Record records an outcome on the fixture.

func (*Fixture) Verify

func (f *Fixture) Verify() error

Verify checks the fixture's expected outcome and exact event order.

type Outcome

type Outcome struct {
	Terminal   string
	Settlement string
	Cleanup    string
	Policy     string
}

Outcome is the expected one-event result of a named schedule.

type OverlayCleanupSchedule

type OverlayCleanupSchedule struct {
	Fixture
	ExternalIngress, OverlayCleanup *Barrier
}

OverlayCleanupSchedule exposes external ingress and fixed-overlay cleanup gates for stale state after a crash or restart.

func StaleOverlayCleanupSchedule

func StaleOverlayCleanupSchedule() OverlayCleanupSchedule

StaleOverlayCleanupSchedule models idempotent stale overlay deactivation.

type PolicyRaceSchedule

type PolicyRaceSchedule struct {
	Fixture
	Snapshot, Write, SnapshotComplete *Barrier
}

PolicyRaceSchedule exposes the snapshot/write ordering gates.

func PolicySchedules

func PolicySchedules() []PolicyRaceSchedule

PolicySchedules returns both deterministic linearization orders.

func PolicySnapshotBeforeWriteSchedule

func PolicySnapshotBeforeWriteSchedule() PolicyRaceSchedule

PolicySnapshotBeforeWriteSchedule models a request retaining the old complete state while a later write applies to the next request.

func PolicyWriteBeforeSnapshotSchedule

func PolicyWriteBeforeSnapshotSchedule() PolicyRaceSchedule

PolicyWriteBeforeSnapshotSchedule models a request observing the new complete state.

type ProviderFailureKind

type ProviderFailureKind string

ProviderFailureKind identifies a failure at the provider boundary.

const (
	ProviderTimeout   ProviderFailureKind = "timeout"
	ProviderError     ProviderFailureKind = "error"
	ProviderPanic     ProviderFailureKind = "panic"
	ProviderMalformed ProviderFailureKind = "malformed"
)

type ProviderFailureSchedule

type ProviderFailureSchedule struct {
	Fixture
	Kind     ProviderFailureKind
	Provider *Barrier
}

ProviderFailureSchedule gates provider timeout, error, panic, and malformed result paths. All normalize to one safe terminal and no continuation.

func ProviderFailureSchedules

func ProviderFailureSchedules() []ProviderFailureSchedule

ProviderFailureSchedules returns one independent schedule per boundary failure mode.

type Recorder

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

Recorder rejects duplicate outcome categories, making exactly-once checks deterministic without polling or timeouts.

func NewRecorder

func NewRecorder() *Recorder

NewRecorder returns an empty event recorder.

func (*Recorder) Events

func (r *Recorder) Events() []Event

Events returns a copy in recording order so callers can assert linearization, such as publication before settlement.

func (*Recorder) Matches

func (r *Recorder) Matches(want Outcome) error

Matches compares recorded results with the schedule's expected outcome.

func (*Recorder) Outcome

func (r *Recorder) Outcome() (Outcome, error)

Outcome returns the four recorded categories. Missing categories are an error because every schedule declares one explicit result for each class.

func (*Recorder) Record

func (r *Recorder) Record(kind EventKind, value string) error

Record appends one outcome, rejecting empty values and duplicate categories.

type WithdrawalSchedule

type WithdrawalSchedule struct {
	Fixture
	PinnedRequest, Withdrawal, Drain, Close *Barrier
}

WithdrawalSchedule exposes pin, withdrawal, drain, and close barriers.

func GenerationWithdrawalSchedule

func GenerationWithdrawalSchedule() WithdrawalSchedule

GenerationWithdrawalSchedule models an admitted request retaining its immutable generation while new admission is withdrawn.

Jump to

Keyboard shortcuts

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