@cratis/pi 7.6.5 → 7.7.0

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 (212) hide show
  1. package/package/corpus/agents/backend-developer.md +14 -0
  2. package/package/corpus/agents/code-reviewer.md +16 -0
  3. package/package/corpus/agents/coordinator.md +17 -0
  4. package/package/corpus/agents/frontend-developer.md +17 -0
  5. package/package/corpus/agents/orchestrator.md +18 -0
  6. package/package/corpus/agents/planner.md +24 -0
  7. package/package/corpus/agents/screenplay-modeler.md +57 -0
  8. package/package/corpus/agents/screenplay-renderer.md +42 -0
  9. package/package/corpus/agents/screenplay-reviewer.md +45 -0
  10. package/package/corpus/agents/slice-implementer.md +32 -5
  11. package/package/corpus/agents/spec-writer.md +16 -3
  12. package/package/corpus/prompts/add-reactor.prompt.md +5 -3
  13. package/package/corpus/prompts/new-vertical-slice.prompt.md +16 -5
  14. package/package/corpus/prompts/write-specs.prompt.md +12 -6
  15. package/package/corpus/rules/application-profile.md +7 -3
  16. package/package/corpus/rules/general.md +8 -3
  17. package/package/corpus/rules/glossary.md +1 -1
  18. package/package/corpus/rules/profiles.md +42 -4
  19. package/package/corpus/rules/reactors.md +30 -22
  20. package/package/corpus/rules/vertical-slices.md +3 -1
  21. package/package/corpus/skills/cratis-application-react-specifications/SKILL.md +13 -0
  22. package/package/corpus/skills/cratis-application-slice-conformance/LICENSE +2 -0
  23. package/package/corpus/skills/cratis-application-slice-conformance/SKILL.md +173 -0
  24. package/package/corpus/skills/cratis-application-slice-conformance/references/checklists.md +66 -0
  25. package/package/corpus/skills/cratis-application-slice-conformance/references/contract-and-precedence.md +49 -0
  26. package/package/corpus/skills/cratis-application-slice-conformance/references/provenance.md +23 -0
  27. package/package/corpus/skills/cratis-application-slice-conformance/references/worked-example.md +91 -0
  28. package/package/corpus/skills/cratis-application-slice-conformance/verification.json +14 -0
  29. package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +57 -1
  30. package/package/corpus/skills/cratis-application-slice-specifications/references/provenance.md +16 -0
  31. package/package/corpus/skills/cratis-arc-command/SKILL.md +10 -0
  32. package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +10 -0
  33. package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +10 -0
  34. package/package/corpus/skills/cratis-arc-observable-query-http/SKILL.md +10 -0
  35. package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +10 -0
  36. package/package/corpus/skills/cratis-arc-react-page/SKILL.md +68 -8
  37. package/package/corpus/skills/cratis-arc-react-page/references/from-screenplay.md +199 -0
  38. package/package/corpus/skills/cratis-arc-react-page/references/provenance.md +13 -0
  39. package/package/corpus/skills/cratis-chronicle-event-constraints/SKILL.md +10 -0
  40. package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +38 -10
  41. package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +13 -0
  42. package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +13 -0
  43. package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +58 -6
  44. package/package/corpus/skills/cratis-chronicle-reactor/references/provenance.md +9 -0
  45. package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +13 -0
  46. package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +47 -0
  47. package/package/corpus/skills/cratis-chronicle-read-model-specifications/references/provenance.md +11 -0
  48. package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +13 -0
  49. package/package/corpus/skills/cratis-components-stepper-command-dialog/SKILL.md +13 -0
  50. package/package/corpus/skills/cratis-event-model-diagram/SKILL.md +35 -16
  51. package/package/corpus/skills/cratis-screenplay-automations-and-translations/LICENSE +28 -0
  52. package/package/corpus/skills/cratis-screenplay-automations-and-translations/SKILL.md +166 -0
  53. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/audit-format.md +31 -0
  54. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/automation-patterns.md +139 -0
  55. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/cases-to-specify.md +69 -0
  56. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/effects-and-idempotency.md +88 -0
  57. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/integration-contracts.md +64 -0
  58. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/provenance.md +37 -0
  59. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/realization-and-gap-fill.md +34 -0
  60. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/todo-list-example.md +208 -0
  61. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/translate-example.md +126 -0
  62. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/translation-patterns.md +93 -0
  63. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/worked-integration.md +98 -0
  64. package/package/corpus/skills/cratis-screenplay-automations-and-translations/verification.json +15 -0
  65. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +267 -50
  66. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/complete-examples.md +185 -0
  67. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/verification.json +60 -12
  68. package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +42 -12
  69. package/package/corpus/skills/cratis-screenplay-discovery/LICENSE +30 -0
  70. package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +229 -0
  71. package/package/corpus/skills/cratis-screenplay-discovery/references/divergent-sweep.md +37 -0
  72. package/package/corpus/skills/cratis-screenplay-discovery/references/event-naming.md +64 -0
  73. package/package/corpus/skills/cratis-screenplay-discovery/references/facilitation.md +62 -0
  74. package/package/corpus/skills/cratis-screenplay-discovery/references/human-workshop.md +222 -0
  75. package/package/corpus/skills/cratis-screenplay-discovery/references/interview-questions.md +66 -0
  76. package/package/corpus/skills/cratis-screenplay-discovery/references/personas-and-causes.md +152 -0
  77. package/package/corpus/skills/cratis-screenplay-discovery/references/plotting-and-handoff.md +111 -0
  78. package/package/corpus/skills/cratis-screenplay-discovery/references/provenance.md +37 -0
  79. package/package/corpus/skills/cratis-screenplay-discovery/references/storming-loop.md +119 -0
  80. package/package/corpus/skills/cratis-screenplay-discovery/references/worked-session.md +87 -0
  81. package/package/corpus/skills/cratis-screenplay-discovery/verification.json +15 -0
  82. package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +140 -77
  83. package/package/corpus/skills/cratis-screenplay-event-modeling/references/invoicing-example.md +51 -0
  84. package/package/corpus/skills/cratis-screenplay-event-modeling/references/nine-steps.md +114 -28
  85. package/package/corpus/skills/cratis-screenplay-event-modeling/references/parsed-not-runnable.md +50 -0
  86. package/package/corpus/skills/cratis-screenplay-event-modeling/verification.json +28 -3
  87. package/package/corpus/skills/cratis-screenplay-legacy-extraction/LICENSE +31 -0
  88. package/package/corpus/skills/cratis-screenplay-legacy-extraction/SKILL.md +239 -0
  89. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/chronicle-observations.md +25 -0
  90. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/evidence-table-template.md +79 -0
  91. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/expert-verification.md +48 -0
  92. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/generate-notes.md +75 -0
  93. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/intent-example.md +164 -0
  94. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/interview-findings.md +88 -0
  95. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/loss-report-template.md +47 -0
  96. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/prologue-safety.md +147 -0
  97. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/provenance.md +10 -0
  98. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/rule-modeling.md +36 -0
  99. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/side-car-migration.md +126 -0
  100. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/signal-to-intent.md +57 -0
  101. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/ui-observation.md +52 -0
  102. package/package/corpus/skills/cratis-screenplay-legacy-extraction/verification.json +17 -0
  103. package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +77 -57
  104. package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +50 -20
  105. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-loop.md +211 -0
  106. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-tools.md +44 -6
  107. package/package/corpus/skills/cratis-screenplay-model-authoring/references/provenance.md +13 -0
  108. package/package/corpus/skills/cratis-screenplay-model-authoring/verification.json +64 -10
  109. package/package/corpus/skills/cratis-screenplay-model-review/LICENSE +34 -0
  110. package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +209 -0
  111. package/package/corpus/skills/cratis-screenplay-model-review/references/anti-patterns.md +89 -0
  112. package/package/corpus/skills/cratis-screenplay-model-review/references/business-questions.md +128 -0
  113. package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +176 -0
  114. package/package/corpus/skills/cratis-screenplay-model-review/references/provenance.md +36 -0
  115. package/package/corpus/skills/cratis-screenplay-model-review/references/report-template.md +149 -0
  116. package/package/corpus/skills/cratis-screenplay-model-review/references/review-questions.md +59 -0
  117. package/package/corpus/skills/cratis-screenplay-model-review/references/worked-example.md +255 -0
  118. package/package/corpus/skills/cratis-screenplay-model-review/verification.json +13 -0
  119. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/LICENSE +32 -0
  120. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +239 -0
  121. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/code-reading-and-tokens.md +55 -0
  122. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/handoff-template.md +124 -0
  123. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/identity-and-edits.md +84 -0
  124. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/opt-in.md +48 -0
  125. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phase-report-inventories.md +25 -0
  126. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +162 -0
  127. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/principles.md +53 -0
  128. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/provenance.md +63 -0
  129. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/reasoning-notes.md +31 -0
  130. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/safety.md +31 -0
  131. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/stop-or-assume.md +46 -0
  132. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/verdicts-and-modes.md +204 -0
  133. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/vocabulary-map.md +55 -0
  134. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/worked-example.md +86 -0
  135. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/verification.json +16 -0
  136. package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +14 -3
  137. package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +15 -1
  138. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/LICENSE +2 -0
  139. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +179 -0
  140. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/delivery-protocol.md +99 -0
  141. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/drift-and-ledger.md +67 -0
  142. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/gap-fill-handoff.md +72 -0
  143. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/provenance.md +27 -0
  144. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/renderability-gate.md +56 -0
  145. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/worked-example.md +124 -0
  146. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/verification.json +14 -0
  147. package/package/corpus/skills/cratis-screenplay-scenario-coverage/LICENSE +31 -0
  148. package/package/corpus/skills/cratis-screenplay-scenario-coverage/SKILL.md +200 -0
  149. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/berth-reservations.md +579 -0
  150. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/chronicle-verification.md +24 -0
  151. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/coverage-matrix.md +102 -0
  152. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/provenance.md +41 -0
  153. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md +196 -0
  154. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-workshop.md +102 -0
  155. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/spec-forms-by-mode.md +71 -0
  156. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/view-and-story-specs.md +91 -0
  157. package/package/corpus/skills/cratis-screenplay-scenario-coverage/verification.json +13 -0
  158. package/package/corpus/skills/cratis-screenplay-slice-design/LICENSE +30 -0
  159. package/package/corpus/skills/cratis-screenplay-slice-design/SKILL.md +236 -0
  160. package/package/corpus/skills/cratis-screenplay-slice-design/references/command-inventory.md +107 -0
  161. package/package/corpus/skills/cratis-screenplay-slice-design/references/field-lineage.md +130 -0
  162. package/package/corpus/skills/cratis-screenplay-slice-design/references/provenance.md +20 -0
  163. package/package/corpus/skills/cratis-screenplay-slice-design/references/read-model-design.md +201 -0
  164. package/package/corpus/skills/cratis-screenplay-slice-design/references/review-questions.md +23 -0
  165. package/package/corpus/skills/cratis-screenplay-slice-design/references/rule-layers.md +41 -0
  166. package/package/corpus/skills/cratis-screenplay-slice-design/references/slicing.md +122 -0
  167. package/package/corpus/skills/cratis-screenplay-slice-design/references/worked-example.md +305 -0
  168. package/package/corpus/skills/cratis-screenplay-slice-design/verification.json +43 -0
  169. package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +217 -36
  170. package/package/corpus/skills/cratis-screenplay-specifications/verification.json +28 -4
  171. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/LICENSE +33 -0
  172. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/SKILL.md +191 -0
  173. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/boundaries.md +154 -0
  174. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/chronicle-boundaries.md +54 -0
  175. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/consistency-and-concurrency.md +191 -0
  176. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/evolution-example.md +70 -0
  177. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/evolution.md +65 -0
  178. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/provenance.md +13 -0
  179. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/stream-patterns.md +128 -0
  180. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/streams-example.md +378 -0
  181. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/verification.json +14 -0
  182. package/package/corpus/skills/cratis-screenplay-toolchain/LICENSE +2 -0
  183. package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +177 -0
  184. package/package/corpus/skills/cratis-screenplay-toolchain/references/automation-translate-example.md +121 -0
  185. package/package/corpus/skills/cratis-screenplay-toolchain/references/cheat-sheet-example.md +319 -0
  186. package/package/corpus/skills/cratis-screenplay-toolchain/references/cheat-sheet.md +96 -0
  187. package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +107 -0
  188. package/package/corpus/skills/cratis-screenplay-toolchain/references/doc-contradictions.md +48 -0
  189. package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-example.md +113 -0
  190. package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +148 -0
  191. package/package/corpus/skills/cratis-screenplay-toolchain/references/pdl-example.md +267 -0
  192. package/package/corpus/skills/cratis-screenplay-toolchain/references/provenance.md +51 -0
  193. package/package/corpus/skills/cratis-screenplay-toolchain/references/renderable-subset.md +88 -0
  194. package/package/corpus/skills/cratis-screenplay-toolchain/references/traps.md +51 -0
  195. package/package/corpus/skills/cratis-screenplay-toolchain/references/verdicts.md +134 -0
  196. package/package/corpus/skills/cratis-screenplay-toolchain/references/versions.md +134 -0
  197. package/package/corpus/skills/cratis-screenplay-toolchain/verification.json +15 -0
  198. package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +53 -5
  199. package/package/corpus/skills/cratis-screenplay-ui-composition/references/flow-review.md +56 -0
  200. package/package/corpus/skills/cratis-screenplay-ui-composition/references/provenance.md +13 -0
  201. package/package/corpus/skills/cratis-screenplay-ui-composition/references/worked-flow.md +65 -0
  202. package/package/corpus/skills/cratis-screenplay-ui-composition/verification.json +4 -1
  203. package/package/corpus/skills/cratis-specification-by-example/SKILL.md +44 -1
  204. package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +10 -0
  205. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +186 -219
  206. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/admission.md +177 -0
  207. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/render-example.md +150 -0
  208. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/rendered-application.md +87 -0
  209. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/sandbox-and-specrunner.md +98 -0
  210. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/verification.json +19 -0
  211. package/package/profile-catalog.json +11 -0
  212. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: cratis-event-model-diagram
3
- description: Create and maintain Mermaid eventmodeling diagrams for a Cratis module or feature, and keep them in sync with the code. Use when adding, renaming, moving, or deleting a module, feature, behavior, command, event, read model, automation, translation, or cross-module flow. Do not use to decide the event vocabulary or stream boundaries - settle the model first, then render it here.
3
+ description: Create and maintain Mermaid eventmodeling diagrams for a Cratis module or feature, and keep them in sync with their authority (the accepted `.play` model where one covers the scope, otherwise the code). Use when adding, renaming, moving, or deleting a module, feature, behavior, command, event, read model, automation, translation, or cross-module flow. Do not use to decide the event vocabulary or stream boundaries - settle the model first, then render it here.
4
4
  license: MIT
5
5
  ---
6
6
 
@@ -73,22 +73,30 @@ tf 03 evt <EntityName><PastTenseVerb>
73
73
  rf 04 rmo <ReadModelName> ->> 03
74
74
  tf 05 ui <Persona>
75
75
 
76
- %% -- Automation: <ReactorName> (external side effect only) --
76
+ %% -- Automation: <ReactorName> (reacts to our own event) --
77
77
  rf 06 evt <EntityName><PastTenseVerb>
78
78
  tf 07 pcr <ReactorName>
79
-
80
- %% -- Translation: <Source>.<Event> -> <Target>.<Reactor> --
81
- rf 08 evt <SourceModule>.<EventName>
82
- tf 09 pcr <TargetModule>.<ReactorName>
83
- tf 10 evt <TargetModule>.<EventName>
79
+ %% add the next two frames only when the automation invokes a command
80
+ tf 08 cmd <CommandName>
81
+ tf 09 evt <EntityName><PastTenseVerb>
82
+
83
+ %% -- Translation: <Outside>.<Fact> -> <Adapter> -> our event --
84
+ rf 10 evt <ExternalSource>.<FactName>
85
+ tf 11 pcr <AdapterName>
86
+ tf 12 evt <EntityName><PastTenseVerb>
84
87
  ```
85
88
 
86
89
  - A state view's `rmo` references the event frames it projects from by number;
87
90
  its consumer `ui` frame auto-chains after it. A passive read model has no
88
91
  consumer UI — emit only the `rmo ... ->>` line with a `%% passive` comment.
89
- - Translation flows are reactor-only: `evt` to `pcr` to `evt`, with no
90
- intermediate `cmd`. If you draw a `cmd` between the `pcr` and the resulting
91
- event, it is an **automation**, not a translation — reclassify it.
92
+ - One definition of Translation everywhere: data from **outside** our own facts
93
+ becomes our own facts. Its flow starts at an outside-origin `evt` (an
94
+ `<ExternalSource>.` prefix marks it), passes through the adapter `pcr`, and
95
+ ends at an event we own. A `pcr` that reacts to **our own** event is an
96
+ **automation**, whether it causes an external side effect, appends a
97
+ follow-up event, or invokes a command (then draw the `cmd` and its resulting
98
+ `evt` after the `pcr`). Classify by where the data comes from, not by how the
99
+ reactor is built.
92
100
  - Several consumers of one read model: declare each consumer `ui` as its own
93
101
  `rf` frame with an explicit `->>` back to the `rmo`.
94
102
 
@@ -105,17 +113,25 @@ language. Include commands that emit no event.
105
113
  1. **Discover** the behaviors by scanning the module for the artifacts that
106
114
  define them: command records for state changes, read models without a command
107
115
  handler for state views, `IReactor` implementations that call out of the
108
- system for automations, and `IReactor` implementations that return events for
109
- translations. Use the exact type names.
116
+ system or return events or commands in response to our own events for
117
+ automations, and adapters that take outside data in as our own events for
118
+ translations. Choose the **authority** here: when an accepted model covers
119
+ the scope (or the repository is opted in, per `cratis-screenplay-modeling-lifecycle`), read the behaviors from
120
+ its slices (`StateChange`, `StateView`, `Automation`, `Translate`) and render
121
+ from the model; otherwise the code is the authority. Report code that
122
+ disagrees with the model as drift, separately; do not add unmodeled behavior
123
+ to the diagram. Use the exact type names.
110
124
  2. **Order** frames by domain causality — what must happen before what. Put state
111
125
  views after the events they project from. Use `rf` only between independent
112
126
  flows, never between sibling events of one flow, or the diagram becomes a
113
127
  tall tower one event wide.
114
128
  3. **Write** the diagram and the command-rules table.
115
129
  4. **Verify** it renders without a syntax-error banner, then reconcile it against
116
- the source: every behavior appears, classified by the marker it actually
117
- contains. A clean render proves valid Mermaid, not completeness — close the
118
- gaps against the code, never from memory.
130
+ the authority chosen in step 1 (the model's slices, or the code's markers):
131
+ every behavior appears, classified by the type the authority gives it. A clean
132
+ render proves valid Mermaid, not completeness — close the gaps against the
133
+ authority, never from memory. List model/code drift in the report instead of
134
+ resolving it in the diagram.
119
135
 
120
136
  ## Common mistakes
121
137
 
@@ -133,7 +149,7 @@ language. Include commands that emit no event.
133
149
  ## Verify
134
150
 
135
151
  - The diagram renders with no syntax-error banner.
136
- - Every behavior in the module appears, with the type its code actually has.
152
+ - Every behavior in the module appears, with the type its authority (the accepted `.play` slice, otherwise the code) gives it; drift is reported separately.
137
153
  - Every event frame uses the exact event type name from the source.
138
154
  - Independent flows start with `rf`; sibling events within a flow do not.
139
155
  - Passive read models have no consumer `ui` frame.
@@ -143,6 +159,9 @@ language. Include commands that emit no event.
143
159
 
144
160
  ## Route near misses
145
161
 
162
+ - An accepted model covers the scope (or the repository is opted in): it is the source for this
163
+ diagram; do not redraw from code and never change the model to match a
164
+ diagram. The diagram is a view of it.
146
165
  - Deciding the model rather than drawing one: `cratis-chronicle-event-modeling`
147
166
  for a hand-written Chronicle implementation, or
148
167
  `cratis-screenplay-event-modeling` when the model is authored as a Screenplay
@@ -0,0 +1,28 @@
1
+ Copyright (c) Cratis. All rights reserved.
2
+ Licensed under the MIT license. See LICENSE file in the canonical Cratis/AI repository for the full license text.
3
+
4
+ ## Third-party notices
5
+
6
+ Parts of this skill (the integration interview, the output format and the checklist of `references/worked-integration.md` and `references/integration-contracts.md`) are adapted from the `eventmodeling-translating-external-events` skill of TrogonStack agentskills, commit `7b249d3ee42d8b7e11fa564141ebd5fbc37aadf1`, used under this licence:
7
+
8
+ MIT License
9
+
10
+ Copyright (c) 2025 Straw Hat, LLC
11
+
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of this software and associated documentation files (the "Software"), to deal
14
+ in the Software without restriction, including without limitation the rights
15
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16
+ copies of the Software, and to permit persons to whom the Software is
17
+ furnished to do so, subject to the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be included in all
20
+ copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
+ SOFTWARE.
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: cratis-screenplay-automations-and-translations
3
+ description: "Model Screenplay Automation and Translate slices: when a reaction is warranted, todo-list work queues, produces versus invokes, the trusted actor behind caller-less invokes, termination, clock and trigger occurrences, outside facts via capture with correlation, dedup and enrich/ignore/infer, recovery ownership, and what once-only does not prove about external effects. Use when a model has or needs 'when X happens then ...', schedules, work queues, webhooks, API polls, message feeds or imported events. Not for: reaction, trigger or capture grammar (use `cratis-screenplay-captures-and-reactions`)."
4
+ license: MIT
5
+ ---
6
+
7
+ # Automations and translations
8
+
9
+ ## Purpose
10
+ Decide which work the system does on its own, which outside facts it accepts, and what that work
11
+ guarantees. Then write it as `Automation` and `Translate` slices that say truthfully what is
12
+ protected, what is only recorded, and who acts. Grammar depth is in
13
+ `cratis-screenplay-captures-and-reactions`; this skill owns the decisions.
14
+
15
+ **One meaning of Translation:** outside data becomes our facts (a `capture` or a translator
16
+ reaction over an imported event, in a `Translate` slice). Our own event-to-event follow-up is an
17
+ Automation (`produces` or `invokes`), even when a Chronicle reactor realizes it.
18
+
19
+ Work in the model first. Code appears only where it is truly needed: the external call, the
20
+ source adapter, the trusted actor, and everything Stage cannot render (below). Session and
21
+ verdict discipline: `cratis-screenplay-modeling-lifecycle`; tools, versions and verdicts V1 to V5:
22
+ `cratis-screenplay-toolchain`. When you add or change a reaction or capture, resolve its input,
23
+ identity, effect and pending-work contract at that point; do not postpone it to the final review.
24
+
25
+ ## Tool and realization facts (read before promising anything)
26
+ - Reactions, clocks, triggers, captures and Automation/Translate slices compile (V1) on both tools
27
+ and bind (V3) only on the standalone compiler 4.61 or later. The cratis 3.27.1 bundled compiler
28
+ (4.60.1) reports PLAY0268 at binding: report "V3 blocked: PLAY0268 (ESM v6)", never remove them.
29
+ - No MCP tool, `validate` or render runs Automation or Translate specs. V4 is "not run: no route".
30
+ - Stage 4.24.0 renders no Automation or Translate slice (Stage#79): the whole automation is
31
+ gap-fill or hand-written delivery with the model as contract (`references/realization-and-gap-fill.md`).
32
+ - Invoked commands run with no caller; `.play` cannot name an actor (Screenplay#383).
33
+
34
+ ## Verified product sources
35
+ | Package | Version | Used for |
36
+ | --- | --- | --- |
37
+ | Screenplay | v4.64.0 (`7e16162`) | `Documentation/screenplay/{reactions,captures,triggers,specifications,diagnostics}.md`; examples compiled with the standalone tool |
38
+ | cratis CLI | v3.27.1 | bundled compiler 4.60.1 (PLAY0268 on v6 constructs, false PLAY0285 on cascades, cli#242) |
39
+ | Stage | v4.24.0 | admits ESM v1 to v3; renders no Automation or Translate slice |
40
+ | Arc | v22.50.5 | `ExecuteCommandsAsSystemAttribute` (since v20.56.0) |
41
+ | Chronicle | v19.32.0 | `OnceOnlyAttribute`, `ReactorDelivery` and `Documentation/reactors/delivery-identity.mdx` |
42
+
43
+ Full pin table: `cratis-screenplay-toolchain` `references/versions.md`. Reverify before claiming
44
+ another version behaves the same.
45
+
46
+ ## When / when not
47
+ - Use: "when X happens, then ...", schedules, retries, work queues, notifications, webhooks, APIs,
48
+ files or message feeds, events imported from another context, legacy sync.
49
+ - Not for: reaction, trigger or CDL grammar (`cratis-screenplay-captures-and-reactions`); stream
50
+ identity and invariants (`cratis-screenplay-streams-and-consistency`); UI interactions such as
51
+ `on click` (`cratis-screenplay-ui-composition`); hand-written reactors (`cratis-chronicle-reactor`).
52
+
53
+ ## Interview phase
54
+ **Skip if** the user already gave: every external system with its record types, a sanitized sample
55
+ of each, and how each record finds our entity (the correlation strategy); and for automations, the
56
+ occurrence, the effect and who acts. Cite existing answers instead of asking again. Missing
57
+ correlation is the most common cause of failed integrations: surface it first.
58
+
59
+ **Critical questions** (ask one group at a time; follow up from the answer; accept "unsure" as an
60
+ open question, not an invented answer):
61
+ 1. **Sources.** "Which systems send us facts? For each: name, record types, channel (webhook, poll,
62
+ topic, file), format, who authenticates it?" Follow-up per system: "Does the record carry our
63
+ entity id, or do we need to remember their id against ours?"
64
+ 2. **Mapping.** "For the hardest record: does it map directly to one fact of ours, need several
65
+ facts, or need data we already hold?" Follow-up if not direct: "What do we look up, and what
66
+ happens when the record arrives before that data exists?"
67
+ 3. **Automations.** "What happens on its own after <fact>? Can it fail, wait, or need a person? What
68
+ do people see meanwhile? Who is allowed to do it?" Follow-up: "What makes it stop? What if it ran
69
+ twice?"
70
+ 4. **Recovery.** "Which records or steps can we not accept, and who fixes them, how, and how does
71
+ processing resume?"
72
+
73
+ **Unattended:** assume visibly. Record each assumption as a labelled open decision in `STATE.md`
74
+ (`.ai-work/screenplay/<model-slug>/STATE.md`), mark the dependent slice open, never write a mapping
75
+ or actor that nobody confirmed. Transcript-shaped worked example: `references/worked-integration.md`.
76
+
77
+ ## Procedure
78
+ 1. **Inventory.** List every reaction, trigger and external source/type in scope; read their
79
+ declarations, mappings, descriptions and specs. For integrations resolve only the unknowns
80
+ (`references/integration-contracts.md`).
81
+ 2. **Is it an automation?** Write four lines: occurrence (event, clock, application trigger), state
82
+ consulted, condition, effect. Always fires, consults nothing, cannot fail, touches nothing outside:
83
+ co-production, the command produces both facts. Otherwise continue (`references/automation-patterns.md`).
84
+ 3. **Queue or direct?** A todo list (a read model whose membership is the pending work) when work can
85
+ wait, retry, fail or need people. Name each opening and closing fact (result, cancellation,
86
+ supersession), the work-item key and the recovery path. Direct reaction only for an immediate,
87
+ internal, always-possible effect; say why no pending state is needed. A translation is not
88
+ automatically infallible.
89
+ 4. **Effect and actor.** `produces <Fact>` when nothing should refuse the fact. `invokes <Command>`
90
+ when the step is a decision that may reject; it carries **no caller**, so gated commands reject it.
91
+ Record one actor decision: internal ungated command (only when safe and unreachable), direct
92
+ `produces`, or gated command with a trusted actor and the capability gap (Screenplay#383). The code
93
+ realization of the actor is a reactor with `[ExecuteCommandsAsSystem("<role>")]` and a policy
94
+ requiring that role; never invent `runs as`. Never strip authorization to pass a tool.
95
+ 5. **Trace inputs.** Every trigger value, command input, event property and destination needs a
96
+ supported source; every filter a business reason. Gaps are questions, not invented mappings.
97
+ 6. **Repetition and termination.** Identify one logical work occurrence and what a retry is. Guard the
98
+ result fact with `constraint ... unique event` on the right stream only when once per source is the
99
+ rule. Name what ends each chain and check cycles. Answer separately how the *external* effect avoids
100
+ repeating and how replay differs from recovery redelivery (`references/effects-and-idempotency.md`).
101
+ 7. **Translate outside facts** (`references/translation-patterns.md`): enter only via `capture` or a
102
+ translator reaction, in a `Translate` slice; correlate first; keep the external fact distinct from
103
+ ours; trace source fields *and* every required target field; decide dedup, ordering and recovery
104
+ ownership. A worker after translation needs a distinct local decision, obligation or effect.
105
+ 8. **Specify and audit.** Work through `references/cases-to-specify.md` per declaration and hand the
106
+ named cases to `cratis-screenplay-scenario-coverage`. Produce the audit in `references/audit-format.md`.
107
+
108
+ ## Rules
109
+ **Compiler contracts** (diagnostics at 4.64.0)
110
+ - No inline `produces event` in a reaction (PLAY0474); declare reaction-produced events in the slice.
111
+ - Effects sit under a trigger; only `description` and `where` are reaction-level; one `where` per
112
+ reaction (PLAY0252); a trigger may not repeat (PLAY0253).
113
+ - Clock triggers take no values (PLAY0450) and no `by` on reads (PLAY0443). `for each <View>` is
114
+ reserved, not available.
115
+ - Capture `when` cannot mix `and` and `or` (PLAY0089). A capture without `key` does not bind.
116
+ - Undeclared events in capture `append` and `remove with` pass V1 and fail only at binding (V3, PLAY0273): run V3.
117
+ - A trigger with `reads` that `produces` directly fails binding: decide in a command. `reads` never protects.
118
+ - An authorized command exercised in a spec without `given caller` is PLAY0389 at binding.
119
+ - A list query (`=> Item[]`) and a clock sweep that iterates items do not bind; show them only as marked
120
+ design-only excerpts (`references/todo-list-example.md`).
121
+
122
+ **Modeling defaults** (deviate with a recorded reason)
123
+ - A `produces` without `for` lands on the triggering fact's source; clock and trigger occurrences have
124
+ none, so give `for` (a carried value or a literal).
125
+ - `where` guards every trigger of the reaction and must resolve from each trigger's values: give a clock
126
+ sweep its own reaction.
127
+ - Malformed or unmappable input becomes a recorded failure fact or dead-letter view, never a dropped
128
+ record. A fan-out records one outcome per item; partial success is failure at an effect boundary
129
+ (`cratis-engineering-effect-boundaries`), never a batch "done" while members failed.
130
+ - Infrastructure (logging, caching, retries, outbox plumbing) is never a Translate slice.
131
+ - Personal data kept in events needs `@pii` on its concept; keep it even when it blocks binding or render.
132
+ - Code bodies (`file`, inline fences) document realization; no local engine runs them.
133
+
134
+ **Review questions**
135
+ - What stops this from running twice? Forever? When the external call times out?
136
+ - Who is the actor, and could an outsider reach the invoked command?
137
+ - What does a person see while the work is pending or failed?
138
+ - What happens if the outside fact arrives before ours, twice, out of order, or changed?
139
+
140
+ ## Gate
141
+ Not done until, for every affected reaction and capture, there is a line in the audit
142
+ (`references/audit-format.md`) with a location and a result of complete, open or blocked, and any
143
+ unreviewed scope is named. Open decisions and target requirements are in `STATE.md`.
144
+ Never report a verdict without the tool and version that produced it.
145
+
146
+ ## Verify
147
+ - V1 and V3 per `cratis-screenplay-toolchain`, each with tool and version. On the cratis-bundled
148
+ compiler report "V3 blocked: PLAY0268 (ESM v6)". V4 is "not run: no route" for these slices.
149
+ - For each external source and type: its translation, or an explicit out-of-scope reason; check
150
+ target-field completeness as well as source-field dispositions.
151
+ - One happy path is not coverage: cite the spec or the missing case for each branch, denial, competing
152
+ claim and closing event.
153
+ - Every complete example compiles: `references/todo-list-example.md`, `references/translate-example.md`.
154
+
155
+ ## Route near misses
156
+ - Grammar: `cratis-screenplay-captures-and-reactions`; invoked commands: `cratis-screenplay-command-surface`;
157
+ triggers versus UI interactions: `cratis-screenplay-ui-composition`.
158
+ - Stream identity, constraints, races: `cratis-screenplay-streams-and-consistency`.
159
+ - Specifications for these slices: `cratis-screenplay-scenario-coverage`, then `cratis-screenplay-specifications`.
160
+ - Rendering, gap-fill and delivery route: `cratis-screenplay-render-and-gap-fill`.
161
+ - Legacy database-only writes: `cratis-screenplay-legacy-extraction` classifies them first; not
162
+ automatically Translate.
163
+ - Hand-written reactors and replay semantics: `cratis-chronicle-reactor`.
164
+
165
+ ## Lineage
166
+ Sources, adaptations and attribution: `references/provenance.md`.
@@ -0,0 +1,31 @@
1
+ # Audit format
2
+
3
+ Use after any reaction, capture or translation was added or changed, and at the end of a review.
4
+ Enumerate every affected declaration with its location; name any scope you did not review. A
5
+ result is complete, open or blocked, never "looks fine". The exhaustive enumeration is the
6
+ technique: partial work stays visible and nothing is skipped because it looked redundant.
7
+
8
+ ## Per automation (reaction)
9
+ | Declaration | Location | Trigger inputs traced | Condition | Effect and actor | Pending lifecycle | Repetition scope | Closing paths | Named cases | Result |
10
+ |---|---|---|---|---|---|---|---|---|---|
11
+
12
+ Result is `complete` only when every column is filled or says why it does not apply (for example
13
+ "direct effect: immediate, internal, cannot fail"). `open` names the unresolved decision and who
14
+ answers. `blocked` names the capability gap (for example Screenplay#383 for the actor, or a
15
+ list query that does not bind) with the intended behaviour.
16
+
17
+ ## Per translation (capture or translator reaction)
18
+ | Source and type | Location | Correlation | Field dispositions | Target fields traced | Dedup and ordering | Trust boundary | Recovery owner | Named cases | Result |
19
+ |---|---|---|---|---|---|---|---|---|---|
20
+
21
+ ## Filled example (from `todo-list-example.md`)
22
+ | Declaration | Check | Result |
23
+ |---|---|---|
24
+ | `CertificateSender` | trigger `CoursePassed` selects `enrolmentId`; `invokes SendCertificate`; actor recorded as an internal command not exposed (target requirement); repeat absorbed by `IssueOnce` | complete |
25
+ | queue `CertificatesToSend` | opens on `CoursePassed`, closes on `CertificateSent`; cancellation or supersession: none in scope (stated); specs open and close | complete |
26
+ | `CertificateRetrySweep` | reads the whole view; per-item fan-out needs code (Screenplay#286) | blocked |
27
+ | external send once | not provable in the model; idempotency key = enrolment id is a target requirement | open (owner: realization) |
28
+ | Unreviewed | `RecordCompletion` denial for a non-coordinator is specified; query authorization not in scope | stated |
29
+
30
+ Then the verdict line per `cratis-screenplay-toolchain`: tool and version on each of V1 to V4
31
+ (V4 for these slices: "not run: no route").
@@ -0,0 +1,139 @@
1
+ # Automation patterns
2
+
3
+ Complete compiled example: `todo-list-example.md` (binds on Screenplay 4.64.0; the list query
4
+ and retry sweep that do not bind are shown there as marked excerpts).
5
+
6
+ ## 1. Deciding whether it is an automation
7
+ Write the four parts in one line each:
8
+
9
+ | Part | Question | Example (`todo-list-example.md`) |
10
+ |---|---|---|
11
+ | occurrence | what sets it off? | `CoursePassed` |
12
+ | state consulted | what must it know? | the pending-certificate queue |
13
+ | condition | when does it act? | the item is still pending |
14
+ | effect | which command or fact results? | `SendCertificate` -> `CertificateSent` |
15
+
16
+ Outcomes:
17
+ - Unconditional, consults nothing, cannot fail, nothing outside: **co-production**. Add a
18
+ second `produces` to the command (one decision may record several recognised facts).
19
+ - An internal follow-up decision that may reject: reaction `invokes` a command.
20
+ - Work that waits, can fail, is retried or must be visible: **todo list** + reaction.
21
+ - A recurring check: clock reaction (`every` / `at`), usually over a todo list.
22
+ - A signal only an integration knows: declare a `trigger` and react `when <Trigger>`; specify
23
+ it with `when trigger`. A UI click is an interaction, not a trigger.
24
+
25
+ ## 2. Todo list in Screenplay
26
+ - A `readmodel` for one pending item: the identity plus what the worker needs to act. **No
27
+ status field**: being in the list is the state. If another consumer needs history, that is a
28
+ different read model.
29
+ - A projection that adds an item `from <OpeningFact>` and removes it with
30
+ `remove with <ClosingFact>`. Several facts may open or close; they need not match one to one.
31
+ - A keyed query (`…ById => Item optional` + `by itemId`) for specs and executable scope; a
32
+ list query for the visible queue (design-only: a list query reports PLAY0268 at binding on 4.64.0).
33
+ - A reaction `when <OpeningFact>` that invokes the command producing the closing fact.
34
+ The trigger may `reads` the item view to document its input; that is not protection.
35
+ - A retry sweep on a clock reads the whole view (no `by` on clock reads). Iterating its items
36
+ declaratively (`for each <View>`) is reserved syntax; today the sweep needs a code body,
37
+ which the reference never runs. Durable fan-out is outside the language today (Screenplay#286).
38
+ - Specify the list as a small story: empty -> item present (`then query …ById`) -> closed
39
+ (`when append <Closing>` + `then no readmodel … for`), plus "not opened" for facts that
40
+ must not queue work.
41
+
42
+ When a todo list is not needed: the effect is immediate, internal and cannot fail (a direct
43
+ `produces` or co-production), and nobody needs to see pending work. Say why in the slice
44
+ `description`; do not add a list just to follow a pattern.
45
+
46
+ ## 3. Effects: `produces` vs `invokes`
47
+ | | `produces <Fact>` | `invokes <Command>` |
48
+ |---|---|---|
49
+ | meaning | records a fact | asks for a decision |
50
+ | can it be refused? | only by append-time constraints | authorization, validation, `require`, constraints |
51
+ | destination | `for` value; without `for`, the trigger fact's source | the command's identifier |
52
+ | with trigger `reads` | fails binding (unprotected decision) | allowed; protection is the command's job |
53
+ | caller | n/a | **none**: gated commands reject |
54
+
55
+ ## 4. The actor behind an invoke
56
+ Today there is no caller: the invoked command runs its full pipeline (authorization, validation,
57
+ requirements, constraints) with no caller, a command that needs one rejects, and the rejection
58
+ ends the scenario. Screenplay has no syntax for an identity (Screenplay#383, open); never invent
59
+ `runs as` or a caller line. At code level the realization is a Chronicle reactor whose returned
60
+ commands run as a trusted system actor: `[ExecuteCommandsAsSystem("<role>")]` (Arc, since
61
+ v20.56.0; also in a Stage-rendered app, whose Arc is 22.25.0) with a policy that requires that
62
+ role. Record the intended actor in the model; the attribute lives in gap-fill code.
63
+
64
+ Decide and record one of:
65
+ 1. **Internal ungated command** - only if the security design supports it: not reachable by
66
+ outside callers in the target (verify; the model cannot show exposure), safe to repeat
67
+ (guarded by `unique event`), and touching one stream. State the reasons in the module
68
+ `description` (as `todo-list-example.md` does) and list "not externally exposed" as a target
69
+ requirement in `STATE.md`.
70
+ 2. **Direct `produces`** - when no decision is left (the fact is already decided) and nothing
71
+ should refuse it.
72
+ 3. **Gated command + trusted actor + recorded gap** - when the command must stay protected.
73
+ Keep the gate (a policy requiring the service role), name the role as the intended actor,
74
+ and record that `.play` cannot declare it yet. The reference rejects the caller-less invoke,
75
+ so the automation spec cannot pass: do not write a fake passing spec. Report V4 as "not run:
76
+ no route" (no available route executes these specs) and record the expected rejection and
77
+ the trusted-actor gap separately, citing the reaction semantics (a command that requires a
78
+ caller rejects the reaction).
79
+ Never remove an existing gate only to make a reaction spec pass.
80
+ Omitting an HTTP route is not an authorization proof: the exposure requirement stays a target
81
+ requirement with its negative case (an outside caller is refused).
82
+
83
+ ## 5. Termination
84
+ For every reaction, name the fact that ends the work and check the graph: no reaction is set
85
+ off by its own result (directly or via another reaction) unless a condition stops it. The
86
+ reference evaluator caps a scenario at 1,000 new facts and a clock advance at 10,000
87
+ occurrences; hitting that is a modeling defect, not a limit to tune.
88
+
89
+ ## 6. Clock and trigger occurrences
90
+ - `every N minutes|hours|days`, `at HH:mm`, `at HH:mm on <Weekday>`, `at HH:mm on day N`.
91
+ - Occurrences carry no event source: every `produces` needs `for` (a literal such as
92
+ `"weekly"` for a singleton stream, or a carried value).
93
+ - `where` must be resolvable from each trigger's values; a clock has none, so a clock trigger
94
+ in a reaction with `where` fails binding. Give the sweep its own reaction.
95
+ - Specify with `given clock` + `when clock` (state both); `$context.occurred` takes the clock
96
+ instant. A clock-produced fact example with its spec: `cratis-screenplay-toolchain`
97
+ `references/cheat-sheet-example.md` (`Reminder` reaction).
98
+
99
+ ## 7. Shapes to question in review
100
+ - A relay that only renames an already-recorded fact: ask what local decision, obligation or
101
+ effect it adds; otherwise project from the first fact.
102
+ - A reaction triggered directly by another context's event that also makes our decision:
103
+ establish what the outside fact means and what we trust (translate first), then decide.
104
+ - An automation with no visible pending state where failures are likely.
105
+ - A gated command invoked by a reaction with no recorded actor decision.
106
+ - A reaction that `reads` and `produces`.
107
+
108
+ ## 8. Chain completion checkpoint
109
+ Walk each affected chain from occurrence to terminal outcome.
110
+
111
+ For each queue:
112
+ - Identify one work item and its key. If an entity can need several independent jobs, its id
113
+ alone may not identify the work.
114
+ - List every opening and closing cause, including cancellation and supersession; opening and
115
+ closing keys must address the same item.
116
+ - Trace every worker input to its source. A view describing work is not an atomic claim and
117
+ does not authorize an external effect.
118
+ - Decide what stays visible after rejection, timeout or manual intervention.
119
+ - Specify each lifecycle path: removal of the right item, unaffected items, and later
120
+ occurrences that legitimately create new work.
121
+
122
+ A translation queue, when needed, has the same completion duty: do not keep processed
123
+ records forever while calling the view pending work.
124
+
125
+ For a proposed worker after translation ask: what must our side still decide or perform;
126
+ which local authority or obligation makes it ours; what observable outcome vanishes if it is
127
+ removed? No distinct outcome means a projection of the translated fact. Field equality is not
128
+ proof that two systems own the same decision.
129
+
130
+ Naming: no command or event is named for a form (`Update/Edit/Save/Set/Change<Noun>`,
131
+ `<Noun>Updated/Changed/Saved`); a correction names what it corrects. Separately, a relay or
132
+ an event whose payload restates an earlier event's fields (`…Synced`) is a review signal: it
133
+ is major only when business meaning is lost, a rule is bypassed or consumers become
134
+ ambiguous. Historical event generations are exempt.
135
+
136
+ ## 9. Fan-out
137
+ Record one outcome fact per item. Never record a batch completion fact while some items
138
+ failed or are unknown; partial success is failure at an effect boundary
139
+ (`cratis-engineering-effect-boundaries`).
@@ -0,0 +1,69 @@
1
+ # Cases to specify
2
+
3
+ Decide each case's expected outcome with the domain expert, then hand the list to
4
+ `cratis-screenplay-scenario-coverage` for the coverage matrix. A case may be "not applicable" only with a domain reason. A case
5
+ whose outcome nobody knows is an open question in `STATE.md`, not a spec.
6
+
7
+ Enumerate per reaction trigger, capture append branch and invoked command. Give each
8
+ applicable case a named outcome and a spec location, or an explicit capability/decision gap.
9
+ One spec in the slice does not cover the others.
10
+
11
+ ## Automations
12
+ | Case | Question | Typical Screenplay shape |
13
+ |---|---|---|
14
+ | happy path | trigger occurs, work done | `when append <Trigger>` -> `then <Result>` (Automation slice) |
15
+ | condition false | trigger occurs, nothing should happen | assert a view (`then no readmodel …`), not an empty event list |
16
+ | queue opens / closes | item appears, item disappears | `then query …ById`; `when append <Closing>` + `then no readmodel … for` |
17
+ | already done | trigger re-delivered after the result exists | `given <Result>` + `when <Command>` -> `then error "<fixed constraint message>"` |
18
+ | invoked command rejects | validation or constraint refuses | command spec in its StateChange slice; record what the queue shows afterwards |
19
+ | no caller | invoked command is gated | record the expected rejection and the actor decision (`automation-patterns.md` §4); V4 is "not run: no route" |
20
+ | clock boundary | due exactly at the instant, just before, just after | `given clock` + `when clock`; boundary semantics are contested in the docs, mark the expectation as an assumption |
21
+ | each branch | does every filter and conditional production have both outcomes? | concrete triggering and non-triggering values; assert the resulting facts or view |
22
+ | denied actor | every command and query under an inherited module/feature `authorize` needs its own denial; also, can an unauthorized caller reach a gated invoked command by another origin? | command spec with otherwise-valid inputs, `given caller` carrying the wrong role/claim (or no caller) and `then denied`; separate from the caller-less reaction gap |
23
+ | competing claim | two sources claim the same constrained value | `given` the first fact, `when <Command>` the second, `then error "<message>"` |
24
+ | all closing paths | result, cancellation or supersession ends work | one `remove with` path per case, `then no readmodel … for` |
25
+ | distinct later work | same entity needs another legitimate job | prove dedup does not suppress the new occurrence |
26
+ | partial cascade | earlier effect succeeded, later invocation failed | record which facts persist and how retry resumes; no cascade rollback |
27
+ | loop / runaway | result re-triggers the reaction | prove termination in text; no spec can show "never" |
28
+ | external effect fails / times out | send failed, or unknown | item stays pending; retry sweep; see `effects-and-idempotency.md` |
29
+
30
+ ## Translations
31
+ | Case | Question | Typical shape |
32
+ |---|---|---|
33
+ | happy path | record arrives, our fact recorded | `when capture` -> `then <External>` + `then <Ours>` |
34
+ | arrives before our entity | the reference is unknown to us | decide: park, reject, or record an orphan fact for follow-up |
35
+ | duplicate delivery | same record again | `given capture` (same record) + `when capture`: nothing new; or constraint rejection on our fact |
36
+ | out of order | an older record after a newer one | `given capture` newer + `when capture` older; expected outcome stated |
37
+ | partial | required field missing | decide: enrich later, pending fact, or reject; never a fabricated default |
38
+ | invalid | unknown code, wrong type | `translate` has no entry -> decide and specify |
39
+ | changed / corrected | outside value changes after our fact | correction fact or open decision (`translation-patterns.md` §6) |
40
+ | mis-correlated | reference points at the wrong stream | property constraint on the external reference, or an expert review case |
41
+ | personal data | field we must not keep | excluded from the append mappings; note in `description`; the source record may still carry it |
42
+ | authenticity / ownership | wrong source, tenant or entity reference | specify the rejection and name where it is enforced; capture metadata does not verify it |
43
+ | each mapping branch | every recognized code has its intended local meaning | concrete payload and exact translated values; unknown code is a separate case |
44
+ | same object, different occurrence | two legitimate events share a provider object id | both stay representable; dedup hits only the repeated occurrence |
45
+ | material field changes alone | amount or score changes, status does not | explicit correction or rejection outcome; inspect the append conditions |
46
+ | units and timestamps | units, precision, timezone, provider time differ | concrete conversions; record unsupported transforms |
47
+ | deferred recovery | correlation or enrichment arrives after the record | owner, resumption point and stable work identity |
48
+ | consent missing | processing needs a permission not given | no unauthorized domain effect; name where enforced |
49
+ | malformed record | unparseable or unmappable input | a recorded failure fact or dead-letter view, not a throw |
50
+
51
+ ## Concurrency and retries (both kinds)
52
+ - Two deliveries of the same logical occurrence at once: which atomic mechanism prevents
53
+ duplicate work, and does the caller see success or rejection? Also two distinct legitimate
54
+ occurrences, which must not be mistaken for retries.
55
+ - The append commits but the acknowledgement to the source is lost: the source resends; layer
56
+ 1 or 2 dedup must absorb it.
57
+ - Projection lag: the reaction's `reads` sees the queue before or after the closing fact?
58
+ The decision must not depend on it (it is not protected).
59
+
60
+ ## Spec limits (tool differences: `cratis-screenplay-toolchain` `references/versions.md`)
61
+ - These Automation/Translate specs parse and bind (V3) on Screenplay 4.64.0, but no MCP tool,
62
+ `validate` or Stage render runs them (Stage renders no Automation or Translate slice). Report
63
+ V4 as "not run: no route"; never as passed.
64
+ - With the standalone compiler, a command spec lists the cascade (v6 semantics: after
65
+ `when <Command>`, `then` lists every new fact, including reaction appends). Only when the
66
+ cratis-bundled compiler is the V1 tool does it report a false PLAY0285 on a cascade (cli#242):
67
+ then keep the cascade out of the command spec, specify it in the Automation slice
68
+ (`when append <Trigger>`) and record the expectation. See `cratis-screenplay-scenario-coverage`.
69
+ - `given capture` never persists between specs: state the baseline in each spec that needs it.
@@ -0,0 +1,88 @@
1
+ # Effects and idempotency
2
+
3
+ ## Three guarantees, three proofs
4
+ | Guarantee | What it promises | What can show it |
5
+ |---|---|---|
6
+ | **once-only fact** | `CertificateSent` exists at most once for an enrolment | `constraint … unique event` on the right stream + a violation spec |
7
+ | **idempotent handling** | asking again gives the caller the same outcome, no new effect | target behaviour (map "already has the event" to success where intended); the model shows a rejection |
8
+ | **exactly-once external effect** | the person receives one certificate, the card is charged once | nothing in the model; only the outside system's dedup or a reconciliation can |
9
+
10
+ A todo list + reaction + unique constraint proves the first. It does **not** prove the third:
11
+ the send can succeed and the append fail (crash, lost reply, constraint race), and the retry
12
+ sends again.
13
+
14
+ ## Where the external call sits
15
+ The model states facts; the call to the outside world happens in the realization of a command
16
+ or reaction. Choose and record one of:
17
+ 1. **Effect, then fact** (`todo-list-example.md`): the realization calls out, then appends the
18
+ result fact. Failure between the two repeats the effect on retry. Make it safe with an
19
+ **idempotency key** the outside system honours (our stream id or a deterministic
20
+ derivative), or accept at-least-once and say so.
21
+ 2. **Intent fact, then outcome fact**: record our decision first (`CertificateRequested`), call
22
+ out from the realization, and record the outcome from the outside system's
23
+ acknowledgement through a `Translate` slice (`CertificateDelivered`, `DeliveryFailed`).
24
+ Pending state is visible; reconciliation compares intents without outcomes.
25
+ 3. **Outside system owns it**: we only record what they report (translation); the duplicate
26
+ question moves to their side.
27
+ 4. **Inline operation** (syntax-only: `system` + `operation` with `execute`/`compensate`
28
+ are syntax-only and leave the application with no executable model): the command does
29
+ immediate outside work before its facts commit and declares how to undo it if they do not
30
+ (reserve a seat in an outside booking system); realized as an Arc `ICommandOperation`. Only
31
+ when the outside work is part of the decision and has a meaningful reversal; never for
32
+ work that must survive commit (email, payment, webhook): that is 1 or 2.
33
+ Payments, legal notices and anything costly or irreversible: prefer 2 or 3 and an idempotency
34
+ key; write a reconciliation case.
35
+
36
+ ## Retry identity
37
+ - The retry must carry the same identity as the first attempt: the stream id chosen before
38
+ the first try (never a fresh id per attempt), and the same idempotency key outward.
39
+ - Dedup scope must match the guarantee: `unique event` is per source; `unique x on` is across
40
+ sources but lets the same source re-claim; capture change detection is per key and only as
41
+ durable as the target's last-seen store.
42
+
43
+ ## Ordering and lost acknowledgements
44
+ - A reaction cascade is not one transaction: earlier accepted facts stay when a later invoked
45
+ command rejects (Screenplay `reactions.md`). Design each step to be retried on its own.
46
+ - Facts are reacted to in append order in the reference; across sources assume no order.
47
+ - A capture spec does not acknowledge the source or store a new last-seen record; prefix
48
+ facts that were accepted do not mean the record was processed (Screenplay `captures.md`).
49
+ Record how the target acknowledges.
50
+ - Delivery guarantees, acknowledgements and durable fan-out are outside the language today (Screenplay#286);
51
+ never describe them as provided.
52
+
53
+ ## Projection lag and rebuild
54
+ - The queue view may lag the closing fact: a sweep may see an item that was just closed. The
55
+ invoked command's `unique event` absorbs that; the external call must too (idempotency key).
56
+ - Rebuilding the queue from history restores only genuinely open items, because closing facts
57
+ are history too. A reaction must not repeat external effects on replay or rebuild: confirm
58
+ the target's replay behaviour before relying on it, and record the answer.
59
+ - Replay and recovery redelivery are different. Chronicle `[OnceOnly]` skips replays (rewind,
60
+ redaction, revision) only; a recovered failed partition redelivers the event as a normal
61
+ observation. A receipt keyed by `ReactorDelivery.Id` identifies the retry. Name both.
62
+
63
+ ## What to write down (slice `description` + `STATE.md`)
64
+ - Effect placement (1-4) and why. Placement 4 is syntax-only: say the model then has no
65
+ executable form.
66
+ - The idempotency key, and whether the outside system honours it.
67
+ - At-least-once accepted? Who notices duplicates or misses (reconciliation view, person)?
68
+ - The actor and gate decision for invoked commands.
69
+
70
+ ## Chronicle realization
71
+ Choose replay exclusion when replay must not repeat an effect; an alternate replay handler
72
+ only when replay has different required work. Recovery redelivers normally either way. A
73
+ local delivery receipt cannot atomically prove an external service completed: keep external
74
+ idempotency or reconciliation.
75
+
76
+ A returned-event batch can be transactional across event sources; a reaction cascade is not
77
+ one transaction. Returned commands can fail validation or authorization, and a duplicate
78
+ append can fail its observer partition. Define when an already-completed result is
79
+ acknowledged and when a conflicting request must fail.
80
+
81
+ Separate domain failure from observer failure. A domain failure gets a timely visible
82
+ outcome and an owner; a paused or quarantined observer gets an operational recovery owner.
83
+
84
+ Prefer trigger facts as inputs. When an irreversible action depends on absence, do not trust
85
+ an eventually consistent sink: use authoritative state with an explicit protection strategy,
86
+ and bound unattended sweeps by expected population and per-run limits. Cross-service delivery
87
+ uses a published contract with outbox/inbox realization, not an assumed shared log;
88
+ namespace bridging is explicit translation.