Skip to main content
This chapter continues the shared-state manual. The poll examples build on the activity_poll definition in Machines, commands, and views. Alternative fragments are labeled separately.

Testing without a survey

A machine is testable as an ordinary transition system:
The state is now:
Trying to change Amina’s vote leaves it unchanged because once=True. Render the visible data separately:
These calls are useful for unit tests. Production execution performs the same transition through a transactional store.

Serialization

Machines and state maps use versioned JSON representations:
An input reference becomes data resembling:
The payload contains no executable Python. Serialization is why the DSL uses field("votes") rather than a closure and arg("activity") rather than a lambda. Persisted values follow a deliberately narrow JSON contract:
  • mapping keys are strings;
  • numbers are finite, so NaN and infinity are rejected;
  • expression and effect operators have validated names and arities; and
  • symbolic conditions use &, |, and ~, not Python and, or, and not.
Python Boolean operators attempt to ask an expression for its truth value while the definition is being built. EDSL raises a TypeError instead of accidentally collapsing a symbolic condition to True or False. Machine and SharedStateMap currently serialize as version 1. Unsupported versions fail explicitly rather than being interpreted as the current language.

Using the ep CLI

Write a serialized machine to a JSON file, then validate and inspect it without loading the authoring code:
To exercise a sequence locally, put transitions in a JSON file. Each transition names a command and supplies its inputs:
The output includes each event, resulting state, rendered view, and completion status. This is a local dry run of the definition; it does not write to a shared-state backend. For a completed job, inspect the persisted bindings and snapshots with: