Help us shape the future of Go! Take the 2026 Go Developer Survey

chaos

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package chaos is a deterministic crash-injection benchmark for agent runtimes: it drives a NON-IDEMPOTENT side effect through a fault schedule and checks it fires at most once.

It's the exportable form of Bide' internal DST — point it at any SDK by implementing System (wire that SDK to do one non-idempotent side effect against a fault-injectable, resumable store). The harness is what proves — or disproves — an at-most-once guarantee: a loop that relies on at-least-once + idempotency double-fires here, visibly. See Bide for the reference adapter that passes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Report

type Report struct {
	Name       string
	Sweeps     int // crash points swept exhaustively
	Schedules  int // total crash schedules exercised (sweep + randomized)
	MaxFired   int // worst side-effect count observed (want 1)
	Violations int // schedules where the side effect fired more than once
}

Report is the outcome of a chaos run against one System.

func Verify

func Verify(name string, sys System, seeds int) Report

Verify runs an exhaustive crash-point sweep plus `seeds` randomized multi-crash schedules against sys, and returns a Report. The invariant checked is that the non-idempotent side effect fires at most once, no matter where or how often it crashes.

func (Report) OK

func (r Report) OK() bool

OK reports whether the at-most-once invariant held across every schedule.

func (Report) String

func (r Report) String() string

type Run

type Run interface {
	Step(crashAt int) (crashed bool)
	Fired() int
}

Run is one scenario instance: a fresh store + zeroed side-effect counter. Step runs or resumes one attempt, injecting a crash at the crashAt-th durable write (0 = no crash); it returns crashed=true if that crash aborted the attempt (call Step again to resume), false when the attempt reaches a terminal state. Fired reports how many times the non-idempotent side effect actually executed across all Steps so far.

type System

type System interface {
	NewRun() Run
	Writes() int
}

System is one SDK under test: it builds fresh Runs and reports the number of durable writes in a clean run (the crash-sweep upper bound).

func Bide

func Bide() System

Bide is the reference System: Bide' durable loop wired to charge once. It is expected to PASS (at-most-once) under any crash schedule.

func NaiveReference

func NaiveReference() System

NaiveReference is a deliberately-simple at-least-once loop: it journals tool results and replays them, but a tool whose result isn't journaled is simply RE-RUN — no attempt marker, no halt-on-unknown-outcome. So a crash after the side effect but before its result persists causes a DOUBLE-FIRE. This is the common "just make your side effects idempotent" design; it is the baseline an SDK must beat on this benchmark, and it makes the harness demonstrably non-vacuous (a correct loop passes it; this one fails).

Jump to

Keyboard shortcuts

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