@cratis/pi 7.158.0 → 7.158.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.
Files changed (37) hide show
  1. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/SKILL.md +7 -0
  2. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authorization.md +73 -0
  3. package/package/corpus/skills/cratis-documentation-writing/SKILL.md +43 -127
  4. package/package/corpus/skills/cratis-documentation-writing/references/writing-guidance.md +110 -0
  5. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/public-events-and-direction.md +21 -0
  6. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +6 -0
  7. package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +54 -126
  8. package/package/corpus/skills/cratis-screenplay-command-surface/references/compliance.md +6 -0
  9. package/package/corpus/skills/cratis-screenplay-command-surface/references/concepts-and-types.md +38 -0
  10. package/package/corpus/skills/cratis-screenplay-command-surface/references/generated-values-and-responses.md +19 -0
  11. package/package/corpus/skills/cratis-screenplay-command-surface/references/policy-persona-seed.md +61 -0
  12. package/package/corpus/skills/cratis-screenplay-command-surface/references/validate-rules.md +7 -0
  13. package/package/corpus/skills/cratis-screenplay-command-surface/verification.json +1 -5
  14. package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +21 -8
  15. package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +3 -3
  16. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/principles.md +1 -1
  17. package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +51 -97
  18. package/package/corpus/skills/cratis-screenplay-projections/references/mapping-sources.md +33 -0
  19. package/package/corpus/skills/cratis-screenplay-projections/references/outbound-every.md +12 -0
  20. package/package/corpus/skills/cratis-screenplay-projections/references/reducers.md +40 -0
  21. package/package/corpus/skills/cratis-screenplay-projections/references/stage-admission.md +18 -0
  22. package/package/corpus/skills/cratis-screenplay-projections/verification.json +2 -3
  23. package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +61 -134
  24. package/package/corpus/skills/cratis-screenplay-read-surface/references/passive.md +78 -0
  25. package/package/corpus/skills/cratis-screenplay-read-surface/references/performer-bodies.md +29 -0
  26. package/package/corpus/skills/cratis-screenplay-read-surface/references/query-execution.md +21 -0
  27. package/package/corpus/skills/cratis-screenplay-read-surface/references/screen-levels.md +51 -0
  28. package/package/corpus/skills/cratis-screenplay-read-surface/verification.json +5 -2
  29. package/package/corpus/skills/cratis-screenplay-reverse-engineering/references/synthesis-rules.md +7 -4
  30. package/package/corpus/skills/cratis-screenplay-slice-design/references/rule-layers.md +21 -0
  31. package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +15 -0
  32. package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +12 -2
  33. package/package/corpus/skills/cratis-screenplay-toolchain/verification.json +1 -0
  34. package/package/corpus/skills/cratis-writing-voice-and-cadence/SKILL.md +7 -122
  35. package/package/corpus/skills/cratis-writing-voice-and-cadence/references/voice-guidance.md +139 -0
  36. package/package/corpus/skills/cratis-writing-voice-and-cadence/verification.json +9 -9
  37. package/package.json +1 -1
@@ -8,28 +8,25 @@ license: MIT
8
8
 
9
9
  Read [preferred syntax](../cratis-screenplay-toolchain/references/preferred-syntax.md) when writing or reviewing `.play`.
10
10
 
11
- What the system can be asked, and what a user sees. The `readmodel` declares the
12
- shape, the `query` is the entry point, and the `screen` renders it.
11
+ What the system can be asked and what a user sees: the `readmodel` is the shape,
12
+ the `query` the entry point, the `screen` the rendering.
13
13
 
14
14
  ## Locate the model
15
15
 
16
- Look first for the project's existing `.play` files: the folder holding them is the
17
- model. Reuse existing model/workspace roots; code-only `Source/` or `src/` does
18
- not qualify. Otherwise use repository-root `Screenplay/`, never `.cratis/`
19
- (configuration/shared corpus only). Read [discovery/version gates](../cratis-screenplay-event-modeling/references/file-layout.md#locate-the-model)
20
- when locating the model; do not invent another location.
16
+ The folder holding the project's existing `.play` files is the model; code-only
17
+ `Source/` or `src/` does not qualify. Otherwise use repository-root `Screenplay/`,
18
+ never `.cratis/`. Read [discovery/version gates](../cratis-screenplay-event-modeling/references/file-layout.md#locate-the-model)
19
+ and do not invent another location.
21
20
 
22
- `cratis ai install` manages `.cratis/ai/`, never model files. Never
23
- hand-copy Screenplay source between repositories. Keep Markdown that explains,
24
- questions or navigates the model in the repository's documentation; the `.play`
25
- source is the single flow model.
21
+ `cratis ai install` manages `.cratis/ai/`, never model files. Never hand-copy
22
+ Screenplay source between repositories; the `.play` source is the single flow model.
26
23
 
27
24
  ## Product sources
28
25
 
29
26
  Screenplay `Documentation/screenplay/{queries,readmodels,screens,policies,specifications,interactions,types,vscode}.md`
30
- describe the parser, validator and binder behavior, including which query shapes bind and render
31
- (`Semantics/`). Compilation does not establish query execution. Equality-filter evidence: read
32
- [the sources and compiled example](references/equality-filters.md).
27
+ describe parser, validator and binder behavior, including which query shapes bind and render
28
+ (`Semantics/`). Compilation does not establish query execution. Equality filters: see
29
+ [sources and compiled example](references/equality-filters.md).
33
30
 
34
31
  ## `readmodel` — shape only
35
32
 
@@ -43,23 +40,22 @@ readmodel AccountBalance
43
40
  note String optional
44
41
  ```
45
42
 
46
- A read model declares what it **is** — nothing about what builds it. Whatever
47
- builds it points at it with `=>`, and **exactly one thing may**: two builders is
48
- error `PLAY0191`. See `cratis-screenplay-projections` for the builder side.
43
+ A read model declares what it **is**, not what builds it. The builder points at it
44
+ with `=>`, and **exactly one thing may** (two builders: `PLAY0191`). See `cratis-screenplay-projections` for the builder side.
49
45
 
50
46
  Use trailing `key` on top-level read-model properties, never `identifier`.
51
47
  Explicit marks replace inference; otherwise a single-instance query's `by` supplies
52
48
  identity (all such queries must agree). Only with no single-instance identifier
53
49
  and an admitted list query does the binder infer an unambiguous `*Id`; queryless
54
- read models need an explicit `key`. See named keys below for collection-key exclusions.
55
- One explicit key binds byte-identically to equivalent inference. Several marks
50
+ read models need an explicit `key`. One explicit key binds byte-identically to
51
+ equivalent inference. Several marks
56
52
  form a flat composite key: an optional single-instance query names every part in a
57
53
  `by` block, a list query narrows with equality filters, and fixtures state every part.
58
54
  Requires Screenplay 4.204.0 (ESM v27; `screenplay --version`); older binders refuse
59
55
  several key marks with PLAY0268. A list query over such a read model cannot use a
60
56
  `by` block (PLAY0268).
61
- Read [named keys](references/named-keys.md) for one complete executable example,
62
- trigger/command reads, all-parts fixtures, PLAY0660–0662 and command-read-only PLAY0661 repair.
57
+ Read [named keys](references/named-keys.md) for a complete example, collection-key exclusions,
58
+ trigger/command reads, all-parts fixtures, PLAY0660–0662 and PLAY0661 repair.
63
59
  A `=>` target resolving to an event is an event-target builder, not a read model;
64
60
  keep event and read-model names distinct (see projections' public-event targets).
65
61
 
@@ -70,6 +66,12 @@ No `sink` line means the default sink. `sink <Name>` stores it in a root-declare
70
66
  when `<Name>` is a declared sink, else a property. `@sink <Type>` is always the property.
71
67
  Read [sinks](references/sinks.md) before naming a sink.
72
68
 
69
+ ## Passive read models
70
+
71
+ A bare `passive` line in a read model body marks one that only informs a command's decision.
72
+ It is never inferred, and a query or screen that consumes it is error `PLAY0859`. Read
73
+ [passive read models](references/passive.md) before declaring one.
74
+
73
75
  ## `query`
74
76
 
75
77
  Excerpt: the concepts, the read model and the policy are declared elsewhere.
@@ -83,9 +85,8 @@ query ListInvoices => InvoiceListReadModel[]
83
85
  authorize IsAuthenticated
84
86
  ```
85
87
 
86
- A deliberately public query (no identity needed) uses a policy with `require anonymous`
87
- as its whole authorization, ideally in a separate public module; leaving `authorize` off
88
- is not the same thing. Rules and diagnostics:
88
+ A deliberately public query uses a policy with `require anonymous` as its whole
89
+ authorization, ideally in a separate public module; omitting `authorize` is not the same. Rules and diagnostics:
89
90
  [anonymous policy](../cratis-screenplay-command-surface/references/policy-persona-seed.md#anonymous-policy).
90
91
 
91
92
  **Name the compiler and renderer.** Optional keyed queries and collection queries
@@ -105,9 +106,8 @@ collection, not absent items. Legacy `Type?` reports information `PLAY0479`,
105
106
  which does not fail `--warnaserror`; use a verified repair or editor quick fix.
106
107
 
107
108
  Keep `query Q => observable?` only for a one-shot query returning an optional
108
- scalar type named `observable`. It is the canonical exception and has no
109
- `PLAY0479`: `observable optional` instead means a live result of a type named
110
- `optional`. Do not migrate that exception.
109
+ scalar type named `observable`: the canonical exception, with no `PLAY0479`
110
+ (`observable optional` means a live result of a type named `optional`).
111
111
 
112
112
  ### `by` vs `filter` — and why it is a security decision
113
113
 
@@ -138,18 +138,14 @@ query Everyones => Timesheet[]
138
138
  tenant it runs for unless it says otherwise, so `scoped to global` is how a query
139
139
  *opts out* and reaches past the tenant: the dangerous case is the one you write down.
140
140
 
141
- **The scope is a name, not a closed set.** `identity` and `global` are the two the
142
- language documents, but the grammar accepts any name — what scopes exist follows
143
- the identity model of whatever runs the document. A query declares at most one.
144
-
145
- `scoped to` remains an opaque name, **not** a reference
146
- to a declared identity detail. An `identity` query source must be keyed and return
147
- one result (possibly optional), with a type compatible with the detail; its key
148
- uses only caller built-ins/claims/literals and its effective gate cannot depend
149
- on details (PLAY0641–0646). Source resolution is metadata, not runtime execution.
150
- See command-surface `references/context.md` for the full contract.
141
+ **The scope is a name, not a closed set.** `identity` and `global` are documented,
142
+ but the grammar accepts any name; a query declares at most one.
143
+ `scoped to` is an opaque name, **not** a reference to a declared identity detail. An `identity`
144
+ query source must be keyed and return one result, with a compatible type, a key from caller
145
+ built-ins/claims/literals and a gate that cannot depend on details (PLAY0641–0646). See
146
+ command-surface `references/context.md` for the full contract.
151
147
 
152
- Treat every `scoped to global` in a review as a question to answer, not a detail.
148
+ Question every `scoped to global` in review.
153
149
 
154
150
  ### `observable`
155
151
 
@@ -157,7 +153,7 @@ Treat every `scoped to global` in a review as a question to answer, not a detail
157
153
  pushing; without the marker a query is one-shot, which is the default and what
158
154
  most reads are. The marker qualifies only *how* the result arrives, so it composes
159
155
  with `[]`, `optional`, `by`, `filter`, `authorize` and a `performer`, and a screen binds
160
- to a live query exactly as it binds to a one-shot one. The delivery itself is the
156
+ to a live query exactly as it binds to a one-shot one. Delivery is the
161
157
  target runtime's: the executable model binds `observable` queries (delivery `live`) that
162
158
  have no opaque scope/performer and, when filtered, only admitted caller-supplied equality filters (ESM v14).
163
159
 
@@ -168,9 +164,13 @@ Paging, sorting and change-set delivery for queries are planned but **not in the
168
164
  A query is **complete without a performer** — it is realization metadata, not a
169
165
  precondition. It takes a `file` reference or an inline block in a tagged fence
170
166
  (` ```csharp `, ` ```sql `), and is the query's counterpart to a command's
171
- `handler`. The parser accepts any registered inline language and does not reject
172
- a nonsensical one, so the choice is yours to get right. Built-in inline languages are `csharp`, `typescript`, `react`, `html`, `sql` and `java`. A performer query refuses a `by` or `filter` argument sourced from `$context` with PLAY0810 (C# binding; Requires Screenplay 4.244.0, `screenplay --version`; older compilers silently drop it): take a caller-supplied argument instead. Performer code is opaque:
173
- Screenplay never runs it. It is reported as information `PLAY0270` and left out of the executable model; a specification that reads it is left out while every other specification still runs. Older compilers refuse it with PLAY0268: see the [version gate](../cratis-screenplay-toolchain/references/executable-subset.md#code-attachments-what-binds-what-never-does).
167
+ `handler`. The parser accepts any registered inline language (`csharp`, `typescript`, `react`,
168
+ `html`, `sql`, `java`) and rejects none. A performer query refuses a `by` or
169
+ `filter` argument sourced from `$context` with PLAY0810 (older compilers
170
+ silently drop it): take a caller-supplied argument instead. Performer code is opaque: Screenplay never
171
+ runs it. It is reported as information `PLAY0270` and left out of the executable model, with any
172
+ specification that reads it. Older compilers refuse it with PLAY0268: see the
173
+ [version gate](../cratis-screenplay-toolchain/references/executable-subset.md#code-attachments-what-binds-what-never-does).
174
174
 
175
175
  A read model a performer composes needs no projection, and no event builds it.
176
176
  Specify it from state with `given readmodel`, then `when query <Query>` with the
@@ -178,61 +178,24 @@ arguments and `then result` - see `cratis-screenplay-specifications`.
178
178
 
179
179
  #### Performer bodies are rendered
180
180
 
181
- Reach for a performer body when the declarative query cannot say what the read needs, for
182
- example a filter relative to today: clock operands are syntax-only in query filters, so the
183
- body computes it. Attach the body with `file` (or an inline `csharp` fence):
184
-
185
- ```screenplay excerpt
186
- query FiguresInRegion => InvoiceFigures[]
187
- filter region String
188
- filter status String optional
189
- performer
190
- file Queries/FiguresInRegion.cs
191
- ```
192
-
193
- The body is synchronous C# that returns the read-model instance (or null) for a single query,
194
- or `IEnumerable<ReadModel>` for a collection. It sees `readModels` (the current collection), the
195
- caller arguments by camelCase name and on `context.Arguments`, and `context.Tenant`,
196
- `context.Identity` and `context.ReceivedAt`, for example
197
- `return readModels.Where(figures => figures.Total > 0);`.
198
-
199
- Stage renders the read model record and the query method with its route, parameters (filters in
200
- declaration order, optional ones defaulted) and the modeled `[Authorize]` policy, and embeds the
201
- verified body in a compile-checked helper; no projection or reducer is needed. Do not hand-write
202
- a supported performer as gap-fill: attach the body to the model and render. An observable
203
- performer, a non-C# body, a missing, changed or hash-invalid body, or a body that does not compile
204
- becomes an explicit implementation gap instead, with a not-fully-runnable marker (see
205
- [bodies and implementation gaps](../cratis-stage-rendering-and-sandbox/references/current-boundaries.md#bodies-and-implementation-gaps)).
181
+ Read [performer bodies](references/performer-bodies.md) when a query needs a body the declarative form cannot say (for example a filter relative to today), or when deciding rendering versus gap-fill.
206
182
 
207
- Requires Stage 4.197.0 to render performer bodies, run directly or through a CLI that bundles it (check with `cratis --version`; CLI 3.100.0 bundles Stage 4.196.0); older versions keep the gap-fill path.
208
183
 
209
184
  A query's key goes on its own `by` line in the body. `query X => RM optional by id Type`
210
185
  on the header line is a declaration error, not a shorthand.
211
186
 
212
187
  ### What runs
213
188
 
214
- These bind: keyed `=> RM optional`, unfiltered collections,
215
- collections narrowed by caller-supplied `by`, and their `observable` forms.
216
- Caller-supplied equality filters on collections select ESM v14 (Requires Screenplay 4.143.0 or later): same-named scalar
217
- primitive/concept/enum properties, same nominal type ignoring optionality, no
218
- `from`, distinct names not repeating `by`. `by` and supplied filters AND together;
219
- optional filters may be omitted, but supplied null is refused. PLAY0268 still
220
- rejects context sources, single-result filters, opaque scope and
221
- a `by` block on a list query (or on a non-optional single result).
222
- Authorization runs before lookup, ANDed with module/feature gates; policies see
223
- only `by`, never filters. Pin denial with `given caller` and `then denied`.
224
- Specs pass `by` and filters by name (PLAY0468 for unknown, repeated or missing
225
- required arguments); collection results match by read model/key regardless of
226
- row order.
227
-
228
- A reducer-built view is keyed by event-source id, so a single-instance `by` of another
229
- nominal type warns `PLAY0690`. Rebuild it as a projection keyed on each `from`: projections
230
- [reducer identity](../cratis-screenplay-projections/references/reducer-identity.md).
189
+ Keyed `=> RM optional`, unfiltered collections, collections narrowed by caller-supplied `by`
190
+ or equality filters (ESM v14) and their `observable` forms bind;
191
+ authorization runs before lookup and policies see only `by`. Pin denial with `given caller`
192
+ and `then denied`. Read [query execution](references/query-execution.md) for the filter rules,
193
+ PLAY0268, PLAY0468 and the reducer-view `PLAY0690` warning.
231
194
 
232
195
  ## `screen` — three levels
233
196
 
234
- The examples below are excerpts: each screen sits in a slice, and the queries,
235
- commands and screens it names are declared elsewhere.
197
+ Excerpts: each screen sits in a slice, and the queries, commands and screens it names are
198
+ declared elsewhere.
236
199
 
237
200
  **Level 1 — intent.** Data and actions; the tool generates the component.
238
201
 
@@ -246,50 +209,14 @@ screen InvoiceList
246
209
  action CancelInvoice
247
210
  ```
248
211
 
249
- **Level 2 — structure.** Named sections, tables and summaries filling a template's
250
- slots.
251
-
252
- ```screenplay excerpt
253
- screen InvoiceDetails
254
- template MasterDetail
255
- sidebar
256
- data InvoiceDetailsReadModel via query GetInvoice by invoiceId
257
- summary InvoiceDetailsReadModel
258
- field invoiceNumber label "Invoice #"
259
- section actions
260
- action CancelInvoice
261
- main
262
- section lineItems
263
- table lineItems
264
- column lineNumber label "#"
265
- column quantity label "Qty"
266
- on row-click navigate to InvoiceLineDetail by lineNumber
267
- ```
268
-
269
- **Level 3 — inline code.** The surrounding Screenplay context supplies the typed
270
- data contract; the inline block receives it as `Props`. Languages: `react`,
271
- `typescript`, `html`, `csharp`.
272
-
273
- Constructs: `title`, `data … via query … [by <param>]`, `action <Command>` with
274
- `label` and `navigate to <Screen> [by <param>]`, `section <name>`,
275
- `table <target>` with `column <property> [label]` and
276
- `on row-click navigate to <Screen> [by <param>]`, `summary <ReadModel>` with
277
- `field <property> label`, `template <Name>` with slot bodies, `show <Screen> by <param> from <table>.selection`
278
- in a slot body, and `fits dialog, drawer, pane` (where a State Change screen opens; `cratis-screenplay-ui-composition`).
279
-
280
- The screen's `data` and `action` declarations are the typed context for later UI
281
- composition. Component `context`, toolbar parameters, dialog inputs, slot routes
282
- and manual form columns must all trace back to this screen contract, a form's
283
- command, a selected item, or `$context`. If a generated app shows a default list
284
- or empty panel because it could not consume one of those directives, treat that as
285
- a dropped UI construct, not as an acceptable Level 1 screen.
286
-
287
- `on row-click navigate to …` is the one-line table navigation form. What a click,
288
- selection, submit or screen entry *does* beyond that — confirm, execute, refresh,
289
- open a dialog, branch on success or failure — is an interaction: an inline `on`
290
- block or a named `behavior` attached with `uses`. See
291
- `cratis-screenplay-ui-composition`. Screens and interactions are deferred from the
292
- executable model (information `PLAY0269`); they never block binding.
212
+ **Level 2 — structure** fills a template's slots with named sections, tables and summaries;
213
+ **Level 3 — inline code** receives the typed data contract as `Props` (`react`, `typescript`,
214
+ `html`, `csharp`). A screen's `data` and `action` declarations are the typed context for UI
215
+ composition: if a generated app shows a default list or empty panel because it could not consume
216
+ one of those directives, treat that as a dropped UI construct, not an acceptable Level 1 screen.
217
+ Screens and interactions are deferred from the executable model (information `PLAY0269`); what a
218
+ click or submit *does* is an interaction (`cratis-screenplay-ui-composition`). Read
219
+ [screen levels](references/screen-levels.md) for the Level 2 example and the construct list.
293
220
 
294
221
  ## Guarded screen actions
295
222
 
@@ -339,15 +266,15 @@ binding failures are errors.
339
266
 
340
267
  ## Verify
341
268
 
342
- - [ ] Standalone `screenplay <model> --warnaserror` reports zero errors and zero
343
- warnings; or `cratis screenplay validate --warnings-as-errors` on the model folder
344
- (an older bundled compiler can stop at a lower ESM version). Name which tool produced the result.
269
+ - [ ] Standalone `screenplay <model> --warnaserror` or `cratis screenplay validate --warnings-as-errors`
270
+ reports zero errors and warnings (an older bundled compiler can stop at a lower ESM version). Name the tool.
345
271
  - [ ] Every value the caller must not choose is a `from` parameter, not a `filter`.
346
272
  - [ ] Every `scoped to global` is deliberate and defensible.
347
273
  - [ ] `observable` is present exactly where the caller should see changes without
348
274
  asking again.
349
275
  - [ ] Every authorized query has a specification with `given caller`, including a
350
276
  `then denied` case (a query authorized only by an anonymous policy may omit `given caller`).
277
+ - [ ] No query or screen consumes a `passive` read model (`PLAY0859`); a command reads each one (`PLAY0860`).
351
278
  - [ ] Each read model has exactly one builder and every field traces to an event.
352
279
  - [ ] A reducer-built view's `by` type matches its events' event-source identity (`PLAY0690`).
353
280
  - [ ] No screen reference is left ambiguous or unresolved.
@@ -0,0 +1,78 @@
1
+ # Passive read models
2
+
3
+ ## Contents
4
+
5
+ - When to declare `passive`
6
+ - Syntax
7
+ - What a passive read model is, and is not
8
+ - Diagnostics
9
+ - Compiler support
10
+
11
+ ## When to declare `passive`
12
+
13
+ Declare a read model `passive` only when it exists to inform a command's decision and no query or
14
+ screen shows it. A command names it in `reads`; the realization replays the key's events for each
15
+ decision instead of keeping a stored copy. Without the directive the read model is active, which
16
+ is the default and the right choice for anything a user reads.
17
+
18
+ `passive` is an explicit choice. A read model is never made passive because of how it happens to be
19
+ used, and never made active because a command reads it. Declare it, or leave it out.
20
+
21
+ ## Syntax
22
+
23
+ `passive` is a bare line in the read model body, beside `description`, `file` and `sink`. Excerpt,
24
+ inside a `StateChange` slice:
25
+
26
+ ```screenplay excerpt
27
+ readmodel InvoiceReservationState
28
+ passive
29
+ invoiceId InvoiceId key
30
+ isReserved Bool
31
+ ```
32
+
33
+ The command reads it, and an ordinary projection or reducer builds it; `passive` changes only how
34
+ the read model is realized:
35
+
36
+ ```screenplay excerpt
37
+ command ReserveInvoiceNumber
38
+ reads InvoiceReservationState as reservation by invoiceId
39
+ validate
40
+ require reservation.isReserved == false
41
+ ```
42
+
43
+ Only the exact line `passive` is the directive:
44
+
45
+ - `passive Bool` is a property named `passive`.
46
+ - `passive true`, `passive false` and `readmodel Name passive` are errors.
47
+
48
+ ## What a passive read model is, and is not
49
+
50
+ - Realization is never inferred. The directive is the only way to make a read model passive.
51
+ - It is realization metadata, not behavior: toggling it changes neither the executable model bytes
52
+ nor their revision, and the compiler reports it as information `PLAY0270`. A consumer that keys
53
+ rendering on the revision alone misses the change; see `cratis-screenplay-render-and-gap-fill`.
54
+ - A renderer realizes it as a Chronicle passive projection (no sink, inactive; `[Passive]` in C#),
55
+ so a command's decision read rebuilds one key from that key's events. It trades sink writes for a
56
+ replay per command, which is why it is opt-in.
57
+ - Stage renders a passive read model only when it has no joins, no child or nested scopes and is
58
+ keyed by the event source id; anything else is refused with `STAGE-ESM-061`. Compiler support
59
+ alone does not mean your Stage release renders it: check the Stage release notes.
60
+ - It cannot name a sink (`PLAY0935`): see [sinks](sinks.md).
61
+
62
+ ## Diagnostics
63
+
64
+ | Code | Severity | Cause | Fix |
65
+ | --- | --- | --- | --- |
66
+ | `PLAY0859` | Error | A `query` returns a passive read model (including `[]`, `optional` and `observable` forms), or a `screen` `data` line binds one | Remove `passive` if users read the model; otherwise point the query or screen at an active read model |
67
+ | `PLAY0860` | Warning | No command `reads` the passive read model | Add the intended command read, or remove `passive` |
68
+ | `PLAY0858` | Warning | The `passive` line is repeated | Keep one line |
69
+
70
+ Only the C# compiler reports `PLAY0859` and `PLAY0860`; the TypeScript compiler keeps the directive
71
+ and reports `PLAY0858` only. A clean TypeScript result does not prove that no query or screen
72
+ consumes a passive read model.
73
+
74
+ ## Compiler support
75
+
76
+ Requires Screenplay 5.3.0 (`screenplay --version`). Older compilers do not know the directive: they
77
+ reject syntax JSON that carries `isPassive`, and a bare `passive` line is not a valid property
78
+ there. Remove the line, or re-export the model from a compiler that omits it, before downgrading.
@@ -0,0 +1,29 @@
1
+ # Performer bodies are rendered
2
+
3
+ Reach for a performer body when the declarative query cannot say what the read needs, for
4
+ example a filter relative to today: clock operands are syntax-only in query filters, so the
5
+ body computes it. Attach the body with `file` (or an inline `csharp` fence):
6
+
7
+ ```screenplay excerpt
8
+ query FiguresInRegion => InvoiceFigures[]
9
+ filter region String
10
+ filter status String optional
11
+ performer
12
+ file Queries/FiguresInRegion.cs
13
+ ```
14
+
15
+ The body is synchronous C# that returns the read-model instance (or null) for a single query,
16
+ or `IEnumerable<ReadModel>` for a collection. It sees `readModels` (the current collection), the
17
+ caller arguments by camelCase name and on `context.Arguments`, and `context.Tenant`,
18
+ `context.Identity` and `context.ReceivedAt`, for example
19
+ `return readModels.Where(figures => figures.Total > 0);`.
20
+
21
+ Stage renders the read model record and the query method with its route, parameters (filters in
22
+ declaration order, optional ones defaulted) and the modeled `[Authorize]` policy, and embeds the
23
+ verified body in a compile-checked helper; no projection or reducer is needed. Do not hand-write
24
+ a supported performer as gap-fill: attach the body to the model and render. An observable
25
+ performer, a non-C# body, a missing, changed or hash-invalid body, or a body that does not compile
26
+ becomes an explicit implementation gap instead, with a not-fully-runnable marker (see
27
+ [bodies and implementation gaps](../../cratis-stage-rendering-and-sandbox/references/current-boundaries.md#bodies-and-implementation-gaps)).
28
+
29
+ Requires Stage 4.197.0 to render performer bodies, run directly or through a CLI that bundles it (check with `cratis --version`; CLI 3.100.0 bundles Stage 4.196.0); older versions keep the gap-fill path.
@@ -0,0 +1,21 @@
1
+ # What runs for a query
2
+
3
+ Read this when checking which query forms bind in the executable model, or writing query specifications.
4
+
5
+ These bind: keyed `=> RM optional`, unfiltered collections,
6
+ collections narrowed by caller-supplied `by`, and their `observable` forms.
7
+ Caller-supplied equality filters on collections select ESM v14: same-named scalar
8
+ primitive/concept/enum properties, same nominal type ignoring optionality, no
9
+ `from`, distinct names not repeating `by`. `by` and supplied filters AND together;
10
+ optional filters may be omitted, but supplied null is refused. PLAY0268 still
11
+ rejects context sources, single-result filters, opaque scope and
12
+ a `by` block on a list query (or on a non-optional single result).
13
+ Authorization runs before lookup, ANDed with module/feature gates; policies see
14
+ only `by`, never filters. Pin denial with `given caller` and `then denied`.
15
+ Specs pass `by` and filters by name (PLAY0468 for unknown, repeated or missing
16
+ required arguments); collection results match by read model/key regardless of
17
+ row order.
18
+
19
+ A reducer-built view is keyed by event-source id, so a single-instance `by` of another
20
+ nominal type warns `PLAY0690`. Rebuild it as a projection keyed on each `from`:
21
+ [reducer identity](../../cratis-screenplay-projections/references/reducer-identity.md).
@@ -0,0 +1,51 @@
1
+ # Screen levels and constructs
2
+
3
+ Read this when writing a `screen` beyond the intent level, or choosing which level to use.
4
+
5
+ The examples below are excerpts: each screen sits in a slice, and the queries,
6
+ commands and screens it names are declared elsewhere.
7
+
8
+ **Level 2 — structure.** Named sections, tables and summaries filling a template's
9
+ slots.
10
+
11
+ ```screenplay excerpt
12
+ screen InvoiceDetails
13
+ template MasterDetail
14
+ sidebar
15
+ data InvoiceDetailsReadModel via query GetInvoice by invoiceId
16
+ summary InvoiceDetailsReadModel
17
+ field invoiceNumber label "Invoice #"
18
+ section actions
19
+ action CancelInvoice
20
+ main
21
+ section lineItems
22
+ table lineItems
23
+ column lineNumber label "#"
24
+ column quantity label "Qty"
25
+ on row-click navigate to InvoiceLineDetail by lineNumber
26
+ ```
27
+
28
+ **Level 3 — inline code.** The surrounding Screenplay context supplies the typed
29
+ data contract; the inline block receives it as `Props`. Languages: `react`,
30
+ `typescript`, `html`, `csharp`.
31
+
32
+ Constructs: `title`, `data … via query … [by <param>]`, `action <Command>` with
33
+ `label` and `navigate to <Screen> [by <param>]`, `section <name>`,
34
+ `table <target>` with `column <property> [label]` and
35
+ `on row-click navigate to <Screen> [by <param>]`, `summary <ReadModel>` with
36
+ `field <property> label`, `template <Name>` with slot bodies, `show <Screen> by <param> from <table>.selection`
37
+ in a slot body, and `fits dialog, drawer, pane` (where a State Change screen opens; `cratis-screenplay-ui-composition`).
38
+
39
+ The screen's `data` and `action` declarations are the typed context for later UI
40
+ composition. Component `context`, toolbar parameters, dialog inputs, slot routes
41
+ and manual form columns must all trace back to this screen contract, a form's
42
+ command, a selected item, or `$context`. If a generated app shows a default list
43
+ or empty panel because it could not consume one of those directives, treat that as
44
+ a dropped UI construct, not as an acceptable Level 1 screen.
45
+
46
+ `on row-click navigate to …` is the one-line table navigation form. What a click,
47
+ selection, submit or screen entry *does* beyond that — confirm, execute, refresh,
48
+ open a dialog, branch on success or failure — is an interaction: an inline `on`
49
+ block or a named `behavior` attached with `uses`. See
50
+ `cratis-screenplay-ui-composition`. Screens and interactions are deferred from the
51
+ executable model (information `PLAY0269`); they never block binding.
@@ -14,7 +14,7 @@
14
14
  { "kind": "skill-contains", "value": "filter status InvoiceStatus optional" },
15
15
  { "kind": "skill-contains", "value": "query Q => observable?" },
16
16
  { "kind": "skill-contains", "value": "information `PLAY0479`" },
17
- { "kind": "skill-contains", "value": "Look first for the project's existing `.play` files" },
17
+ { "kind": "skill-contains", "value": "The folder holding the project's existing `.play` files" },
18
18
  { "kind": "skill-contains", "value": "`cratis ai install` manages `.cratis/ai/`, never model files" },
19
19
  { "kind": "skill-contains", "value": "The tenant is the default and stays unstated" },
20
20
  { "kind": "skill-contains", "value": "belongs on a `from` parameter, never on a `filter`" },
@@ -31,6 +31,9 @@
31
31
  { "kind": "skill-contains", "value": "`@sink <Type>` is always the property", "file": "references/sinks.md" },
32
32
  { "kind": "skill-contains", "value": "| `PLAY0935` | Error | A `passive` read model names a sink |", "file": "references/sinks.md" },
33
33
  { "kind": "skill-contains", "value": "The model never names a database", "file": "references/sinks.md" },
34
- { "kind": "skill-contains", "value": "Read [sinks](references/sinks.md) before naming a sink." }
34
+ { "kind": "skill-contains", "value": "Read [sinks](references/sinks.md) before naming a sink." },
35
+ { "kind": "skill-contains", "value": "[passive read models](references/passive.md) before declaring one" },
36
+ { "kind": "skill-contains", "value": "| `PLAY0859` | Error | A `query` returns a passive read model", "file": "references/passive.md" },
37
+ { "kind": "skill-contains", "value": "Requires Screenplay 5.3.0", "file": "references/passive.md" }
35
38
  ]
36
39
  }
@@ -100,10 +100,13 @@ the deliverable; see "Runnability" in [fidelity-check.md](fidelity-check.md)).
100
100
  - **Toggles clear what the inverse clears**: when a probe shows the inverse command reset a
101
101
  field (a completed-at timestamp on reopen), the projection resets it too.
102
102
  - **Ownership and state-reading authorization** ("only the owner may change X"): probe it as
103
- a second caller, record it as an authorization finding, and never drop it. The policy form
104
- admits caller conditions only (`authenticated`, roles); a rule that reads state is not
105
- expressible, so write a `GAP` line citing the open Cratis/Screenplay issues on state-reading
106
- authorization policies (search the tracker for the numbers) and keep the rule as an anchored `question` note. Do not invent syntax.
103
+ a second caller, record it as an authorization finding, and never drop it. Model it as a
104
+ state-reading policy: `reads <Model> as <alias> by <property>` plus a state condition in
105
+ `require` (`article.author == $identity.id`), as in command-surface
106
+ [policies that decide from recorded state](../../cratis-screenplay-command-surface/references/policy-persona-seed.md#policies-that-decide-from-recorded-state).
107
+ Admitted shapes are limited (the caller's identifier is `$identity.id`, compared with `==` or `!=`;
108
+ constants only); a rule outside them is a `GAP` line citing the matching open Cratis/Screenplay issue
109
+ (search the tracker) with the rule kept as an anchored `question` note. Do not invent syntax.
107
110
  - **Cross-field rules** ("a first or a last name"): write a declarative
108
111
  `require <condition>` with a `message`, for example
109
112
  `require firstName != "" or lastName != ""`. A fenced code body is a last resort; its
@@ -10,6 +10,7 @@ code only as XML doc comments (Stage#178): a rule that exists only in prose is u
10
10
  | this command's own inputs | command `validate` / `require` | a rule that applies only sometimes is an implication: `require a == false or b > c` |
11
11
  | who may ask | `authorize` with a policy (role, claim, authenticated) | enclosing gates combine with AND and run first. Gates every command and query in a feature shares go on the feature or module so a new path inherits them |
12
12
  | whose instance | policy `claim "x" matches subject` (the command identifier) or `matches <command property>` | executable; renders for text, Uuid, Date and DateTime subjects; an authorized command needs exactly one identifier (STAGE-ESM-015 otherwise) |
13
+ | whether the caller may act, decided from recorded state (the asset's plan, the article's author) | policy with `reads <Model> [as alias] [by property]` and a state condition in `require`, attached with `authorize` | executable (ESM v44+); an absent read denies. See "State-reading policy or refusal rule" below |
13
14
  | uniqueness, once-only facts | `constraint` (`unique ... on`, `unique event`) | append-time; the constraint name is its identity |
14
15
  | stored state (record exists, balance, current status) | `reads <View>` + `require` with an indented message | opt eligible reads into `command reads protected` (v25); absence Validation, matching intervening facts Conflict. Legacy/refused shapes stay stated intent with a named target mechanism |
15
16
 
@@ -23,6 +24,26 @@ Read [protected command reads](../../cratis-screenplay-command-surface/reference
23
24
  for admission and protected-read rendering (Stage 4.138.0; STAGE-ESM-044 otherwise); never remove protection to obtain rendering. Forbidden: caller-supplied copies of state in `require`, boolean attestation
24
25
  inputs (`confirmsX == true`), rules in `handler` / implementation-hint prose.
25
26
 
27
+ ## State-reading policy or refusal rule
28
+
29
+ Both read recorded state; they answer different questions. Choose by the question and the outcome the caller sees.
30
+
31
+ | Question | Use | Outcome |
32
+ |---|---|---|
33
+ | May this caller act at all, given the state (plan includes the feature, caller is the recorded author, tenant is enabled)? | `policy` with `reads` + `authorize` | `Unauthorized` (`then denied`), before validation and the handler; absent state denies |
34
+ | Is this request acceptable in the current state (balance sufficient, status allows the transition, record exists)? | command `reads <View>` + `require` with an indented message | `Validation` refusal the caller can act on; matching intervening facts are `Conflict` |
35
+ | A list should show each caller only some rows | `narrow <Policy>` on the query | disallowed rows are dropped, not refused |
36
+
37
+ Rules of thumb:
38
+
39
+ - If the denial must not reveal anything about the business state or must apply to every command and query that uses the gate, use the policy. If the user needs an explanation and can fix it, use a refusal rule with a message.
40
+ - The policy is an admission check on a read model that may lag the events; it revokes nothing later. A rule that must hold under concurrent writers (a balance, a capacity, a status transition) is a refusal rule with a protected command read, not a policy.
41
+ - Use `$identity.id` for "only the author" ownership of a recorded entity; use `claim "x" matches subject` when the identifier is on the command and no recorded state is needed.
42
+ - A policy has no write effects and no message; put the business wording in a refusal rule. Declare the read model and projection it reads in the model; a `reads` target that no projection fills always denies.
43
+ - Every state-reading gate gets specifications for: allowed, denied by state, and no recorded state (`then denied`); with `$identity.id`, also another caller and a caller without an identifier.
44
+
45
+ Syntax and fail-closed behavior: `cratis-screenplay-command-surface`, `references/policy-persona-seed.md`. Hand-written counterpart: `StateAwareAuthorizationPolicy<TState>` in `cratis-arc-authentication-authorization-and-identity`.
46
+
26
47
  ## Authorization is executable
27
48
 
28
49
  Persona Does/Reads/Cannot text is intent. Every Cannot line resolves to an `authorize` gate
@@ -20,6 +20,7 @@
20
20
  - Provided values (PLAY1119-PLAY1129)
21
21
  - Audiences and availability (PLAY1130-PLAY1141)
22
22
  - Sinks (PLAY0931-PLAY0939)
23
+ - Passive read models (PLAY0858-PLAY0860)
23
24
  - Structural completeness and timeline checks
24
25
  - Editor versus C# verdicts
25
26
  - Consistency errors (V1: the model contradicts itself)
@@ -401,6 +402,20 @@ is information PLAY0270, outside the ESM. The fixes are in
401
402
  | PLAY0938 | W | A declared sink no read model or graph uses. |
402
403
  | PLAY0939 | W | A read-model property `sink` whose type differs only in case from a declared sink. Spell the sink exactly, or write `@sink <Type>`. |
403
404
 
405
+ ## Passive read models (PLAY0858-PLAY0860)
406
+
407
+ Requires Screenplay 5.3.0 (`screenplay --version`). A bare `passive` line in a read model body
408
+ marks one that only informs command decisions. The fixes are in
409
+ `../../cratis-screenplay-read-surface/references/passive.md`; a passive read model that names a sink is PLAY0935.
410
+
411
+ | Code | Severity | Meaning / fix |
412
+ | --- | --- | --- |
413
+ | PLAY0858 | W | A read model repeats the `passive` line. Keep one. |
414
+ | PLAY0859 | E | A `query` returns a passive read model, or a `screen` `data` line binds one. Only commands may read it: remove `passive` or use an active read model. |
415
+ | PLAY0860 | W | No command `reads` the passive read model. Add the read or remove `passive`. |
416
+
417
+ Only the C# compiler reports PLAY0859 and PLAY0860; the TypeScript compiler reports PLAY0858 only.
418
+
404
419
  ## Structural completeness and timeline checks
405
420
 
406
421
  Opt in with `--check <names>` or MCP diagnostics `checks`, then treat warnings
@@ -373,8 +373,18 @@ bodies still leave their owner non-executable.
373
373
  - The reference runner returns Unsupported for the opaque bodies that do bind (rule and
374
374
  policy predicates, code validation, reducer transitions); a specification that needs one
375
375
  never passes. Attached handlers and file constraints (and reaction effects on a trigger with
376
- `reads`) are different: they leave the whole model unbound, so no specification runs at
377
- all.
376
+ `reads`) are different: under strict binding (`ISemanticModelCompiler.Compile`) they leave the
377
+ whole model unbound, so no specification runs at all.
378
+ - **Admissible compilation is narrower than that.** `CompileAdmissible` (the opt-in
379
+ `IAdmissibleSemanticModelCompiler`) binds the supported subset of a source-valid application
380
+ and lists what it removed in `Exclusions`. A top-level `trigger` that fails to bind is excluded
381
+ (kind `Trigger`, cause `Root`, carrying the original binder diagnostic; it has no code of its own).
382
+ The reactions and specifications it sets off stop binding and are excluded on later passes as
383
+ `Dependent` exclusions whose `DependsOn` names the trigger. Independent slices stay in the
384
+ model. A trigger declared more than once, or named `Startup` or `Shutdown`, is not pruned.
385
+ Requires Screenplay 5.2.0 (`screenplay --version`); earlier compilers drop the whole model for
386
+ one failing trigger. The strict path, and a host that calls only `Compile`, still refuse the
387
+ whole model, so name which compiler a result came from.
378
388
 
379
389
  ## Refused (code, reason): fix, or record as a mode gap
380
390
 
@@ -87,6 +87,7 @@
87
87
  { "kind": "skill-contains", "value": "including `change`, which keeps opaque `where`", "file": "references/diagnostics.md" },
88
88
  { "kind": "skill-contains", "value": "(a `change` keeps it)", "file": "references/preferred-syntax.md" },
89
89
  { "kind": "skill-contains", "value": "| PLAY0935 | E | A `passive` read model names a sink", "file": "references/diagnostics.md" },
90
+ { "kind": "skill-contains", "value": "| PLAY0859 | E | A `query` returns a passive read model", "file": "references/diagnostics.md" },
90
91
  { "kind": "skill-contains", "value": "| PLAY0939 | W | A read-model property `sink`", "file": "references/diagnostics.md" },
91
92
  { "kind": "skill-contains", "value": "`ApplicationSyntax.sinks` (`SinkSyntax` with `name`, `stores`)", "file": "references/executable-subset.md" }
92
93
  ]