@cratis/pi 7.140.0 → 7.141.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/package/corpus/skills/cratis-chronicle-hosting/SKILL.md +7 -0
  2. package/package/corpus/skills/cratis-chronicle-hosting/references/sinks.md +119 -0
  3. package/package/corpus/skills/cratis-chronicle-hosting/verification.json +5 -1
  4. package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +8 -0
  5. package/package/corpus/skills/cratis-chronicle-projection/references/graph-projections.md +25 -0
  6. package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +5 -0
  7. package/package/corpus/skills/cratis-chronicle-read-model/references/sinks.md +133 -0
  8. package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +28 -1
  9. package/package/corpus/skills/cratis-screenplay-model-authoring/verification.json +4 -1
  10. package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +1 -1
  11. package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +4 -3
  12. package/package/corpus/skills/cratis-screenplay-model-review/verification.json +3 -2
  13. package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +6 -1
  14. package/package/corpus/skills/cratis-screenplay-projections/references/graphs.md +56 -0
  15. package/package/corpus/skills/cratis-screenplay-projections/verification.json +4 -1
  16. package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +11 -6
  17. package/package/corpus/skills/cratis-screenplay-read-surface/references/sinks.md +166 -0
  18. package/package/corpus/skills/cratis-screenplay-read-surface/verification.json +7 -1
  19. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +4 -0
  20. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/verification.json +2 -1
  21. package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +1 -1
  22. package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +20 -0
  23. package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +6 -0
  24. package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.json +608 -0
  25. package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.version +1 -1
  26. package/package/corpus/skills/cratis-screenplay-toolchain/verification.json +4 -1
  27. package/package.json +1 -1
@@ -0,0 +1,166 @@
1
+ # Where a read model is stored
2
+
3
+ ## Contents
4
+
5
+ - Default and named sinks
6
+ - Choose a sink
7
+ - A property named `sink`
8
+ - Passive read models have no sink
9
+ - What the deployment and the compiler do with it
10
+ - Diagnostics
11
+
12
+ Requires Screenplay 6.4.0 (`screenplay --version`); older compilers do not know sinks and read
13
+ `sink <Name>` in a read model as a property.
14
+
15
+ ## Default and named sinks
16
+
17
+ A sink is where a read model or a graph is stored. Every application has two implicit sinks, one
18
+ for read models and one for graphs, and anything that names no sink uses the default for its kind.
19
+ Never declare a default sink: a model with no `sink` lines keeps its meaning.
20
+
21
+ Declare a **named** sink only when part of the state belongs somewhere else, such as reporting read
22
+ models in a separate database. Declare each one once, at the application root (beside `concept` and
23
+ `module`, never inside one), with the kind it stores: `sink <Name> for readmodels` or
24
+ `sink <Name> for graphs`. Names are unique across the application, compared ignoring case.
25
+
26
+ The model never names a database, an engine or a connection. The deployment binds each sink name
27
+ to storage, so moving reporting read models to another database changes the deployment, not the
28
+ model.
29
+
30
+ ## Choose a sink
31
+
32
+ A bare `sink <Name>` line in the read model body chooses it, the same way `passive` is a bare
33
+ directive; it may sit anywhere among the body's directives and properties. The model below is
34
+ complete:
35
+
36
+ ```screenplay
37
+ sink Reporting for readmodels
38
+
39
+ concept CustomerId : Uuid
40
+ concept Money : Decimal
41
+
42
+ module Sales
43
+ feature Revenue
44
+ slice StateView CustomerRevenue
45
+ event OrderPlaced
46
+ customerId CustomerId
47
+ amount Money
48
+
49
+ readmodel CustomerRevenue
50
+ sink Reporting
51
+ customerId CustomerId key
52
+ total Money
53
+
54
+ projection CustomerRevenueProjection => CustomerRevenue
55
+ from OrderPlaced key customerId
56
+ add total by amount
57
+
58
+ query RevenueForCustomer => CustomerRevenue optional
59
+ by customerId CustomerId
60
+ ```
61
+
62
+ Nothing else names a sink. The projection writes to `Reporting` because its target is stored
63
+ there, and the query reads from `Reporting` because its read model is. Do not add a sink to a
64
+ projection, reducer or query: what builds or reads a read model follows the read model's sink.
65
+
66
+ ## A property named `sink`
67
+
68
+ A read model has always been able to declare a property called `sink`, so the line is ambiguous on
69
+ its own. `sink <Name>` is the **directive** only when `<Name>` is a sink the application declares,
70
+ spelled exactly as declared, in any file of the model (a declaration in another file counts once the
71
+ files are merged). Otherwise it is a **property** named `sink` of type `<Name>`, as it always was.
72
+
73
+ - `sink Warehouse` with no sink called `Warehouse` declares a property `sink` of type `Warehouse`.
74
+ - `@sink <Type>` is always the property, even when a sink has that name. Write it that way when a
75
+ property's type shares a sink's name; the printer writes it that way too.
76
+ - A collection (`sink Reporting[]`), an optional type or a modifier also makes the line a property.
77
+
78
+ ```screenplay
79
+ sink Reporting for readmodels
80
+
81
+ concept OrderId : Uuid
82
+ concept Warehouse : String
83
+ concept Reporting : String
84
+
85
+ module Shipping
86
+ feature Dispatch
87
+ slice StateView Shipments
88
+ readmodel Shipment
89
+ sink Reporting
90
+ orderId OrderId key
91
+
92
+ readmodel Dispatch
93
+ orderId OrderId key
94
+ sink Warehouse
95
+
96
+ readmodel Audit
97
+ orderId OrderId key
98
+ @sink Reporting
99
+ ```
100
+
101
+ `Shipment` is stored in `Reporting`. `Dispatch` uses the default sink and has a property `sink` of
102
+ type `Warehouse`, because no sink is called `Warehouse`. `Audit` uses the default sink and has a
103
+ property `sink` of type `Reporting`.
104
+
105
+ A property type that differs from a declared sink only in case keeps its meaning but warns, because
106
+ the author probably meant the directive:
107
+
108
+ ```screenplay expect PLAY0939
109
+ sink Reporting for readmodels
110
+
111
+ concept OrderId : Uuid
112
+ concept reporting : String
113
+
114
+ module Shipping
115
+ feature Dispatch
116
+ slice StateView Shipments
117
+ readmodel Shipment
118
+ sink Reporting
119
+ orderId OrderId key
120
+
121
+ readmodel Audit
122
+ orderId OrderId key
123
+ sink reporting
124
+ ```
125
+
126
+ Fix `PLAY0939` by spelling the sink exactly (`sink Reporting`) when the directive was meant, or by
127
+ writing `@sink reporting` when the property was.
128
+
129
+ ## Passive read models have no sink
130
+
131
+ A `passive` read model is never materialized: it is replayed for command decisions, so it has
132
+ nowhere to be stored. Naming a sink on it is error `PLAY0935`; remove the `sink` line, or remove
133
+ `passive` when the read model should be stored.
134
+
135
+ ```screenplay excerpt
136
+ readmodel PendingShipment
137
+ passive
138
+ sink Reporting
139
+ orderId OrderId key
140
+ ```
141
+
142
+ ## What the deployment and the compiler do with it
143
+
144
+ A sink is realization metadata, not part of the executable semantic model (ESM). Adding, removing
145
+ or changing a `sink` line leaves the ESM bytes and its revision unchanged, and the compiler reports
146
+ each one as information `PLAY0270`. A renderer that keys on the ESM revision alone misses a sink
147
+ change: see `cratis-screenplay-render-and-gap-fill`.
148
+
149
+ In Chronicle the same choice is `[Sink("name")]` on the read model type and a `sinks` entry in the
150
+ Kernel configuration (`cratis-chronicle-read-model`, `cratis-chronicle-hosting`).
151
+
152
+ ## Diagnostics
153
+
154
+ | Code | Severity | Cause | Fix |
155
+ | --- | --- | --- | --- |
156
+ | `PLAY0931` | Error | A malformed sink declaration or graph `sink` line, or lines under a declaration | `sink <Name> for readmodels\|graphs` at the root; `sink <Name>` in a body |
157
+ | `PLAY0932` | Error | Two sinks share a name, ignoring case | Rename one |
158
+ | `PLAY0933` | Error | A graph names an undeclared sink | Declare it `for graphs`, or fix the name |
159
+ | `PLAY0934` | Error | A read model names a `for graphs` sink, or a graph a `for readmodels` sink | Name a sink of the right kind |
160
+ | `PLAY0935` | Error | A `passive` read model names a sink | Remove the `sink` line or `passive` |
161
+ | `PLAY0936` | Error | A read model or graph names two different sinks | Keep one |
162
+ | `PLAY0937` | Warning | The same `sink` line repeated | Remove the repeat |
163
+ | `PLAY0938` | Warning | A declared sink nothing uses | Use it or remove the declaration |
164
+ | `PLAY0939` | Warning | A property `sink` whose type differs only in case from a declared sink | Spell the sink exactly, or write `@sink <Type>` |
165
+
166
+ A read model's `sink <Name>` naming no declared sink is never `PLAY0933`: it is a property.
@@ -25,6 +25,12 @@
25
25
  { "kind": "skill-contains", "value": "a `Decimal` part or a concept over `Decimal` is always refused", "file": "references/named-keys.md" },
26
26
  { "kind": "skill-contains", "value": "a replay can split `1.0` and `1.00` into two instances", "file": "references/named-keys.md" },
27
27
  { "kind": "skill-contains", "value": "the decimal refusal lifts with Stage#847 once Chronicle#5427 lands", "file": "references/named-keys.md" },
28
- { "kind": "skill-contains", "value": "`when`/`otherwise` on click, double click, select or change:" }
28
+ { "kind": "skill-contains", "value": "`when`/`otherwise` on click, double click, select or change:" },
29
+ { "kind": "skill-contains", "value": "`sink <Name>` is the **directive** only when `<Name>` is a sink the application declares", "file": "references/sinks.md" },
30
+ { "kind": "skill-contains", "value": "`sink Warehouse` with no sink called `Warehouse` declares a property `sink` of type `Warehouse`", "file": "references/sinks.md" },
31
+ { "kind": "skill-contains", "value": "`@sink <Type>` is always the property", "file": "references/sinks.md" },
32
+ { "kind": "skill-contains", "value": "| `PLAY0935` | Error | A `passive` read model names a sink |", "file": "references/sinks.md" },
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." }
29
35
  ]
30
36
  }
@@ -152,6 +152,10 @@ model still compiles and binds) and its V5 states the scope.
152
152
  with a fresh render under the same inputs. For hand-written scope, `cratis screenplay conform` gives
153
153
  structural code-vs-model evidence (`references/drift-and-fallback-record.md`). For changes since verification,
154
154
  follow that reference's "Hand-written code changed since it was last verified" procedure.
155
+ A sink change does not move `semanticRevision`: sinks are realization metadata outside the ESM,
156
+ so a renderer or drift check must hash `SemanticCompilation.Sinks`, `ReadModelSinks` and
157
+ `GraphSinks` into its render input, or a changed `sink` line never triggers a re-render.
158
+ Map each sink name to deployment storage; never emit a database name from the model.
155
159
  9. **Hand off** the packet: verdict lines, spec mapping, edit requests for the modeler, fallback record
156
160
  entries, UI omissions, learning candidates (at most 3).
157
161
 
@@ -49,6 +49,7 @@
49
49
  { "kind": "skill-contains", "value": "Requires Stage 4.146.0" },
50
50
  { "kind": "skill-contains", "value": "Unsupported generated\ntypes (`STAGE-ESM-028`) and result combinations (`-038`)" },
51
51
  { "kind": "skill-contains", "value": "authored-UI parity" },
52
- { "kind": "skill-contains", "value": "responsible tool version" }
52
+ { "kind": "skill-contains", "value": "responsible tool version" },
53
+ { "kind": "skill-contains", "value": "`GraphSinks` into its render input, or a changed `sink` line never triggers a re-render" }
53
54
  ]
54
55
  }
@@ -184,7 +184,7 @@ unknown apply outcome requires recovery, not retry.
184
184
 
185
185
  All 44 traps, with fixes: `references/traps.md`. Read `references/traps.md` when diagnosing an unexpected compile, binding, rendering or MCP result.
186
186
 
187
- Read [references/diagnostics.md](references/diagnostics.md) when a PLAY, STAGE or CLI-RENDER diagnostic needs its meaning and fix. When the Screenplay documentation and the compiler disagree, follow the compiler for what is accepted, keep the intended semantics in the model, and record the gap.
187
+ Read [references/diagnostics.md](references/diagnostics.md) when a PLAY, STAGE or CLI-RENDER diagnostic needs its meaning and fix. Sink lines (`PLAY0931`–`PLAY0939`) are realization metadata (PLAY0270): a sink change leaves the ESM revision unchanged. When the Screenplay documentation and the compiler disagree, follow the compiler for what is accepted, keep the intended semantics in the model, and record the gap.
188
188
 
189
189
  1. Clean V1 is not executable: only MCP (V2) or `render` binds.
190
190
  2. Prefer inline `produces event` for a command-owned event; plain command productions need explicit `for <identifier>`.
@@ -17,6 +17,7 @@
17
17
  - Guarded interaction diagnostics
18
18
  - UI profile shell: root template, options, appearance
19
19
  - Design systems and themes (PLAY0916-PLAY0930)
20
+ - Sinks (PLAY0931-PLAY0939)
20
21
  - Structural completeness and timeline checks
21
22
  - Editor versus C# verdicts
22
23
  - Consistency errors (V1: the model contradicts itself)
@@ -350,6 +351,25 @@ Requires a Screenplay release that carries design systems (next minor after 6.2.
350
351
  | PLAY0929 | W | `accent`, `corners` or `font` in a profile's `appearance` is deprecated; put the value in the theme. |
351
352
  | PLAY0930 | E | A theme's `implements`, `palette`, `values` or mode block is malformed or repeated. |
352
353
 
354
+ ## Sinks (PLAY0931-PLAY0939)
355
+
356
+ Requires Screenplay 6.4.0 (`screenplay --version`). A `sink <Name> for readmodels|graphs`
357
+ declaration and a `sink <Name>` line in a read model or graph body choose where it is stored; each
358
+ is information PLAY0270, outside the ESM. The fixes are in
359
+ `../../cratis-screenplay-read-surface/references/sinks.md`.
360
+
361
+ | Code | Severity | Meaning / fix |
362
+ | --- | --- | --- |
363
+ | PLAY0931 | E | A malformed sink declaration or graph `sink` line, or lines under a declaration. |
364
+ | PLAY0932 | E | Two sinks share a name, compared ignoring case. Rename one. |
365
+ | PLAY0933 | E | A graph names an undeclared sink. A read model's line naming no declared sink is a property instead. |
366
+ | PLAY0934 | E | A read model names a `for graphs` sink, or a graph a `for readmodels` sink. |
367
+ | PLAY0935 | E | A `passive` read model names a sink; it is never materialized. Remove one of the two. |
368
+ | PLAY0936 | E | A read model or graph names two different sinks. |
369
+ | PLAY0937 | W | A read model or graph repeats the same `sink` line. |
370
+ | PLAY0938 | W | A declared sink no read model or graph uses. |
371
+ | 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>`. |
372
+
353
373
  ## Structural completeness and timeline checks
354
374
 
355
375
  Opt in with `--check <names>` or MCP diagnostics `checks`, then treat warnings
@@ -102,6 +102,12 @@ Requires Screenplay 4.141.0 or later (`screenplay --version`) to bind concept co
102
102
  specifications ending in `then query` or `then readmodel`.
103
103
  - `seed`. Personas, screens and descriptions are PLAY0270/PLAY0269 information, not
104
104
  blocking.
105
+ - Sinks. `sink <Name> for readmodels|graphs` and a body's `sink <Name>` are PLAY0270 realization
106
+ metadata outside the ESM: the ESM bytes and revision do not change with them. A compilation
107
+ exposes them as `SemanticCompilation.Sinks` (declared sinks, defaults never listed),
108
+ `ReadModelSinks` (by read model identity) and `GraphSinks` (by graph name); in the syntax tree as
109
+ `ApplicationSyntax.sinks` (`SinkSyntax` with `name`, `stores`), `ReadModelSyntax.sink` and
110
+ `GraphSyntax.sink`, omitted from JSON when empty. Older tools reject syntax JSON that carries them.
105
111
 
106
112
  ## Text `not empty` reference correction
107
113