soma.cell

State machines builtins

5 builtins of Soma 3.2.4 in the category State machines, with their exact signatures, as soma describe --builtins --json prints them.

next_id

next_id() -> Int

Monotonic per-cell counter, in its own table (persistent under run/serve; per test cell in tests); journaled — a refused request burns no id; the ids drawn inside a try that fails are kept (they may have escaped into a local), so ids are unique, not always dense. Exhaustion at 2^63 - 1 raises range; a malformed or negative stored counter raises storage. Legacy migration is confined to the current cell.

deterministic · replay: pure

Used in verified programs:

transition

transition(id, target_state: String) -> {id, from, to} | transition(id, from_state: String, to_state: String) -> {id, from, to}

Move instance id to target_state (read the new state with get_status(id)); raises kind "invalid_transition" with the valid targets, or "guard_failed". With three arguments the handler declares the source: soma check verifies the edge exists and the call fails (invalid_transition) when the instance is elsewhere, even if some edge into the target exists from there. Rolled back if the handler later fails.

deterministic · replay: pure

Used in verified programs:

get_status

get_status(id) -> String

Current state of instance id. For an id never transitioned: () in edition 2027, the INITIAL state in edition 2026 — get_status(id) ?? "initial" reads the same in both (has_state(id) tells a fresh id from one that moved).

deterministic · replay: pure

Used in verified programs:

has_state

has_state(id) -> Bool

True when instance id was transitioned at least once (a recorded state exists). get_status(id) alone cannot distinguish an unknown id from a fresh one.

deterministic · replay: pure

valid_transitions

valid_transitions(id) -> List<String>

States reachable from instance id's current state.

deterministic · replay: pure

Used in verified programs: