Simulation reference
Use this page when you need exact simulator facts: command forms, event input, settings, history/export formats, Python runtime API, and public failure boundaries. For a first run, see FCSTM simulation first run; for recipes, see Simulation tasks; for ordering semantics, see Execution semantics explanation.
CLI invocation
pyfcstm simulate loads one FCSTM file, parses it into a state-machine model,
constructs a pyfcstm.simulate.SimulationRuntime, and either starts an
interactive REPL or runs semicolon-separated batch commands.
Option |
Required |
Meaning |
|---|---|---|
|
yes |
Path to the FCSTM input file. |
|
no |
Batch command string. Commands are separated by semicolons. |
|
no |
Disable ANSI color in command output. |
|
no |
Show Click help and exit. |
Parse, decode, grammar, and model-validation failures are written to stderr as
Failed to parse DSL file: .... Batch and REPL command failures normally
return a user-facing message in command output instead of raising through the
CLI process.
Batch and REPL commands
Batch mode and the interactive REPL use the same command processor.
Command |
Parameters |
Output and boundary |
|---|---|---|
|
Optional positive integer count followed by event inputs. Without a count, one cycle is executed. |
Runs cycle(s). A non-positive count reports |
|
none |
Prints current cycle, state, and persistent variables. |
|
none |
Lists events available from the current runtime state. |
|
Optional positive integer row count or |
Prints retained history. Empty history reports |
|
Target state plus numeric variable assignments. |
Rebuilds the runtime as a hot start. Every declared variable must be provided. Values accept decimal, hexadecimal, binary, float, and scientific notation. |
|
No arguments, one key, or key/value pair. |
Lists settings, shows one setting, or updates one setting. |
|
Output path ending in |
Writes retained history. Empty history, unsupported suffixes, and file write failures return explicit command messages. |
|
none |
Rebuilds a fresh runtime while preserving session-level configuration. |
|
none |
Prints command help and keyboard shortcuts. |
|
none |
Leaves the interactive REPL or ends batch command processing. |
Event input forms
The runtime accepts model-owned pyfcstm.model.Event objects, one event
path string, or an iterable containing those values. A bare string is one event
input, not a sequence of characters.
Form |
Example |
Meaning |
|---|---|---|
Short or relative event name |
|
Resolved from the current runtime state. |
Dot-separated full path |
|
Resolved as a model event path. |
Parent-relative path |
|
Navigates relative to the current state path. |
Absolute path |
|
Resolved from the root state. |
Multiple events |
|
Makes all listed events available for the cycle. |
A pyfcstm.simulate.SimulationRuntimeEventError is raised by the Python
API, and shown as Cycle execution failed: ... by the command layer, when an
event input has an unsupported shape, cannot be resolved, or belongs to a
different state machine.
Settings
Settings are command-layer session settings. --no-color initializes
color to False for that CLI session.
Key |
Type and legal values |
Default |
Effect |
|---|---|---|---|
|
Non-negative integer |
|
Controls table truncation for large command output. |
|
Non-negative integer; |
|
Controls how many history entries the active runtime retains. |
|
Boolean strings |
|
Enables or disables ANSI color in display output. |
|
|
|
Controls simulator log verbosity. |
Unknown settings report Error: 'Unknown setting: <key>'. Invalid values
report an Error: ... message from the setting validator.
Note
The history_size=0 setting is a command-layer convention. During
setting synchronization, the command layer maps it to
SimulationRuntime.history_size = None. Direct Python API use is
different: SimulationRuntime(history_size=None) means unlimited history,
while SimulationRuntime(history_size=0) keeps no entries.
History and export formats
Runtime history entries are dictionaries with cycle, state, vars,
and optional events keys. history displays retained rows; export is
a command-layer feature and is not a pyfcstm.simulate.SimulationRuntime method.
Suffix |
Shape |
Notes |
|---|---|---|
|
Columns |
Events are joined with semicolons inside one CSV cell. |
|
JSON array of history entry objects. |
Uses two-space indentation and UTF-8 output. |
|
YAML sequence of history entry mappings. |
Uses Unicode-friendly PyYAML output. |
|
One JSON history entry object per line. |
Suitable for append-like or streaming post-processing. |
Python runtime API
Surface |
Purpose and boundary |
|---|---|
|
Creates a runtime. Default-start mode may accept partial
|
|
Executes one cycle, validates candidate paths, commits or rolls back, and records history. |
|
Legacy return value; currently |
|
Canonical event paths supplied for the cycle, in normalized input order. |
|
Canonical event paths for evented transitions that executed. |
|
Canonical supplied event paths that did not correspond to executed evented transitions. |
|
Public runtime state used by command display, tests, and tooling. The
command-layer |
|
Current active state. Check |
|
Terminal-safe stack summary as |
|
|
|
Abstract-handler diagnostic state. |
|
Manage handlers for named abstract actions. |
|
Clear handlers plus related diagnostics. |
|
Inspect handler registration state. |
|
Register object methods decorated with |
|
Immutable handler context exposing state path, variable snapshot, action metadata, active leaf, abstract target, and named-ref metadata. |
|
Decorator that marks object methods for bulk handler registration. |
Public failures and boundaries
Failure |
Where it appears |
Meaning |
|---|---|---|
|
Python API and |
Invalid error mode, unknown variables, missing hot-start variables, unresolved state path, or invalid persistent value type. |
|
Python API; command layer reports |
Unsupported, unresolved, or foreign event input. |
|
Python API; command layer reports an unbounded execution-chain message |
Speculative validation exceeded DFS or stack-depth safety limits while looking for a stoppable state or termination. |
|
Python API |
Runtime has ended and the active stack is empty. |
|
Python API; command layer reports |
Runtime evaluation of a guard or action expression failed. |
|
Python API |
A named action reference could not be resolved or executed safely. |
Abstract handler exception |
Python API |
In |
Unsupported export suffix or file error |
Command layer |
|
Source facts
This reference is aligned with these implementation and test facts:
pyfcstm/entry/simulate/__init__.pyfor Click options and parse failure handling.pyfcstm/entry/simulate/batch.pyandcommands.pyfor batch and REPL command behavior.pyfcstm/simulate/runtime.py,context.pyanddecorators.pyfor the Python API surface.test/fixtures/simulate_semantics/cases/andtest/testings/simulate_semantics.pyfor execution-order scenarios.docs/source/tutorials/simulation/*.demo.*for checked documentation transcripts.