@cratis/pi 7.163.0 → 7.164.1

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 (41) hide show
  1. package/package/corpus/skills/cratis-arc-react-page/references/from-screenplay.md +1 -1
  2. package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +4 -0
  3. package/package/corpus/skills/cratis-chronicle-projection/references/dictionaries-set-once-ordering.md +47 -0
  4. package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +1 -0
  5. package/package/corpus/skills/cratis-lens-browser-extension/SKILL.md +2 -0
  6. package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +2 -0
  7. package/package/corpus/skills/cratis-screenplay-command-surface/references/policy-persona-seed.md +24 -0
  8. package/package/corpus/skills/cratis-screenplay-command-surface/verification.json +3 -1
  9. package/package/corpus/skills/cratis-screenplay-delivery-planning/SKILL.md +1 -1
  10. package/package/corpus/skills/cratis-screenplay-delivery-planning/verification.json +3 -1
  11. package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +2 -0
  12. package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +3 -3
  13. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-tools.md +12 -2
  14. package/package/corpus/skills/cratis-screenplay-model-authoring/references/storylines.md +68 -0
  15. package/package/corpus/skills/cratis-screenplay-model-authoring/verification.json +9 -1
  16. package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +1 -0
  17. package/package/corpus/skills/cratis-screenplay-model-review/verification.json +2 -1
  18. package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +1 -0
  19. package/package/corpus/skills/cratis-screenplay-projections/references/dictionaries-and-ordering.md +64 -0
  20. package/package/corpus/skills/cratis-screenplay-projections/references/graphs.md +96 -0
  21. package/package/corpus/skills/cratis-screenplay-projections/references/pdl-grammar.md +5 -0
  22. package/package/corpus/skills/cratis-screenplay-projections/verification.json +7 -1
  23. package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +4 -2
  24. package/package/corpus/skills/cratis-screenplay-read-surface/references/screen-levels.md +2 -2
  25. package/package/corpus/skills/cratis-screenplay-read-surface/verification.json +3 -1
  26. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +1 -0
  27. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/renderability-gate.md +8 -0
  28. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/verification.json +5 -1
  29. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md +1 -1
  30. package/package/corpus/skills/cratis-screenplay-specifications/references/graph-steps.md +10 -0
  31. package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +5 -1
  32. package/package/corpus/skills/cratis-screenplay-toolchain/references/cheat-sheet.md +1 -1
  33. package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +52 -0
  34. package/package/corpus/skills/cratis-screenplay-toolchain/references/language-admission.md +14 -0
  35. package/package/corpus/skills/cratis-screenplay-toolchain/references/model-export-diff-rename.md +68 -0
  36. package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.json +1557 -42
  37. package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.version +1 -1
  38. package/package/corpus/skills/cratis-screenplay-toolchain/references/verdicts.md +1 -2
  39. package/package/corpus/skills/cratis-screenplay-toolchain/verification.json +14 -1
  40. package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +1 -1
  41. package/package.json +1 -1
@@ -34,7 +34,7 @@ UI model/runtime in Stage output; read `cratis-stage-rendering-and-sandbox`
34
34
 
35
35
  So no product source maps a `.play` screen to an Arc React page. A hand-written
36
36
  page is a **gap-fill** (`cratis-screenplay-render-and-gap-fill`) with the `.play`
37
- screen as its contract. Screens are deferred by the backend profile: that deferral
37
+ screen as its contract. Screens are deferred by default (an ESM v42 export admits only their data, actions, navigation and layout): that deferral
38
38
  is information `PLAY0269` and does not block binding, but the authoring
39
39
  diagnostics still apply (syntax, unresolved or ambiguous references), and
40
40
  warnings fail a warnings-as-errors gate. A clean compile proves the model is
@@ -263,6 +263,10 @@ or a reactor rather than annotating the projection.
263
263
  Their two optional arguments are in **opposite order**: `[FromAll(contextProperty,
264
264
  property)]` and `[FromEvery(property, contextProperty)]`. Name them.
265
265
 
266
+ ## Dictionary keys, set once and ordering
267
+
268
+ Requires Chronicle 19.150.0 (check the installed `Cratis.Chronicle` package). Fluent `.SetOnce(...)`, keyed `.Set/.Add/.Subtract/.Increment/.Decrement/.Count(m => m.Dict, e => key)`, `.RemoveKey(...)`, and children `.Prepend()`, `.OrderBy(...)`, `.OrderByDescending(...)`; model-bound `SetOnce = true`, `Prepend = true`, `OrderBy`/`OrderByDescending`. See [dictionaries, set once and ordering](references/dictionaries-set-once-ordering.md).
269
+
266
270
  ## Graph projections — nodes and edges
267
271
 
268
272
  A graph projection turns events into idempotent operations on a property graph
@@ -0,0 +1,47 @@
1
+ # Dictionary keys, set once and children ordering (.NET)
2
+
3
+ Read this when a projection keeps a first value, writes one entry per key into a dictionary property, or keeps children in a chosen order.
4
+ Requires Chronicle 19.150.0 (check the installed `Cratis.Chronicle` package).
5
+
6
+ ## Fluent
7
+
8
+ ```csharp
9
+ builder
10
+ .From<ItemSold>(_ => _
11
+ .SetOnce(m => m.OriginalTitle).To(e => e.Title)
12
+ .SetOnce(m => m.Created).ToEventContextProperty(c => c.Occurred)
13
+ .Add(m => m.UnitsByCategory, e => e.Category).With(e => e.Quantity)
14
+ .Increment(m => m.SalesByCategory, e => e.Category)
15
+ .Count(m => m.SalesByUser, c => c.CausedBy.Subject)
16
+ .SetOnce(m => m.FirstSaleByCategory, e => e.Category).ToEventContextProperty(c => c.Occurred))
17
+ .From<ItemReturned>(_ => _
18
+ .Subtract(m => m.UnitsByCategory, e => e.Category).With(e => e.Quantity)
19
+ .Decrement(m => m.SalesByCategory, e => e.Category))
20
+ .From<CategoryRetired>(_ => _.RemoveKey(m => m.UnitsByCategory, e => e.Category))
21
+ .Children(m => m.Comments, children => children
22
+ .IdentifiedBy(c => c.CommentId)
23
+ .Prepend()
24
+ .From<CommentPosted>(_ => _.UsingKey(e => e.CommentId)))
25
+ .Children(m => m.Tasks, children => children
26
+ .IdentifiedBy(t => t.TaskId)
27
+ .OrderByDescending(t => t.Priority)
28
+ .From<TaskAdded>(_ => _.UsingKey(e => e.TaskId)));
29
+ ```
30
+
31
+ ## Model-bound
32
+
33
+ | Need | Attribute |
34
+ | --- | --- |
35
+ | Keep the first value | `SetOnce = true` on `[SetFrom<E>]` or `[SetFromContext<E>]` |
36
+ | Newest child first | `[ChildrenFrom<E>(key: ..., Prepend = true)]` |
37
+ | Sorted children | `[ChildrenFrom<E>(key: ..., OrderBy = nameof(Child.Prop))]` or `OrderByDescending = ...` |
38
+
39
+ A collection takes one ordering; different orderings or an unknown sort property fail at build time.
40
+
41
+ ## Semantics
42
+
43
+ - A dictionary property must be a dictionary (or a property-less object); keys are strings. `Add`, `Subtract`, `Increment`, `Decrement` and `Count` use 64-bit integers.
44
+ - An event-content key must be non-empty, contain no `.`, `[`, `]` or NUL, and not start with `$`; a bad key fails the event and the partition shows the failure. Context and `CausedBy` keys are not checked (`john.doe` nests), so prefer `CausedBy.Subject`. A null or missing key skips the mapping; a key path the event type lacks fails at registration.
45
+ - `SetOnce` assigns again after the property was cleared to null.
46
+ - Equal sort values tie-break by child identifier ascending.
47
+ - Choose a projection over a reducer when the only state is a per-key map, a first value, or child order, with no branching on prior state.
@@ -34,6 +34,7 @@ Reverify product sources before claiming support for another version.
34
34
 
35
35
  - Direct property mapping, counters and sums usually read best as projections.
36
36
  Fluent definitions add mapping structure, not arbitrary per-event code.
37
+ - If the reducer would only key a dictionary, keep a first value or order children, use a projection (see [dictionaries, set once and ordering](../cratis-chronicle-projection/references/dictionaries-set-once-ordering.md)).
37
38
  - Prior-state branches and guarded calculations often read best as reducers.
38
39
  Explain the state-transition rule, rather than proving both projection APIs
39
40
  incapable. Reducers fold per event source: no native cross-source joins,
@@ -6,6 +6,8 @@ license: MIT
6
6
 
7
7
  # Use Lens against a running Arc application
8
8
 
9
+ Screenplay `user` declarations (`cratis-screenplay-command-surface`, "Users") are development identities Stage can offer to Lens when its development mode and explicit users switch are both on.
10
+
9
11
  Lens is a Manifest V3 browser extension that impersonates a user and a tenant
10
12
  against an Arc application you are developing, and executes that application's
11
13
  commands and queries from a popup. It changes nothing in the application: it
@@ -236,6 +236,8 @@ declaring a policy (including `require anonymous` for a deliberately public comm
236
236
  A policy that decides from recorded state declares `reads <Model> [as alias] [by property]` and a state condition in `require`
237
237
  (`plan.dataQuality == true`, `article.author == $identity.id`); an absent read denies. See the same reference, "Policies that decide from recorded state".
238
238
 
239
+ A `user` line names a development session identity and the personas it plays; see the same reference, "Users".
240
+
239
241
  `authorize` says who may act; whether the command exists for the caller at all is `available`, with `provide` for `$context` values: `cratis-screenplay-availability`.
240
242
 
241
243
  ## Event data subject
@@ -3,6 +3,7 @@
3
3
  ## Contents
4
4
 
5
5
  - `policy` and `persona`
6
+ - Users
6
7
  - Anonymous policy
7
8
  - Policy negation
8
9
  - Policies that decide from recorded state
@@ -38,6 +39,29 @@ A `persona` is authoring metadata: the binder reports it as information `PLAY027
38
39
  (report-only) and it does not block binding; an unknown policy it lists is an error.
39
40
  Personas an `onboarding` block invites or grants must be declared here; see `cratis-screenplay-authentication-and-onboarding`.
40
41
 
42
+ ## Users
43
+
44
+ Requires Screenplay 5.11.0 or later (`screenplay --version`). A `user` is a person a development or test session can act as: one top-level line naming the personas it plays. Personas are roles (`Accountant`); users are people (`kari`).
45
+
46
+ ```screenplay
47
+ policy IsAccountant
48
+ require role "Accountant"
49
+ policy IsInvoiceManager
50
+ require role "InvoiceManager"
51
+
52
+ persona Accountant
53
+ policy IsAccountant
54
+ persona InvoiceManager
55
+ policy IsInvoiceManager
56
+
57
+ user kari "Kari Nordmann" as Accountant, InvoiceManager
58
+ user guest "Guest"
59
+ ```
60
+
61
+ The name is the identity a session presents; the quoted display name is optional. A user plays only declared personas (`PLAY0888`), names are unique (`PLAY0889`), and a user with no persona is authenticated and holds no roles, which tests a signed-in person without access. A user holds the roles and claims its personas' policies give it.
62
+
63
+ Like `persona`, a user is syntax-only: it never enters the executable model, so the bytes and revision are unchanged and a model without users compiles as before. Users exist for tooling that exercises a running application; Stage offers them to Lens only when its development mode and its explicit users switch are both on, never in a published or rendered application.
64
+
41
65
  ## Anonymous policy
42
66
 
43
67
  Requires Screenplay 4.231.0 (ESM v31; `screenplay --version`); older compilers reject
@@ -114,6 +114,8 @@
114
114
  { "kind": "skill-contains", "value": "PLAY0682", "file": "references/generated-values-and-responses.md" },
115
115
  { "kind": "skill-contains", "value": "zero trailing bits", "file": "references/generated-values-and-responses.md" },
116
116
  { "kind": "skill-contains", "value": "STAGE-ESM-038", "file": "references/generated-values-and-responses.md" },
117
- { "kind": "skill-contains", "value": "file Validations/AllowedEmailDomain.cs", "file": "references/validate-rules.md" }
117
+ { "kind": "skill-contains", "value": "file Validations/AllowedEmailDomain.cs", "file": "references/validate-rules.md" },
118
+ {"kind":"skill-contains","value":"`PLAY0888`","file":"references/policy-persona-seed.md"},
119
+ {"kind":"skill-contains","value":"user kari","file":"references/policy-persona-seed.md"}
118
120
  ]
119
121
  }
@@ -113,6 +113,6 @@ provides a claim tool such as `issue_work`, its claim step is that guard.
113
113
  - `references/provenance.md` - sources and what was not adopted.
114
114
 
115
115
  ## Related skills
116
- `cratis-screenplay-slice-design` (slice dependencies), `cratis-screenplay-model-authoring`
116
+ after a model change, `slices` from `screenplay diff --format json` (with `modelWide` and `affectedSlices`) scopes the re-planning; `screenplay export --scope <slice>` hands one slice's executable model to a builder and `screenplay diff` lists what changed ([CLI reference](../cratis-screenplay-toolchain/references/model-export-diff-rename.md)); `cratis-screenplay-slice-design` (slice dependencies), `cratis-screenplay-model-authoring`
117
117
  (MCP navigation), `cratis-screenplay-render-and-gap-fill` (what renders, gap-fill handoff),
118
118
  `cratis-screenplay-modeling-lifecycle` (phases and gates).
@@ -11,6 +11,8 @@
11
11
  { "kind": "skill-contains", "value": "Never quote an accuracy", "file": "SKILL.md" },
12
12
  { "kind": "skill-contains", "value": "Estimate fit", "file": "references/velocity-and-capacity.md" },
13
13
  { "kind": "skill-contains", "value": "Wave 1", "file": "references/parallel-delivery.md" },
14
- { "kind": "skill-contains", "value": "One GitHub issue per slice group", "file": "references/parallel-delivery.md" }
14
+ { "kind": "skill-contains", "value": "One GitHub issue per slice group", "file": "references/parallel-delivery.md" },
15
+ {"kind":"skill-contains","value":"--scope <slice>"},
16
+ {"kind":"skill-contains","value":"affectedSlices"}
15
17
  ]
16
18
  }
@@ -35,6 +35,8 @@ still need binding and otherwise substitute their own slice. Inspect
35
35
  ambiguous identities; fix parse/placement errors first. Read the notes reference
36
36
  for refusals, `ambiguous: true`, typed targets and every `substitutions` entry.
37
37
 
38
+ Read [storylines](references/storylines.md) to name a journey across modules, features and slices.
39
+
38
40
  ## Choosing a strategy
39
41
 
40
42
  Read [shop strategies and entropy](references/choosing-generation.md) before
@@ -21,8 +21,8 @@ repository is the full list; this page is the authoring summary.
21
21
 
22
22
  ## Accepted constructs
23
23
 
24
- **Top level:** `domain`, `import`, `concept`, `type`, `policy`, `persona`,
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`,
24
+ **Top level:** `domain`, `import`, `concept`, `type`, `policy`, `persona`, `user` (development identity; [users](../../cratis-screenplay-command-surface/references/policy-persona-seed.md#users)),
25
+ `authentication`, `identity`, `purpose`, `storyline` (authoring-only; [storylines](storylines.md)), `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
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>"`,
@@ -323,7 +323,7 @@ See read-surface `references/named-keys.md` for the collection-key exclusion alg
323
323
  | Blocks binding (`PLAY0268`) | enum/identity compliance and events combining personal or explicitly subject-scoped secret values with explicit subject marks; a compiler that stops before v13 refuses all `pii`/`secret` concepts ("compliance attributes require portable data-subject semantics"), while v13 binds them and Stage renders protection; bare `rule <Name>`, read paths without protected opt-in or in unsupported positions such as `produces when`, date comparisons with mixed primitives, optional condition operands, `$context`, protected read paths or `today`, date rules on concepts or reaction `where`, `$context.tenant`/claims/roles/causation in `produces`, `$env` conditions, `file` constraints, unquoted `import` of an external contract, a read model with neither explicit `key` nor unambiguous query-based identity as described above (several key marks bind as v27; older binders refuse PLAY0268; toolchain `language-admission.md`), queries with context `from` sources (typed query context is unadmitted), single-result filters (collections only), `scoped to` (opaque scope) or a `by` block on a list query or non-optional single result (a `performer` query is not refused: it 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)); optional keyed and collection queries, including caller-supplied equality filters and observable delivery, bind, `$causedBy` and templates in projections |
324
324
  | Blocks binding (`PLAY0800`) | Attached file/inline command `handler` with no unconditional `produces`, with `produces ... when`, or with an unresolved body. Beside unconditional `produces` with a resolved body it binds as the v23 result contract, and pending described intent also binds v23 (command-surface `references/described-handlers.md` has the compiler gate). Read required typed `arguments.subject` for the command, never parse the message. Compiler prerequisite and older PLAY0268 attribution: [diagnostic arguments](../../cratis-screenplay-toolchain/references/diagnostic-arguments.md) |
325
325
  | Blocks binding (`PLAY0271`, legacy meaning) | Command reads without protected opt-in and `concurrency`; combined protected reads/concurrency is PLAY0783 |
326
- | Deferred (`PLAY0269`, information) | Screens, layouts, templates, forms, contributions, UI profiles, themes, behaviors and `on`/`uses` |
326
+ | Deferred by default (`PLAY0269`, information; screens admitted on request as ESM v42 with `--screens`) | Screens, layouts, templates, forms, contributions, UI profiles, themes, behaviors and `on`/`uses` |
327
327
  | Metadata only (`PLAY0270`, information) | `domain`, `seed`, `persona`, trigger and other descriptions, and `file` provenance on declarations |
328
328
 
329
329
  The table is a snapshot, not a contract: ask the binder (MCP `executable-diagnostics`
@@ -67,7 +67,7 @@ the [MCP loop](mcp-loop.md).
67
67
  | Group | Tools | Intent |
68
68
  | --- | --- | --- |
69
69
  | Understanding | `describe-application`, `search-declarations`, `find-declaration`, `declaration-details`, `list-storylines` (one optional argument) | Navigate logical hierarchy, inspect bounded details and list storylines |
70
- | References and examples | `find-references`, `dependencies`, `dependency-graph`, `find-fixtures`, `find-assertion-gaps`, `find-specification-obligations`, `find-modeling-smells`, `trace-lineage`, `semantic-diff` | Inspect declared relationships and authored examples, not executed coverage |
70
+ | References and examples | `list-storylines`, `find-references`, `dependencies`, `dependency-graph`, `find-fixtures`, `find-assertion-gaps`, `find-specification-obligations`, `find-modeling-smells`, `trace-lineage`, `semantic-diff` | Inspect declared relationships and authored examples, not executed coverage |
71
71
  | Source and validation | `diagnostics`, `ui-profiles` (also the design system, themes and resolved values per mode), `read-document`, `merged-document`, `syntax-schema` | Read exact source or typed structure and diagnose problems |
72
72
  | Workspace inspection | `open-workspace`, `read-workspace`, `read-ast`, `workspace-state`, `export-workspace`, `repair-capabilities` | Obtain current identities, handles, readiness, code attachment requirements, source-map locations, durable-state status and the repair catalog |
73
73
  | Visual (MCP-Apps hosts only) | `visualize-model` | Draw the board for the model or a `proposalId`; its `sketch` argument previews a what-if of whole documents. Reads only |
@@ -396,7 +396,7 @@ leave the event standalone; never work around it with text edits.
396
396
 
397
397
  Requires Screenplay 4.223.0 (`screenplay --version`) for `trace-lineage`.
398
398
 
399
- `trace-lineage` takes a read-model property `address` and returns a paged tree
399
+ Requires Screenplay 6.6.0 or later (`screenplay --version`) for `direction` and for command, event and screen-field addresses. `trace-lineage` takes a property `address` (a command, event or read-model property: the owner's address and the member; or a screen field: the screen's or form's address and the bound property) and a `direction` (`upstream`, `downstream` or `both`, the default). Downstream a command property goes to the event properties its productions set, to the read-model properties its projections set (and the command properties a reaction's `invokes` sets), then to the queries and screens that show it; a form input field has only downstream hops and a shown field only upstream ones; a command with a `handler` stops at `opaque`. Hops carry `id`, `parent`, `depth`, `direction`, `role`, `status`, `kind`, `address`, `location` (and, for projections, `mode` and `block`). It returns a paged tree
400
400
  (`limit`, `offset`) from the property through projection or reducer mappings, joins and
401
401
  child mappings to the event property, then to the producing command property or capture
402
402
  source. A broken hop is reported where the chain breaks, several sources appear as
@@ -405,6 +405,16 @@ advisory.
405
405
 
406
406
  Requires Screenplay 4.153.0 or later (`screenplay --version`) for `propose-rename` to consult release-baseline mutability; before it, `propose-rename` pins the previous effective name without a baseline.
407
407
 
408
+ `read-workspace` with `view: "executable-model"` and `screens: true` admits screens (ESM v42; Screenplay 6.8.0 or later); a reference the model does not hold is refused with `ScreensRefused`.
409
+
410
+ `read-workspace` also pages `view: "api-description"` (OpenAPI 3.1) and `view: "ui-contract"` (`screenplay-ui/1`) like `executable-model`; `api-description` is unavailable (`available: false`) without an executable model (Screenplay 6.5.0 or later).
411
+
412
+ `semantic-diff` results carry `slices`, the per-slice change summary (`slices`, `modelWide`, `affectedSlices`; Screenplay 6.2.0 or later); the tool count is unchanged.
413
+
414
+ `syntax-schema` exposes graph query collects as `GraphQuerySyntax.collects` (`GraphCollectSyntax` with `property`, `from`, `hop`, `returns`; Screenplay 6.29.0 or later, `screenplay --version`); `propose-ast` adds, replaces and removes them through the ordinary typed operations, and the member is omitted when a query collects nothing.
415
+
416
+ `screenplay rename` is the scriptable, identity-preserving alternative to `propose-rename` plus `apply` (Screenplay 6.1.0 or later; see [export, compare and rename](../../cratis-screenplay-toolchain/references/model-export-diff-rename.md)).
417
+
408
418
  `propose-rename` consults release-baseline mutability: without a
409
419
  baseline it conservatively pins the previous effective name; an unadmitted event
410
420
  gets no new pin, while any admitted revision requires preserving its stored name.
@@ -0,0 +1,68 @@
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
+ # Storylines
5
+
6
+ Read this when a journey that crosses several modules, features and slices must be named, reviewed or walked step by step.
7
+ Requires Screenplay 6.6.0 or later (`screenplay --version`).
8
+
9
+ A `storyline` is authoring metadata: the executable model, the semantic revision and every generated artifact are identical with or without it.
10
+
11
+ ```text
12
+ storyline <Name> ["<title>"]
13
+ [description "<text>"]
14
+ <kind> <reference> ["<note>"]*
15
+ ```
16
+
17
+ - `<Name>` is unique among the application's storylines (`PLAY0943`); the optional title is what a board shows.
18
+ - `<kind>` is `module`, `feature`, `slice`, `command`, `event`, `readmodel`, `query`, `screen` or `reaction`; line order is path order.
19
+ - `<reference>` is the element's name; qualify it (`Returns.Requests`, `Requests.RequestReturn`) when several elements of that kind match (`PLAY0198`, warning).
20
+ - A storyline is declared at the top level, in exactly one file of a folder model.
21
+
22
+ ```screenplay expect PLAY0533
23
+ concept ItemId : Uuid
24
+
25
+ module Returns
26
+ feature Requests
27
+ slice StateChange RequestReturn
28
+ command RequestReturn
29
+ itemId ItemId
30
+ produces ReturnRequested
31
+ itemId = itemId
32
+
33
+ event ReturnRequested
34
+ itemId ItemId
35
+
36
+ slice StateView PendingReturns
37
+ readmodel PendingReturn
38
+ itemId ItemId
39
+
40
+ projection PendingReturn
41
+ from ReturnRequested
42
+ key itemId
43
+
44
+ query AllPending => PendingReturn[]
45
+
46
+ storyline ReturnAnItem "A customer returns an item"
47
+ description "From the request to the list the warehouse works from"
48
+ feature Returns.Requests
49
+ command RequestReturn "The customer asks to return the item"
50
+ event ReturnRequested
51
+ readmodel PendingReturn
52
+ query AllPending "The warehouse sees the return"
53
+ ```
54
+
55
+ ## Diagnostics
56
+
57
+ | Code | Severity | Meaning |
58
+ | --- | --- | --- |
59
+ | `PLAY0940` | Error | Malformed `storyline` declaration |
60
+ | `PLAY0941` | Error | A step is not `<kind> <reference> ["<note>"]`, has an unknown kind, or has a line nested under it |
61
+ | `PLAY0942` | Warning | A step names no element; remove it or point it at its replacement |
62
+ | `PLAY0943` | Error | Two storylines carry the same name |
63
+
64
+ ## Renames and tools
65
+
66
+ - Renaming or moving an element rewrites the steps that name it (`propose-rename`, `screenplay rename`).
67
+ - MCP `list-storylines` (optional `name`) lists each storyline's steps with kind, reference, note and the resolved element's kind, address, location and semantic id, or `missing` / `ambiguous`.
68
+ - Storylines are AST nodes (`StorylineSyntax`, `StorylineStepSyntax`): `read-ast` reads them; `propose-ast` and `propose-source` edit them. `search-declarations` and `declaration-details` use kind `Storyline`; `export-workspace` keeps them.
@@ -268,6 +268,14 @@
268
268
  { "kind": "skill-contains", "value": "`sink`, `module`, `seed`", "file": "references/language-reference.md" },
269
269
  { "kind": "skill-contains", "value": "| `PLAY0937` | Warning | A repeated identical `sink` line |", "file": "references/language-reference.md" },
270
270
  { "kind": "skill-contains", "value": "`ReadModelSyntax.sink` and `GraphSyntax.sink` hold the chosen name", "file": "references/language-reference.md" },
271
- { "kind": "skill-contains", "value": "repaired occurrence by occurrence, never by message text or in bulk" }
271
+ { "kind": "skill-contains", "value": "repaired occurrence by occurrence, never by message text or in bulk" },
272
+ { "kind": "skill-contains", "value": "GraphCollectSyntax", "file": "references/mcp-tools.md" },
273
+ {"kind":"skill-contains","value":"screenplay rename","file":"references/mcp-tools.md"},
274
+ {"kind":"skill-contains","value":"ScreensRefused","file":"references/mcp-tools.md"},
275
+ {"kind":"skill-contains","value":"api-description","file":"references/mcp-tools.md"},
276
+ {"kind":"skill-contains","value":"`slices`","file":"references/mcp-tools.md"},
277
+ {"kind":"skill-contains","value":"list-storylines","file":"references/mcp-tools.md"},
278
+ {"kind":"skill-contains","value":"storyline ReturnAnItem","file":"references/storylines.md"},
279
+ {"kind":"skill-contains","value":"`direction`","file":"references/mcp-tools.md"}
272
280
  ]
273
281
  }
@@ -66,6 +66,7 @@ model's behalf.
66
66
  or literal, to the screen, reaction or integration that supplies it. Trace a field with the
67
67
  `screenplay` MCP server's `trace-lineage` tool (paged tree, breaks, branches and opaque hops
68
68
  are reported) rather than stitching `dependencies` calls; confirm each hop in the model.
69
+ Trace both directions (`direction`: `upstream`, `downstream`, `both`); `screenplay lineage <address> [PATH] [--direction ...] [--format json]` prints the same tree for scripts (exit 0 complete, 1 breaks, 2 cannot run; Screenplay 6.6.0 or later for command, event and screen-field addresses).
69
70
  Requires Screenplay 4.223.0 (`screenplay --version`); on older releases use `dependencies`. AutoMap fills same-named
70
71
  fields silently: count them. Forward: every event to a consumer or a terminal reason; every
71
72
  command input to an event field or a rule. Before calling data missing, search the model.
@@ -24,6 +24,7 @@
24
24
  { "kind": "skill-contains", "value": "could a non-technical product owner read it and immediately understand" },
25
25
  { "kind": "skill-contains", "value": "a \"simple relay\" is not exempt from having pending work" },
26
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" },
27
- { "kind": "skill-contains", "value": "no read model exposes a `secret` concept", "file": "references/mode-compliance.md" }
27
+ { "kind": "skill-contains", "value": "no read model exposes a `secret` concept", "file": "references/mode-compliance.md" },
28
+ {"kind":"skill-contains","value":"screenplay lineage"}
28
29
  ]
29
30
  }
@@ -201,6 +201,7 @@ nested billingContact
201
201
  - **`nested <property>`** — a single nullable object. It **must** contain at least
202
202
  one `from` (error `PLAY0067`), and `clear with <Event>` drops the whole object
203
203
  back to null. To clear one property instead, use a `clear <property>` mapping.
204
+ - **Ordering, `set once` and dictionary keys**: a `children` block may carry `insert first` or `sort by <property>`; `set once` keeps a first value; a target may end in `.$eventContent.<path>`. See [dictionaries and ordering](references/dictionaries-and-ordering.md).
204
205
 
205
206
  ## Removal
206
207
 
@@ -0,0 +1,64 @@
1
+ # Set once, dictionary keys and children ordering
2
+
3
+ Read this when a projection must keep the first value of a property, write one entry per key into a dictionary, or keep children in a chosen order.
4
+ Requires Screenplay 6.9.0 or later (`screenplay --version`); a model that uses `set once` or an ordered `children` block selects ESM v43.
5
+
6
+ ## Set once
7
+
8
+ `set once <property> = <expression>` (or `to`) assigns only while the property is missing or null; later events leave it. It is replay-stable and works in `from`, `every`, `all` and `with` blocks. A property named `once` is written `set @once = ...`.
9
+
10
+ ```screenplay excerpt
11
+ from ModelDefined
12
+ name = name
13
+ set once createdBy = $causedBy.subject
14
+ set once createdAt = $eventContext.occurred
15
+ ```
16
+
17
+ Choose it over a reducer when the only state needed is the first value ("created by", "created at").
18
+
19
+ ## Dictionary keys
20
+
21
+ A target may end in a dynamic key: `<property>.$eventContent.<path>`, `.$eventContext.<path>` or `.$causedBy.subject|name|userName`. The value the key reads becomes the dictionary key. Assignment, `set once`, `increment`, `decrement`, `count`, `add`, `subtract` and `remove` all accept one.
22
+
23
+ ```screenplay excerpt
24
+ from SlotAssigned
25
+ slots.$eventContent.slot = series
26
+ count assignmentsByUser.$causedBy.userName
27
+ from SlotDropped
28
+ remove slots.$eventContent.slot
29
+ ```
30
+
31
+ - `remove <target>` deletes the entry; the target must end in a dynamic key (`PLAY0956`). Removing an absent key does nothing. Escape a property named `with` or `via`: `remove @with.$eventContent.slot`.
32
+ - `clear <target>` with a dynamic key is an error (`PLAY0963`); write `remove`.
33
+ - Screenplay has no dictionary type, so a dynamic key on a property the read model declares is a warning (`PLAY0962`). Dictionary entries are for projections whose read model lives in application code. The reference evaluator does not run them and reports `PLAY0268` for those lines.
34
+ - Prefer `$causedBy.subject` for identity keys; the other members are not checked for characters such as `.`.
35
+
36
+ ## Children ordering
37
+
38
+ One ordering line directly inside a `children` block: `insert last` (the default), `insert first`, or `sort by <property> [ascending|descending]`.
39
+
40
+ ```screenplay excerpt
41
+ children lineItems identified by lineNumber
42
+ sort by quantity descending
43
+ from InvoiceLineItemAdded key lineNumber
44
+ parent invoiceId
45
+ quantity = quantity
46
+ ```
47
+
48
+ - The order is stored and applied when a child is added; updating a child never moves it. The sort is stable, a missing value sorts first ascending and last descending, and a dotted path is allowed.
49
+ - Two ordering lines in one block are `PLAY0959`; an ordering line outside `children`, with indented lines or malformed is `PLAY0958`; a `sort by` property the child type does not declare is a warning (`PLAY0960`).
50
+
51
+ ## Diagnostics
52
+
53
+ | Code | Severity | Meaning |
54
+ | --- | --- | --- |
55
+ | `PLAY0956` | Error | `remove <target>` without a dynamic key |
56
+ | `PLAY0957` | Error | `.$eventContent` without a path, or a `.$causedBy` member other than `subject`, `name`, `userName` |
57
+ | `PLAY0958` | Error | Malformed ordering line, one with indented lines, or one outside `children` |
58
+ | `PLAY0959` | Error | More than one ordering line in a `children` block |
59
+ | `PLAY0960` | Warning | `sort by` names a property the child type does not declare |
60
+ | `PLAY0961` | Warning | `.$eventContent` path the handled event does not have |
61
+ | `PLAY0962` | Warning | Dynamic key on a property the read model declares |
62
+ | `PLAY0963` | Error | `clear` with a dynamic key |
63
+
64
+ The .NET fluent and model-bound forms are in [dictionary keys, set once and ordering](../../cratis-chronicle-projection/references/dictionaries-set-once-ordering.md).
@@ -8,6 +8,7 @@
8
8
  - Storing a graph in a named sink
9
9
  - Reading the graph backwards
10
10
  - Reading a graph with a query
11
+ - Collect nested rows
11
12
  - The five operations
12
13
  - What a graph projection cannot say
13
14
  - Diagnostics
@@ -273,6 +274,97 @@ The read-surface side is in
273
274
  query in a specification with `then query`
274
275
  ([graph steps](../../cratis-screenplay-specifications/references/graph-steps.md)).
275
276
 
277
+ ## Collect nested rows
278
+
279
+ Requires Screenplay 6.29.0 or later (`screenplay --version`); a collecting query selects ESM v54.
280
+
281
+ A query returns nested rows with a `return` assignment of the form
282
+ `<property> = collect <root> -[alias:]TYPE-> [alias:]Label` (or `<-[alias:]TYPE-` for an incoming
283
+ edge), followed by one line per row property:
284
+
285
+ ```screenplay
286
+ concept PersonId : Uuid
287
+ concept GroupId : Uuid
288
+ concept Name : String
289
+
290
+ type GroupMembership
291
+ id GroupId
292
+ name Name
293
+ since DateTime optional
294
+
295
+ type GroupSummary
296
+ id GroupId
297
+ name Name
298
+
299
+ module Organization
300
+ feature Chart
301
+ slice StateView OrganizationViews
302
+ graph Organization
303
+ node Person
304
+ personId PersonId key
305
+ name Name
306
+ node Group
307
+ groupId GroupId key
308
+ name Name
309
+ edge MEMBER_OF source Person target Group
310
+ since DateTime optional
311
+ edge PART_OF source Group target Group
312
+
313
+ readmodel PersonWithGroups
314
+ id PersonId key
315
+ name Name
316
+ groups GroupMembership[]
317
+
318
+ readmodel GroupWithParent
319
+ id GroupId key
320
+ name Name
321
+ parent GroupSummary optional
322
+
323
+ query PeopleInGroup => PersonWithGroups[] graph Organization
324
+ filter groupId GroupId
325
+ match person:Person
326
+ where group.groupId = $groupId
327
+ return
328
+ id = person.personId
329
+ name = person.name
330
+ groups = collect person -membership:MEMBER_OF-> group:Group
331
+ id = group.groupId
332
+ name = group.name
333
+ since = membership.since
334
+
335
+ query GroupsWithParent => GroupWithParent[] graph Organization
336
+ match group:Group
337
+ return
338
+ id = group.groupId
339
+ name = group.name
340
+ parent = collect group -PART_OF-> parent:Group
341
+ id = parent.groupId
342
+ name = parent.name
343
+ ```
344
+
345
+ - **The root.** The query reads like a view: one `match <alias>:<Label>` of its root alone, no hops
346
+ and no `optional match`. Scalar returns come from the root; each result row is one root node,
347
+ distinct by key and ordered by the key (`PLAY1147` otherwise).
348
+ - **The edge.** A collect follows one declared edge from the root, outgoing or incoming; the arrow
349
+ settles the direction, so an edge whose source and target share a label (`PART_OF`) is never
350
+ ambiguous. Name the edge (`-membership:MEMBER_OF->`) to read one of its properties.
351
+ - **The rows.** The property is a list of a composite type (`GroupMembership[]`) or an optional one
352
+ (`GroupSummary optional`), and the lines under the collect assign every required property of the
353
+ type (`PLAY1145`). A list has one row per edge reached, ordered by the reached node's key and then
354
+ the edge's `identified by` value, and is empty when nothing is reached; an optional row is the
355
+ first of those, or null.
356
+ - **Conditions select roots.** A `where` on a collected node keeps the roots with at least one
357
+ reached node that satisfies every condition on that alias; it never narrows what is collected. A
358
+ condition on a collected edge is `PLAY1147`.
359
+ - **Absent properties.** A node created only by an edge has none of its other properties yet; a row
360
+ reads them as null.
361
+ - **One level.** A collect inside a collect is `PLAY1146`; a malformed collect is `PLAY1144`.
362
+
363
+ Assert collected rows in a specification with structured values: see
364
+ [graph steps](../../cratis-screenplay-specifications/references/graph-steps.md#asserting-collected-rows).
365
+ Stage may not render a collecting query; see the ESM v54 row in
366
+ [language admission](../../cratis-screenplay-toolchain/references/language-admission.md).
367
+
276
368
  ## The five operations
277
369
 
278
370
  Every sink applies the same idempotent operations: `UpsertNode`, `SetProperties`,
@@ -316,3 +408,7 @@ an event leaves a graph projection reported as unknown.
316
408
  | `PLAY0884` | Graph query uses the same alias twice |
317
409
  | `PLAY0885` | Graph query uses variable-length paths, `or`, ranges, functions or aggregates |
318
410
  | `PLAY0886` | `foreach` names a collection inside another, or something that is not a list of a composite type of the event |
411
+ | `PLAY1144` | Malformed `collect` (shape, start at the root, row lines) |
412
+ | `PLAY1145` | `collect` does not fit the read model: not `Row[]` or `Row optional`, or a row property unknown, duplicate, missing or mistyped |
413
+ | `PLAY1146` | `collect` nested inside another `collect` |
414
+ | `PLAY1147` | Collecting query is not view-shaped, or has a `where` condition on a collected edge |
@@ -114,6 +114,11 @@ LiteralKeyword = "literal", " ", Literal ; (* parsed at the Expr level *)
114
114
  | Counters | `^(increment\|decrement\|count\|clear)\s+(@?[$\w.]+)$` |
115
115
  | Arithmetic | `^(add\|subtract)\s+(@?[$\w.]+)\s+by\s+(.+)$` |
116
116
  | Assignment | `^(@?[$\w.@]+)\s*=(?!=\|>)\s*(.+)$` |
117
+ | Set once | `^set\s+once\s+(@?[$\w.]+)\s+(?:=\|to)\s+(.+)$` |
118
+ | Remove entry | `^remove\s+(@?[$\w.]+)$` (target ends in a dynamic key) |
119
+ | Children ordering | `insert first`, `insert last`, `sort by <property> [ascending\|descending]` |
120
+
121
+ Diagnostics `PLAY0956`-`PLAY0963` for these lines are in [dictionaries and ordering](dictionaries-and-ordering.md#diagnostics).
117
122
 
118
123
  ## Diagnostics
119
124
 
@@ -38,6 +38,12 @@
38
38
  { "kind": "skill-contains", "value": "Requires Screenplay 5.10.0 or later", "file": "references/graphs.md" },
39
39
  { "kind": "skill-contains", "value": "runs in the reference runner as UTC text" },
40
40
  { "kind": "skill-contains", "value": "`PLAY1142` (`SecretConceptProjected`)", "file": "references/secret-concepts.md" },
41
- { "kind": "skill-contains", "value": "references/secret-concepts.md" }
41
+ { "kind": "skill-contains", "value": "references/secret-concepts.md" },
42
+ { "kind": "skill-contains", "value": "## Collect nested rows", "file": "references/graphs.md" },
43
+ { "kind": "skill-contains", "value": "Requires Screenplay 6.29.0 or later", "file": "references/graphs.md" },
44
+ { "kind": "skill-contains", "value": "insert first", "file": "references/dictionaries-and-ordering.md" },
45
+ { "kind": "skill-contains", "value": "sort by", "file": "references/dictionaries-and-ordering.md" },
46
+ { "kind": "skill-contains", "value": "`PLAY0963`", "file": "references/dictionaries-and-ordering.md" },
47
+ { "kind": "skill-contains", "value": "Requires Screenplay 6.9.0", "file": "references/dictionaries-and-ordering.md" }
42
48
  ]
43
49
  }
@@ -74,7 +74,9 @@ It is never inferred, and a query or screen that consumes it is error `PLAY0859`
74
74
 
75
75
  ## `query`
76
76
 
77
- A query that ends in `graph <Graph>` reads a graph: see [graph queries](references/graph-queries.md).
77
+ A query's HTTP shape and a screen's data contract are exported (`screenplay export --format openapi|ui`; [formats](../cratis-screenplay-toolchain/references/model-export-diff-rename.md#openapi-and-ui-contract-formats)).
78
+
79
+ A query that ends in `graph <Graph>` reads a graph: see [graph queries](references/graph-queries.md). Such a query may return nested rows with `collect` (a view-shaped query; see [collect nested rows](../cratis-screenplay-projections/references/graphs.md#collect-nested-rows)).
78
80
 
79
81
  Excerpt: the concepts, the read model and the policy are declared elsewhere.
80
82
 
@@ -216,7 +218,7 @@ screen InvoiceList
216
218
  `html`, `csharp`). A screen's `data` and `action` declarations are the typed context for UI
217
219
  composition: if a generated app shows a default list or empty panel because it could not consume
218
220
  one of those directives, treat that as a dropped UI construct, not an acceptable Level 1 screen.
219
- Screens and interactions are deferred from the executable model (information `PLAY0269`); what a
221
+ Screens and interactions are deferred by default (information `PLAY0269`); `screenplay export --screens` admits the neutral parts as ESM v42 (data, actions, navigation, layout; never blocking binding); what a
220
222
  click or submit *does* is an interaction (`cratis-screenplay-ui-composition`). Read
221
223
  [screen levels](references/screen-levels.md) for the Level 2 example and the construct list.
222
224
 
@@ -47,5 +47,5 @@ a dropped UI construct, not as an acceptable Level 1 screen.
47
47
  selection, submit or screen entry *does* beyond that — confirm, execute, refresh,
48
48
  open a dialog, branch on success or failure — is an interaction: an inline `on`
49
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.
50
+ `cratis-screenplay-ui-composition`. Screens and interactions are deferred by default
51
+ (information `PLAY0269`) and admitted on request as ESM v42 with `screenplay export --screens`; they never block binding.
@@ -37,6 +37,8 @@
37
37
  { "kind": "skill-contains", "value": "[passive read models](references/passive.md) before declaring one" },
38
38
  { "kind": "skill-contains", "value": "| `PLAY0859` | Error | A `query` returns a passive read model", "file": "references/passive.md" },
39
39
  { "kind": "skill-contains", "value": "Requires Screenplay 5.3.0", "file": "references/passive.md" },
40
- { "kind": "skill-contains", "value": "[graph queries](references/graph-queries.md)" }
40
+ { "kind": "skill-contains", "value": "[graph queries](references/graph-queries.md)" },
41
+ { "kind": "skill-contains", "value": "collect nested rows" },
42
+ {"kind":"skill-contains","value":"ESM v42"}
41
43
  ]
42
44
  }
@@ -217,6 +217,7 @@ whole re-render. What to do:
217
217
  - Screens reported as `PLAY0269` are information that the backend profile defers them. They are not
218
218
  proof of a rendered screen: check the running app (`cratis-screenplay-toolchain` `references/fast-path.md`)
219
219
  and list any authored screen that is missing as not rendered.
220
+ - Scope a re-render with `screenplay diff --format json` (`slices`, `modelWide`); other stacks read ESM v42 or `--format ui`: [exports](references/renderability-gate.md#cli-exports-and-diffs).
220
221
 
221
222
  ## Gate
222
223