@cratis/pi 8.15.0 → 8.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/package/corpus/skills/cratis-arc-authorize-request/references/authproxy.md +3 -0
  2. package/package/corpus/skills/cratis-arc-authorize-request/references/csharp.md +21 -0
  3. package/package/corpus/skills/cratis-arc-diagnose-live-query/references/csharp.md +19 -6
  4. package/package/corpus/skills/cratis-arc-expose-query/references/csharp.md +12 -2
  5. package/package/corpus/skills/cratis-arc-generate-proxies/SKILL.md +1 -1
  6. package/package/corpus/skills/cratis-arc-host-application/SKILL.md +1 -1
  7. package/package/corpus/skills/cratis-arc-host-application/references/csharp.md +27 -0
  8. package/package/corpus/skills/cratis-arc-localize-application/SKILL.md +3 -2
  9. package/package/corpus/skills/cratis-arc-localize-application/references/csharp.md +1 -1
  10. package/package/corpus/skills/cratis-arc-localize-application/references/typescript-tooling.md +3 -0
  11. package/package/corpus/skills/cratis-arc-localize-application/references/typescript.md +32 -0
  12. package/package/corpus/skills/cratis-arc-react-bind-slice/references/typescript-localization.md +26 -2
  13. package/package/corpus/skills/cratis-arc-react-separate-view-model/SKILL.md +1 -1
  14. package/package/corpus/skills/cratis-arc-react-separate-view-model/references/typescript.md +31 -1
  15. package/package/corpus/skills/cratis-arc-storage-typescript/SKILL.md +1 -1
  16. package/package/corpus/skills/cratis-arc-storage-typescript/references/typescript-drizzle.md +2 -0
  17. package/package/corpus/skills/cratis-authproxy-configure/SKILL.md +3 -2
  18. package/package/corpus/skills/cratis-authproxy-configure/references/admission.md +6 -4
  19. package/package/corpus/skills/cratis-authproxy-configure/references/services-and-routing.md +12 -1
  20. package/package/corpus/skills/cratis-authproxy-configure/references/sessions-and-logout.md +47 -7
  21. package/package/corpus/skills/cratis-chronicle-cli-operations/SKILL.md +1 -1
  22. package/package/corpus/skills/cratis-chronicle-connect-application/references/csharp-patterns.md +3 -1
  23. package/package/corpus/skills/cratis-chronicle-connect-application/references/elixir-patterns.md +2 -1
  24. package/package/corpus/skills/cratis-chronicle-connect-application/references/go-patterns.md +3 -1
  25. package/package/corpus/skills/cratis-chronicle-connect-application/references/go.md +3 -3
  26. package/package/corpus/skills/cratis-chronicle-connect-application/references/java.md +40 -2
  27. package/package/corpus/skills/cratis-chronicle-connect-application/references/kotlin-patterns.md +3 -2
  28. package/package/corpus/skills/cratis-chronicle-connect-application/references/kotlin.md +2 -2
  29. package/package/corpus/skills/cratis-chronicle-connect-application/references/typescript-patterns.md +2 -1
  30. package/package/corpus/skills/cratis-chronicle-deploy-kernel/references/upgrade-and-recovery.md +14 -0
  31. package/package/corpus/skills/cratis-chronicle-project-view/SKILL.md +11 -10
  32. package/package/corpus/skills/cratis-chronicle-project-view/references/join-precedence.md +38 -0
  33. package/package/corpus/skills/cratis-chronicle-project-view/references/typescript.md +1 -1
  34. package/package/corpus/skills/cratis-chronicle-protect-decision/references/csharp.md +11 -2
  35. package/package/corpus/skills/cratis-chronicle-react-to-fact/SKILL.md +17 -1
  36. package/package/corpus/skills/cratis-chronicle-record-event/references/go.md +11 -0
  37. package/package/corpus/skills/cratis-chronicle-select-client/references/python.md +8 -1
  38. package/package/corpus/skills/cratis-code-review/SKILL.md +5 -0
  39. package/package/corpus/skills/cratis-components-submit-form/SKILL.md +1 -1
  40. package/package/corpus/skills/cratis-components-submit-form/references/typescript-commanddialog.md +1 -0
  41. package/package/corpus/skills/cratis-platform-deliver-slice/SKILL.md +3 -0
  42. package/package/corpus/skills/cratis-platform-deliver-slice/references/csharp.md +9 -3
  43. package/package/corpus/skills/cratis-platform-start-application/SKILL.md +1 -1
  44. package/package/corpus/skills/cratis-platform-start-application/references/csharp.md +5 -0
  45. package/package/corpus/skills/cratis-platform-upgrade-application/SKILL.md +2 -2
  46. package/package/corpus/skills/cratis-platform-upgrade-application/references/csharp.md +1 -0
  47. package/package/corpus/skills/cratis-platform-upgrade-application/references/typescript.md +1 -1
  48. package/package/corpus/skills/cratis-screenplay-declare-slice/SKILL.md +2 -2
  49. package/package/corpus/skills/cratis-screenplay-declare-slice/references/commands.md +9 -0
  50. package/package/corpus/skills/cratis-screenplay-declare-slice/references/read-identity.md +1 -1
  51. package/package/corpus/skills/cratis-screenplay-declare-slice/references/structure-and-imports.md +1 -1
  52. package/package/corpus/skills/cratis-screenplay-model-automation/SKILL.md +8 -10
  53. package/package/corpus/skills/cratis-screenplay-model-interaction/SKILL.md +9 -8
  54. package/package/corpus/skills/cratis-screenplay-model-interaction/references/csharp-host-api.md +12 -1
  55. package/package/corpus/skills/cratis-screenplay-model-interaction/references/csharp.md +1 -0
  56. package/package/corpus/skills/cratis-screenplay-model-interaction/references/localized-strings.md +2 -0
  57. package/package/corpus/skills/cratis-screenplay-model-interaction/references/shell-and-data.md +21 -0
  58. package/package/corpus/skills/cratis-specifications-exercise-backend/SKILL.md +1 -1
  59. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-command-results.md +9 -2
  60. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-events.md +9 -1
  61. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-query-scenario.md +2 -2
  62. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-reactors.md +1 -0
  63. package/package/corpus/skills/cratis-specifications-exercise-backend/references/csharp-read-models.md +13 -1
  64. package/package/profile-catalog.json +2 -0
  65. package/package.json +1 -1
@@ -240,6 +240,11 @@ run `yarn dev` in the `MyApp` project folder. Vite forwards to `http://localhost
240
240
  listens elsewhere, align the Vite targets with its listening address. Run the Demo registration and
241
241
  list smoke check as for `cratis`.
242
242
 
243
+ - Choose the database in the scaffold command (`--database`). It decides the app host's containers
244
+ and the backend's read-model packages and `AddCratis` configuration together, so to change it later,
245
+ scaffold again with the other choice and move the slices over; do not rewire the app host by hand.
246
+ - Features stay in `MyApp`. Edit `MyApp.Composition` only to change which services start together or
247
+ how their connections reach the backend; a new slice never needs a change there.
243
248
  - Start the backend only through the app host: its `appsettings.json` has no Chronicle connection
244
249
  string, because the app host supplies it.
245
250
  - Telemetry is exported only when `OTEL_EXPORTER_OTLP_ENDPOINT` is set, which Aspire does for every
@@ -33,7 +33,7 @@ Read `references/<language>.md` for the application's backend (`.csproj` → csh
33
33
  Work on a branch. Names and paths are illustrative.
34
34
 
35
35
  1. **Baseline.** Make build, specs and the application's smoke check pass on the current versions, and record the versions in use: Cratis packages, kernel image, AuthProxy image, CLI.
36
- 2. **Plan every boundary.** For each product, list the majors between the current and the target version and read that product's upgrade notes for each one, in order. Read the release notes too when only a minor changes: a default can change inside a major. Classify each step with the table below before changing anything. When `cratis ai profiles list --all` offers a `cratis/migrate/<product>-<from>-to-<to>` profile for a boundary, install it next to the current profiles for the upgrade and remove it when the upgrade is merged.
36
+ 2. **Plan every boundary.** For each product, list the majors between the current and the target version and read that product's upgrade notes for each one, in order. Read the release notes too when only a minor changes: a default can change inside a major. Classify each step with the table below before changing anything. Migration guidance for a major is not installed by default: run `cratis ai migrations list` in the repository root, and for each boundary it offers a `cratis/migrate/<product>-<from>-to-<to>` profile for, install it before the first step with `cratis ai migrations add <id>`. It joins the current profiles; remove it with `cratis ai migrations remove <id>` when the upgrade is merged. Where no profile matches a boundary, the product's upgrade notes are the source.
37
37
  3. **Decide the kernel order.** If the change raises the .NET Chronicle client, no environment may run a kernel older than that client: within a major, upgrade the kernel first; across a major, move kernel and clients together unless the upgrade notes state that the boundary keeps the wire contract. For any other client, test the new client release against the kernel version each environment runs. The kernel upgrade itself is `cratis-chronicle-deploy-kernel`, `references/upgrade-and-recovery.md`.
38
38
  4. **Do the steps that come before the bump.** Some product-specific steps (next section) run on the current release. Entered from the major directly before it, a Components major starts with an import migration that is applied and verified while the old package is still installed. On a direct jump across more than one major the migrator does not run on the old package: make the preparatory import edits by hand, and run the migrator only after the target is installed. Do these, repeat the baseline checks and keep the result as a checkpoint: source, manifest and lockfile together.
39
39
  5. **Raise every Cratis package in one change.** Backend: all packages of each product to one release, with `Cratis` deciding the Arc and Chronicle pair on .NET. Frontend: every `@cratis/*` package, in releases whose declared peer ranges accept each other, then install and commit the lockfile. Details are in the language reference.
@@ -68,7 +68,7 @@ Compile-time and changed-default steps belong to the application. Stored-state,
68
68
  | Chronicle kernel: order, backup, rollout, majors | `cratis-chronicle-deploy-kernel`, `references/upgrade-and-recovery.md` |
69
69
  | Chronicle kernel that holds unique constraint claims | `cratis-chronicle-constrain-append`, `references/operations.md` |
70
70
  | Arc on .NET: defaults that changed | `references/csharp.md` in this skill |
71
- | Components across a major | The matching `cratis/migrate/components-<from>-to-<to>` profile |
71
+ | Arc or Components across a major | The matching `cratis/migrate/<product>-<from>-to-<to>` profile, installed as in step 2 |
72
72
  | Specifications across a major | `cratis-specifications-isolate-behavior`, `references/csharp-running.md` |
73
73
  | AuthProxy | Read both its upgrade notes and the release notes of every version you cross: a change to what an unchanged configuration does can be described in only one of them. Settings are in `cratis-authproxy-configure` |
74
74
 
@@ -98,6 +98,7 @@ Alternative: set `Off` explicitly to keep the previous behaviour when the upgrad
98
98
  Two things change with the default and are easy to miss:
99
99
 
100
100
  - **Key coverage is strict.** A command without generated read-model key metadata fails at startup instead of falling back to reflection, and a composite key part without an accessor throws. Enable the Arc source generator or register the accessors; the opt-outs are for runtimes that allow dynamic code.
101
+ - **Guarded reads cost more.** Under `On` each guarded read folds that key's events again instead of returning the stored state, so the cost grows with the key's history, on every read. Measure the protected read with a realistic history before turning `On` for a model that folds years of events on one key. Split the key (by period, per order, per booking) only when the business invariant is independent in each partition; otherwise keep every fact the decision needs in the same protected history, because the guarded read does not see the other partitions. For a pure uniqueness rule, use a uniqueness constraint.
101
102
  - **Command specs.** Replacing or mocking the read-model reader no longer gives a protected read its state; the model can arrive as `null`. Arrange the state through the command scenario's own `Given`.
102
103
 
103
104
  How to select keys, mark advisory reads and read the measurement: `cratis-chronicle-protect-decision`, `references/csharp.md`. Scenario setup: `cratis-specifications-exercise-backend`, `references/csharp-command-results.md`. Runtime policy keys: `cratis-arc-host-application`, `references/csharp-configuration.md`.
@@ -56,7 +56,7 @@ A Components major is not a version bump: imports, provider setup, styling selec
56
56
  - The migrator refuses an installed version outside the majors it supports. On the direct path from an older major, no command runs on the old release: make the preparatory import changes by hand, and run every command, the import migration included, only after the new major is installed.
57
57
  - After the bump, update the provider setup and the stylesheet imports and make the source changes the guide lists before expecting the frontend to build. A failing build between the bump and those changes is expected, not a defect.
58
58
 
59
- Order, commands and what changes by hand: the matching `cratis/migrate/components-<from>-to-<to>` profile.
59
+ Order, commands and what changes by hand are in the matching `cratis/migrate/components-<from>-to-<to>` profile, which is not installed by default. Before the first step, run `cratis ai migrations list` in the repository root and add the profile it offers with `cratis ai migrations add <id>`. Never improvise the order or the commands from memory: if no profile matches the boundary, follow Components' migration guide for it.
60
60
 
61
61
  ## Node backend and Chronicle client
62
62
 
@@ -118,7 +118,7 @@ Read [structure and imports](references/structure-and-imports.md) when composing
118
118
  - `import <Qualified.Name> [from "<origin>"]`: names another application's contract (loads no file).
119
119
  - `module <Name>` / `feature <Name>` (features nest): address segments; take `description`, `documentation`, `purpose`, `provide`, `available`, `authorize`, `depends on`.
120
120
  - `slice <StateChange|StateView|Automation|Translate> <Name>`: one behavior unit.
121
- - `depends on <Module[.Feature]>`: dependency metadata. `shows event|readmodel <Path>`: draws another slice's declaration here.
121
+ - `depends on <Module[.Feature]>`: dependency metadata. `shows event|readmodel <Path>`: draws another slice's declaration here; never redeclare it.
122
122
  - `seed ["<name>"]` with `for "<event source id>"` groups: starting facts outside the executable model. `example <Name> : <Command|Event>` with mappings: a named value for specifications and screens.
123
123
  - Root only: `concept`, `type`, `policy`, `audience`, `availability`, `purpose`, `persona`, `sink`, `eventsource`, `system`, `secret`, `trigger`, `statemachine`, `workflow`, `seed`.
124
124
  - Text: `description "<text>"` or a fenced block (meaning), `documentation` with a `markdown` fence (tradeoff reasoning); text enforces nothing.
@@ -146,7 +146,7 @@ Read [commands](references/commands.md) when writing properties, reads, validati
146
146
 
147
147
  - `command <Name>`: one decision; share a slice only for the same decision from different callers.
148
148
  - `<name> <Type> [generated] [identifier]`: input; `identifier` names the event source.
149
- - `reads <ReadModel> [as <alias>] [by <property>]`: state the decision consults as `<alias>.<property>`; needs `command reads protected`. A `by` block of key parts is authoring-only.
149
+ - `reads <ReadModel> [as <alias>] [by <property>]`: state the decision consults as `<alias>.<property>`; needs `command reads protected` and a view keyed by `$eventSourceId`, never by payload (`PLAY0781`). A `by` block of key parts is authoring-only.
150
150
  - `validate` block: property rules (`<property> <operator>`; on a concept without the property) and `require <condition>` whole-command conditions, each optionally with `message "<text>"` and `severity error|warning|information`.
151
151
  - Rule operators: `not empty`, `min`, `max`, comparisons (`==`, `!=`, `>`, `>=`, `<`, `<=`), `length ==`, `decimals <=`, `all >`/`all >=`, text tests (`[not] contains`, `starts with`, `ends with`), `matches email|"<regex>"`; `rule <Name>` with a body for what only code can state (a bare one is authoring-only), or a `file` or fenced block under a command's `validate`. Types, clock operands and operator precedence: see commands.
152
152
  - `authorize <policy expression>`: who may call; enclosing module and feature gates also apply.
@@ -67,6 +67,15 @@ Refer to the state as `<alias>.<property>` or, for an unaliased read, `<ReadMode
67
67
 
68
68
  Declare the application-root `command reads protected` preamble whenever a command decides from a read. With it, the decision is guarded against the view changing between the read and the append, a missing instance rejects with `<ReadModel> does not exist.`, and read paths may feed event mappings. Without it, a read-fed decision is authoring intent only and executable binding refuses it.
69
69
 
70
+ A view a command reads has exactly one admitted shape, because the guard watches the one history the view is keyed by:
71
+
72
+ - Every instance is routed by event-source identity: the view has one `key` property filled from `$eventSourceId`, and no `from` or `remove with` carries a payload `key`.
73
+ - The command looks it up by one required, non-generated scalar command property of type `String`, `Uuid` or a non-enum concept backed by either. Its type must match the view's key. An unsupported or incompatible key is refused with `PLAY0781`.
74
+ - It handles a finite, non-empty set of events, each named in an explicit `from <Event>`.
75
+ - It declares removal: `remove with <Event>`.
76
+
77
+ Never key such a view by a payload property (`from <Event> key <property>`), not even when the payload value happens to equal the identity the command addresses. A payload key, a join, a reducer, `children`, `every`/`all`, a composite, generated, optional or collection key, a named source or stream, a singleton view or a missing `remove with` is refused (`PLAY0781`, error, with the reason). There is no advisory or unguarded fallback. When the rule needs facts from another history, do not bend the view. Move the decision to the history that owns the state, give each scarce thing its own identity and claim it with a uniqueness constraint, or accept and compensate with the business's agreement. The `cratis-screenplay-streams-and-consistency` skill owns the refusal reasons and these alternatives.
78
+
70
79
  For state that exists only so that commands can decide, declare the read model `passive` on its own line inside the declaration.
71
80
 
72
81
  ## Validation
@@ -2,7 +2,7 @@
2
2
 
3
3
  Start with two rows that would collide under the suspected key. For a monthly total, use two resources in the same month **and** the same resource in a different month. The answer should identify exactly one pair. Do not fix a collision by concatenating strings in the query.
4
4
 
5
- 1. Mark the identifying top-level read-model properties `key`. Explicit keys take precedence over inferred identity. Without them, an unambiguous single-instance query can supply the key; an eligible collection query can fall back to one conventional property ending in `Id`. A collection filter is not a reliable declaration of row identity. Use `$eventSourceId` if the row identifies that history; use a payload ID only if that is the row identity by design. Do not duplicate the source ID just to display it. Make the intent explicit if adding a query might change inference.
5
+ 1. Mark the identifying top-level read-model properties `key`. Explicit keys take precedence over inferred identity. Without them, an unambiguous single-instance query can supply the key; an eligible collection query can fall back to one conventional property ending in `Id`. A collection filter is not a reliable declaration of row identity. Use `$eventSourceId` if the row identifies that history; use a payload ID only if that is the row identity by design and no command reads the view. A view a command reads must be keyed by `$eventSourceId`; a payload key is refused there (`PLAY0781`). Do not duplicate the source ID just to display it. Make the intent explicit if adding a query might change inference.
6
6
  2. Several scalar keys form **one** identity with named parts. For `ResourceMonth`, compare both `resourceId` and `period`, not argument order. For an optional single result, declare every part in the query's `by` block as `name Type`; for a command read, map each as `name = source`. A list may filter on fewer parts because it need not identify one row.
7
7
  3. Supply every key part in `given readmodel` and `then readmodel`. Require all parts on expected collection rows. Otherwise a passing comparison may answer a different question from the one the owner asked.
8
8
  4. Match each event to the same instance in the projection. The `key` on the model describes the lookup; it does not route incoming facts. For several separate key properties, use an untyped key block with every named part on each root `from` and `remove with`. A typed composite property is a different shape.
@@ -39,7 +39,7 @@ time zone "Europe/Oslo"
39
39
  | `feature <Name>` | Slices, nested features, free screens, examples | Features nest to any depth; each level adds an address segment. Same members as a module. |
40
40
  | `slice <Type> <Name>` | The declarations of one unit of behavior | `<Type>` is `StateChange`, `StateView`, `Automation` or `Translate`. |
41
41
  | `depends on <Module[.Feature]>` | — | Authoring metadata, one target per line. Naming itself, an ancestor, a descendant or a target that does not resolve warns (`PLAY0554`); a target that matches more than one container warns `PLAY0198`. See Declared dependencies below. |
42
- | `shows event <Path>` / `shows readmodel <Path>` | — | Slice member. Draws a linked copy of another slice's event or read model on this slice of the board. Presentation only. |
42
+ | `shows event <Path>` / `shows readmodel <Path>` | — | Slice member. Draws a linked copy of another slice's event or read model on this slice of the board. Declare the element once and show it elsewhere; never declare it a second time. The copy refers to the declaration, so renaming the declaration renames every placement. Presentation only: it adds nothing to the executable model. A malformed line is an error (`PLAY0953`); a name no event or read model has warns (`PLAY0954`); showing what the slice itself declares, or showing it twice, warns (`PLAY0955`). |
43
43
 
44
44
  Write slices in story order, one whole slice after another, never grouped by kind: the slice that records a fact comes before the slices that project it, react to it or read a view built from it. The compiler reads the model as a timeline (modules in order, a feature's own slices before its sub-features) and reports a consumer placed before its producer as `PLAY0516` (information). Move the slice, or keep the order when the story really runs that way and say why. `PLAY0517` marks a group whose members depend on each other, which no reordering fixes; check whether the group is one slice split in two.
45
45
 
@@ -39,9 +39,7 @@ Prefer a reaction that **invokes a command** over one that produces events direc
39
39
  2. Select only the event values it needs, on the lines under the trigger. Address the triggering event's source with `$eventSourceId`.
40
40
  3. `invokes <Command>` with every required input mapped. When the command is gated by `authorize`, declare `runs as system role "<Role>"` with exactly the roles its policy requires. The Arc reactor that realizes it carries the same roles in `[ExecuteCommandsAsSystem("<Role>")]` (Stage renders it; add it to a hand-written reactor); without it, a role gate denies the command.
41
41
  4. Make repetition safe: give the command a constraint that refuses a duplicate, and handle only that refusal with `on refused by constraint <Name>` + `acknowledge`.
42
- 5. Test the normal handoff, duplicate refusal and acknowledgement separately. Check the target before relying on its commit or retry behavior.
43
-
44
- Use [the handoff and refusal example](references/reaction-example.md) to test each at the right boundary.
42
+ 5. Test the normal handoff, duplicate refusal and acknowledgement separately, each at the right boundary: [handoff and refusal example](references/reaction-example.md). Check the target before relying on its commit or retry behavior.
45
43
 
46
44
  ## Capability catalog
47
45
 
@@ -70,7 +68,7 @@ A reaction may have several triggers; each is handled separately, in authored or
70
68
  - `when <System>.<Trigger>`: a trigger contributed by the extension the system names.
71
69
  - `every <n> second|seconds|minute|minutes|hour|hours|day|days`: an interval counted from the Unix epoch.
72
70
  - `at <HH:mm>`: daily at a UTC time; add `on <Weekday>` for weekly or `on day <n>` for monthly (not both).
73
- - A trigger with nothing under it records intent only; it has no effect until effects or an implementation are attached.
71
+ - A trigger with nothing under it records intent only until effects or an implementation are attached.
74
72
 
75
73
  ### Under a trigger
76
74
 
@@ -79,7 +77,7 @@ A reaction may have several triggers; each is handled separately, in authored or
79
77
  - `invokes <System>.<Ability>` + inputs + answer branches: model an external call with scripted reference answers; Stage refuses reaction ability calls (see Systems and abilities).
80
78
  - `produces <Event>` + mappings: append a declared event. `for` takes a required scalar trigger value or nonblank text; omit only for an event trigger to reuse its source. `produces ... when` is the command form; a reaction narrows with `where`.
81
79
  - Production `tag <tag>` lines: literal append metadata, before the payload mappings.
82
- - `reads <View> [as <alias>] [by <value>]`: documents the state the follow-up depends on. For executable invocation-only intent, leave protected reads and their decision to the command; aliases are not portable mapping values. Direct production or a body with `reads` does not bind. A composite key uses a child `by` block of `<part> = <value>` lines (authoring-only).
80
+ - `reads <View> [as <alias>] [by <value>]`: the state the follow-up depends on. `by` must name a value this trigger selects on its own line: unlike a `where` operand, an unselected one warns (`PLAY0442`), and a clock trigger takes no `by` (`PLAY0443`, error). Repeated reads of a view need distinct aliases that match no trigger value. Leave protected reads and their decision to the invoked command; aliases are not mapping values. Direct production or a body with `reads` does not bind. Composite key: a child `by` block of `<part> = <value>` lines (authoring-only).
83
81
  - `file <path>` or a fenced C# block: an attached implementation, not an executable effect by itself. Use only on a standalone single event trigger, without declarative effects, decision reads or output route overrides. Stage rendering of bodies is C#-only.
84
82
 
85
83
  ### Values in reaction mappings
@@ -105,7 +103,7 @@ Written under an `invokes <Command>`; the first matching branch wins. Classifica
105
103
  - Trigger `description` and `file <path>`: document the signal and navigate to its producer; neither arranges delivery.
106
104
  - Authoring resolves events before declared triggers, then registry names. Binding resolves events, declared triggers and the supported built-ins. Do not name a trigger like a screen interaction kind.
107
105
  - The host raises the trigger at runtime; a screen interaction can fire it with `raise <Trigger>` or observe it with `on <Trigger>` (see `cratis-screenplay-model-interaction`); a specification supplies it with `when trigger <Name>`.
108
- - A tool that embeds the compiler can register a trigger name, with an optional value shape, instead of declaring it in the model. Registration is authoring-only: it names no runtime producer. Prefer a typed `trigger` declaration to bind executable custom signals. The registration API is SDK-specific: see the language reference of `cratis-screenplay-onboard-workspace`.
106
+ - A tool embedding the compiler can register a trigger name (optional value shape) instead of declaring it. Registration is authoring-only and names no runtime producer; prefer a typed `trigger` declaration for executable signals. The API is SDK-specific: see the language reference of `cratis-screenplay-onboard-workspace`.
109
107
 
110
108
  ### Systems and abilities
111
109
 
@@ -156,10 +154,10 @@ Written under an `invokes <Command>`; the first matching branch wins. Classifica
156
154
  - `given generated <Command>.<property> = <value>`: pin a generated value for a reaction-invoked command, one line per invocation.
157
155
  - `given <System>.<Ability> returns` + fields / `answers <Outcome>` / `fails "<reason>"`: script an ability's answer.
158
156
  - `then <Event>`: assert new facts; after `when append`, exclude the appended trigger itself.
159
- - `then no events`: successful action with no new facts, not a rejection assertion.
157
+ - `then no events`: success with no new facts, not a rejection assertion.
160
158
  - `then invokes <Command or System.Ability>` + optional input values: assert the handoff. Command expectations match all invocations once any are stated, including refusals, and compare only stated values.
161
159
  - `then events in any order`: compare exact counts without ordering, also for command invocation expectations.
162
- - `then error ["<message>"]`: assert an unhandled validation or constraint rejection, optionally checking the message; not a success assertion.
160
+ - `then error ["<message>"]`: assert an unhandled validation or constraint rejection, optionally checking the message.
163
161
  - `then denied`: assert authorization denial, not a validation or constraint error.
164
162
  - State-machine specs: `then is <State>` checks state; `then starts <Workflow>` and `then invokes <Command or System.Ability>` check entry effects.
165
163
  - Workflow specs: `when start <key>` starts a manual or scheduled run; `outcome <Node> <outlet>` chooses a simulated path.
@@ -175,13 +173,13 @@ Written under an `invokes <Command>`; the first matching branch wins. Classifica
175
173
 
176
174
  ## Work in Studio
177
175
 
178
- To add automation in Studio, use **Add → Add Slice → Automation** in the feature header. On the trigger control, **Event** selects a fact, **Timer** describes a schedule, and **Custom** describes intent for generation. Use **Change trigger type**, **Edit trigger** or **Remove trigger** to revise it. Use **Add refusal handling** on the command; acknowledge or add events. Move branches to put narrow matches first.
176
+ In Studio, use **Add → Add Slice → Automation** in the feature header. On the trigger control, **Event** selects a fact, **Timer** describes a schedule, and **Custom** describes intent for generation. Use **Change trigger type**, **Edit trigger** or **Remove trigger** to revise it. Use **Add refusal handling** on the command; acknowledge or add events. Move branches to put narrow matches first.
179
177
 
180
178
  In **State machines** or **Workflows**, use **Simulate** to choose events and guards or step through outlets. Board intent and simulation are not executable admission or live delivery.
181
179
 
182
180
  ## Check the model
183
181
 
184
- Compile, then run the specifications with the reference runner:
182
+ Compile, then run the specifications:
185
183
 
186
184
  ```bash
187
185
  screenplay <model-folder>
@@ -18,7 +18,7 @@ compatibility: Requires the Screenplay CLI.
18
18
 
19
19
  ## What the UI layer is
20
20
 
21
- A Screenplay model describes the UI declaratively, next to the slices it uses. A `screen` reads a read model through a query and offers commands as actions. A `form` shapes a command's input. `on <trigger>` interactions and named `behavior`s wire gestures and events to actions. Layouts, screen templates, dialog templates and outlets give screens a shared shell. A `ui profile` selects the shell, theme and component packages for a target.
21
+ A Screenplay model declares the UI next to the slices it uses. A `screen` reads a read model through a query and offers commands as actions. A `form` shapes a command's input. `on <trigger>` interactions and named `behavior`s wire gestures and events to actions. Layouts, templates and outlets give screens a shared shell. A `ui profile` selects the shell, theme and component packages for a target.
22
22
 
23
23
  The compiler checks references and shapes but never runs UI or evaluates a guard. A renderer (Stage, through Scene) realizes what it supports and reports the rest. Names in the examples are illustrative.
24
24
 
@@ -95,10 +95,10 @@ module Facilities
95
95
  - `data <ReadModel>` | `data <ReadModel>[]`, then `via query <Query> [by <param>]` — what the screen shows; `by` takes a scalar argument only (a composite key is refused, `PLAY0661`).
96
96
  - `available for|when|with …` on `data` or `action` — narrow who sees the element; never widens the command or query (`PLAY1172`).
97
97
  - `data <Shape>[] [as <alias>]` (no `via`) — a free screen's *need*; `shape <Name>` (top level) declares typed fields for it.
98
- - `uses screen <Screen>` in a slice, then `data <need|alias> via query <Query> [by <param>]` and `<field> from <path>` where the names differ — adopt a free screen. An unadopted screen is design-only (`PLAY1164`); an unprovided need warns (`PLAY1155`).
98
+ - `uses screen <Screen>` in a slice, then `data <need|alias> via query <Query> [by <param>]` and `<field> from <path>` where the names differ — adopt a free screen. Unadopted: design-only (`PLAY1164`, information). Unprovided need: warning (`PLAY1155`). Misfit provision: error. See [adoption checks](references/shell-and-data.md).
99
99
  - Name resolution runs inside-out (slice, feature, module, document). Qualify with a trailing scope (`Queue.All`) when ambiguous.
100
100
  - `sketch|mockup|image <path>` — authoring visuals beside the model, never executed.
101
- - `file <path>` — an external file realizes the whole screen; a fenced `react|typescript|html|csharp` block in a section or slot realizes that part inline.
101
+ - `file <path>` — an external file realizes the screen; a fenced `react|typescript|html|csharp` block in a section or slot realizes that part inline.
102
102
 
103
103
  ### Actions and subjects
104
104
 
@@ -125,7 +125,7 @@ module Facilities
125
125
  - `navigate to <Screen> [by <param>]` as a screen directive, an action child or a toolbar item — takes `route "<path>"`, `slot <name>` and `parameter <p> from data|query|component|literal <binding>`.
126
126
  - Inside an interaction, `navigate to <Screen>` takes only `with <name> from <binding>`; it has no outcome, so `on success` or `on failure` under it is an error.
127
127
  - `navigate back` (interaction) — return to the previous screen.
128
- - `--check navigation` (`PLAY0537`) reports screens no entry point reaches; see [Navigation reachability](references/navigation-reachability.md).
128
+ - `--check navigation` (`PLAY0537`) reports unreachable screens: [Navigation reachability](references/navigation-reachability.md).
129
129
  - `outlet <name> of navigation [in <slot>]` on a layout, with `logo image "<url>" title "…"` (layout only) and `default <id> title "…" [icon <i>] [target <Module>[.<Feature>] [screen <Screen>]] [slot <n>]`. Nest `item` lines for children. A module's items target only its own module. Stage does not honor the `screen` part; it is not in the UI contract either.
130
130
 
131
131
  ### Forms
@@ -170,13 +170,14 @@ See [Shell and design](references/shell-and-data.md) for the shell skeleton, `ar
170
170
 
171
171
  ### Profiles, design, sample data and strings
172
172
 
173
- Companion file rules: [Localized strings](references/localized-strings.md).
173
+ Rules: [Localized strings](references/localized-strings.md).
174
174
 
175
- - `ui profile <Name>` (top level; several allowed) — `target platform`, `target size compact|regular|expanded`, `theme`, `root template [blueprint <Bp>] <Name> [version "<range>"]` with `option <n> <v>`, `identity` (`name`, `logo initials|icon|image`, `show name`), `appearance` → `color scheme light|dark|system`, `new screens use template …`, `packages` (in priority order, `core` as fallback), `icons` and `sample data` (`active <Pack>`, `shape <S> maps to <ReadModel>`, `bind <ReadModel> to <Pack>`). A screen never names a profile.
176
- - `design system <Name>` (top level, once) — `modes`, `default theme` (required), `tokens` by category (color, space, size, radius, border, shadow, font, type, motion, opacity, z), `components` with `parts`, `variant` and `state`, `words` (`voice`, `naming`) and `rules contrast <part> on <part> at least <ratio>`.
175
+ - `ui profile <Name>` (top level; several allowed) — `target platform`, `target size compact|regular|expanded`, `theme`, `root template [blueprint <Bp>] <Name> [version "<range>"]` with `option <n> <v>`, `identity` (`name`, `logo initials|icon|image`, `show name`), `appearance` → `color scheme light|dark|system`, `new screens use template …`, `packages` (in priority order, `core` as fallback), `icons` and `sample data` (`active <Pack>`, `shape <S> maps to <ReadModel>`, `bind <ReadModel> to <Pack>`). A screen never names one.
176
+ - `design system <Name>` (top level, once) — `modes`, `default theme` (required), `tokens` by category (color, space, size, radius, border, shadow, font, type, motion, opacity, z), `components` with `parts`, `variant` and `state`, `words` and `rules contrast <part> on <part> at least <ratio>`.
177
177
  - `theme <Name>` (top level) — `implements <DesignSystem>`, `compatible with <Package>`, `palette`, `values`, and per-mode blocks. Every color token needs a value in every mode. A profile's theme must implement the design system.
178
178
  - `sample data <Name>` (top level) — `title`, `locale`, and `shape <ReadModel>` with `row` and `<field> = <literal>` (nested rows for collections). Activate it from a profile.
179
- - `<base>.<locale>.strings` companion files with `key = "value"` — use `$strings.<key>` for screen and section titles, labels (action, column, summary field, form field, contribution), toolbar button titles, notify, confirm and validation messages.
179
+ - `<base>.<locale>.strings` companion files with `key = "value"` — use `$strings.<key>` for titles, labels, toolbar button titles, notify, confirm and validation messages.
180
+ - Values use ICU 1 apostrophe quoting (`''`, `'{'`); a placeholder is one name or number, no plural or select.
180
181
 
181
182
  ### Tools and SDK surfaces
182
183
 
@@ -170,8 +170,19 @@ foreach (var file in files.FindIn("models/helpdesk"))
170
170
 
171
171
  var english = new StringsFile([new StringsEntry("tickets.fields.subject", "Subject")]);
172
172
  File.WriteAllText("models/helpdesk/tickets.en.strings", english.Write());
173
+
174
+ var entry = new StringsEntry("tickets.assigned", "Assigned to {assignee}, don''t reply");
175
+ foreach (var part in entry.Parts())
176
+ {
177
+ switch (part)
178
+ {
179
+ case StringsText text: Console.Write(text.Text); break;
180
+ case StringsPlaceholder placeholder: Console.Write($"<{placeholder.Name}>"); break;
181
+ }
182
+ }
173
183
  ```
174
184
 
175
185
  - `FindIn(root)` matches `StringsFiles.Pattern` (`**/*.strings`) and orders results by `RelativePath`; `Path` is absolute. `BaseName` and `Locale` come from `<base>.<locale>.strings`; `Locale` is `null` without a locale segment.
176
- - `Parse` skips blank lines and `//` comments and throws `InvalidStringsLine` (with the line number) for anything else. A key starts with a letter or underscore and continues in dotted word segments. A value is double-quoted, cannot contain `"` and has no escapes; `{placeholder}` tokens stay verbatim.
186
+ - `Parse` skips blank lines and `//` comments and throws `InvalidStringsLine` (with the line number) for anything else. A key starts with a letter or underscore and continues in dotted word segments. A value is double-quoted, cannot contain `"` and has no escapes. Values stay verbatim: `Parse` applies no placeholder or quoting rules.
187
+ - `StringsValue.Parse(value)` and `StringsEntry.Parts()` return the value as ordered `StringsText` (`Text`) and `StringsPlaceholder` (`Name`) parts with ICU MessageFormat 1 apostrophe quoting removed: `''` is an apostrophe, `'{'` and `'}'` are literal braces, an unclosed quote runs to the end. A placeholder is one name or a number 0–32767 without leading zeros. They throw `InvalidStringsValue` (with `Position`, the 0-based index of the offending character) for an unbalanced brace, braces around anything but one name or number, or an apostrophe directly before `<` or `>`.
177
188
  - `Write()` emits the canonical form: one entry per line, keys padded to the longest. It drops comments and blank lines, so don't round-trip a hand-commented file through it.
@@ -118,6 +118,7 @@ return 0;
118
118
  | `DesignSystemResolver.SelectTheme` / `.SelectMode` / `.Resolve` | Flatten a profile's theme and mode into tokens and component parts. |
119
119
  | `UiProfileShellBinder.Bind` | Check profile shells against the blueprints a host has installed. |
120
120
  | `StringsFile` / `StringsFiles` | Find, parse and write `.strings` files. |
121
+ | `StringsValue.Parse` / `StringsEntry.Parts` | Split a value into ordered `StringsText` and `StringsPlaceholder` parts; throws `InvalidStringsValue` with a `Position`. `StringsFile.Parse` keeps values verbatim. |
121
122
 
122
123
  ## Not supported in this SDK
123
124
 
@@ -8,6 +8,8 @@ invoices.fields.number = "Invoice number"
8
8
  notifications.invoiceRegistered = "Invoice {number} from Acme"
9
9
  ```
10
10
 
11
+ A value uses ICU MessageFormat 1 apostrophe quoting: `''` is an apostrophe, `'{'` and `'}'` are literal braces, so `'{number}'` is the text `{number}`, and an apostrophe directly before `<` or `>` is refused (write `''<`). A placeholder is a single name, or a number 0–32767 without leading zeros. Plural, select and typed forms such as `{count, number}` are not supported. Every locale of a key uses the same placeholder names.
12
+
11
13
  Use the same dotted keys and preserve `{number}` and any other placeholders in each locale's file, such as `invoicing.nb.strings`. At a screen label or title, use the unquoted reference; for example, a form field can use:
12
14
 
13
15
  ```play
@@ -7,6 +7,7 @@
7
7
  - Root template, shell options and appearance
8
8
  - Design system and themes
9
9
  - Check a screen in its real shell
10
+ - Free screen adoption checks
10
11
  - Stage behavior
11
12
  - Design in Studio
12
13
  - Design operations
@@ -163,6 +164,26 @@ theme Plain
163
164
 
164
165
  A collection filter narrows rows; it is not tenant isolation. Check cross-tenant denial on the backend, not through a hidden filter or a disabled control.
165
166
 
167
+ ## Free screen adoption checks
168
+
169
+ A free screen is declared outside any slice and states its needs (`data <Shape>[] [as <alias>]`, no `via query`). A slice adopts it with `uses screen <Screen>` and provides each need from one of its own queries. The compiler treats the three situations differently; report each at its real severity.
170
+
171
+ | Situation | Code | Severity and consequence |
172
+ | --- | --- | --- |
173
+ | No slice adopts the free screen | `PLAY1164` | Information. The screen is design-only: it never blocks the rest of the model, never enters the executable model and is not in the UI contract. |
174
+ | A screen a slice adopts or declares has a need no provision supplies | `PLAY1155` | Warning while the model is being built. It fails wherever warnings are errors (`--warnaserror`, a gate file's `warningsAsErrors`), and executable screen admission refuses the model, naming the screen and the shape. |
175
+ | The providing query returns a list where the need is single, or a single value where it is a list | `PLAY1159` | Error. |
176
+ | A field the screen reads, or its `shape` declares, is not a property of the query's read model, by name or through `<field> from <path>` | `PLAY1160` | Error. |
177
+ | The providing property has another type than the `shape` declares (a concept stands for its underlying primitive) | `PLAY1161` | Error. |
178
+ | `by` names a parameter the providing query does not declare | `PLAY1162` | Error. |
179
+ | A `<field> from <path>` mapping names a field the screen does not read and its `shape` does not declare | `PLAY1163` | Error. |
180
+ | A provision names a need the screen does not have, one the screen already sources with its own `data <ReadModel> via query`, or the same need twice | `PLAY1156`, `PLAY1157`, `PLAY1158` | Error. |
181
+ | A slice adopts the same screen twice; a screen needs the same shape twice without distinct `as <alias>` names | `PLAY1154`, `PLAY1153` | Error. |
182
+
183
+ - Leave a design-only screen unadopted until a slice really supplies its data. Do not add an empty `uses screen` to silence `PLAY1164`: that trades information for the `PLAY1155` warning.
184
+ - Provide every need before the release gate. A model that compiles with `PLAY1155` is not releasable under warnings-as-errors and its screens are not admitted.
185
+ - Fix a provision error at the provision: return the right cardinality, map the differing field with `<field> from <path>`, or correct the query. Never loosen the `shape` to make a wrong query fit.
186
+
166
187
  ## Stage behavior
167
188
 
168
189
  - A plain `for item` action is disabled without one selected row from the current screen's tables or boards. A row menu supplies its own row. Keep a summary-only detail screen read-only unless its action can run without row selection.
@@ -144,7 +144,7 @@ Where supported: check whether a caller is authorized, denied or unsupported for
144
144
  - **Perform**: return the query result, with arguments and, where supported, paging and sorting.
145
145
  - **Observe or collect**: for an observable query, the initial result and subsequent emissions, bounded by a count or timeout.
146
146
  - **Seed**: events projected into the read model on demand, or a pinned read-model instance.
147
- - **Caller, tenant, context, serialization round trip**: as for commands.
147
+ - **Caller, context, serialization round trip**: as for commands; tenant where supported.
148
148
  - **Result assertions**: successful, has data, paging, change set, ready, validation errors, authorized or not; for observables, emission count, termination or rejection.
149
149
 
150
150
  ### Event scenario
@@ -67,11 +67,18 @@ Use `Execute` to prove that submitting a command is refused and appends nothing.
67
67
 
68
68
  A concurrency conflict at commit surfaces as a validation result with reason `ConcurrencyViolation`: assert `ShouldHaveValidationErrorBecauseOf(ValidationResultReason.ConcurrencyViolation)`. Provoking one in a command scenario is framework verification, for an explicit need only (see Seeding before the act). For a command with a typed response, assert on the result's `Response` directly.
69
69
 
70
- A repository can strengthen every result assertion in one place: a class implementing `ICommandResultAssertionPolicy` with a public parameterless constructor is discovered automatically, and its `OnAssertionPassed(assertion, result)` runs after each built-in assertion passes; it may throw to fail it, never turn a failure into a pass. Use it for a house rule such as "a rejection must name its member".
70
+ A repository can strengthen every result assertion in one place: a class implementing `ICommandResultAssertionPolicy` with a public parameterless constructor is discovered automatically, and its `OnAssertionPassed(assertion, result)` runs after each built-in assertion passes; it may throw to fail it, never turn a failure into a pass. Use it for a house rule such as "a rejection must name its member". The policy runs only after the `CommandResult` assertions in the table above. The decision helpers on a value returned by a direct `Handle()` call (`ShouldBeAccepted`, `ShouldBeRejected`, `ShouldBeEvent` and the others in [csharp-slice.md](csharp-slice.md)) never apply it, so a direct-call spec does not enforce the house rule: assert through a command scenario where it must hold.
71
71
 
72
72
  Three false greens to rule out:
73
73
 
74
- - **The rule never ran.** A read model the validator or `Provide()` needs but the spec did not seed rejects the command before the validator is constructed, so `ShouldNotBeSuccessful()` passes without the rule. Seed the state and assert the rule's stable member, reason or reason detail, or assert `ShouldHaveValidationErrorBecauseOf(ValidationResultReason.DependencyUnavailable)` (from `Cratis.Arc.Validation`) when missing state is the intended outcome.
74
+ - **The rule never ran.** A read model the validator, `Provide()` or `Handle()` requires but the spec did not seed rejects the command before the rule runs, so `ShouldNotBeSuccessful()` passes without the rule. Seed the state and assert the rule's stable member, reason or reason detail. When missing state is the intended outcome, what the result carries depends on the command's effective read protection (`ValidationResultReason` is in `Cratis.Arc.Validation`):
75
+
76
+ | The missing read | Result | Assert |
77
+ | --- | --- | --- |
78
+ | Effective `On`, a required (non-nullable) protected read-model parameter | Reason `Rule`, message `<ReadModel> does not exist.`, where `<ReadModel>` is the model's simple type name; the key is never in the message | `ShouldHaveValidationErrorBecauseOf(ValidationResultReason.Rule)` and `ShouldBeRejected("TripCapacity does not exist.")` on the same result, then `await ShouldNotHaveAppendedEvents()` |
79
+ | `Off`, `Measure`, or an advisory (`[Unprotected]`) read | Reason `DependencyUnavailable` | `ShouldHaveValidationErrorBecauseOf(ValidationResultReason.DependencyUnavailable)` |
80
+
81
+ Moving a command to `On` therefore changes this outcome. A spec that asserted `DependencyUnavailable` must assert the `Rule` reason and the exact message instead; do not lower the mode to keep the old assertion green. A bare `ShouldHaveValidationErrors()` or `ShouldBeRejected()` failed on a missing model before the move and passes after it, because `Rule` is an ordinary validation reason: it no longer tells a missing model from the rule under test. An explicitly nullable protected parameter is not rejected for a valid key with no instance; it receives `null`.
75
82
  - **Authorization refused first.** Pair a refusal with `ShouldBeAuthorized()` when the caller should have been allowed.
76
83
  - **The framework refused, not the rule.** For a constraint or concurrency rejection, assert the reason or the constraint name and that nothing was appended. Message text is presentation and changes; the reason and name are the contract. Check `Execute` as well as `Validate`: `Validate` runs the pipeline filters but skips `Provide()` and `Handle()`, so it cannot show what the command commits.
77
84
 
@@ -36,7 +36,8 @@ result.ShouldHaveConstraintViolation("UniqueCarrierName");
36
36
  | --- | --- |
37
37
  | `new EventScenario()` | Event log of an isolated in-memory store with the application's discovered artifacts and constraints |
38
38
  | `new EventScenario(constraintProvider)` | Supply constraints explicitly through an `ICanProvideConstraints` |
39
- | `new EventScenario(defaults)` | Share explicit artifacts, services or a clock through a `Defaults` instance |
39
+ | `new EventScenario(defaults)` | Share explicit artifacts, services or a clock through a `Defaults` instance. Constraints are discovered from those defaults, not from the shared artifacts |
40
+ | `new EventScenario(defaults, constraintProvider)` | The same, with constraints from the given `ICanProvideConstraints`. See the note on `null` below the table |
40
41
  | `new EventScenario(eventSequenceId, eventStoreName, namespaceName)` | Target another event sequence, store name or namespace; overloads add `defaults` first or a constraint provider last |
41
42
  | `Given.ForEventSource(id).Events(...)` | Seed history; awaited. A seeded event the log refuses throws `GivenEventAppendFailed` naming the violations, so a spec never runs against history it did not receive |
42
43
  | `When.ForEventSource(id).Events(first, ...)` | The act; returns `AppendResult` |
@@ -45,6 +46,13 @@ result.ShouldHaveConstraintViolation("UniqueCarrierName");
45
46
  | `Time` | The scenario clock, a `ScenarioTime` |
46
47
  | `Dispose()` | Release the scenario; use `using` or `Destroy` |
47
48
 
49
+ For event types or constraints that exist only for one run, such as generated ones, the default is `new EventScenario(new Defaults(runArtifacts))`: that run's `IClientArtifactsProvider` then drives event-type discovery, serialization and constraint discovery. Do not add per-run artifacts to the shared provider behind `Defaults.Instance`. What `null` means for the constraint provider depends on the overload:
50
+
51
+ | Overload | `null` constraint provider |
52
+ | --- | --- |
53
+ | `(defaults, constraintProvider)` | Still discovers constraints from `defaults`. To run without constraints, pass a provider whose `Provide()` returns an empty list |
54
+ | `(constraintProvider)` and `(eventSequenceId, eventStoreName, namespaceName, constraintProvider)` | No constraints. These use the shared artifacts |
55
+
48
56
  `scenario.ReadModels` is the surface to hand to code that depends on `IReadModels` and enumerates or observes. It reads only what was seeded or appended through this scenario (`Given`, `When`, `EventLog`).
49
57
 
50
58
  - `await scenario.ReadModels.GetInstances<T>()` returns the collection folded from the log, and `GetInstanceById<T>(key)` one instance.
@@ -37,7 +37,7 @@ result.IsSuccess.ShouldBeTrue();
37
37
  ((Carrier)result.Data).Id.ShouldEqual(id);
38
38
  ```
39
39
 
40
- A successful result without the expected ID does not satisfy the query contract. A query restricted to an authentication scheme fails closed as unauthorized here, because selecting a scheme needs a live HTTP context: prove it in an HTTP-hosted spec.
40
+ A successful result without the expected ID does not satisfy the query contract. A query restricted to an authentication scheme fails closed as unauthorized here, because selecting a scheme needs a live HTTP context: prove it in an HTTP-hosted spec. The scenario also has no tenant selector, unlike `CommandScenario.Tenant(...)`: a query runs under default tenant resolution. Prove tenant isolation and request authentication in an HTTP-hosted spec, and keep `QueryScenario` for the variants that need neither a scheme nor a chosen tenant.
41
41
 
42
42
  Both `Perform` and `Observe` take optional `paging` (`Paging`) and `sorting` (`Sorting`) arguments after the query arguments and a `CancellationToken` last; `Observe` also takes a `timeout` for the first emission, and `Next(timeout)` one for the next. A scenario extender (`IQueryScenarioExtender`) can publish helpers through `scenario.Context`; the Chronicle package uses it for `Given`.
43
43
 
@@ -73,7 +73,7 @@ Always assert `IsSuccess` on the result of `Next()` before its data: a failed re
73
73
 
74
74
  State each prior event exactly once. After sharing, `queries.Given` and `commands.Given` write to the same seeds: in decision mode both enter the one shared log, and in legacy mode the observation folds those seeds plus every successful append to the command's log, including events placed there with `commands.EventScenario.Given`. An event stated through two of those is folded twice, so counts and sums double. `commands.EventScenario` throws in decision mode.
75
75
 
76
- An observed query merges a row pinned with `.ReadModel(instance)` by its identifier: `[Key]`, then `[Subject]`, then a property named `Id`. A pinned instance without a readable identifier, or with a null one, cannot be merged. `scenario.Observe` does not throw for it: the failure arrives as a failed query result carrying the `PinnedReadModelCannotBeObserved` message. Where it arrives depends on when the instance was pinned:
76
+ An observed query merges a row pinned with `.ReadModel(instance)` by its identifier: `[Key]`, then `[Subject]`, then a property named `Id`. The pin wins over the instance projected from seeded events for that key. This proves which row the query emits, not transport or a live subscription. A pinned instance without a readable identifier, or with a null one, cannot be merged. `scenario.Observe` does not throw for it: the failure arrives as a failed query result carrying the `PinnedReadModelCannotBeObserved` message. Only code that calls `Observe<T>()` on the `IReadModels` resolved from `scenario.Services` itself gets the exception thrown. Where it arrives depends on when the instance was pinned:
77
77
 
78
78
  | Pinned | Failed result |
79
79
  | --- | --- |
@@ -28,6 +28,7 @@ var scenario = new ReactorScenario<ParcelNotifier>(new Defaults(new InMemoryClie
28
28
  ```
29
29
 
30
30
  Without the reactor nomination the constructor throws `InvalidExplicitArtifact`; an unregistered event type throws `TypeIsNotAnEventType` on delivery. A public method shaped as a handler (a registered event type, optionally followed by `EventContext` or `ReactorDelivery`) throws `InvalidReactorHandlerReturnType` when its return type is synchronous and unsupported, for example an unregistered event type. `void`, any `Task` (including `Task<T>`), a registered event type, `EventForEventSourceId`, `EventsWithConcurrencyScopes`, sequences of registered events, `EventForEventSourceId` or `object`, and any type a side-effect handler claims all pass. Events returned inside `EventForEventSourceId` are recorded without registration. With the default recorder (no explicit `IReactorSideEffectHandlers` passed to the constructor), a returned bare event whose type is not registered appears in `Produced` but not in `ProducedEvents`, so the ordered and destination assertions do not see it. Create new options and defaults for each independent run and never change `Defaults.Instance`: each scenario store keeps the registrations it had when it was created.
31
+ - A reactor method that returns a custom type, neither an event nor one of the shapes above, needs an `IReactorSideEffectHandler` whose `CanHandleReturnType` claims that type. Register it in `scenario.Services`, or in the pre-built provider when you passed one, before the first event; otherwise the scenario throws `InvalidReactorHandlerReturnType`. Then assert the returned value with `ShouldHaveProduced<T>`. With the default recorder the registration only makes the return type legal: the handler is never called, so prove what it does in a spec of the handler.
31
32
  - A reactor that checks `EventContext.EventStore` or `EventContext.Namespace` sees the identity of the scenario's store, by default `testing` in namespace `default`. Pass `Defaults` built with the expected store and namespace, or an explicit `eventStore` that has them; its identity wins over the defaults. `Redeliver` keeps the occurrence's original context. See [csharp-events.md](csharp-events.md#control-time-and-artifacts).
32
33
  - `await scenario.Given.ForEventSource(id).Events(...)` delivers the events. It does **not** build read models.
33
34
  - A reactor method that takes a read model needs it declared: `scenario.Given.ForEventSource(id).ReadModel(instance)` or `.NoReadModel<T>()` for a deliberate `null`. Omitting both throws `ReadModelNotSeededForReactorScenario`, for nullable and non-nullable parameters alike; its message lists the keys already seeded for that type. When the reactor implements `ICanResolveReadModelKey`, seed or declare absence under the key it returns, not the triggering event source id.
@@ -1,5 +1,13 @@
1
1
  # Prove a C# projected or reduced row with ReadModelScenario
2
2
 
3
+ ## Contents
4
+
5
+ - Run the application's definition
6
+ - Members
7
+ - Failures that name the cause
8
+ - Share or isolate the in-memory store
9
+ - ProjectionSlice
10
+
3
11
  Names are illustrative; the application's own domain language replaces them.
4
12
 
5
13
  ## Run the application's definition
@@ -7,7 +15,11 @@ Names are illustrative; the application's own domain language replaces them.
7
15
  `ReadModelScenario<TReadModel>` (namespace `Cratis.Chronicle.Testing.ReadModels`) runs the application's discovered projection or reducer for that model.
8
16
 
9
17
  - **Route events as production does.** `Given.ForEventSource(id).Events(...)` uses the source alone; add `.OnStream(...)` or `.WithTags(...)` when the model depends on them. A one-source happy path can conceal a broken join or key.
10
- - **Read the result by key.** `scenario.Instance` is the single materialized instance and throws when there are several; use `scenario.InstanceForEventSourceId(id)` or `scenario.Instances` then. `ShouldPartiallyMatchReadModel(id, new { Status = "Held" })` recursively checks only the listed public properties at that key, `ShouldExactlyMatchReadModel(id, expected)` the complete public property set, and `ShouldHaveNoReadModel(id)` absence.
18
+ - **Read the result by key.** `scenario.Instance` is the single materialized instance and throws when there are several; use `scenario.InstanceForEventSourceId(id)` or `scenario.Instances` then. `ShouldPartiallyMatchReadModel(id, new { Status = "Held" })` recursively checks only the listed public properties at that key, `ShouldExactlyMatchReadModel(id, expected)` the complete public property set, and `ShouldHaveNoReadModel(id)` absence. For all three:
19
+ - The `id` is the materialized read-model key, which is not the appending event's source when the definition keys the model by something else. Assert at the key the definition produces.
20
+ - Scalar and concept types compare strictly and property names are case-sensitive: an expected `12` (`int`) does not match a `decimal` `12m`, and a primitive does not match its concept. Write the expected value in the property's declared type; a type difference is a real failure, not noise to work around. A listed `null` is an expected value: to ignore a property in a partial match, leave it out.
21
+ - Collections must have equal length and order; dictionary entries match by key. A failure throws `ReadModelAssertionFailed` naming the model, the key and the first differing member.
22
+ - The exact form adds completeness only. It does not repair a wrong key or a wrong type.
11
23
  - **Several sources feed one model.** `CollectEventsFor(id, events)` accumulates events per source and they are processed together on the next read, which a model with children from other streams needs; `await ProcessEventsFor(id, events)` collects bare events for the next read.
12
24
  - **Start from existing state when that is the premise.** `await scenario.Given.ForEventSource(id).ReadModel(existing)` seeds an instance; later events fold on top of it. `Given.ForKey(...)` seeds a composite key. Seeding the same key twice throws `ReadModelAlreadySeeded`.
13
25
  - **Reuse real envelopes.** `ProcessAppendedEvents(events)` applies `AppendedEvent` values captured elsewhere with their original context. Only an envelope carries the original `Occurred`, including its UTC offset: a bare event passed to `Given...Events(...)` or `ProcessEventsFor` gets the time of the spec run. A regression about a value taken from the event context therefore needs the envelopes. `DateTimeOffset` equality compares the instant and ignores the offset, so `ShouldEqual` passes when only the offset changed: assert `actual.EqualsExact(expected)` or the `Offset` as well.
@@ -1289,6 +1289,8 @@
1289
1289
  "cratis-commits-and-pull-requests",
1290
1290
  "cratis-environments-and-secrets",
1291
1291
  "cratis-performance-review",
1292
+ "cratis-platform-start-application",
1293
+ "cratis-platform-upgrade-application",
1292
1294
  "cratis-rtk",
1293
1295
  "cratis-security-review"
1294
1296
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "8.15.0",
3
+ "version": "8.17.0",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [