@cratis/pi 7.98.0 → 7.99.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.
@@ -1,5 +1,12 @@
1
1
  # Constraints, produces mappings and concurrency
2
2
 
3
+ ## Contents
4
+
5
+ - `constraint` — uniqueness at append time
6
+ - Refuse a command on an unknown id
7
+ - `concurrency`
8
+ - `produces`
9
+
3
10
  This reference holds the detailed forms for append-time `constraint` uniqueness, `produces` mapping sources and conditions, and the `concurrency` block.
4
11
 
5
12
  ## `constraint` — uniqueness at append time
@@ -39,6 +46,48 @@ belongs in `validate`/`require`. Use a constraint when two concurrent appends mu
39
46
  not both win — a `validate` rule cannot do that. Stage renders only single-text-property and
40
47
  `unique event` constraints (`STAGE-ESM-014`; `cratis-stage-rendering-and-sandbox` `references/admission.md`).
41
48
 
49
+ ## Refuse a command on an unknown id
50
+
51
+ Without a guard, a command naming an id that has no state is accepted and appends its event. Guard
52
+ existence with a protected read: after authorization and property rules, and before any `require`
53
+ or mapping runs, it rejects with `<ReadModel> '<key>' does not exist.` The preamble goes in the root document, the read model's key property is
54
+ named `id` (`STAGE-ESM-044` otherwise, found by `cratis render --check`), and the view needs a
55
+ `remove with` event. Complete model; it validates with `--executable`, renders with `--check`,
56
+ and the specification passes in `screenplay test`:
57
+
58
+ ```screenplay
59
+ domain Tasks
60
+ command reads protected
61
+ module Work
62
+ feature Closing
63
+ slice StateView TaskStatus
64
+ event TaskOpened
65
+ title String
66
+ event TaskDeleted
67
+ readmodel Task
68
+ id String key
69
+ title String
70
+ projection TaskProjection => Task
71
+ from TaskOpened
72
+ remove with TaskDeleted
73
+ slice StateChange CloseTask
74
+ event TaskClosed
75
+ reason String
76
+ command CloseTask
77
+ taskId String identifier
78
+ reads Task by taskId
79
+ produces TaskClosed
80
+ for taskId
81
+ reason = "done"
82
+ specification ClosingAnUnknownTask
83
+ when CloseTask
84
+ taskId = "missing"
85
+ then error "Task 'missing' does not exist."
86
+ ```
87
+
88
+ Admission, races and refused read shapes: [protected reads](protected-reads.md). A `validate` rule or a
89
+ screen guard cannot check existence, and a `unique` constraint only guards duplicates.
90
+
42
91
  ## `concurrency`
43
92
 
44
93
  Five dimensions, each at most once, and at most one `concurrency` block per
@@ -34,6 +34,8 @@ module Invoicing
34
34
 
35
35
  ## Source rules
36
36
 
37
+ - Member names are lowercase identifiers: `hourly`, not `Hourly`. A capitalised member is
38
+ PLAY0009 ("expected an identifier"); rename it, and use the same name in specifications.
37
39
  - Number **all members or none**; there is no implicit continuation after a pin.
38
40
  - Numbers are unique whole int32 values, from -2147483648 through 2147483647.
39
41
  Gaps and negative numbers are allowed; aliases and flags semantics are not.
@@ -1,5 +1,13 @@
1
1
  # Validation rule forms
2
2
 
3
+ ## Contents
4
+
5
+ - Rule vocabulary
6
+ - `require` message
7
+ - Date and DateTime comparisons
8
+ - `not empty` means non-blank text
9
+ - Rules whose logic is code
10
+
3
11
  ## Rule vocabulary
4
12
 
5
13
  | Rule | Example |
@@ -24,6 +32,16 @@ modifier generates check digits but does not add validation. Check digits catch
24
32
  typos, not forgery. For generated-concept proof statuses, deterministic regex
25
33
  limits and PLAY0688 repairs, read [generated rules](generated-values-and-responses.md#generated-concept-rules-esm-v20).
26
34
 
35
+ ## `require` message
36
+
37
+ The `message` of a whole-command `require` goes on the next, indented line, not on the `require` line:
38
+
39
+ ```screenplay excerpt
40
+ validate
41
+ require to >= from
42
+ message "The end must not be before the start"
43
+ ```
44
+
27
45
  ## Date and DateTime comparisons
28
46
 
29
47
  Requires Screenplay 4.199.0 (ESM v26; `screenplay --version`); older binders refuse
@@ -10,3 +10,7 @@ automation: model it as one `StateChange` slice with several `produces` blocks.
10
10
 
11
11
  **Translation is workflow-specific anti-corruption.** Generic infrastructure every
12
12
  workflow needs (event persistence, message transport) is not a `Translate` slice.
13
+
14
+ **Events have no optional properties for the `cratis` target.** An event property
15
+ marked `optional` validates, but `cratis render --check` refuses it (`STAGE-ESM-005`).
16
+ Make it required, or leave it out of the event; whether the detail is a separate fact is a modeling decision.
@@ -64,6 +64,9 @@ of executing the newly selected command.
64
64
 
65
65
  ## Guard boundaries
66
66
 
67
+ A guard hides an offer; it does not make a command on an unknown id fail. Existence is refused in the
68
+ command: [refuse a command on an unknown id](../../cratis-screenplay-command-surface/references/constraints-produces-concurrency.md#refuse-a-command-on-an-unknown-id).
69
+
67
70
  Conditions compare item paths to literals, not other paths, route/screen state,
68
71
  `$context` or `$env`. Equality/inequality, numeric ordering, string contains/starts
69
72
  with and grouped and/or are supported; and binds tighter than or. Collections
@@ -27,6 +27,17 @@ selection is:
27
27
  candidates and requires exactly one. An admitted list query here is a collection
28
28
  query without context-derived `by`, filters or scope.
29
29
 
30
+ Two `*Id` properties (`orderId`, `customerId`) with only a list query are ambiguous
31
+ (PLAY0268). Add one keyed query, whose `by` names the identity:
32
+
33
+ ```screenplay excerpt
34
+ readmodel Order
35
+ orderId String
36
+ customerId String
37
+ query OrderById => Order optional
38
+ by orderId String
39
+ ```
40
+
30
41
  A projection-only/queryless read model needs an explicit `key`: a lone `*Id`
31
42
  property alone does not infer identity. Never use the command's `identifier`
32
43
  modifier on a read model.
@@ -37,6 +37,8 @@ The person looks at where something stands and decides what to do next.
37
37
  events so far. Every field shown has a source in that read model.
38
38
  - The available actions depend on state. A static `action` line is always offered; an action that
39
39
  must differ by state is a guarded action (`references/guarded-actions.md`), never prose.
40
+ - A list the screen renders is `query <Name> => observable <ReadModel>[]`. A snapshot list renders too, but
41
+ it is read once and does not follow later events; `observable` keeps the table current after a command.
40
42
  - A status screen with no incoming view is a gap; only a blank creation form is exempt.
41
43
 
42
44
  ## Error state
@@ -34,6 +34,24 @@ Requires Screenplay 4.145.0 or later (`screenplay --version`) for `run-specifica
34
34
 
35
35
  Read [source notes](references/source-notes.md) for the retained inline-fact and action-syntax evidence; run the changed examples at the standalone pin.
36
36
 
37
+ ## State every property
38
+
39
+ A `when` command and each `then` event list **every** property, including `optional`
40
+ ones, with a concrete value; omitting one is PLAY0524. Only a read-model property may be `null` (PLAY0350).
41
+ This model fails with PLAY0524 on both `when` and `then` until `note = "none"` is added:
42
+
43
+ ```screenplay excerpt
44
+ event TaskOpened
45
+ note String optional
46
+ specification Opening
47
+ when OpenTask
48
+ taskId = "t1"
49
+ title = "Write"
50
+ then TaskOpened
51
+ for "t1"
52
+ title = "Write"
53
+ ```
54
+
37
55
  ## Reference execution — what actually runs
38
56
 
39
57
  Screenplay's reference runner executes specifications against an immutable
@@ -25,6 +25,8 @@ a seed is not a portable fixture.
25
25
 
26
26
  ## When not to
27
27
 
28
+ A fixture still states every command and event property with a concrete value, optional ones included (PLAY0524); a generated value does not excuse an omitted field.
29
+
28
30
  Pins do not prove randomness, authorization, idempotency, storage freshness or
29
31
  secret safety. Client-minted IDs stay inputs; gapless invoice numbering needs an
30
32
  allocator, not a random fixture or pattern. Check digits catch typos, not forgery;
@@ -218,6 +218,8 @@ unresolved questions: the standalone tool has `--open-questions fail`; `cratis s
218
218
  does through `--open-questions report|fail`. It is separate from compilation and `--warnaserror`.
219
219
  Requires Cratis CLI 3.60.0 or later (`cratis --version`) for that option; older CLIs lack it.
220
220
 
221
+ Read [fast path](references/fast-path.md) for the ordered requirements-to-running-app checklist (validate, `render --check`, render, build, run).
222
+
221
223
  ## Route near misses
222
224
 
223
225
  Read [references/neighbouring-skills.md](references/neighbouring-skills.md) when the work is modeling phases, MCP editing, construct depth, rendering or running systems.
@@ -0,0 +1,24 @@
1
+ # Fast path: requirements to a running Cratis app
2
+
3
+ Run these in order and stop at the first failure; each step catches what the one before cannot.
4
+ `<root>` is the model folder, `<dir>` the render destination.
5
+
6
+ 1. **Model** the requirements (`cratis-screenplay-modeling-lifecycle`). Enum members lowercase,
7
+ specifications state every property, no optional event property, list queries `observable`
8
+ (`references/traps.md` 46-47).
9
+ 2. **Validate:** `cratis screenplay validate --executable --warnings-as-errors <root>`. Pass: exit 0 and no error.
10
+ It binds the model but does not run the renderer's admission.
11
+ 3. **Admit:** `cratis render <root> --target cratis --name <App> --destination <dir> --check`.
12
+ It plans without writing; a refusal (for example `STAGE-ESM-005`, an optional event
13
+ property) lists every blocker at once. Fix and repeat until it reports no error diagnostic. Exit 6 on a
14
+ clean plan means only that changes are pending; nothing is published.
15
+ 4. **Render:** the same command without `--check`. Publication succeeded when it exits 0 and the receipt shows
16
+ `refused: 0` and `recoveryPending: false`.
17
+ 5. **Build:** `dotnet build <dir>/<App>.csproj` (Debug).
18
+ 6. **Services:** `docker compose up -d` in `<dir>` (Chronicle and MongoDB).
19
+ 7. **Backend:** `dotnet run --project <App>.csproj` in `<dir>`.
20
+ 8. **Frontend:** in `<dir>`, `yarn` then `yarn dev` (npm: `npm install`, `npm run dev`); open the URL Vite
21
+ prints. It proxies API calls to the backend.
22
+
23
+ The rendered `README.md` repeats steps 6-8 for the pinned scaffold. Re-render and gap-fill rules:
24
+ `cratis-screenplay-render-and-gap-fill`.
@@ -18,7 +18,7 @@ Compiler syntax: `cheat-sheet.md`. Negative capability claims depend on the tool
18
18
  14. AutoMap is on by default: same-named event properties fill read-model properties silently (scoped: case-insensitive, same type only; flat-bound: exact name, no type check, so a type mismatch invalidates the model). Use `no automap` for control.
19
19
  15. `given readmodel` bypasses the projection; prove a projection with `given` events + `when append`/command + `then readmodel`/`then query`.
20
20
  16. PLAY0285/0286/0287 are static spec checks: do not edit expectations blindly. An older bundled compiler can report PLAY0285 falsely on reaction cascades; confirm with the standalone tool before changing a `then`.
21
- 17. `null` in specs only for optional read-model properties (PLAY0350); omit the property or record a gap; whether an optional detail is really a separate fact is a review question, not the fix for this code.
21
+ 17. `null` in specs only for optional read-model properties (PLAY0350). A `when` command or `then` event states every property with a concrete value, optional ones too (PLAY0524); whether an optional detail is really a separate fact is a review question, not the fix for this code.
22
22
  18. `then` events are exhaustive and ordered (use `then events in any order` for order only). From ESM v6 they include reaction cascades; after `when append` they list only what followed the append.
23
23
  19. Under `command reads protected`, omitted `by` uses the command identifier; absent identifier is PLAY0782. Eligible reads bind v25; legacy reads and `concurrency` retain PLAY0271. Combining reads/concurrency under opt-in is PLAY0783.
24
24
  20. Declare each event once, in its producing slice; renaming a persisted event needs `id "OldName"`; renaming a constraint discards its index.
@@ -70,3 +70,5 @@ Traps 39 to 44 are tool traps.
70
70
  43. `modelRevision` is canonical semantic (line positions and descriptions do not change it; a file move only if it changes logical placement or application identity) and, without `identities.json`, changes with the root folder name; it is not comparable with a render's `semanticRevision`. Source identity for verdicts is the commit plus the digest from the source-identity helper (`cratis-screenplay-modeling-lifecycle` `references/verdicts-and-modes.md` "Source identity").
71
71
  44. `cratis render` neither builds nor tests; `--name` is required for plain source; `.cratis-render/` is control state and is never staged; rendered apps pin their own Arc and Chronicle versions (`[ProtectedDecision]` is available to gap-fill, not automatically emitted). `cratis` file mode versus folder mode (trap 6) and a stale `cratis` on `PATH` (`which -a cratis`) both silently change what a verdict means.
72
72
  45. A reducer cannot be re-keyed: its instances follow the event-source id, so a query `by` another identity type warns PLAY0690 (`--warnaserror` fails it; editors only show it when the host supplies native findings). Aggregate by a payload value with a projection keyed on each `from`, or a join: projections [reducer identity](../../cratis-screenplay-projections/references/reducer-identity.md).
73
+ 46. Enum members are lowercase identifiers (`hourly`, not `Hourly`; PLAY0009). A specification states every property of the command and events, optional ones too (PLAY0524). A read model with two `*Id` properties needs one keyed query, `query OrderById => Order optional` with `by orderId String` (PLAY0268 otherwise). A `require` message goes on the next indented line (trap 38). Screen list queries are `observable`.
74
+ 47. Cratis events have no optional properties (STAGE-ESM-005), and `validate --executable` does not catch it: run `cratis render <folder> --target cratis --name <App> --destination <dir> --check` right after validate, since it runs the renderer's admission and writes nothing.
@@ -2,6 +2,7 @@
2
2
 
3
3
  ## Contents
4
4
 
5
+ - Default shell
5
6
  - One complete shell
6
7
  - Navigation regions: inherit, extend or override
7
8
  - Toolbar buttons that invoke a State Change slice
@@ -20,6 +21,12 @@ Every construct here is authoring syntax. The executable model defers it (`PLAY0
20
21
  tree, and none of it changes a backend. The Scene designer, the Stage runtime and Studio read the same lines, so the
21
22
  Screenplay is the one place to write them.
22
23
 
24
+ ## Default shell
25
+
26
+ Requires Stage 4.189.3 or later (the CLI that bundles it) for a rendered frontend to get a default application shell without a
27
+ `layout` or `ui profile`. Declare a `layout` and a `ui profile` only to customize that shell
28
+ (navigation, logo, templates, sample data), as below.
29
+
23
30
  ## One complete shell
24
31
 
25
32
  ```screenplay
@@ -2,6 +2,7 @@
2
2
 
3
3
  ## Contents
4
4
 
5
+ - Probe before the first real render
5
6
  - How a refusal arrives
6
7
  - Event-reaction boundary
7
8
  - Recovery, stored identity and baseline boundaries
@@ -57,6 +58,13 @@ Binding with the CLI's bundled compiler is a separate
57
58
  prerequisite. The exhaustive construct table is `references/renderable-subset.md` in
58
59
  `cratis-screenplay-toolchain`; run the real render before claiming anything is admitted.
59
60
 
61
+ ## Probe before the first real render
62
+
63
+ `cratis screenplay validate --executable` binds the model but does not run Stage admission, so a
64
+ renderer refusal such as `STAGE-ESM-005` (Cratis events have no optional properties) passes it.
65
+ Run `cratis render <root> --target cratis --name <App> --destination <dir> --check` right after validate:
66
+ it runs the same admission, collects every refusal and writes nothing.
67
+
60
68
  ## How a refusal arrives
61
69
 
62
70
  One blocking diagnostic fails the **whole** plan and nothing is published (exit 5).
@@ -3,6 +3,7 @@
3
3
  ## Contents
4
4
 
5
5
  - Scaffold
6
+ - Lists on screen
6
7
  - Reducer layout for new applications
7
8
  - What is managed
8
9
  - `Customizations/` (unmanaged)
@@ -50,6 +51,13 @@ is off), but any override must be proven with a restore and build. The compose f
50
51
  `35000`, keeps data in the named volumes `chronicle-data` and `chronicle-config`, and
51
52
  `docker compose down --volumes` is the only thing that deletes them.
52
53
 
54
+ ## Lists on screen
55
+
56
+ A `data <ReadModel>[] via query <Query>` list renders from either list-query mode, but
57
+ `observable` renders `Observe<T>()` and a first-result wait, while a snapshot renders a one-shot
58
+ `GetInstances<T>()`. Declare `query <Name> => observable <ReadModel>[]` for any list a person watches change.
59
+ Run `cratis render --check` first (`references/admission.md`) to catch refusals before a real render.
60
+
53
61
  ## Reducer layout for new applications
54
62
 
55
63
  Requires Stage 4.128.0 for the Cratis C# self-reducing profile; older renderers emit
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.98.0",
3
+ "version": "7.99.0",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [