@cratis/pi 8.4.1 → 8.5.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.
- package/package/corpus/harnesses/copilot/instructions/ai-distribution.instructions.md +2 -1
- package/package/corpus/harnesses/copilot/instructions/exit-codes-and-wrappers.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/scripting.instructions.md +2 -1
- package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +131 -9
- package/package/corpus/rules/ai-distribution.md +2 -1
- package/package/corpus/rules/exit-codes-and-wrappers.md +1 -1
- package/package/corpus/rules/scripting.md +2 -1
- package/package/corpus/skills/cratis-application-growth/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-arc-authorize-request/SKILL.md +3 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +28 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp-query-security.md +3 -3
- package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-arc-authorize-request/references/typescript.md +2 -0
- package/package/corpus/skills/cratis-arc-connect-storage/references/csharp.md +1 -0
- package/package/corpus/skills/cratis-arc-connect-storage/references/elixir.md +9 -2
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-chronicle.md +1 -1
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp-history.md +2 -2
- package/package/corpus/skills/cratis-arc-declare-command/references/csharp.md +7 -7
- package/package/corpus/skills/cratis-arc-declare-operation/references/csharp-abilities.md +2 -2
- package/package/corpus/skills/cratis-arc-declare-operation/references/csharp-recovery.md +6 -4
- package/package/corpus/skills/cratis-arc-declare-operation/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-arc-diagnose-live-query/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +6 -6
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/java.md +1 -1
- package/package/corpus/skills/cratis-arc-diagnose-live-query/references/kotlin.md +1 -1
- package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp-diagnose-tool-call.md +9 -7
- package/package/corpus/skills/cratis-arc-expose-mcp-operation/references/csharp.md +3 -1
- package/package/corpus/skills/cratis-arc-expose-query/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +10 -7
- package/package/corpus/skills/cratis-arc-expose-query/references/go.md +2 -2
- package/package/corpus/skills/cratis-arc-expose-query/references/typescript.md +6 -3
- package/package/corpus/skills/cratis-arc-generate-proxies/references/csharp.md +7 -5
- package/package/corpus/skills/cratis-arc-host-application/references/csharp-identity.md +3 -2
- package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +7 -0
- package/package/corpus/skills/cratis-arc-invoke-command/references/csharp-extensions.md +4 -0
- package/package/corpus/skills/cratis-arc-isolate-tenant/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-isolate-tenant/references/csharp.md +4 -2
- package/package/corpus/skills/cratis-arc-react-bind-slice/SKILL.md +17 -22
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-commands.md +11 -1
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-host.md +10 -3
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-identity.md +7 -3
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-queries.md +1 -1
- package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-arc-testing-typescript/references/typescript.md +2 -2
- package/package/corpus/skills/cratis-arc-validation-typescript/SKILL.md +1 -0
- package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +5 -5
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/inspection.md +11 -3
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/project-tooling.md +22 -0
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/recovery-and-comparison.md +17 -3
- package/package/corpus/skills/cratis-chronicle-cli-operations/references/setup-and-target.md +8 -2
- package/package/corpus/skills/cratis-chronicle-connect-application/references/python.md +2 -2
- package/package/corpus/skills/cratis-chronicle-constrain-append/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/SKILL.md +4 -3
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/configuration.md +86 -16
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/kernel-options.md +3 -3
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/network-and-tls.md +14 -6
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/storage.md +33 -1
- package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +27 -1
- package/package/corpus/skills/cratis-chronicle-evolve-event/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-chronicle-inspect-observer/SKILL.md +4 -4
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/csharp.md +8 -7
- package/package/corpus/skills/cratis-chronicle-inspect-observer/references/go.md +2 -2
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/references/deployment.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-fluent.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-model-bound.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/csharp-reading.md +2 -0
- package/package/corpus/skills/cratis-chronicle-project-view/references/java.md +1 -1
- package/package/corpus/skills/cratis-chronicle-project-view/references/kotlin.md +3 -3
- package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +2 -0
- package/package/corpus/skills/cratis-chronicle-protect-decision/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp-scopes.md +1 -1
- package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-chronicle-protect-personal-data/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-protect-personal-data/references/csharp.md +4 -2
- package/package/corpus/skills/cratis-chronicle-publish-contract/SKILL.md +6 -5
- package/package/corpus/skills/cratis-chronicle-publish-contract/references/elixir-integrations.md +3 -3
- package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +2 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp-pages.md +1 -1
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/csharp.md +3 -3
- package/package/corpus/skills/cratis-chronicle-react-to-fact/references/java.md +1 -1
- package/package/corpus/skills/cratis-chronicle-record-event/SKILL.md +2 -2
- package/package/corpus/skills/cratis-chronicle-reduce-state/references/typescript.md +1 -1
- package/package/corpus/skills/cratis-chronicle-web-workbench/SKILL.md +1 -1
- package/package/corpus/skills/cratis-ci-pipeline-performance/SKILL.md +4 -3
- package/package/corpus/skills/cratis-ci-pipeline-performance/references/publish-pipelines.md +19 -4
- package/package/corpus/skills/cratis-code-review/SKILL.md +6 -2
- package/package/corpus/skills/cratis-code-review/references/csharp.md +3 -3
- package/package/corpus/skills/cratis-commits-and-pull-requests/SKILL.md +6 -38
- package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-description.md +2 -0
- package/package/corpus/skills/cratis-commits-and-pull-requests/references/pr-labels-and-release.md +5 -4
- package/package/corpus/skills/cratis-commits-and-pull-requests/references/workflow-inputs.md +39 -0
- package/package/corpus/skills/cratis-components-submit-form/SKILL.md +6 -6
- package/package/corpus/skills/cratis-components-submit-form/references/typescript-commanddialog.md +21 -1
- package/package/corpus/skills/cratis-components-submit-form/references/typescript.md +2 -2
- package/package/corpus/skills/cratis-fundamentals-concept/references/csharp-serialization.md +2 -1
- package/package/corpus/skills/cratis-fundamentals-concept/references/csharp.md +1 -0
- package/package/corpus/skills/cratis-fundamentals-concept/references/go.md +1 -1
- package/package/corpus/skills/cratis-fundamentals-concept/references/java-json.md +3 -2
- package/package/corpus/skills/cratis-fundamentals-concept/references/kotlin-json.md +3 -2
- package/package/corpus/skills/cratis-fundamentals-concept/references/typescript-serialization.md +8 -2
- package/package/corpus/skills/cratis-fundamentals-name-value/SKILL.md +8 -7
- package/package/corpus/skills/cratis-fundamentals-type-discovery/SKILL.md +3 -3
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp-diagnostics.md +3 -0
- package/package/corpus/skills/cratis-fundamentals-type-discovery/references/csharp.md +2 -2
- package/package/corpus/skills/cratis-platform-deliver-slice/references/typescript.md +14 -1
- package/package/corpus/skills/cratis-platform-prepare-release-pr/SKILL.md +8 -8
- package/package/corpus/skills/cratis-platform-prepare-release-pr/references/product-release-checks.md +16 -2
- package/package/corpus/skills/cratis-release-notes/SKILL.md +1 -1
- package/package/corpus/skills/cratis-release-notes/references/publish-repair.md +6 -3
- package/package/corpus/skills/cratis-screenplay-accept-model/references/csharp.md +5 -3
- package/package/corpus/skills/cratis-screenplay-accept-model/references/read-the-evidence.md +2 -2
- package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +6 -10
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/commands.md +8 -4
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/projections.md +2 -0
- package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +19 -1
- package/package/corpus/skills/cratis-screenplay-edit-workspace/SKILL.md +2 -1
- package/package/corpus/skills/cratis-screenplay-edit-workspace/references/mcp-tools.md +1 -1
- package/package/corpus/skills/cratis-screenplay-handoff-slice/references/csharp.md +13 -1
- package/package/corpus/skills/cratis-screenplay-model-translation/SKILL.md +1 -1
- package/package/corpus/skills/cratis-screenplay-model-translation/references/boundary-diagnostics.md +1 -1
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/SKILL.md +26 -48
- package/package/corpus/skills/cratis-screenplay-onboard-workspace/references/studio.md +5 -0
- package/package/corpus/skills/cratis-screenplay-specify-outcome/SKILL.md +8 -12
- package/package/corpus/skills/cratis-screenplay-specify-outcome/references/running-mcp.md +12 -0
- package/package/corpus/skills/cratis-screenplay-specify-outcome/references/scenarios.md +2 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-command-results.md +1 -1
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md +6 -0
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-integration.md +3 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +15 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-read-models.md +4 -2
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp.md +1 -1
- package/package/corpus/skills/cratis-specifications-exercise-backend/references/typescript.md +4 -2
- package/package/corpus/skills/cratis-stage-render-slice/SKILL.md +6 -0
- package/package/corpus/skills/cratis-stage-render-slice/references/semantic-conformance.md +64 -0
- package/package.json +1 -1
|
@@ -151,7 +151,7 @@ Read [commands](references/commands.md) when writing properties, reads, validati
|
|
|
151
151
|
- Rule operators: `not empty`, `min`, `max`, comparisons (`==`, `!=`, `>`, `>=`, `<`, `<=`), `length ==`, `decimals <=`, `all >`/`all >=`, text tests (`[not] contains`, `starts with`, `ends with`), `matches email|"<regex>"`; `rule <Name>` with a body for what only code can state (a bare one is authoring-only), or a `file` or fenced block under a command's `validate`. Types, clock operands and operator precedence: see commands.
|
|
152
152
|
- `authorize <policy expression>`: who may call; enclosing module and feature gates also apply.
|
|
153
153
|
- `produces <Event>` with `for <property>`, `tag <value>` and `<property> = <source>` lines: records a fact. Default.
|
|
154
|
-
- `produces when <condition>` with the
|
|
154
|
+
- `produces when <condition>` with the event name and its block beneath: only when the condition holds; each evaluated independently. The condition uses command properties, literals, enum members and clock operands, never read paths.
|
|
155
155
|
- `produces event <Name>` with `<name> <Type> = <source>`: single-producer inline event. Allows a rename-only `id`; extract for `generation` or `public`.
|
|
156
156
|
- `produces operation <Name>`: declared external work (automation).
|
|
157
157
|
- `returns <property>` or a `returns` block of `<name> = <source>`: the response.
|
|
@@ -184,7 +184,6 @@ Read [projections](references/projections.md) when building a view from events (
|
|
|
184
184
|
|
|
185
185
|
- `readmodel <Name>` with properties; `key` marks identity, several `key`s a composite key.
|
|
186
186
|
- `passive`: replayed for command decisions only, never stored or queried.
|
|
187
|
-
- `sink <Name>` on a read model or graph: stores it in that sink (exact declared spelling).
|
|
188
187
|
- `projection <Name> => <ReadModel>`: the default view builder.
|
|
189
188
|
- `from <Event>[, <Event>]` with mapping lines: creates or updates the selected instance.
|
|
190
189
|
- `key <expr>` on a `from`, or a `key` block of `<part> = <expr>`: select by payload value or composite key. `key literal "<text>"`: one summary instance for every event.
|
|
@@ -206,14 +205,10 @@ Read [projections](references/projections.md) when building a view from events (
|
|
|
206
205
|
Read [reducers, graphs and sinks](references/reducers-graphs-sinks.md) when a projection cannot express the view or the question is about paths.
|
|
207
206
|
|
|
208
207
|
- `reducer <Name> => <ReadModel>` with `on <Event>` rules, each with a body, and an optional `from <Source>[.<Stream>]` filter: code over previous state and event; keyed by event source id.
|
|
209
|
-
- `graph <Name
|
|
210
|
-
- `
|
|
211
|
-
- `
|
|
212
|
-
- `
|
|
213
|
-
- `detach` on node `remove with`: delete incident edges; otherwise they may dangle.
|
|
214
|
-
- `query … graph <Graph>`: path `match`, `optional match`, equality `where`, and mapped `return`.
|
|
215
|
-
- `collect` in a graph query `return`: child rows via one hop from a single root-node match; no optional match or nested collect.
|
|
216
|
-
- `sink <Name> for readmodels|graphs`: declare storage; select it with `sink <Name>` on a view or graph.
|
|
208
|
+
- `graph <Name>` with `node` types (one required scalar `key` each) and `edge <Name> source <Node> target <Node> [identified by <property>]`: a relationship view.
|
|
209
|
+
- `projection <Name> => graph <Graph>`: node handlers by `key`, edge handlers by `source`/`target`; add `detach` to node removal or edges dangle.
|
|
210
|
+
- `query … graph <Graph>`: `match`, `optional match`, equality `where`, mapped `return` and one-hop `collect`.
|
|
211
|
+
- `sink <Name> for readmodels|graphs`: declare storage; select it with `sink <Name>` (exact declared spelling) on a read model or graph.
|
|
217
212
|
|
|
218
213
|
### Queries
|
|
219
214
|
|
|
@@ -255,6 +250,7 @@ The rest of the language (reactions, systems, workflows, captures, screens, spec
|
|
|
255
250
|
- Events are past-tense facts with one purpose each.
|
|
256
251
|
- Mappings copy values; accumulate with `add`/`subtract` in the projection or compute in a `handler`.
|
|
257
252
|
- Rules and policies cannot refer to a `generated` property; it does not exist yet.
|
|
253
|
+
- Property names start with an ASCII `a`–`z` or `_`, after any `@` escape (`quantity Int`, `updatedAt DateTime`) in commands, events, types and read models. An uppercase-leading line is not a property and fails to compile (`PLAY0016` outside commands).
|
|
258
254
|
- A key on one `from` does not carry over to another; remove with the same key rule that created the row.
|
|
259
255
|
- One projection or reducer per read model (`PLAY0191`).
|
|
260
256
|
|
|
@@ -63,7 +63,7 @@ command IssuePermit
|
|
|
63
63
|
| `reads Account as source by sourceId` | Aliased read. Every read of the same view needs an alias once there are two. |
|
|
64
64
|
| `reads ResourceMonth as totals` followed by an indented `by` block of `part = source` lines | Composite key: every key part mapped once from a required scalar command property. |
|
|
65
65
|
|
|
66
|
-
Refer to the state as `<alias>.<property>` or, for an unaliased read, `<ReadModel>.<property>`, in `require` conditions and in production mappings.
|
|
66
|
+
Refer to the state as `<alias>.<property>` or, for an unaliased read, `<ReadModel>.<property>`, in `require` conditions and in production mappings. A `produces when` condition cannot use it; it tests only command properties, literals, enum members and clock operands.
|
|
67
67
|
|
|
68
68
|
Declare the application-root `command reads protected` preamble whenever a command decides from a read. With it, the decision is guarded against the view changing between the read and the append, a missing instance rejects with `<ReadModel> does not exist.`, and read paths may feed event mappings. Without it, a read-fed decision is authoring intent only and executable binding refuses it.
|
|
69
69
|
|
|
@@ -76,8 +76,8 @@ validate
|
|
|
76
76
|
plate not empty message "A plate is required"
|
|
77
77
|
fee >= 0 message "A fee cannot be negative"
|
|
78
78
|
kind != visitor severity warning message "Visitor permits need approval"
|
|
79
|
-
require
|
|
80
|
-
message "An extension
|
|
79
|
+
require fee >= Permit.fee
|
|
80
|
+
message "An extension cannot cost less than the current permit"
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
Property rule: `<property path> <operator> [severity <level>] [message "<text>" | message $strings.<key>]`.
|
|
@@ -114,7 +114,11 @@ One condition grammar serves `require`, `produces when`, policy `require` and re
|
|
|
114
114
|
|
|
115
115
|
- Comparisons: `==`, `!=`, `>`, `>=`, `<`, `<=`, `contains`, `starts with`.
|
|
116
116
|
- Combine with `and`, `or` and parentheses; `and` binds tighter than `or`.
|
|
117
|
-
- Operands:
|
|
117
|
+
- Operands: properties, literals, enum members and clock operands. A read path (`<alias>.<property>`) is admitted in two places only:
|
|
118
|
+
- A command `require` under `command reads protected`, on either side of a comparison of numbers, text, enum members or booleans, or of `==`/`!=` between required scalar Uuid values (two concepts must be the same concept; a bare `Uuid` matches any Uuid concept). A `Date` or `DateTime` read path is refused, also against a clock operand; compare dates through command properties.
|
|
119
|
+
- A policy `require` through the policy's own `reads`, on the left only, compared with a constant or an enum member. `$identity.id` is admitted only on the right of `==` or `!=`, against a required text property that is not an enum.
|
|
120
|
+
|
|
121
|
+
A read path in `produces when` or a reaction `where` does not bind. `$env.<Name>` is also accepted, but a condition that uses it is authoring intent only and is refused at executable binding.
|
|
118
122
|
|
|
119
123
|
| Clock operand | Type | Notes |
|
|
120
124
|
| --- | --- | --- |
|
|
@@ -65,6 +65,8 @@ Compiling does not report a read-model field that neither automatic mapping nor
|
|
|
65
65
|
- A key on one `from` does not carry over to another. Every handler for an event from a different source needs its own `key`.
|
|
66
66
|
- `from EventA key idA, EventB key idB, EventC` shares one mapping block between events that name the identity differently.
|
|
67
67
|
- The read model's `key` properties describe lookups. They do not route events; align each `from` key with them.
|
|
68
|
+
- A projection level uses each event type once. `from` (including comma-separated events), `remove with`, `remove via join` and `clear with` share one set, so a second reference to the same event is error PLAY0801, whether its key differs or matches. All joins at the level share a second, separate set, so an event may appear once in that first set and once in a join. The check compares event names exactly as written (case-sensitive); it does not resolve qualified names or generations. Each `children`, `nested` and variant block starts fresh, and separate projections are independent.
|
|
69
|
+
- Put all mappings for one event into its single `from` block at that projection level. Different events that change the same row may share one comma-separated `from` when their mappings match; otherwise give each its own `from`. A `from` routes its event to one row through its key, so a second `from` for the same event to reach another row is PLAY0801. A `join` updates every matching existing row, and `remove via join` removes matching children from every parent. Needing a second row does not make a second business fact. Emit a separate event only when a second domain fact actually occurs, produced by the command or reaction where it happens; never invent an event only to feed a read model, and a second key does not make a second fact.
|
|
68
70
|
|
|
69
71
|
For each event, write down its event source, its payload and the row it should change before writing the handler. Test two rows that would collide under the wrong key.
|
|
70
72
|
|
package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md
CHANGED
|
@@ -38,7 +38,7 @@ time zone "Europe/Oslo"
|
|
|
38
38
|
| `module <Name>` | Features, free screens, templates, forms, examples | Sets the first address segment. Accepts `description`, `documentation`, `purpose`, `provide`, `available`, `authorize`, `depends on`. |
|
|
39
39
|
| `feature <Name>` | Slices, nested features, free screens, examples | Features nest to any depth; each level adds an address segment. Same members as a module. |
|
|
40
40
|
| `slice <Type> <Name>` | The declarations of one unit of behavior | `<Type>` is `StateChange`, `StateView`, `Automation` or `Translate`. |
|
|
41
|
-
| `depends on <Module[.Feature]>` | — | Authoring metadata, one target per line. Naming itself, an ancestor or a
|
|
41
|
+
| `depends on <Module[.Feature]>` | — | Authoring metadata, one target per line. Naming itself, an ancestor, a descendant or a target that does not resolve warns (`PLAY0554`); a target that matches more than one container warns `PLAY0198`. See Declared dependencies below. |
|
|
42
42
|
| `shows event <Path>` / `shows readmodel <Path>` | — | Slice member. Draws a linked copy of another slice's event or read model on this slice of the board. Presentation only. |
|
|
43
43
|
|
|
44
44
|
Write slices in story order, one whole slice after another, never grouped by kind: the slice that records a fact comes before the slices that project it, react to it or read a view built from it. The compiler reads the model as a timeline (modules in order, a feature's own slices before its sub-features) and reports a consumer placed before its producer as `PLAY0516` (information). Move the slice, or keep the order when the story really runs that way and say why. `PLAY0517` marks a group whose members depend on each other, which no reordering fixes; check whether the group is one slice split in two.
|
|
@@ -47,6 +47,24 @@ An address is `Module.Feature[.SubFeature].Slice.Declaration`. Addresses, not fi
|
|
|
47
47
|
|
|
48
48
|
`concept`, `type`, `policy`, `audience`, `availability`, `purpose`, `persona`, `sink`, `eventsource`, `system`, `secret`, `trigger`, `statemachine`, `workflow`, `seed`, design and layout declarations belong to the application root, not to a slice. A `type` inside a slice is an unknown construct (`PLAY0029`).
|
|
49
49
|
|
|
50
|
+
### Declared dependencies
|
|
51
|
+
|
|
52
|
+
`depends on` is optional metadata that records intended coupling. It does not control execution or ordering, and it does not change the executable model, its revisions or its identities. It is still source text, so editing it changes the MCP source revision like any other edit.
|
|
53
|
+
|
|
54
|
+
- **Resolution.** A bare name searches the declaring container's siblings, then each ancestor's siblings, then root modules, and the nearest match wins: a nearer feature with the same name hides a module. A bare name never finds a feature inside another module. A dotted name matches any container whose address ends with it, so write enough segments to name one container: `<Module>.<Feature>`, and more nesting segments when that is still ambiguous (`PLAY0198`). A full address gets no priority over a longer address that ends with it: if `Billing.Invoices` is both a feature's full address and the end of `Sales.Billing.Invoices`, no dotted spelling names the shorter one alone; only a bare `Invoices` written in another feature of `Billing` reaches it. Otherwise rename a container.
|
|
55
|
+
- **Coverage.** The check runs only for a module or feature that declares at least one dependency. That container's own list must then cover every counted reference leaving it, including references from its descendant features:
|
|
56
|
+
- event triggers;
|
|
57
|
+
- read-model reads;
|
|
58
|
+
- events used by projections, reducers, unique constraints and concurrency event lists;
|
|
59
|
+
- commands invoked by reactions, screen actions and forms;
|
|
60
|
+
- queries a screen shows or a form populates from, and screens it navigates to.
|
|
61
|
+
|
|
62
|
+
Only references written inside slices are counted; forms declared directly on a module are not. References to events owned by an imported bounded context are never counted, whichever construct uses them.
|
|
63
|
+
|
|
64
|
+
The `shows event` and `shows readmodel` slice placements are presentation and are not counted. Neither are specifications. References into the container itself or an ancestor's own slices are ignored. A module target covers all its features. Uncovered references whose producer is unambiguous are grouped by producer module, and each group gives one `PLAY0552` at the container header; a reference whose producer is ambiguous stays provisional and does not warn.
|
|
65
|
+
- **Lists are independent.** A parent's list never satisfies a child's list, and a child's never satisfies the parent's. Complete the child's list, or remove it to stop the child's own check. That stops only the child's check: the parent is checked only if it declares its own dependencies (its check already counts the child's references), and every other container with a list is still checked.
|
|
66
|
+
- Removing every `depends on` line from a container stops its check, and also drops the record of intended coupling. Prefer correcting the list.
|
|
67
|
+
|
|
50
68
|
## Imports and how a model is loaded
|
|
51
69
|
|
|
52
70
|
- **Folder input** compiles every `.play` file below the folder, including scratch files.
|
|
@@ -84,7 +84,8 @@ Each proposal result has a one-paragraph `summary` for reporting. Check the deta
|
|
|
84
84
|
- `orphanedNotes` lists notes whose anchor disappears. A null value with unreadable notes means unknown, not none.
|
|
85
85
|
- `view: "semantic-diff"` shows model-level changes. Read `view: "release-baseline"` when event contracts change and `view: "notes"` for notes proposals.
|
|
86
86
|
- Tool reports: `property.generations`, `moveReport`, `eventRename.mutability` and `eventRename.pinAdded`.
|
|
87
|
-
- `run-specifications` with `proposalId` runs the candidate
|
|
87
|
+
- `run-specifications` with `proposalId` runs the specifications against the retained candidate. If the candidate does not bind, the tool result has `isError: true`, `outcome: "unbound"`, the candidate's `executableDiagnostics` and `executed: 0`.
|
|
88
|
+
- Optional: if `tools/list` includes `visualize-model`, call it with `proposalId` to show the candidate on the board.
|
|
88
89
|
|
|
89
90
|
A valid proposal can still change the wrong thing, so check every changed reference.
|
|
90
91
|
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
## Shared arguments and values
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
`tools/list` returns 47 tools, or 48 when it also includes `visualize-model`. That tool is listed only when both conditions hold: the server was built with the board, and the client advertises the MCP Apps extension (`io.modelcontextprotocol/ui`) in its `initialize` capabilities, including `text/html;profile=mcp-app` if it supplies `mimeTypes`. Otherwise `tools/list` omits it, and calling it returns JSON-RPC error `-32602` (`Unknown tool 'visualize-model'.`) instead of a tool result. Claude Code does not advertise the extension, and changing its server registration does not add it. Names, kinds and enumeration values are case-sensitive. Only `apply` and `recover-workspace` write; every other tool is read-only or keeps an in-memory proposal.
|
|
17
17
|
|
|
18
18
|
| Argument | Shape and values |
|
|
19
19
|
| --- | --- |
|
|
@@ -10,9 +10,10 @@
|
|
|
10
10
|
- Capability manifest
|
|
11
11
|
- Read ESM documents strictly
|
|
12
12
|
- Read newer minor versions while preserving unknowns
|
|
13
|
+
- Evaluate command date comparisons in your own host
|
|
13
14
|
- Direct Stage planning
|
|
14
15
|
|
|
15
|
-
Use
|
|
16
|
+
Use the in-process export APIs only when a .NET tool or test must build handoff artifacts itself; the `screenplay` CLI stays the default for export. The export APIs are in `Cratis.Screenplay`. Names in the examples are illustrative.
|
|
16
17
|
|
|
17
18
|
## Open the model
|
|
18
19
|
|
|
@@ -100,6 +101,17 @@ The whole document is refused for:
|
|
|
100
101
|
|
|
101
102
|
Breaches refuse; nothing is truncated to pass. Admission grants no trust, execution or rendering authority. Check the target's own admission separately, and report any degradation or refusal.
|
|
102
103
|
|
|
104
|
+
## Evaluate command date comparisons in your own host
|
|
105
|
+
|
|
106
|
+
When your host executes Screenplay commands itself, reuse the reference evaluator's date behaviour from `Cratis.Screenplay.Semantics`. Do not compare date text or copy the logic. These helpers have no clock. `SemanticConditionEvaluator.Evaluate` throws `InvalidSemanticContract` when it reaches a comparison that uses `today`, `now` or `date of` (`and` and `or` can short-circuit past one), and `SemanticDateComparisons.Check` cannot resolve a validation rule's clock operand. Execute any command that declares a `calendar`, or uses `today`, `now` or `date of` anywhere, with `SemanticEvaluator` (namespace `Cratis.Screenplay.Semantics.Execution`) instead. This includes a property-only `date of` reduction such as `date of occurred == dueDate`, and a branch that might be skipped.
|
|
107
|
+
|
|
108
|
+
1. Authorize the caller first, so an unauthorized caller never sees a property-specific error. Then, before command validation rules and conditions run, call `SemanticDateComparisons.CheckInputs(application, command, inputs)`. It checks participating `DateTime` properties in declaration order and returns `null` or an `Error` `SemanticValidationFailure` (namespace `Cratis.Screenplay.Semantics.Execution`) for the first property whose text value is not an accepted instant. It checks only the first supplied entry for each property, so a valid entry can hide an invalid duplicate; keep your duplicate-input validation. That covers a missing offset or `Z`, an invalid calendar value such as `2026-02-30T00:00Z`, and any other unaccepted spelling. Absent and non-text values are not checked, so keep your general input type validation. The message is `DateTime command property '<name>' requires an explicit offset or Z.` Reject on that failure even if a condition would short-circuit. Check the original text before a deserializer can attach a local offset; never assume UTC.
|
|
109
|
+
2. Call `SemanticDateComparisons.Participants(application, command)` once and reuse the map as `dateTypes`.
|
|
110
|
+
3. Check each command validation rule with `SemanticDateComparisons.Check(rule, value, dateTypes.GetValueOrDefault(rule.Property))`. Date comparison rules compare chronologically; other rules fall back to the ordinary value-rule check.
|
|
111
|
+
4. Evaluate `require` and `produces when` conditions with `SemanticConditionEvaluator.Evaluate(condition, values, dateTypes)`. That form is only for conditions without read operands. If the command declares protected reads, resolve every one of them after authorization and successful property validation and before any requirement runs, even when no requirement references it. Reject missing required state with `Validation` and `<ReadModel> does not exist.`, and keep decide/commit conflict protection. Passing the values as the fourth argument, `reads`, keyed by read name and then by view property ID, only supplies operand values; without it, reaching a read operand fails. Read operands are admitted only in non-date comparisons; neither side of a date comparison can be a read path. Without the `dateTypes` map, text equality is ordinal and ordering non-numeric operands throws `InvalidSemanticContract`.
|
|
112
|
+
|
|
113
|
+
`Date` compares calendar dates without a time zone. `DateTime` compares UTC instants at tick precision, so different offsets for the same instant are equal. Chronological equality applies only to command comparisons. Specification expectations and read-model keys stay ordinal, and constraints keep their own equality rules (a unique constraint can ignore casing). These APIs do not authorize a caller or execute the command.
|
|
114
|
+
|
|
103
115
|
## Direct Stage planning
|
|
104
116
|
|
|
105
117
|
Use this only when embedding Stage. Keep the accepted full `ExecutableSemanticModel` and its capability-admitted `SemanticExecutionPlan` together; the revision must match. `SemanticExecutionPlan.Compile(model)` reports `Success`, `Plan` and `Issues`; the scoped overload can take selected slice identities without pruning the ESM. Do not treat strict ESM admission as target capability admission.
|
|
@@ -116,7 +116,7 @@ module Rentals
|
|
|
116
116
|
|
|
117
117
|
Check it:
|
|
118
118
|
|
|
119
|
-
1. `screenplay <model-folder> --warnaserror`
|
|
119
|
+
1. `screenplay <model-folder> --warnaserror` with no scope in effect: pass no `--scope`, and confirm with `--print-gate` that the validation gate sets no scope (or pass `--no-gate-file` to bypass the gate deliberately). Only then is it a whole-application check; require exit 0.
|
|
120
120
|
2. `screenplay test <model-folder>` runs every specification in the in-memory reference evaluator; require exit 0 with every specification executed and none unsupported. `--format json` gives a machine-readable report; `--filter <specification-address>` runs one.
|
|
121
121
|
|
|
122
122
|
In an MCP session, use the Screenplay server's read-only `run-specifications` instead of step 2; see Review, compare and apply in `cratis-screenplay-edit-workspace`. Non-event `source` blocks are metadata (`PLAY0270`); specifications supply records without contacting a provider.
|
package/package/corpus/skills/cratis-screenplay-model-translation/references/boundary-diagnostics.md
CHANGED
|
@@ -19,7 +19,7 @@ The compiler checks public/private usage across the whole assembled model. The e
|
|
|
19
19
|
| `PLAY0619` | `source events` appears outside an explicitly inbound translation. | Move the capture to an inbound slice. |
|
|
20
20
|
| `PLAY0620` | A `source events` block is empty, has a line that is not `from <Event>`, an invalid name or a repeated event. | Fix the block. |
|
|
21
21
|
| `PLAY0687` | One `source events` capture reads events from several origins. | Split it into one capture per origin. |
|
|
22
|
-
| `PLAY0694` (warning) |
|
|
22
|
+
| `PLAY0694` (warning) | An unrouted reaction (no `from`) in a directionless Translate slice has a named trigger, and the trigger and a capture append in that slice resolve to the same event declaration or public import. It can fire even when the model has other errors. | The warning does not by itself fail compilation. With `--warnaserror`, the check fails if `PLAY0694` is in the reported diagnostic set; a `--scope` option or a scope inherited from the validation gate can exclude it. Keep the capture; move the reaction to an Automation slice with its own specifications. There is no automatic split. Adding `direction inbound` alone does not fix a reaction to a captured local fact: explicit inbound rejects that input with `PLAY0616`. |
|
|
23
23
|
| `PLAY0700` | A `source events` key is not a required property of every `from` event, or is a `$` context key. | Choose a required key every source event carries. |
|
|
24
24
|
| `PLAY0701` | `given capture` or `when capture` names an events capture. | Use `given <Event>` / `when append <Event>`; a repair exists when the capture has one `from` event. |
|
|
25
25
|
| `PLAY0809` | `is event source` on a capture that is not `source events`, or on a composite key. | Remove the marker or use a single-property key. |
|
|
@@ -15,14 +15,12 @@ compatibility: Requires the Screenplay CLI (`screenplay`) or the Cratis CLI (`cr
|
|
|
15
15
|
- Connect an MCP server
|
|
16
16
|
- Create the first document through MCP
|
|
17
17
|
- Migrate retired source forms
|
|
18
|
-
- Exchange a model with Studio
|
|
19
18
|
- Capability catalog
|
|
19
|
+
- References
|
|
20
20
|
|
|
21
21
|
Names such as `Greenhouse` and `Watering` are illustrative.
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Workspace onboarding uses the same DSL and tools on every stack; the language reference covers embedding the compiler or a `.play` editor in your own code.
|
|
23
|
+
Onboarding uses the same DSL and tools on every stack; see References for embedding the compiler or a `.play` editor in your own code.
|
|
26
24
|
|
|
27
25
|
## How a workspace works
|
|
28
26
|
|
|
@@ -35,12 +33,15 @@ Workspace onboarding uses the same DSL and tools on every stack; the language re
|
|
|
35
33
|
|
|
36
34
|
## Choose the model root
|
|
37
35
|
|
|
38
|
-
Reuse an existing root rather than starting a second application.
|
|
36
|
+
Reuse an existing root rather than starting a second application. Project registrations resolve the root in this order:
|
|
37
|
+
|
|
38
|
+
1. `mcpServers.screenplay.root` in `.cratis/ai.json`: exactly that project-relative folder.
|
|
39
|
+
2. `.cratis/screenplay`, when it holds `.play` files.
|
|
40
|
+
3. The deepest folder holding every `.play` file that discovery finds. Discovery does not descend into folders whose names start with `.`, build and package output (`bin`, `obj`, `node_modules`, `dist`, `out`, `artifacts`, `packages`), linked folders or folders more than ten levels deep, and finds nothing after visiting more than 50,000 entries. These limits only choose the root. The server then compiles every `.play` file under that root as one application, skipping only `.git`, `.ai-work`, `.screenplay`, `bin`, `obj` and `node_modules`, so files in `dist` or `out` are loaded too and conflicting declarations are reported. It refuses any symbolic link under the root outside those folders, so replace linked `.play` files with real files. Configure `root` to serve one of several unrelated models.
|
|
41
|
+
4. When discovery finds no `.play` files, a `Source` or `src` folder that already holds `.screenplay` state. An ordinary code folder is never picked.
|
|
42
|
+
5. Otherwise a `Screenplay` folder at the project root, for a new model. The standalone server also falls back to this folder when it resolves a project.
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
2. A folder holding `.screenplay/identities.json` or `.screenplay/pending.json`. Existing identity state keeps its root.
|
|
42
|
-
3. The common folder of the project's existing `.play` files, for example `.cratis/screenplay` when it holds them.
|
|
43
|
-
4. For a new model, a `Screenplay` folder at the project root. Both MCP servers pick this folder too. Never pick an ordinary code `src` folder.
|
|
44
|
+
When the bundled server resolves a project (`.cratis/ai.json` present or `--project-root`) without a configured `root`, it checks every folder from the project down to the folder chosen above, both included, for `.screenplay` state (identities or an interrupted write). Only the state folder nearest the project is served, even when it holds just an interrupted write. Startup reports identities in deeper folders and ignores them. To work with one of those folders, start a new `cratis screenplay mcp <folder>` server; `open-workspace` cannot switch a running fixed-root server to it. If any other of those folders holds an interrupted write (`pending.json`), startup fails until that write is recovered. Without `.cratis/ai.json` or `--project-root`, the root is bound at `open-workspace` (see Connect an MCP server).
|
|
44
45
|
|
|
45
46
|
Done when exactly one root is named and no other `.play` files sit beneath it unintentionally.
|
|
46
47
|
|
|
@@ -79,10 +80,10 @@ The server is the `screenplay` program speaking MCP over stdio. Choose one launc
|
|
|
79
80
|
- **Native:** command `screenplay`, arguments `mcp` and the absolute model root.
|
|
80
81
|
- **Cratis CLI:** command `cratis`, arguments `screenplay`, `mcp` and the absolute root. This uses the CLI's bundled compiler, so no second tool is needed. Use `--project-root <dir>` or `--project-root-env <variable>` to resolve the root as described in Choose the model root.
|
|
81
82
|
- **Docker:** `docker run -i --rm -v "<absolute host root>:/model" cratis/screenplay mcp /model`. Run `docker pull cratis/screenplay` first so the first start does not time out. On Linux add `--user "$(id -u):$(id -g)"` before the image so that applied files stay writable. Docker silently creates a missing host folder, which shows up as an empty model, so check the host path first.
|
|
82
|
-
- **Project registration:** `cratis ai install` registers the server when the selected profiles include `cratis/screenplay`. In Pi, call `cratis_enable_mcp` with `server: "screenplay"` to make tools available from the next step.
|
|
83
|
+
- **Project registration:** `cratis ai install` registers the server when the selected profiles include `cratis/screenplay`. In Pi, call `cratis_enable_mcp` with `server: "screenplay"` to make tools available from the next step.
|
|
83
84
|
- **Desktop apps:** `cratis screenplay desktop install --clients claude,chatgpt`. Always pass `--clients` when running noninteractively; only an interactive terminal may omit it to pick detected hosts. For ChatGPT, pass `--model-root <existing folder>`. For Claude, name the folder in the conversation. Finish host-owned removal in each host's own UI.
|
|
84
85
|
|
|
85
|
-
A missing physical
|
|
86
|
+
A path passed to `cratis screenplay mcp` overrides `.cratis/ai.json` and must exist; without a path, a configured `root` must exist before startup. Other launches (standalone `screenplay mcp <root>`, a root bound at `open-workspace`, or the bundled server's discovered root) admit a missing physical folder whose parent exists and create it on the first approved write. Standalone `--create-root <dir>` instead creates it at startup. Standalone startup with an existing root configures the editor resolver for that root and can update `screenplay.lock` and the extension cache when `SCREENPLAY_EXTENSION_SOURCE` names a package directory and the model references extensions. Do not assume that a later `open-workspace` restores extensions; restore explicitly if needed.
|
|
86
87
|
|
|
87
88
|
Without a startup root, the server binds one at `open-workspace`:
|
|
88
89
|
|
|
@@ -92,6 +93,8 @@ Without a startup root, the server binds one at `open-workspace`:
|
|
|
92
93
|
|
|
93
94
|
Verify the connection by listing the server's tools. Then ask the assistant to confirm the bound root (`/model` under Docker).
|
|
94
95
|
|
|
96
|
+
The `visualize-model` board is listed only when the server was built with the board and the client advertises the MCP Apps extension (`io.modelcontextprotocol/ui`) when it connects. Claude Desktop and GitHub Copilot in VS Code advertise it; Claude Code, a terminal client, does not, so it receives every authoring tool except the board. If the client lists `mimeTypes` for that extension, the list must include `text/html;profile=mcp-app`. Reinstalling the registration, `--force` or editing it cannot give a client that capability. In such a client, explore the model through text and view the board in an MCP Apps host or the Screenplay VS Code extension. If a client advertises the extension but the board is missing, first check that its `mimeTypes` include that type; only then suspect a server build without the board.
|
|
97
|
+
|
|
95
98
|
## Create the first document through MCP
|
|
96
99
|
|
|
97
100
|
1. Call `open-workspace`. For a new model, pass `applicationName: "Greenhouse"`. The default name is the persisted name, or else the root folder's name, so a `Screenplay` root would be named `Screenplay`. Passing a name that differs from a persisted one is refused with `IdentityStateConflict`. Keep `revision` and `catalogRevision`. Check `readiness.state`:
|
|
@@ -131,12 +134,6 @@ Use this when a diagnostic names `screenplay migrate`, including `PLAY0890`–`P
|
|
|
131
134
|
|
|
132
135
|
For an isolated saved file, VS Code **Screenplay: Migrate document** asks for the source major, replaces the editor text and reports changes and review items in **Screenplay migration** output. Review the edit before saving. Use the CLI for cross-file changes.
|
|
133
136
|
|
|
134
|
-
## Exchange a model with Studio
|
|
135
|
-
|
|
136
|
-
- **Import:** In an open board choose Screenplay file, folder or ZIP. Check the preview's diagnostics and omissions before **Accept & Import**. Check the imported slices and any reported sketch, mockup, image or issue-link losses. Cancel rather than treating a lossy preview as a round trip.
|
|
137
|
-
- **Export:** Choose Screenplay folder for a repository or to carry sketches, mockups, images and issue links. Extract the ZIP intact, read export warnings, and compile the exported model; re-import into an empty project and compare when continuity matters.
|
|
138
|
-
- **Git sync:** Choose a dedicated branch/folder destination; Studio commits the board's files there, replacing whatever the folder holds. Studio never overwrites a repository change it has not seen: when the folder changed since its last commit, it stops committing and lists **Files that differ**. Then import the repository's version through import preview, or confirm committing the board's version on top (the repository's change stays in history). Enable the import offer if repository edits should come back. Reconcile elsewhere first if both changes must survive. **Stop syncing** (after confirmation) only stops future commits; nothing already committed is removed.
|
|
139
|
-
|
|
140
137
|
## Capability catalog
|
|
141
138
|
|
|
142
139
|
Toolchain and hosting:
|
|
@@ -144,17 +141,10 @@ Toolchain and hosting:
|
|
|
144
141
|
- `screenplay version` (or `--version`), `screenplay help`: identify the installed compiler; show usage.
|
|
145
142
|
- `dotnet tool install --global Cratis.Screenplay.Tool` / `dotnet tool update --global Cratis.Screenplay.Tool`: install or update the standalone tool (needs the latest .NET SDK).
|
|
146
143
|
- `cratis/screenplay` Docker image: the same program without a local .NET.
|
|
147
|
-
- Compiler as a library and browser editor support: embed the compiler in your own tool, or host a `.play` editor in a web page (SDK-specific; see the language reference).
|
|
148
144
|
- `cratis version`: the Cratis CLI's bundled compiler version.
|
|
149
|
-
- `cratis screenplay validate [<path>]`: check with the CLI's bundled compiler before Stage delivery; exit `0` valid, `1` invalid input or scope, `5` validation failed. Options belong to `cratis-screenplay-accept-model`.
|
|
150
145
|
- `code --install-extension cratis.screenplay`: VS Code board and diagnostics beside the source.
|
|
151
146
|
- VS Code User settings `screenplay.repairs.enabled`, `.executable`, `.arguments`, `.modelRoot`: opt into typed repairs, choose the approved bridge executable and launch arguments, and bind one physical root. Workspace-level overrides are refused.
|
|
152
|
-
- `screenplay <path
|
|
153
|
-
- `screenplay test <path>`: run model specifications in process.
|
|
154
|
-
- `screenplay restore <folder>`: pin referenced extensions in `screenplay.lock` and restore their contracts.
|
|
155
|
-
- `screenplay migrate <path> --from <source-major>`: rewrite retired source forms forward.
|
|
156
|
-
- `screenplay contract`: print the language and tool contract, for tooling.
|
|
157
|
-
- See [command selection and flags](references/cli.md) for CLI options, desktop verbs and delivery commands.
|
|
147
|
+
- `screenplay <path>`, `test`, `restore`, `migrate`, `contract` and `cratis screenplay validate`: see References for options and exit codes.
|
|
158
148
|
|
|
159
149
|
Server launch and registration:
|
|
160
150
|
|
|
@@ -162,29 +152,10 @@ Server launch and registration:
|
|
|
162
152
|
- `cratis screenplay mcp [<path>] | --project-root <dir> | --project-root-env <variable>`: the server hosted by the CLI. With no argument and `.cratis/ai.json` present, it uses the configured root.
|
|
163
153
|
- `cratis ai install`: project-local registration when the Screenplay profile is selected.
|
|
164
154
|
- `mcpServers.screenplay.enabled: false`: opt out in `.cratis/ai.json`.
|
|
165
|
-
- `mcpServers.screenplay.root`: override discovery with
|
|
166
|
-
- `
|
|
167
|
-
|
|
168
|
-
- `
|
|
169
|
-
- `cratis screenplay desktop status`: inspect local registration and available updates, not whether a host enabled the integration.
|
|
170
|
-
- `cratis screenplay desktop uninstall`: remove the CLI-owned integration; remove the host-owned plugin or extension in the app.
|
|
171
|
-
|
|
172
|
-
MCP tools used while onboarding:
|
|
173
|
-
|
|
174
|
-
- `open-workspace`: bind a disk root or open a portable snapshot; use returned revisions for later operations.
|
|
175
|
-
- `syntax-schema`: discover the language contract before writing typed edits.
|
|
176
|
-
- `workspace-state`: inspect identities, notes, baselines and interrupted writes; page exact identity state when needed.
|
|
177
|
-
- `propose-source`: propose whole-document creates, replacements, moves, key changes or removals.
|
|
178
|
-
- `read-proposal`: review paged changes, exact before/after bytes, diagnostics and identity or contract consequences.
|
|
179
|
-
- `discard-proposal`: drop a reviewed but unwanted plan without writing.
|
|
180
|
-
- `apply`: write an approved proposal against its original base.
|
|
181
|
-
- `read-workspace`: page workspace inventory, diagnostics, identities or portable contracts.
|
|
182
|
-
- `recover-workspace`: roll back the reported interrupted operation with explicit approval.
|
|
183
|
-
- `export-workspace`: page a portable snapshot for transfer or backup; identity continuity on disk does not depend on exporting.
|
|
184
|
-
- `migrate`: preview the migration report and request one document's migrated source without writing.
|
|
185
|
-
- `recommend-layout`: ask for layout advice as the model grows.
|
|
186
|
-
- `expand-layout`: propose a canonical single, module, feature or slice layout (`cratis-screenplay-edit-workspace`).
|
|
187
|
-
- Every other MCP tool (reading, typed edits, renames, specifications, the `visualize-model` board): `cratis-screenplay-edit-workspace`.
|
|
155
|
+
- `mcpServers.screenplay.root`: override discovery with a slash-separated project-relative directory such as `models/billing`, without backslashes, `..`, host placeholders or symbolic links. `.` serves the whole project as one model with the bundled CLI server, but the Pi harness rejects it. Set it only here: generated client entries pass just the project folder, and the server reads the root from this file. For an enabled server with at least one supported client registration, a successful `cratis ai install`/`update` creates the folder but no `.play` files; `--dry-run` leaves the project unchanged. When no path is passed, a configured root that does not exist fails server startup, so after changing or moving it run `cratis ai update` or create the folder first.
|
|
156
|
+
- `cratis screenplay desktop install|update|status|uninstall`: manage desktop-app integration (see References).
|
|
157
|
+
|
|
158
|
+
MCP tools used while onboarding: `open-workspace`, `syntax-schema`, `workspace-state`, `propose-source`, `read-proposal`, `discard-proposal`, `apply`, `read-workspace`, `recover-workspace`, `export-workspace`, `migrate`, `recommend-layout` and `expand-layout` (see References). Every other MCP tool (reading, typed edits, renames, specifications, the `visualize-model` board): `cratis-screenplay-edit-workspace`.
|
|
188
159
|
|
|
189
160
|
Application-root directives (declare each once, in the root document only; a repeat or a non-root placement is an error):
|
|
190
161
|
|
|
@@ -199,3 +170,10 @@ File directives:
|
|
|
199
170
|
- `import "<path-or-glob>"`: compose documents when using a file entry point; place it in the intended module or feature to place the imported declarations there.
|
|
200
171
|
- `import <Qualified.Contract>`: name an external contract, not a file.
|
|
201
172
|
- `import <Qualified.Event> from "<origin>"`: record a public event contract's origin in source. This form does not bind for execution (`PLAY0268`).
|
|
173
|
+
|
|
174
|
+
## References
|
|
175
|
+
|
|
176
|
+
- `references/<language>.md` for the project's SDK (`.csproj` → csharp, Node server `package.json` → typescript, `*.kt` → kotlin, `*.java` → java, `go.mod` → go, `mix.exs` → elixir; only the project's languages are installed): read it to embed the compiler in your own tool or host a `.play` editor in a web page.
|
|
177
|
+
- [Command selection and flags](references/cli.md): read it for standalone and Cratis CLI options, delivery commands and desktop integration verbs.
|
|
178
|
+
- [Workspace request catalog](references/workspace-mcp.md): read it for the arguments, views and paging of each workspace MCP tool.
|
|
179
|
+
- [Exchange a model with Studio](references/studio.md): read it before importing into, exporting from or Git-syncing a Studio board.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Exchange a model with Studio
|
|
2
|
+
|
|
3
|
+
- **Import:** In an open board choose Screenplay file, folder or ZIP. Check the preview's diagnostics and omissions before **Accept & Import**. Check the imported slices and any reported sketch, mockup, image or issue-link losses. Cancel rather than treating a lossy preview as a round trip.
|
|
4
|
+
- **Export:** Choose Screenplay folder for a repository or to carry sketches, mockups, images and issue links. Extract the ZIP intact, read export warnings, and compile the exported model; re-import into an empty project and compare when continuity matters.
|
|
5
|
+
- **Git sync:** Choose a dedicated branch/folder destination; Studio commits the board's files there, replacing whatever the folder holds. Studio never overwrites a repository change it has not seen: when the folder changed since its last commit, it stops committing and lists **Files that differ**. Then import the repository's version through import preview, or confirm committing the board's version on top (the repository's change stays in history). Enable the import offer if repository edits should come back. Reconcile elsewhere first if both changes must survive. **Stop syncing** (after confirmation) only stops future commits; nothing already committed is removed.
|
|
@@ -103,7 +103,7 @@ Every line belongs inside a `specification` unless it says otherwise. Value line
|
|
|
103
103
|
### Scenario structure
|
|
104
104
|
|
|
105
105
|
- `specification <Name>`: in a slice, addressed `<Module>.<Feature>.<Slice>.<Name>`; in a `statemachine` or `workflow`, `<Declaration>.<Name>`; a slice's graph specification, `<Slice>.<Name>`.
|
|
106
|
-
- `description "<text>"`, or a fenced `text` block: states the rule this scenario witnesses. It is report-only
|
|
106
|
+
- `description "<text>"`, or a fenced `text` block: states the rule this scenario witnesses. It is report-only (informational `PLAY0270`).
|
|
107
107
|
- `file <path>`: the repository-relative file that realizes the specification.
|
|
108
108
|
- `example <Name> : <Command | Event | ReadModel>`: a named, possibly partial fixture holding property values, an optional `for` and optional `generated` values. Declare it at slice, feature, module or document level.
|
|
109
109
|
- Using an example: put its name where a type name would go in `given`, `given readmodel`, `when`, `when append`, `then` or `then readmodel`. One override can follow on the same line (`when Pottery seats = 0`); further overrides are indented. An override replaces the whole value. Examples cannot supply callers, clocks, query rows, responses, triggers or captures.
|
|
@@ -127,7 +127,7 @@ Every line belongs inside a `specification` unless it says otherwise. Value line
|
|
|
127
127
|
- `given <System>.<Ability> returns` (with fields), `answers <Outcome>` or `fails "<reason>"`: what an ability call answers while a reaction runs.
|
|
128
128
|
- `given capture <Capture>` with record fields: the record a non-event capture last saw for a key.
|
|
129
129
|
- `given graph <Graph>` with `has node <Label> <key>` and `has edge <TYPE> from <source> to <target> [identified by <value>]`: graph state that exists before the action.
|
|
130
|
-
- `given operation <Name> fails`, `then operation <Name>`, `then compensated <Name>`:
|
|
130
|
+
- `given operation <Name> fails`, `then operation <Name>`, `then compensated <Name>`: parse, but no executable model admits them (`PLAY0268`); never use them for acceptance.
|
|
131
131
|
|
|
132
132
|
### Actions (at most one)
|
|
133
133
|
|
|
@@ -145,7 +145,7 @@ Every line belongs inside a `specification` unless it says otherwise. Value line
|
|
|
145
145
|
|
|
146
146
|
### Event outcomes
|
|
147
147
|
|
|
148
|
-
- `then <Event | Example>` with `for` and required values: one expected new fact. State the complete count and order. After `when append`,
|
|
148
|
+
- `then <Event | Example>` with `for` and required values: one expected new fact. State the complete count and order. After `when append`, omitting them skips this comparison; which facts stated ones cover is in Comparing outcomes in [scenarios](references/scenarios.md).
|
|
149
149
|
- `tag <value>` (repeatable) or `no tags` under a `then` event: the event's exact tags, or no tags at all. To set a payload property named `tag`, write `@tag`.
|
|
150
150
|
- `stream <Source>.<Stream>`: the route of an occurrence on `given`, `when append`, `then`, an event example or a redelivery locator.
|
|
151
151
|
- A keyed stream takes `streamId = <literal>`. A composite stream takes a bare `streamId` block of part assignments.
|
|
@@ -160,10 +160,10 @@ Every line belongs inside a `specification` unless it says otherwise. Value line
|
|
|
160
160
|
### State and query outcomes
|
|
161
161
|
|
|
162
162
|
- `then readmodel <ReadModel | Example> [exactly]` with the key and values: projected state.
|
|
163
|
-
- `then no readmodel <ReadModel> for <key>`: no instance exists for that scalar key.
|
|
163
|
+
- `then no readmodel <ReadModel> for <key>`: no instance exists for that scalar key in the final state. It passes even for a key that never existed, so to prove a removal, establish the instance in the givens, run the removing action, then assert absence. A `then readmodel` asserting `null` for optional properties (the only ones that accept `null`) asserts an instance that still exists, and an empty `then query` is a separate check. One specification cannot assert both presence and absence for the same read model and key, whether presence comes from `then readmodel` or a read-model `then query` `result` (`PLAY0273`).
|
|
164
164
|
- `then no readmodel <ReadModel> for` with an indented block of `<part> = <value>` assignments: no instance exists for that composite key; state every named part.
|
|
165
165
|
- `then query <Query> [exactly]` with an `arguments` block and repeated `result [exactly]` blocks: the rows a caller gets. Without a refusal expectation, no `result` means zero rows. Use one comparison mode for all rows.
|
|
166
|
-
- `then query <GraphQuery> [exactly]`: assert rows against the graph snapshot,
|
|
166
|
+
- `then query <GraphQuery> [exactly]`: assert rows against the graph snapshot, not a read-model query; collected properties take structured values.
|
|
167
167
|
- `then result [exactly]` (repeatable) or `then no result`: the rows of a `when query`.
|
|
168
168
|
- `then graph <Graph>` with `has node`, `has edge`, `no node` and `no edge`: graph state. Properties go only under `has`.
|
|
169
169
|
|
|
@@ -202,13 +202,7 @@ Write these inside the `statemachine` or `workflow`. The full process semantics
|
|
|
202
202
|
- `screenplay test [path] [--filter <address>] [--format json]`: a folder is one application; a file runs with its imports only.
|
|
203
203
|
- `--filter` takes one exact, case-sensitive address or semantic id. A table address runs every case; `<Specification>_<Case>` one.
|
|
204
204
|
- Exit codes: `0` all selected passed (possibly zero); `1` at least one failed; `2` invalid input or selection; `3` the model did not bind, or nothing failed but something was unsupported.
|
|
205
|
-
- MCP `run-specifications`: use when working through a model workspace; with no selector it runs all executable specifications.
|
|
206
|
-
- `specification`: select an exact address or semantic id, including a table or an individual case.
|
|
207
|
-
- `scope`: select a module, feature or slice and its descendants; combined selectors intersect.
|
|
208
|
-
- `proposalId`: run the outstanding proposal instead of the current model.
|
|
209
|
-
- `limit`: bound the page size (1–200); totals and overall outcome cover the complete selection.
|
|
210
|
-
- `offset`: for continuation, pass `page.nextOffset` with the same selectors and, if used, the same `proposalId`. Rows are sorted by address; oversize responses are refused, not truncated.
|
|
211
|
-
- `expectedSourceRevision`: required at nonzero `offset`; echo the first response's `sourceRevision` (the candidate revision for a proposal). On `StaleSourceRevision`, restart from the first page. Check for the intended passing addresses across all pages.
|
|
205
|
+
- MCP `run-specifications`: use when working through a model workspace; with no selector it runs all executable specifications. Its selectors and paging are in [running through MCP](references/running-mcp.md).
|
|
212
206
|
|
|
213
207
|
## Off the default path
|
|
214
208
|
|
|
@@ -235,6 +229,8 @@ Read `references/<language>.md` for the project's SDK (`.csproj` → csharp, Nod
|
|
|
235
229
|
## Avoid
|
|
236
230
|
|
|
237
231
|
- Writing `then no events` for a refusal. It asserts a successful action.
|
|
232
|
+
- Leaving a slice specification without graph steps and without any `then`. It does not bind. In an ordinary slice specification, write `then no events` to assert that a successful action produced no new facts; after `when append`, it asserts only that no facts followed the appended event.
|
|
233
|
+
- Leaving a graph specification without `then graph` or a graph `then query`, the only outcomes it checks. A `given graph` step (not owning a graph or appending its input event) makes one, and it binds without a `then` but checks nothing.
|
|
238
234
|
- Inferring the destination from a payload field. Assert `for` on the expected event.
|
|
239
235
|
- Asserting another slice's events. Move that assertion to the owning slice, and use `then invokes` here.
|
|
240
236
|
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Running specifications through MCP
|
|
2
|
+
|
|
3
|
+
Use the read-only MCP `run-specifications` tool when you work through a model workspace. With no selector, it runs all executable specifications.
|
|
4
|
+
|
|
5
|
+
- `specification`: select an exact address or semantic id, including a table or an individual case.
|
|
6
|
+
- `scope`: select a module, feature or slice and its descendants; combined selectors intersect.
|
|
7
|
+
- `proposalId`: run the outstanding proposal instead of the current model.
|
|
8
|
+
- `limit`: bound the page size (1–200); totals and overall outcome cover the complete selection.
|
|
9
|
+
- `offset`: for continuation, pass `page.nextOffset` with the same selectors and, if used, the same `proposalId`. Rows are sorted by address; oversize responses are refused, not truncated.
|
|
10
|
+
- `expectedSourceRevision`: required at nonzero `offset`; echo the first response's `sourceRevision` (the candidate revision for a proposal). On `StaleSourceRevision`, restart from the first page.
|
|
11
|
+
|
|
12
|
+
Check that every intended address passed, across all pages.
|
|
@@ -214,9 +214,9 @@ specification HarbourIsFull
|
|
|
214
214
|
|
|
215
215
|
## Comparing outcomes
|
|
216
216
|
|
|
217
|
-
- **New facts.** `then <Event>` lines must match the complete count of new facts, in authored order. `then events in any order` relaxes only the order. With other actions, omitting event assertions expects no new facts, even beside state or response assertions. After `when append`, omitting events skips that comparison
|
|
217
|
+
- **New facts.** `then <Event>` lines must match the complete count of new facts, in authored order. `then events in any order` relaxes only the order. With other actions, omitting event assertions expects no new facts, even beside state or response assertions. After `when append`, omitting events skips that comparison. Stated events cover only the facts that followed the appended event when the model compiles to a semantic version that runs reactions, as any model with automation does; an earlier version compares them against the appended event itself. `then no events` always excludes the appended event. In an ordinary slice specification, use `then no events` when zero new facts is the promise. A slice specification without graph steps and with no outcome at all does not bind: omitting every `then` is not a no-event assertion. (A `given graph` step makes it a graph specification instead: it binds without a `then`, but then it checks nothing. A graph specification checks only `then graph` and graph `then query`.)
|
|
218
218
|
- **Event content.** State every required property (`PLAY0524`). `for` checks the occurrence's source, not a payload field. Tags and routes are checked only when stated, including the `no tags` and `no stream` forms.
|
|
219
|
-
- **Read models.** The key selects one instance. `then readmodel` compares stated properties; `exactly` also disallows additional properties. `then no readmodel` checks only the named key; other instances may survive.
|
|
219
|
+
- **Read models.** The key selects one instance. `then readmodel` compares stated properties; `exactly` also disallows additional properties. `then no readmodel` checks only the named key; other instances may survive, so assert a survivor with its own `then readmodel`. If computing the read model needs a reducer with opaque transitions that the runner cannot execute, the run is unsupported, not passed.
|
|
220
220
|
- **Read-model query rows.** Count must be exact; order does not matter, and rows are matched by read model and key. State only relevant properties unless exact matching is part of the contract. A missing property is not an asserted `null`.
|
|
221
221
|
- **Refusals.** State at most one and no success outcomes. `then error` covers contract, validation, constraint or generated-identity conflict; a query error must be Validation. A supplied message must match. `then denied` matches authorization denial only. Neither checks the rule's severity.
|
|
222
222
|
- **Givens are history.** Establish and project them before the action; compare only facts that follow the action. A `given` event without `for` belongs to the source the action acts on. If its projection needs the event's identity and cannot resolve it, the scenario is unsupported. Set `for` when the location matters.
|
|
@@ -19,7 +19,7 @@ Applies to `CommandScenario<TCommand>` with `Cratis.Arc.Testing.Commands` and, f
|
|
|
19
19
|
|
|
20
20
|
Set everything here before the first `Execute` or `Validate`. The caller and pinned generated values cannot change after that call.
|
|
21
21
|
|
|
22
|
-
- **History.** `_scenario.Given.ForEventSource(id).Events(first, second)` supplies the events the command's read models are built from. For a per-stream model, add `.OnRoute(route)` before `.Events(...)`, resolving the route from `_scenario.EventRoutes`.
|
|
22
|
+
- **History.** `_scenario.Given.ForEventSource(id).Events(first, second)` supplies the events the command's read models are built from. For a per-stream model, add `.OnRoute(route)` before `.Events(...)`, resolving the route from `_scenario.EventRoutes`. Routed seeds need decision mode, which a command declaring a per-stream or other protected decision dependency uses automatically; in ordinary mode `.OnRoute(...)` makes `.Events(...)` throw `RoutedEventSeedingRequiresDecisionReads`. In decision mode one shared log holds the seeds, reads and appends, so seed only through `Given`: `_scenario.EventScenario` throws there. In an ordinary scenario these seeds control the read models injected into the command and are separate from the event log: `_scenario.EventScenario.Given` fills only the log, which the handler's event-log reads and constraints see, and events the command appends never reach these seeds. When the command needs both, seed the same facts in both places. Observable queries combine both histories, so facts seeded in both places are processed twice when observed.
|
|
23
23
|
- **A fixed read model.** `_scenario.Given.ForEventSource(id).ReadModel(instance)` pins the instance the command receives. A pin wins over seeded events for that model and key. It cannot back a `DecisionRead<T>` parameter (`PinnedReadModelCannotProvideDecisionToken`) or a per-stream model; seed events for those.
|
|
24
24
|
- **The caller.** `.WithClaims(new Claim(ClaimTypes.Role, "Dispatcher"))` runs the command as an authenticated caller with those claims, `.WithPrincipal(principal)` uses an existing `ClaimsPrincipal`, and `.Unauthenticated()` runs it anonymously. These set the principal authorization reads; they do not exercise login or token validation.
|
|
25
25
|
- **Server-generated values.** `_scenario.PinGeneratedValue("orderId", id)` fixes a generated parameter so the spec can assert it. When the exact value is irrelevant, call `.AllowGeneration()`. With neither, `Execute` returns a result carrying a `GeneratedValueNotPinned` exception instead of running the command.
|
package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md
CHANGED
|
@@ -133,4 +133,10 @@ var other = events.Single(_ => _.Context.SequenceNumber == kept.SequenceNumber);
|
|
|
133
133
|
|
|
134
134
|
- `scenario.Time.Advance(duration)` and `scenario.Time.AdvanceTo(instant)` move the scenario clock forward; `Now` reads it. It starts at 2026-01-01T00:00:00Z, never moves backward (a negative duration or an earlier instant throws `ScenarioTimeCannotMoveBackwards`), and supplies the default occurrence time of appended events and the timestamps of effect receipts. Advancing it never delivers work or fires timers.
|
|
135
135
|
- `new Defaults(artifacts, serviceProvider, options, time)` builds explicit defaults: `artifacts` is an `IClientArtifactsProvider`, for which `InMemoryClientArtifactsProvider` lets a spec list exactly the `EventTypes`, `Projections`, `ModelBoundProjections`, `Reducers`, `Reactors`, `UniqueConstraints` and other artifact types in play. Use it when discovery over the loaded assemblies picks up artifacts the spec must not see, or when several scenarios share one clock. `Defaults.Instance` is the discovered default. A scenario that needs the schema of an event type or generation missing from those artifacts fails with `EventSchemaNotDiscovered`; add that type and generation to the provider.
|
|
136
|
+
- When the code under test checks the store name or namespace, give the test store that identity: `new Defaults(artifacts, serviceProvider, options, time, eventStoreName, namespaceName)` with an `EventStoreName` and an `EventStoreNamespaceName` (`time` may be `null`). Pass those defaults to `ReactorScenario`, `ReadModelScenario` or `OccurrenceScenario`, and the store each scenario creates takes that store name and namespace. Other `Defaults` give store `testing` in namespace `default`. Limits:
|
|
137
|
+
- A `ReactorScenario` given an explicit `eventStore` uses that store's identity instead. `EventStoreForTesting` takes names only in its full constructor `(serviceProvider, artifacts, options, time, eventStoreName, namespaceName)`, where `time` is a non-null `ScenarioTime`; no constructor takes the names alone. Prefer the `Defaults` above.
|
|
138
|
+
- Redelivered occurrences and events passed to `ProcessAppendedEvents` keep the store name and namespace of their original contexts.
|
|
139
|
+
- An occurrence handler receives the namespace in `OccurrenceContext.Namespace`, but no store name.
|
|
140
|
+
- `EventScenario` never takes its identity from `Defaults` (without explicit names it uses `test-event-store` in `default`): pass the names with `new EventScenario(defaults, eventSequenceId, eventStoreName, namespaceName)`.
|
|
141
|
+
- Matching names alone never share storage: each store a scenario creates is private. To share events, share one store explicitly; see [csharp-read-models.md](csharp-read-models.md#share-or-isolate-the-in-memory-store).
|
|
136
142
|
- `RoundDownTicks()` on `DateTimeOffset`, `DateTime` and `TimeOnly` trims a value to the precision a stored event keeps, so an expected timestamp compares equal after a round trip.
|
|
@@ -27,7 +27,8 @@ Use the xUnit fixtures from `Cratis.Chronicle.XUnit.Integration.v3`; a project o
|
|
|
27
27
|
- `ChronicleInProcessFixture` hosts the kernel in the test process with MongoDB in a container. Start with it.
|
|
28
28
|
- `ChronicleOutOfProcessFixture` runs the kernel in a separate container. Use it when the promise depends on the kernel being a separate process.
|
|
29
29
|
- Register a consumer-owned xUnit collection: for an in-process suite, define `ChronicleCollection : ICollectionFixture<ChronicleInProcessFixture>` with `[CollectionDefinition(Name)]`, where `Name` is a constant unique to the collection. Put `[Collection(ChronicleCollection.Name)]` on the spec class. If using a custom fixture, register that type instead.
|
|
30
|
-
- `UsesPerContextMongoDBHost` defaults to `false`. Override it on
|
|
30
|
+
- `UsesPerContextMongoDBHost` defaults to `false`. Override it on a collection fixture derived from `ChronicleInProcessFixture` and register that fixture for the collection; every context in that collection then gets a fresh host and unique database prefix. The default storage configuration applies the prefix. If the client fixture overrides `GetStorageConfigurator`, pass its `DatabaseNamePrefix` to `WithMongoDB` as `databaseNamePrefix` so contexts do not share storage. One host per context adds startup cost; the switch does not isolate out-of-process or remote kernels.
|
|
31
|
+
- A context's `EventTypes`, `Reactors` and other artifact overrides need no extra isolation: the shared in-process host switches to the current context's lists and rediscovers them. `ChronicleOptions.ExplicitArtifacts` is different. Configure it before the fixture host starts: a store snapshots it when the store is created, and by default every class deriving from the same closed `ChronicleClientFixture<TChronicleFixture>` shares one host, so a store that host already created ignores later changes. Another context class over the same `TChronicleFixture` argument is not enough. To give a context different `ExplicitArtifacts`, close the client fixture over a different `TChronicleFixture` type, or run it in a collection whose fixture overrides `UsesPerContextMongoDBHost => true`; a store created on a new host takes its own snapshot.
|
|
31
32
|
|
|
32
33
|
A spec has two classes. The context derives from the integration `Specification<TFixture>(fixture)`, overrides `EventTypes` and `Reactors` to name what it registers, and arranges and acts once. The spec class derives from `Given<TContext>`, which hands it that initialized context as `Context`; its facts only assert.
|
|
33
34
|
|
|
@@ -99,7 +100,7 @@ When the repository keeps specs inside the application assembly, follow its conv
|
|
|
99
100
|
|
|
100
101
|
Edge cases, each an override on the context:
|
|
101
102
|
|
|
102
|
-
- `
|
|
103
|
+
- `protected override bool ShouldBootstrap => <stable condition>;`: return `false` to skip the context's setup, act and cleanup for a suite tier that is switched off. It is `protected`, unlike the `public` artifact lists, so `public override` does not compile. The collection fixture still starts its container; to avoid that, do not register the collection.
|
|
103
104
|
- `ConfigureHostServices` and `AdditionalHostConfiguration`: services and configuration keys for the in-process kernel rather than the application, for example a naming policy or a sink connection.
|
|
104
105
|
- `GetStorageConfigurator`, `GetStorageHostConfiguration`, `GetDefaultSinkTypeId` and `WipeInProcessStorage`: run the in-process kernel on storage other than MongoDB.
|
|
105
106
|
|
package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md
CHANGED
|
@@ -15,7 +15,20 @@ Names are illustrative; the application's own domain language replaces them.
|
|
|
15
15
|
|
|
16
16
|
`ReactorScenario<TReactor>` (namespace `Cratis.Chronicle.Testing.Reactors`) activates the reactor from `scenario.Services` and hands it each event once.
|
|
17
17
|
|
|
18
|
-
- Register fakes in `scenario.Services` before the first event.
|
|
18
|
+
- Register fakes in `scenario.Services` before the first event. `Services` resolves constructor dependencies and service-typed handler parameters, and already includes logging, so `ILogger<T>` needs no registration. If you pass a pre-built `IServiceProvider` to the constructor, `Services` is ignored: register every dependency in that provider instead, or drop it and use `Services`.
|
|
19
|
+
- A reactor class that does not implement `IReactor` must be nominated in the scenario's `Defaults`, together with every event type it handles and every event type it returns, because `InMemoryClientArtifactsProvider` (`Cratis.Chronicle.Testing`) starts empty:
|
|
20
|
+
|
|
21
|
+
```csharp
|
|
22
|
+
var options = new ChronicleOptions();
|
|
23
|
+
options.ExplicitArtifacts
|
|
24
|
+
.RegisterEventType<ParcelHeld>()
|
|
25
|
+
.RegisterEventType<CustomerNotified>()
|
|
26
|
+
.RegisterReactor<ParcelNotifier>();
|
|
27
|
+
var scenario = new ReactorScenario<ParcelNotifier>(new Defaults(new InMemoryClientArtifactsProvider(), null, options));
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Without the reactor nomination the constructor throws `InvalidExplicitArtifact`; an unregistered event type throws `TypeIsNotAnEventType` on delivery. A public method shaped as a handler (a registered event type, optionally followed by `EventContext` or `ReactorDelivery`) throws `InvalidReactorHandlerReturnType` when its return type is synchronous and unsupported, for example an unregistered event type. `void`, any `Task` (including `Task<T>`), a registered event type, `EventForEventSourceId`, `EventsWithConcurrencyScopes`, sequences of registered events, `EventForEventSourceId` or `object`, and any type a side-effect handler claims all pass. Events returned inside `EventForEventSourceId` are recorded without registration. With the default recorder (no explicit `IReactorSideEffectHandlers` passed to the constructor), a returned bare event whose type is not registered appears in `Produced` but not in `ProducedEvents`, so the ordered and destination assertions do not see it. Create new options and defaults for each independent run and never change `Defaults.Instance`: each scenario store keeps the registrations it had when it was created.
|
|
31
|
+
- A reactor that checks `EventContext.EventStore` or `EventContext.Namespace` sees the identity of the scenario's store, by default `testing` in namespace `default`. Pass `Defaults` built with the expected store and namespace, or an explicit `eventStore` that has them; its identity wins over the defaults. `Redeliver` keeps the occurrence's original context. See [csharp-events.md](csharp-events.md#control-time-and-artifacts).
|
|
19
32
|
- `await scenario.Given.ForEventSource(id).Events(...)` delivers the events. It does **not** build read models.
|
|
20
33
|
- A reactor method that takes a read model needs it declared: `scenario.Given.ForEventSource(id).ReadModel(instance)` or `.NoReadModel<T>()` for a deliberate `null`. Omitting both throws `ReadModelNotSeededForReactorScenario`, for nullable and non-nullable parameters alike; its message lists the keys already seeded for that type. When the reactor implements `ICanResolveReadModelKey`, seed or declare absence under the key it returns, not the triggering event source id.
|
|
21
34
|
- That guard applies to a parameter whose type has a discovered projection or reducer and that resolves to `null`, in the scenario's own store or an `EventStoreForTesting` passed as the constructor's `eventStore`. With any other explicit `IEventStore` the guard is off: the parameter is whatever that store resolves, and a scenario that seeded a read model throws `CannotSeedReadModelWithExplicitEventStore` when it delivers. Do not expect the missing-seed failure there.
|
|
@@ -77,7 +90,7 @@ The scenario delivers a given only when it matches the reactor's `[EventSourceTy
|
|
|
77
90
|
|
|
78
91
|
## ReactionSlice
|
|
79
92
|
|
|
80
|
-
`ReactionSlice<TReactor>` (namespace `Cratis.Chronicle.Testing.Slices`) is the given/run/then shape: `new ReactionSlice<T>()` (or with `Defaults`), `.GivenEvents(id, events)`, `await Run()`, then chain `Then.ShouldHaveProducedEventsInOrder(...)`, `.ShouldHaveProducedEventsInAnyOrder(...)`, `.ShouldNotHaveProducedEvents()` or `.Should(scenario => ...)`. `Scenario` exposes the underlying `ReactorScenario<T>` for services, read models or history. Use the scenario directly for redelivery, pages or stream coordinates.
|
|
93
|
+
`ReactionSlice<TReactor>` (namespace `Cratis.Chronicle.Testing.Slices`) is the given/run/then shape: `new ReactionSlice<T>()` (or with `Defaults`), `.GivenEvents(id, events)`, `await Run()`, then chain `Then.ShouldHaveProducedEventsInOrder(...)`, `.ShouldHaveProducedEventsInAnyOrder(...)`, `.ShouldNotHaveProducedEvents()` or `.Should(scenario => ...)`. `Scenario` exposes the underlying `ReactorScenario<T>` for services, read models or history. Use the scenario directly for redelivery, pages or stream coordinates. The slice is `IDisposable`, not `IAsyncDisposable` like the command `Slice<TCommand>`: dispose it with `void Destroy() => _slice.Dispose();`. Disposing it disposes its scenario. After that, `GivenEvents`, `Run` and `Then` throw `SliceDisposed`; another `Dispose` does nothing, and `Scenario` still returns the disposed scenario, so do not use it.
|
|
81
94
|
|
|
82
95
|
## Occurrence scenario
|
|
83
96
|
|