StatePro ships with utilities to inspect and exercise machines without writing extra scaffolding.
Located under debugger/cli, this TUI loads definitions, events, and snapshots for interactive
exploration.
go run ./example/cliBy default the example loads files from the repository root. Use the setters on
cli.StateMachineDebugger to point at custom paths:
debugger := cli.NewStateMachineDebugger()
debugger.SetStateMachinePath("./state_machine.json")
debugger.SetEventsPath("./events.json")
debugger.SetSnapshotsPath("./snapshots.json")
debugger.SetSMContextPath("./context.json")
debugger.Run(nil)- View machine metadata, universes, and realities as formatted JSON (with color support).
- Send events from the loaded list and observe resulting snapshots in real time.
- Inspect history timelines, tracking information, and serialized accumulator state.
- Load machine context fixtures (
context.json) to simulate stateful execution.
Tips:
- Provide
events.jsonas a list of objects withname, optionaldata, and optional flags. snapshots.jsoncan preload earlier runs—useqm.GetSnapshot()andToJson()to generate it.
The bot under debugger/bot automates event playback for repeatable testing.
qm := loadDefinition() // see modeling guide
provider := func(_ *instrumentation.MachineSnapshot) (instrumentation.Event, error) {
if len(events) == 0 {
return nil, nil
}
evt := events[0]
events = events[1:]
return evt, nil
}
b, _ := bot.NewBot(qm, provider, true)
_ = b.Run(context.Background(), myContext)
for _, step := range b.GetHistory() {
fmt.Println(step.Event.GetEventName(), step.Snapshot.GetResume())
}Parameters:
qm: anyinstrumentation.QuantumMachine(experimental runtime or custom implementation).eventProvider: called after each step, receives the latest snapshot, and returns the next event (ornilto stop).initQuantumMachine: whentrue,Runcallsqm.Initbefore sending events.
- Deterministic regression tests for complex flows.
- Batch simulations that assert snapshot contents after each event.
- Generating documentation assets by exporting tracking histories.
Use builtin.SetLogger(abslog.New(...)) or register your own logger to capture runtime diagnostics.
Abslog integrates with structured logging backends and honors context cancellation.
- Review runtime.md to understand how events propagate while using these tools.
- Combine the bot with Go testing frameworks to cover edge cases involving superposition and observers.