Determa State-rust
A Rust implementation of the Determa State statechart engine.
Implements Determa State spec v0.0.5. Correctness is defined by the language-agnostic
conformance suite at fruwehq/determa-state-conformance
(pinned at tag v0.0.2 as a submodule under conformance-suite/); this engine is
correct iff it passes every case.
What is Determa State?
Determa State is a language-agnostic statechart format: a machine is declared once in YAML
and run by an implementation in any language, with all implementations held
accountable by a shared conformance suite. It follows the run-to-completion and
hierarchical-state-machine semantics of Miro Samek's Practical Statecharts in
C/C++ (PSiCC) — the outermost state is top — and keeps the vocabulary of
cns_statemachine (top, esvs, on_events, transition_to, defer, publish)
while replacing raw guards/actions with CEL and a small
structured action set.
This crate provides:
- Full statechart semantics (SPEC §5): hierarchy with LCA exit/entry, run-to-
completion, internal/local/external transitions, orthogonal regions +
done, shallow/deep history, choice pseudostates,deferred events, and timers over a virtual clock. - Extended state (
esvs) declared inside states, hierarchically scoped with shadowing (§4.4), plusexternalesvs driven by the reservedenvevent and therefreshaction (§5.4). - Guards in CEL and a structured action set (
assign/publish/refresh/spawn/stop) whose computed values are CEL (§6). - Active objects — each instance owns an event queue; instances are spawned dynamically with deterministic ids and communicate only by publishing events (directed or by subscription/scope) over a pluggable bus (§5.7).
- Faults via the reserved
errorevent with atomic step rollback and a dead-letter (§5.10). - Versioned definitions + safe-point migration (§10).
- Snapshot/restore and a passive per-step Observer (§8).
- Mermaid export (§12).
- An embeddable library API (§2) and the standard
Determa StateCLI (§13): all commands, exit codes, normative--jsonshapes,--store file:/mem:/sqlite:, batch/streamingrun, and the §14mode/inject/step/inspectverbs.
Build
# the binary is target/release/Determa State
Run the conformance suite
# engine cases (SPEC §9)
# black-box CLI cases (SPEC §13.6)
Both are wired into CI (.github/workflows/ci.yml), which fetches the suite at tag
v0.0.5 and fails the build on any regression.
CLI
--store <spec> selects a backend: file:<dir> (default, portable snapshot files),
mem: (ephemeral, in-process), or sqlite:<path>. See Determa State --help.
Library
use ;
use BTreeMap;
#
Status
Pre-1.0 (0.0.x), tracking the synchronized Determa State spec/conformance version.
License
MIT — see LICENSE.