@cratis/pi 7.5.1 → 7.5.2

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.
@@ -39,6 +39,26 @@ is not admitted by ESM v1*), and so do reactions and declared triggers. A
39
39
  specification's `when append` never runs reactions either. Model them when the
40
40
  `.play` file is the deliverable; do not promise they execute.
41
41
 
42
+ **Specify what sets them off anyway** (v4.48.0, checked at tag `v4.48.0`, commit
43
+ `3baf4a4`): `when clock "<instant>"` for a reaction on `every` or `at`,
44
+ `when trigger <Trigger>` with its values for one on an application trigger, and
45
+ `given capture` / `when capture <Capture>` with the source record's fields for a
46
+ capture, then the events that should follow. `given clock` fixes the occurrence
47
+ time, so values mapped from `$context.occurred` can be asserted:
48
+
49
+ ```screenplay
50
+ specification ChasingAnOverdueInvoiceOnMonday
51
+ given clock "2026-10-05T07:00:00Z"
52
+ when clock "2026-10-05T07:30:00Z"
53
+ then CollectionsDigestIssued
54
+ issuedAt = "2026-10-05T07:30:00Z"
55
+ ```
56
+
57
+ These actions parse and are checked against the application, but they bind to
58
+ nothing yet: admitting them, and running reactions, is proposed as ESM v6 in
59
+ the Screenplay repository's decision 0022. Report such a specification as
60
+ parsed, not executed.
61
+
42
62
  ## `capture` — the Change Data Capture Language
43
63
 
44
64
  Captures live in `Translate` slices and are the anti-corruption layer: external
@@ -208,6 +208,9 @@ A continuation line extends the clause.
208
208
  - **`produces when <condition>`** takes the event name on the next indented line.
209
209
  Conditions over command properties and constants bind; each is evaluated
210
210
  independently, and when all are false the command is accepted with no events.
211
+ Compare an enumeration with a member bare (`status == sent`) or quoted
212
+ (`status == "sent"`); the bare form binds from v4.48.0, so quote it when a model
213
+ must bind on an older version.
211
214
  Excerpt:
212
215
 
213
216
  ```screenplay
@@ -172,7 +172,37 @@ At the most granular layout, folders mirror the language, one folder per level:
172
172
  one slice, whole. A slice file restates its `module` and `feature`; nothing is
173
173
  written twice.
174
174
 
175
- ⚠️ **Compile the folder as one application.** `screenplay <folder>` merges every
175
+ **Compose focused files with imports** (v4.48.0, checked at tag `v4.48.0`,
176
+ commit `3baf4a4`). `import "<path or glob>"` imports `.play` files relative to
177
+ the importing file - `**` crosses folders, `*` stays in one, `..` climbs. Where
178
+ the import is written decides where the files belong: at the top level it brings
179
+ in whole documents; inside a `module` or `feature` it places each imported file
180
+ there, so a file holds only its part of the story - a slice file is just the
181
+ `slice`. A root file that imports everything says what the application is made
182
+ of:
183
+
184
+ ```screenplay
185
+ domain Acme.Commerce
186
+
187
+ import "Shared/*.play"
188
+ import "Ordering/Ordering.play"
189
+ ```
190
+
191
+ ```screenplay
192
+ module Ordering
193
+ description "Orders, from basket to doorstep"
194
+ feature Orders
195
+ import "Orders/*.play"
196
+ ```
197
+
198
+ Every file is imported once. When a root glob and a module file both match a
199
+ file, the deepest placement wins; two placements where neither lies inside the
200
+ other are an error (`PLAY0457`), and so is a file placed in a module it does not
201
+ restate (`PLAY0459`). `import Customers.CustomerRegistered` without quotes still
202
+ names a contract from another bounded context.
203
+
204
+ ⚠️ **Compile the folder, or its root file, as one application.**
205
+ `screenplay <root file>` compiles what the root imports. `screenplay <folder>` merges every
176
206
  `.play` beneath the root *before* resolving, so an event declared in one file and
177
207
  produced in another resolves. Compiling files individually reports unknown types,
178
208
  events and policies (`PLAY0165`, `PLAY0166`, `PLAY0167`) that are not missing.
@@ -15,11 +15,25 @@ repository is the full list; this page is the authoring summary.
15
15
  `authentication`, `trigger`, `theme`, `layout`, `ui profile`, `behavior`,
16
16
  `module`, `seed`.
17
17
 
18
- **Inside a module:** `description`, `authorize`, `screen`/`dialog` templates,
19
- `form`, `contribute`, `on`/`uses` behavior attachments, `feature`.
20
-
21
- **Inside a feature:** `description`, `authorize`, nested `feature`, `slice`,
22
- `contribute`, `on`/`uses` behavior attachments.
18
+ **Inside a module:** `description`, `authorize`, `import "<glob>"`,
19
+ `screen`/`dialog` templates, `form`, `contribute`, `on`/`uses` behavior
20
+ attachments, `feature`.
21
+
22
+ **Inside a feature:** `description`, `authorize`, `import "<glob>"`, nested
23
+ `feature`, `slice`, `contribute`, `on`/`uses` behavior attachments.
24
+
25
+ **Files (v4.48.0).** `import "<path or glob>"` - quoted - imports `.play` files
26
+ relative to the importing file; unquoted, `import` still names a contract from
27
+ another bounded context. At the top level it brings in whole documents. Inside a
28
+ `module` or `feature` it places each imported file there, and that file's top
29
+ level is the module's or feature's body, alongside any application-level
30
+ declarations it makes. A file matched by several imports is imported once, at the
31
+ deepest placement; conflicting placements (`PLAY0457`), cycles (`PLAY0458`) and
32
+ imports that match nothing (`PLAY0455`, `PLAY0456`) are reported where the import
33
+ is written. `screenplay <file>` compiles the application that file is the root
34
+ of; `screenplay <folder>` treats every file as a root and still places what the
35
+ imports place. The VS Code extension validates a workspace folder the same way,
36
+ as one application.
23
37
 
24
38
  | Slice type | Meaning | Typical contents |
25
39
  | --- | --- | --- |
@@ -131,6 +131,13 @@ precondition. It takes a `file` reference or an inline block in a tagged fence
131
131
  a nonsensical one, so the choice is yours to get right. Performer code is opaque:
132
132
  Screenplay never runs it.
133
133
 
134
+ A read model a performer composes needs no projection, and no event builds it.
135
+ Specify it from state with `given readmodel`, then `when query <Query>` with the
136
+ arguments and `then result` (v4.48.0) - see `cratis-screenplay-specifications`.
137
+
138
+ A query's key goes on its own `by` line in the body. `query X => RM? by id Type`
139
+ on the header line is a declaration error, not a shorthand.
140
+
134
141
  ### What runs
135
142
 
136
143
  In the executable model today, only the keyed snapshot shape binds:
@@ -33,6 +33,12 @@ The worked example below compiles with zero diagnostics, binds to ESM v2, and
33
33
  all six specifications pass the reference runner at that tag. Reverify before
34
34
  claiming another version behaves the same.
35
35
 
36
+ The specification actions beyond commands (`given clock`, `when clock`,
37
+ `when trigger`, `given capture`, `when capture`, `when query`, `then result`,
38
+ `then no result`) were checked against tag `v4.48.0` (commit `3baf4a4`):
39
+ `Documentation/screenplay/{specifications,diagnostics}.md` and the proposed
40
+ decision 0022. They do not exist before v4.48.0.
41
+
36
42
  ## The vocabulary
37
43
 
38
44
  | Construct | Meaning |
@@ -42,6 +48,13 @@ claiming another version behaves the same.
42
48
  | `given caller` | the caller: `authenticated`, `role "<r>"`, repeatable `claim "<type>" = "<value>"`; empty means unauthenticated |
43
49
  | `when <CommandType>` | run a command |
44
50
  | `when append <EventType>` | append one event: constraints and projections run, the command and reactions do not |
51
+ | `when query <Query>` | perform a query with the argument values beneath it (v4.48.0) |
52
+ | `then result [exactly]` | one expected row of the performed query; repeat for several (v4.48.0) |
53
+ | `then no result` | the performed query returns nothing (v4.48.0) |
54
+ | `given clock "<instant>"` | the ISO 8601 instant the scenario happens at (v4.48.0) |
55
+ | `when clock "<instant>"` | the clock reaches an instant; scheduled reactions that are due run (v4.48.0) |
56
+ | `when trigger <Trigger>` | an application trigger fires with the values beneath it (v4.48.0) |
57
+ | `given capture` / `when capture <Capture>` | an earlier and the current record of a capture's source (v4.48.0) |
45
58
  | `then <EventType>` | an expected new event |
46
59
  | `then events in any order` | compare the new events without regard to order |
47
60
  | `then readmodel <ReadModelType> [exactly]` | read-model state afterwards — must state the identifier |
@@ -52,10 +65,23 @@ claiming another version behaves the same.
52
65
  | `for <value>` | the event source of a `given`/`then` event, or of the `when` command or appended event |
53
66
  | `<property> = <value>` | a literal, `null`, or a one-line JSON-shaped object or list: `lines = [{"sku":"A-1","quantity":2}]` |
54
67
 
68
+ From v4.48.0 an enumeration value binds whether it is written bare
69
+ (`status = sent`), qualified (`status = InvoiceStatus.sent`) or quoted, and a
70
+ `DateTime` value binds as a plain ISO 8601 instant (`"2026-10-05T08:00:00Z"`).
71
+ Before v4.48.0 only the quoted member and the full round-trip instant
72
+ (`"2026-10-05T08:00:00.0000000Z"`) bound, although the compiler accepted all of
73
+ them - quote members when a model must bind on older versions.
74
+
55
75
  Rules the binder enforces:
56
76
 
57
- - **At most one action** — `when` or `when append` (`PLAY0358`). Without an
58
- action, assert only `then readmodel` or `then query` (`PLAY0352`).
77
+ - **At most one action** — a command, `when append`, `when clock`, `when trigger`,
78
+ `when capture` or `when query` (`PLAY0097`, `PLAY0358`). Without an action,
79
+ assert only `then readmodel` or `then query` (`PLAY0352`).
80
+ - **`then result` and `then no result` need `when query`**, and `when query`
81
+ needs one of them or `then denied` (`PLAY0465`). Each argument is a `by` or
82
+ `filter` parameter of the query (`PLAY0468`).
83
+ - **A clock instant is ISO 8601 with an offset or `Z`**, such as
84
+ `"2026-10-05T08:00:00Z"` (`PLAY0461`); `given clock` appears at most once.
59
85
  - **`then` contains either events or an error — never both.** A rejection
60
86
  specification has exactly one rejection and no success outcome.
61
87
  - **`then denied` stands alone**: not with events, errors or state assertions
@@ -170,11 +196,10 @@ module Invoicing
170
196
  given readmodel InvoiceSummary
171
197
  invoiceId = "9c858901-8a57-4791-81fe-4c455b099bc9"
172
198
  invoiceNumber = "INV-000001"
173
- then query InvoiceById
174
- arguments
175
- invoiceId = "9c858901-8a57-4791-81fe-4c455b099bc9"
176
- result
177
- invoiceNumber = "INV-000001"
199
+ when query InvoiceById
200
+ invoiceId = "9c858901-8a57-4791-81fe-4c455b099bc9"
201
+ then result
202
+ invoiceNumber = "INV-000001"
178
203
  ```
179
204
 
180
205
  - `RejectingANumberAnotherInvoiceHolds` needs `for`: without it the `given`
@@ -183,7 +208,30 @@ module Invoicing
183
208
  - `ProjectingAnAppendedInvoice` exercises the projection without running the
184
209
  command. Put `for`-bearing specifications in the slice whose command produces
185
210
  the event; placed in the view slice, binding fails with `PLAY0273`.
186
- - `LookingUpAnExistingInvoice` has no action: it checks established state only.
211
+ - `LookingUpAnExistingInvoice` performs the query as its action. It binds to
212
+ exactly what `then query` with `arguments` and `result` would, so on a version
213
+ before v4.48.0 write it that way instead.
214
+
215
+ ## Actions beyond commands
216
+
217
+ A slice is not always set off by a command. Name what does:
218
+
219
+ | Slice | Action |
220
+ | --- | --- |
221
+ | A view no event builds - its query has a `performer` | `given readmodel` …, `when query <Query>`, `then result` / `then no result` |
222
+ | An automation driven by the clock | `given clock "<instant>"`, `when clock "<later instant>"` |
223
+ | An automation driven by an application trigger | `when trigger <Trigger>` with the values it carries |
224
+ | A translation driven by a capture | `given capture <Capture>` (the record as it was), `when capture <Capture>` (as it is now) |
225
+
226
+ `given clock` also fixes the occurrence time of every action in the scenario, so
227
+ a value a `produces` maps from `$context.occurred` can be asserted.
228
+
229
+ **`when query` executes today. The clock, trigger and capture actions do not.**
230
+ They parse, print and are checked against the application, but binding reports
231
+ `PLAY0268` naming the proposed ESM v6 (decision 0022): the executable model does
232
+ not yet admit automation or translate slices, nor the reactions and captures these
233
+ actions drive. Write them - they state what sets the slice off - and report them
234
+ as parsed, not executed.
187
235
 
188
236
  ## Rejections and denials say different things
189
237
 
@@ -248,7 +296,9 @@ target has one normalized behavior to match.
248
296
  - Unsupported reachable declarative constructs block the whole execution plan
249
297
  rather than running partially: no specification in the model runs, including
250
298
  the ones that never touch the refused construct.
251
- - Reactions never run, not even after `when append`.
299
+ - Reactions never run, not even after `when append`. `when clock`,
300
+ `when trigger` and `when capture` fail binding until ESM v6 is accepted and
301
+ built.
252
302
  - A rejection leaves the world unchanged; an accepted action commits once, then
253
303
  the read models and queries are compared.
254
304
 
@@ -273,6 +323,8 @@ For command specifications:
273
323
 
274
324
  For view specifications:
275
325
 
326
+ - [ ] A view a `performer` composes is specified with `given readmodel`,
327
+ `when query` and `then result` or `then no result`.
276
328
  - [ ] `given readmodel` is a complete instance with its identifier.
277
329
  - [ ] `then readmodel` states the identifier and the properties that matter; add
278
330
  `exactly` only when extra properties must fail the assertion.
@@ -34,6 +34,18 @@
34
34
  {
35
35
  "kind": "skill-contains",
36
36
  "value": "Bare `then error` never matches\n a denial"
37
+ },
38
+ {
39
+ "kind": "skill-contains",
40
+ "value": "**`when query` executes today. The clock, trigger and capture actions do not.**"
41
+ },
42
+ {
43
+ "kind": "skill-contains",
44
+ "value": "`then result` and `then no result` need `when query`"
45
+ },
46
+ {
47
+ "kind": "skill-contains",
48
+ "value": "A clock instant is ISO 8601 with an offset or `Z`"
37
49
  }
38
50
  ]
39
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.5.1",
3
+ "version": "7.5.2",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [