@cratis/pi 7.14.1 → 7.14.3

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 (197) hide show
  1. package/package/corpus/agents/security-reviewer.md +2 -1
  2. package/package/corpus/rules/concepts.md +13 -7
  3. package/package/corpus/rules/glossary.md +2 -1
  4. package/package/corpus/rules/vertical-slices.md +5 -4
  5. package/package/corpus/skills/cratis-application-slice-conformance/SKILL.md +11 -2
  6. package/package/corpus/skills/cratis-application-slice-conformance/references/build-prompts.md +8 -0
  7. package/package/corpus/skills/cratis-application-slice-conformance/references/checklists.md +10 -6
  8. package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +1 -1
  9. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/SKILL.md +11 -7
  10. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authentication.md +12 -2
  11. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authorization.md +16 -1
  12. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/frontend.md +7 -0
  13. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/observable-emission-guards.md +9 -0
  14. package/package/corpus/skills/cratis-arc-command/SKILL.md +24 -16
  15. package/package/corpus/skills/cratis-arc-command/references/command-result.md +7 -0
  16. package/package/corpus/skills/cratis-arc-command/references/handler-shapes.md +10 -3
  17. package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +1 -1
  18. package/package/corpus/skills/cratis-arc-command-operation/SKILL.md +5 -1
  19. package/package/corpus/skills/cratis-arc-command-operation/references/execution-and-recovery.md +12 -0
  20. package/package/corpus/skills/cratis-arc-command-operation/references/testing.md +10 -3
  21. package/package/corpus/skills/cratis-arc-command-typescript/SKILL.md +20 -116
  22. package/package/corpus/skills/cratis-arc-command-typescript/references/chronicle-events.md +11 -8
  23. package/package/corpus/skills/cratis-arc-command-typescript/references/command-specifications.md +63 -0
  24. package/package/corpus/skills/cratis-arc-command-typescript/references/hosting-and-storage.md +10 -0
  25. package/package/corpus/skills/cratis-arc-command-typescript/references/proxy-generation.md +38 -0
  26. package/package/corpus/skills/cratis-arc-command-typescript/references/slice-layout.md +19 -0
  27. package/package/corpus/skills/cratis-arc-command-typescript/verification.json +1 -1
  28. package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +1 -1
  29. package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +11 -10
  30. package/package/corpus/skills/cratis-arc-react-page/SKILL.md +30 -19
  31. package/package/corpus/skills/cratis-arc-react-page/references/data-page.md +11 -0
  32. package/package/corpus/skills/cratis-arc-react-page/references/data-tables.md +10 -0
  33. package/package/corpus/skills/cratis-arc-react-page/references/dialogs.md +12 -10
  34. package/package/corpus/skills/cratis-arc-react-page/references/from-screenplay.md +10 -0
  35. package/package/corpus/skills/cratis-arc-react-page/references/mvvm.md +11 -0
  36. package/package/corpus/skills/cratis-arc-react-page/references/queries-and-commands.md +7 -0
  37. package/package/corpus/skills/cratis-chronicle-client-dotnet/SKILL.md +58 -122
  38. package/package/corpus/skills/cratis-chronicle-client-dotnet/references/compatibility-check.md +26 -0
  39. package/package/corpus/skills/cratis-chronicle-client-dotnet/references/discovery.md +22 -0
  40. package/package/corpus/skills/cratis-chronicle-client-dotnet/references/hosting.md +31 -0
  41. package/package/corpus/skills/cratis-chronicle-client-elixir/SKILL.md +52 -131
  42. package/package/corpus/skills/cratis-chronicle-client-elixir/references/append-api.md +19 -0
  43. package/package/corpus/skills/cratis-chronicle-client-elixir/references/variants.md +73 -0
  44. package/package/corpus/skills/cratis-chronicle-client-kotlin/SKILL.md +29 -232
  45. package/package/corpus/skills/cratis-chronicle-client-kotlin/references/connection-lifecycle.md +20 -0
  46. package/package/corpus/skills/cratis-chronicle-client-kotlin/references/discovery-and-registration.md +44 -0
  47. package/package/corpus/skills/cratis-chronicle-client-kotlin/references/java-api.md +33 -0
  48. package/package/corpus/skills/cratis-chronicle-client-kotlin/references/spring-boot.md +54 -0
  49. package/package/corpus/skills/cratis-chronicle-client-kotlin/references/variants.md +77 -0
  50. package/package/corpus/skills/cratis-chronicle-client-typescript/SKILL.md +26 -102
  51. package/package/corpus/skills/cratis-chronicle-client-typescript/references/read-models-and-projections.md +23 -0
  52. package/package/corpus/skills/cratis-chronicle-client-typescript/references/variants.md +63 -0
  53. package/package/corpus/skills/cratis-chronicle-compliance/SKILL.md +11 -2
  54. package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +2 -2
  55. package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +13 -13
  56. package/package/corpus/skills/cratis-chronicle-mcp-inspection/SKILL.md +1 -1
  57. package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +13 -4
  58. package/package/corpus/skills/cratis-chronicle-projection/references/fluent-builder.md +10 -0
  59. package/package/corpus/skills/cratis-chronicle-projection/references/model-bound-attributes.md +14 -6
  60. package/package/corpus/skills/cratis-chronicle-projection/references/variants.md +9 -0
  61. package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +7 -49
  62. package/package/corpus/skills/cratis-chronicle-reactor/references/domain-failures.md +19 -0
  63. package/package/corpus/skills/cratis-chronicle-reactor/references/specifications.md +33 -0
  64. package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +2 -2
  65. package/package/corpus/skills/cratis-chronicle-read-model/references/queries.md +11 -0
  66. package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +1 -0
  67. package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +1 -1
  68. package/package/corpus/skills/cratis-chronicle-web-workbench/SKILL.md +24 -24
  69. package/package/corpus/skills/cratis-content-length/SKILL.md +1 -1
  70. package/package/corpus/skills/cratis-content-length/references/length-evidence.md +12 -0
  71. package/package/corpus/skills/cratis-developer-marketing/SKILL.md +19 -19
  72. package/package/corpus/skills/cratis-developer-marketing/references/measurement.md +10 -0
  73. package/package/corpus/skills/cratis-developer-marketing/references/playbook-evidence.md +10 -0
  74. package/package/corpus/skills/cratis-engineering-csharp-conventions/SKILL.md +5 -0
  75. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/code-style.md +15 -0
  76. package/package/corpus/skills/cratis-engineering-csharp-conventions/references/exceptions-logging-and-di.md +9 -4
  77. package/package/corpus/skills/cratis-engineering-decision-record/SKILL.md +1 -2
  78. package/package/corpus/skills/cratis-engineering-decision-record/references/record-format.md +8 -0
  79. package/package/corpus/skills/cratis-engineering-docs-authoring/SKILL.md +1 -2
  80. package/package/corpus/skills/cratis-engineering-effect-boundaries/references/failure-archetypes.md +10 -0
  81. package/package/corpus/skills/cratis-fundamentals-concept/SKILL.md +4 -4
  82. package/package/corpus/skills/cratis-fundamentals-type-discovery/SKILL.md +1 -1
  83. package/package/corpus/skills/cratis-lens-browser-extension/SKILL.md +18 -18
  84. package/package/corpus/skills/cratis-performance-review/SKILL.md +1 -1
  85. package/package/corpus/skills/cratis-release-notes/SKILL.md +1 -0
  86. package/package/corpus/skills/cratis-screenplay-automations-and-translations/SKILL.md +29 -4
  87. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/automation-patterns.md +16 -4
  88. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/effects-and-idempotency.md +4 -15
  89. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/todo-list-example.md +6 -2
  90. package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/translation-patterns.md +1 -6
  91. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +45 -245
  92. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/capture-map-and-example.md +42 -0
  93. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/complete-examples.md +155 -0
  94. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/specifying-triggers-and-clock.md +27 -0
  95. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/trigger-reads-example.md +21 -0
  96. package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +70 -221
  97. package/package/corpus/skills/cratis-screenplay-command-surface/references/context.md +10 -0
  98. package/package/corpus/skills/cratis-screenplay-command-surface/references/generated-values-and-responses.md +51 -0
  99. package/package/corpus/skills/cratis-screenplay-command-surface/references/inline-events.md +62 -0
  100. package/package/corpus/skills/cratis-screenplay-command-surface/references/policy-persona-seed.md +46 -0
  101. package/package/corpus/skills/cratis-screenplay-command-surface/references/validate-rules.md +36 -0
  102. package/package/corpus/skills/cratis-screenplay-command-surface/verification.json +11 -11
  103. package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +10 -3
  104. package/package/corpus/skills/cratis-screenplay-discovery/references/facilitation.md +1 -6
  105. package/package/corpus/skills/cratis-screenplay-discovery/references/human-workshop.md +13 -0
  106. package/package/corpus/skills/cratis-screenplay-discovery/references/personas-and-causes.md +8 -0
  107. package/package/corpus/skills/cratis-screenplay-discovery/references/plotting-and-handoff.md +11 -0
  108. package/package/corpus/skills/cratis-screenplay-discovery/references/storming-loop.md +7 -0
  109. package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +75 -198
  110. package/package/corpus/skills/cratis-screenplay-event-modeling/references/file-layout.md +89 -0
  111. package/package/corpus/skills/cratis-screenplay-event-modeling/references/naming-primitives.md +26 -0
  112. package/package/corpus/skills/cratis-screenplay-event-modeling/references/nine-steps.md +14 -1
  113. package/package/corpus/skills/cratis-screenplay-event-modeling/references/parsed-not-runnable.md +8 -0
  114. package/package/corpus/skills/cratis-screenplay-event-modeling/references/provenance.md +10 -0
  115. package/package/corpus/skills/cratis-screenplay-event-modeling/references/slice-type-rules.md +12 -0
  116. package/package/corpus/skills/cratis-screenplay-event-modeling/verification.json +12 -6
  117. package/package/corpus/skills/cratis-screenplay-legacy-extraction/SKILL.md +5 -6
  118. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/candidate-inventory.md +11 -0
  119. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/prologue-safety.md +8 -0
  120. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/side-car-migration.md +11 -0
  121. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/ui-observation.md +1 -1
  122. package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +33 -10
  123. package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +8 -0
  124. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-loop.md +13 -17
  125. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-tools.md +11 -0
  126. package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +9 -9
  127. package/package/corpus/skills/cratis-screenplay-model-review/references/business-questions.md +9 -0
  128. package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +16 -1
  129. package/package/corpus/skills/cratis-screenplay-model-review/references/report-template.md +9 -0
  130. package/package/corpus/skills/cratis-screenplay-model-review/references/worked-example.md +9 -0
  131. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +17 -8
  132. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/handoff-template.md +8 -0
  133. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/identity-and-edits.md +1 -6
  134. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +19 -0
  135. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/safety.md +1 -1
  136. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/verdicts-and-modes.md +11 -1
  137. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/vocabulary-map.md +2 -2
  138. package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +3 -4
  139. package/package/corpus/skills/cratis-screenplay-projections/references/pdl-grammar.md +8 -0
  140. package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +2 -2
  141. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +3 -3
  142. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/gap-fill-handoff.md +1 -1
  143. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/renderability-gate.md +1 -1
  144. package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/worked-example.md +8 -0
  145. package/package/corpus/skills/cratis-screenplay-scenario-coverage/SKILL.md +10 -10
  146. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/coverage-matrix.md +8 -0
  147. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/invoicing-dues-example.md +4 -0
  148. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md +17 -0
  149. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-examples.md +10 -0
  150. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-workshop.md +11 -0
  151. package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/view-and-story-specs.md +12 -0
  152. package/package/corpus/skills/cratis-screenplay-slice-design/SKILL.md +2 -2
  153. package/package/corpus/skills/cratis-screenplay-slice-design/references/command-inventory.md +7 -0
  154. package/package/corpus/skills/cratis-screenplay-slice-design/references/field-lineage.md +8 -0
  155. package/package/corpus/skills/cratis-screenplay-slice-design/references/read-model-design.md +16 -0
  156. package/package/corpus/skills/cratis-screenplay-slice-design/references/slicing.md +10 -0
  157. package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +52 -360
  158. package/package/corpus/skills/cratis-screenplay-specifications/references/actions-beyond-commands.md +34 -0
  159. package/package/corpus/skills/cratis-screenplay-specifications/references/concept-rules.md +77 -0
  160. package/package/corpus/skills/cratis-screenplay-specifications/references/generated-fixtures.md +39 -0
  161. package/package/corpus/skills/cratis-screenplay-specifications/references/reactions-and-cascades.md +72 -0
  162. package/package/corpus/skills/cratis-screenplay-specifications/references/worked-example.md +110 -0
  163. package/package/corpus/skills/cratis-screenplay-specifications/verification.json +6 -6
  164. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/SKILL.md +23 -3
  165. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/boundaries.md +13 -0
  166. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/chronicle-boundaries.md +3 -3
  167. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/consistency-and-concurrency.md +16 -20
  168. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/stream-patterns.md +16 -0
  169. package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +13 -7
  170. package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +10 -0
  171. package/package/corpus/skills/cratis-screenplay-toolchain/references/doc-contradictions.md +1 -1
  172. package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +12 -2
  173. package/package/corpus/skills/cratis-screenplay-toolchain/references/generated-responses-example.md +1 -1
  174. package/package/corpus/skills/cratis-screenplay-toolchain/references/provenance.md +2 -2
  175. package/package/corpus/skills/cratis-screenplay-toolchain/references/renderable-subset.md +1 -1
  176. package/package/corpus/skills/cratis-screenplay-toolchain/references/traps.md +1 -1
  177. package/package/corpus/skills/cratis-screenplay-toolchain/references/verdicts.md +10 -0
  178. package/package/corpus/skills/cratis-screenplay-toolchain/references/versions.md +15 -5
  179. package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +11 -13
  180. package/package/corpus/skills/cratis-screenplay-ui-composition/references/flow-review.md +1 -1
  181. package/package/corpus/skills/cratis-security-review/SKILL.md +13 -8
  182. package/package/corpus/skills/cratis-social-feed-post/SKILL.md +10 -10
  183. package/package/corpus/skills/cratis-social-feed-post/references/engagement-evidence.md +12 -0
  184. package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +13 -2
  185. package/package/corpus/skills/cratis-specifications-csharp/references/application-scenarios.md +10 -10
  186. package/package/corpus/skills/cratis-specifications-csharp/references/csharp-patterns.md +10 -0
  187. package/package/corpus/skills/cratis-specifications-csharp/references/integration-specs.md +9 -0
  188. package/package/corpus/skills/cratis-specifications-typescript/SKILL.md +1 -2
  189. package/package/corpus/skills/cratis-specifications-typescript/references/typescript-patterns.md +11 -1
  190. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +30 -21
  191. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/admission.md +9 -0
  192. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/render-example.md +5 -0
  193. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/sandbox-and-specrunner.md +2 -4
  194. package/package/corpus/skills/cratis-studio-mcp-safety-guidance/SKILL.md +2 -2
  195. package/package/corpus/skills/cratis-writing-voice-and-cadence/SKILL.md +39 -39
  196. package/package/corpus/skills/cratis-writing-voice-and-cadence/references/ai-tells.md +10 -0
  197. package/package.json +1 -1
@@ -35,6 +35,57 @@ placeholder injected at pack time (`Source/Directory.Build.props`), so the
35
35
  repository never carries the real number. Reverify before claiming support for a
36
36
  version you have not checked.
37
37
 
38
+ ## Lifecycle
39
+
40
+ - **Registration is wired to the connection, not called by you.**
41
+ `EventStore.cs:265-268` subscribes `RegisterAll` to `Connection.Lifecycle.OnConnected`
42
+ when `autoDiscoverAndRegister` is on, so a reconnect re-registers everything.
43
+ - `DiscoverAll()` does event types first, then constraints, reactors, reducers,
44
+ projections, and seeding in parallel (`EventStore.cs:349-362`). `RegisterAll()`
45
+ is single-flighted with jittered backoff and a background retry loop (`:373-379`).
46
+ - **Wait with `WaitForRegistration`, not by polling `IsConnected`.**
47
+ `RegistrationWaitExtensions.WaitForRegistration(this IEventStore, TimeSpan? timeout = default)`
48
+ (`Source/Clients/DotNET/Registrations/RegistrationWaitExtensions.cs:42`, default
49
+ 5 seconds) exists precisely for this, and its own remarks warn against the
50
+ `IConnectionLifecycle.IsConnected` alternative (`:34-39`). Connected is not
51
+ registered.
52
+ - **Keepalive is a bidirectional stream plus a watchdog.** The watchdog monitors
53
+ every `MonitorIntervalMilliseconds = 1000`
54
+ (`Source/Clients/Connections/ConnectionWatchdog.cs:34`) and a keepalive that
55
+ falls more than 5 seconds behind is treated as a lost connection, with
56
+ reconnect backoff capped at 30 seconds. **The failure mode is silence, not an
57
+ exception** — appends keep working while observers go quiet.
58
+ - `Dispose()` disposes read model reactors for created stores, cancels the owned
59
+ connection, and disposes the connection
60
+ (`Source/Clients/DotNET/ChronicleClient.cs:225-246`).
61
+
62
+ ## What a standalone app owns that a host would have supplied
63
+
64
+ Every one of these has a silent default. Read them as a checklist, because the
65
+ defaults are reasonable for a sample and wrong for a service
66
+ (`ChronicleClient.cs:121-127`):
67
+
68
+ | Concern | Default when you pass nothing |
69
+ | --- | --- |
70
+ | `IClientArtifactsProvider` | `DefaultClientArtifactsProvider.Default` — full assembly scan |
71
+ | `IServiceProvider` | `DefaultServiceProvider`, which activates everything through `Activator.CreateInstance` (`DefaultServiceProvider.cs:41`) |
72
+ | `IIdentityProvider` | `BaseIdentityProvider` |
73
+ | `ICorrelationIdAccessor` | `CorrelationIdAccessor` |
74
+ | `IEventStoreNamespaceResolver` | `DefaultEventStoreNamespaceResolver` — always `"Default"` |
75
+ | `ILoggerFactory` | `new LoggerFactory()` — **a silent one** |
76
+ | Configuration binding | none; there is no `Cratis:Chronicle` section without a host |
77
+
78
+ The `IServiceProvider` default is the sharp one: **a reactor or reducer with
79
+ constructor dependencies is default-constructed** unless you pass a real
80
+ container. Pass one, or keep observers dependency-free.
81
+
82
+ The AspNetCore package additionally registers `AddUnitOfWork()`,
83
+ `AddCompliance()`, `AddCausation()`, `AddChronicleHealthCheck()`, and
84
+ `UseCratisChronicle()` — none of which the base package gives you.
85
+
86
+ **Keep the process alive.** Observation is a live gRPC duplex stream; a console
87
+ app that appends and returns from `Main` never sees a reactor run.
88
+
38
89
  ## Which package
39
90
 
40
91
  ```shell
@@ -149,62 +200,15 @@ from `string` (`:158`) and a `Redacted` form for logging (`:152`).
149
200
 
150
201
  ### In a host
151
202
 
152
- ```csharp
153
- var builder = Host.CreateApplicationBuilder(args);
154
- builder.AddCratisChronicle(options => options.EventStore = "<EventStoreName>");
155
- builder.Services.AddHostedService<<WorkerName>>();
156
- await builder.Build().RunAsync();
157
- ```
203
+ `AddCratisChronicle` is an extension on `IHostApplicationBuilder` (and `WebApplicationBuilder`), not on `IServiceCollection`; there is no `WithClaimsBasedNamespaceResolver`.
158
204
 
159
- `AddCratisChronicle` is an extension on **`IHostApplicationBuilder`**
160
- (`Source/Clients/DotNET/ChronicleHostApplicationBuilderExtensions.cs:28`) and binds
161
- the `Cratis:Chronicle` configuration section by default (`:25`, `:37`), with
162
- `ValidateDataAnnotations().ValidateOnStart()`. The bound type is
163
- `ChronicleClientOptions : ChronicleOptions`, which adds a `[Required] EventStore`
164
- and an optional `EventStoreNamespaceResolverType`.
165
-
166
- > **`AddCratisChronicle` on `IServiceCollection` does not exist**, despite what
167
- > `Documentation/clients/dotnet/getting-started.md:61` shows. The real extensions
168
- > are on `IHostApplicationBuilder`, `WebApplicationBuilder` (in the AspNetCore
169
- > package), and Aspire's `IDistributedApplicationBuilder`. `IHostBuilder.AddCratisChronicle()`
170
- > also exists but only registers concept type converters
171
- > (`Source/Clients/DotNET/Hosting/HostBuilderExtensions.cs:18-23`) — it is not
172
- > the wiring entry point.
173
-
174
- `IChronicleBuilder` extensions are exactly five:
175
- `WithArtifactsProvider`, `WithIdentityProvider`, `WithCorrelationIdAccessor`,
176
- `WithNamespaceResolver`, `WithCamelCaseNamingPolicy`
177
- (`Source/Clients/DotNET/ChronicleBuilderExtensions.cs`). **There is no
178
- `WithClaimsBasedNamespaceResolver`**, despite a doc comment at
179
- `ChronicleOptions.cs:141` referring to one. Pass the resolver instead:
180
- `new ChronicleClient(options, namespaceResolver: new ClaimsBasedNamespaceResolver("tenant_id"))`.
205
+ Read [references/hosting.md](references/hosting.md) when wiring Chronicle into a worker or ASP.NET Core host, or when `AddCratisChronicle` or a namespace resolver does not resolve.
181
206
 
182
207
  ## The client and the server check each other
183
208
 
184
- Since Chronicle 17 the compatibility check is a server-side RPC, and **the client
185
- runs it automatically inside `Connect()`** —
186
- `Source/Clients/Connections/ChronicleConnection.cs:310` calls
187
- `CheckCompatibility` (`:414`), sending the client type, client version, protocol
188
- version, and the descriptor set its contracts package was built with (`:420-426`).
189
- The rationale is at `:409-413`: Chronicle has clients in four languages and only
190
- some can build a descriptor set at runtime, so each ships the one it was built
191
- with and the server does the single comparison.
192
-
193
- Behavior you can rely on:
194
-
195
- - A server too old to have the RPC answers `Unimplemented`, and the client falls
196
- back to the previous client-side exchange (`:428-434`) — upgrading the client
197
- does not silently drop the check.
198
- - Any other transport error is **logged and ignored** (`:435-441`), on the stated
199
- reasoning that failing to ask says nothing about whether the two sides agree.
200
- - A genuine mismatch throws `IncompatibleServerException`
201
- (`Source/Clients/Connections/IncompatibleServerException.cs:10`) whose message
202
- names the server address, its version, its protocol version, and the specific
203
- incompatibilities (`:443-449`).
204
-
205
- The client identifies itself as `".NET"`
206
- (`Source/Clients/Connections/ChronicleClientIdentity.cs:22`) with its assembly
207
- informational version (`:27`) and the contracts protocol version (`:32`).
209
+ The client runs the server-side compatibility check automatically inside `Connect()`; a genuine mismatch throws `IncompatibleServerException`, while a transport error is logged and ignored by design.
210
+
211
+ Read [references/compatibility-check.md](references/compatibility-check.md) when diagnosing an `IncompatibleServerException`, a skipped compatibility check, or an old-server fallback.
208
212
 
209
213
  ## Event types
210
214
 
@@ -357,77 +361,9 @@ Read models are queried through `eventStore.ReadModels`
357
361
 
358
362
  ## Discovery
359
363
 
360
- Artifacts are found by **assembly scanning**, with no registration call and no DI
361
- container required. `DefaultClientArtifactsProvider.Default` composes the
362
- project-referenced and package-referenced assemblies
363
- (`Source/Clients/DotNET/DefaultClientArtifactsProvider.cs:37`), and the
364
- predicates are exactly (`:242-251`):
365
-
366
- | Kind | Predicate |
367
- | --- | --- |
368
- | event types | `HasAttribute<EventTypeAttribute>()` or `HasAttribute<EventTypeGenerationForAttribute>()` |
369
- | projections | `HasInterface(typeof(IProjectionFor<>))` |
370
- | model-bound projections | `HasModelBoundProjectionAttributes()` |
371
- | reactors | `HasInterface<IReactor>()` and not generic |
372
- | read model reactors | `HasInterface<IReadModelReactor>()` and not generic |
373
- | reducers | `HasInterface(typeof(IReducerFor<>))` and not generic |
374
-
375
- Explicit registration is available per family as an alternative —
376
- `IEventTypes.Register`, `IConstraints.Register`, `IProjections.Register`,
377
- `IReducers.Register`, `IReactors.Register<TReactor>()`,
378
- `IReadModels.Register<TReadModel>()` — and is what you use with
379
- `AutoDiscoverAndRegister = false`.
380
-
381
- ## Lifecycle
382
-
383
- - **Registration is wired to the connection, not called by you.**
384
- `EventStore.cs:265-268` subscribes `RegisterAll` to `Connection.Lifecycle.OnConnected`
385
- when `autoDiscoverAndRegister` is on, so a reconnect re-registers everything.
386
- - `DiscoverAll()` does event types first, then constraints, reactors, reducers,
387
- projections, and seeding in parallel (`EventStore.cs:349-362`). `RegisterAll()`
388
- is single-flighted with jittered backoff and a background retry loop (`:373-379`).
389
- - **Wait with `WaitForRegistration`, not by polling `IsConnected`.**
390
- `RegistrationWaitExtensions.WaitForRegistration(this IEventStore, TimeSpan? timeout = default)`
391
- (`Source/Clients/DotNET/Registrations/RegistrationWaitExtensions.cs:42`, default
392
- 5 seconds) exists precisely for this, and its own remarks warn against the
393
- `IConnectionLifecycle.IsConnected` alternative (`:34-39`). Connected is not
394
- registered.
395
- - **Keepalive is a bidirectional stream plus a watchdog.** The watchdog monitors
396
- every `MonitorIntervalMilliseconds = 1000`
397
- (`Source/Clients/Connections/ConnectionWatchdog.cs:34`) and a keepalive that
398
- falls more than 5 seconds behind is treated as a lost connection, with
399
- reconnect backoff capped at 30 seconds. **The failure mode is silence, not an
400
- exception** — appends keep working while observers go quiet.
401
- - `Dispose()` disposes read model reactors for created stores, cancels the owned
402
- connection, and disposes the connection
403
- (`Source/Clients/DotNET/ChronicleClient.cs:225-246`).
364
+ Artifacts are found by assembly scanning, with no registration call and no DI container required.
404
365
 
405
- ## What a standalone app owns that a host would have supplied
406
-
407
- Every one of these has a silent default. Read them as a checklist, because the
408
- defaults are reasonable for a sample and wrong for a service
409
- (`ChronicleClient.cs:121-127`):
410
-
411
- | Concern | Default when you pass nothing |
412
- | --- | --- |
413
- | `IClientArtifactsProvider` | `DefaultClientArtifactsProvider.Default` — full assembly scan |
414
- | `IServiceProvider` | `DefaultServiceProvider`, which activates everything through `Activator.CreateInstance` (`DefaultServiceProvider.cs:41`) |
415
- | `IIdentityProvider` | `BaseIdentityProvider` |
416
- | `ICorrelationIdAccessor` | `CorrelationIdAccessor` |
417
- | `IEventStoreNamespaceResolver` | `DefaultEventStoreNamespaceResolver` — always `"Default"` |
418
- | `ILoggerFactory` | `new LoggerFactory()` — **a silent one** |
419
- | Configuration binding | none; there is no `Cratis:Chronicle` section without a host |
420
-
421
- The `IServiceProvider` default is the sharp one: **a reactor or reducer with
422
- constructor dependencies is default-constructed** unless you pass a real
423
- container. Pass one, or keep observers dependency-free.
424
-
425
- The AspNetCore package additionally registers `AddUnitOfWork()`,
426
- `AddCompliance()`, `AddCausation()`, `AddChronicleHealthCheck()`, and
427
- `UseCratisChronicle()` — none of which the base package gives you.
428
-
429
- **Keep the process alive.** Observation is a live gRPC duplex stream; a console
430
- app that appends and returns from `Main` never sees a reactor run.
366
+ Read [references/discovery.md](references/discovery.md) when an event type, reactor, reducer or projection is not being found, or when you need explicit registration with `AutoDiscoverAndRegister = false`.
431
367
 
432
368
  ## Common pitfalls
433
369
 
@@ -0,0 +1,26 @@
1
+ ## The client and the server check each other
2
+
3
+ Since Chronicle 17 the compatibility check is a server-side RPC, and **the client
4
+ runs it automatically inside `Connect()`** —
5
+ `Source/Clients/Connections/ChronicleConnection.cs:310` calls
6
+ `CheckCompatibility` (`:414`), sending the client type, client version, protocol
7
+ version, and the descriptor set its contracts package was built with (`:420-426`).
8
+ The rationale is at `:409-413`: Chronicle has clients in four languages and only
9
+ some can build a descriptor set at runtime, so each ships the one it was built
10
+ with and the server does the single comparison.
11
+
12
+ Behavior you can rely on:
13
+
14
+ - A server too old to have the RPC answers `Unimplemented`, and the client falls
15
+ back to the previous client-side exchange (`:428-434`) — upgrading the client
16
+ does not silently drop the check.
17
+ - Any other transport error is **logged and ignored** (`:435-441`), on the stated
18
+ reasoning that failing to ask says nothing about whether the two sides agree.
19
+ - A genuine mismatch throws `IncompatibleServerException`
20
+ (`Source/Clients/Connections/IncompatibleServerException.cs:10`) whose message
21
+ names the server address, its version, its protocol version, and the specific
22
+ incompatibilities (`:443-449`).
23
+
24
+ The client identifies itself as `".NET"`
25
+ (`Source/Clients/Connections/ChronicleClientIdentity.cs:22`) with its assembly
26
+ informational version (`:27`) and the contracts protocol version (`:32`).
@@ -0,0 +1,22 @@
1
+ ## Discovery
2
+
3
+ Artifacts are found by **assembly scanning**, with no registration call and no DI
4
+ container required. `DefaultClientArtifactsProvider.Default` composes the
5
+ project-referenced and package-referenced assemblies
6
+ (`Source/Clients/DotNET/DefaultClientArtifactsProvider.cs:37`), and the
7
+ predicates are exactly (`:242-251`):
8
+
9
+ | Kind | Predicate |
10
+ | --- | --- |
11
+ | event types | `HasAttribute<EventTypeAttribute>()` or `HasAttribute<EventTypeGenerationForAttribute>()` |
12
+ | projections | `HasInterface(typeof(IProjectionFor<>))` |
13
+ | model-bound projections | `HasModelBoundProjectionAttributes()` |
14
+ | reactors | `HasInterface<IReactor>()` and not generic |
15
+ | read model reactors | `HasInterface<IReadModelReactor>()` and not generic |
16
+ | reducers | `HasInterface(typeof(IReducerFor<>))` and not generic |
17
+
18
+ Explicit registration is available per family as an alternative —
19
+ `IEventTypes.Register`, `IConstraints.Register`, `IProjections.Register`,
20
+ `IReducers.Register`, `IReactors.Register<TReactor>()`,
21
+ `IReadModels.Register<TReadModel>()` — and is what you use with
22
+ `AutoDiscoverAndRegister = false`.
@@ -0,0 +1,31 @@
1
+ ## In a host
2
+
3
+ ```csharp
4
+ var builder = Host.CreateApplicationBuilder(args);
5
+ builder.AddCratisChronicle(options => options.EventStore = "<EventStoreName>");
6
+ builder.Services.AddHostedService<<WorkerName>>();
7
+ await builder.Build().RunAsync();
8
+ ```
9
+
10
+ `AddCratisChronicle` is an extension on **`IHostApplicationBuilder`**
11
+ (`Source/Clients/DotNET/ChronicleHostApplicationBuilderExtensions.cs:28`) and binds
12
+ the `Cratis:Chronicle` configuration section by default (`:25`, `:37`), with
13
+ `ValidateDataAnnotations().ValidateOnStart()`. The bound type is
14
+ `ChronicleClientOptions : ChronicleOptions`, which adds a `[Required] EventStore`
15
+ and an optional `EventStoreNamespaceResolverType`.
16
+
17
+ > **`AddCratisChronicle` on `IServiceCollection` does not exist**, despite what
18
+ > `Documentation/clients/dotnet/getting-started.md:61` shows. The real extensions
19
+ > are on `IHostApplicationBuilder`, `WebApplicationBuilder` (in the AspNetCore
20
+ > package), and Aspire's `IDistributedApplicationBuilder`. `IHostBuilder.AddCratisChronicle()`
21
+ > also exists but only registers concept type converters
22
+ > (`Source/Clients/DotNET/Hosting/HostBuilderExtensions.cs:18-23`) — it is not
23
+ > the wiring entry point.
24
+
25
+ `IChronicleBuilder` extensions are exactly five:
26
+ `WithArtifactsProvider`, `WithIdentityProvider`, `WithCorrelationIdAccessor`,
27
+ `WithNamespaceResolver`, `WithCamelCaseNamingPolicy`
28
+ (`Source/Clients/DotNET/ChronicleBuilderExtensions.cs`). **There is no
29
+ `WithClaimsBasedNamespaceResolver`**, despite a doc comment at
30
+ `ChronicleOptions.cs:141` referring to one. Pass the resolver instead:
31
+ `new ChronicleClient(options, namespaceResolver: new ClaimsBasedNamespaceResolver("tenant_id"))`.
@@ -125,6 +125,54 @@ depends on it, and nothing is left holding a dead channel.
125
125
  Pass `name:` to `Chronicle.Client` and `client:` to every API call. Every public
126
126
  function takes a `:client` option.
127
127
 
128
+ ## Connecting is asynchronous — wait for the lifecycle
129
+
130
+ The client connects in the background. `Chronicle.Connections.Lifecycle`
131
+ broadcasts `{:chronicle_lifecycle, phase, connection_id}` with three phases
132
+ (`lib/chronicle/connections/lifecycle.ex:54`):
133
+
134
+ | Phase | Meaning |
135
+ | --- | --- |
136
+ | `:disconnected` | no live session with the kernel |
137
+ | `:connected` | the session handshake completed |
138
+ | `:registered` | the registration coordinator registered the base artifacts |
139
+
140
+ **Wait for `:registered`, never merely `:connected`** — the module's own docs say
141
+ so at `:27-29`, because reducers and reactors are not attached until registration
142
+ finishes.
143
+
144
+ ```elixir
145
+ config = Chronicle.Client.config()
146
+
147
+ case Chronicle.Connections.Lifecycle.wait_until(config.lifecycle, :registered, 30_000) do
148
+ :ok -> :ok
149
+ {:error, :timeout} -> # decide what a not-yet-registered client means for you
150
+ end
151
+ ```
152
+
153
+ `wait_until(lifecycle, target_phase, timeout \\ 30_000)` is at `:141`.
154
+ `subscribe/1` (`:90`) returns the current phase **and** sends it as a message,
155
+ which closes the subscribe-after-transition race; `phase/1` (`:98`) is the plain
156
+ read.
157
+
158
+ ## Keepalive — the failure mode is silence
159
+
160
+ The contract is spelled out in `lib/chronicle/connections/keep_alive.ex:7-17`:
161
+ the kernel pushes a `ConnectionKeepAlive` down the `Connect` server stream once
162
+ per second, and for each one **the client must call back the separate unary
163
+ `ConnectionKeepAlive` RPC** (`answer/2` at `:56`). A client that only consumes the
164
+ stream is evicted once the kernel's `LastSeen` falls more than five seconds
165
+ behind, and the kernel then unsubscribes its observers.
166
+
167
+ The consequence is stated in that same comment and is worth carrying into any
168
+ diagnosis: **reactors and reducers go quiet while the `Connect` stream stays open
169
+ and every append keeps working.** Nothing raises. If observers stop firing but
170
+ appends succeed, look at the connection before you look at the observer.
171
+
172
+ Reconnect is exponential backoff — `:retry_attempts` 5, `:reconnect_base_delay`
173
+ 1000 ms, `:reconnect_max_delay` 10000 ms — re-resolving addresses on every
174
+ attempt.
175
+
128
176
  ## Connection strings
129
177
 
130
178
  `Chronicle.Connections.ConnectionString` accepts `chronicle://` and
@@ -205,21 +253,8 @@ raises at compile time.
205
253
  sequence number, and `append_and_wait_for_completion/3` exists for when you need
206
254
  the outcome.
207
255
 
208
- | Function | Arity | Line in `event_log.ex` |
209
- | --- | --- | --- |
210
- | `append/3` | `(event_source_id, event, opts)` | `:99` |
211
- | `append_many/3` | `(event_source_id, events, opts)` | `:120` |
212
- | `append_many_for_event_sources/2` | `(events, opts)` | `:155` |
213
- | `append_and_wait_for_completion/3` | returns `{:ok, %{success: _, failed_partitions: _}}` | `:215` |
214
- | `get_for_event_source/2` | | `:326` |
215
- | `get_from_sequence_number/2` | | `:369` |
216
- | `get_tail_sequence_number/2` | | `:408` |
217
-
218
- Append options (`event_log.ex:79-94`, plus `:occurred` read at `:720`): `:client`, `:namespace`,
219
- `:event_sequence_id` (default `"event-log"`), `:event_source_type` (default
220
- `"Default"`), `:event_stream_type` (default **`"All"`**), `:event_stream_id`
221
- (default `"Default"`), `:tags`, `:subject`, `:correlation_id`, `:identity`,
222
- `:causation`, `:concurrency_scope`, `:occurred`.
256
+ The other append functions (`append_many/3`, `append_many_for_event_sources/2`, `append_and_wait_for_completion/3`, the `get_*` readers) and the full option list are in the reference.
257
+ Read [references/append-api.md](references/append-api.md) when you need an append variant, a read-back function, or an append option such as `:event_stream_type`, `:concurrency_scope` or `:tags`.
223
258
 
224
259
  Errors are normalized to one of two shapes:
225
260
 
@@ -313,75 +348,9 @@ process**, so the reduction is Elixir code you own.
313
348
 
314
349
  #### Variants — mutually exclusive read models for one entity's lifecycle
315
350
 
316
- > Requires `cratis_chronicle` `3.4.0` or later — newer than this skill's
317
- > `3.1.0` baseline (`lib/chronicle/projections/variant_reclassifier.ex` and
318
- > siblings). Reverify before claiming support; take the version from hex.pm.
319
-
320
- Some entities do not have one shape for their whole lifetime — a work item is a
321
- backlog entry until a pull request exists for it, then it is a pull request
322
- until it merges. `variant_of/2` and `enters_on/1,2` are macros imported by
323
- **both** `use Chronicle.ReadModels.ReadModel` and
324
- `use Chronicle.Projections.Projection`, so the model-bound and declarative
325
- paths declare a variant identically:
326
-
327
- ```elixir
328
- defmodule MyApp.ReadModels.WorkItem do
329
- end
330
-
331
- defmodule MyApp.ReadModels.BacklogItem do
332
- use Chronicle.ReadModels.ReadModel
333
- defstruct id: nil, title: nil
334
-
335
- variant_of MyApp.ReadModels.WorkItem, key: :id
336
- enters_on MyApp.Events.IssueCreated
337
-
338
- from MyApp.Events.IssueCreated, set: [id: :event_source_id, title: :title]
339
- end
340
-
341
- defmodule MyApp.ReadModels.PullRequestItem do
342
- use Chronicle.ReadModels.ReadModel
343
- defstruct id: nil, pull_request_url: nil, build_status: nil
344
-
345
- variant_of MyApp.ReadModels.WorkItem, key: :id
346
- enters_on MyApp.Events.PullRequestCreated
351
+ Requires `cratis_chronicle` `3.4.0` or later (newer than this skill's `3.1.0` baseline). `variant_of/2` requires `:key`; a variant with no `enters_on` raises `Chronicle.Projections.VariantMustDeclareEntersOnEvent` at registration.
347
352
 
348
- from MyApp.Events.PullRequestCreated,
349
- set: [id: :event_source_id, pull_request_url: :pull_request_url]
350
-
351
- # not the entering event -> automatically reclassified into an update-only join
352
- from MyApp.Events.BuildCompleted, set: [build_status: :build_status]
353
- end
354
- ```
355
-
356
- `variant_of/2` takes `:key` — **required** — the field on this variant that
357
- carries the shared identity. `enters_on/1,2` is repeatable and its own `:key`
358
- option names an *event* property (defaults to `:event_source_id`); every
359
- `from`/`join` this variant declares for a non-entering event, whether declared
360
- locally or merged from a shared handler, is automatically reclassified into an
361
- update-only join keyed on `variant_of`'s `:key`.
362
-
363
- A mapping shared across every variant of an identity is a
364
- `Chronicle.Projections.GlobalHandler`, never registered as a projection on its
365
- own:
366
-
367
- ```elixir
368
- defmodule MyApp.Projections.WorkItemTitleHandler do
369
- use Chronicle.Projections.GlobalHandler, identity: MyApp.ReadModels.WorkItem
370
-
371
- from MyApp.Events.TitleChanged, set: [title: :title]
372
- end
373
- ```
374
-
375
- Register it explicitly with `global_handlers: [...]` on `Chronicle.Client`, or
376
- let `:otp_app` auto-discovery find it (modules exporting
377
- `__chronicle_global_handler__/1`). A mapping that targets a field some variant
378
- lacks raises `Chronicle.Projections.GlobalHandlerPropertyNotOnVariant` at
379
- registration, not a silently skipped mapping.
380
-
381
- **A variant with no `enters_on` raises
382
- `Chronicle.Projections.VariantMustDeclareEntersOnEvent`** at registration — a
383
- variant that could never be entered could never be written to at all, since
384
- every other handler on it is update-only.
353
+ Read [references/variants.md](references/variants.md) when an entity has mutually exclusive lifecycle shapes (for example a backlog entry that becomes a pull request) and you need variant read models or a `GlobalHandler`.
385
354
 
386
355
  Querying (`lib/chronicle/read_models.ex`):
387
356
 
@@ -402,54 +371,6 @@ Querying (`lib/chronicle/read_models.ex`):
402
371
  is the Elixir analogue of the other clients' observable APIs, and it means the
403
372
  receiving process must have a `handle_info` for both.
404
373
 
405
- ## Connecting is asynchronous — wait for the lifecycle
406
-
407
- The client connects in the background. `Chronicle.Connections.Lifecycle`
408
- broadcasts `{:chronicle_lifecycle, phase, connection_id}` with three phases
409
- (`lib/chronicle/connections/lifecycle.ex:54`):
410
-
411
- | Phase | Meaning |
412
- | --- | --- |
413
- | `:disconnected` | no live session with the kernel |
414
- | `:connected` | the session handshake completed |
415
- | `:registered` | the registration coordinator registered the base artifacts |
416
-
417
- **Wait for `:registered`, never merely `:connected`** — the module's own docs say
418
- so at `:27-29`, because reducers and reactors are not attached until registration
419
- finishes.
420
-
421
- ```elixir
422
- config = Chronicle.Client.config()
423
-
424
- case Chronicle.Connections.Lifecycle.wait_until(config.lifecycle, :registered, 30_000) do
425
- :ok -> :ok
426
- {:error, :timeout} -> # decide what a not-yet-registered client means for you
427
- end
428
- ```
429
-
430
- `wait_until(lifecycle, target_phase, timeout \\ 30_000)` is at `:141`.
431
- `subscribe/1` (`:90`) returns the current phase **and** sends it as a message,
432
- which closes the subscribe-after-transition race; `phase/1` (`:98`) is the plain
433
- read.
434
-
435
- ## Keepalive — the failure mode is silence
436
-
437
- The contract is spelled out in `lib/chronicle/connections/keep_alive.ex:7-17`:
438
- the kernel pushes a `ConnectionKeepAlive` down the `Connect` server stream once
439
- per second, and for each one **the client must call back the separate unary
440
- `ConnectionKeepAlive` RPC** (`answer/2` at `:56`). A client that only consumes the
441
- stream is evicted once the kernel's `LastSeen` falls more than five seconds
442
- behind, and the kernel then unsubscribes its observers.
443
-
444
- The consequence is stated in that same comment and is worth carrying into any
445
- diagnosis: **reactors and reducers go quiet while the `Connect` stream stays open
446
- and every append keeps working.** Nothing raises. If observers stop firing but
447
- appends succeed, look at the connection before you look at the observer.
448
-
449
- Reconnect is exponential backoff — `:retry_attempts` 5, `:reconnect_base_delay`
450
- 1000 ms, `:reconnect_max_delay` 10000 ms — re-resolving addresses on every
451
- attempt.
452
-
453
374
  ## Idioms worth knowing
454
375
 
455
376
  - **Process-scoped context.** Correlation id, identity, and causation are held per
@@ -0,0 +1,19 @@
1
+ # Append API
2
+
3
+ ## Append functions and options
4
+
5
+ | Function | Arity | Line in `event_log.ex` |
6
+ | --- | --- | --- |
7
+ | `append/3` | `(event_source_id, event, opts)` | `:99` |
8
+ | `append_many/3` | `(event_source_id, events, opts)` | `:120` |
9
+ | `append_many_for_event_sources/2` | `(events, opts)` | `:155` |
10
+ | `append_and_wait_for_completion/3` | returns `{:ok, %{success: _, failed_partitions: _}}` | `:215` |
11
+ | `get_for_event_source/2` | | `:326` |
12
+ | `get_from_sequence_number/2` | | `:369` |
13
+ | `get_tail_sequence_number/2` | | `:408` |
14
+
15
+ Append options (`event_log.ex:79-94`, plus `:occurred` read at `:720`): `:client`, `:namespace`,
16
+ `:event_sequence_id` (default `"event-log"`), `:event_source_type` (default
17
+ `"Default"`), `:event_stream_type` (default **`"All"`**), `:event_stream_id`
18
+ (default `"Default"`), `:tags`, `:subject`, `:correlation_id`, `:identity`,
19
+ `:causation`, `:concurrency_scope`, `:occurred`.
@@ -0,0 +1,73 @@
1
+ # Variants
2
+
3
+ ## Variants — mutually exclusive read models for one entity's lifecycle
4
+
5
+ > Requires `cratis_chronicle` `3.4.0` or later — newer than this skill's
6
+ > `3.1.0` baseline (`lib/chronicle/projections/variant_reclassifier.ex` and
7
+ > siblings). Reverify before claiming support; take the version from hex.pm.
8
+
9
+ Some entities do not have one shape for their whole lifetime — a work item is a
10
+ backlog entry until a pull request exists for it, then it is a pull request
11
+ until it merges. `variant_of/2` and `enters_on/1,2` are macros imported by
12
+ **both** `use Chronicle.ReadModels.ReadModel` and
13
+ `use Chronicle.Projections.Projection`, so the model-bound and declarative
14
+ paths declare a variant identically:
15
+
16
+ ```elixir
17
+ defmodule MyApp.ReadModels.WorkItem do
18
+ end
19
+
20
+ defmodule MyApp.ReadModels.BacklogItem do
21
+ use Chronicle.ReadModels.ReadModel
22
+ defstruct id: nil, title: nil
23
+
24
+ variant_of MyApp.ReadModels.WorkItem, key: :id
25
+ enters_on MyApp.Events.IssueCreated
26
+
27
+ from MyApp.Events.IssueCreated, set: [id: :event_source_id, title: :title]
28
+ end
29
+
30
+ defmodule MyApp.ReadModels.PullRequestItem do
31
+ use Chronicle.ReadModels.ReadModel
32
+ defstruct id: nil, pull_request_url: nil, build_status: nil
33
+
34
+ variant_of MyApp.ReadModels.WorkItem, key: :id
35
+ enters_on MyApp.Events.PullRequestCreated
36
+
37
+ from MyApp.Events.PullRequestCreated,
38
+ set: [id: :event_source_id, pull_request_url: :pull_request_url]
39
+
40
+ # not the entering event -> automatically reclassified into an update-only join
41
+ from MyApp.Events.BuildCompleted, set: [build_status: :build_status]
42
+ end
43
+ ```
44
+
45
+ `variant_of/2` takes `:key` — **required** — the field on this variant that
46
+ carries the shared identity. `enters_on/1,2` is repeatable and its own `:key`
47
+ option names an *event* property (defaults to `:event_source_id`); every
48
+ `from`/`join` this variant declares for a non-entering event, whether declared
49
+ locally or merged from a shared handler, is automatically reclassified into an
50
+ update-only join keyed on `variant_of`'s `:key`.
51
+
52
+ A mapping shared across every variant of an identity is a
53
+ `Chronicle.Projections.GlobalHandler`, never registered as a projection on its
54
+ own:
55
+
56
+ ```elixir
57
+ defmodule MyApp.Projections.WorkItemTitleHandler do
58
+ use Chronicle.Projections.GlobalHandler, identity: MyApp.ReadModels.WorkItem
59
+
60
+ from MyApp.Events.TitleChanged, set: [title: :title]
61
+ end
62
+ ```
63
+
64
+ Register it explicitly with `global_handlers: [...]` on `Chronicle.Client`, or
65
+ let `:otp_app` auto-discovery find it (modules exporting
66
+ `__chronicle_global_handler__/1`). A mapping that targets a field some variant
67
+ lacks raises `Chronicle.Projections.GlobalHandlerPropertyNotOnVariant` at
68
+ registration, not a silently skipped mapping.
69
+
70
+ **A variant with no `enters_on` raises
71
+ `Chronicle.Projections.VariantMustDeclareEntersOnEvent`** at registration — a
72
+ variant that could never be entered could never be written to at all, since
73
+ every other handler on it is update-only.