@cratis/pi 7.157.0 → 7.158.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 (32) hide show
  1. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/SKILL.md +7 -0
  2. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authorization.md +73 -0
  3. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/public-events-and-direction.md +21 -0
  4. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +6 -0
  5. package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +54 -126
  6. package/package/corpus/skills/cratis-screenplay-command-surface/references/compliance.md +6 -0
  7. package/package/corpus/skills/cratis-screenplay-command-surface/references/concepts-and-types.md +38 -0
  8. package/package/corpus/skills/cratis-screenplay-command-surface/references/generated-values-and-responses.md +19 -0
  9. package/package/corpus/skills/cratis-screenplay-command-surface/references/policy-persona-seed.md +61 -0
  10. package/package/corpus/skills/cratis-screenplay-command-surface/references/validate-rules.md +7 -0
  11. package/package/corpus/skills/cratis-screenplay-command-surface/verification.json +1 -5
  12. package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +21 -8
  13. package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +3 -3
  14. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/principles.md +1 -1
  15. package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +51 -97
  16. package/package/corpus/skills/cratis-screenplay-projections/references/mapping-sources.md +33 -0
  17. package/package/corpus/skills/cratis-screenplay-projections/references/outbound-every.md +12 -0
  18. package/package/corpus/skills/cratis-screenplay-projections/references/reducers.md +40 -0
  19. package/package/corpus/skills/cratis-screenplay-projections/references/stage-admission.md +18 -0
  20. package/package/corpus/skills/cratis-screenplay-projections/verification.json +2 -3
  21. package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +61 -134
  22. package/package/corpus/skills/cratis-screenplay-read-surface/references/passive.md +78 -0
  23. package/package/corpus/skills/cratis-screenplay-read-surface/references/performer-bodies.md +29 -0
  24. package/package/corpus/skills/cratis-screenplay-read-surface/references/query-execution.md +21 -0
  25. package/package/corpus/skills/cratis-screenplay-read-surface/references/screen-levels.md +51 -0
  26. package/package/corpus/skills/cratis-screenplay-read-surface/verification.json +5 -2
  27. package/package/corpus/skills/cratis-screenplay-reverse-engineering/references/synthesis-rules.md +7 -4
  28. package/package/corpus/skills/cratis-screenplay-slice-design/references/rule-layers.md +21 -0
  29. package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +15 -0
  30. package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +12 -2
  31. package/package/corpus/skills/cratis-screenplay-toolchain/verification.json +1 -0
  32. package/package.json +1 -1
@@ -79,8 +79,7 @@ only when `<Name>` is declared (in any file of the model), otherwise a property
79
79
  never names a database. In the typed syntax, `ApplicationSyntax.sinks` holds `SinkSyntax`
80
80
  (`name`, `stores`), and `ReadModelSyntax.sink` and `GraphSyntax.sink` hold the chosen name; JSON
81
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
82
+ on a sink renames its declaration and every directive naming it. Syntax, examples and `PLAY0931`–`PLAY0939`: read surface
84
83
  [sinks](../../cratis-screenplay-read-surface/references/sinks.md).
85
84
 
86
85
  | Code | Severity | Meaning |
@@ -98,6 +97,20 @@ on a sink renames its declaration and every directive naming it. Requires Screen
98
97
  Each `sink` line is also reported as information `PLAY0270`: realization metadata outside the
99
98
  executable model, so the ESM revision does not change with it.
100
99
 
100
+ **Passive read models.** A bare `passive` line in a `readmodel` body (beside `description`, `file`
101
+ and `sink`) marks one that only informs a command's `reads` decision; it is never inferred, and
102
+ only the exact line is the directive (`passive Bool` is a property). A `query` that returns it or
103
+ a `screen` `data` line that binds it is error `PLAY0859`, an unread one warns `PLAY0860` and a
104
+ repeated line warns `PLAY0858`; the directive is realization metadata (`PLAY0270`, no ESM change)
105
+ and `ReadModelSyntax.isPassive` carries it in typed syntax. Older tools reject syntax JSON that carries it. Read surface
106
+ [passive read models](../../cratis-screenplay-read-surface/references/passive.md).
107
+
108
+ **State-reading policies.** A `policy` may declare `reads <Model> [as <alias>] [by <property>]`
109
+ and compare what it holds in its one `require` (`article.author == $identity.id`); an absent read
110
+ denies. Command-surface
111
+ [policies that decide from recorded state](../../cratis-screenplay-command-surface/references/policy-persona-seed.md#policies-that-decide-from-recorded-state)
112
+ has the forms, ESM versions and limits.
113
+
101
114
  Projections and captures use their dedicated sub-grammars. Inline code uses a
102
115
  tagged fence (` ```csharp `); the older language-line form still parses with
103
116
  warning `PLAY0397`. Query the MCP's `syntax-schema` instead of inventing JSON
@@ -296,16 +309,16 @@ See read-surface `references/named-keys.md` for the collection-key exclusion alg
296
309
  | Concept generation strategies (ESM v15) | Required scalar generatable Uuid/String concepts; concept-owned uuid/uuidv7/ulid/typeid/nanoid/bytes strategies and admitted modifiers. Strict fixture encoding; Guarded whole-source freshness rejects Concurrency with no append/retry. Generated secrets and sequence remain refused; generated-concept rules select v20, pattern/random/rule and checksum validation select v21. Stage renders supported strategies: command-surface `references/generated-values-and-responses.md` |
297
310
  | Response-name UI continuations (no ESM change) | Form submit and execute-success scopes, own failure PLAY0685, nested shadowing and outer success in inner failure; field/parameter precedence. An older bundled compiler lacks resolution; Scene runtime binding remains downstream. UI composition `references/response-continuations.md` |
298
311
  | Collection equality filters (ESM v14) | Caller-supplied `filter name Type [optional]`, no `from`, matching a same-named scalar primitive/concept/enum read-model property with the same nominal type. AND with `by`; optional omission does not narrow, supplied null is refused. PLAY0468 covers unknown/repeated/missing required spec arguments; result rows compare by read-model/key regardless of order. Read read-surface `references/equality-filters.md` for the compiled example and renderer ceilings |
299
- | Recovery and no-event assertions (ESM v17) | `when redelivered` delivers one given occurrence to one reaction without append; `then no events` checks no new facts, excluding append input. Requires Screenplay 4.157.0 or later (`screenplay --version`); older compilers report PLAY0268. |
300
- | Query Validation rejection (ESM v18) | Exactly one queried call plus one `then error`, no other action/result/denial. Concept key/supplied filters validate after authorization in every version. Requires Screenplay 4.161.0 or later (`screenplay --version`); older runners may answer absence. |
301
- | Invocation refusal branches (ESM v19) | Ordered first-match `on refused` productions or acknowledgement, `$refusal` values; bare refusal excludes authorization. Requires Screenplay 4.160.0 or later (`screenplay --version`); older compilers report PLAY0268. |
302
- | Generated-concept rules (ESM v20) | Proven rules bind silently, Refuted PLAY0688 errors include a witness, Unproven PLAY0689 warnings include a reason; deterministic regex containment only, not passing samples. Fixtures obey shape and rules. Requires Screenplay 4.164.0 or later (`screenplay --version`); older compilers report PLAY0268. |
303
- | Finite generation and attachments (ESM v21) | String pattern with optional Luhn/Mod11/Mod97 checksum, inclusive Int random range, attached String generation rule with language-neutral Now/Tenant context and String result, String checksum validation. Requires Screenplay 4.172.0 (`screenplay --version`); older compilers report PLAY0268. PLAY0691 is support-budget exhaustion, PLAY0692 empty support on a scanned date. Pin date fixtures with given clock. Requires Stage 4.118.0 for checksum validation and 4.119.0 for pattern/random rendering; older renderers refuse them. current renderers render `generate rule` (the Host and legacy syntax engine keep STAGE-ESM-028); see command-surface `references/generated-values-and-responses.md`. |
312
+ | Recovery and no-event assertions (ESM v17) | `when redelivered` delivers one given occurrence to one reaction without append; `then no events` checks no new facts, excluding append input. Older compilers report PLAY0268. |
313
+ | Query Validation rejection (ESM v18) | Exactly one queried call plus one `then error`, no other action/result/denial. Concept key/supplied filters validate after authorization in every version. Older runners may answer absence. |
314
+ | Invocation refusal branches (ESM v19) | Ordered first-match `on refused` productions or acknowledgement, `$refusal` values; bare refusal excludes authorization. Older compilers report PLAY0268. |
315
+ | Generated-concept rules (ESM v20) | Proven rules bind silently, Refuted PLAY0688 errors include a witness, Unproven PLAY0689 warnings include a reason; deterministic regex containment only, not passing samples. Fixtures obey shape and rules. Older compilers report PLAY0268. |
316
+ | Finite generation and attachments (ESM v21) | String pattern with optional Luhn/Mod11/Mod97 checksum, inclusive Int random range, attached String generation rule with language-neutral Now/Tenant context and String result, String checksum validation. Older compilers report PLAY0268. PLAY0691 is support-budget exhaustion, PLAY0692 empty support on a scanned date. Pin date fixtures with given clock. Older renderers refuse checksum validation and pattern/random rendering. current renderers render `generate rule` (the Host and legacy syntax engine keep STAGE-ESM-028); see command-surface `references/generated-values-and-responses.md`. |
304
317
  | Atomic reaction batches (ESM v22) | Root `reaction batches atomic`; direct productions per occurrence and selected refusal branches are separate batches, commands independent; Stage refuses v22 and atomic mode |
305
318
  | Described handlers (ESM v23) | Pending implementation beside unconditional produces; payload-only contract, reached body Unsupported ImplementationBody; Stage STAGE-IMPL-002 even Stub mode |
306
319
  | Ordinal text rules (ESM v24) | contains/not contains/starts with/ends with on scalar non-enum text properties; quoted literals, not conditions; Stage semantic engines execute/render |
307
320
  | Protected command reads (ESM v25) | Root `command reads protected`; eligible read paths in requirements and production mappings, absence Validation, concurrent matching facts Conflict; Stage admits v25 and, in a new enough bundle, renders protected reads as Arc read protection, refusing unpreservable shapes and every older bundle with STAGE-ESM-044; semantic Host/executor execute admitted reads with non-Error protected requirements refused STAGE-ESM-045 |
308
- | Chronological command dates (ESM v26) | Same-primitive Date/DateTime `==`, `!=`, `>`, `>=`, `<`, `<=` in require/produces-when (property or literal RHS) and command/property rules (literal RHS only). DateTime uses UTC ticks, participating offset-less inputs reject Validation before rules; then matching stays ordinal. Requires Screenplay 4.199.0 (`screenplay --version`); older binders refuse PLAY0268. The Stage Host and executor run v26 (older Stage refuses STAGE-ESM-016); the renderer and legacy engines refuse STAGE-ESM-046 (toolchain `language-admission.md`). Read command-surface `references/date-comparisons.md`. |
321
+ | Chronological command dates (ESM v26) | Same-primitive Date/DateTime `==`, `!=`, `>`, `>=`, `<`, `<=` in require/produces-when (property or literal RHS) and command/property rules (literal RHS only). DateTime uses UTC ticks, participating offset-less inputs reject Validation before rules; then matching stays ordinal. Older binders refuse PLAY0268. The Stage Host and executor run v26 (older Stage refuses STAGE-ESM-016); the renderer and legacy engines refuse STAGE-ESM-046 (toolchain `language-admission.md`). Read command-surface `references/date-comparisons.md`. |
309
322
  | Current routing and actor admission | Sources/streams and command/specification routes bind and reference-execute as v8; reaction `runs as system role` supplies the invocation actor as v10. Whole-workspace binding determines executable availability; CLI/Stage realization remains separate |
310
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 |
311
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) |
@@ -174,14 +174,14 @@ Nebulit (`provenance.md`).
174
174
  | G5 | Row scoping (whose data) is part of the view, not a filter the caller supplies | queries | D |
175
175
  | G6 | Every persona Cannot line resolves to an executable gate (`authorize` policy, or ownership `claim "x" matches subject\|<command property>`, or a Uuid `require <command property> == <protected read path>`) and a `then denied` spec whose caller is synthesized with `given caller as <Persona>` or explicitly carries the effective-gate roles/claims; otherwise recorded as a gap. Persona text is intent only | personas, policies, specs | D |
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
- | 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) |
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. A state-reading policy (`reads <Model> [as alias] [by property]`): every `reads` target is a declared read model that a projection fills; `by` names a property of each command or query that uses the policy (or a mapped policy input) and matches the key of the read model; every state condition path starts at a declared alias or `$identity`; `$identity.id` is compared only with a required text property using `==` or `!=`; no `or`/`not` combination that lets a caller through when the state is absent (absence must deny); the policy has no implementation alongside it; the specs cover allowed, denied by state and no recorded state, and for `$identity.id` another caller and a caller without an identifier. A rule that must hold under concurrent writers placed in such a policy instead of a protected command read is a finding | policies, read models, specs | C (renderable mode) for binding and shape; D for the placement and specs |
178
178
 
179
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
- | H3 | One builder per read model; projection `key` only on `from` | projections | C |
184
+ | H3 | One builder per read model; projection `key` only on `from`. A read model with the explicit `passive` line only informs command decisions: no query returns it and no screen binds it (`PLAY0859`, error), a command `reads` it (`PLAY0860`, warning), and a user-facing read model is not passive ([passive read models](../../cratis-screenplay-read-surface/references/passive.md)); the C# compiler is the one that reports them | projections, read models, queries, screens | C |
185
185
  | H4 | Screens show one actor's point of view; a form submits one command | screens, forms | D |
186
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) |
187
187
 
@@ -196,7 +196,7 @@ artifact is `N/A: <reason>`.
196
196
  | R1 | Code-first change that silently outranks accepted model intent | behaviour added in code with no `.play` counterpart (for hand-written code changed since it was last checked, use `cratis-screenplay-render-and-gap-fill/references/drift-and-fallback-record.md`, section "Hand-written code changed since it was last verified"); the model edited to match existing code; the model left stale after a code change; optional structural evidence: `cratis screenplay conform <model-root> --project <path>` (CLI 3.42.0+, exit 0/1/2, exact structural addresses only, never a behavioral or V4 verdict; MSBuild runs, so a trusted clone) | major (critical when the code contradicts a protection) |
197
197
  | R2 | A diagram, board or document in place of executable semantics | a rule only in a board note, a description or a wiki page; no property, validation, constraint or spec behind it (E8) | major |
198
198
  | R3 | Claims of universal low-code, lossless recovery or target parity | words like "fully generated", "lossless", "any target" in a report or description | minor; major when it hides a gap |
199
- | R4 | Framework machinery in the domain vocabulary (saga, aggregate, passive objects, HTTP or broker detail) or syntax wanted because a framework API is common | declarations named after saga, handler classes, topics, endpoints; a request to add language syntax to mirror a framework API | minor; major when it shapes the model |
199
+ | R4 | Framework machinery in the domain vocabulary (saga, aggregate, passive objects, HTTP or broker detail, a hand-built replay-on-demand store) or syntax wanted because a framework API is common. The language's own explicit `passive` read-model line is not this finding: it is a declared realization choice (H3) | declarations named after saga, handler classes, topics, endpoints; a request to add language syntax to mirror a framework API | minor; major when it shapes the model |
200
200
  | R5 | Silent query broadening, authorization weakening, guessed identities, unprotected-read fallback | a query that lost a filter or `by`; a policy removed or loosened to compile or render; an identity assumed instead of resolved | critical |
201
201
  | R6 | Generated TODOs, defaults or stubs presented as success | TODO, placeholder values, default branches in a "complete" slice or a render report | major |
202
202
  | R7 | Editing managed output, or mixing generated and user-owned code without a separate contract | edits under Stage-managed paths; hand code in rendered files; no named gap-fill seam | major |
@@ -36,7 +36,7 @@ Do not do these, and do not reopen them because a tool or extractor meets framew
36
36
  - Diagrams or documentation as a substitute for executable semantics.
37
37
  - Claims of universal low-code, lossless recovery or target parity.
38
38
  - Adding language syntax because a framework API is popular.
39
- - Saga, aggregate, passive read-model, HTTP, or broker machinery copied into the core vocabulary. Commands, events, read models, reactions, typed identities, deadlines and specifications express these.
39
+ - Saga, aggregate, passive-object, HTTP, or broker machinery copied into the core vocabulary. Commands, events, read models, reactions, typed identities, deadlines and specifications express these. The language's own `passive` read-model line is a declared realization choice for a read model only commands consume, never inferred; it is not this anti-pattern.
40
40
  - Silent query broadening, authorization weakening, guessed identities or an unprotected-read fallback.
41
41
  - Generated TODOs, defaults or stubs presented as a successful realization.
42
42
  - Editing managed output, or mixing generated and user-owned code without a separate contract.
@@ -14,27 +14,22 @@ text. This is half of every event model, and the half most easily got wrong.
14
14
 
15
15
  ## Locate the model
16
16
 
17
- Look first for the project's existing `.play` files: the folder holding them is the
18
- model. Reuse existing model/workspace roots; code-only `Source/` or `src/` does
19
- not qualify. Otherwise use repository-root `Screenplay/`, never `.cratis/`
20
- (configuration/shared corpus only). Read [discovery/version gates](../cratis-screenplay-event-modeling/references/file-layout.md#locate-the-model)
21
- when locating the model; do not invent another location.
17
+ The folder holding the project's existing `.play` files is the model; code-only
18
+ `Source/` or `src/` does not qualify. Otherwise use repository-root `Screenplay/`,
19
+ never `.cratis/`. Read [discovery/version gates](../cratis-screenplay-event-modeling/references/file-layout.md#locate-the-model)
20
+ and do not invent another location.
22
21
 
23
- `cratis ai install` manages `.cratis/ai/`, never model files. Never
24
- hand-copy Screenplay source between repositories. Keep Markdown that explains,
25
- questions or navigates the model in the repository's documentation; the `.play`
26
- source is the single flow model.
22
+ `cratis ai install` manages `.cratis/ai/`, never model files. Never hand-copy
23
+ Screenplay source between repositories; the `.play` source is the single flow model.
27
24
 
28
25
  ## Product sources
29
26
 
30
- Consult Screenplay `Documentation/screenplay/projections/` for grammar and semantics,
31
- `readmodels.md` for targets and `diagnostics.md` for errors. Verify examples with
32
- the standalone compiler before claiming another version behaves the same.
27
+ Screenplay `Documentation/screenplay/projections/` covers grammar and semantics,
28
+ `readmodels.md` targets and `diagnostics.md` errors.
33
29
 
34
- **Chronicle decides what a projection means.**
35
- Screenplay owns the grammar; which instance an event affects, what a join may
36
- create and what a removal removes follow Chronicle's lowering. Syntax that
37
- compiles can still mean something other than it seems: read the warnings.
30
+ **Chronicle decides what a projection means.** Screenplay owns the grammar; which instance an
31
+ event affects, what a join may create and what a removal removes follow Chronicle's lowering.
32
+ Syntax that compiles can still mean something else: read the warnings.
38
33
 
39
34
  ## The shape
40
35
 
@@ -73,12 +68,9 @@ graph projection to its graph's sink; only the `readmodel` or `graph` body carri
73
68
 
74
69
  In an explicitly outbound Translate slice, `projection P => PublicEvent` or
75
70
  `reducer P => PublicEvent` targets the slice's one local public event (ESM v9).
76
- The projection folds one instance per event source id; opaque reducers remain
77
- Unsupported in reference execution. Read
78
- [public-event folds](../cratis-screenplay-automations-and-translations/references/public-events-and-direction.md)
79
- for publication rules and the `when append`/`then PublicEvent` specification.
80
- A reducer can filter `from Source[.Stream]` (ESM v10); a projection cannot.
81
- Read [observer filters](../cratis-screenplay-toolchain/references/production-routes-and-filters.md).
71
+ Read [public-event folds](../cratis-screenplay-automations-and-translations/references/public-events-and-direction.md)
72
+ for publication rules and specifications. A reducer can filter `from Source[.Stream]`
73
+ (ESM v10); a projection cannot: [observer filters](../cratis-screenplay-toolchain/references/production-routes-and-filters.md).
82
74
 
83
75
  ## Projection-level directives
84
76
 
@@ -113,18 +105,12 @@ For same-source events, map the read-model identity from `$eventSourceId`
113
105
  (or `$eventContext.eventSourceId`), not a duplicated payload field. That holds for
114
106
  executable or design scope; in renderable scope (Stage) never map it from `$eventSourceId`:
115
107
  the key of a scoped projection establishes it (`cratis-stage-rendering-and-sandbox`
116
- `references/admission.md`). An event
117
- declared by `produces event` is still a named slice-owned contract: projections
118
- subscribe to it exactly like a standalone event. Verified extraction preserves
119
- canonical ESM and identities, so it changes no projection contract. Removing a
120
- payload property is different and requires consumer/persistence review.
108
+ `references/admission.md`). An event declared by `produces event` is a named
109
+ slice-owned contract: projections subscribe to it like a standalone event.
110
+ Removing a payload property needs consumer/persistence review.
121
111
 
122
- A read model with several flat `key` parts needs that block in every root `from` and
123
- `remove with` (`PLAY0661`/`PLAY0662`); other blocks and reducers there are `PLAY0268`
124
- (`references/pdl-grammar.md`).
125
-
126
- A second key on one `from` is error `PLAY0060`. A template expression in a
127
- composite key is error `PLAY0073`; an empty composite key is `PLAY0074`.
112
+ Key errors (`PLAY0060`, `PLAY0073`, `PLAY0074`, `PLAY0661`/`PLAY0662`, `PLAY0268`) are in
113
+ [key diagnostics](references/mapping-sources.md#key-diagnostics).
128
114
 
129
115
  ## `from` vs `every` vs `all`
130
116
 
@@ -146,14 +132,17 @@ subscribe to every event type: `all` inside `children` or `nested` behaves as
146
132
  `lastUpdatedAt`. The `every` block **inside** a `children` block does not accept
147
133
  it — it is already in a children context.
148
134
 
135
+ ⚠️ A projection that targets a public event and combines `from` with `every` over different
136
+ producible event types is refused as `InvalidSemanticContract` (no `PLAY` code). Read
137
+ [outbound `every`](references/outbound-every.md) when writing one.
138
+
149
139
  ## One event per level
150
140
 
151
141
  One event type is used once per projection level (`PLAY0801`): two `from` blocks
152
142
  cannot update two rows at that level, even with different keys. Combine mappings
153
143
  for one row; model a genuine second domain fact as its own event. Never invent
154
144
  events only to satisfy the read side. Joins use a separate set; each children,
155
- nested and variant block starts fresh sets. Read [event scope](references/pdl-grammar.md#event-scope)
156
- for grouped events, removals and compiler compatibility.
145
+ nested and variant block starts fresh sets. See [event scope](references/pdl-grammar.md#event-scope).
157
146
 
158
147
  ## Property mapping and AutoMap
159
148
 
@@ -167,24 +156,11 @@ without one, the joined event follows its level's auto-map.
167
156
  Requires Screenplay 4.212.4 (`screenplay --version`) for joined-event auto-map
168
157
  overrides in executable binding; older binders replace the setting with the level's.
169
158
 
170
- Mapping sources: a property path (`name`, `contactInfo.email`), a literal
171
- (`true`, `"Pending"`, `42`, `null`), `$eventSourceId`, and
172
- `$eventContext.<path>` from the event-context catalog (for example `occurred`,
173
- `sequenceNumber`, `correlationId`, `causedBy.subject`; an unknown path warns with
174
- `PLAY0295`). Templates (`` `${first} ${last}` ``) and `$causedBy.<…>` parse but
175
- do not bind to the executable model; write `$eventContext.causedBy.subject`
176
- instead of `$causedBy.subject`.
177
-
178
- ⚠️ Only the event source identity (`$eventSourceId`,
179
- `$eventContext.eventSourceId`) runs in the reference runner. Any other
180
- `$eventContext` path in a mapping or key — `occurred` in the shape above,
181
- `sequenceNumber`, `causedBy.subject` — binds, but the reference execution plan
182
- refuses it, so no specification in that model runs there. Use it when the target
183
- needs it, and report those specifications as needing a target.
184
-
185
- `clear <property>` removes a value and is equivalent to `= null`; prefer `clear`.
186
- It takes a dotted path (`clear Owner.Note`) and escapes reserved names
187
- (`clear @with`).
159
+ Mapping sources are a property path, a literal, `$eventSourceId` and `$eventContext.<path>`.
160
+ ⚠️ Only the event source identity runs in the reference runner; any other `$eventContext`
161
+ path (such as `occurred` in the shape above) binds but its specifications cannot run there.
162
+ `clear <property>` removes a value; prefer it to `= null`. Read
163
+ [mapping sources](references/mapping-sources.md) for the catalog, `PLAY0295` and `clear` paths.
188
164
 
189
165
  ## Arithmetic
190
166
 
@@ -231,12 +207,9 @@ remove via join on CustomerAccountClosed
231
207
 
232
208
  `remove with <Event> [key <expr>]` removes the instance the event identifies.
233
209
  `remove via join on <Event> [key <expr>]` removes instances reached through a
234
- join. On a projection's own level, as in the second line above, it has no
235
- verified meaning — Chronicle's engine wires it as a child removal — so it binds
236
- but the reference execution plan refuses it. Use it inside `children`. Inside
237
- `children`, both take an indented `parent <expr>` — and **only**
238
- `parent`; anything else is error `PLAY0069`. Several removal conditions may
239
- coexist.
210
+ join; on a projection's own level (second line above) it binds but the reference
211
+ execution plan refuses it, so use it inside `children`. There both forms take an
212
+ indented `parent <expr>` and **only** `parent` (`PLAY0069`).
240
213
 
241
214
  ## Variants — one identity, mutually exclusive read models
242
215
 
@@ -248,10 +221,9 @@ A `graph` declares node labels (one `key` each) and edge types; `projection X =>
248
221
  builds it with `node` and `edge` blocks. Nothing writes to a graph except events.
249
222
  Requires Screenplay 5.7.0 (`screenplay --version`).
250
223
 
251
- Choose a graph for traversals (membership, nesting, paths) and a document read model
252
- for lookups by key. Design by **reading the graph backwards**: write each question
253
- as a path, make every hop an edge type and every stop a node label, then name the
254
- event that creates and the one that removes each. Read
224
+ Choose a graph for traversals and a document read model for lookups by key. Design by
225
+ **reading the graph backwards**: write each question as a path, make every hop an edge type
226
+ and every stop a node label, then name the event that creates and removes each. Read
255
227
  [references/graphs.md](references/graphs.md) for syntax, operations, a graph in a named sink
256
228
  (`sink People for graphs`) and `PLAY0862`–`PLAY0877`.
257
229
 
@@ -281,48 +253,31 @@ state depends on the current one — a running balance, a state machine.
281
253
  `Event`, `Key`, `Tenant`, `Occurred`, `SequenceNumber` and `IsFirst` are always
282
254
  there.
283
255
 
284
- What the executable model does with it (ESM v3):
285
-
286
- - Every `on` rule needs a body, inline or `file`. Mixing bodied and body-less
287
- rules is `PLAY0398`; two rules for one event is `PLAY0399`; a reducer with no
288
- bodies is rejected with a hint to write a projection.
289
- - The key is **always the event source id** — a reducer cannot route by an event
290
- property. State starts at null; returning null deletes the instance. A query
291
- `by` another identity type warns `PLAY0690`; use a projection keyed on each `from`
292
- or a join ([reducer identity](references/reducer-identity.md)).
293
- - The body is an opaque attachment identified by a content hash, never compiled
294
- or run by Screenplay. The reference runner cannot compute reducer state, so a
295
- specification that reads a reducer-built read model reports unsupported and
296
- never passes. A target must supply the transition. Stage admits only pure reducer bodies
297
- (Roslyn allowlist, `STAGE-ESM-019`/`-022`); an impure body is gap-fill code, and the model stays the contract.
256
+ `context.Key` is text; read it typed with `context.KeyAs<T>()` (Requires Screenplay 5.2.0).
257
+
258
+ Key facts: every `on` rule needs a body, inline or `file` (`PLAY0398`/`PLAY0399`); the key is
259
+ **always the event source id**, and a query `by` another identity warns `PLAY0690`
260
+ ([reducer identity](references/reducer-identity.md)); the reference runner cannot compute
261
+ reducer state, so a specification reading a reducer-built read model never passes. Read
262
+ [reducer details](references/reducers.md) for `KeyAs<T>()`, the executable-model rules and Stage
263
+ admission.
298
264
 
299
265
  **Prefer a projection where one will do.** A reducer is code, and code is the part
300
266
  of a document a reader cannot check at a glance.
301
267
 
302
268
  Read [pdl-grammar.md](references/pdl-grammar.md) when checking exact syntax, interpreting a projection diagnostic code, or needing a worked example.
303
269
 
304
- ## `STAGE-ESM-017` on a projection passes `validate` and fails at `render`
305
-
306
- Symptom: `cratis screenplay validate --executable` exits 0, then `cratis render` (or `render --check`)
307
- refuses with `STAGE-ESM-017` and a generic message whose location is a `sem1:<hash>`, not a source line
308
- (seen on Stage 4.192.0 and CLI 3.94.0). Cause: `validate --executable` binds only Screenplay's model;
309
- Stage's admission runs only in `render`. Check every `from` block in turn:
310
-
311
- 1. **Key.** An event property or the event source. A root `from` also accepts a constant text key (nonempty, only letters, digits, `_`, space and `. / : * + -`); any other literal key, and a literal key outside a root, is refused.
312
- 2. **Do not overwrite the key.** A mapping onto the key property must restate the key itself (`from E` keyed by the event source with `berthId = $eventSourceId`, or the key's own event property); mapping a different value onto it is refused (`MatchesKey`). Simplest is to leave the key property unmapped.
313
- 3. **`$eventSourceId` into a non-key target** is admitted in a `from` block keyed by an event property, when every command and reaction producing the event addresses it with a non-collection value of exactly the target's type (optionality ignored). It is refused in `join`s, for a mismatched type, and for an event nothing produces.
314
- 4. **No `$context.*`.** Map an event property instead and have the command set it. The compiler may refuse it first (`PLAY0152`); Stage refuses a context value in a projection with `STAGE-ESM-017`.
315
- 5. **Targets.** A target path through an optional or non-composite intermediate is refused; an optional leaf and a path through required composites are fine. The event property mapped from must exist on the event.
270
+ ## `STAGE-ESM-017` passes `validate` and fails at `render`
316
271
 
317
- Bisect: run `cratis render <root> --target cratis --name <App> --destination <dir> --check` (plans,
318
- writes nothing), comment out `from` blocks one at a time until the error clears, then apply the list to
319
- the block that cleared it. Reference: `cratis-stage-rendering-and-sandbox` `references/admission.md`.
272
+ `validate --executable` binds only Screenplay's model; Stage's admission runs only in `render`.
273
+ Read [Stage admission](references/stage-admission.md) when `cratis render` refuses a projection
274
+ with `STAGE-ESM-017` after `validate` exits 0.
320
275
 
321
276
  ## Verify
322
277
 
323
- - [ ] Standalone `screenplay <model> --warnaserror` reports zero errors and zero
324
- warnings; or `cratis screenplay validate --warnings-as-errors` on the model folder
325
- (an older bundled compiler can stop at a lower ESM version). Name which tool produced the result. If it reports diagnostics, correct the model and rerun the same command; report unresolved diagnostics as blockers rather than a passing verification.
278
+ - [ ] Standalone `screenplay <model> --warnaserror` or `cratis screenplay validate --warnings-as-errors`
279
+ reports zero errors and warnings (an older bundled compiler can stop at a lower ESM version).
280
+ Name the tool; fix and rerun, and report unresolved diagnostics as blockers.
326
281
  - [ ] Each read model has **exactly one** builder.
327
282
  - [ ] No projection-level `key`; every `from` that must address the same
328
283
  instance is keyed on the same identity.
@@ -332,8 +287,7 @@ the block that cleared it. Reference: `cratis-stage-rendering-and-sandbox` `refe
332
287
  right level.
333
288
  - [ ] Every `children` block's `from` declares `parent`.
334
289
  - [ ] Every `nested` block contains at least one `from`.
335
- - [ ] No `$causedBy`, template or `sequence` where the model must run.
336
- - [ ] Where specifications must run in the reference runner: no `$eventContext`
290
+ - [ ] Where the model must run: no `$causedBy`, template or `sequence`; no `$eventContext`
337
291
  path other than `eventSourceId`, no projection-level `remove via join`, no
338
292
  `all` beside removals, `children` or `nested`, and no `join`, `children` or
339
293
  `remove via join` inside `nested`.
@@ -0,0 +1,33 @@
1
+ # Mapping sources and key diagnostics
2
+
3
+ Read this when choosing what a property mapping reads from, using `$eventContext`, or diagnosing a key error.
4
+
5
+ ## Mapping sources
6
+
7
+ A property path (`name`, `contactInfo.email`), a literal
8
+ (`true`, `"Pending"`, `42`, `null`), `$eventSourceId`, and
9
+ `$eventContext.<path>` from the event-context catalog (for example `occurred`,
10
+ `sequenceNumber`, `correlationId`, `causedBy.subject`; an unknown path warns with
11
+ `PLAY0295`). Templates (`` `${first} ${last}` ``) and `$causedBy.<…>` parse but
12
+ do not bind to the executable model; write `$eventContext.causedBy.subject`
13
+ instead of `$causedBy.subject`.
14
+
15
+ ⚠️ Only the event source identity (`$eventSourceId`,
16
+ `$eventContext.eventSourceId`) runs in the reference runner. Any other
17
+ `$eventContext` path in a mapping or key — `occurred`, `sequenceNumber`,
18
+ `causedBy.subject` — binds, but the reference execution plan
19
+ refuses it, so no specification in that model runs there. Use it when the target
20
+ needs it, and report those specifications as needing a target.
21
+
22
+ `clear <property>` removes a value and is equivalent to `= null`; prefer `clear`.
23
+ It takes a dotted path (`clear Owner.Note`) and escapes reserved names
24
+ (`clear @with`).
25
+
26
+ ## Key diagnostics
27
+
28
+ A read model with several flat `key` parts needs that block in every root `from` and
29
+ `remove with` (`PLAY0661`/`PLAY0662`); other blocks and reducers there are `PLAY0268`
30
+ (see [pdl-grammar.md](pdl-grammar.md)).
31
+
32
+ A second key on one `from` is error `PLAY0060`. A template expression in a
33
+ composite key is error `PLAY0073`; an empty composite key is `PLAY0074`.
@@ -0,0 +1,12 @@
1
+ # `from` plus `every` in an outbound event projection
2
+
3
+ Read this when a projection that targets a public event combines `from` and `every`.
4
+
5
+ In an outbound Translate slice, events that outbound projections publish count as producers for
6
+ routed facts, `every`/`all` scopes and source-type inference. An `every` scope therefore folds
7
+ every producible event type, so a projection that combines `from` and `every` over *different*
8
+ producible event types is ambiguous and refused: the published event no longer has one distinct
9
+ source type. The executable model reports it as `InvalidSemanticContract` ("needs one unambiguous
10
+ declared producer destination type") when a routed fact or specification fixture needs that
11
+ type; no `PLAY` code is assigned. Keep the producing events to one source type, or drop `every`
12
+ and map each event in its own `from`.
@@ -0,0 +1,40 @@
1
+ # Reducer details
2
+
3
+ Read this when writing a reducer body that needs the read model's key, or when checking what the
4
+ executable model and the reference runner do with a reducer.
5
+
6
+ ## Reading the key as a typed value
7
+
8
+ `context.Key` is text. Read it as the read model's key type with `context.KeyAs<T>()`
9
+ instead of parsing it: `T` is `string`, `Guid` (UUID text in N, D, B or P form, without
10
+ whitespace) or a key concept with one public constructor taking a `string` or `Guid`.
11
+
12
+ ```csharp
13
+ var id = context.KeyAs<AccountId>();
14
+ return context.State is null
15
+ ? new(id, context.Event.amount)
16
+ : context.State with { balance = context.State.balance + context.Event.amount };
17
+ ```
18
+
19
+ Malformed UUID text and an unsupported `T` throw `ContextKeyNotConvertible` (the raw key is
20
+ not in the message); a concept's own validation exception propagates unchanged. The compiler
21
+ accepts `KeyAs<T>()` only for a read model with one required, non-collection Uuid or Text key;
22
+ a composite key and a reducer that targets an event keep reading `Key`. This is executable-model
23
+ support: Stage does not yet generate `KeyAs<T>()` on typed reducer contexts, so a rendered reducer
24
+ that needs it is a gap to fill by hand.
25
+ Requires Screenplay 5.2.0 (`screenplay --version`); an older tool has no `KeyAs<T>()`.
26
+
27
+ ## What the executable model does (ESM v3)
28
+
29
+ - Every `on` rule needs a body, inline or `file`. Mixing bodied and body-less
30
+ rules is `PLAY0398`; two rules for one event is `PLAY0399`; a reducer with no
31
+ bodies is rejected with a hint to write a projection.
32
+ - The key is **always the event source id** — a reducer cannot route by an event
33
+ property. State starts at null; returning null deletes the instance. A query
34
+ `by` another identity type warns `PLAY0690`; use a projection keyed on each `from`
35
+ or a join ([reducer identity](reducer-identity.md)).
36
+ - The body is an opaque attachment identified by a content hash, never compiled
37
+ or run by Screenplay. The reference runner cannot compute reducer state, so a
38
+ specification that reads a reducer-built read model reports unsupported and
39
+ never passes. A target must supply the transition. Stage admits only pure reducer bodies
40
+ (Roslyn allowlist, `STAGE-ESM-019`/`-022`); an impure body is gap-fill code, and the model stays the contract.
@@ -0,0 +1,18 @@
1
+ # `STAGE-ESM-017` on a projection passes `validate` and fails at `render`
2
+
3
+ Read this when `cratis render` refuses a projection that `cratis screenplay validate --executable` accepted.
4
+
5
+ Symptom: `cratis screenplay validate --executable` exits 0, then `cratis render` (or `render --check`)
6
+ refuses with `STAGE-ESM-017` and a generic message whose location is a `sem1:<hash>`, not a source line
7
+ (seen on older Stage and CLI builds). Cause: `validate --executable` binds only Screenplay's model;
8
+ Stage's admission runs only in `render`. Check every `from` block in turn:
9
+
10
+ 1. **Key.** An event property or the event source. A root `from` also accepts a constant text key (nonempty, only letters, digits, `_`, space and `. / : * + -`); any other literal key, and a literal key outside a root, is refused.
11
+ 2. **Do not overwrite the key.** A mapping onto the key property must restate the key itself (`from E` keyed by the event source with `berthId = $eventSourceId`, or the key's own event property); mapping a different value onto it is refused (`MatchesKey`). Simplest is to leave the key property unmapped.
12
+ 3. **`$eventSourceId` into a non-key target** is admitted in a `from` block keyed by an event property, when every command and reaction producing the event addresses it with a non-collection value of exactly the target's type (optionality ignored). It is refused in `join`s, for a mismatched type, and for an event nothing produces.
13
+ 4. **No `$context.*`.** Map an event property instead and have the command set it. The compiler may refuse it first (`PLAY0152`); Stage refuses a context value in a projection with `STAGE-ESM-017`.
14
+ 5. **Targets.** A target path through an optional or non-composite intermediate is refused; an optional leaf and a path through required composites are fine. The event property mapped from must exist on the event.
15
+
16
+ Bisect: run `cratis render <root> --target cratis --name <App> --destination <dir> --check` (plans,
17
+ writes nothing), comment out `from` blocks one at a time until the error clears, then apply the list to
18
+ the block that cleared it. Reference: `cratis-stage-rendering-and-sandbox` `references/admission.md`.
@@ -4,9 +4,8 @@
4
4
  "fixtures": [],
5
5
  "assertions": [
6
6
  { "kind": "play-compiles" },
7
- { "kind": "skill-contains", "value": "it changes no projection contract" },
8
7
  { "kind": "skill-contains", "value": "map the read-model identity from `$eventSourceId`" },
9
- { "kind": "skill-contains", "value": "Look first for the project's existing `.play` files" },
8
+ { "kind": "skill-contains", "value": "The folder holding the project's existing `.play` files" },
10
9
  { "kind": "skill-contains", "value": "`cratis ai install` manages `.cratis/ai/`, never model files" },
11
10
  { "kind": "skill-contains", "value": "AutoMap is on by default" },
12
11
  { "kind": "skill-contains", "value": "decides auto-mapping for that event alone" },
@@ -25,7 +24,7 @@
25
24
  { "kind": "skill-contains", "value": "references/pdl-grammar.md" },
26
25
  { "kind": "skill-contains", "value": "Do not write `key` on the projection." },
27
26
  { "kind": "skill-contains", "value": "**routes nothing** (`PLAY0381`)" },
28
- { "kind": "skill-contains", "value": "The key is **always the event source id**" },
27
+ { "kind": "skill-contains", "value": "The key is **always the event source id**", "file": "references/reducers.md" },
29
28
  { "kind": "skill-contains", "value": "**A join never creates an" },
30
29
  { "kind": "skill-contains", "value": "Inline code uses a tagged fence" },
31
30
  { "kind": "skill-contains", "value": "PLAY0690", "file": "references/reducer-identity.md" },