@cratis/pi 7.51.4 → 7.52.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +2 -1
  2. package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +15 -0
  3. package/package/corpus/product-sync.json +26 -20
  4. package/package/corpus/rules/glossary.md +2 -1
  5. package/package/corpus/rules/profiles.md +15 -0
  6. package/package/corpus/skills/cratis-application-slice-specifications/references/query-and-decision-scenarios.md +14 -3
  7. package/package/corpus/skills/cratis-arc-command/SKILL.md +4 -0
  8. package/package/corpus/skills/cratis-arc-command/references/decisions-and-routing.md +22 -3
  9. package/package/corpus/skills/cratis-arc-command/references/fresh-identifiers.md +52 -0
  10. package/package/corpus/skills/cratis-arc-command/references/generated-values.md +7 -7
  11. package/package/corpus/skills/cratis-arc-command/references/handler-shapes.md +9 -0
  12. package/package/corpus/skills/cratis-arc-command/references/proxy-generation.md +5 -0
  13. package/package/corpus/skills/cratis-arc-command/references/read-model-injection.md +11 -0
  14. package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +12 -1
  15. package/package/corpus/skills/cratis-arc-command-execution/references/command-refusals.md +65 -0
  16. package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +5 -0
  17. package/package/corpus/skills/cratis-arc-hosting/SKILL.md +1 -0
  18. package/package/corpus/skills/cratis-arc-observable-query-http/SKILL.md +6 -0
  19. package/package/corpus/skills/cratis-chronicle-client-dotnet/references/additional-surfaces.md +18 -0
  20. package/package/corpus/skills/cratis-chronicle-client-dotnet/references/discovery.md +33 -1
  21. package/package/corpus/skills/cratis-chronicle-client-dotnet/references/lifecycle.md +7 -1
  22. package/package/corpus/skills/cratis-chronicle-compliance/SKILL.md +5 -0
  23. package/package/corpus/skills/cratis-chronicle-decision-reads/SKILL.md +17 -0
  24. package/package/corpus/skills/cratis-chronicle-decision-reads/references/choosing-how-a-rule-holds.md +3 -3
  25. package/package/corpus/skills/cratis-chronicle-event-constraints/SKILL.md +4 -0
  26. package/package/corpus/skills/cratis-chronicle-event-constraints/references/storage-uniqueness.md +28 -0
  27. package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +5 -3
  28. package/package/corpus/skills/cratis-chronicle-event-specifications/SKILL.md +7 -0
  29. package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +18 -0
  30. package/package/corpus/skills/cratis-chronicle-event-type-migration/references/explicit-migrations.md +46 -0
  31. package/package/corpus/skills/cratis-chronicle-hosting/SKILL.md +8 -0
  32. package/package/corpus/skills/cratis-chronicle-hosting/references/operations.md +42 -0
  33. package/package/corpus/skills/cratis-chronicle-multi-tenancy/SKILL.md +1 -0
  34. package/package/corpus/skills/cratis-chronicle-projection/references/model-bound-attributes.md +6 -0
  35. package/package/corpus/skills/cratis-chronicle-projection/references/variants.md +7 -0
  36. package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +13 -7
  37. package/package/corpus/skills/cratis-chronicle-reactor/references/cross-service-events.md +9 -2
  38. package/package/corpus/skills/cratis-chronicle-reactor/references/return-event-metadata.md +7 -0
  39. package/package/corpus/skills/cratis-chronicle-reactor/references/slice-delivery-checklist.md +3 -3
  40. package/package/corpus/skills/cratis-chronicle-reactor/references/specifications.md +11 -5
  41. package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +8 -4
  42. package/package/corpus/skills/cratis-chronicle-read-model/references/collection-observation.md +49 -0
  43. package/package/corpus/skills/cratis-chronicle-read-model/references/queries.md +13 -2
  44. package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +8 -0
  45. package/package/corpus/skills/cratis-chronicle-web-workbench/SKILL.md +15 -0
  46. package/package/corpus/skills/cratis-multi-service-architecture/SKILL.md +204 -0
  47. package/package/corpus/skills/cratis-multi-service-architecture/references/publish-and-consume.md +229 -0
  48. package/package/corpus/skills/cratis-multi-service-local-orchestration/SKILL.md +172 -0
  49. package/package/corpus/skills/cratis-multi-service-local-orchestration/references/docker-compose.md +144 -0
  50. package/package/corpus/skills/cratis-screenplay-automations-and-translations/SKILL.md +4 -0
  51. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/automation-patterns.md +1 -1
  52. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/effects-and-idempotency.md +24 -5
  53. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/public-events-and-direction.md +1 -1
  54. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +11 -6
  55. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/invocation-identity.md +3 -1
  56. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/refusals-and-redelivery.md +97 -26
  57. package/package/corpus/skills/cratis-screenplay-command-surface/references/compliance.md +2 -1
  58. package/package/corpus/skills/cratis-screenplay-command-surface/references/generated-values-and-responses.md +45 -10
  59. package/package/corpus/skills/cratis-screenplay-command-surface/verification.json +3 -1
  60. package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +1 -0
  61. package/package/corpus/skills/cratis-screenplay-event-modeling/references/parsed-not-runnable.md +10 -6
  62. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/generate-notes.md +12 -1
  63. package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +5 -1
  64. package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +7 -3
  65. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-loop.md +28 -12
  66. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-tools.md +29 -6
  67. package/package/corpus/skills/cratis-screenplay-model-authoring/references/screen-authoring-workflow.md +15 -3
  68. package/package/corpus/skills/cratis-screenplay-model-authoring/verification.json +4 -1
  69. package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +1 -1
  70. package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +4 -0
  71. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +5 -1
  72. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/delivery-protocol.md +1 -1
  73. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/renderability-gate.md +1 -1
  74. package/package/corpus/skills/cratis-screenplay-scenario-coverage/SKILL.md +9 -1
  75. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md +12 -10
  76. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/spec-forms-by-mode.md +11 -6
  77. package/package/corpus/skills/cratis-screenplay-slice-design/references/field-lineage.md +1 -1
  78. package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +18 -10
  79. package/package/corpus/skills/cratis-screenplay-specifications/references/examples-and-routes.md +14 -13
  80. package/package/corpus/skills/cratis-screenplay-specifications/references/query-rejections.md +44 -0
  81. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/SKILL.md +2 -1
  82. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/multi-service-models.md +188 -0
  83. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/verification.json +1 -1
  84. package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +6 -1
  85. package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +12 -4
  86. package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +10 -6
  87. package/package/corpus/skills/cratis-screenplay-toolchain/references/renderable-subset.md +28 -9
  88. package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.json +4658 -230
  89. package/package/corpus/skills/cratis-screenplay-toolchain/references/screenplay-contract.version +1 -1
  90. package/package/corpus/skills/cratis-screenplay-toolchain/references/traps.md +1 -1
  91. package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +5 -0
  92. package/package/corpus/skills/cratis-specifications-csharp/references/application-scenarios.md +1 -1
  93. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +1 -1
  94. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/admission.md +63 -15
  95. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/sandbox-and-specrunner.md +2 -2
  96. package/package/profile-catalog.json +3 -1
  97. package/package.json +1 -1
@@ -0,0 +1,172 @@
1
+ ---
2
+ name: cratis-multi-service-local-orchestration
3
+ description: Run several Cratis services, one Chronicle kernel and their frontends together from one repository - layout with contracts projects, a .NET Aspire AppHost with Cratis.Chronicle.Aspire, the Docker Compose alternative with a MongoDB replica set, explicit per-service connection and event-store settings, health-gated startup, a cratis CLI context per store, and a frontend per service. Use when laying out a multi-service repository, writing an AppHost or compose file for several services, or when a service locally reaches the wrong kernel or store. Not for how services communicate (use cratis-multi-service-architecture) or production kernel hosting (use cratis-chronicle-hosting).
4
+ license: MIT
5
+ ---
6
+
7
+ <!-- Copyright (c) Cratis. All rights reserved. -->
8
+ <!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
9
+
10
+ # Run several Cratis services locally
11
+
12
+ Locally, a multi-service Cratis system is **one** Chronicle kernel hosting one
13
+ event store per service, one MongoDB replica set behind it, every service as its
14
+ own process with its own store name, and one frontend per service. Cross-store
15
+ forwarding only works inside one kernel, so never start a kernel per service.
16
+ `cratis-multi-service-architecture` owns why the services are split this way.
17
+
18
+ ## Lay out the repository
19
+
20
+ ```text
21
+ Shop/
22
+ ├── Shop.slnx
23
+ ├── AppHost/ # .NET Aspire AppHost (or docker-compose.yml at the root)
24
+ ├── Ordering/ # service: ASP.NET host, slices, Ordering.csproj
25
+ │ ├── Ordering.Contracts/ # public events only, references Cratis.Chronicle
26
+ │ ├── Screenplay/ # this service's model folder, when modeled
27
+ │ └── Web/ # this service's frontend
28
+ └── Billing/
29
+ ├── Screenplay/
30
+ └── Web/
31
+ ```
32
+
33
+ - One service per folder, each with its own project, `appsettings.json` naming its
34
+ own `Cratis:Chronicle:EventStore`, and its own frontend.
35
+ - A `<Service>.Contracts` project per producer, holding public events and the
36
+ assembly-level `[EventStore("<producer store>")]`. A consumer references the
37
+ contracts project (or its package), never the producer's service project.
38
+ - One solution may list every project; nothing shares source between services
39
+ except contracts projects.
40
+ - One model folder per service (`<Service>/Screenplay/`), never one folder above all
41
+ services: a folder of `.play` files is one application. Read
42
+ `cratis-screenplay-streams-and-consistency` (multi-service models) before modeling.
43
+
44
+ ## Choose the orchestrator
45
+
46
+ | Default | Use instead when |
47
+ | --- | --- |
48
+ | **.NET Aspire AppHost** with `Cratis.Chronicle.Aspire` | Docker Compose: the team does not run Aspire, or the services must start as containers |
49
+
50
+ Both need the same five decisions per service: kernel address, store name,
51
+ read-model database, startup order and a health endpoint.
52
+
53
+ ## Aspire AppHost
54
+
55
+ Add the `Cratis.Chronicle.Aspire` package to the AppHost only. `AddCratisChronicle`
56
+ runs the development image in run mode (bundled MongoDB, self-signed TLS, the
57
+ well-known development client) and the production image in publish mode.
58
+
59
+ ```csharp
60
+ // AppHost/Program.cs
61
+ using Aspire.Hosting.ApplicationModel;
62
+ using Cratis.Chronicle.Aspire;
63
+
64
+ var builder = DistributedApplication.CreateBuilder(args);
65
+
66
+ var mongo = builder.AddCratisChronicleMongoDB();
67
+ var chronicle = builder.AddCratisChronicle("chronicle", c => c.WithMongoDB(mongo));
68
+ var grpc = chronicle.GetEndpoint("grpc");
69
+
70
+ AddService<Projects.Ordering>("ordering", "Ordering");
71
+ AddService<Projects.Billing>("billing", "Billing");
72
+
73
+ builder.Build().Run();
74
+
75
+ void AddService<TProject>(string name, string eventStore)
76
+ where TProject : IProjectMetadata, new() =>
77
+ builder.AddProject<TProject>(name)
78
+ .WithEnvironment("Cratis__Chronicle__ConnectionString",
79
+ $"chronicle://chronicle-dev-client:chronicle-dev-secret@{grpc.Property(EndpointProperty.HostAndPort)}")
80
+ .WithEnvironment("Cratis__Chronicle__EventStore", eventStore)
81
+ .WithEnvironment("Cratis__MongoDB__Server", mongo.Resource.ConnectionStringExpression)
82
+ .WithEnvironment("Cratis__MongoDB__Database", eventStore)
83
+ .WaitFor(chronicle);
84
+ ```
85
+
86
+ Rules behind each line:
87
+
88
+ - **Set `Cratis__Chronicle__ConnectionString` explicitly.** `WithReference(chronicle)`
89
+ supplies the resource's connection string as `ConnectionStrings__chronicle`, a
90
+ setting the Chronicle client does not read; it binds `Cratis:Chronicle` and
91
+ otherwise falls back to `localhost:35000`. A service that appears to work with
92
+ only `WithReference` is reaching a kernel on port 35000 by accident.
93
+ - **Set `Cratis__Chronicle__EventStore` per service.** It is required, and it is the
94
+ origin name the other services' contracts use.
95
+ - **MongoDB must be a replica set.** `AddCratisChronicleMongoDB()` starts a
96
+ single-node replica set and hands back a connection string with
97
+ `directConnection=true`. Aspire's own `AddMongoDB` is a standalone server:
98
+ Chronicle's observers and observable queries then silently do nothing.
99
+ - **Point Arc's read models at the same server.** Each service's `Cratis:MongoDB`
100
+ `Server` is the replica set and `Database` is the service's event-store name,
101
+ the pairing the Stage-rendered scaffold uses.
102
+ - **`WaitFor(chronicle)`** orders startup; the client also reconnects on its own.
103
+ - The development client and secret are for a local kernel only. Publish mode
104
+ selects the production image, which needs storage, a TLS certificate and an
105
+ encryption certificate (`cratis-chronicle-hosting`).
106
+
107
+ To reach the kernel at a fixed address (the CLI default, a browser bookmark), pin
108
+ the host port: `chronicle.WithEndpoint("grpc", endpoint => endpoint.Port = 35000);`.
109
+
110
+ ## Docker Compose
111
+
112
+ Order the containers MongoDB → replica-set initiation → Chronicle → services, and
113
+ gate each step on health. Chronicle publishes 35000 (clients, Workbench, health over
114
+ TLS) to `127.0.0.1` only; its dedicated health port (8080 here, HTTP without TLS)
115
+ stays inside the network for the health check; the Orleans ports 11111 and 30000
116
+ stay unpublished for a single node. Services reach the kernel at
117
+ `chronicle://chronicle-dev-client:chronicle-dev-secret@chronicle:35000`. Read
118
+ [references/docker-compose.md](references/docker-compose.md) for the complete file
119
+ and the per-service settings.
120
+
121
+ ## A `cratis` CLI context per store
122
+
123
+ A context stores one server plus a default event store and namespace, so create
124
+ one per service on the same kernel:
125
+
126
+ ```bash
127
+ cratis context create ordering --server chronicle://localhost:35000 -e Ordering
128
+ cratis context create billing --server chronicle://localhost:35000 -e Billing
129
+ cratis context set billing
130
+ cratis chronicle subscriptions list
131
+ ```
132
+
133
+ `-e <store>` on a single command overrides the context. Under Aspire without a
134
+ pinned port, use the host port the dashboard shows for the `grpc` endpoint.
135
+ `cratis-chronicle-cli-operations` owns the rest of the CLI.
136
+
137
+ ## Frontends
138
+
139
+ - One frontend per service. Its generated Arc proxies call routes relative to the
140
+ origin, so serve each frontend from its own service (static files plus a
141
+ fallback, as the Stage-rendered scaffold does) or from a dev server that proxies
142
+ `/api` to that service. One frontend calling several services needs an ingress
143
+ that routes by the `microservice` metadata; nested `<Arc>` providers do not
144
+ isolate identity.
145
+ - Types several services share are generated once: map their assembly to an npm
146
+ package with `<AssemblyToPackageMapping Include="shared" Assembly="Shop.Shared" Package="@shop/shared" />`
147
+ in each service project.
148
+ - Ports: give each service and dev server a fixed, distinct port, and keep
149
+ 27017 and 35000 for MongoDB and Chronicle. Two Stage-rendered services each ship a
150
+ compose file binding 27017 and 35000; run one kernel from the orchestrator instead
151
+ and point both at it.
152
+
153
+ ## Verify the local system
154
+
155
+ 1. The orchestrator shows MongoDB, Chronicle and every service healthy;
156
+ `cratis chronicle event-stores list` lists exactly one store per service.
157
+ 2. Each service's effective `Cratis:Chronicle:EventStore` matches its contracts'
158
+ `[EventStore]`, and no service logs a connection to `localhost:35000` it was not
159
+ given.
160
+ 3. `cratis chronicle subscriptions list -e <consumer>` shows each producer, and an
161
+ action in one service's frontend produces the consumer's private event.
162
+ 4. Restarting the kernel alone: services reconnect and forwarding resumes without
163
+ restarting them.
164
+
165
+ ## Route near misses
166
+
167
+ - Contracts, subscriptions, delivery and idempotency between services:
168
+ `cratis-multi-service-architecture`.
169
+ - Kernel storage, TLS, certificates, clustering and production images:
170
+ `cratis-chronicle-hosting`.
171
+ - Bootstrapping one Arc service: `cratis-arc-hosting`.
172
+ - Rendering a service from its model: `cratis-screenplay-render-and-gap-fill`.
@@ -0,0 +1,144 @@
1
+ <!-- Copyright (c) Cratis. All rights reserved. -->
2
+ <!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
3
+
4
+ # Docker Compose for several Cratis services
5
+
6
+ ## Contents
7
+
8
+ - The file
9
+ - What each part is for
10
+ - Per-service settings
11
+ - Checks
12
+
13
+ ## The file
14
+
15
+ Two services, `ordering` and `billing`, each built from its own Dockerfile, on one
16
+ Chronicle kernel backed by a single-node MongoDB replica set. The Chronicle image is
17
+ the development image without bundled MongoDB, so it uses the replica set below and
18
+ accepts the well-known development client.
19
+
20
+ ```yaml
21
+ services:
22
+ mongodb:
23
+ image: mongo:8.2
24
+ command: ["mongod", "--replSet", "rs0", "--bind_ip_all"]
25
+ volumes:
26
+ - mongodb-data:/data/db
27
+ healthcheck:
28
+ test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping')"]
29
+ interval: 5s
30
+ timeout: 5s
31
+ retries: 30
32
+
33
+ mongodb-init:
34
+ image: mongo:8.2
35
+ depends_on:
36
+ mongodb:
37
+ condition: service_healthy
38
+ restart: "no"
39
+ command:
40
+ - mongosh
41
+ - --host
42
+ - mongodb
43
+ - --quiet
44
+ - --eval
45
+ - |
46
+ try {
47
+ const status = db.adminCommand({ replSetGetStatus: 1 });
48
+ if (!status.ok) { throw new Error(JSON.stringify(status)); }
49
+ } catch (error) {
50
+ if (error.code !== 94) { throw error; }
51
+ const result = rs.initiate({ _id: 'rs0', members: [{ _id: 0, host: 'mongodb:27017' }] });
52
+ if (!result.ok) { throw new Error(JSON.stringify(result)); }
53
+ }
54
+
55
+ chronicle:
56
+ image: cratis/chronicle:latest-development-slim
57
+ depends_on:
58
+ mongodb-init:
59
+ condition: service_completed_successfully
60
+ environment:
61
+ Cratis__Chronicle__Storage__Type: MongoDB
62
+ Cratis__Chronicle__Storage__ConnectionDetails: mongodb://mongodb:27017/?replicaSet=rs0&directConnection=true
63
+ Cratis__Chronicle__Health__Port: "8080"
64
+ Cratis__Chronicle__Health__Tls: "false"
65
+ Cratis__Chronicle__Health__Exclusive: "true"
66
+ healthcheck:
67
+ test: ["CMD", "curl", "-fsS", "http://localhost:8080/health"]
68
+ interval: 5s
69
+ timeout: 5s
70
+ retries: 60
71
+ ports:
72
+ - "127.0.0.1:35000:35000"
73
+
74
+ ordering:
75
+ build: ./Ordering
76
+ depends_on:
77
+ chronicle:
78
+ condition: service_healthy
79
+ environment:
80
+ Cratis__Chronicle__ConnectionString: chronicle://chronicle-dev-client:chronicle-dev-secret@chronicle:35000
81
+ Cratis__Chronicle__EventStore: Ordering
82
+ Cratis__MongoDB__Server: mongodb://mongodb:27017/?replicaSet=rs0&directConnection=true
83
+ Cratis__MongoDB__Database: Ordering
84
+ ports:
85
+ - "127.0.0.1:5101:8080"
86
+
87
+ billing:
88
+ build: ./Billing
89
+ depends_on:
90
+ chronicle:
91
+ condition: service_healthy
92
+ environment:
93
+ Cratis__Chronicle__ConnectionString: chronicle://chronicle-dev-client:chronicle-dev-secret@chronicle:35000
94
+ Cratis__Chronicle__EventStore: Billing
95
+ Cratis__MongoDB__Server: mongodb://mongodb:27017/?replicaSet=rs0&directConnection=true
96
+ Cratis__MongoDB__Database: Billing
97
+ ports:
98
+ - "127.0.0.1:5102:8080"
99
+
100
+ volumes:
101
+ mongodb-data:
102
+ ```
103
+
104
+ ## What each part is for
105
+
106
+ - **Replica set first.** Chronicle needs MongoDB transactions and change streams,
107
+ which a standalone `mongod` does not provide. `mongodb-init` initiates the set once
108
+ and tolerates an already initiated one (error code 94), so `docker compose up`
109
+ is repeatable. `directConnection=true` keeps the driver on the address it was
110
+ given.
111
+ - **Health-gated kernel.** The dedicated health port serves `/health` over plain
112
+ HTTP/1.1; `Health__Exclusive` makes it answer nothing else, and it is not
113
+ published. The image ships `curl` for the check. Services wait for
114
+ `service_healthy`; the client would also reconnect on its own.
115
+ - **Ports.** Only 35000 (clients, Workbench, REST and OAuth over TLS) is published,
116
+ bound to `127.0.0.1`, because the development image accepts well-known
117
+ credentials. The Orleans silo (11111) and gateway (30000) ports are for
118
+ clustering and stay unpublished for one node.
119
+ - **Image choice.** The development image bundles MongoDB and suits a kernel alone;
120
+ with external storage use the development-slim image as above. The production
121
+ image starts only with storage, a TLS certificate and an encryption certificate,
122
+ and generates no development client (`cratis-chronicle-hosting`). Pin an exact
123
+ image version in shared environments instead of a floating tag.
124
+
125
+ ## Per-service settings
126
+
127
+ | Setting | Value |
128
+ | --- | --- |
129
+ | `Cratis__Chronicle__ConnectionString` | The kernel's service name and port inside the network; the development client and secret locally, a per-service client and `skipTlsValidation=false` with a real certificate elsewhere |
130
+ | `Cratis__Chronicle__EventStore` | The service's own store name, equal to its contracts' `[EventStore]` |
131
+ | `Cratis__MongoDB__Server`, `Cratis__MongoDB__Database` | The replica set, and the service's event-store name as the database |
132
+ | Host port | A distinct port per service, bound to `127.0.0.1` |
133
+
134
+ Connection-string options (`skipTlsValidation`, credentials, several hosts) are
135
+ covered in `cratis-chronicle-client-dotnet`.
136
+
137
+ ## Checks
138
+
139
+ - `docker compose ps` shows `mongodb-init` exited 0 and every other service healthy
140
+ or running.
141
+ - `cratis chronicle event-stores list --server chronicle://localhost:35000` lists
142
+ `Ordering` and `Billing` once each.
143
+ - `docker compose restart chronicle`: both services reconnect and forwarding resumes
144
+ without restarting them.
@@ -19,6 +19,8 @@ preserves inbound for translations without a declared direction. Private-to-priv
19
19
  Automation (`produces` or `invokes`), even when a Chronicle reactor realizes it.
20
20
  Read [public events and direction](references/public-events-and-direction.md) for released
21
21
  ESM v9 forms, event-target folds, publication specifications and the Unsupported capture limit.
22
+ One `source events` capture reads one origin (event store); split several origins.
23
+ Requires Screenplay 4.155.0 (`screenplay --version`) for PLAY0687; older tools leave it unchecked.
22
24
 
23
25
  Work in the model first. Code appears only where it is truly needed: the external call, the
24
26
  source adapter, the trusted actor, and everything Stage cannot render (below). Session and
@@ -55,6 +57,8 @@ sends again.
55
57
 
56
58
  - A reaction cascade is not one transaction: earlier accepted facts stay when a later invoked
57
59
  command rejects (Screenplay `reactions.md`). Design each step to be retried on its own.
60
+ - Read `references/effects-and-idempotency.md` when specifying redelivery,
61
+ `then no events` or refusal disposition; execution is not external deduplication.
58
62
  - Replay and recovery redelivery are different. Chronicle `[OnceOnly]` skips replays (rewind,
59
63
  redaction, revision) only, not ordinary catch-up, repeated same-source events or crash
60
64
  redelivery. Recovery runs the handler normally. It is not a per-source run limit or
@@ -45,7 +45,7 @@ Outcomes:
45
45
  - A projection that adds an item `from <OpeningFact>` and removes it with
46
46
  `remove with <ClosingFact>`. Several facts may open or close; they need not match one to one.
47
47
  - A keyed query (`…ById => Item optional` + `by itemId`) for specs and executable scope; a
48
- list query for the visible queue (`=> Item[]` binds on Screenplay 4.105.0 or later; a snapshot list is refused by Stage, `STAGE-ESM-010`).
48
+ list query for the visible queue (`=> Item[]` binds on Screenplay 4.105.0 or later; a snapshot list renders with Stage 4.90.0 or later; older renderers refuse STAGE-ESM-010).
49
49
  - A reaction `when <OpeningFact>` that invokes the command producing the closing fact.
50
50
  The trigger may `reads` the item view to document its input; that is not protection.
51
51
  - A retry sweep on a clock reads the whole view (no `by` on clock reads). Iterating its items
@@ -1,5 +1,16 @@
1
1
  # Effects and idempotency
2
2
 
3
+ ## Contents
4
+
5
+ - Three guarantees, three proofs
6
+ - Where the external call sits
7
+ - Refusal disposition and redelivery
8
+ - Retry identity
9
+ - Ordering and lost acknowledgements
10
+ - Projection lag and rebuild
11
+ - What to write down (slice `documentation` + `STATE.md`)
12
+ - Chronicle realization
13
+
3
14
  ## Three guarantees, three proofs
4
15
  See "Effect guarantees and recovery traps" in SKILL.md.
5
16
 
@@ -31,17 +42,25 @@ An invocation can state ordered `on refused` selectors for
31
42
  validation, constraint (optionally named) or explicit authorization denial.
32
43
  Bare refusal does not include authorization. A matching branch declares a fact
33
44
  or leaf `acknowledge`; `$refusal.reason`/`.message` are String details and
34
- `.constraint` belongs only to constraint selectors. This is **authoring-only**
35
- (PLAY0268), not evidence that a duplicate was safely acknowledged at runtime.
45
+ `.constraint` belongs only to constraint selectors and names the first violated
46
+ constraint. The first matching branch wins; a handled refusal stops the trigger's
47
+ remaining invocations, not other reactions. Mixed refusals classify authorization,
48
+ then constraint, then validation. A rejected branch append ends the scenario.
49
+ Acknowledgement records handling, not completion; unhandled validation/constraint
50
+ refusals stay assertable with `then error`.
36
51
 
37
- Requires Screenplay 4.81.0 or later (`screenplay --version`) for `on refused` selectors and `$refusal` values.
52
+ Requires Screenplay 4.160.0 or later (`screenplay --version`) for executable refusal branches and `$refusal` values (ESM v19); older compilers report PLAY0268.
38
53
 
39
54
  Recovery syntax `when redelivered <Event> to <Reaction>` selects exactly one
40
55
  existing given occurrence; it is not append or replay. `then no events` makes a
41
- no-new-facts contract explicit but remains unadmitted too. Full selectors,
42
- occurrence matching and checked source examples: captures-and-reactions
56
+ no-new-facts contract explicit, including the settled cascade; after append it
57
+ excludes the input fact. Specify retry/recovery behavior this way rather than
58
+ re-appending the input or claiming an external effect was deduplicated. Full
59
+ selectors, occurrence matching and examples: captures-and-reactions
43
60
  `references/refusals-and-redelivery.md`.
44
61
 
62
+ Requires Screenplay 4.157.0 or later (`screenplay --version`) for executable redelivery and no-event assertions (ESM v17); older compilers report PLAY0268.
63
+
45
64
  Infrastructure/contract errors, Unsupported and concurrency are never domain
46
65
  refusals. No `by concurrency` exists: fail/retry transient contention. Record the
47
66
  actual target's disposition, trusted actor, durable delivery identity and external
@@ -121,7 +121,7 @@ ESM v9 shipped and is selected only by use of public events,
121
121
  origins, direction, event-target builders or events-source captures. At 4.135.0,
122
122
  publication reference scenarios execute; imported shapes still refuse binding.
123
123
  Stage 4.52.0 (previous CLI 3.46.1, history) audited only through v7. The CLI/Stage pair (toolchain `references/renderable-subset.md`)
124
- reaches construct admission through v15 but still refuses publication (STAGE-ESM-032), foreign
124
+ reaches construct admission through its bundled ceiling but still refuses publication (STAGE-ESM-032), foreign
125
125
  events/events-source captures (STAGE-ESM-033); source admission is not rendering.
126
126
 
127
127
  Requires Screenplay 4.117.0 or later (`screenplay --version`) for public events (ESM v9).
@@ -50,6 +50,11 @@ Method (the four-part automation test, loops, translations versus automations):
50
50
 
51
51
  Read [ESM v9 translation](../cratis-screenplay-automations-and-translations/references/public-events-and-direction.md)
52
52
  for `direction`, `source events`/`from`, and its typed Unsupported evaluation.
53
+ One `source events` capture consumes events from exactly one origin (event store).
54
+ Split inputs from several external systems into one capture per origin; otherwise
55
+ PLAY0687 reports an error, matching Chronicle's one-inbox-observer boundary.
56
+
57
+ Requires Screenplay 4.155.0 or later (`screenplay --version`) for PLAY0687; older compilers do not catch the runtime-invalid multi-origin capture.
53
58
  Read [v10 filters](../cratis-screenplay-toolchain/references/production-routes-and-filters.md)
54
59
  for reaction/reducer `from Source[.Stream]`; unrouted facts never match.
55
60
 
@@ -94,12 +99,12 @@ the invoked command or the implementation. A compiler that stops before ESM v6 b
94
99
 
95
100
  ## Refusals and recovery redelivery
96
101
 
97
- Invocation refusal selectors, `$refusal` branch values,
98
- `acknowledge`, `when redelivered ... to ...` and `then no events` are valid
99
- authoring intent but refuse binding with PLAY0268. Read
100
- [refusals and redelivery](references/refusals-and-redelivery.md) for first-match
101
- selectors, typed values, occurrence matching, diagnostics and the checked
102
- unbound example. Never acknowledge infrastructure or concurrency failures.
102
+ Invocation refusal selectors, `$refusal` branch values and `acknowledge`
103
+ bind/reference-execute as ESM v19; `when redelivered ... to ...` and `then no events`
104
+ as ESM v17. Read [refusals and redelivery](references/refusals-and-redelivery.md)
105
+ when choosing ordered first-match branches or specifying recovery, for typed values,
106
+ occurrence matching, diagnostics and a complete example. Never acknowledge
107
+ infrastructure or concurrency failures; acknowledgement is not completed work.
103
108
 
104
109
  ## Complete example (ESM v6)
105
110
 
@@ -80,7 +80,9 @@ through v7 only (toolchain `references/renderable-subset.md`).
80
80
  Clock/application-trigger identities have no Stage Arc realization either.
81
81
  Use authorized gap-fill with the model as contract; returned-command Arc identity
82
82
  uses `[ExecuteCommandsAsSystem]`, never permission inferred from a model header.
83
- Refusal/redelivery syntax remains unadmitted even when identity itself runs.
83
+ Redelivery/no-event assertions execute as v17 and refusal branches as v19;
84
+ identity admission alone does not establish a target's support for either.
85
+ Read [refusals and redelivery](refusals-and-redelivery.md) when combining them.
84
86
 
85
87
  Authority: Screenplay `reactions.md`, `ReactionIdentityParser.cs`,
86
88
  `ReactionRefusalValidator.cs`, `SemanticModelBinder.cs`; Stage `SemanticCratisAdmission.cs`.
@@ -12,14 +12,13 @@
12
12
 
13
13
  ## Select a refusal
14
14
 
15
- These forms are authoring-only: binding refuses the whole
16
- model with PLAY0268, even when the source is valid. Do not execute them as append
17
- scenarios or silently drop branches. Sources: released `reactions.md`,
18
- `specifications.md`, decision 0030.
15
+ Refusal branches and `$refusal` values bind and reference-execute as ESM v19.
16
+
17
+ Requires Screenplay 4.160.0 or later (`screenplay --version`) for refusal execution; older compilers report PLAY0268.
19
18
 
20
19
  Inside an `invokes` block, ordered selectors state intended recovery:
21
20
 
22
- | Selector | Matches at future admission |
21
+ | Selector | Matches |
23
22
  | --- | --- |
24
23
  | `on refused` | Validation or constraint, not authorization |
25
24
  | `on refused by validation` | Input/concept/require rejection |
@@ -31,44 +30,113 @@ The first matching selector wins. Repeated selectors or narrower branches after
31
30
  covering branches report PLAY0540; bare refusal does not cover authorization.
32
31
  Unknown named constraints report PLAY0542; known but inapplicable constraints
33
32
  also report PLAY0540. Authorization recovery requires a deliberate trusted path,
34
- not a fictional caller supplied by `given caller`. On current source a declared
35
- reaction `runs as` affects identity diagnostics, but refusal branches themselves
36
- remain unadmitted; do not infer their execution from that separate capability.
33
+ not a fictional caller supplied by `given caller`. Declare the reaction's
34
+ trusted actor with `runs as` when its invoked command requires one.
35
+ Mixed refusals classify as authorization first, then constraint, then validation.
37
36
 
38
37
  ## Branch values and acknowledgement
39
38
 
40
39
  A branch contains leaf `acknowledge` alone, or ordinary `produces <Event>` blocks
41
40
  with mappings and optional `for`. Empty branches, repeated acknowledgement,
42
41
  acknowledgement plus productions, operations, inline events and attachments refuse.
43
- Acknowledgement states a terminal disposition, not a successful command or fact.
42
+ Acknowledgement records that a refusal was handled, not that work completed.
44
43
 
45
44
  Branch event mappings may use String values `$refusal.reason` (validation,
46
- constraint, authorization), `$refusal.message` (verbatim details, including symbolic
47
- localization keys), and `$refusal.constraint` only in constraint selectors.
45
+ constraint, authorization), `$refusal.message` (error messages joined with a newline
46
+ verbatim, including symbolic localization keys), and `$refusal.constraint` (the first
47
+ violated constraint's name) only in constraint selectors.
48
48
  Unknown members, wrong scope or incompatible targets report PLAY0541. Messages
49
49
  are display details, not stable identity; trigger inputs remain available, read
50
50
  aliases do not become branch inputs.
51
51
 
52
- The intended admitted behavior stops remaining invocations of that trigger after
53
- handling a refusal, but lets other reactions/cascades from accepted facts settle.
54
- The refused command adds no facts; branch appends obey normal constraints and
55
- cannot catch their own refusal through another branch. Unhandled refusal retains
56
- earlier accepted facts. This is a future contract, not passing runner behavior.
52
+ A handled refusal stops remaining invocations of that trigger, while other
53
+ reactions/cascades from accepted facts continue. The refused command adds no facts;
54
+ branch appends obey normal constraints. A rejected branch append ends the scenario,
55
+ not another refusal branch. Unhandled validation/constraint refusals remain assertable
56
+ with `then error`; earlier accepted facts remain.
57
+
58
+ This complete model records a constrained duplicate as a refusal fact. Run
59
+ `screenplay test <root>`: exit 0 with one passed scenario.
60
+
61
+ ```screenplay
62
+ module Billing
63
+ feature Claims
64
+ slice Automation Recovery
65
+ event Approved
66
+ invoice String
67
+ event Claimed
68
+ event Refused
69
+ reason String
70
+ constraint String
71
+ message String
72
+ command Approve
73
+ id String identifier
74
+ invoice String
75
+ produces Approved
76
+ for id
77
+ invoice = invoice
78
+ command Claim
79
+ id String identifier
80
+ produces Claimed
81
+ for id
82
+ constraint OneClaim
83
+ unique event Claimed
84
+ message "Already claimed"
85
+ reaction Claimer
86
+ when Approved
87
+ invoice
88
+ invokes Claim
89
+ id = invoice
90
+ on refused by constraint OneClaim
91
+ produces Refused
92
+ reason = $refusal.reason
93
+ constraint = $refusal.constraint
94
+ message = $refusal.message
95
+ on refused
96
+ acknowledge
97
+ specification RecordingTheDuplicate
98
+ given Claimed
99
+ for "invoice-1"
100
+ given Approved
101
+ for "invoice-1"
102
+ invoice = "invoice-1"
103
+ when redelivered Approved to Claimer
104
+ then Refused
105
+ for "invoice-1"
106
+ reason = "constraint"
107
+ constraint = "OneClaim"
108
+ message = "Already claimed"
109
+ ```
57
110
 
58
111
  ## Redeliver an existing occurrence
59
112
 
60
- The complete authoring model below compiles without warnings on 4.125.0;
61
- `screenplay test` intentionally returns 3/unbound with PLAY0268 for redelivery
62
- and no-event assertion, not a recovery pass:
113
+ Recovery redelivery and explicit no-event assertions bind and reference-execute as ESM v17.
63
114
 
64
- ```screenplay test=unbound
115
+ Requires Screenplay 4.157.0 or later (`screenplay --version`); older compilers report PLAY0268.
116
+
117
+ Run `screenplay test <root>` on this complete model: exit 0 with one passed scenario.
118
+
119
+ ```screenplay
65
120
  module Billing
66
121
  feature Claims
67
122
  slice Automation Recovery
68
123
  event Approved
69
124
  invoice String
125
+ event Claimed
126
+ invoice String
127
+ command Approve
128
+ id String identifier
129
+ invoice String
130
+ produces Approved
131
+ for id
132
+ invoice = invoice
70
133
  reaction Claimer
71
134
  when Approved
135
+ invoice
136
+ produces Claimed
137
+ for invoice
138
+ invoice = invoice
139
+ where invoice == "invoice-2"
72
140
  specification Recovery
73
141
  given Approved
74
142
  for "invoice-1"
@@ -85,12 +153,15 @@ exactly one definitely matching occurrence and no unknown candidates are require
85
153
  (PLAY0543). Equal duplicate givens are still separate candidates. A locator with
86
154
  no route is a wildcard; explicit stream ids compare canonically, and `no stream`
87
155
  selects only unrouted givens. This is the sole action, not an extra action after
88
- append. Intended delivery uses the existing occurrence, never appends it again.
89
-
90
- Leaf `then no events` explicitly expects no new facts after a non-append action.
91
- It may accompany view/query/response assertions, not events, any-order events,
92
- error or denial. It is invalid after `when append` (PLAY0545), and remains
93
- unadmitted even on a model without a refusal branch.
156
+ append. Givens establish state without firing reactions; delivery uses the existing
157
+ occurrence only for the named reaction, honors its `from`/`where` filters, then
158
+ settles the cascade. It never appends the input again.
159
+
160
+ Leaf `then no events` explicitly expects no new facts from the action and its
161
+ cascade. After `when append`, it excludes the input fact and asserts nothing
162
+ followed. It counts as a success outcome and may accompany view/query/response
163
+ assertions, not events, any-order events, error or denial (PLAY0545). Omitting
164
+ event expectations is not this explicit assertion.
94
165
 
95
166
  ## Recovery boundaries
96
167
 
@@ -79,7 +79,8 @@ including personal data and nested/collection uses, also gets property-level
79
79
  `[NotAudited]`. Qualifiers do not alter the generated attribute; reasons remain metadata.
80
80
  Protected identity uses and enum concepts refuse `STAGE-ESM-040` (the source binder
81
81
  already refuses the enum/identity shapes below). Non-text `secret` concepts (Int/Decimal/Bool/Date/DateTime/Uuid)
82
- refuse `STAGE-ESM-041`; `pii secret` uses PII and is exempt. No explicit subject lineage renders.
82
+ render with their original types (Requires Stage 4.96.0); older renderers refuse
83
+ `STAGE-ESM-041`. `pii secret` uses PII only. No explicit subject lineage renders.
83
84
  The semantic Host now protects values at rest and releases them on read, but existing stores keep
84
85
  earlier plaintext events. Reference/specification success does not prove storage protection.
85
86
  Never remove protection to fit a tool. Sources: Stage