@cratis/pi 7.6.4 → 7.7.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.
- package/package/corpus/agents/backend-developer.md +14 -0
- package/package/corpus/agents/code-reviewer.md +16 -0
- package/package/corpus/agents/coordinator.md +17 -0
- package/package/corpus/agents/frontend-developer.md +17 -0
- package/package/corpus/agents/orchestrator.md +18 -0
- package/package/corpus/agents/planner.md +24 -0
- package/package/corpus/agents/screenplay-modeler.md +57 -0
- package/package/corpus/agents/screenplay-renderer.md +42 -0
- package/package/corpus/agents/screenplay-reviewer.md +45 -0
- package/package/corpus/agents/slice-implementer.md +32 -5
- package/package/corpus/agents/spec-writer.md +16 -3
- package/package/corpus/prompts/add-reactor.prompt.md +5 -3
- package/package/corpus/prompts/new-vertical-slice.prompt.md +16 -5
- package/package/corpus/prompts/write-specs.prompt.md +12 -6
- package/package/corpus/rules/application-profile.md +7 -3
- package/package/corpus/rules/general.md +8 -3
- package/package/corpus/rules/glossary.md +1 -1
- package/package/corpus/rules/profiles.md +42 -4
- package/package/corpus/rules/reactors.md +30 -22
- package/package/corpus/rules/vertical-slices.md +3 -1
- package/package/corpus/skills/cratis-application-react-specifications/SKILL.md +13 -0
- package/package/corpus/skills/cratis-application-slice-conformance/LICENSE +2 -0
- package/package/corpus/skills/cratis-application-slice-conformance/SKILL.md +173 -0
- package/package/corpus/skills/cratis-application-slice-conformance/references/checklists.md +66 -0
- package/package/corpus/skills/cratis-application-slice-conformance/references/contract-and-precedence.md +49 -0
- package/package/corpus/skills/cratis-application-slice-conformance/references/provenance.md +23 -0
- package/package/corpus/skills/cratis-application-slice-conformance/references/worked-example.md +91 -0
- package/package/corpus/skills/cratis-application-slice-conformance/verification.json +14 -0
- package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +57 -1
- package/package/corpus/skills/cratis-application-slice-specifications/references/provenance.md +16 -0
- package/package/corpus/skills/cratis-arc-command/SKILL.md +10 -0
- package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +10 -0
- package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +10 -0
- package/package/corpus/skills/cratis-arc-observable-query-http/SKILL.md +10 -0
- package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +10 -0
- package/package/corpus/skills/cratis-arc-react-page/SKILL.md +68 -8
- package/package/corpus/skills/cratis-arc-react-page/references/from-screenplay.md +199 -0
- package/package/corpus/skills/cratis-arc-react-page/references/provenance.md +13 -0
- package/package/corpus/skills/cratis-chronicle-event-constraints/SKILL.md +10 -0
- package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +38 -10
- package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +13 -0
- package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +13 -0
- package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +58 -6
- package/package/corpus/skills/cratis-chronicle-reactor/references/provenance.md +9 -0
- package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +13 -0
- package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +47 -0
- package/package/corpus/skills/cratis-chronicle-read-model-specifications/references/provenance.md +11 -0
- package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +13 -0
- package/package/corpus/skills/cratis-components-stepper-command-dialog/SKILL.md +13 -0
- package/package/corpus/skills/cratis-event-model-diagram/SKILL.md +35 -16
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/LICENSE +28 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/SKILL.md +166 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/audit-format.md +31 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/automation-patterns.md +139 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/cases-to-specify.md +69 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/effects-and-idempotency.md +88 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/integration-contracts.md +64 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/provenance.md +37 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/realization-and-gap-fill.md +34 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/todo-list-example.md +208 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/translate-example.md +126 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/translation-patterns.md +93 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/worked-integration.md +98 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/verification.json +15 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +267 -50
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/complete-examples.md +185 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/verification.json +60 -12
- package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +42 -12
- package/package/corpus/skills/cratis-screenplay-discovery/LICENSE +30 -0
- package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +229 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/divergent-sweep.md +37 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/event-naming.md +64 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/facilitation.md +62 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/human-workshop.md +222 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/interview-questions.md +66 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/personas-and-causes.md +152 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/plotting-and-handoff.md +111 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/provenance.md +37 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/storming-loop.md +119 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/worked-session.md +87 -0
- package/package/corpus/skills/cratis-screenplay-discovery/verification.json +15 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +140 -77
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/invoicing-example.md +51 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/nine-steps.md +114 -28
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/parsed-not-runnable.md +50 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/verification.json +28 -3
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/LICENSE +31 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/SKILL.md +239 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/chronicle-observations.md +25 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/evidence-table-template.md +79 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/expert-verification.md +48 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/generate-notes.md +75 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/intent-example.md +164 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/interview-findings.md +88 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/loss-report-template.md +47 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/prologue-safety.md +147 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/provenance.md +10 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/rule-modeling.md +36 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/side-car-migration.md +126 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/signal-to-intent.md +57 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/ui-observation.md +52 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/verification.json +17 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +95 -54
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +50 -20
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-loop.md +211 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-tools.md +45 -5
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/provenance.md +13 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/verification.json +64 -7
- package/package/corpus/skills/cratis-screenplay-model-review/LICENSE +34 -0
- package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +209 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/anti-patterns.md +89 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/business-questions.md +128 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +176 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/provenance.md +36 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/report-template.md +149 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/review-questions.md +59 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/worked-example.md +255 -0
- package/package/corpus/skills/cratis-screenplay-model-review/verification.json +13 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/LICENSE +32 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +239 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/code-reading-and-tokens.md +55 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/handoff-template.md +124 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/identity-and-edits.md +84 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/opt-in.md +48 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phase-report-inventories.md +25 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +162 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/principles.md +53 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/provenance.md +63 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/reasoning-notes.md +31 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/safety.md +31 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/stop-or-assume.md +46 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/verdicts-and-modes.md +204 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/vocabulary-map.md +55 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/worked-example.md +86 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/verification.json +16 -0
- package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +14 -3
- package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +15 -1
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/LICENSE +2 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +179 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/delivery-protocol.md +99 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/drift-and-ledger.md +67 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/gap-fill-handoff.md +72 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/provenance.md +27 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/renderability-gate.md +56 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/worked-example.md +124 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/verification.json +14 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/LICENSE +31 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/SKILL.md +200 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/berth-reservations.md +579 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/chronicle-verification.md +24 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/coverage-matrix.md +102 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/provenance.md +41 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md +196 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-workshop.md +102 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/spec-forms-by-mode.md +71 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/view-and-story-specs.md +91 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/verification.json +13 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/LICENSE +30 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/SKILL.md +236 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/command-inventory.md +107 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/field-lineage.md +130 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/provenance.md +20 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/read-model-design.md +201 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/review-questions.md +23 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/rule-layers.md +41 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/slicing.md +122 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/worked-example.md +305 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/verification.json +43 -0
- package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +217 -36
- package/package/corpus/skills/cratis-screenplay-specifications/verification.json +28 -4
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/LICENSE +33 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/SKILL.md +191 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/boundaries.md +154 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/chronicle-boundaries.md +54 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/consistency-and-concurrency.md +191 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/evolution-example.md +70 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/evolution.md +65 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/provenance.md +13 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/stream-patterns.md +128 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/streams-example.md +378 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/verification.json +14 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/LICENSE +2 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +177 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/automation-translate-example.md +121 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/cheat-sheet-example.md +319 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/cheat-sheet.md +96 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +107 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/doc-contradictions.md +48 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-example.md +113 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +148 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/pdl-example.md +267 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/provenance.md +51 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/renderable-subset.md +88 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/traps.md +51 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/verdicts.md +134 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/versions.md +134 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/verification.json +15 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +53 -5
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/flow-review.md +56 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/provenance.md +13 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/worked-flow.md +65 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/verification.json +4 -1
- package/package/corpus/skills/cratis-specification-by-example/SKILL.md +44 -1
- package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +10 -0
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +186 -219
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/admission.md +177 -0
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/render-example.md +150 -0
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/rendered-application.md +87 -0
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/sandbox-and-specrunner.md +98 -0
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/verification.json +19 -0
- package/package/profile-catalog.json +11 -0
- package/package.json +1 -1
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# Read-model design
|
|
2
|
+
|
|
3
|
+
## Start from the consumer
|
|
4
|
+
|
|
5
|
+
List every consumer before designing any read model: each screen area a person looks at, and
|
|
6
|
+
each automation that needs to decide something. A read model exists for a consumer; a read
|
|
7
|
+
model nobody uses is a question.
|
|
8
|
+
|
|
9
|
+
For each consumer: what does it show or decide, for which instance or set, and for whom? How
|
|
10
|
+
stale may it be, and what does a stale answer cost? For each field: what does the person decide
|
|
11
|
+
or do with it? A field with no decision behind it is a question, not a requirement.
|
|
12
|
+
|
|
13
|
+
A screen that acts on an existing instance needs a view: it supplies the identifier the command
|
|
14
|
+
needs and the state the person decides on. Only a creation screen with nothing to show is
|
|
15
|
+
exempt; state the exemption.
|
|
16
|
+
|
|
17
|
+
## Components
|
|
18
|
+
|
|
19
|
+
- A component is an area of a screen a person would describe as one thing ("the locker list",
|
|
20
|
+
"my request status"). Most screens have one.
|
|
21
|
+
- One read model per component. Split when a person would point at two areas and name them
|
|
22
|
+
differently, or when one area needs facts from many events and another needs only one or
|
|
23
|
+
two - they change for different reasons and at different speeds.
|
|
24
|
+
- A homogeneous list is one component.
|
|
25
|
+
|
|
26
|
+
## Fan-in per field
|
|
27
|
+
|
|
28
|
+
For each read-model field, count the events that set it. More than about three is a signal to
|
|
29
|
+
look at, not a rule: a status fed by a long lifecycle is normal. Ask whether the field mixes
|
|
30
|
+
concerns that should be separate views, and whether every contributing event is genuinely a
|
|
31
|
+
change to *this* value. Report a problem only when it has a consequence (coupling, a view that
|
|
32
|
+
must change whenever unrelated facts change).
|
|
33
|
+
|
|
34
|
+
## Builder and freshness
|
|
35
|
+
|
|
36
|
+
Observable delivery does not make a materialized projection decision-consistent; a protected
|
|
37
|
+
decision needs a guarded read (`rule-layers.md`, `cratis-screenplay-streams-and-consistency`). Prefer a
|
|
38
|
+
declarative projection (mappings, event joins, counters, bounded children, removals); a join
|
|
39
|
+
consumes event facts, not another read model. Use a reducer when prior-state, attempt or
|
|
40
|
+
ordering guards cannot be expressed declaratively. Review every writer of a property: AutoMap
|
|
41
|
+
can introduce updates from other events. Use variants only when lifecycle stages have different
|
|
42
|
+
shapes. Keep growing histories in a separate view; never combine several people's PII under
|
|
43
|
+
one read-model instance (compose queries across person-scoped views instead).
|
|
44
|
+
|
|
45
|
+
Every `from` event must set or affect a field (AutoMap counts); otherwise drop it or record why
|
|
46
|
+
it stays.
|
|
47
|
+
|
|
48
|
+
## Query shape follows the business view
|
|
49
|
+
|
|
50
|
+
| The person... | Design-mode query | Executable/renderable scope |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| opens one thing | `XById => RM optional` + `by xId XId` | same (the only shape that binds today) |
|
|
53
|
+
| scans a list | `ListX => RM[]` (optionally `observable`, `filter`) | keep the list for design; add the keyed query; record V3 blocked by the list |
|
|
54
|
+
| sees their own rows | list with scope/`from` on the caller | as above; access rules are part of the view, enforced by the target |
|
|
55
|
+
| sees a site-wide figure | singleton read model, `from <Event> key literal "global"` on every `from` (a projection-level `key` routes nothing, PLAY0381; example in Screenplay `projections/keys.md`, "Literal keys") | check the binding (V3, `cratis-screenplay-toolchain`) |
|
|
56
|
+
|
|
57
|
+
- `observable` when people are expected to see others' or automation's changes while looking
|
|
58
|
+
(worklists, status awaiting an outside answer); one-shot otherwise. Design mode only
|
|
59
|
+
(PLAY0268). If access can be revoked mid-session, record that the target re-checks per emission.
|
|
60
|
+
- Never model paging or page size (no syntax, Screenplay#140). State the order in the query
|
|
61
|
+
`description` ("oldest first"); an unbounded list is a review question.
|
|
62
|
+
- A gated keyed query needs its own denial spec.
|
|
63
|
+
|
|
64
|
+
Never drop a list query from a design model just to make it bind; record the capability gap.
|
|
65
|
+
The keyed query also defines the read model's identity: its `by` property must be a read-model
|
|
66
|
+
property. The identifier always equals the projection's effective key:
|
|
67
|
+
|
|
68
|
+
| Effective key | Executable model | Renderable model (Stage) |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| event source (default or `key $eventSourceId`) | `xId = $eventSourceId`, or leave it unmapped in a scoped projection | scoped: leave it unmapped; the event must not carry a same-named, same-typed property unless `no automap` |
|
|
71
|
+
| event property (`key invoiceId`) | `xId = invoiceId` (never `$eventSourceId`) | if it binds **flat** (exact condition: `admission.md`, "Identity and key rule" 3), Stage admits it only with one `from`, every property mapped from an event property (no literals) and the key an identifier concept filled by each producing command's `for`; any other flat-bound shape is refused (`STAGE-ESM-008`/`-009`), it does not fall back to scoped. Any other shape is scoped (for example a `remove with`, a `= null` clear, or another `from` keyed by the event source); then leave the identifier unmapped or map it only from the key's own property |
|
|
72
|
+
| literal (`key literal "global"`) | leave it unmapped (scoped seeds it from the key) | refused: Stage keys are an event property or the event source (`STAGE-ESM-017`); keep the singleton in design or executable scope and record the gap |
|
|
73
|
+
|
|
74
|
+
The full rule, with the sources, is in `cratis-stage-rendering-and-sandbox`
|
|
75
|
+
`references/admission.md` ("Identity and key rule").
|
|
76
|
+
|
|
77
|
+
## No clock-relative state
|
|
78
|
+
|
|
79
|
+
"Overdue", "expired", "due in 3 days" are true now and false later; a view changes only when a
|
|
80
|
+
fact arrives. Store the deadline (business-supplied) and compare at the query or screen edge.
|
|
81
|
+
Record a fact only when passing the deadline is itself a business fact (a fee charged, a
|
|
82
|
+
reminder sent): a clock-triggered reaction (`cratis-screenplay-automations-and-translations`).
|
|
83
|
+
|
|
84
|
+
## Who may see what
|
|
85
|
+
|
|
86
|
+
- `by` and `filter` are values the caller chooses. Anything the caller must not choose (their
|
|
87
|
+
own identity, the tenant) comes from context (`from $context...`), never from a filter.
|
|
88
|
+
- `scoped to global` reaches past the tenant; treat it as a review question.
|
|
89
|
+
- A compiling query is not access control; the target realises it.
|
|
90
|
+
|
|
91
|
+
## Collections and many-at-once
|
|
92
|
+
|
|
93
|
+
Ask for each field: can there be more than one at the same time? If yes, the view is a list or
|
|
94
|
+
has children, not a single value.
|
|
95
|
+
|
|
96
|
+
## Building it
|
|
97
|
+
|
|
98
|
+
- Event properties fill read-model properties of the same name automatically (AutoMap), but the
|
|
99
|
+
match differs by binding: a scoped projection matches names case-insensitively and only for
|
|
100
|
+
the same type (Screenplay v4.64.0 `ProjectionValues.cs` `AutoMapped`); a flat-bound projection
|
|
101
|
+
matches exact names only and does not check the type, so a same-named property of another
|
|
102
|
+
type makes the model invalid (`Projections.cs` `BindFlatTransition`). Do not rely on AutoMap
|
|
103
|
+
where it matters: map explicitly when names or types differ, and use `no automap` where an
|
|
104
|
+
event property would land on the identifier.
|
|
105
|
+
- Status words are literals per event (`state = "waiting"` on the request event).
|
|
106
|
+
- Removal is a fact: `remove with <Event>` when the business ends the instance's visibility.
|
|
107
|
+
- Projection mechanics (keys, joins, children, counters): `cratis-screenplay-projections`.
|
|
108
|
+
- A read model that is not built from events uses a query `performer`; its data is outside the
|
|
109
|
+
model's lineage - say where it comes from.
|
|
110
|
+
|
|
111
|
+
## Omissions are decisions
|
|
112
|
+
|
|
113
|
+
If a view must stop showing cancelled items, use `remove with <Event>` and pin it with
|
|
114
|
+
`then no readmodel <RM> for "<key>"`. If it keeps them, map a status literal from that event
|
|
115
|
+
instead. The slice `description`, the projection and every spec of the view must agree.
|
|
116
|
+
A complete example (marina berths; the `then no readmodel` assertion needs the keyed
|
|
117
|
+
query, which is why the view has one):
|
|
118
|
+
|
|
119
|
+
```screenplay
|
|
120
|
+
domain Harbourlight.Berths
|
|
121
|
+
|
|
122
|
+
concept BookingId : Uuid
|
|
123
|
+
concept BerthName : String
|
|
124
|
+
validate
|
|
125
|
+
not empty message "A berth needs a name"
|
|
126
|
+
concept BookingState : Enum
|
|
127
|
+
open
|
|
128
|
+
cancelled
|
|
129
|
+
|
|
130
|
+
policy IsAuthenticated
|
|
131
|
+
require authenticated
|
|
132
|
+
|
|
133
|
+
module Berths
|
|
134
|
+
description "Berth bookings for one marina"
|
|
135
|
+
authorize IsAuthenticated
|
|
136
|
+
feature Bookings
|
|
137
|
+
slice StateChange BookBerth
|
|
138
|
+
description "A skipper books a berth"
|
|
139
|
+
command BookBerth
|
|
140
|
+
bookingId BookingId identifier
|
|
141
|
+
berth BerthName
|
|
142
|
+
produces BerthBooked
|
|
143
|
+
for bookingId
|
|
144
|
+
berth = berth
|
|
145
|
+
event BerthBooked
|
|
146
|
+
berth BerthName
|
|
147
|
+
specification BookingABerth
|
|
148
|
+
given caller
|
|
149
|
+
authenticated
|
|
150
|
+
when BookBerth
|
|
151
|
+
bookingId = "3b0c7a14-5d2e-4f61-8a9b-0c1d2e3f4a01"
|
|
152
|
+
berth = "Pier 2, berth 14"
|
|
153
|
+
then BerthBooked
|
|
154
|
+
for "3b0c7a14-5d2e-4f61-8a9b-0c1d2e3f4a01"
|
|
155
|
+
berth = "Pier 2, berth 14"
|
|
156
|
+
|
|
157
|
+
slice StateChange CancelBooking
|
|
158
|
+
description "A skipper cancels a booking they no longer need"
|
|
159
|
+
command CancelBooking
|
|
160
|
+
bookingId BookingId identifier
|
|
161
|
+
produces BookingCancelled
|
|
162
|
+
for bookingId
|
|
163
|
+
event BookingCancelled
|
|
164
|
+
|
|
165
|
+
slice StateView OpenBookings
|
|
166
|
+
description "The harbour office lists bookings that still hold a berth. BerthBooked sets berth: the booking enters the list. BookingCancelled removes it: a cancelled booking never shows."
|
|
167
|
+
readmodel OpenBooking
|
|
168
|
+
bookingId BookingId
|
|
169
|
+
berth BerthName
|
|
170
|
+
query OpenBookingById => OpenBooking optional
|
|
171
|
+
by bookingId BookingId
|
|
172
|
+
projection OpenBookings => OpenBooking
|
|
173
|
+
from BerthBooked
|
|
174
|
+
bookingId = $eventSourceId
|
|
175
|
+
berth = berth
|
|
176
|
+
remove with BookingCancelled
|
|
177
|
+
screen OpenBooking
|
|
178
|
+
title "Open booking"
|
|
179
|
+
data OpenBooking via query OpenBookingById
|
|
180
|
+
action CancelBooking
|
|
181
|
+
specification CancelledBookingLeavesTheList
|
|
182
|
+
given caller
|
|
183
|
+
authenticated
|
|
184
|
+
given BerthBooked
|
|
185
|
+
for "3b0c7a14-5d2e-4f61-8a9b-0c1d2e3f4a01"
|
|
186
|
+
berth = "Pier 2, berth 14"
|
|
187
|
+
given BookingCancelled
|
|
188
|
+
for "3b0c7a14-5d2e-4f61-8a9b-0c1d2e3f4a01"
|
|
189
|
+
then no readmodel OpenBooking for "3b0c7a14-5d2e-4f61-8a9b-0c1d2e3f4a01"
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## Checks before handing off
|
|
193
|
+
|
|
194
|
+
- The StateView slice `description` gives, per contributing event, the fields it sets and why
|
|
195
|
+
(see `LockerBoard` in `worked-example.md`); extend it whenever a `from` is added.
|
|
196
|
+
- Every consumer has its read model; every read model has a consumer.
|
|
197
|
+
- Every field traced (`field-lineage.md`).
|
|
198
|
+
- Executable/renderable scope: one unambiguous key per read model (one or more keyed queries,
|
|
199
|
+
all with the same `by` property), identifier equal to the projection's key (table above);
|
|
200
|
+
no list queries.
|
|
201
|
+
- Design-only shapes listed with the V3 code they cause.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Review questions
|
|
2
|
+
|
|
3
|
+
Ask these while designing and again before the Gate. Report a finding only when it has a
|
|
4
|
+
domain consequence.
|
|
5
|
+
|
|
6
|
+
- Can the persona who should do this reach the command, and may they? Does every persona have
|
|
7
|
+
a screen with data (and an action unless it is a read-only role with a stated purpose)? Can
|
|
8
|
+
someone act for another: role policy, ownership claim, or a separate command?
|
|
9
|
+
- Does this command apply in every state and set most of the entity's fields? That is a form:
|
|
10
|
+
which business reasons hide behind it? What does a person decide with each field?
|
|
11
|
+
- Does a command input carry a secret or personal value (by default the causation chain keeps it; retention is configurable, verify it)?
|
|
12
|
+
Mark the concept `@pii` or record the need for a not-audited marking.
|
|
13
|
+
- Does this optional event property hide two situations, or is it an optional detail?
|
|
14
|
+
- Does an event exist for a derived condition? Only when a domain expert names it and something
|
|
15
|
+
reacts to it; merge causes only when they mean the same to the business.
|
|
16
|
+
- Does a read model or component draw on many events (fan-in)? Split only for a named
|
|
17
|
+
consequence: different owners, change reasons or consistency needs, or a harder screen. High
|
|
18
|
+
fan-in alone is not a finding.
|
|
19
|
+
- Does one screen fire several commands for one intent (one decision)? Can there be more than
|
|
20
|
+
one of these at once (a collection)?
|
|
21
|
+
- Where is each invariant enforced atomically, and what happens if two people try at once or a
|
|
22
|
+
command is retried (`cratis-screenplay-streams-and-consistency`)?
|
|
23
|
+
- Who may see these rows, and is that enforced by scope/`from`, not by a caller filter?
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Rule layers
|
|
2
|
+
|
|
3
|
+
Put each rule in the lowest layer where it is true for every caller. Descriptions never reach
|
|
4
|
+
rendered code (Stage#178): a rule that exists only in prose is unenforced in rendered scope.
|
|
5
|
+
|
|
6
|
+
| Rule is about | Layer | Notes |
|
|
7
|
+
|---|---|---|
|
|
8
|
+
| format or meaning of a value, true wherever used | `concept` `validate` | travels with every use; a value some use must accept unchecked is a different concept. One rejection spec per concept (through one command), not per use |
|
|
9
|
+
| a predicate that is not a comparison (checksum, registry format) | `rule <Name>` on the property or concept | design mode; blocks V3 (PLAY0268) |
|
|
10
|
+
| this command's own inputs | command `validate` / `require` | a rule that applies only sometimes is an implication: `require a == false or b > c` |
|
|
11
|
+
| who may ask | `authorize` with a policy (role, claim, authenticated) | enclosing gates combine with AND and run first. Gates every command and query in a feature shares go on the feature or module so a new path inherits them |
|
|
12
|
+
| whose instance | policy `claim "x" matches subject` (the command identifier) or `matches <command property>` | executable; renders only for text-backed subjects (Uuid: STAGE-ESM-015) |
|
|
13
|
+
| uniqueness, once-only facts | `constraint` (`unique ... on`, `unique event`) | append-time; the constraint name is its identity |
|
|
14
|
+
| stored state (record exists, balance, current status) | `reads <View>` + `require <expr> message "..."` | stated intent, **NOT enforced in the model today** (PLAY0268/0271 at binding are expected in design mode; Screenplay#129/#209). Name the target: Arc `[ProtectedDecision]` + `DecisionRead<T>` (Arc 22.39.0 or later), Chronicle DCB (`concurrency` scope), or a constraint |
|
|
15
|
+
|
|
16
|
+
An unguarded materialized read is unsafe for a protected decision; a guarded read is the
|
|
17
|
+
supported route. Availability: `[ProtectedDecision]` and `DecisionRead<T>` need Arc 22.39.0 or
|
|
18
|
+
later and are **not available in Stage-rendered apps**, whose scaffold pins Arc 22.25.0 (Stage
|
|
19
|
+
4.24.0); never edit the managed dependency files to get them. For rendered scope, record a
|
|
20
|
+
capability gap (or a separately verified compatible enforcement path, such as a constraint or
|
|
21
|
+
a Chronicle DCB scope) and keep the rule as NOT enforced. Forbidden: caller-supplied copies of state in `require`, boolean attestation
|
|
22
|
+
inputs (`confirmsX == true`), rules in `handler` / implementation-hint prose.
|
|
23
|
+
|
|
24
|
+
## Authorization is executable
|
|
25
|
+
|
|
26
|
+
Persona Does/Reads/Cannot text is intent. Every Cannot line resolves to an `authorize` gate
|
|
27
|
+
(policy or ownership claim) plus a `then denied` spec whose `given caller` carries the roles
|
|
28
|
+
and claims standing for that persona; otherwise record a gap. Every command and query under an
|
|
29
|
+
inherited module/feature `authorize` gets its own `then denied` spec. Ownership gates need a
|
|
30
|
+
second caller with another claim value.
|
|
31
|
+
|
|
32
|
+
## Secrets and personal data
|
|
33
|
+
|
|
34
|
+
Command property values are, by default, recorded in the causation chain of the events they
|
|
35
|
+
produce, so treat them as permanent. Newer Chronicle versions can omit causation properties
|
|
36
|
+
(`CausationPropertyRetention.Omit`, Chronicle v19.32.0); rendered apps pin Chronicle 19.8.1.
|
|
37
|
+
Verify the actual auditing and retention configuration before relying on omission, and never
|
|
38
|
+
audit secrets. Never mark the identifier's
|
|
39
|
+
concept `@pii`; use a surrogate `Uuid` identity and carry the personal value as a `@pii`
|
|
40
|
+
property. Bearer tokens, magic links and signed URLs are never facts (record a keyed hash or
|
|
41
|
+
reference).
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Slicing, state transitions and the next slice
|
|
2
|
+
|
|
3
|
+
## Slices are the authoring unit
|
|
4
|
+
|
|
5
|
+
In Screenplay every construct already lives in a typed slice, so slicing is not a separate
|
|
6
|
+
step at the end: design each behaviour as its slice, then audit the set.
|
|
7
|
+
|
|
8
|
+
| Slice | Holds | Named after | Default |
|
|
9
|
+
|---|---|---|---|
|
|
10
|
+
| `StateChange` | command, its events, its constraints, specs | the command (`AssignLocker`) | one command per slice; renderable: required |
|
|
11
|
+
| `StateView` | read model, queries, projection/reducer, screen, specs | the view (`LockerBoard`) | one read model per slice |
|
|
12
|
+
| `Automation` | reactions, the events they produce | the behaviour (`RemindUncollectedParcels`) | see `cratis-screenplay-automations-and-translations` |
|
|
13
|
+
| `Translate` | captures, translated events | the integration (`CarrierManifests`) | see `cratis-screenplay-automations-and-translations` |
|
|
14
|
+
|
|
15
|
+
Screenplay allows several commands or read models in one slice; prefer splitting unless the
|
|
16
|
+
behaviour is genuinely one (and say why in the `description`).
|
|
17
|
+
|
|
18
|
+
## Slice dependencies
|
|
19
|
+
|
|
20
|
+
Record, per slice, the events it consumes and which slice produces each. This is for
|
|
21
|
+
orientation, not a build order: view specifications use synthetic `given` events, so slices
|
|
22
|
+
are built and checked independently. A command or reaction may consult another slice's view
|
|
23
|
+
(`reads`; unprotected in `.play`, see `rule-layers.md`). A slice never calls another slice's
|
|
24
|
+
command except through `invokes`. Dependencies run in one direction; a cycle through events
|
|
25
|
+
means the story is a feedback loop that belongs in an `Automation` slice.
|
|
26
|
+
|
|
27
|
+
For `worked-example.md`:
|
|
28
|
+
|
|
29
|
+
| Slice | Consumes | Produced by | Also reads |
|
|
30
|
+
|---|---|---|---|
|
|
31
|
+
| InstallLocker | none | | |
|
|
32
|
+
| RequestLocker | none | | |
|
|
33
|
+
| AssignLocker | none (appends `LockerAssigned`) | | views LockerSummary, RequestStatus (intent, not enforced) |
|
|
34
|
+
| LockerBoard | LockerInstalled, LockerAssigned | InstallLocker, AssignLocker | |
|
|
35
|
+
| RequestProgress | LockerRequested, LockerAssigned | RequestLocker, AssignLocker | |
|
|
36
|
+
|
|
37
|
+
## State-transition table (per entity)
|
|
38
|
+
|
|
39
|
+
Rows are states (named after the fact that put the entity there); columns are commands. Each
|
|
40
|
+
cell: the resulting event, or the refusal and where it is enforced. Fill every cell; blank
|
|
41
|
+
cells hide missing decisions.
|
|
42
|
+
|
|
43
|
+
For the locker in `worked-example.md`:
|
|
44
|
+
|
|
45
|
+
| State \ command | InstallLocker | AssignLocker |
|
|
46
|
+
|---|---|---|
|
|
47
|
+
| (none) | LockerInstalled; refused by UniqueLockerNumber if another locker holds the number | refused: `reads` + `require` (the locker is not free / the request is not waiting) - intent, NOT enforced today |
|
|
48
|
+
| installed | refused: LockerInstalledOnce | LockerAssigned; refused by OneLockerPerRequest if the request already has a locker |
|
|
49
|
+
| assigned | refused: LockerInstalledOnce | refused: OneRequestPerLocker |
|
|
50
|
+
|
|
51
|
+
The trap this table caught: `UniqueLockerNumber` alone does not stop the same locker being
|
|
52
|
+
installed twice, because an event source may re-claim its own value. The `unique event`
|
|
53
|
+
constraint closes that hole. Releasing a locker (a later slice) would add `released by` lines
|
|
54
|
+
to both assignment constraints.
|
|
55
|
+
|
|
56
|
+
Mark how each refusal is enforced: `authorize`, `validate`/`require` (inputs only),
|
|
57
|
+
`constraint` (append-time), or **target-enforced** (stored-state; recorded in the slice
|
|
58
|
+
`description` and the handoff as NOT enforced today, see `rule-layers.md`). Terminal states have
|
|
59
|
+
refusals in every column. Add one line per gated command: the caller fixture that must be
|
|
60
|
+
denied (it needs its `then denied` spec).
|
|
61
|
+
|
|
62
|
+
## Generic edits
|
|
63
|
+
|
|
64
|
+
A command or event named for a form (`UpdateLocker`, `LockerDetailsUpdated`) records that data
|
|
65
|
+
changed, not why. Rules, reactions and history lose their meaning, and the edit path usually
|
|
66
|
+
skips rules the install path enforces. Detect it in the state table: a command with the same
|
|
67
|
+
result in every row and no refusal anywhere, whose event restates most of the entity.
|
|
68
|
+
|
|
69
|
+
1. List the values the form can change; for each, ask who changes it and why.
|
|
70
|
+
2. Group values that change together for one reason; each group is a command and an event named
|
|
71
|
+
for that reason (`RelocateLocker` -> `LockerRelocated`; `CorrectLockerVolume` ->
|
|
72
|
+
`LockerVolumeCorrected`). Values nobody changes after installation need no command.
|
|
73
|
+
3. Give each new command its own state-table column, and fill its cell for every state, with refusals (an assigned locker cannot be
|
|
74
|
+
relocated).
|
|
75
|
+
4. Apply rule coverage (below) to each new path.
|
|
76
|
+
5. If the business treats a multi-value data-entry correction as one act, keep one correction
|
|
77
|
+
command named for the correction (never `Update`), with the reason in the slice
|
|
78
|
+
`description`; rule coverage still applies.
|
|
79
|
+
|
|
80
|
+
A repeated-field event is a review signal; it is major only when business meaning is lost, a
|
|
81
|
+
rule is bypassed or consumers become ambiguous. Historical generations repeat prior shape on
|
|
82
|
+
purpose and are exempt.
|
|
83
|
+
|
|
84
|
+
## Rule coverage
|
|
85
|
+
|
|
86
|
+
For each value that carries a rule, list every path that can set it:
|
|
87
|
+
|
|
88
|
+
| Value | Rule and layer | Paths that set it | Covered? |
|
|
89
|
+
|---|---|---|---|
|
|
90
|
+
| locker number | unique (constraint `UniqueLockerNumber`) | InstallLocker -> LockerInstalled; RenumberLocker -> LockerRenumbered | add `unique number on LockerRenumbered` to the same constraint |
|
|
91
|
+
| volume | at least one litre (concept `validate`) | InstallLocker; CorrectLockerVolume | covered: the concept travels |
|
|
92
|
+
| attendant gate | `authorize` on the feature | every command in the feature | covered: inherited |
|
|
93
|
+
|
|
94
|
+
A constraint covers another event by repeating its `unique` line under the same constraint name
|
|
95
|
+
(the claim is shared) - only when the events set the **same claim**. Command-level
|
|
96
|
+
`validate` / `require` and `produces when` branches do not travel: review each path and copy a
|
|
97
|
+
rule only where that decision needs it; move a format rule into the concept so it travels.
|
|
98
|
+
|
|
99
|
+
## Slice audit
|
|
100
|
+
|
|
101
|
+
- Every event belongs to exactly one `StateChange` (or `Automation`/`Translate`) slice.
|
|
102
|
+
- Every command has a reachable, authorized origin.
|
|
103
|
+
- Every read model has a consumer and a keyed query when the scope is executable.
|
|
104
|
+
- Every slice has a `description` that states its business purpose.
|
|
105
|
+
- No slice exists only for technical reasons ("set up storage").
|
|
106
|
+
|
|
107
|
+
## The next slice
|
|
108
|
+
|
|
109
|
+
If the request names the capability, build that one. Otherwise, when the current timeline is
|
|
110
|
+
fully designed, read the slices in story order and choose, preferring in order:
|
|
111
|
+
|
|
112
|
+
1. the next stage of an existing lifecycle (a locker can be assigned; can it be released?);
|
|
113
|
+
2. an action a screen implies but nothing implements, or a state change with no confirmation
|
|
114
|
+
view (in the example, the attendant needs a waiting-request view to pick a request);
|
|
115
|
+
3. a missing ending, correction or reversal - a correction or reversal names what it corrects
|
|
116
|
+
or reverses (`CorrectLockerVolume`), never `Update<Entity>`;
|
|
117
|
+
4. a notification or follow-up the business expects.
|
|
118
|
+
|
|
119
|
+
Prefer what continues the current story over a new thread. In a modeling session, act: write
|
|
120
|
+
the slice, note the assumption that chose it, and ask for correction afterwards. A wrong guess
|
|
121
|
+
costs one edit; an empty turn costs a round-trip. Record why the slice was chosen in the
|
|
122
|
+
handoff.
|