Deterministic Scenario Engine
Generate test scenarios, not just test records.
Deterministic Scenario Engine creates reproducible, state-consistent business histories with deterministic ground truth for testing.
Why it exists
Fake-data libraries and random record generators produce values; fixtures often describe isolated records. Scenario Engine executes histories: each committed step sees a consistent state, produces traceable state changes and artifacts, and advances an explicit logical clock. The same scenario and execution context can be replayed byte-for-byte, while invariants, controlled faults, and an oracle make expected behavior explicit.
Core capabilities
- DSL 1 parsing, compilation, and deterministic execution
- addressed randomness and logical IDs that do not depend on a shared stream
- current state plus append-only committed history and artifacts
- whole-step atomicity
- explicit external inputs, resource DAG resolution, validators, and constraints
- subflows, ordered branches, and bounded repeat
- invariants, deterministic fault injection, provenance, and oracle evaluation
- canonical result bytes and a
ReproducibilityManifestfor exact replay - an explicit, versioned plugin boundary and a reference ecommerce plugin pack
- a JSON-file adapter
- optional pytest, SQLAlchemy Core, Hypothesis, and Schemathesis integrations
Core execution does not require a database, network service, plugin, or property testing framework. See security assumptions and non-goals.
Installation
From a source checkout, use a virtual environment and install the checkout:
python3 -m venv /tmp/scenario-engine-docs-venv
/tmp/scenario-engine-docs-venv/bin/python -m pip install .
Install only the named optional integrations you need:
/tmp/scenario-engine-docs-venv/bin/python -m pip install '.[pytest]'
/tmp/scenario-engine-docs-venv/bin/python -m pip install '.[sqlalchemy]'
/tmp/scenario-engine-docs-venv/bin/python -m pip install '.[hypothesis]'
/tmp/scenario-engine-docs-venv/bin/python -m pip install '.[schemathesis]'
The distribution is deterministic-scenario-engine 1.0.0. Install the package
with pip install deterministic-scenario-engine, or select an optional integration
with a command such as pip install 'deterministic-scenario-engine[pytest]'.
Minimal quickstart
The public cart scenario is an executable DSL 1 document. Run it from the repository root:
from pathlib import Path
from scenario_engine import (
compile_document,
parse_yaml,
replay_scenario,
run_scenario,
)
yaml_text = Path("examples/cart.yaml").read_text(encoding="utf-8")
document = parse_yaml(yaml_text)
scenario = compile_document(document)
result = run_scenario(scenario, root_seed="quickstart", run_index=0)
print(result.final_state["checkout_complete"])
print(result.trace())
stable_bytes = result.to_json_bytes()
manifest = result.manifest
replayed = replay_scenario(yaml_text, manifest)
assert replayed.to_json_bytes() == stable_bytes
ScenarioResult.final_state is the supported state-reading property; the stable
normalized result contains the same data under its state field.
Determinism contract
Generation derives from semantic ExecutionAddress values, not consumption of
a mutable global random stream. Exact replay requires the same canonical
scenario, explicit inputs, algorithms/plugins, and recorded execution context.
Unsupported cross-version replay fails explicitly. See the determinism model,
reproducibility guide, and normative
compatibility contract.
Documentation
- Quickstart
- DSL 1 reference
- Determinism model
- Reproducibility and replay
- Testing, faults, and oracle
- Plugins
- SQLAlchemy adapter
- Hypothesis integration
- Schemathesis integration
- Public Python API
- Security assumptions and non-goals
- Compatibility contract
Status
The distribution and engine compatibility version are both 1.0.0. The project is licensed under Apache-2.0.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deterministic_scenario_engine-1.0.0.tar.gz.
File metadata
- Download URL: deterministic_scenario_engine-1.0.0.tar.gz
- Upload date:
- Size: 99.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3264bbbb1956ff183c01cd85f379fe1a9afdf31d9375be7f95c003aff1a1800e
|
|
| MD5 |
3540220e68fac42daebc9f205f0bf6e8
|
|
| BLAKE2b-256 |
06a17042d0f0cfab5df89a6df4e5ad33e140214992c751d0fba7599213971b44
|
File details
Details for the file deterministic_scenario_engine-1.0.0-py3-none-any.whl.
File metadata
- Download URL: deterministic_scenario_engine-1.0.0-py3-none-any.whl
- Upload date:
- Size: 58.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a5dfe8666fdf82233ad2fecd1aa54a190291bf731a3929faca26047b5eab511
|
|
| MD5 |
83baa36faebde728f65f8e0fbda6a640
|
|
| BLAKE2b-256 |
76b71e04cbf239c0c4b2dee1cd9225e6810f425caa7ddd95fb34cad6b2920a39
|