@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
@@ -52,6 +52,13 @@ Read [storage resolution](references/storage-resolution.md) when choosing
52
52
  per-namespace destinations, schema/runtime identities, Azure authentication,
53
53
  SQL schemas, or disabling automatic creation.
54
54
 
55
+ Read models and graphs can live apart from the events. The `sinks` section names
56
+ sink configurations (`type` `MongoDB`, `SQL` or `Neo4j`, each with its own
57
+ connection); `sinks.readModels` and `sinks.graphs` replace the defaults (the
58
+ `storage` connection and the `neo4j` server), and clients choose a named sink with
59
+ `[Sink("name")]`. Changing a sink replays the affected read models. Read
60
+ [named sinks](references/sinks.md) before adding or changing the section.
61
+
55
62
  ## Supply certificates before starting production
56
63
 
57
64
  Default TLS needs a PFX certificate with a private key:
@@ -0,0 +1,119 @@
1
+ <!-- Copyright (c) Cratis. All rights reserved. -->
2
+ <!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
3
+
4
+ # Configure named sinks in the Kernel
5
+
6
+ ## Contents
7
+
8
+ - Defaults without a `sinks` section
9
+ - One MongoDB and one SQL sink
10
+ - Read models in another engine than the events
11
+ - Graphs in their own Neo4j servers
12
+ - Environment variables
13
+ - Startup validation and moves
14
+
15
+ Requires Chronicle 19.144.0 for the `sinks` section and for clients that name sinks (check the
16
+ Kernel image tag and the `Cratis.Chronicle` package version).
17
+
18
+ ## Defaults without a `sinks` section
19
+
20
+ Without a `sinks` section the Kernel stores read models through its `storage` connection, with the
21
+ sink type the client chose (`DefaultSinkTypeId`, MongoDB unless changed), and graphs in its `neo4j`
22
+ server. Nothing changes for an existing deployment until the section is added.
23
+
24
+ The section has three members:
25
+
26
+ | Member | Default | Meaning |
27
+ | --- | --- | --- |
28
+ | `readModels` | empty | The configuration a read model naming no sink stores to. Empty keeps `storage` |
29
+ | `graphs` | empty | The configuration a graph naming no sink stores to. Empty keeps `neo4j` |
30
+ | `configurations.<name>` | empty | One named sink: `type` (`MongoDB`, `SQL` or `Neo4j`) and its own connection. Names match without regard to case |
31
+
32
+ `MongoDB` and `SQL` take `connectionDetails`; for `SQL` the engine (PostgreSQL, Microsoft SQL
33
+ Server or SQLite) is read from the connection string. `Neo4j` takes `server` (a bolt URI),
34
+ `userName`, `passwordSecret` (the **name** of the configuration key holding the password, never the
35
+ password), `databaseMode` (`PerNamespace` or `Single`), `databasePrefix`, `singleDatabase` and
36
+ `createIfMissing`. A named MongoDB or SQL sink derives its database names the way `storage` does,
37
+ including `storage.databaseNamePrefix`.
38
+
39
+ ## One MongoDB and one SQL sink
40
+
41
+ The default read-model sink becomes the `primary` MongoDB configuration, and read models that the
42
+ client marks `[Sink("reporting")]` go to PostgreSQL:
43
+
44
+ ```json
45
+ {
46
+ "sinks": {
47
+ "readModels": "primary",
48
+ "configurations": {
49
+ "primary": { "type": "MongoDB", "connectionDetails": "mongodb://mongo:27017" },
50
+ "reporting": { "type": "SQL", "connectionDetails": "Host=pg;Database=reporting;Username=chronicle" }
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ Keep credentials out of the file: supply them through approved configuration, or let
57
+ [storage resolution](storage-resolution.md) resolve the connection. A named SQL or Neo4j sink
58
+ resolves its connection through `storage.connectionResolution` when that is configured; a named
59
+ MongoDB sink uses its `connectionDetails` directly.
60
+
61
+ ## Read models in another engine than the events
62
+
63
+ Named sinks do not depend on event storage. A Kernel on PostgreSQL can keep read models in
64
+ MongoDB, and a Kernel on MongoDB can keep some in PostgreSQL:
65
+
66
+ ```json
67
+ {
68
+ "storage": { "type": "postgresql", "connectionDetails": "Host=pg;Database=chronicle;Username=chronicle" },
69
+ "sinks": {
70
+ "readModels": "documents",
71
+ "configurations": {
72
+ "documents": { "type": "MongoDB", "connectionDetails": "mongodb://mongo:27017" }
73
+ }
74
+ }
75
+ }
76
+ ```
77
+
78
+ The configuration's `type` decides the engine, so a read model naming a `SQL` sink is stored in
79
+ SQL even when the client's `DefaultSinkTypeId` is MongoDB.
80
+
81
+ ## Graphs in their own Neo4j servers
82
+
83
+ ```json
84
+ {
85
+ "sinks": {
86
+ "graphs": "people",
87
+ "configurations": {
88
+ "people": { "type": "Neo4j", "server": "bolt://people-graph:7687", "userName": "chronicle", "passwordSecret": "NEO4J_PASSWORD" },
89
+ "organization": { "type": "Neo4j", "server": "bolt://organization-graph:7687" }
90
+ }
91
+ }
92
+ }
93
+ ```
94
+
95
+ ## Environment variables
96
+
97
+ The same keys under the `Cratis__Chronicle__` prefix:
98
+
99
+ ```bash
100
+ Cratis__Chronicle__Sinks__ReadModels=primary
101
+ Cratis__Chronicle__Sinks__Configurations__primary__Type=MongoDB
102
+ Cratis__Chronicle__Sinks__Configurations__primary__ConnectionDetails=mongodb://mongo:27017
103
+ Cratis__Chronicle__Sinks__Configurations__reporting__Type=SQL
104
+ Cratis__Chronicle__Sinks__Configurations__reporting__ConnectionDetails=Host=pg;Database=reporting;Username=chronicle
105
+ ```
106
+
107
+ ## Startup validation and moves
108
+
109
+ The Kernel refuses to start, naming the configuration, when a `type` is not `MongoDB`, `SQL` or
110
+ `Neo4j`; a `MongoDB` or `SQL` entry has no `connectionDetails` or a `Neo4j` entry no `server`;
111
+ `readModels` or `graphs` names a missing configuration; or `readModels` names a `Neo4j` entry or
112
+ `graphs` a `MongoDB`/`SQL` one. A client registering a read model whose `[Sink]` names no
113
+ configuration is refused with `UnknownSinkName`.
114
+
115
+ Changing `readModels` or `graphs` moves every read model or graph that names no sink. When their
116
+ clients register again, the Kernel replays them into the new sink under the
117
+ `observers.definitionEvolution` policy (`Manual` records a replay recommendation instead). Plan
118
+ the replay time and the new database's capacity before changing it in production: a move is a
119
+ replay from the event log, not a data copy.
@@ -9,6 +9,10 @@
9
9
  { "kind": "skill-contains", "value": "clustering.type=MongoDB" },
10
10
  { "kind": "skill-contains", "value": "directly in persistent storage" },
11
11
  { "kind": "skill-contains", "file": "references/operations.md", "value": "single globally ordered job step" },
12
- { "kind": "skill-contains", "file": "references/operations.md", "value": "GetSequenceNumberError.NotFound" }
12
+ { "kind": "skill-contains", "file": "references/operations.md", "value": "GetSequenceNumberError.NotFound" },
13
+ { "kind": "skill-contains", "file": "references/sinks.md", "value": "\"reporting\": { \"type\": \"SQL\", \"connectionDetails\": \"Host=pg;Database=reporting;Username=chronicle\" }" },
14
+ { "kind": "skill-contains", "file": "references/sinks.md", "value": "\"primary\": { \"type\": \"MongoDB\", \"connectionDetails\": \"mongodb://mongo:27017\" }" },
15
+ { "kind": "skill-contains", "file": "references/sinks.md", "value": "Cratis__Chronicle__Sinks__Configurations__reporting__Type=SQL" },
16
+ { "kind": "skill-contains", "value": "[named sinks](references/sinks.md) before adding or changing the section." }
13
17
  ]
14
18
  }
@@ -280,6 +280,14 @@ element and a read model (CHR0068). Read
280
280
  [references/graph-projections.md](references/graph-projections.md) for the attributes,
281
281
  fluent builder, operation model, replay and idempotency, and the sinks.
282
282
 
283
+ ## Where the output is stored
284
+
285
+ A projection never names a sink: it writes to its read model's sink, chosen by `[Sink("name")]` on
286
+ the read-model type (or `DefaultSinkName`, then the Kernel default). Moving a read model to another
287
+ sink replays its projections there under the `observers.definitionEvolution` policy. Read
288
+ [read-model sinks](../cratis-chronicle-read-model/references/sinks.md) for the attribute, client
289
+ defaults and `CHR0069`, and [graph projections](references/graph-projections.md#sinks) for graphs.
290
+
283
291
  ## Definition changes replay
284
292
 
285
293
  Read [references/definition-changes.md](references/definition-changes.md) when a changed mapping, key, filter, join or child must replay, or when a corrected mapping does not repair existing counters and joins (replay rebuilds them; deploying alone does not).
@@ -139,6 +139,31 @@ services.Configure<ChronicleOptions>(options =>
139
139
  });
140
140
  ```
141
141
 
142
+ To keep one graph in its own Neo4j server, name a sink configured in the Kernel's `sinks` section
143
+ (`cratis-chronicle-hosting`) with `[Sink("name")]` from `Cratis.Chronicle.Sinks`. Put it on an
144
+ `IGraphProjection` class, or on **every** node and edge of a model-bound graph: elements of one
145
+ graph naming different sinks fail registration with `GraphHasConflictingSinks`. Without it the
146
+ graph uses `ChronicleOptions.DefaultGraphSinkName`, then the Kernel's `sinks.graphs`, then its
147
+ `neo4j` server. Requires Chronicle 19.144.0.
148
+
149
+ ```csharp
150
+ using Cratis.Chronicle.Projections.Graphs;
151
+ using Cratis.Chronicle.Sinks;
152
+
153
+ [Graph("People")]
154
+ [Sink("people")]
155
+ public class PeopleGraph : IGraphProjection
156
+ {
157
+ public void Define(IGraphProjectionBuilder builder)
158
+ {
159
+ // Nodes and edges, as in the fluent graph projection.
160
+ }
161
+ }
162
+ ```
163
+
164
+ A graph naming a read-model sink (`MongoDB` or `SQL`) is refused with
165
+ `SinkConfigurationIsForAnotherKindOfReadModel`. Changing a graph's sink replays it into the new one.
166
+
142
167
  ## Testing and analyzers
143
168
 
144
169
  `GraphScenario` runs a graph projection against the in-memory graph sink:
@@ -78,6 +78,11 @@ public record <ReadModelName>(
78
78
  indexing in the sink, including SQL. `[CompositeIndex]` on the class declares ordered multi-property indexes and
79
79
  `[Index(IsDescending = true)]` declares descending ones. Read
80
80
  [indexing](references/indexing.md) for valid paths, flags and store-specific limits.
81
+ - `[Sink("name")]` (`Cratis.Chronicle.Sinks`) on the read-model type stores it in a named sink the
82
+ Kernel configures, such as a reporting database in another engine; without it the read model uses
83
+ `ChronicleOptions.DefaultSinkName`, then the Kernel default. Never combine it with `[Passive]`
84
+ (`CHR0069`), and expect a replay when the sink changes. Read [sinks](references/sinks.md) before
85
+ choosing one.
81
86
 
82
87
  ### Shape the model for its consumer
83
88
 
@@ -0,0 +1,133 @@
1
+ <!-- Copyright (c) Cratis. All rights reserved. -->
2
+ <!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
3
+
4
+ # Named sinks for read models
5
+
6
+ ## Contents
7
+
8
+ - Default and named sinks
9
+ - Choose a sink with `[Sink]`
10
+ - Client defaults
11
+ - Passive read models have no sink
12
+ - Changing a sink replays
13
+ - Refusals
14
+
15
+ Requires Chronicle 19.144.0 for `[Sink]`, `DefaultSinkName`, `DefaultGraphSinkName`, CHR0069 and
16
+ the Kernel `sinks` configuration (check the `Cratis.Chronicle` package and the Kernel image tag;
17
+ both must be at least that version). Older clients have no `Cratis.Chronicle.Sinks.SinkAttribute`.
18
+
19
+ ## Default and named sinks
20
+
21
+ A sink is where a read model is stored. Without any choice every read model goes to the Kernel's
22
+ default sink: the client's `DefaultSinkTypeId` (MongoDB unless changed) on the Kernel's `storage`
23
+ connection. A **named sink** is a sink type with a connection of its own, configured by name in
24
+ the Kernel's `sinks` section (`cratis-chronicle-hosting`). Use one when some read models belong in
25
+ another database or engine, such as reporting tables in PostgreSQL while the rest stays in MongoDB.
26
+ The client only names the sink; it never carries a connection string.
27
+
28
+ ## Choose a sink with `[Sink]`
29
+
30
+ `Cratis.Chronicle.Sinks.SinkAttribute` goes on the **read model type**, whatever builds it: a
31
+ model-bound read model, one filled by an `IProjectionFor<T>`, or one folded by a reducer. Never put
32
+ it on the projection or reducer class; the builder writes wherever its read model is stored.
33
+
34
+ ```csharp
35
+ using Cratis.Chronicle.Events;
36
+ using Cratis.Chronicle.Keys;
37
+ using Cratis.Chronicle.Projections;
38
+ using Cratis.Chronicle.Projections.ModelBound;
39
+ using Cratis.Chronicle.Reducers;
40
+ using Cratis.Chronicle.Sinks;
41
+
42
+ [EventType]
43
+ public record OrderPlaced(Guid CustomerId, decimal Amount);
44
+
45
+ [EventType]
46
+ public record ShipmentDispatched(Guid OrderId, string Carrier);
47
+
48
+ [Sink("reporting")]
49
+ [FromEvent<ShipmentDispatched>(key: nameof(ShipmentDispatched.OrderId))]
50
+ public record DispatchedShipment([property: Key] Guid OrderId, string Carrier);
51
+
52
+ [Sink("reporting")]
53
+ public record CustomerRevenue([property: Key] Guid CustomerId, decimal Total);
54
+
55
+ public class CustomerRevenueProjection : IProjectionFor<CustomerRevenue>
56
+ {
57
+ public void Define(IProjectionBuilderFor<CustomerRevenue> builder) =>
58
+ builder.From<OrderPlaced>(from => from
59
+ .UsingKey(@event => @event.CustomerId)
60
+ .Add(model => model.Total).With(@event => @event.Amount));
61
+ }
62
+
63
+ [Sink("reporting")]
64
+ public record OrderCount(int Orders);
65
+
66
+ public class OrderCountReducer : IReducerFor<OrderCount>
67
+ {
68
+ public OrderCount OnOrderPlaced(OrderPlaced @event, OrderCount? current, EventContext context) =>
69
+ new((current?.Orders ?? 0) + 1);
70
+ }
71
+ ```
72
+
73
+ The name matches a `sinks.configurations` entry, compared without regard to case. The sink's
74
+ configured `type` decides the engine: a read model naming a `SQL` sink is stored in SQL even when
75
+ the client's `DefaultSinkTypeId` is MongoDB. Queries keep reading through Chronicle's read-model
76
+ APIs; a direct `IMongoCollection<T>` or SQL query must target the database the named sink points
77
+ at, not the Kernel's default storage.
78
+
79
+ Graphs choose a sink the same way: read
80
+ [graph projections](../../cratis-chronicle-projection/references/graph-projections.md#sinks).
81
+
82
+ ## Client defaults
83
+
84
+ To send everything that names no sink to a named sink, set the client defaults. Both are empty
85
+ by default, which leaves the choice to the Kernel's `sinks.readModels` and `sinks.graphs`:
86
+
87
+ ```csharp
88
+ using Microsoft.Extensions.Hosting;
89
+
90
+ public static class Program
91
+ {
92
+ public static void Configure(string[] args)
93
+ {
94
+ var builder = Host.CreateApplicationBuilder(args);
95
+
96
+ builder.AddCratisChronicle(configureOptions: options =>
97
+ {
98
+ options.DefaultSinkName = "reporting";
99
+ options.DefaultGraphSinkName = "people";
100
+ });
101
+ }
102
+ }
103
+ ```
104
+
105
+ The order is: `[Sink]` on the type, then `ChronicleOptions.DefaultSinkName` (or
106
+ `DefaultGraphSinkName` for graphs), then the Kernel's `sinks.readModels` (or `sinks.graphs`), then
107
+ the Kernel's own storage.
108
+
109
+ ## Passive read models have no sink
110
+
111
+ A `[Passive]` read model is never materialized, so it has nowhere to be stored. Combining
112
+ `[Passive]` with `[Sink]` is analyzer error `CHR0069`: remove `[Sink]` to keep it passive, or
113
+ remove `[Passive]` to store it in the named sink. Event targets (a projection or reducer publishing
114
+ to an event sequence) ignore sink names.
115
+
116
+ ## Changing a sink replays
117
+
118
+ Moving a read model to another sink, by a different `[Sink]`, client default or Kernel default,
119
+ rebuilds it there: the Kernel replays the projections and reducers that fill it into the new sink,
120
+ as it does for a changed definition. The
121
+ `observers.definitionEvolution` policy applies, so a `Manual` policy records a replay
122
+ recommendation instead of replaying. A read model whose sink is unchanged is not replayed. Read
123
+ [definition changes](../../cratis-chronicle-projection/references/definition-changes.md) before
124
+ deploying a sink move on a large history.
125
+
126
+ ## Refusals
127
+
128
+ | Failure | Cause | Fix |
129
+ | --- | --- | --- |
130
+ | `CHR0069` (analyzer, error) | `[Passive]` and `[Sink]` on one type | Remove one of them |
131
+ | `UnknownSinkName` at registration | The Kernel has no `sinks.configurations` entry with that name | Add the configuration, or fix the name |
132
+ | `SinkConfigurationIsForAnotherKindOfReadModel` | A read model names a `Neo4j` sink, or a graph a `MongoDB`/`SQL` sink | Name a sink of the right kind |
133
+ | `GraphHasConflictingSinks` | Nodes and edges of one model-bound graph name different sinks | Give every element of the graph the same `[Sink]` |
@@ -23,7 +23,7 @@ repository is the full list; this page is the authoring summary.
23
23
 
24
24
  **Top level:** `domain`, `import`, `concept`, `type`, `policy`, `persona`,
25
25
  `authentication`, `identity`, `purpose`, `trigger`, `design system` (one per application: `modes`, `default theme`, `tokens`, `components`, `words`, `rules`), `theme` (`implements`, `compatible with`, `palette`, `values`, a block per mode), `layout`, `ui profile`, `behavior`,
26
- `module`, `seed`, authoring-only `system`, and admitted `eventsource` with its `stream`s (ESM v8).
26
+ `sink`, `module`, `seed`, authoring-only `system`, and admitted `eventsource` with its `stream`s (ESM v8).
27
27
 
28
28
  **Inside a module:** `description`, `authorize`, `import "<glob>"`,
29
29
  `screen`/`dialog` templates, `form`, `contribute`, `on`/`uses` behavior
@@ -71,6 +71,33 @@ positional pins preserve older bytes/version. Fixtures and conditions
71
71
  still name members. Syntax, stored-number safety and consumer admission:
72
72
  command-surface `references/enum-numbers.md`.
73
73
 
74
+ **Sinks.** `sink <Name> for readmodels` or `sink <Name> for graphs` at the application root
75
+ declares a named sink; a `readmodel` or `graph` body chooses one with a bare `sink <Name>` line,
76
+ and anything that names none uses its kind's default. In a read model the line is the directive
77
+ only when `<Name>` is declared (in any file of the model), otherwise a property named `sink`;
78
+ `@sink <Type>` is always the property, and in a graph every `sink` line is the directive. The model
79
+ never names a database. In the typed syntax, `ApplicationSyntax.sinks` holds `SinkSyntax`
80
+ (`name`, `stores`), and `ReadModelSyntax.sink` and `GraphSyntax.sink` hold the chosen name; JSON
81
+ omits all three when empty, and older tools reject syntax JSON that carries them. `propose-rename`
82
+ on a sink renames its declaration and every directive naming it. Requires Screenplay 6.4.0
83
+ (`screenplay --version`). Syntax, examples and `PLAY0931`–`PLAY0939`: read surface
84
+ [sinks](../../cratis-screenplay-read-surface/references/sinks.md).
85
+
86
+ | Code | Severity | Meaning |
87
+ | --- | --- | --- |
88
+ | `PLAY0931` | Error | Malformed sink declaration or graph `sink` line |
89
+ | `PLAY0932` | Error | Duplicate sink name, ignoring case |
90
+ | `PLAY0933` | Error | A graph names an undeclared sink |
91
+ | `PLAY0934` | Error | The sink's kind does not match the read model or graph |
92
+ | `PLAY0935` | Error | A `passive` read model names a sink |
93
+ | `PLAY0936` | Error | Two different sinks on one read model or graph |
94
+ | `PLAY0937` | Warning | A repeated identical `sink` line |
95
+ | `PLAY0938` | Warning | A declared sink nothing uses |
96
+ | `PLAY0939` | Warning | A read-model property `sink` whose type differs only in case from a declared sink |
97
+
98
+ Each `sink` line is also reported as information `PLAY0270`: realization metadata outside the
99
+ executable model, so the ESM revision does not change with it.
100
+
74
101
  Projections and captures use their dedicated sub-grammars. Inline code uses a
75
102
  tagged fence (` ```csharp `); the older language-line form still parses with
76
103
  warning `PLAY0397`. Query the MCP's `syntax-schema` instead of inventing JSON
@@ -262,6 +262,9 @@
262
262
  "kind": "skill-contains",
263
263
  "value": "Both sides reload",
264
264
  "file": "references/mcp-tools.md"
265
- }
265
+ },
266
+ { "kind": "skill-contains", "value": "`sink`, `module`, `seed`", "file": "references/language-reference.md" },
267
+ { "kind": "skill-contains", "value": "| `PLAY0937` | Warning | A repeated identical `sink` line |", "file": "references/language-reference.md" },
268
+ { "kind": "skill-contains", "value": "`ReadModelSyntax.sink` and `GraphSyntax.sink` hold the chosen name", "file": "references/language-reference.md" }
266
269
  ]
267
270
  }
@@ -191,7 +191,7 @@ Read [references/neighbouring-skills.md](references/neighbouring-skills.md) when
191
191
 
192
192
  ## References (load on demand)
193
193
  - Review public leaks, direction, complete keys and effective routes with [public/key/route checks](references/public-keys-and-routes.md).
194
- - Read `references/checklist.md` when performing the element sweep and phased audit; it contains eleven phases, 89 checks, tiers and evidence sources.
194
+ - Read `references/checklist.md` when performing the element sweep and phased audit; it contains eleven phases, 90 checks, tiers and evidence sources.
195
195
  - Read `references/anti-patterns.md` when investigating an anti-pattern signal.
196
196
  - Read `references/report-template.md` when classifying findings, deciding the verdict, writing the report or conducting a re-review.
197
197
  - Read `references/worked-example.md` when an example of the sweep, lineage or report is needed, or when checking the complete examples: seeded model, filled report, fixed model.
@@ -11,11 +11,11 @@
11
11
  - Phase 7. Rules and their layer (9 checks, E1-E9)
12
12
  - Phase 8. Flow and lifecycle (13 checks, F1-F13)
13
13
  - Phase 9. Personas, reach and authorization (8 checks, G1-G8)
14
- - Phase 10. Views, queries and screens (4 checks, H1-H4)
14
+ - Phase 10. Views, queries and screens (5 checks, H1-H5)
15
15
  - Phase 11. Strategy checks (13 checks, R1-R13)
16
16
  - Closing questions (3, Q1-Q3; each needs an answer in the report; a "no" is a finding)
17
17
 
18
- Eleven phases, 89 checks and three closing questions. Each phase header says how many checks it holds; the report lists
18
+ Eleven phases, 90 checks and three closing questions. Each phase header says how many checks it holds; the report lists
19
19
  every phase with its count and, per check, a status, the element and the evidence
20
20
  (`report-template.md`). Each check names what to look at, the Screenplay evidence source and the
21
21
  tier:
@@ -176,13 +176,14 @@ Nebulit (`provenance.md`).
176
176
  | G7 | Every command and query under an inherited module/feature `authorize` has its own `then denied` spec; authorization shared by a feature is declared at feature/module level so new paths inherit it. `require anonymous` is flagged on anything the business did not name public; it must be the whole authorization, preferably in a separate public module, and is not the same as omitting `authorize` | policies, specs | D (major when it exposes another person's data) |
177
177
  | G8 | Ownership/claim targets are a supported scalar (text, Uuid, Date or DateTime render; a numeric or Boolean target is always denied; other shapes and a command without exactly one identifier are STAGE-ESM-015): noted | policies | C (renderable mode) |
178
178
 
179
- ## Phase 10. Views, queries and screens (4 checks, H1-H4)
179
+ ## Phase 10. Views, queries and screens (5 checks, H1-H5)
180
180
  | Id | Check | Evidence | Tier |
181
181
  |---|---|---|---|
182
182
  | H1 | Query shape follows the business view (list where people scan; lookup where they open one) | queries, screens | D |
183
183
  | H2 | Executable scope: a keyed `=> RM optional` query with `by` named like a read-model property, or a collection (`=> RM[]`, observable too) with caller-supplied `by` and/or equality filters. `from`, single-result filters, opaque `scoped to` and a list-query `by` block remain PLAY0268; a `performer` query is an opaque read (PLAY0270) left out of the executable model ([version gate](../../cratis-screenplay-toolchain/references/executable-subset.md#code-attachments-what-binds-what-never-does)). A read model with several key parts binds as v27 (Requires Screenplay 4.204.0). The projection routes by the same identity (a `from` key or an event property, or `$eventSourceId`; `$eventSourceId` is not mandated). Filtered models: supported v14 equality filters render within the CLI bundle's ESM ceiling. Renderable scope only: Stage-specific identity/filter limits; keyed optional snapshot lookups and snapshot/observable collections render (Requires Stage 4.90.0 for snapshot lists; older renderers report `STAGE-ESM-010`). Check query concept-validation parity separately; primitive-argument targets answer absence instead of Validation | queries, projections | C (executable); C (render admission, renderable only) |
184
184
  | H3 | One builder per read model; projection `key` only on `from` | projections | C |
185
185
  | H4 | Screens show one actor's point of view; a form submits one command | screens, forms | D |
186
+ | H5 | Sinks: every declared `sink` is used by a read model or graph (`PLAY0938`), names differ ignoring case (`PLAY0932`), no `passive` read model names one (`PLAY0935`), and no read model's `sink <Type>` line is a property where the directive was meant (`PLAY0939`, or a type spelled exactly like no declared sink). The model names no database; a named sink needs a reason such as separate reporting storage ([sinks](../../cratis-screenplay-read-surface/references/sinks.md)) | `sink` declarations, read models, graphs | C (PLAY0932/0935); D (unused or unneeded sinks) |
186
187
 
187
188
  ## Phase 11. Strategy checks (13 checks, R1-R13)
188
189
  The rejected anti-patterns of the Screenplay strategy, as review checks. They apply to the
@@ -20,8 +20,9 @@
20
20
  { "kind": "skill-contains", "value": "business-question" },
21
21
  { "kind": "skill-contains", "value": "find-modeling-smells" },
22
22
  { "kind": "skill-contains", "value": "entity walk" },
23
- { "kind": "skill-contains", "value": "eleven phases, 89 checks" },
23
+ { "kind": "skill-contains", "value": "eleven phases, 90 checks" },
24
24
  { "kind": "skill-contains", "value": "could a non-technical product owner read it and immediately understand" },
25
- { "kind": "skill-contains", "value": "a \"simple relay\" is not exempt from having pending work" }
25
+ { "kind": "skill-contains", "value": "a \"simple relay\" is not exempt from having pending work" },
26
+ { "kind": "skill-contains", "value": "| H5 | Sinks: every declared `sink` is used by a read model or graph (`PLAY0938`), names differ ignoring case (`PLAY0932`)", "file": "references/checklist.md" }
26
27
  ]
27
28
  }
@@ -65,6 +65,10 @@ build a read model** — two builders is error `PLAY0191`: *a projection or a
65
65
  reducer builds it, and only one of them*. A slice may still declare several
66
66
  projections, each building a **different** read model.
67
67
 
68
+ **A builder never names a sink.** A projection or reducer writes to its read model's sink, and a
69
+ graph projection to its graph's sink; only the `readmodel` or `graph` body carries `sink <Name>`
70
+ (read surface [sinks](../cratis-screenplay-read-surface/references/sinks.md)).
71
+
68
72
  ## Public-event targets and observer filters
69
73
 
70
74
  In an explicitly outbound Translate slice, `projection P => PublicEvent` or
@@ -248,7 +252,8 @@ Choose a graph for traversals (membership, nesting, paths) and a document read m
248
252
  for lookups by key. Design by **reading the graph backwards**: write each question
249
253
  as a path, make every hop an edge type and every stop a node label, then name the
250
254
  event that creates and the one that removes each. Read
251
- [references/graphs.md](references/graphs.md) for syntax, operations and `PLAY0862`–`PLAY0877`.
255
+ [references/graphs.md](references/graphs.md) for syntax, operations, a graph in a named sink
256
+ (`sink People for graphs`) and `PLAY0862`–`PLAY0877`.
252
257
 
253
258
  ## When PDL is not enough — the reducer
254
259
 
@@ -4,6 +4,7 @@
4
4
 
5
5
  - Declaring a graph
6
6
  - Projecting events onto it
7
+ - Storing a graph in a named sink
7
8
  - Reading the graph backwards
8
9
  - The five operations
9
10
  - What a graph projection cannot say
@@ -103,6 +104,61 @@ module Organization
103
104
  edge before the events that create its nodes arrive. A projection owns the edges
104
105
  and node properties it declares and never deletes a node it did not declare.
105
106
 
107
+ ## Storing a graph in a named sink
108
+
109
+ A graph names no sink by default and is stored in the application's default graph sink. To keep one
110
+ graph apart from another, declare a sink `for graphs` at the application root and put a bare
111
+ `sink <Name>` line in the graph body. The projection never names a sink: it writes to its graph's
112
+ sink. Requires Screenplay 6.4.0 (`screenplay --version`).
113
+
114
+ ```screenplay
115
+ sink People for graphs
116
+
117
+ concept PersonId : Uuid
118
+ concept GroupId : Uuid
119
+ concept PersonName : String
120
+
121
+ module Organization
122
+ feature Chart
123
+ slice StateView OrganizationChart
124
+ event PersonRegistered
125
+ name PersonName
126
+
127
+ event GroupCreated
128
+ name String
129
+
130
+ event MemberAdded
131
+ groupId GroupId
132
+
133
+ graph Organization
134
+ sink People
135
+ node Person
136
+ personId PersonId key
137
+ name PersonName
138
+ node Group
139
+ groupId GroupId key
140
+ name String
141
+ edge MEMBER_OF source Person target Group
142
+ since DateTime
143
+
144
+ projection OrganizationChart => graph Organization
145
+ node Person
146
+ from PersonRegistered key $eventSourceId
147
+ name = name
148
+ node Group
149
+ from GroupCreated key $eventSourceId
150
+ name = name
151
+ edge MEMBER_OF
152
+ from MemberAdded source $eventSourceId target groupId
153
+ since = $eventContext.occurred
154
+ ```
155
+
156
+ A graph body has no properties of its own, so every `sink` line in it is the directive: an
157
+ undeclared name is `PLAY0933`, and a sink declared `for readmodels` is `PLAY0934`. The model never
158
+ names a Neo4j server or database; the deployment maps `People` to one. The read-model side and the
159
+ full `PLAY0931`–`PLAY0939` table are in the read surface's
160
+ [sinks](../../cratis-screenplay-read-surface/references/sinks.md).
161
+
106
162
  ## Reading the graph backwards
107
163
 
108
164
  1. List the questions the graph must answer ("who is in this group, including nested groups?").
@@ -28,6 +28,9 @@
28
28
  { "kind": "skill-contains", "value": "The key is **always the event source id**" },
29
29
  { "kind": "skill-contains", "value": "**A join never creates an" },
30
30
  { "kind": "skill-contains", "value": "Inline code uses a tagged fence" },
31
- { "kind": "skill-contains", "value": "PLAY0690", "file": "references/reducer-identity.md" }
31
+ { "kind": "skill-contains", "value": "PLAY0690", "file": "references/reducer-identity.md" },
32
+ { "kind": "skill-contains", "value": "**A builder never names a sink.**" },
33
+ { "kind": "skill-contains", "value": "sink People for graphs", "file": "references/graphs.md" },
34
+ { "kind": "skill-contains", "value": "every `sink` line in it is the directive", "file": "references/graphs.md" }
32
35
  ]
33
36
  }
@@ -63,6 +63,13 @@ trigger/command reads, all-parts fixtures, PLAY0660–0662 and command-read-only
63
63
  A `=>` target resolving to an event is an event-target builder, not a read model;
64
64
  keep event and read-model names distinct (see projections' public-event targets).
65
65
 
66
+ ## Where a read model is stored
67
+
68
+ No `sink` line means the default sink. `sink <Name>` stores it in a root-declared
69
+ `sink <Name> for readmodels`, never on a `passive` read model (`PLAY0935`); it is the directive only
70
+ when `<Name>` is a declared sink, else a property. `@sink <Type>` is always the property.
71
+ Read [sinks](references/sinks.md) before naming a sink.
72
+
66
73
  ## `query`
67
74
 
68
75
  Excerpt: the concepts, the read model and the policy are declared elsewhere.
@@ -86,7 +93,7 @@ bind, including `observable`. Caller-supplied equality
86
93
  filters on collections bind as ESM v14; `from`, single-result filters, `scoped to`,
87
94
  and a `by` block on a list query (or on a non-optional single result) remain PLAY0268, each with its reason. A `performer` query is not refused: it is an opaque read (PLAY0270 information) left out of the executable model ([version gate](../cratis-screenplay-toolchain/references/executable-subset.md#code-attachments-what-binds-what-never-does)). Read
88
95
  [equality filters](references/equality-filters.md) for the admitted shape, a complete
89
- compiled specification model and the Stage/CLI ceilings. Keep a list the domain needs.
96
+ compiled specification model and the Stage/CLI ceilings.
90
97
 
91
98
  Concept keys/supplied filters validate after authorization: invalid means Validation,
92
99
  not absence; omitted optional filters are unchecked. Read [query rejections](../cratis-screenplay-specifications/references/query-rejections.md) when specifying this.
@@ -129,9 +136,7 @@ query Everyones => Timesheet[]
129
136
 
130
137
  ⚠️ **The tenant is the default and stays unstated.** A query is scoped to the
131
138
  tenant it runs for unless it says otherwise, so `scoped to global` is how a query
132
- *opts out* and reaches past the tenant. As the documentation puts it: *"Making the
133
- narrow case the default means the dangerous case is the one you have to write
134
- down, rather than the one you get by forgetting."*
139
+ *opts out* and reaches past the tenant: the dangerous case is the one you write down.
135
140
 
136
141
  **The scope is a name, not a closed set.** `identity` and `global` are the two the
137
142
  language documents, but the grammar accepts any name — what scopes exist follows
@@ -156,7 +161,7 @@ to a live query exactly as it binds to a one-shot one. The delivery itself is th
156
161
  target runtime's: the executable model binds `observable` queries (delivery `live`) that
157
162
  have no opaque scope/performer and, when filtered, only admitted caller-supplied equality filters (ESM v14).
158
163
 
159
- Paging, sorting and change-set delivery for queries are are planned but **not in the language yet**. Do not invent syntax for them.
164
+ Paging, sorting and change-set delivery for queries are planned but **not in the language yet**. Do not invent syntax for them.
160
165
 
161
166
  ### `performer`
162
167
 
@@ -218,7 +223,7 @@ Authorization runs before lookup, ANDed with module/feature gates; policies see
218
223
  only `by`, never filters. Pin denial with `given caller` and `then denied`.
219
224
  Specs pass `by` and filters by name (PLAY0468 for unknown, repeated or missing
220
225
  required arguments); collection results match by read model/key regardless of
221
- row order. Details and renderer limits: [equality filters](references/equality-filters.md).
226
+ row order.
222
227
 
223
228
  A reducer-built view is keyed by event-source id, so a single-instance `by` of another
224
229
  nominal type warns `PLAY0690`. Rebuild it as a projection keyed on each `from`: projections