@cratis/pi 7.6.1 → 7.6.3

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 (31) hide show
  1. package/package/corpus/rules/reactors.md +11 -0
  2. package/package/corpus/rules/vertical-slices.md +27 -0
  3. package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +38 -1
  4. package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +7 -2
  5. package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +14 -0
  6. package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +20 -0
  7. package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +36 -2
  8. package/package/corpus/skills/cratis-chronicle-read-model/references/queries.md +37 -0
  9. package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +16 -0
  10. package/package/corpus/skills/cratis-performance-review/SKILL.md +14 -1
  11. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +8 -0
  12. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/verification.json +3 -0
  13. package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +85 -8
  14. package/package/corpus/skills/cratis-screenplay-command-surface/references/context.md +10 -0
  15. package/package/corpus/skills/cratis-screenplay-command-surface/verification.json +10 -0
  16. package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +20 -7
  17. package/package/corpus/skills/cratis-screenplay-event-modeling/references/nine-steps.md +25 -15
  18. package/package/corpus/skills/cratis-screenplay-event-modeling/verification.json +4 -1
  19. package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +44 -8
  20. package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +40 -21
  21. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-tools.md +53 -1
  22. package/package/corpus/skills/cratis-screenplay-model-authoring/verification.json +7 -0
  23. package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +11 -0
  24. package/package/corpus/skills/cratis-screenplay-projections/verification.json +3 -0
  25. package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +26 -14
  26. package/package/corpus/skills/cratis-screenplay-read-surface/verification.json +4 -0
  27. package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +18 -12
  28. package/package/corpus/skills/cratis-screenplay-specifications/verification.json +4 -0
  29. package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +16 -9
  30. package/package/corpus/skills/cratis-screenplay-ui-composition/verification.json +5 -0
  31. package/package.json +1 -1
@@ -85,7 +85,9 @@ Commands are imperative and present tense: `RegisterInvoice`, `ProcessPayment`.
85
85
  **Output:** the `command` declaration with its properties, its `identifier`
86
86
  property (at most one; leave it out only when the runtime should allocate a new
87
87
  identity), `authorize`, and `produces`. Excerpt: the concepts, the policy and the
88
- event are declared elsewhere in the model.
88
+ event are declared elsewhere in the model. Give the event a description of the
89
+ fact, and fenced Markdown `documentation` when its meaning needs elaboration.
90
+ Alternatively, declare it in the command with `produces event` and typed mappings.
89
91
 
90
92
  ```screenplay
91
93
  slice StateChange RegisterInvoice
@@ -96,7 +98,7 @@ slice StateChange RegisterInvoice
96
98
  validate
97
99
  invoiceNumber not empty message "Invoice number is required"
98
100
  produces InvoiceRegistered
99
- invoiceId = invoiceId
101
+ for invoiceId
100
102
  invoiceNumber = invoiceNumber
101
103
  registeredAt = $context.occurred
102
104
  ```
@@ -116,7 +118,7 @@ Verify **every** field traces back to an event:
116
118
 
117
119
  ```text
118
120
  InvoiceListReadModel:
119
- invoiceId <- InvoiceRegistered.invoiceId
121
+ invoiceId <- InvoiceRegistered event context ($eventSourceId)
120
122
  invoiceNumber <- InvoiceRegistered.invoiceNumber
121
123
  status <- InvoiceRegistered, InvoiceSent, InvoicePaid
122
124
  ```
@@ -128,10 +130,11 @@ a collection type, not a singular value.
128
130
  builds it. **Exactly one thing may build a read model** — two builders is a
129
131
  compile error (`PLAY0191`).
130
132
 
131
- Key **every** `from` on the value that identifies the instance. A `from` without a
132
- key routes by the event's event source id, not by the key of another `from`, and
133
- a `key` written directly on the projection routes nothing (`PLAY0381`). Excerpt:
134
- the concepts and events are declared elsewhere, and both events carry `invoiceId`.
133
+ Route each `from` deliberately. When the instance is the event source, omit the
134
+ key and map its identity from `$eventSourceId`; do not duplicate it in payload.
135
+ A `from` without a key never inherits another `from`'s key, and a projection-level
136
+ `key` routes nothing (`PLAY0381`). Excerpt: the concepts and events are declared
137
+ elsewhere, and both events target the invoice's event source.
135
138
 
136
139
  ```screenplay
137
140
  slice StateView InvoiceList
@@ -140,9 +143,11 @@ slice StateView InvoiceList
140
143
  invoiceNumber InvoiceNumber
141
144
  status InvoiceStatus
142
145
  projection InvoiceList => InvoiceListReadModel
143
- from InvoiceRegistered key invoiceId
146
+ from InvoiceRegistered
147
+ invoiceId = $eventSourceId
144
148
  status = "draft"
145
- from InvoiceSent key invoiceId
149
+ from InvoiceSent
150
+ invoiceId = $eventSourceId
146
151
  status = "sent"
147
152
  query ListInvoices => InvoiceListReadModel[]
148
153
  ```
@@ -164,20 +169,25 @@ system state?"* If no, it is co-production — one `StateChange` slice with seve
164
169
  **Output:** the `reaction`, in an `Automation` slice. It documents the automation;
165
170
  it does not bind to the executable model today. When the automation decides from
166
171
  a view, declare it under the trigger with `reads` (see
167
- `cratis-screenplay-captures-and-reactions`). Excerpt: the event and the
168
- command are declared in their own slices.
172
+ `cratis-screenplay-captures-and-reactions`). Intent-only excerpt: the event and
173
+ command are declared in their own slices; the view comes from Step 6.
169
174
 
170
175
  ```screenplay
171
176
  slice Automation ChaseOverdueInvoices
172
177
  reaction OverdueChaser
173
178
  when InvoiceRegistered
174
- invoiceId
175
- dueDate
179
+ description "Check the invoice's due date and unpaid state before requesting MarkInvoiceOverdue for the triggering event's source"
180
+ reads InvoiceListReadModel
176
181
  invokes MarkInvoiceOverdue
177
- invoiceId = invoiceId
178
- where dueDate < today
179
182
  ```
180
183
 
184
+ The realization must obtain `invoiceId` from the triggering event's source
185
+ identity, not its payload. Screenplay does not yet document a reaction-context
186
+ binding for invocation arguments; `$eventSourceId` is documented for projections,
187
+ not reaction mappings. Leave the argument mapping and overdue decision as intent
188
+ until realization supplies them. Do not select missing `invoiceId` or `dueDate`
189
+ payload fields from Step 5's event, or add them merely to make this reaction parse.
190
+
181
191
  `produces` and `invokes` are indented **inside** the trigger; only `description`
182
192
  and `where` sit at reaction level. Outdenting an effect gives `PLAY0137`.
183
193
 
@@ -3,6 +3,9 @@
3
3
  "input": "Facilitate an event modeling session and land the model as .play source.",
4
4
  "fixtures": [],
5
5
  "assertions": [
6
+ { "kind": "skill-contains", "value": "main `fd18129`" },
7
+ { "kind": "skill-contains", "value": "Inline events remain slice-owned contracts" },
8
+ { "kind": "skill-contains", "value": "Storage identity is not payload identity" },
6
9
  {
7
10
  "kind": "skill-contains",
8
11
  "value": ".cratis/screenplay/"
@@ -41,7 +44,7 @@
41
44
  },
42
45
  {
43
46
  "kind": "skill-contains",
44
- "value": "are accepted but\n**not available**"
47
+ "value": "Event generations and typed repairs now ship"
45
48
  },
46
49
  {
47
50
  "kind": "skill-contains",
@@ -13,20 +13,25 @@ the compiler already knows declarations, references, hierarchy and source owners
13
13
  Screenplay remains experimental. **Valid source is not necessarily executable.**
14
14
  It does not generate or run an application; Stage owns rendering/runtime admission.
15
15
  See the [language reference](references/language-reference.md) for constructs,
16
- the executable profile and the complete canonical model.
16
+ the executable profile and a complete compiled model.
17
17
 
18
18
  ## Verified product sources
19
19
 
20
20
  | Package | Version | Purpose |
21
21
  | --- | --- | --- |
22
- | `Cratis.Screenplay` | `4.31.0` | Compiler, executable semantic model (ESM), workspace and MCP server |
22
+ | `Cratis.Screenplay` | `4.31.0` | Original compiler, ESM and workspace evidence |
23
+ | `Cratis.Screenplay` | main `fd18129` | Inline events, repairs, rename/extraction and `optional` |
24
+
25
+ The update follows `commands.md`, `events.md`, `types.md`, `diagnostics.md`,
26
+ `mcp/authoring-tools.md`, `vscode.md` and decision 0023 at that main commit
27
+ (after v4.52.0). Changed examples were compiled; MCP contracts were read, not
28
+ exercised against a live server.
23
29
 
24
30
  Checked against the Screenplay repository at tag `v4.31.0` (commit `355dffb`):
25
31
  `Documentation/screenplay/{ast-authoring,mcp,mcp-authoring,printing,file-references,diagnostics}.md`
26
- and the release notes for v4.17.0 to v4.31.0. The canonical model in the language
27
- reference compiles with zero diagnostics, binds to ESM v1, and both its
28
- specifications pass the reference runner at that tag. Reverify before claiming
29
- another version behaves the same.
32
+ and the release notes for v4.17.0 to v4.31.0 established the original baseline.
33
+ The updated registration model in the language reference uses inline events and
34
+ `optional`; its current verification is compilation, not reference execution.
30
35
 
31
36
  ## Locate and connect
32
37
 
@@ -105,7 +110,38 @@ each lost comment (`PLAY0288` also reports their count and lines). Untouched
105
110
  documents retain exact bytes. A printer that loses requested structural fields
106
111
  rejects the plan.
107
112
 
108
- Read the [MCP tool guide](references/mcp-tools.md) for tool groups and refusals.
113
+ ## Repair or extract before rewriting
114
+
115
+ Read `read-workspace` with `view: "diagnostics"`, then `view: "repairs"` at the
116
+ same revision. Pass the returned `diagnosticCode`, `subject`, required formatting
117
+ and both revisions to `propose-repair`; preview with `read-proposal`, then `apply`.
118
+ Discovery lists verified repairs only when their acceptance checks pass (the
119
+ legacy `PLAY0397` fence recipe is an exception). A cached discovery verdict is
120
+ not a cached proposal: the selected repair gets a fresh transaction.
121
+
122
+ - `PLAY0166`: declare a missing produced event only when mapping types are known.
123
+ - `PLAY0478`: explicitly choose the identifier destination for a plain production;
124
+ this is a routing decision, not a spelling-only cleanup.
125
+ - `PLAY0471`: remove a redundant name-equal event pin without changing semantics.
126
+ - `PLAY0469`: remove an inline identifier payload copy. It **changes the event
127
+ contract**, retires a property and refuses consumer/opaque impact. No fix-all.
128
+ The catalog does not prove whether events were persisted; ask about stored
129
+ contracts before removing fields. No automatic generation-evolution repair ships.
130
+ - `PLAY0479`: migrate optionality spelling with `PreserveTrivia`; document scope
131
+ migrates all occurrences together. Keep the `query Q => observable?` exception.
132
+
133
+ Use `propose-extract-inline-event` on the inline `EventSyntax` handle before
134
+ adding a generation. It makes the declaration standalone, preserves metadata,
135
+ identities and canonical ESM, and states the formerly implicit `for`. It needs
136
+ canonical formatting consent and refuses comment loss. There is no reverse
137
+ inlining operation.
138
+
139
+ Event `propose-rename` pins `id "<old name>"` by default; existing older pins
140
+ survive. Use `eventNeverPersisted: true` only when that is known, to skip a new
141
+ pin. Renaming back to the pinned name removes it. Catalog persistence and stored
142
+ event history are different things.
143
+
144
+ Read the [MCP tool guide](references/mcp-tools.md) for exact repair limits and refusals.
109
145
 
110
146
  ## Choose a readable layout
111
147
 
@@ -186,7 +222,7 @@ The ordinary CLI remains useful for whole-folder validation:
186
222
  cratis screenplay validate .cratis/screenplay --warnings-as-errors
187
223
  ```
188
224
 
189
- MCP guidance here follows the Screenplay 4.31.0 server documentation. The Cratis
225
+ Repair and refactoring guidance follows Screenplay main `fd18129`. The Cratis
190
226
  CLI bundles its own Screenplay version, so check the installed `tools/list`
191
227
  schemas before relying on a view or argument named here (for example
192
228
  `dropped-comments` or `implementation-requirements`). Do not invent a command,
@@ -57,12 +57,12 @@ tagged fence (` ```csharp `); the older language-line form still parses with
57
57
  warning `PLAY0397`. Query the MCP's `syntax-schema` instead of inventing JSON
58
58
  members or translating names from memory.
59
59
 
60
- ## Canonical complete model
60
+ ## Complete model
61
61
 
62
- The RegisterProject conformance vector is the narrow executable example shared
63
- by downstream tooling. Its source is shipped in `Cratis.Screenplay.CanonicalCorpus`.
64
- At v4.31.0 it compiles with zero diagnostics, binds to ESM v1, and both
65
- specifications pass the reference runner.
62
+ This registration model uses an inline event and context identity rather than
63
+ copying the identifier into payload. It was compiled at main `fd18129` with zero
64
+ source diagnostics; that check does not run its specifications. Inline lowering
65
+ and `optional` spelling do not themselves select a newer ESM version.
66
66
 
67
67
  ```screenplay
68
68
  concept ProjectId : Uuid
@@ -75,19 +75,14 @@ module Projects
75
75
  name ProjectName
76
76
  validate
77
77
  name not empty message "Project name is required"
78
- produces ProjectRegistered
79
- for projectId
80
- projectId = projectId
81
- name = name
82
- event ProjectRegistered
83
- projectId ProjectId
84
- name ProjectName
78
+ produces event ProjectRegistered
79
+ name ProjectName = name
85
80
  specification RegisteringAProject
86
81
  when RegisterProject
87
82
  projectId = "3fa85f64-5717-4562-b3fc-2c963f66afa6"
88
83
  name = "Screenplay"
89
84
  then ProjectRegistered
90
- projectId = "3fa85f64-5717-4562-b3fc-2c963f66afa6"
85
+ for "3fa85f64-5717-4562-b3fc-2c963f66afa6"
91
86
  name = "Screenplay"
92
87
  then readmodel ProjectSummary
93
88
  projectId = "3fa85f64-5717-4562-b3fc-2c963f66afa6"
@@ -107,10 +102,11 @@ module Projects
107
102
  readmodel ProjectSummary
108
103
  projectId ProjectId
109
104
  name ProjectName
110
- query ProjectById => ProjectSummary?
105
+ query ProjectById => ProjectSummary optional
111
106
  by projectId ProjectId
112
107
  projection ProjectSummaryProjection => ProjectSummary
113
- from ProjectRegistered key projectId
108
+ from ProjectRegistered
109
+ projectId = $eventSourceId
114
110
  name = name
115
111
  ```
116
112
 
@@ -136,6 +132,13 @@ The ESM version is selected by what a model uses, never by the author:
136
132
  `policy` implemented in code or a file. They bind as opaque requirements with
137
133
  capability `pure`. The reference runner returns `SemanticUnsupported` whenever
138
134
  it would need one, so a specification that depends on one never passes.
135
+ - **v4** represents complete event generations, with one contract identity and
136
+ distinct revision property identities. Historical declarations are not migration
137
+ implementations; a target without migration support must reject the contract.
138
+
139
+ Inline events lower to slice-owned standalone contracts and preserve equivalent
140
+ canonical bytes. Event `description`, `documentation` and rename-only `id` are
141
+ authoring metadata, not new ESM bytes or replacements for catalog identity.
139
142
 
140
143
  Binding is not the last gate before the reference runner. The runner needs an
141
144
  execution plan, and the plan is created only when every reachable capability is
@@ -150,7 +153,7 @@ what blocks binding (Screenplay v4.31.0):
150
153
  | Binds and runs in the reference runner | `StateChange`/`StateView` slices; `produces` including `when` conditions over command properties and literal tags; the portable validation rules, `matches email`, quoted `matches` patterns and `require` over command properties; declarative policies and `authorize` on modules, features, commands and keyed queries; `unique` constraints; projections as Chronicle lowers them, including variants, except the projection constructs in the next row; specifications, including `given caller`, `then denied` and `when append` |
151
154
  | Binds, but the reference execution plan refuses it | A projection-level `remove via join`; `all` beside removals, `children` or `nested`; a `join`, `children` or `remove via join` inside `nested`; any event-context value other than the event source identity in a projection mapping or key, such as `$eventContext.occurred`, `$eventContext.sequenceNumber` or `$eventContext.causedBy.subject` (`$eventSourceId` and `$eventContext.eventSourceId` run) |
152
155
  | Binds as opaque code (v3); reference runner reports unsupported | Bodied reducers, bodied named rules, fenced `validate` blocks, code or file policies |
153
- | Blocks binding (`PLAY0268`) | `Automation` and `Translate` slices, reactions (with or without trigger `reads`), captures, top-level `trigger`, `persona`, `@pii`/`@sensitive` concepts, command `handler`, bare `rule <Name>`, `require` or conditions over read-model paths, dates and `today` in comparisons, `$context.tenant`/claims/roles/causation in `produces`, `$env` conditions, `file` constraints, a read model whose keyed queries in its own slice do not share one `by` property (none, or two different properties; several queries over the same property bind), any query other than `=> <ReadModel>?` with one caller-supplied `by` argument (so also observable, filtered, scoped and performer-backed queries), `$causedBy` and templates in projections |
156
+ | Blocks binding (`PLAY0268`) | `Automation` and `Translate` slices, reactions (with or without trigger `reads`), captures, top-level `trigger`, `persona`, `@pii`/`@sensitive` concepts, command `handler`, bare `rule <Name>`, `require` or conditions over read-model paths, dates and `today` in comparisons, `$context.tenant`/claims/roles/causation in `produces`, `$env` conditions, `file` constraints, a read model whose keyed queries in its own slice do not share one `by` property (none, or two different properties; several queries over the same property bind), any query other than `=> <ReadModel> optional` with one caller-supplied `by` argument (so also observable, filtered, scoped and performer-backed queries), `$causedBy` and templates in projections |
154
157
  | Blocks binding (`PLAY0271`, legacy meaning) | Command `reads` and `concurrency` |
155
158
  | Deferred (`PLAY0269`, information) | Screens, layouts, templates, forms, contributions, UI profiles, themes, behaviors and `on`/`uses` |
156
159
  | Metadata only (`PLAY0270`, information) | `domain`, `seed`, descriptions and `file` provenance on declarations |
@@ -168,11 +171,27 @@ Decision 0006 shipped in Screenplay 4.31.0: a reaction trigger may declare
168
171
  `cratis-screenplay-captures-and-reactions`). Reactions still block binding, so
169
172
  those reads are declared, not enforced.
170
173
 
171
- Screenplay decisions 0007 to 0014 are accepted but not implemented. Do not write
172
- their syntax: affected-instance declarations, per-event data subjects, external event origin, query paging/sorting/change-set delivery, event
173
- generations, a typed context descriptor or command-handler role, code round-trip
174
- equivalence, or typed diagnostic repairs. Model today's syntax and record the
175
- gap in prose or an issue.
174
+ Do not infer availability from an accepted decision. Event generations and typed
175
+ diagnostic repairs now exist; see the event and MCP references rather than the
176
+ old blanket claim that decisions 0011–0014 are unimplemented. Generations describe
177
+ full historical shapes, not deployed-schema immutability or a working migrator.
178
+ Code attachment/source-map support likewise does not prove code round-trip
179
+ execution equivalence.
180
+
181
+ Decision 0023's generated values and `returns` (allocated ESM v8), operations
182
+ (v9), named event sources/streams (v10), and protected reads, `derive`/`provide`
183
+ (v11) are planned, not available yet. Do not teach their example syntax as usable.
184
+ The allocations are not shipped capabilities. Affected-instance declarations,
185
+ per-event data subjects, external event origin and query paging/sorting/change-set
186
+ delivery also remain unavailable here.
187
+
188
+ `Type optional` is canonical for admitted type references; `Type?` remains
189
+ compatible with information `PLAY0479`. The modifier follows `[]` for an optional
190
+ collection. It changes no `IsOptional` meaning or ESM bytes. Keep the exceptional
191
+ one-shot result `query Q => observable?` when the type itself is named
192
+ `observable`: `observable optional` would be parsed as a live result of a type
193
+ named `optional`. Screen data, behavior parameters, concept bases and
194
+ `reads X optional` do not accept optionality.
176
195
 
177
196
  ## Editor support
178
197
 
@@ -20,7 +20,7 @@ these short descriptions.
20
20
  | References and examples | `find-references`, `dependencies`, `find-fixtures`, `find-assertion-gaps` | Inspect declared relationships and authored examples, not executed coverage |
21
21
  | Source and validation | `diagnostics`, `read-document`, `merged-document`, `syntax-schema` | Read exact source or typed structure and diagnose problems |
22
22
  | Workspace inspection | `open-workspace`, `read-workspace`, `read-ast`, `workspace-state`, `export-workspace` | Obtain current identities, handles, readiness, code attachment requirements and durable-state status |
23
- | Planning | `propose-ast`, `propose-rename`, `propose`, `recommend-layout`, `expand-layout` | Produce validated, reviewable candidates without writing them |
23
+ | Planning | `propose-ast`, `propose-rename`, `propose-repair`, `propose-extract-inline-event`, `propose`, `recommend-layout`, `expand-layout` | Produce validated, reviewable candidates without writing them |
24
24
  | Review | `read-proposal`, `discard-proposal` | Inspect exact changes, dropped comments and proposed attachments, or abandon a connection-local proposal |
25
25
  | Effects | `apply`, `recover-workspace` | Apply an accepted plan or explicitly recover an interrupted write |
26
26
 
@@ -29,6 +29,58 @@ for full-language authoring and `propose-rename` for proved logical renames. A
29
29
  source-only authoring proposal may be accepted while `executableReady` is false.
30
30
  That is not permission to claim the application runs.
31
31
 
32
+ ## Diagnostic repairs and refactorings
33
+
34
+ Check installed `tools/list` before using these capabilities. Read `read-workspace`
35
+ with `view: "diagnostics"`, then `view: "repairs"` at the current revision.
36
+ `read-ast` reports parser diagnostics, not all compilation diagnostics.
37
+
38
+ | Code | Offered repair and boundary |
39
+ | --- | --- |
40
+ | `PLAY0166` | Declare a missing command-produced event in its slice. Infer known command-path types (retaining concepts) or `$context.occurred` as `DateTime`; refuse uncertain/conflicting shapes, imports, existing declarations, cross-file producers and parser-invalid workspaces. |
41
+ | `PLAY0478` | Add `for <identifier>` to a plain production. Both models must be executable; refuse a version change or retargeting another production. Accept only if the identifier, not allocation, is intended. |
42
+ | `PLAY0471` | Remove a redundant event id only with unchanged executable model, catalog and comments. |
43
+ | `PLAY0469` | Remove an inline same-source identifier property and mapping, retiring its semantic address. This changes the contract; `canFixAll` is false. Refuse other consumers, opaque impact, changed routing or comment loss. Plain contracts get guidance only. |
44
+ | `PLAY0479` | Migrate one optional type spelling, or all in a document, preserving syntax and trivia. Exclude `query Q => observable?`. |
45
+
46
+ These discoveries verify acceptance before listing a repair. Only compact
47
+ acceptance/conflict verdicts are cached on the immutable snapshot, not diagnostics,
48
+ proposals or write plans. Optionality discovery verifies the document migration
49
+ once, then offers its occurrences. `PLAY0397` on legacy `validate csharp` is a
50
+ recipe-only discovery whose proposal may still fail; do not generalize it to all
51
+ legacy fences.
52
+
53
+ Send the selected `diagnosticCode` and original `subject` to `propose-repair`,
54
+ with both revisions and the returned `requiredFormatting`. For optionality,
55
+ select `scope: "document"` during discovery to get the document root handle;
56
+ pass that handle, not a scope argument, to the proposal. Its default is
57
+ `PreserveTrivia`; the other listed repairs need explicit
58
+ `CanonicalizeTouchedDocuments` consent. Every proposal runs one fresh transaction
59
+ for the selected subject. Review bytes before `apply`; no discovery writes files.
60
+
61
+ An unknown code, subject or recipe yields `UnknownRepair`. A known recipe that
62
+ fails verification returns `success: false`, typed `conflicts`,
63
+ `authoringDiagnostics` and `executableDiagnostics`, without a proposal ID.
64
+ `InvalidOperation` is a transaction conflict, not an unknown recipe. Rediscover
65
+ after revision drift; never turn a refusal into a text replacement.
66
+
67
+ `propose-extract-inline-event` takes the inline event's `subject`, both revisions
68
+ and `formatting: "CanonicalizeTouchedDocuments"`. It moves the declaration to
69
+ its owning slice and makes an implicit identifier destination explicit. Metadata,
70
+ tags and identities survive; canonical ESM must stay byte-identical and every
71
+ comment must survive exactly once. Extract before adding `generation`, not after
72
+ making the document parser-invalid. This is a refactoring, not a diagnostic repair.
73
+
74
+ `propose-rename` conservatively pins an event's previous effective name. Set
75
+ `eventNeverPersisted: true` only with knowledge of storage history; the identity
76
+ catalog is not that evidence. It skips a new pin, removes a redundant current-name
77
+ pin, but retains a pin for a different earlier name. Contradictory generation pins
78
+ refuse the rename. Do not promise a generation-2 payload-removal repair or a
79
+ `PLAY0470` repair: neither is available.
80
+
81
+ VS Code and Monaco provide local optionality quick fixes without .NET; they do
82
+ not host these production-repair transactions. Use MCP for production repairs.
83
+
32
84
  ## Revision and ownership rules
33
85
 
34
86
  - A source query's `sourceRevision` binds its pages. Use `expectedSourceRevision`
@@ -3,6 +3,13 @@
3
3
  "input": "Author and organize a Screenplay model in a repository.",
4
4
  "fixtures": [],
5
5
  "assertions": [
6
+ { "kind": "skill-contains", "value": "main `fd18129`" },
7
+ { "kind": "skill-contains", "value": "view: \"repairs\"" },
8
+ { "kind": "skill-contains", "value": "propose-repair" },
9
+ { "kind": "skill-contains", "value": "propose-extract-inline-event" },
10
+ { "kind": "skill-contains", "value": "eventNeverPersisted: true" },
11
+ { "kind": "skill-contains", "value": "No automatic generation-evolution repair ships" },
12
+ { "kind": "skill-contains", "value": "`PLAY0479`: migrate optionality spelling with `PreserveTrivia`" },
6
13
  {
7
14
  "kind": "skill-contains",
8
15
  "value": ".cratis/screenplay/"
@@ -26,6 +26,10 @@ source is the single flow model.
26
26
  | Package | Version | Purpose |
27
27
  | --- | --- | --- |
28
28
  | `Cratis.Screenplay` | `4.31.0` | PDL parser, validator, diagnostics, semantic binder |
29
+ | `Cratis.Screenplay` | main `fd18129` | Inline event extraction and context identity guidance |
30
+
31
+ The update follows `commands.md`, `events.md` and `mcp/authoring-tools.md` at
32
+ that main commit (after v4.52.0); no PDL example changes in this update.
29
33
 
30
34
  Checked against the Screenplay repository at tag `v4.31.0` (commit `355dffb`):
31
35
  `Documentation/screenplay/projections/` (including `semantic-model.md`, `keys.md`
@@ -95,6 +99,13 @@ the event source id. A `from` without a key does **not** inherit another
95
99
  update the same instance only if the event source id happens to equal
96
100
  `invoiceId`.
97
101
 
102
+ For same-source events, map the read-model identity from `$eventSourceId`
103
+ (or `$eventContext.eventSourceId`), not a duplicated payload field. An event
104
+ declared by `produces event` is still a named slice-owned contract: projections
105
+ subscribe to it exactly like a standalone event. Verified extraction preserves
106
+ canonical ESM and identities, so it changes no projection contract. Removing a
107
+ payload property is different and requires consumer/persistence review.
108
+
98
109
  A second key on one `from` is error `PLAY0060`. A template expression in a
99
110
  composite key is error `PLAY0073`; an empty composite key is `PLAY0074`.
100
111
 
@@ -3,6 +3,9 @@
3
3
  "input": "Build a read model from events with the Projection Declaration Language.",
4
4
  "fixtures": [],
5
5
  "assertions": [
6
+ { "kind": "skill-contains", "value": "main `fd18129`" },
7
+ { "kind": "skill-contains", "value": "it changes no projection contract" },
8
+ { "kind": "skill-contains", "value": "map the read-model identity from `$eventSourceId`" },
6
9
  { "kind": "skill-contains", "value": ".cratis/screenplay/" },
7
10
  { "kind": "skill-contains", "value": "`cratis ai install` manages `.cratis/ai/`, not `.cratis/screenplay/`" },
8
11
  { "kind": "skill-contains", "value": "AutoMap is on by default" },
@@ -24,12 +24,16 @@ source is the single flow model.
24
24
 
25
25
  | Package | Version | Purpose |
26
26
  | --- | --- | --- |
27
- | `Cratis.Screenplay` | `4.31.0` | Parser, validator, diagnostics, semantic binder |
27
+ | `Cratis.Screenplay` | `4.31.0` | Original parser, validator and binder evidence |
28
+ | `Cratis.Screenplay` | main `fd18129` | Canonical optionality; changed examples compiled |
29
+
30
+ The update follows `types.md`, `queries.md` and `vscode.md` at that main commit
31
+ (after v4.52.0). Compilation does not establish query execution.
28
32
 
29
33
  Checked against the Screenplay repository at tag `v4.31.0` (commit `355dffb`):
30
34
  `Documentation/screenplay/{queries,readmodels,screens,policies,specifications,interactions}.md`
31
- and decision 0010. Every example below compiles with that version's compiler.
32
- Reverify before claiming another version behaves the same.
35
+ and decision 0010 established the original baseline. Changed examples use the
36
+ newer main commit above; do not attribute their verification to the old tag.
33
37
 
34
38
  ## `readmodel` — shape only
35
39
 
@@ -40,7 +44,7 @@ readmodel AccountBalance
40
44
  description "What the account is worth right now"
41
45
  balance Decimal
42
46
  movements Int
43
- note String?
47
+ note String optional
44
48
  ```
45
49
 
46
50
  A read model declares what it **is** — nothing about what builds it. Whatever
@@ -50,9 +54,10 @@ error `PLAY0191`. See `cratis-screenplay-projections` for the builder side.
50
54
  Do not mark a read-model property `identifier`. The executable model infers the
51
55
  instance identifier from the `by` property of the keyed queries that return the
52
56
  read model in its own slice
53
- (`query InvoiceById => InvoiceSummary? by invoiceId InvoiceId`). Several queries
57
+ (`query InvoiceById => InvoiceSummary optional`, then `by invoiceId InvoiceId`
58
+ on its own body line). Several queries
54
59
  over the same `by` property are fine; each must still have the shape the
55
- executable model admits, `=> <ReadModel>?` with one caller-supplied `by`. A read
60
+ executable model admits, `=> <ReadModel> optional` with one caller-supplied `by`. A read
56
61
  model with no keyed query, or with keyed queries over different `by` properties,
57
62
  has no unambiguous identifier and does not bind (`PLAY0268`), and specifications
58
63
  cannot select an instance of it.
@@ -64,21 +69,28 @@ Excerpt: the concepts, the read model and the policy are declared elsewhere.
64
69
  ```screenplay
65
70
  query ListInvoices => InvoiceListReadModel[]
66
71
  description "Every invoice the caller may see, narrowed by status and customer"
67
- filter status InvoiceStatus?
68
- filter customerId CustomerId?
72
+ filter status InvoiceStatus optional
73
+ filter customerId CustomerId optional
69
74
  filter tenantId TenantId from $context.tenant
70
75
  authorize IsAuthenticated
71
76
  ```
72
77
 
73
- Return-type forms after `=>`: `ReadModel`, `ReadModel?`, `ReadModel[]`, each
74
- optionally prefixed `observable`.
78
+ Return-type forms after `=>`: `ReadModel`, `ReadModel optional`, `ReadModel[]`,
79
+ each optionally prefixed `observable`. `ReadModel[] optional` permits an absent
80
+ collection, not absent items. Legacy `Type?` reports information `PLAY0479`,
81
+ which does not fail `--warnaserror`; use a verified repair or editor quick fix.
82
+
83
+ Keep `query Q => observable?` only for a one-shot query returning an optional
84
+ scalar type named `observable`. It is the canonical exception and has no
85
+ `PLAY0479`: `observable optional` instead means a live result of a type named
86
+ `optional`. Do not migrate that exception.
75
87
 
76
88
  ### `by` vs `filter` — and why it is a security decision
77
89
 
78
90
  | Clause | Meaning |
79
91
  | --- | --- |
80
92
  | `by` | the **identifying** parameter — the query returns the instance it identifies |
81
- | `filter` | an optional parameter narrowing the result set; usually typed `?` |
93
+ | `filter` | an optional parameter narrowing the result set; usually typed `optional` |
82
94
  | `from <source>` | fills the parameter **from the context** instead of from the caller |
83
95
 
84
96
  ⚠️ **Anything the caller must not be able to choose — the tenant, the caller's own
@@ -115,7 +127,7 @@ Treat every `scoped to global` in a review as a question to answer, not a detail
115
127
  `=> observable OverdueInvoicesReadModel[]` declares a live read that keeps
116
128
  pushing; without the marker a query is one-shot, which is the default and what
117
129
  most reads are. The marker qualifies only *how* the result arrives, so it composes
118
- with `[]`, `?`, `by`, `filter`, `authorize` and a `performer`, and a screen binds
130
+ with `[]`, `optional`, `by`, `filter`, `authorize` and a `performer`, and a screen binds
119
131
  to a live query exactly as it binds to a one-shot one. The delivery itself is the
120
132
  target runtime's: the executable model does not bind observable queries.
121
133
 
@@ -135,13 +147,13 @@ A read model a performer composes needs no projection, and no event builds it.
135
147
  Specify it from state with `given readmodel`, then `when query <Query>` with the
136
148
  arguments and `then result` (v4.48.0) - see `cratis-screenplay-specifications`.
137
149
 
138
- A query's key goes on its own `by` line in the body. `query X => RM? by id Type`
150
+ A query's key goes on its own `by` line in the body. `query X => RM optional by id Type`
139
151
  on the header line is a declaration error, not a shorthand.
140
152
 
141
153
  ### What runs
142
154
 
143
155
  In the executable model today, only the keyed snapshot shape binds:
144
- `=> <ReadModel>?` with one caller-supplied `by` argument and no `observable`,
156
+ `=> <ReadModel> optional` with one caller-supplied `by` argument and no `observable`,
145
157
  `filter`, `scoped to` or `performer`. Anything else, including `=> <ReadModel>`
146
158
  and `=> <ReadModel>[]`, reports `PLAY0268`. Its `authorize` gate runs before
147
159
  the lookup, ANDed with module and feature gates; a denied caller gets
@@ -3,6 +3,10 @@
3
3
  "input": "Declare a Screenplay query and the screen that binds to it.",
4
4
  "fixtures": [],
5
5
  "assertions": [
6
+ { "kind": "skill-contains", "value": "main `fd18129`" },
7
+ { "kind": "skill-contains", "value": "filter status InvoiceStatus optional" },
8
+ { "kind": "skill-contains", "value": "query Q => observable?" },
9
+ { "kind": "skill-contains", "value": "information `PLAY0479`" },
6
10
  { "kind": "skill-contains", "value": ".cratis/screenplay/" },
7
11
  { "kind": "skill-contains", "value": "`cratis ai install` manages `.cratis/ai/`, not `.cratis/screenplay/`" },
8
12
  { "kind": "skill-contains", "value": "The tenant is the default and stays unstated" },
@@ -25,13 +25,18 @@ source is the single flow model.
25
25
 
26
26
  | Package | Version | Purpose |
27
27
  | --- | --- | --- |
28
- | `Cratis.Screenplay` | `4.31.0` | Parser, semantic binder, reference execution |
28
+ | `Cratis.Screenplay` | `4.31.0` | Original parser, binder and reference execution evidence |
29
+ | `Cratis.Screenplay` | main `fd18129` | Inline facts, `optional` and clock spelling; changed examples compiled |
30
+
31
+ The update follows `commands.md`, `events.md`, `types.md` and
32
+ `specifications.md` at that main commit (after v4.52.0). This pass compiles the
33
+ changed examples; it does not rerun the reference runner.
29
34
 
30
35
  Checked against the Screenplay repository at tag `v4.31.0` (commit `355dffb`):
31
36
  `Documentation/screenplay/{specifications,policies,constraints,readmodels,diagnostics}.md`.
32
- The worked example below compiles with zero diagnostics, binds to ESM v2, and
33
- all six specifications pass the reference runner at that tag. Reverify before
34
- claiming another version behaves the same.
37
+ The original worked example had reference-runner evidence at that tag. The
38
+ example below now uses inline events and canonical optionality; keep its current
39
+ compile check distinct from that historical execution evidence.
35
40
 
36
41
  The specification actions beyond commands (`given clock`, `when clock`,
37
42
  `when trigger`, `given capture`, `when capture`, `when query`, `then result`,
@@ -127,11 +132,8 @@ module Invoicing
127
132
  authorize IsAccountant
128
133
  validate
129
134
  invoiceNumber not empty message "Invoice number is required"
130
- produces InvoiceRegistered
131
- for invoiceId
132
- invoiceNumber = invoiceNumber
133
- event InvoiceRegistered
134
- invoiceNumber InvoiceNumber
135
+ produces event InvoiceRegistered
136
+ invoiceNumber InvoiceNumber = invoiceNumber
135
137
  constraint UniqueInvoiceNumber
136
138
  unique invoiceNumber on InvoiceRegistered
137
139
  specification RegisteringAnInvoice
@@ -186,7 +188,7 @@ module Invoicing
186
188
  readmodel InvoiceSummary
187
189
  invoiceId InvoiceId
188
190
  invoiceNumber InvoiceNumber
189
- query InvoiceById => InvoiceSummary?
191
+ query InvoiceById => InvoiceSummary optional
190
192
  by invoiceId InvoiceId
191
193
  projection InvoiceSummaries => InvoiceSummary
192
194
  from InvoiceRegistered
@@ -202,6 +204,9 @@ module Invoicing
202
204
  invoiceNumber = "INV-000001"
203
205
  ```
204
206
 
207
+ - Inline events are ordinary named facts in `given` and `then`. Assert their
208
+ destination with `for`, not a payload identifier; inline declaration does not
209
+ change fixture or assertion syntax.
205
210
  - `RejectingANumberAnotherInvoiceHolds` needs `for`: without it the `given`
206
211
  event lands on the command's own event source, and re-claiming your own value
207
212
  is not a violation.
@@ -223,8 +228,9 @@ A slice is not always set off by a command. Name what does:
223
228
  | An automation driven by an application trigger | `when trigger <Trigger>` with the values it carries |
224
229
  | A translation driven by a capture | `given capture <Capture>` (the record as it was), `when capture <Capture>` (as it is now) |
225
230
 
226
- `given clock` also fixes the occurrence time of every action in the scenario, so
227
- a value a `produces` maps from `$context.occurred` can be asserted.
231
+ Use `given clock`, never `given time`, to state the scenario occurrence time and
232
+ assert a value mapped from `$context.occurred`. The clock fixture is documented
233
+ on main, but its executable admission is still deferred as described below.
228
234
 
229
235
  **`when query` executes today. The clock, trigger and capture actions do not.**
230
236
  They parse, print and are checked against the application, but binding reports
@@ -3,6 +3,10 @@
3
3
  "input": "Write given/when/then specifications for a Screenplay slice.",
4
4
  "fixtures": [],
5
5
  "assertions": [
6
+ { "kind": "skill-contains", "value": "main `fd18129`" },
7
+ { "kind": "skill-contains", "value": "Inline events are ordinary named facts" },
8
+ { "kind": "skill-contains", "value": "Use `given clock`, never `given time`" },
9
+ { "kind": "skill-contains", "value": "query InvoiceById => InvoiceSummary optional" },
6
10
  {
7
11
  "kind": "skill-contains",
8
12
  "value": ".cratis/screenplay/"