@cratis/pi 7.53.1 → 7.55.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 +1 -1
- package/package/corpus/agents/code-reviewer.md +1 -1
- package/package/corpus/agents/coordinator.md +1 -1
- package/package/corpus/agents/frontend-developer.md +1 -1
- package/package/corpus/agents/orchestrator.md +1 -1
- package/package/corpus/agents/planner.md +1 -1
- package/package/corpus/agents/screenplay-modeler.md +1 -1
- package/package/corpus/agents/slice-implementer.md +2 -2
- package/package/corpus/agents/spec-writer.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/application-profile.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +2 -0
- package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +1 -5
- package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +3 -2
- package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +14 -1
- package/package/corpus/prompts/add-reactor.prompt.md +1 -1
- package/package/corpus/prompts/new-vertical-slice.prompt.md +1 -1
- package/package/corpus/prompts/write-specs.prompt.md +1 -1
- package/package/corpus/rules/application-profile.md +1 -1
- package/package/corpus/rules/glossary.md +2 -0
- package/package/corpus/rules/profiles.md +1 -5
- package/package/corpus/rules/reactors.md +3 -2
- package/package/corpus/rules/vertical-slices.md +14 -1
- package/package/corpus/skills/cratis-application-react-specifications/SKILL.md +1 -4
- package/package/corpus/skills/cratis-application-slice-conformance/SKILL.md +6 -10
- package/package/corpus/skills/cratis-application-slice-conformance/references/contract-and-precedence.md +3 -8
- package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +1 -3
- package/package/corpus/skills/cratis-arc-command/SKILL.md +1 -4
- package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +1 -4
- package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +1 -4
- package/package/corpus/skills/cratis-arc-observable-query-http/SKILL.md +1 -4
- package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +1 -4
- package/package/corpus/skills/cratis-arc-react-page/SKILL.md +1 -4
- package/package/corpus/skills/cratis-chronicle-event-constraints/SKILL.md +1 -4
- package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +16 -5
- package/package/corpus/skills/cratis-chronicle-event-modeling/references/event-log-cleanup-rollout.md +53 -0
- package/package/corpus/skills/cratis-chronicle-event-modeling/references/event-log-hygiene.md +92 -0
- package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +1 -4
- package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +7 -4
- package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +9 -3
- package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +1 -4
- package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +1 -3
- package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +1 -4
- package/package/corpus/skills/cratis-components-stepper-command-dialog/SKILL.md +1 -4
- package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +1 -2
- package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +1 -7
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +9 -9
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/opt-in.md +3 -33
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +1 -5
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/scripts/model-first-self-test.mjs +104 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/scripts/model-first-status.mjs +141 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +1 -1
- package/package/corpus/skills/cratis-specification-by-example/SKILL.md +1 -3
- package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +1 -4
- package/package.json +1 -1
|
@@ -49,7 +49,7 @@ Load **cratis-application-slice-conformance** when it is installed; read the ski
|
|
|
49
49
|
|
|
50
50
|
## Process
|
|
51
51
|
|
|
52
|
-
0. **Find the contract.** Apply Phase 0 of `application-profile.md` first:
|
|
52
|
+
0. **Find the contract.** Apply Phase 0 of `application-profile.md` first: decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. When opted in, an accepted model under the root is the contract, and new behaviour missing from the model is a request to add it, not a reason to use an outline. Skill availability is checked separately from opt-in. Without opt-in, an agreed outline is the contract and code-first work (infrastructure, clients, adapters, framework) is preserved. If the slice is in a Screenplay model, the `.play` slice and its specifications are the contract: write C# only for scope the renderer rejects or for adapters, never edit Stage-managed output, and never change the model to match code. If the contract is ambiguous or contradictory, do not guess: stop that scope and return one specific question (for `.play`, an edit request: address, change, reason).
|
|
53
53
|
1. **Determine the namespace root** by reading an existing source file to identify the convention (e.g. `Studio`, `Library`, `MyApp`).
|
|
54
54
|
2. **Read existing slices** in the same feature to understand naming, existing concepts, and events you may reference.
|
|
55
55
|
3. **Create a single `.cs` file** at `<Feature>/<Slice>/<Slice>.cs` (under the app source root; an optional `<Module>/` may group the feature — there is **no** top-level `Features/` wrapper).
|
|
@@ -31,7 +31,7 @@ Select only diff-relevant, profile-applicable canonical rules in `.cratis/ai/rul
|
|
|
31
31
|
|
|
32
32
|
## Model-first check
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` once per review for the decision, model root and drafts. Otherwise skip this section, and do not demand a model from framework, brownfield or not-opted-in work. If the Screenplay skills are missing, say so in the report rather than reviewing model content from memory.
|
|
35
35
|
|
|
36
36
|
In an opted-in repository:
|
|
37
37
|
|
|
@@ -45,7 +45,7 @@ After selecting the profile and lane, read the applicable entries only:
|
|
|
45
45
|
Run this once per request, before choosing an implementer; the master text is in `cratis-screenplay-modeling-lifecycle`.
|
|
46
46
|
|
|
47
47
|
1. **Skill availability is separate from consent.** Check that the Screenplay method skills you need are installed. If they are missing, report which and stop for model work; never author Screenplay from memory and never install anything. Installed skills never opt a repository in.
|
|
48
|
-
2. **Opted in?**
|
|
48
|
+
2. **Opted in?** Apply `general.md` "Model first" for opt-in; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. If your brief already states the decision, use it. Then the `.play` model is the source of truth and the plan starts from it.
|
|
49
49
|
3. **Not opted in:** stay code-first. Only the entry-point agent or session proposes a model (never when your brief carries the decision), at most once per session, naming the feature it would start with, and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again, and put the decision in the brief of every delegated agent. Unattended: record the recommendation in the final report. Framework, brownfield, infrastructure, client and adapter work stays code-first and is never forced into a model.
|
|
50
50
|
4. **Code is the right level for** infrastructure, clients, Screenplay code attachments and handlers, adapters, and scope Stage cannot render yet (gap-fill, with the `.play` slice and specs as the contract). Never use code as a shortcut around the model, change the model to match existing code, edit Stage-managed output, leave a modeled rule living only in code, or weaken protection (authorization, `@pii`, rules) to make a model compile or render.
|
|
51
51
|
5. **Proportional execution still applies.** A model-first request does not require a multi-agent hierarchy: a trivial change is one short plan for one implementer (or the parent).
|
|
@@ -52,7 +52,7 @@ Confirm that the TypeScript proxies exist in the slice folder before writing any
|
|
|
52
52
|
|
|
53
53
|
## Model-first check
|
|
54
54
|
|
|
55
|
-
Before writing slice UI, decide the level. The model is the source of truth when an accepted `.play` model covers the slice, or when the repository has opted in
|
|
55
|
+
Before writing slice UI, decide the level. The model is the source of truth when an accepted `.play` model covers the slice, or when the repository has opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts). The page is then the model's implementation:
|
|
56
56
|
|
|
57
57
|
- Read the slice's `screen` and `form` declarations first, and follow `cratis-arc-react-page` `references/from-screenplay.md` for the declaration-to-component mapping. Use `cratis-screenplay-modeling-lifecycle` for the model-first decision rule.
|
|
58
58
|
- Where the model and the request disagree, fix the model first (through the modeler, or ask) and report it. Never change the model to match existing code, and never add data or actions in the page that the model lacks.
|
|
@@ -46,7 +46,7 @@ After selecting the profile and lane, read the applicable entries only:
|
|
|
46
46
|
Run this once per request, before choosing an implementer; the master text is in `cratis-screenplay-modeling-lifecycle`.
|
|
47
47
|
|
|
48
48
|
1. **Skill availability is separate from consent.** Check that the Screenplay method skills you need are installed. If they are missing, report which and stop for model work; never author Screenplay from memory and never install anything. Installed skills never opt a repository in.
|
|
49
|
-
2. **Opted in?**
|
|
49
|
+
2. **Opted in?** Apply `general.md` "Model first" for opt-in; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. If your brief already states the decision, use it. Then the `.play` model is the source of truth and the plan starts from it.
|
|
50
50
|
3. **Not opted in:** stay code-first. Only the entry-point agent or session proposes a model (never when your brief carries the decision), at most once per session, naming the feature it would start with, and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again, and put the decision in the brief of every delegated agent. Unattended: record the recommendation in the final report. Framework, brownfield, infrastructure, client and adapter work stays code-first and is never forced into a model.
|
|
51
51
|
4. **Code is the right level for** infrastructure, clients, Screenplay code attachments and handlers, adapters, and scope Stage cannot render yet (gap-fill, with the `.play` slice and specs as the contract). Never use code as a shortcut around the model, change the model to match existing code, edit Stage-managed output, leave a modeled rule living only in code, or weaken protection (authorization, `@pii`, rules) to make a model compile or render.
|
|
52
52
|
5. **Proportional execution still applies.** A model-first request does not require a multi-agent hierarchy: a trivial change is one short plan for one implementer (or the parent).
|
|
@@ -44,7 +44,7 @@ After selecting the profile and lane, read the applicable entries only:
|
|
|
44
44
|
Run this once per request, before choosing an implementer; the master text is in `cratis-screenplay-modeling-lifecycle`.
|
|
45
45
|
|
|
46
46
|
1. **Skill availability is separate from consent.** Check that the Screenplay method skills you need are installed. If they are missing, report which and stop for model work; never author Screenplay from memory and never install anything. Installed skills never opt a repository in.
|
|
47
|
-
2. **Opted in?**
|
|
47
|
+
2. **Opted in?** Apply `general.md` "Model first" for opt-in; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. If your brief already states the decision, use it. Then the `.play` model is the source of truth and the plan starts from it.
|
|
48
48
|
3. **Not opted in:** stay code-first. Only the entry-point agent or session proposes a model (never when your brief carries the decision), at most once per session, naming the feature it would start with, and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again, and put the decision in the brief of every delegated agent. Unattended: record the recommendation in the final report. Framework, brownfield, infrastructure, client and adapter work stays code-first and is never forced into a model.
|
|
49
49
|
4. **Code is the right level for** infrastructure, clients, Screenplay code attachments and handlers, adapters, and scope Stage cannot render yet (gap-fill, with the `.play` slice and specs as the contract). Never use code as a shortcut around the model, change the model to match existing code, edit Stage-managed output, leave a modeled rule living only in code, or weaken protection (authorization, `@pii`, rules) to make a model compile or render.
|
|
50
50
|
5. **Proportional execution still applies.** A model-first request does not require a multi-agent hierarchy: a trivial change is one short plan for one implementer (or the parent).
|
|
@@ -22,7 +22,7 @@ You author and change the `.play` model, the source of truth for behavior. Code
|
|
|
22
22
|
|
|
23
23
|
## Capability guard (first, before anything else)
|
|
24
24
|
|
|
25
|
-
1. Decide
|
|
25
|
+
1. Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. A direct user request to model this scope is itself the consent for that scope. Your work in the model root stays a draft until the user commits it; recommend the commit at P6 and never commit yourself. Otherwise stop and report that the repository is not opted in (never propose a model yourself when delegated); the code-first path belongs to the code agents.
|
|
26
26
|
2. Availability is separate from consent. If `cratis-screenplay-modeling-lifecycle` (or the phase skill the step needs) is not installed, say that the `cratis/screenplay` profile is not installed, name the missing skill, and stop with `Outcome: blocked`. Never author Screenplay from memory, never install anything.
|
|
27
27
|
3. Read the `.play` slice, its specifications and STATE.md before concluding something is missing.
|
|
28
28
|
|
|
@@ -41,10 +41,10 @@ A new vertical slice (State Change, State View, Automation, Translation), or a n
|
|
|
41
41
|
|
|
42
42
|
### Phase 1 — Contract
|
|
43
43
|
Find what the code must match before writing any of it.
|
|
44
|
-
1. **Look for a Screenplay model** under the
|
|
44
|
+
1. **Look for a Screenplay model** under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts) and search it for the slice, command, event and read-model names. Use the decision in your brief if it carries one. If the Screenplay skills are not installed, say so and do not author `.play` from memory.
|
|
45
45
|
2. **An accepted model under the root covers the slice:** the `.play` slice and its specifications are the contract. Change behaviour in the model first, then render it; write C# by hand only for scope the renderer rejects (gap-fill, per `cratis-screenplay-render-and-gap-fill`) or for adapters and infrastructure. Never hand-edit Stage-managed output; never change the model to match existing code.
|
|
46
46
|
3. **Opted in (an accepted model under the root, or a configured root, even if empty) but no accepted model covers this behaviour:** return a request to add it to the model (address, change, reason); new behaviour starts in discovery and slice design (`cratis-screenplay-discovery`, `cratis-screenplay-slice-design`). Write code first only when the user chooses to, or the behaviour cannot be expressed in `.play`; then report that the model lags the code.
|
|
47
|
-
4. **Not opted in (
|
|
47
|
+
4. **Not opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`):** stay code-first; do not propose a model (only the entry-point agent or session does, at most once per session; a declined proposal is not repeated). Confirm Module/Feature, slice name and type, the behaviour in one sentence, whether a UI surface is needed. For new behaviour, unclear event names/stream boundaries or multi-slice flows, run **cratis-chronicle-event-modeling**. Confirm the domain requirements as before; the agreed outline (fields, events, rules, scenarios) is the contract, recorded where the team tracks work, if anywhere.
|
|
48
48
|
|
|
49
49
|
Load **cratis-application-slice-conformance** and keep its inventory open through every later phase. **Gate:** you can name the contract and its specification list.
|
|
50
50
|
|
|
@@ -36,7 +36,7 @@ Select from these canonical rules in `.cratis/ai/rules/` only after applying the
|
|
|
36
36
|
## Inputs you expect
|
|
37
37
|
|
|
38
38
|
- Feature name, slice name, and slice type (specs are **mandatory for every slice type**)
|
|
39
|
-
- The slice's contract and its specification list: the `.play` slice's specifications, or the agreed outline. Before accepting an outline, apply Phase 0 of `application-profile.md` (an accepted model under the model root covers the scope, or the repository is opted in,
|
|
39
|
+
- The slice's contract and its specification list: the `.play` slice's specifications, or the agreed outline. Before accepting an outline, apply Phase 0 of `application-profile.md` (an accepted model under the model root covers the scope, or the repository is opted in, per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`: the contract is the `.play` slice's specifications; if the model lacks the behaviour, request it be added; check skill availability separately). Without opt-in, an agreed outline is the contract and code-first work is preserved. Existing code is not the contract.
|
|
40
40
|
- The complete slice file (`<Slice>.cs`) so you understand what behaviors to specify
|
|
41
41
|
- Any business rules or constraints that must be validated
|
|
42
42
|
- The namespace root (read from existing source files)
|
|
@@ -69,7 +69,7 @@ Tagged **[contract]** (framework-enforced) or **[convention]** (house default).
|
|
|
69
69
|
|
|
70
70
|
- **Starting a brand-new application:** scaffold it instead of hand-writing the skeleton: `dotnet new install Cratis.Templates`, then `dotnet new cratis -n MyApp -o MyApp` (`--language Kotlin|Java`, `--Database MongoDB|PostgreSQL|MsSql|SQLite`; `cratis-aspire` for Aspire; `cratis-chronicle-console` or `cratis-chronicle-web` for a Chronicle client only). Non-interactive runs need `--allow-scripts yes`; the .NET templates target `net10.0`. The template writes `.cratis/ai.json`; run `cratis ai update` afterwards. Its `SomeModule/SomeFeature/Registration/` slice is the house shape. There is no Go, Python or Elixir template (verified at Cratis.Templates `v1.7.4`).
|
|
71
71
|
- **Phase 0 — Find the contract / choose the level.** Before writing slice code, find what the code must match, and choose the level once for the whole scope.
|
|
72
|
-
1. **Look for a Screenplay model** under the model root (
|
|
72
|
+
1. **Look for a Screenplay model** under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts) for the slice, command, event and read-model names.
|
|
73
73
|
2. **Model level** — an accepted model under the root covers the scope, or the repository is opted in and this scope has no model yet. The `.play` slice and its specs are the contract: change the model first (new behavior starts in discovery), verify it (V1–V3), get an independent review, then render with Stage or gap-fill by hand only what the renderer rejects. Hand-written code stays checked against the model (**cratis-application-slice-conformance**). Never edit Stage-managed output, never implement behavior the model does not state, never change the model to match existing code, never weaken protection to make it compile or render. Start with **cratis-screenplay-event-modeling** (decision rule), then **cratis-screenplay-modeling-lifecycle**. If the Screenplay skills are not installed, say so; do not author `.play` from memory.
|
|
74
74
|
3. **Code level** — infrastructure (hosting, DI composition, identity wiring, CI, deployment), clients, Screenplay code attachments and handlers, adapters in the render's customization area, and scope Stage cannot render yet (the model remains the contract). Framework repositories and brownfield work that is not opted in also stay code-first. Only the entry-point session may propose a model, at most once per session and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again. Confirm Module/Feature, slice name, slice type and domain requirements as before; for new behavior or unclear event vocabulary run **cratis-chronicle-event-modeling** first, and record the agreed outline (fields, events, rules, scenarios) where the team tracks work, if anywhere. If you write code first where a model exists, say the model now lags.
|
|
75
75
|
4. **Trivial changes** keep the proportional-delegation policy; Phases 1–3 below apply to code you write at either level.
|
|
@@ -35,6 +35,8 @@ One precise line per load-bearing term, so the same word means the same thing ev
|
|
|
35
35
|
- **Command** — a `[Command]` record expressing an imperative **intent**; its public `Handle()` produces event(s) (or a response).
|
|
36
36
|
- **Provide()** — the command method that fetches/computes data after validation/authorization and before `Handle()`; may short-circuit with a `ValidationResult`.
|
|
37
37
|
- **Causation chain** — the ordered links saying how an append came about (root process → command → …), each carrying properties. A command records its **name and its property values** there, so an event says what the command was asked to do; the chain lives in the event log and is as permanent as the events.
|
|
38
|
+
- **Observation command** — a command whose input comes from outside the model's own decisions (webhook, poll, sweep, retry, classifier). It compares with current state and appends nothing when nothing changed; looking is not a fact.
|
|
39
|
+
- **Signal event** — an event appended only to make a reactor do something (`…Requested`, `…Started`, `…Skipped`). Not a domain fact; use a job, state machine, command operation or `ICommandPipeline`.
|
|
38
40
|
- **Constraint** — `IConstraint`; an **append-time** invariant (uniqueness / concurrency) enforced at the event-store level.
|
|
39
41
|
- **DCB (Dynamic Consistency Boundary)** — enforcing a state-dependent rule under concurrency over explicitly enrolled event-state reads: stream decisions/exact scopes or protected, admitted projection decision reads. Plain injected models and `Result<TEvent, ValidationResult>` alone are advisory, not a guard.
|
|
40
42
|
- **Consistency boundary** — the scope within which an invariant holds atomically (an event source, a routed stream, or the event state enrolled by an admitted protected decision read).
|
|
@@ -227,11 +227,7 @@ The MCP catalog has no install-hints field and does not install the executable.
|
|
|
227
227
|
|
|
228
228
|
### Event modeling with Screenplay
|
|
229
229
|
|
|
230
|
-
**Model first.**
|
|
231
|
-
`.play` files live: normally under `Source/` or `src/`, else `Screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set
|
|
232
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an
|
|
233
|
-
installed profile or skill, a `.play` file outside the root or an untracked or uncommitted draft is not
|
|
234
|
-
opt-in. An accepted model under the root covering the scope is the contract and the source
|
|
230
|
+
**Model first.** Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. An accepted model under the root covering the scope is the contract and the source
|
|
235
231
|
of truth for behavior. Change the model, verify and independently review it, then render
|
|
236
232
|
or gap-fill from its contract; never edit Stage-managed output or weaken protection.
|
|
237
233
|
Otherwise stay code-first; only the entry-point session may propose a model, at most once
|
|
@@ -10,7 +10,7 @@ profile: application
|
|
|
10
10
|
|
|
11
11
|
Reactors are the "if this then that" of event sourcing — they observe events and produce side effects. Unlike projections (which build state), reactors *do things*: send emails, trigger commands in other slices, call external APIs.
|
|
12
12
|
|
|
13
|
-
**Model first:** when an accepted model under the model root covers this scope (or the repository is opted in
|
|
13
|
+
**Model first:** when an accepted model under the model root covers this scope (or the repository is opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`), a reactor implements an automation that the model owns (`produces` / `invokes`); read the modeled slice first and keep the reactor to what the model leaves to code (gap-fill). Otherwise (not opted in) stay code-first: this file and the **cratis-chronicle-reactor** skill are the guide, and the entry-point session may propose a model at most once per session. See `cratis-screenplay-modeling-lifecycle`'s `scripts/model-first-status.mjs` for the decision, root and drafts.
|
|
14
14
|
|
|
15
15
|
## IReactor — Marker Interface
|
|
16
16
|
|
|
@@ -226,7 +226,8 @@ findings). Each reactor class should have a focused purpose. Multiple handler me
|
|
|
226
226
|
5. **Failure behavior** — If a reactor throws, *or* a returned side-effect event fails to append (constraint violation, concurrency violation, or error), the failing event-source partition pauses until the issue is resolved. Repeated failures can **quarantine** the observer: once `QuarantineOnFailedPartitionCount`/`QuarantineOnFailedPartitionPercentage` (under `Observers`) is crossed, the observer enters the `Quarantined` state — reminders cancelled, retries stopped, automatic recovery suppressed. **A quarantine ends when an operator clears it (`ClearObserverQuarantine()`), or when the observer is subscribed again** — for an application observer that is when the client connects again, for example after a redeploy; Kernel-owned observers are subscribed again when the Kernel starts. A periodic watchdog (default 60s, `WatchdogInterval`) re-routes stuck/dead observers but does not rescue quarantined ones. Design for resilience.
|
|
227
227
|
6. **Don't throw to validate malformed inbound events** — reactors are not data-quality validators; invalid payloads must be rejected at the command/append site. When a malformed cross-service fact reaches a consumer, throwing just to reject it pauses the partition and can quarantine the whole observer. Instead append a clear failure/dead-letter event (e.g. `ProvisioningFailed`) or surface it via the operational failure path, and skip partial side effects.
|
|
228
228
|
7. **No state** — Reactors should be stateless. Inject dependencies via primary constructor, but do not store mutable state on the class.
|
|
229
|
-
8. **
|
|
229
|
+
8. **A new side-effect reactor must not act on history.** A reactor that is new in a release (or has a new id) catches up from the start of the event log when it first registers, and `[OnceOnly]` does not cover that first catch-up because it is not a replay. If its handlers cause side effects (jobs, AI calls, external calls, notifications), start the observer at the tail on first registration or make the handler ignore facts that predate its registration, and specify that history causes nothing.
|
|
230
|
+
9. **An unattended, irreversible pass reads the log, not the sink — and carries a fuse.** A reactor that deletes, revokes, bills or notifies *because a read model says something is absent* is trusting a materialized sink that is only as current as its observer: a paused partition, a replay in progress or a lagging projection makes "absent" true of the sink and false of the world. Decide from a **`[Passive]`** read model (computed on demand from the events at the moment the reactor runs) or from the events themselves. And the code shape cannot tell an **empty subject set** ("nothing to consider" — fail-safe) from an **empty qualifying set** ("nothing survived the filter" — fail-destructive: every subject is about to be acted on), so an unattended pass states its expected population, refuses when the count is implausible, and caps how many subjects one run may touch — the same discipline as [guards-and-fuses.md](./guards-and-fuses.instructions.md), applied to a reactor. A sweep that decides from a read model also refuses while that model's observer is replaying or behind, because a rebuilding model reads as "nothing was ever processed"; specify the replaying case.
|
|
230
231
|
|
|
231
232
|
## Failure transitions **[convention]**
|
|
232
233
|
|
|
@@ -15,7 +15,7 @@ A vertical slice owns a single behavior: the command or query, the events it pro
|
|
|
15
15
|
|
|
16
16
|
This file is the reference for *what* goes in each part of a slice. Layout, slice types, workflow, and quality gates are in [general.md](../../../rules/general.md).
|
|
17
17
|
|
|
18
|
-
**Model-first check.** Before changing a slice, look for it in the accepted `.play` model
|
|
18
|
+
**Model-first check.** Before changing a slice, look for it in the accepted `.play` model under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts). If an accepted model covers it, change the model and render or gap-fill from it; never edit Stage-managed files. See Phase 0 in [application-profile.md](./application-profile.instructions.md).
|
|
19
19
|
|
|
20
20
|
## Technical stack
|
|
21
21
|
|
|
@@ -320,6 +320,18 @@ evaluate reconstruction frequency, history length, consistency, and security.
|
|
|
320
320
|
|
|
321
321
|
**Injected-parameter nullability is the required/optional switch:** a nullable `TReadModel?` parameter (on a validator, `Provide()`, or `Handle()`) gets `null` injected for a never-created/removed instance — check `is null`. A **non-nullable** `TReadModel` whose instance does not exist is **rejected, not crashed**: Arc raises `ReadModelDoesNotExistForCommand`, which surfaces as a validation failure (HTTP 400) with reason `DependencyUnavailable` (non-nullable = "required, must exist"). The server-fault path (`CannotResolveCommandDependency` / `CannotResolveValidatorDependency`, HTTP 500) is reached only when the dependency is *not* a registered read model or no usable key was resolved — the exact contract is in the **cratis-arc-command** skill's `read-model-injection` reference. ⚠️ Both switches ride on the same resolution, so on a **`[Passive]` projection** neither fires for a never-created instance: the nullable parameter receives a default-valued object and the `is null` guard never runs, and the non-nullable one resolves happily. Check the existence flag there, not nullability. Type by-id accessors you write yourself as `Task<T?>` so callers get the compiler signal Chronicle's own signature withholds.
|
|
322
322
|
|
|
323
|
+
### Observation commands append only changes **[convention]**
|
|
324
|
+
|
|
325
|
+
A command fed by a webhook, poll, sweep, retry or classifier is an *observation*, and looking is not a fact.
|
|
326
|
+
|
|
327
|
+
- Compare with current state and append **nothing** when nothing changed; `Handle()` takes the thing it would change and compares each fact on its own.
|
|
328
|
+
- Compare against something that cannot lag: a `[Passive]` read model read by key, or the stream's own events, never a materialized read model (it trails the log and is bypassed exactly while rebuilding).
|
|
329
|
+
- Never append a tick, a heartbeat, a trigger event for a reactor, a "last looked" timestamp, telemetry or a non-answer ("pending", "could not decide"); use a job, state machine, command operation or `ICommandPipeline`.
|
|
330
|
+
- An event named `…Changed` records a real change; split a broad `…DetailsChanged` into per-fact events.
|
|
331
|
+
- Specify two behaviors per observation command: the same observation twice appends nothing, and a changed observation appends exactly the change.
|
|
332
|
+
|
|
333
|
+
See the **cratis-chronicle-event-modeling** skill (`references/event-log-hygiene.md`).
|
|
334
|
+
|
|
323
335
|
## Projections **[contract]**
|
|
324
336
|
|
|
325
337
|
Projections build read models from **events** (never from other read models). Use the ladder — for adding one to an existing model, invoke the **cratis-chronicle-projection** skill:
|
|
@@ -335,6 +347,7 @@ For self models, keep `[ReadModel]`, static `Reduce` methods and queries on one
|
|
|
335
347
|
- ⚠️ **AutoMap runs per *event* across every event the projection references — it does not defer to your explicit setters.** A property sourced with `[SetFrom<A>]` can still be silently overwritten when some *other* referenced event `B` happens to carry an identically named property (AutoMap wires `B`'s value on top). Fence the property with property-level **`[NoAutoMap]`** (which pairs with the `[SetFrom]`, not replaces it) so only your explicit setter writes it. `[SetFrom]` does **not** imply this — leaving AutoMap on is what allows the common create-then-rename pattern (a later event updating a property by name-match). No colliding event property name means no `[NoAutoMap]` needed. (An event subscribed only via an aggregate like `[Count]` doesn't auto-map its other properties, so it can't collide.) The analyzer **`CHR0025`** surfaces this collision as an *informational* heads-up (not a warning, because either resolution — add `[NoAutoMap]`, or accept the update — can be correct).
|
|
336
348
|
- **[contract] `[Nested]`** projects a single nullable child object; place `[FromEvent<T>]` on the nested type (or property-level `[SetFrom<T>]` when the parent shares the event — declaring class-level `[FromEvent<T>]` on both parent and nested type for the same event is a duplicate-registration startup crash).
|
|
337
349
|
- **[contract] Event-sequence source attributes:** class-level `[EventSequence("name")]`, `[EventLog]`, or `[EventStore("name")]` select where the projection reads from (a named sequence, the explicit default log, or another Chronicle event store / inbox). ⚠️ `[FromEventSequence]` is **removed** — use `[EventSequence("name")]`.
|
|
350
|
+
- **[convention] Counters and aggregates (`[Increment]`, `[Decrement]`, `[Count]`) need clean lifecycle transitions.** They see the event, not the item's previous state, so a close for an already closed item drifts the counter permanently and replay reproduces it. The command that appends the lifecycle event refuses a non-transition and appends nothing; fold the log per event source with the proposed mapping and compare it with the state it summarizes before shipping.
|
|
338
351
|
|
|
339
352
|
## Constraints **[contract]**
|
|
340
353
|
|
|
@@ -9,7 +9,7 @@ Add a reactor that observes events and produces side effects. Invoke the **crati
|
|
|
9
9
|
|
|
10
10
|
## Confirm first
|
|
11
11
|
|
|
12
|
-
- **Model first:** if an accepted model under the model root covers this scope, or the repository is opted in (
|
|
12
|
+
- **Model first:** if an accepted model under the model root covers this scope, or the repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`), the automation belongs in the model (`produces` / `invokes`); check there before writing code and follow the model-first routing in `.cratis/ai/rules/general.md`. Reactor code is then gap-fill against the modeled contract. If not opted in, stay code-first.
|
|
13
13
|
- **Events to react to**, the **side effect**, and the slice type: `Automation` (our own event causes an external side effect, a follow-up event, or a follow-up command) or `Translation` (data from an outside system recorded as our own facts).
|
|
14
14
|
- **Contract details to settle:** where each output field comes from (the trigger event, an injected read model, or a stated mapping), every condition that skips an event, and what must not happen twice.
|
|
15
15
|
|
|
@@ -12,7 +12,7 @@ Implement a complete **vertical slice** end-to-end. Follow the Implementation Wo
|
|
|
12
12
|
Before any slice code, find what the code must match. Decide the route once:
|
|
13
13
|
|
|
14
14
|
1. **The slice is in an accepted Screenplay model** (search the model root for the slice, command, event and read-model names; the project's `**/*.play`, or the configured root). The `.play` slice and its specifications are the contract. Change behavior in the model first (the `cratis-screenplay-*` skills), then render it (`cratis-stage-rendering-and-sandbox`). Hand-write C# only for scope the renderer rejects, or for adapters, infrastructure and clients; the model stays the oracle for that code (`cratis-application-slice-conformance`). Never hand-edit rendered, managed output, and never change the model to match existing code.
|
|
15
|
-
2. **The repository is opted in, but the slice is not modeled** (
|
|
15
|
+
2. **The repository is opted in, but the slice is not modeled** (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts): model it first, then continue with route 1. Write code first only when the user chooses to, or the behavior cannot be expressed in `.play`; say then that the model lags the code.
|
|
16
16
|
3. **No accepted model covers this scope and the repository is not opted in:** stay code-first and never force a model. Only the entry-point session may propose one, at most once per session, never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work, and not again if declined. Framework, brownfield, infrastructure, client and adapter work keep their code-first path. For new behavior or unclear event vocabulary, run **cratis-chronicle-event-modeling** first; the agreed outline (fields, events, rules, scenarios) is the contract, recorded where the team tracks work, if anywhere.
|
|
17
17
|
|
|
18
18
|
Whether the Screenplay skills are installed is a separate question from consent: if the route needs them and they are missing, say so and ask; do not author `.play` from memory.
|
|
@@ -13,7 +13,7 @@ The slice file (`.cs`) **and its contract**: the `.play` slice with its specific
|
|
|
13
13
|
|
|
14
14
|
If no contract can be found, decide once:
|
|
15
15
|
|
|
16
|
-
- **An accepted model under the model root covers the scope, or the repository is opted in** (
|
|
16
|
+
- **An accepted model under the model root covers the scope, or the repository is opted in** (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts): do not write code-derived specs in its place. Route to the `cratis-screenplay-*` skills (`cratis-screenplay-specifications`, `cratis-screenplay-scenario-coverage`) to add the slice's specifications to the model first. If those skills are not installed, say so and stop; do not author `.play` from memory.
|
|
17
17
|
- **No model coverage and no opt-in:** stay code-first. Write from the code, report every case as a proposal rather than as agreed behavior. A model is proposed only by the entry-point session, at most once per session, and not for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work.
|
|
18
18
|
|
|
19
19
|
## Coverage (every slice type)
|
|
@@ -68,7 +68,7 @@ Tagged **[contract]** (framework-enforced) or **[convention]** (house default).
|
|
|
68
68
|
|
|
69
69
|
- **Starting a brand-new application:** scaffold it instead of hand-writing the skeleton: `dotnet new install Cratis.Templates`, then `dotnet new cratis -n MyApp -o MyApp` (`--language Kotlin|Java`, `--Database MongoDB|PostgreSQL|MsSql|SQLite`; `cratis-aspire` for Aspire; `cratis-chronicle-console` or `cratis-chronicle-web` for a Chronicle client only). Non-interactive runs need `--allow-scripts yes`; the .NET templates target `net10.0`. The template writes `.cratis/ai.json`; run `cratis ai update` afterwards. Its `SomeModule/SomeFeature/Registration/` slice is the house shape. There is no Go, Python or Elixir template (verified at Cratis.Templates `v1.7.4`).
|
|
70
70
|
- **Phase 0 — Find the contract / choose the level.** Before writing slice code, find what the code must match, and choose the level once for the whole scope.
|
|
71
|
-
1. **Look for a Screenplay model** under the model root (
|
|
71
|
+
1. **Look for a Screenplay model** under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts) for the slice, command, event and read-model names.
|
|
72
72
|
2. **Model level** — an accepted model under the root covers the scope, or the repository is opted in and this scope has no model yet. The `.play` slice and its specs are the contract: change the model first (new behavior starts in discovery), verify it (V1–V3), get an independent review, then render with Stage or gap-fill by hand only what the renderer rejects. Hand-written code stays checked against the model (**cratis-application-slice-conformance**). Never edit Stage-managed output, never implement behavior the model does not state, never change the model to match existing code, never weaken protection to make it compile or render. Start with **cratis-screenplay-event-modeling** (decision rule), then **cratis-screenplay-modeling-lifecycle**. If the Screenplay skills are not installed, say so; do not author `.play` from memory.
|
|
73
73
|
3. **Code level** — infrastructure (hosting, DI composition, identity wiring, CI, deployment), clients, Screenplay code attachments and handlers, adapters in the render's customization area, and scope Stage cannot render yet (the model remains the contract). Framework repositories and brownfield work that is not opted in also stay code-first. Only the entry-point session may propose a model, at most once per session and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again. Confirm Module/Feature, slice name, slice type and domain requirements as before; for new behavior or unclear event vocabulary run **cratis-chronicle-event-modeling** first, and record the agreed outline (fields, events, rules, scenarios) where the team tracks work, if anywhere. If you write code first where a model exists, say the model now lags.
|
|
74
74
|
4. **Trivial changes** keep the proportional-delegation policy; Phases 1–3 below apply to code you write at either level.
|
|
@@ -34,6 +34,8 @@ One precise line per load-bearing term, so the same word means the same thing ev
|
|
|
34
34
|
- **Command** — a `[Command]` record expressing an imperative **intent**; its public `Handle()` produces event(s) (or a response).
|
|
35
35
|
- **Provide()** — the command method that fetches/computes data after validation/authorization and before `Handle()`; may short-circuit with a `ValidationResult`.
|
|
36
36
|
- **Causation chain** — the ordered links saying how an append came about (root process → command → …), each carrying properties. A command records its **name and its property values** there, so an event says what the command was asked to do; the chain lives in the event log and is as permanent as the events.
|
|
37
|
+
- **Observation command** — a command whose input comes from outside the model's own decisions (webhook, poll, sweep, retry, classifier). It compares with current state and appends nothing when nothing changed; looking is not a fact.
|
|
38
|
+
- **Signal event** — an event appended only to make a reactor do something (`…Requested`, `…Started`, `…Skipped`). Not a domain fact; use a job, state machine, command operation or `ICommandPipeline`.
|
|
37
39
|
- **Constraint** — `IConstraint`; an **append-time** invariant (uniqueness / concurrency) enforced at the event-store level.
|
|
38
40
|
- **DCB (Dynamic Consistency Boundary)** — enforcing a state-dependent rule under concurrency over explicitly enrolled event-state reads: stream decisions/exact scopes or protected, admitted projection decision reads. Plain injected models and `Result<TEvent, ValidationResult>` alone are advisory, not a guard.
|
|
39
41
|
- **Consistency boundary** — the scope within which an invariant holds atomically (an event source, a routed stream, or the event state enrolled by an admitted protected decision read).
|
|
@@ -226,11 +226,7 @@ The MCP catalog has no install-hints field and does not install the executable.
|
|
|
226
226
|
|
|
227
227
|
### Event modeling with Screenplay
|
|
228
228
|
|
|
229
|
-
**Model first.**
|
|
230
|
-
`.play` files live: normally under `Source/` or `src/`, else `Screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set
|
|
231
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an
|
|
232
|
-
installed profile or skill, a `.play` file outside the root or an untracked or uncommitted draft is not
|
|
233
|
-
opt-in. An accepted model under the root covering the scope is the contract and the source
|
|
229
|
+
**Model first.** Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. An accepted model under the root covering the scope is the contract and the source
|
|
234
230
|
of truth for behavior. Change the model, verify and independently review it, then render
|
|
235
231
|
or gap-fill from its contract; never edit Stage-managed output or weaken protection.
|
|
236
232
|
Otherwise stay code-first; only the entry-point session may propose a model, at most once
|
|
@@ -9,7 +9,7 @@ profile: application
|
|
|
9
9
|
|
|
10
10
|
Reactors are the "if this then that" of event sourcing — they observe events and produce side effects. Unlike projections (which build state), reactors *do things*: send emails, trigger commands in other slices, call external APIs.
|
|
11
11
|
|
|
12
|
-
**Model first:** when an accepted model under the model root covers this scope (or the repository is opted in
|
|
12
|
+
**Model first:** when an accepted model under the model root covers this scope (or the repository is opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`), a reactor implements an automation that the model owns (`produces` / `invokes`); read the modeled slice first and keep the reactor to what the model leaves to code (gap-fill). Otherwise (not opted in) stay code-first: this file and the **cratis-chronicle-reactor** skill are the guide, and the entry-point session may propose a model at most once per session. See `cratis-screenplay-modeling-lifecycle`'s `scripts/model-first-status.mjs` for the decision, root and drafts.
|
|
13
13
|
|
|
14
14
|
## IReactor — Marker Interface
|
|
15
15
|
|
|
@@ -225,7 +225,8 @@ findings). Each reactor class should have a focused purpose. Multiple handler me
|
|
|
225
225
|
5. **Failure behavior** — If a reactor throws, *or* a returned side-effect event fails to append (constraint violation, concurrency violation, or error), the failing event-source partition pauses until the issue is resolved. Repeated failures can **quarantine** the observer: once `QuarantineOnFailedPartitionCount`/`QuarantineOnFailedPartitionPercentage` (under `Observers`) is crossed, the observer enters the `Quarantined` state — reminders cancelled, retries stopped, automatic recovery suppressed. **A quarantine ends when an operator clears it (`ClearObserverQuarantine()`), or when the observer is subscribed again** — for an application observer that is when the client connects again, for example after a redeploy; Kernel-owned observers are subscribed again when the Kernel starts. A periodic watchdog (default 60s, `WatchdogInterval`) re-routes stuck/dead observers but does not rescue quarantined ones. Design for resilience.
|
|
226
226
|
6. **Don't throw to validate malformed inbound events** — reactors are not data-quality validators; invalid payloads must be rejected at the command/append site. When a malformed cross-service fact reaches a consumer, throwing just to reject it pauses the partition and can quarantine the whole observer. Instead append a clear failure/dead-letter event (e.g. `ProvisioningFailed`) or surface it via the operational failure path, and skip partial side effects.
|
|
227
227
|
7. **No state** — Reactors should be stateless. Inject dependencies via primary constructor, but do not store mutable state on the class.
|
|
228
|
-
8. **
|
|
228
|
+
8. **A new side-effect reactor must not act on history.** A reactor that is new in a release (or has a new id) catches up from the start of the event log when it first registers, and `[OnceOnly]` does not cover that first catch-up because it is not a replay. If its handlers cause side effects (jobs, AI calls, external calls, notifications), start the observer at the tail on first registration or make the handler ignore facts that predate its registration, and specify that history causes nothing.
|
|
229
|
+
9. **An unattended, irreversible pass reads the log, not the sink — and carries a fuse.** A reactor that deletes, revokes, bills or notifies *because a read model says something is absent* is trusting a materialized sink that is only as current as its observer: a paused partition, a replay in progress or a lagging projection makes "absent" true of the sink and false of the world. Decide from a **`[Passive]`** read model (computed on demand from the events at the moment the reactor runs) or from the events themselves. And the code shape cannot tell an **empty subject set** ("nothing to consider" — fail-safe) from an **empty qualifying set** ("nothing survived the filter" — fail-destructive: every subject is about to be acted on), so an unattended pass states its expected population, refuses when the count is implausible, and caps how many subjects one run may touch — the same discipline as [guards-and-fuses.md](./guards-and-fuses.md), applied to a reactor. A sweep that decides from a read model also refuses while that model's observer is replaying or behind, because a rebuilding model reads as "nothing was ever processed"; specify the replaying case.
|
|
229
230
|
|
|
230
231
|
## Failure transitions **[convention]**
|
|
231
232
|
|
|
@@ -14,7 +14,7 @@ A vertical slice owns a single behavior: the command or query, the events it pro
|
|
|
14
14
|
|
|
15
15
|
This file is the reference for *what* goes in each part of a slice. Layout, slice types, workflow, and quality gates are in [general.md](./general.md).
|
|
16
16
|
|
|
17
|
-
**Model-first check.** Before changing a slice, look for it in the accepted `.play` model
|
|
17
|
+
**Model-first check.** Before changing a slice, look for it in the accepted `.play` model under the model root (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, root and drafts). If an accepted model covers it, change the model and render or gap-fill from it; never edit Stage-managed files. See Phase 0 in [application-profile.md](./application-profile.md).
|
|
18
18
|
|
|
19
19
|
## Technical stack
|
|
20
20
|
|
|
@@ -319,6 +319,18 @@ evaluate reconstruction frequency, history length, consistency, and security.
|
|
|
319
319
|
|
|
320
320
|
**Injected-parameter nullability is the required/optional switch:** a nullable `TReadModel?` parameter (on a validator, `Provide()`, or `Handle()`) gets `null` injected for a never-created/removed instance — check `is null`. A **non-nullable** `TReadModel` whose instance does not exist is **rejected, not crashed**: Arc raises `ReadModelDoesNotExistForCommand`, which surfaces as a validation failure (HTTP 400) with reason `DependencyUnavailable` (non-nullable = "required, must exist"). The server-fault path (`CannotResolveCommandDependency` / `CannotResolveValidatorDependency`, HTTP 500) is reached only when the dependency is *not* a registered read model or no usable key was resolved — the exact contract is in the **cratis-arc-command** skill's `read-model-injection` reference. ⚠️ Both switches ride on the same resolution, so on a **`[Passive]` projection** neither fires for a never-created instance: the nullable parameter receives a default-valued object and the `is null` guard never runs, and the non-nullable one resolves happily. Check the existence flag there, not nullability. Type by-id accessors you write yourself as `Task<T?>` so callers get the compiler signal Chronicle's own signature withholds.
|
|
321
321
|
|
|
322
|
+
### Observation commands append only changes **[convention]**
|
|
323
|
+
|
|
324
|
+
A command fed by a webhook, poll, sweep, retry or classifier is an *observation*, and looking is not a fact.
|
|
325
|
+
|
|
326
|
+
- Compare with current state and append **nothing** when nothing changed; `Handle()` takes the thing it would change and compares each fact on its own.
|
|
327
|
+
- Compare against something that cannot lag: a `[Passive]` read model read by key, or the stream's own events, never a materialized read model (it trails the log and is bypassed exactly while rebuilding).
|
|
328
|
+
- Never append a tick, a heartbeat, a trigger event for a reactor, a "last looked" timestamp, telemetry or a non-answer ("pending", "could not decide"); use a job, state machine, command operation or `ICommandPipeline`.
|
|
329
|
+
- An event named `…Changed` records a real change; split a broad `…DetailsChanged` into per-fact events.
|
|
330
|
+
- Specify two behaviors per observation command: the same observation twice appends nothing, and a changed observation appends exactly the change.
|
|
331
|
+
|
|
332
|
+
See the **cratis-chronicle-event-modeling** skill (`references/event-log-hygiene.md`).
|
|
333
|
+
|
|
322
334
|
## Projections **[contract]**
|
|
323
335
|
|
|
324
336
|
Projections build read models from **events** (never from other read models). Use the ladder — for adding one to an existing model, invoke the **cratis-chronicle-projection** skill:
|
|
@@ -334,6 +346,7 @@ For self models, keep `[ReadModel]`, static `Reduce` methods and queries on one
|
|
|
334
346
|
- ⚠️ **AutoMap runs per *event* across every event the projection references — it does not defer to your explicit setters.** A property sourced with `[SetFrom<A>]` can still be silently overwritten when some *other* referenced event `B` happens to carry an identically named property (AutoMap wires `B`'s value on top). Fence the property with property-level **`[NoAutoMap]`** (which pairs with the `[SetFrom]`, not replaces it) so only your explicit setter writes it. `[SetFrom]` does **not** imply this — leaving AutoMap on is what allows the common create-then-rename pattern (a later event updating a property by name-match). No colliding event property name means no `[NoAutoMap]` needed. (An event subscribed only via an aggregate like `[Count]` doesn't auto-map its other properties, so it can't collide.) The analyzer **`CHR0025`** surfaces this collision as an *informational* heads-up (not a warning, because either resolution — add `[NoAutoMap]`, or accept the update — can be correct).
|
|
335
347
|
- **[contract] `[Nested]`** projects a single nullable child object; place `[FromEvent<T>]` on the nested type (or property-level `[SetFrom<T>]` when the parent shares the event — declaring class-level `[FromEvent<T>]` on both parent and nested type for the same event is a duplicate-registration startup crash).
|
|
336
348
|
- **[contract] Event-sequence source attributes:** class-level `[EventSequence("name")]`, `[EventLog]`, or `[EventStore("name")]` select where the projection reads from (a named sequence, the explicit default log, or another Chronicle event store / inbox). ⚠️ `[FromEventSequence]` is **removed** — use `[EventSequence("name")]`.
|
|
349
|
+
- **[convention] Counters and aggregates (`[Increment]`, `[Decrement]`, `[Count]`) need clean lifecycle transitions.** They see the event, not the item's previous state, so a close for an already closed item drifts the counter permanently and replay reproduces it. The command that appends the lifecycle event refuses a non-transition and appends nothing; fold the log per event source with the proposed mapping and compare it with the state it summarizes before shipping.
|
|
337
350
|
|
|
338
351
|
## Constraints **[contract]**
|
|
339
352
|
|
|
@@ -183,10 +183,7 @@ them.
|
|
|
183
183
|
## Route near misses
|
|
184
184
|
|
|
185
185
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
186
|
-
repository is opted in (
|
|
187
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
188
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
189
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
186
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
190
187
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
191
188
|
say so and do not author `.play` from memory.
|
|
192
189
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -52,17 +52,13 @@ This skill is a method: it names no API of its own. When the Screenplay skills a
|
|
|
52
52
|
Find the contract before touching code; say which one you are using. These steps are enough on
|
|
53
53
|
their own when the Screenplay skills are not installed; the master decision rule, when they
|
|
54
54
|
are, is `cratis-screenplay-modeling-lifecycle` ("Decide the level first").
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts.
|
|
56
|
+
Staged or untracked `.play` files are drafts, not the contract; a `.play` outside the model root is not a contract.
|
|
57
|
+
For a committed model with working-tree edits, HEAD remains the contract until the change is committed.
|
|
58
|
+
1. An accepted `.play` model under the model root covers the slice (search
|
|
57
59
|
`**/*.play` for the slice, command, event and read-model names): the `.play` slice and its
|
|
58
|
-
specifications are the contract.
|
|
59
|
-
|
|
60
|
-
root are drafts, not contracts; a file outside the root is not a contract. A committed file
|
|
61
|
-
with uncommitted working-tree edits is a model change in progress: its HEAD version is the
|
|
62
|
-
contract until the change is committed.
|
|
63
|
-
2. The repository is opted in (the root holds a committed `.play` file, or the project
|
|
64
|
-
explicitly set that root, even if it is empty; an empty unconfigured directory, install
|
|
65
|
-
output, an installed skill or an uncommitted draft does not count) but this
|
|
60
|
+
specifications are the contract.
|
|
61
|
+
2. The repository is opted in but this
|
|
66
62
|
scope has no model yet: new behaviour starts in discovery and slice design
|
|
67
63
|
(`cratis-screenplay-discovery`, `cratis-screenplay-slice-design`); do not code first. If those
|
|
68
64
|
skills are not installed, say so and do not author `.play` from memory.
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
# Contract, precedence and conflicting evidence
|
|
2
2
|
|
|
3
3
|
## Which contract
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the root holds a committed `.play`
|
|
8
|
-
file or was explicitly set in `.cratis/ai.json` (even if empty). Staged or untracked files under
|
|
9
|
-
the root are drafts. A committed file with uncommitted working-tree edits is a model change
|
|
10
|
-
in progress; its HEAD version is the contract until the change is committed. An empty directory, install
|
|
11
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count. Otherwise stay code-first.
|
|
4
|
+
Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts. SKILL.md step 1 suffices when the Screenplay skills are not installed.
|
|
5
|
+
Staged or untracked `.play` files are drafts, not the contract; a `.play` outside the model root is not a contract.
|
|
6
|
+
For a committed model with working-tree edits, HEAD remains the contract until the change is committed.
|
|
12
7
|
|
|
13
8
|
| Situation | Contract | Code's role |
|
|
14
9
|
| --- | --- | --- |
|
|
@@ -53,9 +53,7 @@ repository before claiming support for another version.
|
|
|
53
53
|
the contract for this skill). Decide this with the decision rule in
|
|
54
54
|
`cratis-screenplay-modeling-lifecycle`: model-first only when an accepted
|
|
55
55
|
model under the model root covers this scope, or the repository is opted in
|
|
56
|
-
(
|
|
57
|
-
in `.cratis/ai.json`); an empty directory, install output, a `.play` file
|
|
58
|
-
outside the root or an uncommitted draft does not count, and framework, infrastructure, client, adapter and not-opted-in
|
|
56
|
+
(opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`); framework, infrastructure, client, adapter and not-opted-in
|
|
59
57
|
brownfield work stays code-first. Opted in but no model for this scope: model
|
|
60
58
|
it first (`cratis-screenplay-discovery`, then `cratis-screenplay-slice-design`)
|
|
61
59
|
before writing specifications. If those Screenplay skills are not installed,
|
|
@@ -12,10 +12,7 @@ whatever `Handle()` returns into events, server-executed operations, a response,
|
|
|
12
12
|
or a combination.
|
|
13
13
|
|
|
14
14
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
15
|
-
repository is opted in (
|
|
16
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
17
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
18
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
15
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
19
16
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
20
17
|
say so and do not author `.play` from memory.
|
|
21
18
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -234,10 +234,7 @@ Recovery can redeliver the trigger even with `[OnceOnly]`, and a command whose o
|
|
|
234
234
|
- Adding or changing a rule: the Arc command validation guidance.
|
|
235
235
|
- Designing what a reactor should observe: the Chronicle reactor guidance.
|
|
236
236
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
237
|
-
repository is opted in (
|
|
238
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
239
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
240
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
237
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
241
238
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
242
239
|
say so and do not author `.play` from memory.
|
|
243
240
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -47,10 +47,7 @@ another version.
|
|
|
47
47
|
- Writing the specification for the rejection: use
|
|
48
48
|
`cratis-application-slice-specifications`.
|
|
49
49
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
50
|
-
repository is opted in (
|
|
51
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
52
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
53
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
50
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
54
51
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
55
52
|
say so and do not author `.play` from memory.
|
|
56
53
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
@@ -204,10 +204,7 @@ apply. Do not construct or suggest credentials.
|
|
|
204
204
|
- Diagnosing a whole slice rather than one endpoint: the slice diagnostics
|
|
205
205
|
guidance.
|
|
206
206
|
- An accepted `.play` model under the model root covers the behavior, or the
|
|
207
|
-
repository is opted in (
|
|
208
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
209
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
210
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
207
|
+
repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
|
|
211
208
|
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
212
209
|
say so and do not author `.play` from memory.
|
|
213
210
|
Edit code here only for infrastructure, clients, adapters, Screenplay code
|