@cratis/pi 7.137.1 → 7.138.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 (21) hide show
  1. package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +4 -0
  2. package/package/corpus/product-sync.json +1 -0
  3. package/package/corpus/rules/glossary.md +4 -0
  4. package/package/corpus/skills/cratis-arc-neo4j/LICENSE +2 -0
  5. package/package/corpus/skills/cratis-arc-neo4j/SKILL.md +166 -0
  6. package/package/corpus/skills/cratis-arc-neo4j/references/connection-resolution-and-single-mode.md +51 -0
  7. package/package/corpus/skills/cratis-chronicle-client-elixir/SKILL.md +12 -1
  8. package/package/corpus/skills/cratis-chronicle-client-elixir/references/graphs.md +123 -0
  9. package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +18 -1
  10. package/package/corpus/skills/cratis-chronicle-projection/references/graph-projections.md +159 -0
  11. package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +15 -2
  12. package/package/corpus/skills/cratis-screenplay-projections/references/graphs.md +150 -0
  13. package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +25 -23
  14. package/package/corpus/skills/cratis-screenplay-specifications/references/graph-steps.md +90 -0
  15. package/package/corpus/skills/cratis-screenplay-specifications/references/vocabulary.md +6 -0
  16. package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.json +7212 -1834
  17. package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.version +1 -1
  18. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +2 -0
  19. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/graphs.md +52 -0
  20. package/package/profile-catalog.json +1 -0
  21. package/package.json +1 -1
@@ -0,0 +1,150 @@
1
+ # Graph declarations and graph projections
2
+
3
+ ## Contents
4
+
5
+ - Declaring a graph
6
+ - Projecting events onto it
7
+ - Reading the graph backwards
8
+ - The five operations
9
+ - What a graph projection cannot say
10
+ - Diagnostics
11
+
12
+ ## Declaring a graph
13
+
14
+ A slice-level `graph`, a sibling of `readmodel`. Each `node` has typed properties and
15
+ exactly one `key`; each `edge` names existing node labels and may add properties.
16
+
17
+ ```screenplay
18
+ concept PersonId : Uuid
19
+ concept GroupId : Uuid
20
+ concept PersonName : String
21
+
22
+ module Organization
23
+ feature Chart
24
+ slice StateView OrganizationChart
25
+ graph Organization
26
+ node Person
27
+ personId PersonId key
28
+ name PersonName
29
+ node Group
30
+ groupId GroupId key
31
+ name String
32
+ edge MEMBER_OF source Person target Group
33
+ since DateTime
34
+ ```
35
+
36
+ - A property is a primitive, a concept over one, or an array of those. A nested
37
+ object, a `type` or a read model is `PLAY0863`: model it as another node and an edge.
38
+ - An edge is identified by type, source key and target key, so a repeated
39
+ `MEMBER_OF` between one pair is the same edge. For several edges of one type
40
+ between the same pair, write `edge HAS_ROLE source Person target Group identified by assignmentId`
41
+ and declare `assignmentId` on the edge (`PLAY0871`).
42
+ - Edge types read best in `UPPER_SNAKE_CASE`.
43
+
44
+ ## Projecting events onto it
45
+
46
+ Declared in the slice next to its graph; a standalone projection document cannot
47
+ hold one (`PLAY0877`). The model below is complete: events, graph and projection in one slice.
48
+
49
+ ```screenplay
50
+ concept PersonId : Uuid
51
+ concept GroupId : Uuid
52
+ concept PersonName : String
53
+
54
+ module Organization
55
+ feature Chart
56
+ slice StateView OrganizationChart
57
+ event PersonRegistered
58
+ name PersonName
59
+
60
+ event PersonRemoved
61
+
62
+ event GroupCreated
63
+ name String
64
+
65
+ event MemberAdded
66
+ groupId GroupId
67
+
68
+ event MemberRemoved
69
+ groupId GroupId
70
+
71
+ graph Organization
72
+ node Person
73
+ personId PersonId key
74
+ name PersonName
75
+ node Group
76
+ groupId GroupId key
77
+ name String
78
+ edge MEMBER_OF source Person target Group
79
+ since DateTime
80
+
81
+ projection OrganizationChart => graph Organization
82
+ node Person
83
+ from PersonRegistered key $eventSourceId
84
+ name = name
85
+ remove with PersonRemoved key $eventSourceId detach
86
+ node Group
87
+ from GroupCreated key $eventSourceId
88
+ name = name
89
+ edge MEMBER_OF
90
+ from MemberAdded source $eventSourceId target groupId
91
+ since = $eventContext.occurred
92
+ remove with MemberRemoved source $eventSourceId target groupId
93
+ ```
94
+
95
+ - `from <Event> key <expr>` creates or updates a node; `every` applies mappings to
96
+ every `from` of the block; `remove with ... key <expr> [detach]` deletes it.
97
+ - An edge `from` takes `source <expr> target <expr>`; with `identified by` on the
98
+ edge, every handler writes `identified by <expr>` after `target`.
99
+ - Mappings, counters (`increment`, `decrement`, `count`, `add ... by`, `subtract ... by`),
100
+ `$eventContext` and AutoMap behave as in a read-model projection. A property the
101
+ node or edge does not declare is `PLAY0868`.
102
+ - An edge `from` creates a missing endpoint as a bare node, so an event may draw an
103
+ edge before the events that create its nodes arrive. A projection owns the edges
104
+ and node properties it declares and never deletes a node it did not declare.
105
+
106
+ ## Reading the graph backwards
107
+
108
+ 1. List the questions the graph must answer ("who is in this group, including nested groups?").
109
+ 2. Write each as a path: `Person -MEMBER_OF-> Group -PART_OF-> Group`.
110
+ 3. Each hop is an edge type; each stop is a node label with a key.
111
+ 4. For each edge type and node label, name the event that creates it and the one
112
+ that removes it. Nothing creates it: add the fact to the event model, not a write
113
+ to the graph.
114
+ 5. Add `detach` to any node removal whose label has attached edges.
115
+ 6. A question that is a lookup by key, not a path, belongs in a document read model.
116
+
117
+ ## The five operations
118
+
119
+ Every sink applies the same idempotent operations: `UpsertNode`, `SetProperties`,
120
+ `DeleteNode` (with or without `detach`), `UpsertEdge`, `DeleteEdge`. Nodes are
121
+ identified by label and key; edges by type, source, target and the `identified by` value.
122
+
123
+ ## What a graph projection cannot say
124
+
125
+ `children`, `nested`, `join`, `all`, `clear with`, `remove via join`, `variant`, a
126
+ projection-level `key` or `sequence`, and `automap` blocks are `PLAY0872`. There is
127
+ no engine-native block: whatever the language cannot say is not supported. The event
128
+ model board, find-references and rename do not follow graph projections, so renaming
129
+ an event leaves a graph projection reported as unknown.
130
+
131
+ ## Diagnostics
132
+
133
+ | Code | Meaning |
134
+ | --- | --- |
135
+ | `PLAY0862` | Malformed graph, node or edge declaration |
136
+ | `PLAY0863` | Property type not a primitive, concept or array of those |
137
+ | `PLAY0864` | Node with no `key` or more than one |
138
+ | `PLAY0865` | Edge names an undeclared source or target label |
139
+ | `PLAY0866` | Projection targets an undeclared graph |
140
+ | `PLAY0867` | Block for a label or edge type the graph does not declare |
141
+ | `PLAY0868` | Mapped, identity or asserted property the node or edge lacks |
142
+ | `PLAY0869` | `detach` on an edge |
143
+ | `PLAY0870` | Warning: node removal without `detach` while edges attach to the label |
144
+ | `PLAY0871` | `identified by` names a property the edge does not declare |
145
+ | `PLAY0872` | Read-model-only construct in a graph projection |
146
+ | `PLAY0873` | Malformed block or handler, missing `key` or `source`/`target` |
147
+ | `PLAY0874` | Duplicate declaration or duplicate node/edge build in one projection |
148
+ | `PLAY0875` | Malformed `given graph` / `then graph` step |
149
+ | `PLAY0876` | Specification names an undeclared graph, label or edge type |
150
+ | `PLAY0877` | Graph projection declared outside a slice |
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: cratis-screenplay-specifications
3
- description: Use when writing Screenplay specification syntax or checking fixture, outcome-comparison, rejection and denial semantics. Not for choosing scenario coverage or writing C# and TypeScript tests.
3
+ description: Use when writing Screenplay specification syntax, including graph steps, or checking fixture, outcome-comparison, rejection and denial semantics. Not for choosing scenario coverage or writing C# and TypeScript tests.
4
4
  license: MIT
5
5
  ---
6
6
 
@@ -140,9 +140,7 @@ Rules the binder enforces:
140
140
  - **`then result` and `then no result` need `when query`**, and `when query`
141
141
  needs one of them, `then denied` or a sole validation `then error` (`PLAY0465`). Each argument is a `by` or
142
142
  `filter` parameter of the query (`PLAY0468`).
143
- - **A clock instant is ISO 8601 with an offset or `Z`** (PLAY0461); one `given clock` maximum.
144
- - **`given time zone "<id>"` is parsed, not runnable.** Executable binding refuses it with PLAY0268;
145
- a repeated or malformed line is PLAY0814. Do not author it into an executable model.
143
+ - **A clock instant is ISO 8601 with an offset or `Z`** (PLAY0461); one `given clock` maximum. `given time zone` is not runnable: read `references/vocabulary.md`.
146
144
  - **`then` contains either events or an error — never both.** A rejection
147
145
  specification has exactly one rejection and no success outcome.
148
146
  - **`then denied` stands alone**: not with events, errors or state assertions
@@ -153,18 +151,25 @@ Rules the binder enforces:
153
151
  - **`null` only in optional read-model values.** A `null` in a command or event
154
152
  value is `PLAY0350`: an optional fact is a separate event.
155
153
 
156
- V1 does not report binding-only outcome errors; read `references/vocabulary.md`
157
- for parse-versus-bind diagnostics and check executable diagnostics too.
154
+ Read `references/vocabulary.md` for parse-versus-bind diagnostics and check executable diagnostics too.
155
+
156
+ ## Graph specifications
157
+
158
+ `given graph <Graph>` seeds nodes and edges before the action (`has node`, `has edge`
159
+ only); `then graph <Graph>` asserts them and also states absence (`no node`,
160
+ `no edge`). A `has` step lists only the properties it checks. Use them with
161
+ `when append <Event>` for a graph projection. Requires
162
+ Screenplay 5.7.0 (`screenplay --version`). Read
163
+ [references/graph-steps.md](references/graph-steps.md) for the grammar and `PLAY0868`, `PLAY0875`, `PLAY0876`.
158
164
 
159
165
  ## How outcomes are compared
160
166
 
161
167
  Events compare as the complete new set in authored order (exact count). Read models and query rows: only the asserted properties must match (add `exactly` for all). Rejections: `then error "<message>"` matches the message, never severity. Bare `then error` never matches
162
- a denial. Read [references/outcome-comparison.md](references/outcome-comparison.md) when asserting events, rows, ordering or a localized rejection key.
168
+ a denial. Read [references/outcome-comparison.md](references/outcome-comparison.md) for events, rows, ordering or a localized rejection key.
163
169
 
164
170
  ## Worked example
165
171
 
166
- A command with an authorization gate, a validation rule and a uniqueness constraint, specified in full with inline events, optional-aware queries and read-model assertions.
167
- Read [references/worked-example.md](references/worked-example.md) when writing or checking a complete command, view or constraint specification and you need the full compiled model to copy the shape from.
172
+ Read [references/worked-example.md](references/worked-example.md) for a complete command, view or constraint specification (authorization, validation, uniqueness, queries) to copy the shape from.
168
173
 
169
174
  ## Choosing a strategy
170
175
 
@@ -239,20 +244,16 @@ concept rules to follow the general format-rule convention.
239
244
 
240
245
  ## Application-boundary coverage
241
246
 
242
- Every slice should carry at least one specification whose action is what a real
243
- caller does and whose `then` is observable at that same boundary — produced
244
- events, read-model state, query results, a rejection or a denial. A specification
245
- satisfiable only by an internal function describes a unit, not a slice acceptance
246
- criterion.
247
+ Every slice carries at least one specification whose action is what a real caller
248
+ does and whose `then` is observable at that boundary (events, read-model state, query
249
+ results, a rejection or a denial), not only through an internal function.
247
250
 
248
251
  ## Quality checklist
249
252
 
250
253
  For every specification:
251
254
 
252
- - [ ] Concrete, realistic values — never "valid user" or "some amount".
253
- - [ ] The values the outcome depends on are visible in the body, at the edge that matters.
254
- - [ ] Tests exactly one behavior, independent of other specifications.
255
- - [ ] Business language matching the event-model vocabulary.
255
+ - [ ] Concrete, realistic values, visible in the body where the outcome depends on them.
256
+ - [ ] Tests exactly one behavior, in the event-model vocabulary, independent of other specifications.
256
257
 
257
258
  For command specifications:
258
259
 
@@ -283,11 +284,12 @@ For view specifications:
283
284
 
284
285
  ## Run the specs before calling the work done
285
286
 
286
- Symptom: a model delivered with specifications that were never run. `screenplay test <root>` runs the
287
- reference evaluator; after rendering and building in Debug, run `dotnet test <destination>/<Project>.csproj -c Debug --no-build`
288
- for the generated specification classes (Stage-rendered apps use VSTest). Run a built spec executable only where spec projects are executables
289
- (see [specs.csharp](../../rules/specs.csharp.md)). Report both results separately (`cratis-screenplay-toolchain` V4 and V5.tests); a
290
- build that succeeds is not a test run, and `unbound`/`unsupported` is not a pass.
287
+ `screenplay test <root>` runs the reference evaluator. After rendering and building in Debug,
288
+ run `dotnet test <destination>/<Project>.csproj -c Debug --no-build` for the generated
289
+ specification classes (Stage-rendered apps use VSTest); run a built spec executable only where
290
+ spec projects are executables (see [specs.csharp](../../rules/specs.csharp.md)). Report both
291
+ results separately (`cratis-screenplay-toolchain` V4 and V5.tests); a build that succeeds is not a
292
+ test run, and `unbound`/`unsupported` is not a pass.
291
293
 
292
294
  ## Verify
293
295
 
@@ -0,0 +1,90 @@
1
+ # Graph specification steps
2
+
3
+ ## Contents
4
+
5
+ - Steps
6
+ - Example
7
+ - Rules
8
+
9
+ ## Steps
10
+
11
+ | Step | Meaning |
12
+ | --- | --- |
13
+ | `has node <Label> <key>` | The node exists and the properties listed under it hold the given values. |
14
+ | `has edge <TYPE> from <source> to <target> [identified by <value>]` | The edge exists and the properties listed under it hold the given values. |
15
+ | `no node <Label> <key>` | The node does not exist. `then graph` only. |
16
+ | `no edge <TYPE> from <source> to <target> [identified by <value>]` | The edge does not exist. `then graph` only. |
17
+
18
+ ## Example
19
+
20
+ ```screenplay
21
+ concept PersonId : Uuid
22
+ concept GroupId : Uuid
23
+ concept PersonName : String
24
+
25
+ module Organization
26
+ feature Chart
27
+ slice StateView OrganizationChart
28
+ event PersonRegistered
29
+ name PersonName
30
+
31
+ event PersonRemoved
32
+
33
+ event GroupCreated
34
+ name String
35
+
36
+ event MemberAdded
37
+ groupId GroupId
38
+
39
+ event MemberRemoved
40
+ groupId GroupId
41
+
42
+ graph Organization
43
+ node Person
44
+ personId PersonId key
45
+ name PersonName
46
+ node Group
47
+ groupId GroupId key
48
+ name String
49
+ edge MEMBER_OF source Person target Group
50
+ since DateTime
51
+
52
+ projection OrganizationChart => graph Organization
53
+ node Person
54
+ from PersonRegistered key $eventSourceId
55
+ name = name
56
+ remove with PersonRemoved key $eventSourceId detach
57
+ node Group
58
+ from GroupCreated key $eventSourceId
59
+ name = name
60
+ edge MEMBER_OF
61
+ from MemberAdded source $eventSourceId target groupId
62
+ since = $eventContext.occurred
63
+ remove with MemberRemoved source $eventSourceId target groupId
64
+
65
+ specification RemovingAPersonDetachesTheirEdges
66
+ given graph Organization
67
+ has node Person "6fa459ea-ee8a-4ca4-894e-db77e160355e"
68
+ name = "Ada Lovelace"
69
+ has node Group "0f8fad5b-d9cb-469f-a165-70867728950e"
70
+ has edge MEMBER_OF from "6fa459ea-ee8a-4ca4-894e-db77e160355e" to "0f8fad5b-d9cb-469f-a165-70867728950e"
71
+ when append PersonRemoved
72
+ for "6fa459ea-ee8a-4ca4-894e-db77e160355e"
73
+ then graph Organization
74
+ no node Person "6fa459ea-ee8a-4ca4-894e-db77e160355e"
75
+ no edge MEMBER_OF from "6fa459ea-ee8a-4ca4-894e-db77e160355e" to "0f8fad5b-d9cb-469f-a165-70867728950e"
76
+ has node Group "0f8fad5b-d9cb-469f-a165-70867728950e"
77
+ ```
78
+
79
+ The specification sits in the slice that declares the graph and its projection; they give
80
+ the steps their labels and keys. Check with `screenplay --warnaserror` and `screenplay test`.
81
+
82
+ ## Rules
83
+
84
+ - Keys are the values of the node's `key` property, written as literals.
85
+ - A `has` step checks only the properties listed under it.
86
+ - A malformed step is `PLAY0875`; an undeclared graph, node label or edge type is
87
+ `PLAY0876`; a property the node or edge does not declare is `PLAY0868`.
88
+ - The reference runner keeps an in-memory graph and applies the five operations of the
89
+ projection. Values read from `$eventContext` are not materialized there, so do not
90
+ assert an edge property mapped from `$eventContext`.
@@ -74,3 +74,9 @@ An enumeration value binds whether it is written bare
74
74
  An older compiler binds only the quoted member and the full round-trip instant
75
75
  (`"2026-10-05T08:00:00.0000000Z"`) although it accepts all forms - quote members when a
76
76
  model must bind on older versions.
77
+
78
+ ## Time zones
79
+
80
+ - `given time zone "<id>"` is parsed, not runnable. Executable binding refuses it with
81
+ `PLAY0268`; a repeated or malformed line is `PLAY0814`. Do not author it into an
82
+ executable model.