deterministic-scenario-engine 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. deterministic_scenario_engine-1.0.0/LICENSE +201 -0
  2. deterministic_scenario_engine-1.0.0/MANIFEST.in +10 -0
  3. deterministic_scenario_engine-1.0.0/PKG-INFO +146 -0
  4. deterministic_scenario_engine-1.0.0/README.md +115 -0
  5. deterministic_scenario_engine-1.0.0/docs/api.md +153 -0
  6. deterministic_scenario_engine-1.0.0/docs/compatibility.md +91 -0
  7. deterministic_scenario_engine-1.0.0/docs/determinism.md +75 -0
  8. deterministic_scenario_engine-1.0.0/docs/dsl-reference.md +257 -0
  9. deterministic_scenario_engine-1.0.0/docs/hypothesis.md +65 -0
  10. deterministic_scenario_engine-1.0.0/docs/plugins.md +99 -0
  11. deterministic_scenario_engine-1.0.0/docs/quickstart.md +96 -0
  12. deterministic_scenario_engine-1.0.0/docs/reproducibility.md +82 -0
  13. deterministic_scenario_engine-1.0.0/docs/schemathesis.md +85 -0
  14. deterministic_scenario_engine-1.0.0/docs/security-and-non-goals.md +45 -0
  15. deterministic_scenario_engine-1.0.0/docs/sqlalchemy.md +78 -0
  16. deterministic_scenario_engine-1.0.0/docs/testing-oracle.md +82 -0
  17. deterministic_scenario_engine-1.0.0/examples/api_scenario.yaml +40 -0
  18. deterministic_scenario_engine-1.0.0/examples/cart.yaml +94 -0
  19. deterministic_scenario_engine-1.0.0/examples/control_flow.yaml +59 -0
  20. deterministic_scenario_engine-1.0.0/examples/ecommerce.yaml +81 -0
  21. deterministic_scenario_engine-1.0.0/examples/openapi.yaml +32 -0
  22. deterministic_scenario_engine-1.0.0/examples/oracle_fault.yaml +31 -0
  23. deterministic_scenario_engine-1.0.0/examples/phase0_1b_cart.yaml +94 -0
  24. deterministic_scenario_engine-1.0.0/examples/phase0_3_resources.yaml +57 -0
  25. deterministic_scenario_engine-1.0.0/examples/phase0_4_control_flow.yaml +59 -0
  26. deterministic_scenario_engine-1.0.0/examples/phase0_5_oracle_fault.yaml +31 -0
  27. deterministic_scenario_engine-1.0.0/examples/phase0_6_sqlalchemy_rows.yaml +22 -0
  28. deterministic_scenario_engine-1.0.0/examples/phase0_7_ecommerce_plugin.yaml +81 -0
  29. deterministic_scenario_engine-1.0.0/examples/phase0_8_api_scenario.yaml +40 -0
  30. deterministic_scenario_engine-1.0.0/examples/phase0_8_openapi.yaml +32 -0
  31. deterministic_scenario_engine-1.0.0/examples/resources.yaml +57 -0
  32. deterministic_scenario_engine-1.0.0/examples/sqlalchemy_rows.yaml +22 -0
  33. deterministic_scenario_engine-1.0.0/pyproject.toml +46 -0
  34. deterministic_scenario_engine-1.0.0/setup.cfg +4 -0
  35. deterministic_scenario_engine-1.0.0/src/deterministic_scenario_engine.egg-info/PKG-INFO +146 -0
  36. deterministic_scenario_engine-1.0.0/src/deterministic_scenario_engine.egg-info/SOURCES.txt +94 -0
  37. deterministic_scenario_engine-1.0.0/src/deterministic_scenario_engine.egg-info/dependency_links.txt +1 -0
  38. deterministic_scenario_engine-1.0.0/src/deterministic_scenario_engine.egg-info/entry_points.txt +2 -0
  39. deterministic_scenario_engine-1.0.0/src/deterministic_scenario_engine.egg-info/requires.txt +14 -0
  40. deterministic_scenario_engine-1.0.0/src/deterministic_scenario_engine.egg-info/top_level.txt +1 -0
  41. deterministic_scenario_engine-1.0.0/src/scenario_engine/__init__.py +41 -0
  42. deterministic_scenario_engine-1.0.0/src/scenario_engine/_version.py +3 -0
  43. deterministic_scenario_engine-1.0.0/src/scenario_engine/adapters/__init__.py +5 -0
  44. deterministic_scenario_engine-1.0.0/src/scenario_engine/adapters/json_file.py +58 -0
  45. deterministic_scenario_engine-1.0.0/src/scenario_engine/adapters/sqlalchemy.py +207 -0
  46. deterministic_scenario_engine-1.0.0/src/scenario_engine/address.py +37 -0
  47. deterministic_scenario_engine-1.0.0/src/scenario_engine/artifacts.py +16 -0
  48. deterministic_scenario_engine-1.0.0/src/scenario_engine/canonical.py +109 -0
  49. deterministic_scenario_engine-1.0.0/src/scenario_engine/clock.py +22 -0
  50. deterministic_scenario_engine-1.0.0/src/scenario_engine/context.py +25 -0
  51. deterministic_scenario_engine-1.0.0/src/scenario_engine/control_flow.py +63 -0
  52. deterministic_scenario_engine-1.0.0/src/scenario_engine/dsl/__init__.py +31 -0
  53. deterministic_scenario_engine-1.0.0/src/scenario_engine/dsl/compiler.py +232 -0
  54. deterministic_scenario_engine-1.0.0/src/scenario_engine/dsl/errors.py +23 -0
  55. deterministic_scenario_engine-1.0.0/src/scenario_engine/dsl/models.py +74 -0
  56. deterministic_scenario_engine-1.0.0/src/scenario_engine/dsl/parser.py +582 -0
  57. deterministic_scenario_engine-1.0.0/src/scenario_engine/dsl/runtime.py +211 -0
  58. deterministic_scenario_engine-1.0.0/src/scenario_engine/errors.py +13 -0
  59. deterministic_scenario_engine-1.0.0/src/scenario_engine/expressions.py +330 -0
  60. deterministic_scenario_engine-1.0.0/src/scenario_engine/faults.py +36 -0
  61. deterministic_scenario_engine-1.0.0/src/scenario_engine/history.py +38 -0
  62. deterministic_scenario_engine-1.0.0/src/scenario_engine/ids.py +36 -0
  63. deterministic_scenario_engine-1.0.0/src/scenario_engine/integrations/__init__.py +7 -0
  64. deterministic_scenario_engine-1.0.0/src/scenario_engine/integrations/hypothesis.py +103 -0
  65. deterministic_scenario_engine-1.0.0/src/scenario_engine/integrations/schemathesis.py +142 -0
  66. deterministic_scenario_engine-1.0.0/src/scenario_engine/invariants.py +21 -0
  67. deterministic_scenario_engine-1.0.0/src/scenario_engine/manifest.py +102 -0
  68. deterministic_scenario_engine-1.0.0/src/scenario_engine/oracle.py +29 -0
  69. deterministic_scenario_engine-1.0.0/src/scenario_engine/plugins.py +175 -0
  70. deterministic_scenario_engine-1.0.0/src/scenario_engine/provenance.py +27 -0
  71. deterministic_scenario_engine-1.0.0/src/scenario_engine/pytest_plugin.py +95 -0
  72. deterministic_scenario_engine-1.0.0/src/scenario_engine/reference_packs/__init__.py +1 -0
  73. deterministic_scenario_engine-1.0.0/src/scenario_engine/reference_packs/ecommerce.py +57 -0
  74. deterministic_scenario_engine-1.0.0/src/scenario_engine/resources.py +163 -0
  75. deterministic_scenario_engine-1.0.0/src/scenario_engine/result.py +99 -0
  76. deterministic_scenario_engine-1.0.0/src/scenario_engine/rng.py +36 -0
  77. deterministic_scenario_engine-1.0.0/src/scenario_engine/runner.py +103 -0
  78. deterministic_scenario_engine-1.0.0/src/scenario_engine/state.py +39 -0
  79. deterministic_scenario_engine-1.0.0/src/scenario_engine/validation.py +95 -0
  80. deterministic_scenario_engine-1.0.0/src/scenario_engine/values.py +66 -0
  81. deterministic_scenario_engine-1.0.0/tests/test_phase_0_1a_semantic_kernel.py +212 -0
  82. deterministic_scenario_engine-1.0.0/tests/test_phase_0_1b_linear_dsl.py +140 -0
  83. deterministic_scenario_engine-1.0.0/tests/test_phase_0_1c_integrated_phase0_1.py +229 -0
  84. deterministic_scenario_engine-1.0.0/tests/test_phase_0_1c_r1_missing_sentinel_repair.py +68 -0
  85. deterministic_scenario_engine-1.0.0/tests/test_phase_0_2a_reproducible_results.py +193 -0
  86. deterministic_scenario_engine-1.0.0/tests/test_phase_0_2b_json_pytest_integration.py +218 -0
  87. deterministic_scenario_engine-1.0.0/tests/test_phase_0_3_resources_constraints.py +151 -0
  88. deterministic_scenario_engine-1.0.0/tests/test_phase_0_4_control_flow.py +181 -0
  89. deterministic_scenario_engine-1.0.0/tests/test_phase_0_5_oracle_faults.py +91 -0
  90. deterministic_scenario_engine-1.0.0/tests/test_phase_0_6_sqlalchemy_materializer.py +211 -0
  91. deterministic_scenario_engine-1.0.0/tests/test_phase_0_7_plugins_ecommerce.py +203 -0
  92. deterministic_scenario_engine-1.0.0/tests/test_phase_0_8_hypothesis_schemathesis.py +159 -0
  93. deterministic_scenario_engine-1.0.0/tests/test_phase_1_0b_public_api_error_contract.py +175 -0
  94. deterministic_scenario_engine-1.0.0/tests/test_phase_1_0c_dsl_compatibility_contract.py +182 -0
  95. deterministic_scenario_engine-1.0.0/tests/test_phase_1_0d_documentation_examples.py +137 -0
  96. deterministic_scenario_engine-1.0.0/tests/test_phase_1_0e_packaging_release_candidate.py +147 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,10 @@
1
+ include LICENSE
2
+ include README.md
3
+ include pyproject.toml
4
+ recursive-include src *.py
5
+ recursive-include docs *.md
6
+ recursive-include examples *.yaml
7
+ recursive-include tests *.py
8
+ global-exclude *.py[cod]
9
+ global-exclude __pycache__
10
+ global-exclude .DS_Store
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: deterministic-scenario-engine
3
+ Version: 1.0.0
4
+ Summary: Reproducible, state-consistent business scenarios with deterministic ground truth
5
+ License-Expression: Apache-2.0
6
+ Keywords: deterministic,scenario,testing,fixtures,replay
7
+ Classifier: Development Status :: 5 - Production/Stable
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Classifier: Topic :: Software Development :: Testing
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: PyYAML==6.0.3
21
+ Provides-Extra: pytest
22
+ Requires-Dist: pytest<10,>=9.1; extra == "pytest"
23
+ Provides-Extra: sqlalchemy
24
+ Requires-Dist: SQLAlchemy<3,>=2.0; extra == "sqlalchemy"
25
+ Provides-Extra: hypothesis
26
+ Requires-Dist: hypothesis<7,>=6; extra == "hypothesis"
27
+ Provides-Extra: schemathesis
28
+ Requires-Dist: hypothesis<7,>=6; extra == "schemathesis"
29
+ Requires-Dist: schemathesis<5,>=4; extra == "schemathesis"
30
+ Dynamic: license-file
31
+
32
+ # Deterministic Scenario Engine
33
+
34
+ **Generate test scenarios, not just test records.**
35
+
36
+ Deterministic Scenario Engine creates reproducible, state-consistent business
37
+ histories with deterministic ground truth for testing.
38
+
39
+ ## Why it exists
40
+
41
+ Fake-data libraries and random record generators produce values; fixtures often
42
+ describe isolated records. Scenario Engine executes histories: each committed
43
+ step sees a consistent state, produces traceable state changes and artifacts,
44
+ and advances an explicit logical clock. The same scenario and execution context
45
+ can be replayed byte-for-byte, while invariants, controlled faults, and an oracle
46
+ make expected behavior explicit.
47
+
48
+ ## Core capabilities
49
+
50
+ - DSL 1 parsing, compilation, and deterministic execution
51
+ - addressed randomness and logical IDs that do not depend on a shared stream
52
+ - current state plus append-only committed history and artifacts
53
+ - whole-step atomicity
54
+ - explicit external inputs, resource DAG resolution, validators, and constraints
55
+ - subflows, ordered branches, and bounded repeat
56
+ - invariants, deterministic fault injection, provenance, and oracle evaluation
57
+ - canonical result bytes and a `ReproducibilityManifest` for exact replay
58
+ - an explicit, versioned plugin boundary and a reference ecommerce plugin pack
59
+ - a JSON-file adapter
60
+ - optional pytest, SQLAlchemy Core, Hypothesis, and Schemathesis integrations
61
+
62
+ Core execution does not require a database, network service, plugin, or property
63
+ testing framework. See [security assumptions and non-goals](docs/security-and-non-goals.md).
64
+
65
+ ## Installation
66
+
67
+ From a source checkout, use a virtual environment and install the checkout:
68
+
69
+ ```console
70
+ python3 -m venv /tmp/scenario-engine-docs-venv
71
+ /tmp/scenario-engine-docs-venv/bin/python -m pip install .
72
+ ```
73
+
74
+ Install only the named optional integrations you need:
75
+
76
+ ```console
77
+ /tmp/scenario-engine-docs-venv/bin/python -m pip install '.[pytest]'
78
+ /tmp/scenario-engine-docs-venv/bin/python -m pip install '.[sqlalchemy]'
79
+ /tmp/scenario-engine-docs-venv/bin/python -m pip install '.[hypothesis]'
80
+ /tmp/scenario-engine-docs-venv/bin/python -m pip install '.[schemathesis]'
81
+ ```
82
+
83
+ The distribution is `deterministic-scenario-engine` 1.0.0. Install the package
84
+ with `pip install deterministic-scenario-engine`, or select an optional integration
85
+ with a command such as `pip install 'deterministic-scenario-engine[pytest]'`.
86
+
87
+ ## Minimal quickstart
88
+
89
+ The public [cart scenario](examples/cart.yaml) is an executable DSL 1 document.
90
+ Run it from the repository root:
91
+
92
+ ```python
93
+ from pathlib import Path
94
+
95
+ from scenario_engine import (
96
+ compile_document,
97
+ parse_yaml,
98
+ replay_scenario,
99
+ run_scenario,
100
+ )
101
+
102
+ yaml_text = Path("examples/cart.yaml").read_text(encoding="utf-8")
103
+ document = parse_yaml(yaml_text)
104
+ scenario = compile_document(document)
105
+ result = run_scenario(scenario, root_seed="quickstart", run_index=0)
106
+
107
+ print(result.final_state["checkout_complete"])
108
+ print(result.trace())
109
+ stable_bytes = result.to_json_bytes()
110
+ manifest = result.manifest
111
+
112
+ replayed = replay_scenario(yaml_text, manifest)
113
+ assert replayed.to_json_bytes() == stable_bytes
114
+ ```
115
+
116
+ `ScenarioResult.final_state` is the supported state-reading property; the stable
117
+ normalized result contains the same data under its `state` field.
118
+
119
+ ## Determinism contract
120
+
121
+ Generation derives from semantic `ExecutionAddress` values, not consumption of
122
+ a mutable global random stream. Exact replay requires the same canonical
123
+ scenario, explicit inputs, algorithms/plugins, and recorded execution context.
124
+ Unsupported cross-version replay fails explicitly. See the [determinism model](docs/determinism.md),
125
+ [reproducibility guide](docs/reproducibility.md), and normative
126
+ [compatibility contract](docs/compatibility.md).
127
+
128
+ ## Documentation
129
+
130
+ - [Quickstart](docs/quickstart.md)
131
+ - [DSL 1 reference](docs/dsl-reference.md)
132
+ - [Determinism model](docs/determinism.md)
133
+ - [Reproducibility and replay](docs/reproducibility.md)
134
+ - [Testing, faults, and oracle](docs/testing-oracle.md)
135
+ - [Plugins](docs/plugins.md)
136
+ - [SQLAlchemy adapter](docs/sqlalchemy.md)
137
+ - [Hypothesis integration](docs/hypothesis.md)
138
+ - [Schemathesis integration](docs/schemathesis.md)
139
+ - [Public Python API](docs/api.md)
140
+ - [Security assumptions and non-goals](docs/security-and-non-goals.md)
141
+ - [Compatibility contract](docs/compatibility.md)
142
+
143
+ ## Status
144
+
145
+ The distribution and engine compatibility version are both 1.0.0. The project is
146
+ licensed under Apache-2.0.
@@ -0,0 +1,115 @@
1
+ # Deterministic Scenario Engine
2
+
3
+ **Generate test scenarios, not just test records.**
4
+
5
+ Deterministic Scenario Engine creates reproducible, state-consistent business
6
+ histories with deterministic ground truth for testing.
7
+
8
+ ## Why it exists
9
+
10
+ Fake-data libraries and random record generators produce values; fixtures often
11
+ describe isolated records. Scenario Engine executes histories: each committed
12
+ step sees a consistent state, produces traceable state changes and artifacts,
13
+ and advances an explicit logical clock. The same scenario and execution context
14
+ can be replayed byte-for-byte, while invariants, controlled faults, and an oracle
15
+ make expected behavior explicit.
16
+
17
+ ## Core capabilities
18
+
19
+ - DSL 1 parsing, compilation, and deterministic execution
20
+ - addressed randomness and logical IDs that do not depend on a shared stream
21
+ - current state plus append-only committed history and artifacts
22
+ - whole-step atomicity
23
+ - explicit external inputs, resource DAG resolution, validators, and constraints
24
+ - subflows, ordered branches, and bounded repeat
25
+ - invariants, deterministic fault injection, provenance, and oracle evaluation
26
+ - canonical result bytes and a `ReproducibilityManifest` for exact replay
27
+ - an explicit, versioned plugin boundary and a reference ecommerce plugin pack
28
+ - a JSON-file adapter
29
+ - optional pytest, SQLAlchemy Core, Hypothesis, and Schemathesis integrations
30
+
31
+ Core execution does not require a database, network service, plugin, or property
32
+ testing framework. See [security assumptions and non-goals](docs/security-and-non-goals.md).
33
+
34
+ ## Installation
35
+
36
+ From a source checkout, use a virtual environment and install the checkout:
37
+
38
+ ```console
39
+ python3 -m venv /tmp/scenario-engine-docs-venv
40
+ /tmp/scenario-engine-docs-venv/bin/python -m pip install .
41
+ ```
42
+
43
+ Install only the named optional integrations you need:
44
+
45
+ ```console
46
+ /tmp/scenario-engine-docs-venv/bin/python -m pip install '.[pytest]'
47
+ /tmp/scenario-engine-docs-venv/bin/python -m pip install '.[sqlalchemy]'
48
+ /tmp/scenario-engine-docs-venv/bin/python -m pip install '.[hypothesis]'
49
+ /tmp/scenario-engine-docs-venv/bin/python -m pip install '.[schemathesis]'
50
+ ```
51
+
52
+ The distribution is `deterministic-scenario-engine` 1.0.0. Install the package
53
+ with `pip install deterministic-scenario-engine`, or select an optional integration
54
+ with a command such as `pip install 'deterministic-scenario-engine[pytest]'`.
55
+
56
+ ## Minimal quickstart
57
+
58
+ The public [cart scenario](examples/cart.yaml) is an executable DSL 1 document.
59
+ Run it from the repository root:
60
+
61
+ ```python
62
+ from pathlib import Path
63
+
64
+ from scenario_engine import (
65
+ compile_document,
66
+ parse_yaml,
67
+ replay_scenario,
68
+ run_scenario,
69
+ )
70
+
71
+ yaml_text = Path("examples/cart.yaml").read_text(encoding="utf-8")
72
+ document = parse_yaml(yaml_text)
73
+ scenario = compile_document(document)
74
+ result = run_scenario(scenario, root_seed="quickstart", run_index=0)
75
+
76
+ print(result.final_state["checkout_complete"])
77
+ print(result.trace())
78
+ stable_bytes = result.to_json_bytes()
79
+ manifest = result.manifest
80
+
81
+ replayed = replay_scenario(yaml_text, manifest)
82
+ assert replayed.to_json_bytes() == stable_bytes
83
+ ```
84
+
85
+ `ScenarioResult.final_state` is the supported state-reading property; the stable
86
+ normalized result contains the same data under its `state` field.
87
+
88
+ ## Determinism contract
89
+
90
+ Generation derives from semantic `ExecutionAddress` values, not consumption of
91
+ a mutable global random stream. Exact replay requires the same canonical
92
+ scenario, explicit inputs, algorithms/plugins, and recorded execution context.
93
+ Unsupported cross-version replay fails explicitly. See the [determinism model](docs/determinism.md),
94
+ [reproducibility guide](docs/reproducibility.md), and normative
95
+ [compatibility contract](docs/compatibility.md).
96
+
97
+ ## Documentation
98
+
99
+ - [Quickstart](docs/quickstart.md)
100
+ - [DSL 1 reference](docs/dsl-reference.md)
101
+ - [Determinism model](docs/determinism.md)
102
+ - [Reproducibility and replay](docs/reproducibility.md)
103
+ - [Testing, faults, and oracle](docs/testing-oracle.md)
104
+ - [Plugins](docs/plugins.md)
105
+ - [SQLAlchemy adapter](docs/sqlalchemy.md)
106
+ - [Hypothesis integration](docs/hypothesis.md)
107
+ - [Schemathesis integration](docs/schemathesis.md)
108
+ - [Public Python API](docs/api.md)
109
+ - [Security assumptions and non-goals](docs/security-and-non-goals.md)
110
+ - [Compatibility contract](docs/compatibility.md)
111
+
112
+ ## Status
113
+
114
+ The distribution and engine compatibility version are both 1.0.0. The project is
115
+ licensed under Apache-2.0.
@@ -0,0 +1,153 @@
1
+ # Public Python API
2
+
3
+ This is the canonical top-level Phase 1.0 contract. Importable implementation
4
+ symbols not listed here are not implicitly promoted to top-level public API.
5
+
6
+ ## Constants and value objects
7
+
8
+ - `ENGINE_VERSION` — engine compatibility version recorded in manifests; for
9
+ the 1.0 release candidate it intentionally equals distribution version 1.0.0.
10
+ - `MISSING` — singleton semantic missing value, distinct from null.
11
+ - `LogicalID(value: str)` — deterministic logical identifier value; users
12
+ normally receive it from `$id` generation.
13
+ - `ExecutionAddress(scenario_id: str, run_index: int = 0,
14
+ subflow_invocations: tuple[int, ...] = (), repetition_indexes: tuple[int, ...]
15
+ = (), step_id: str | None = None, semantic_path: tuple[str, ...] = ())` — users
16
+ normally inspect plugin context addresses rather than constructing execution.
17
+ - `ScenarioResult(scenario_id: str, runner: ScenarioRunner,
18
+ manifest: ReproducibilityManifest, resources: Any = None, provenance: Any =
19
+ None)` — returned by execution; direct construction depends on nonpublic
20
+ kernel objects and is not the normal user path.
21
+ - `ReproducibilityManifest(root_seed: str | int,
22
+ scenario_canonical_hash: str, engine_version: str, dsl_version: int,
23
+ input_resource_hashes: Mapping[str, str] = {}, domain_pack_versions:
24
+ Mapping[str, str] = {}, generator_versions: Mapping[str, str] = {},
25
+ rng_algorithm_version: str = "scenario-engine-addressed-v1",
26
+ id_algorithm_version: str = "scenario-engine-id-v1", locale: str = "C",
27
+ reference_clock_start: datetime | None = None, run_index: int = 0)` — normally
28
+ received as `ScenarioResult.manifest`; construction is useful for persistence
29
+ readers/tests only when every frozen field is preserved.
30
+ - `GeneratorPlugin(name: str, version: str, generate: PluginCallable)` — explicit
31
+ deterministic generator definition.
32
+ - `PluginRegistry(plugins: Iterable[GeneratorPlugin] = ())` — immutable explicit
33
+ registry.
34
+ - `PluginGenerationContext(rng: DeterministicRNG, clock: LogicalClock,
35
+ ids: DeterministicIDProvider, address: ExecutionAddress)` — normally received
36
+ by a plugin callable.
37
+
38
+ The named kernel types in annotations above are not thereby top-level exports.
39
+
40
+ ## Parsing, compilation, execution, and replay
41
+
42
+ ```python
43
+ parse_yaml(text: str) -> ScenarioDocument
44
+ parse_yaml_file(path: str | Path) -> ScenarioDocument
45
+ compile_document(document: ScenarioDocument, resources=None, plugins=None, state=None) -> CompiledScenario
46
+ run_scenario(scenario: CompiledScenario, root_seed, run_index=0, locale="C", inputs=None, plugins=None)
47
+ replay_scenario(yaml_text, manifest, *, inputs=None, plugins=None)
48
+ evaluate_scenario(scenario: CompiledScenario, root_seed, run_index=0, locale="C", inputs=None, raise_on_mismatch=False, plugins=None)
49
+ ```
50
+
51
+ `parse_yaml_file()` reads UTF-8. `compile_document()` normally receives only a
52
+ parsed document; its other arguments support established integration/runtime
53
+ paths. `run_scenario()` returns `ScenarioResult`. `replay_scenario()` parses and
54
+ checks recorded compatibility before returning a replayed `ScenarioResult`.
55
+ `evaluate_scenario()` returns `OracleEvaluation` and optionally raises on an
56
+ oracle mismatch.
57
+
58
+ ## Canonical scenario functions
59
+
60
+ ```python
61
+ canonical_scenario_payload(scenario: str | ScenarioDocument | CompiledScenario) -> Mapping[str, Any]
62
+ canonical_scenario_bytes(scenario: str | ScenarioDocument | CompiledScenario) -> bytes
63
+ canonical_scenario_hash(scenario: str | ScenarioDocument | CompiledScenario) -> str
64
+ ```
65
+
66
+ These normalize a YAML string, parsed document, or compiled scenario to the
67
+ canonical semantic scenario payload, bytes, or SHA-256 hash.
68
+
69
+ ## Public error categories
70
+
71
+ All canonical errors derive from `ScenarioEngineError` and retain value-error
72
+ compatibility:
73
+
74
+ - `ScenarioEngineError`
75
+ - `DSLError`
76
+ - `DSLParseError`
77
+ - `DSLSchemaError`
78
+ - `DSLCompilationError`
79
+ - `ExpressionEvaluationError`
80
+ - `ResourceError`
81
+ - `ResourceValidationError`
82
+ - `ConstraintError`
83
+ - `ControlFlowError`
84
+ - `InvariantError`
85
+ - `FaultError`
86
+ - `OracleError`
87
+ - `ReplayCompatibilityError`
88
+ - `PluginError`
89
+
90
+ Catch the narrowest useful category. Stable submodule families include more
91
+ specific diagnostic classes without adding them to the canonical top level.
92
+
93
+ ## Exact canonical top-level names
94
+
95
+ The set and order are:
96
+
97
+ ```text
98
+ ENGINE_VERSION
99
+ MISSING
100
+ LogicalID
101
+ ExecutionAddress
102
+ ScenarioResult
103
+ ReproducibilityManifest
104
+ parse_yaml
105
+ parse_yaml_file
106
+ compile_document
107
+ run_scenario
108
+ replay_scenario
109
+ evaluate_scenario
110
+ canonical_scenario_payload
111
+ canonical_scenario_bytes
112
+ canonical_scenario_hash
113
+ GeneratorPlugin
114
+ PluginRegistry
115
+ PluginGenerationContext
116
+ ScenarioEngineError
117
+ DSLError
118
+ DSLParseError
119
+ DSLSchemaError
120
+ DSLCompilationError
121
+ ExpressionEvaluationError
122
+ ResourceError
123
+ ResourceValidationError
124
+ ConstraintError
125
+ ControlFlowError
126
+ InvariantError
127
+ FaultError
128
+ OracleError
129
+ ReplayCompatibilityError
130
+ PluginError
131
+ ```
132
+
133
+ ## Supported optional submodules
134
+
135
+ These are explicitly separate from the top-level contract:
136
+
137
+ - `scenario_engine.adapters.sqlalchemy`: `SqlAlchemyRowCommand`,
138
+ `MaterializationReport`, `extract_row_commands`, `prepare_row_commands`,
139
+ `command_fingerprint`, `materialize_result`, and its adapter errors; see
140
+ [SQLAlchemy](sqlalchemy.md).
141
+ - `scenario_engine.integrations.hypothesis`: `ScenarioHypothesisCase`,
142
+ `scenario_cases`, and `HypothesisIntegrationError`; see
143
+ [Hypothesis](hypothesis.md).
144
+ - `scenario_engine.integrations.schemathesis`: `SchemathesisCaseBindings`,
145
+ `BoundSchemathesisCase`, `bind_case`, `operation_cases`, and integration errors;
146
+ see [Schemathesis](schemathesis.md).
147
+ - `scenario_engine.pytest_plugin`: pytest fixture/marker integration when the
148
+ `pytest` extra is installed.
149
+ - `scenario_engine.reference_packs.ecommerce`: `ecommerce_registry()` reference
150
+ factory; see [plugins](plugins.md).
151
+
152
+ Internal dataclass field layouts beyond frozen normalized result/manifest schemas
153
+ are not promised. See [compatibility](compatibility.md).