@cratis/pi 7.51.3 → 7.51.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/harnesses/copilot/instructions/authoring-skills.instructions.md +1 -1
- package/package/corpus/rules/authoring-skills.md +1 -1
- package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +4 -55
- package/package/corpus/skills/cratis-application-slice-specifications/references/command-result-assertions.md +36 -0
- package/package/corpus/skills/cratis-application-slice-specifications/references/reading-play-specifications.md +30 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/SKILL.md +4 -69
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authentication.md +8 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authorization.md +9 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/frontend.md +19 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/identity-endpoints.md +40 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/local-development.md +7 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/product-sources.md +11 -0
- package/package/corpus/skills/cratis-arc-command/SKILL.md +8 -99
- package/package/corpus/skills/cratis-arc-command/references/causation-details.md +26 -0
- package/package/corpus/skills/cratis-arc-command/references/client-contract.md +16 -0
- package/package/corpus/skills/cratis-arc-command/references/event-source-id-details.md +13 -0
- package/package/corpus/skills/cratis-arc-command/references/generation-boundaries.md +8 -0
- package/package/corpus/skills/cratis-arc-command/references/product-sources.md +16 -0
- package/package/corpus/skills/cratis-arc-command/references/provide-example.md +19 -0
- package/package/corpus/skills/cratis-arc-command/references/proxy-generation.md +8 -0
- package/package/corpus/skills/cratis-arc-command/references/return-shape-examples.md +24 -0
- package/package/corpus/skills/cratis-arc-command-kotlin/SKILL.md +3 -61
- package/package/corpus/skills/cratis-arc-command-kotlin/references/artifacts.md +16 -0
- package/package/corpus/skills/cratis-arc-command-kotlin/references/authorization-override-example.md +17 -0
- package/package/corpus/skills/cratis-arc-command-kotlin/references/project-setup.md +40 -0
- package/package/corpus/skills/cratis-arc-command-typescript/SKILL.md +4 -105
- package/package/corpus/skills/cratis-arc-command-typescript/references/parameter-binding.md +26 -0
- package/package/corpus/skills/cratis-arc-command-typescript/references/project-setup.md +89 -0
- package/package/corpus/skills/cratis-arc-query-typescript/SKILL.md +3 -74
- package/package/corpus/skills/cratis-arc-query-typescript/references/product-sources.md +11 -0
- package/package/corpus/skills/cratis-arc-query-typescript/references/scenario-example.md +23 -0
- package/package/corpus/skills/cratis-arc-query-typescript/references/storage-examples.md +52 -0
- package/package/corpus/skills/cratis-arc-react-page/SKILL.md +3 -63
- package/package/corpus/skills/cratis-arc-react-page/references/data-page.md +28 -0
- package/package/corpus/skills/cratis-arc-react-page/references/dialogs.md +47 -0
- package/package/corpus/skills/cratis-chronicle-client-dotnet/SKILL.md +3 -80
- package/package/corpus/skills/cratis-chronicle-client-dotnet/references/connection-options.md +61 -0
- package/package/corpus/skills/cratis-chronicle-client-dotnet/references/lifecycle.md +30 -0
- package/package/corpus/skills/cratis-chronicle-client-elixir/SKILL.md +8 -101
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/client-options.md +43 -0
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/idioms-and-inspection.md +35 -0
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/product-sources.md +10 -0
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/reactor-example.md +33 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/SKILL.md +7 -88
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/annotations-and-handlers.md +32 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/append-concurrency.md +9 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/connection-string.md +27 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/event-type-annotations.md +9 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/product-sources.md +13 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/read-models-and-projections.md +29 -0
- package/package/corpus/skills/cratis-chronicle-client-typescript/SKILL.md +3 -103
- package/package/corpus/skills/cratis-chronicle-client-typescript/references/connection-options.md +52 -0
- package/package/corpus/skills/cratis-chronicle-client-typescript/references/lifecycle.md +31 -0
- package/package/corpus/skills/cratis-chronicle-client-typescript/references/project-setup.md +36 -0
- package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +1 -21
- package/package/corpus/skills/cratis-chronicle-projection/references/definition-changes.md +27 -0
- package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +5 -110
- package/package/corpus/skills/cratis-chronicle-reactor/references/cross-service-events.md +13 -0
- package/package/corpus/skills/cratis-chronicle-reactor/references/filtering.md +34 -0
- package/package/corpus/skills/cratis-chronicle-reactor/references/read-model-injection.md +29 -0
- package/package/corpus/skills/cratis-chronicle-reactor/references/return-event-metadata.md +51 -0
- package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +7 -92
- package/package/corpus/skills/cratis-chronicle-reducer/references/filtering.md +36 -0
- package/package/corpus/skills/cratis-chronicle-reducer/references/instance-reducer-example.md +20 -0
- package/package/corpus/skills/cratis-chronicle-reducer/references/product-sources.md +8 -0
- package/package/corpus/skills/cratis-chronicle-reducer/references/replay-hooks-and-definition-changes.md +35 -0
- package/package/corpus/skills/cratis-chronicle-reducer/references/specification-example.md +15 -0
- package/package/corpus/skills/cratis-components-styling/SKILL.md +1 -15
- package/package/corpus/skills/cratis-components-styling/references/renderer-adapters.md +21 -0
- package/package/corpus/skills/cratis-governed-release-methodology/SKILL.md +1 -24
- package/package/corpus/skills/cratis-governed-release-methodology/references/lifecycle-phases.md +30 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/SKILL.md +2 -15
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/neighbouring-skills.md +12 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/product-sources.md +11 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +3 -93
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/capture-map-and-example.md +37 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/trigger-declaration.md +48 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/trigger-reads-example.md +16 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +5 -97
- package/package/corpus/skills/cratis-screenplay-command-surface/references/compliance.md +9 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/constraints-produces-concurrency.md +89 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/routes-and-external-operations.md +21 -0
- package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +5 -38
- package/package/corpus/skills/cratis-screenplay-discovery/references/interview-questions.md +14 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/neighbouring-skills.md +14 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/plotting-and-handoff.md +9 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/product-sources.md +16 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +6 -74
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/facilitation-stance.md +12 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/file-layout.md +19 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/modeling-reasoning.md +13 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/neighbouring-skills.md +16 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/parsed-not-runnable.md +33 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/provenance.md +6 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/SKILL.md +2 -17
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/interview-findings.md +18 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/neighbouring-skills.md +12 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +5 -89
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +6 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/layout.md +30 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/repairs.md +42 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/state-and-recovery.md +30 -0
- package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +10 -42
- package/package/corpus/skills/cratis-screenplay-model-review/references/baseline-comparison.md +7 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/business-questions.md +11 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/interview-batch.md +14 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/model-inventory-report.md +8 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/neighbouring-skills.md +12 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/report-template.md +21 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +15 -68
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/completeness-self-check.md +12 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/handoff-template.md +15 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/identity-and-edits.md +9 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/independent-review.md +10 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/neighbouring-skills.md +10 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/per-turn-protocol.md +5 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/product-sources.md +9 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/safety.md +12 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/stop-or-assume.md +25 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/verdicts-and-modes.md +8 -0
- package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +3 -67
- package/package/corpus/skills/cratis-screenplay-projections/references/joins.md +41 -0
- package/package/corpus/skills/cratis-screenplay-projections/references/variants.md +41 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +3 -31
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/delivery-protocol.md +9 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/neighbouring-skills.md +11 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/product-sources.md +23 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/SKILL.md +11 -75
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/interview-batch.md +16 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/neighbouring-skills.md +10 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/public-event-coverage.md +12 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/quality-checklist.md +17 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/review-questions.md +9 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md +28 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/version-skew.md +14 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/SKILL.md +18 -94
- package/package/corpus/skills/cratis-screenplay-slice-design/references/command-inventory.md +25 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/field-lineage.md +9 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/identity-edits.md +14 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/model-reasoning.md +9 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/neighbouring-skills.md +10 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/product-sources.md +9 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/public-boundaries-and-keys.md +16 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/read-model-design.md +36 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/slicing.md +17 -0
- package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +5 -63
- package/package/corpus/skills/cratis-screenplay-specifications/references/examples-and-routes.md +6 -0
- package/package/corpus/skills/cratis-screenplay-specifications/references/outcome-comparison.md +33 -0
- package/package/corpus/skills/cratis-screenplay-specifications/references/vocabulary.md +40 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/SKILL.md +11 -77
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/consistency-and-concurrency.md +21 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/evolution.md +18 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/interview-batch.md +20 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/neighbouring-skills.md +12 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/product-sources.md +12 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/review-questions.md +13 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/stream-id-rules.md +15 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +1 -8
- package/package/corpus/skills/cratis-screenplay-toolchain/references/neighbouring-skills.md +12 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +6 -99
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/file-references.md +38 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/layout-arrangement.md +31 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/localized-strings.md +15 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/screen-composition-contract.md +6 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/ui-profile-and-theme.md +34 -0
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +1 -10
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/neighbouring-skills.md +14 -0
- package/package.json +1 -1
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Reactor and read model examples
|
|
2
|
+
|
|
3
|
+
This reference holds a worked reactor module and a worked model-bound read model.
|
|
4
|
+
|
|
5
|
+
```elixir
|
|
6
|
+
defmodule MyApp.Reactors.DepositLogger do
|
|
7
|
+
use Chronicle.Reactors.Reactor
|
|
8
|
+
require Logger
|
|
9
|
+
|
|
10
|
+
alias MyApp.Events.FundsDeposited
|
|
11
|
+
@handles FundsDeposited
|
|
12
|
+
|
|
13
|
+
@impl true
|
|
14
|
+
def handle(%FundsDeposited{}, %{sequence_number: number}) do
|
|
15
|
+
Logger.info("Deposit observed", sequence_number: number)
|
|
16
|
+
:ok
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Read model example
|
|
22
|
+
|
|
23
|
+
```elixir
|
|
24
|
+
defmodule MyApp.ReadModels.AccountBalance do
|
|
25
|
+
use Chronicle.ReadModels.ReadModel
|
|
26
|
+
defstruct id: "", balance: 0
|
|
27
|
+
|
|
28
|
+
from(MyApp.Events.FundsDeposited,
|
|
29
|
+
set: [id: :event_source_id],
|
|
30
|
+
add: [balance: :amount]
|
|
31
|
+
)
|
|
32
|
+
end
|
|
33
|
+
```
|
|
@@ -15,15 +15,7 @@ you construct a client, ask it for an event store, and append or observe.
|
|
|
15
15
|
|
|
16
16
|
Source: `Cratis/Chronicle.Kotlin`, by source symbols and signatures.
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
| --- | --- |
|
|
20
|
-
| `io.cratis:chronicle` | `Chronicle.Kotlin` |
|
|
21
|
-
| `io.cratis:chronicle-spring-boot-starter` | `Integrations/SpringBoot` |
|
|
22
|
-
| `io.cratis:chronicle-testing` | `Testing` |
|
|
23
|
-
| `io.cratis:chronicle-contracts` | `Source/build.gradle.kts` (`chronicleContractsVersion`) |
|
|
24
|
-
|
|
25
|
-
All three artifacts are published to Maven Central under `io.cratis` (their
|
|
26
|
-
`build.gradle.kts` publishing blocks). The JVM toolchain is **17**.
|
|
18
|
+
Read [references/product-sources.md](references/product-sources.md) when you need the artifacts and their source modules.
|
|
27
19
|
|
|
28
20
|
> **Do not copy a version number out of the repository's README or docs.**
|
|
29
21
|
> The version comes from a Gradle property injected at release time —
|
|
@@ -102,29 +94,7 @@ Narrow discovery with `withArtifactsFrom(vararg packages)` in a large app.
|
|
|
102
94
|
Read [references/options.md](references/options.md) when setting naming policy,
|
|
103
95
|
registration, artifact activation, sink type or OpenTelemetry options.
|
|
104
96
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
`ChronicleConnectionString.kt` documents the grammar:
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
chronicle://<host>[:<port>][,<host>[:<port>]...][?<options>]
|
|
111
|
-
chronicle://<username>:<password>@<host>[:<port>][,...][?<options>]
|
|
112
|
-
chronicle+srv://<host>[:<port>][?<options>]
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
Default port is `35000`. Recognized query keys, lowercased at parse time
|
|
116
|
-
(`ChronicleConnectionString` parser): `disabletls`, `skiptlsvalidation`,
|
|
117
|
-
`loadbalancer`, `srvnameserver`. `apiKey` is parsed but rejected at client
|
|
118
|
-
creation with `IllegalArgumentException`: the kernel has no API-key authentication.
|
|
119
|
-
Use `user:password@`. Omitting credentials selects `chronicle-dev-client` /
|
|
120
|
-
`chronicle-dev-secret`; these are development credentials, not a production setup. `ChronicleConnectionString.parse(String)` is on the companion, and `ChronicleConnectionString.DEVELOPMENT` points at
|
|
121
|
-
`localhost:35000` with the `chronicle-dev-client` / `chronicle-dev-secret`
|
|
122
|
-
credentials.
|
|
123
|
-
|
|
124
|
-
> **TLS is on, certificate validation is off by default** (`disableTls = false`,
|
|
125
|
-
> `skipTlsValidation = true`), for a self-signed development kernel.
|
|
126
|
-
> **Production must set `?skipTlsValidation=false`** for platform trust-store
|
|
127
|
-
> chain validation (`ChronicleConnectionString.createCredentials`).
|
|
97
|
+
Read [references/connection-string.md](references/connection-string.md) when writing a connection string or choosing credentials. A production string must set `?skipTlsValidation=false`; `apiKey` is rejected at client creation.
|
|
128
98
|
|
|
129
99
|
### Spring Boot
|
|
130
100
|
|
|
@@ -159,11 +129,7 @@ annotation class EventType(
|
|
|
159
129
|
Two event classes with the same simple name in different packages therefore
|
|
160
130
|
collide on the wire. Give one an explicit `id`.
|
|
161
131
|
|
|
162
|
-
|
|
163
|
-
`record` (the Spring Boot samples). Property-level
|
|
164
|
-
annotations that travel with the event: `@io.cratis.chronicle.keys.Key`,
|
|
165
|
-
`@io.cratis.chronicle.compliance.Pii`, `@io.cratis.chronicle.Subject`,
|
|
166
|
-
`@io.cratis.chronicle.schemas.JsonSchemaType`.
|
|
132
|
+
Read [references/event-type-annotations.md](references/event-type-annotations.md) when choosing an event class shape or its property annotations.
|
|
167
133
|
|
|
168
134
|
`@Pii` on a `ConceptAs` type is declared once and cascades to its uses.
|
|
169
135
|
For operational secrets (API keys, partner credentials), use
|
|
@@ -226,11 +192,7 @@ legacy route by passing all three explicitly. Reads narrow only by supplied
|
|
|
226
192
|
filters; single-source `appendMany` applies the routing options to every event.
|
|
227
193
|
See the product's `Documentation/guides/migrate-append-routing.md`.
|
|
228
194
|
|
|
229
|
-
|
|
230
|
-
`ConcurrencyScopeBuilder.withExpectsNoMatchingEvent()`. The equivalent is
|
|
231
|
-
`ConcurrencyScope(EventSequenceNumber.unavailable, eventSourceId = true,
|
|
232
|
-
expectsNoMatchingEvent = true)`; a concrete sequence number and this flag are
|
|
233
|
-
mutually exclusive (package `eventSequences.concurrency`).
|
|
195
|
+
Read [references/append-concurrency.md](references/append-concurrency.md) when an append must be an idempotent create (`withExpectsNoMatchingEvent()`).
|
|
234
196
|
|
|
235
197
|
Event-source definitions and their named streams are optional, discovered
|
|
236
198
|
artifacts (kernel requirement above).
|
|
@@ -279,58 +241,15 @@ triggering event source. A returned `List` is one atomic batch: one rejected
|
|
|
279
241
|
event rejects all — `observation/ReactorSideEffects.kt`.
|
|
280
242
|
This is how a reactor appends without ever touching the event log.
|
|
281
243
|
|
|
282
|
-
|
|
283
|
-
`eventType`, `occurred`, `correlationId`, `causedBy`, `eventSourceType`,
|
|
284
|
-
`eventStreamType`, `eventStreamId`, `eventStore`, `namespace`, `causation`,
|
|
285
|
-
`tags`, `hash`, `observationState`, `subject`, `eventSource` —
|
|
286
|
-
`events/EventContext.kt`. Recompile when the constructor changes.
|
|
244
|
+
Read [references/annotations-and-handlers.md](references/annotations-and-handlers.md#eventcontext) when you need the `EventContext` fields.
|
|
287
245
|
|
|
288
246
|
### The annotations
|
|
289
247
|
|
|
290
|
-
|
|
291
|
-
| --- | --- | --- |
|
|
292
|
-
| `@Reactor` | `id = ""`, `eventSequence = ""` | `observation/Reactor.kt` |
|
|
293
|
-
| `@Reducer` | `id = ""`, `eventSequence = ""`, `isActive = true` | `observation/Reducer.kt` |
|
|
294
|
-
| `@ReadModel` | `id = ""`, `displayName = ""` | `readModels/ReadModel.kt` |
|
|
295
|
-
| `@Projection` | `id = ""`, `eventSequence = ""` — optional | `projections/Projection.kt` |
|
|
296
|
-
| `@Constraint` | `id = ""` | `constraints/Constraint.kt` |
|
|
297
|
-
| `@Seeder` | none | `seeding/Seeder.kt` |
|
|
298
|
-
|
|
299
|
-
Handler-level: `@Replay`, `@OnceOnly`. Observer filtering: `@Tag`/`@Tags`,
|
|
300
|
-
`@FilterEventsByTag`/`@FilterEventsByTags`, `@EventSequence`,
|
|
301
|
-
`@EventSourceType`, `@EventStreamType`.
|
|
302
|
-
|
|
303
|
-
A reducer's handler may be `(event)`, `(event, state)`, or
|
|
304
|
-
`(event, state, context)` — the three shapes accepted by the dispatcher and by
|
|
305
|
-
`ReadModelScenario` (`Testing/.../ReadModelScenario.kt`). **Reducers run
|
|
306
|
-
client-side**: the kernel streams events and the handler is invoked in your
|
|
307
|
-
process (`observation/ReducersService.kt`).
|
|
248
|
+
Read [references/annotations-and-handlers.md](references/annotations-and-handlers.md) when choosing an observer annotation (`@Reactor`, `@Reducer`, `@ReadModel`, `@Projection`, `@Constraint`, `@Seeder`), its arguments, or the reducer handler shapes.
|
|
308
249
|
|
|
309
250
|
### Read models and model-bound projections
|
|
310
251
|
|
|
311
|
-
Read models
|
|
312
|
-
(`readModels/IReadModelsService.kt`): `getInstanceByKey(readModelClass, key): T?`,
|
|
313
|
-
`getInstances(readModelClass, eventCount)`,
|
|
314
|
-
`getSnapshotsById`, and `watch(readModelClass): Flow<ReadModelChangeset<T>>`
|
|
315
|
-
(which is **not** suspending — it hands back a `Flow`).
|
|
316
|
-
|
|
317
|
-
A model-bound projection puts the projection on the read model with `@FromEvent`
|
|
318
|
-
(`projections/FromEvent.kt`) and `@SetFrom`
|
|
319
|
-
(`projections/SetFrom.kt`); the full family also includes `SetValue`,
|
|
320
|
-
`SetFromContext`, `AddFrom`, `SubtractFrom`, `Increment`, `Decrement`, `Count`,
|
|
321
|
-
`Join`, `RemovedWith`, `RemovedWithJoin`, `ChildrenFrom`, `ClearWith`,
|
|
322
|
-
`FromAll`, `FromEvery`, `FromEventSourceId`, `CountFromAll`, `IncrementFromAll`,
|
|
323
|
-
`DecrementFromAll`, `Nested`, `NoAutoMap`, `NoAutoMapProperties`,
|
|
324
|
-
`NotRewindable`. The declarative
|
|
325
|
-
alternative is a class implementing `IProjectionFor<TReadModel>`.
|
|
326
|
-
Use fluent `set(...).toValue(...)` for a constant, or `toProperty(...)` for an
|
|
327
|
-
event property. `set(...).to { }` is deprecated: it never evaluated the lambda.
|
|
328
|
-
`noAutoMap()` is honored; composite key parts can use
|
|
329
|
-
`toEventContextProperty(targetPropertyName, contextProperty)`.
|
|
330
|
-
|
|
331
|
-
`@io.cratis.chronicle.readModels.Passive` and `@Reducer(isActive = false)`
|
|
332
|
-
compute a passive model from its events on read, so a read immediately after an
|
|
333
|
-
append includes that event rather than waiting for a materialized observer.
|
|
252
|
+
Read [references/read-models-and-projections.md](references/read-models-and-projections.md) when querying read models through `store.readModels`, declaring a model-bound or `IProjectionFor` projection, or needing a passive model for read-your-writes.
|
|
334
253
|
|
|
335
254
|
### Variants — mutually exclusive read models for one entity's lifecycle
|
|
336
255
|
|
package/package/corpus/skills/cratis-chronicle-client-kotlin/references/annotations-and-handlers.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Observer annotations and handler shapes
|
|
2
|
+
|
|
3
|
+
This reference holds the observer annotations, their arguments, filtering annotations and the reducer handler shapes.
|
|
4
|
+
|
|
5
|
+
### The annotations
|
|
6
|
+
|
|
7
|
+
| Annotation | Arguments | Source |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `@Reactor` | `id = ""`, `eventSequence = ""` | `observation/Reactor.kt` |
|
|
10
|
+
| `@Reducer` | `id = ""`, `eventSequence = ""`, `isActive = true` | `observation/Reducer.kt` |
|
|
11
|
+
| `@ReadModel` | `id = ""`, `displayName = ""` | `readModels/ReadModel.kt` |
|
|
12
|
+
| `@Projection` | `id = ""`, `eventSequence = ""` — optional | `projections/Projection.kt` |
|
|
13
|
+
| `@Constraint` | `id = ""` | `constraints/Constraint.kt` |
|
|
14
|
+
| `@Seeder` | none | `seeding/Seeder.kt` |
|
|
15
|
+
|
|
16
|
+
Handler-level: `@Replay`, `@OnceOnly`. Observer filtering: `@Tag`/`@Tags`,
|
|
17
|
+
`@FilterEventsByTag`/`@FilterEventsByTags`, `@EventSequence`,
|
|
18
|
+
`@EventSourceType`, `@EventStreamType`.
|
|
19
|
+
|
|
20
|
+
A reducer's handler may be `(event)`, `(event, state)`, or
|
|
21
|
+
`(event, state, context)` — the three shapes accepted by the dispatcher and by
|
|
22
|
+
`ReadModelScenario` (`Testing/.../ReadModelScenario.kt`). **Reducers run
|
|
23
|
+
client-side**: the kernel streams events and the handler is invoked in your
|
|
24
|
+
process (`observation/ReducersService.kt`).
|
|
25
|
+
|
|
26
|
+
## EventContext
|
|
27
|
+
|
|
28
|
+
`EventContext` is a data class with `sequenceNumber: Long`, `eventSourceId`,
|
|
29
|
+
`eventType`, `occurred`, `correlationId`, `causedBy`, `eventSourceType`,
|
|
30
|
+
`eventStreamType`, `eventStreamId`, `eventStore`, `namespace`, `causation`,
|
|
31
|
+
`tags`, `hash`, `observationState`, `subject`, `eventSource` —
|
|
32
|
+
`events/EventContext.kt`. Recompile when the constructor changes.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Append concurrency
|
|
2
|
+
|
|
3
|
+
This reference holds how to narrow a concurrency scope for an idempotent create.
|
|
4
|
+
|
|
5
|
+
For an idempotent create, narrow the concurrency scope and use
|
|
6
|
+
`ConcurrencyScopeBuilder.withExpectsNoMatchingEvent()`. The equivalent is
|
|
7
|
+
`ConcurrencyScope(EventSequenceNumber.unavailable, eventSourceId = true,
|
|
8
|
+
expectsNoMatchingEvent = true)`; a concrete sequence number and this flag are
|
|
9
|
+
mutually exclusive (package `eventSequences.concurrency`).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# The connection string
|
|
2
|
+
|
|
3
|
+
This reference holds the connection string grammar, query keys, development credentials and TLS defaults.
|
|
4
|
+
|
|
5
|
+
### The connection string
|
|
6
|
+
|
|
7
|
+
`ChronicleConnectionString.kt` documents the grammar:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
chronicle://<host>[:<port>][,<host>[:<port>]...][?<options>]
|
|
11
|
+
chronicle://<username>:<password>@<host>[:<port>][,...][?<options>]
|
|
12
|
+
chronicle+srv://<host>[:<port>][?<options>]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Default port is `35000`. Recognized query keys, lowercased at parse time
|
|
16
|
+
(`ChronicleConnectionString` parser): `disabletls`, `skiptlsvalidation`,
|
|
17
|
+
`loadbalancer`, `srvnameserver`. `apiKey` is parsed but rejected at client
|
|
18
|
+
creation with `IllegalArgumentException`: the kernel has no API-key authentication.
|
|
19
|
+
Use `user:password@`. Omitting credentials selects `chronicle-dev-client` /
|
|
20
|
+
`chronicle-dev-secret`; these are development credentials, not a production setup. `ChronicleConnectionString.parse(String)` is on the companion, and `ChronicleConnectionString.DEVELOPMENT` points at
|
|
21
|
+
`localhost:35000` with the `chronicle-dev-client` / `chronicle-dev-secret`
|
|
22
|
+
credentials.
|
|
23
|
+
|
|
24
|
+
> **TLS is on, certificate validation is off by default** (`disableTls = false`,
|
|
25
|
+
> `skipTlsValidation = true`), for a self-signed development kernel.
|
|
26
|
+
> **Production must set `?skipTlsValidation=false`** for platform trust-store
|
|
27
|
+
> chain validation (`ChronicleConnectionString.createCredentials`).
|
package/package/corpus/skills/cratis-chronicle-client-kotlin/references/event-type-annotations.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Event type annotations
|
|
2
|
+
|
|
3
|
+
This reference holds the house shape of an event class and the property-level annotations that travel with it.
|
|
4
|
+
|
|
5
|
+
The house shape is a Kotlin `data class` with defaulted properties or a Java
|
|
6
|
+
`record` (the Spring Boot samples). Property-level
|
|
7
|
+
annotations that travel with the event: `@io.cratis.chronicle.keys.Key`,
|
|
8
|
+
`@io.cratis.chronicle.compliance.Pii`, `@io.cratis.chronicle.Subject`,
|
|
9
|
+
`@io.cratis.chronicle.schemas.JsonSchemaType`.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Product sources
|
|
2
|
+
|
|
3
|
+
This reference holds the Chronicle.Kotlin artifacts and the source module each comes from.
|
|
4
|
+
|
|
5
|
+
| Artifact | Source |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| `io.cratis:chronicle` | `Chronicle.Kotlin` |
|
|
8
|
+
| `io.cratis:chronicle-spring-boot-starter` | `Integrations/SpringBoot` |
|
|
9
|
+
| `io.cratis:chronicle-testing` | `Testing` |
|
|
10
|
+
| `io.cratis:chronicle-contracts` | `Source/build.gradle.kts` (`chronicleContractsVersion`) |
|
|
11
|
+
|
|
12
|
+
All three artifacts are published to Maven Central under `io.cratis` (their
|
|
13
|
+
`build.gradle.kts` publishing blocks). The JVM toolchain is **17**.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Read models and model-bound projections
|
|
2
|
+
|
|
3
|
+
This reference holds the read model query surface, projection annotations, the declarative alternative and passive models.
|
|
4
|
+
|
|
5
|
+
### Read models and model-bound projections
|
|
6
|
+
|
|
7
|
+
Read models are queried through `store.readModels`
|
|
8
|
+
(`readModels/IReadModelsService.kt`): `getInstanceByKey(readModelClass, key): T?`,
|
|
9
|
+
`getInstances(readModelClass, eventCount)`,
|
|
10
|
+
`getSnapshotsById`, and `watch(readModelClass): Flow<ReadModelChangeset<T>>`
|
|
11
|
+
(which is **not** suspending — it hands back a `Flow`).
|
|
12
|
+
|
|
13
|
+
A model-bound projection puts the projection on the read model with `@FromEvent`
|
|
14
|
+
(`projections/FromEvent.kt`) and `@SetFrom`
|
|
15
|
+
(`projections/SetFrom.kt`); the full family also includes `SetValue`,
|
|
16
|
+
`SetFromContext`, `AddFrom`, `SubtractFrom`, `Increment`, `Decrement`, `Count`,
|
|
17
|
+
`Join`, `RemovedWith`, `RemovedWithJoin`, `ChildrenFrom`, `ClearWith`,
|
|
18
|
+
`FromAll`, `FromEvery`, `FromEventSourceId`, `CountFromAll`, `IncrementFromAll`,
|
|
19
|
+
`DecrementFromAll`, `Nested`, `NoAutoMap`, `NoAutoMapProperties`,
|
|
20
|
+
`NotRewindable`. The declarative
|
|
21
|
+
alternative is a class implementing `IProjectionFor<TReadModel>`.
|
|
22
|
+
Use fluent `set(...).toValue(...)` for a constant, or `toProperty(...)` for an
|
|
23
|
+
event property. `set(...).to { }` is deprecated: it never evaluated the lambda.
|
|
24
|
+
`noAutoMap()` is honored; composite key parts can use
|
|
25
|
+
`toEventContextProperty(targetPropertyName, contextProperty)`.
|
|
26
|
+
|
|
27
|
+
`@io.cratis.chronicle.readModels.Passive` and `@Reducer(isActive = false)`
|
|
28
|
+
compute a passive model from its events on read, so a read immediately after an
|
|
29
|
+
append includes that event rather than waiting for a materialized observer.
|
|
@@ -58,36 +58,7 @@ Requires `@cratis/chronicle` 6.49.0, Chronicle kernel 19.30.0 and `@cratis/chron
|
|
|
58
58
|
|
|
59
59
|
## Project setup
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
yarn add @cratis/chronicle @cratis/fundamentals reflect-metadata
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
`@cratis/fundamentals` is a peer dependency, so it does not arrive on its own.
|
|
66
|
-
`reflect-metadata` is now a regular dependency. Import it **once, at the entry
|
|
67
|
-
point**, before any decorated class is loaded:
|
|
68
|
-
|
|
69
|
-
```typescript
|
|
70
|
-
import 'reflect-metadata';
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
The package is **ESM-only** and needs Node.js **22.19+** for its `undici`
|
|
74
|
-
dependency (the client itself has no `engines` field). Standard TC39 decorators
|
|
75
|
-
are supported (TypeScript 5.2+) and are the documentation default:
|
|
76
|
-
|
|
77
|
-
```jsonc
|
|
78
|
-
// tsconfig.json — standard decorator mode
|
|
79
|
-
{
|
|
80
|
-
"compilerOptions": {
|
|
81
|
-
"target": "ES2022",
|
|
82
|
-
"lib": ["ES2022", "ESNext.Decorators"]
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
Legacy mode with `experimentalDecorators: true` and
|
|
88
|
-
`emitDecoratorMetadata: true` still works. Standard decorators and esbuild/tsx
|
|
89
|
-
emit no type metadata: declare every serialized property with `@field(Type)`
|
|
90
|
-
from `@cratis/fundamentals`; default values are only an inference fallback.
|
|
61
|
+
Read [references/project-setup.md](references/project-setup.md) when installing the package, importing `reflect-metadata`, or choosing decorator settings. Standard TC39 decorators are the default; esbuild/tsx emit no type metadata, so every property needs `@field(Type)`.
|
|
91
62
|
|
|
92
63
|
## Connecting
|
|
93
64
|
|
|
@@ -120,54 +91,7 @@ exist — it calls `ensureEventStore`.
|
|
|
120
91
|
`dispose()` is **synchronous**, not
|
|
121
92
|
`Symbol.dispose` or `Symbol.asyncDispose`. After disposal every call throws.
|
|
122
93
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
`ChronicleOptions` has a **private constructor** (`Source/ChronicleOptions.ts`);
|
|
126
|
-
use `ChronicleOptions.fromConnectionString(connectionString, options?)` or
|
|
127
|
-
`ChronicleOptions.development(options?)`.
|
|
128
|
-
|
|
129
|
-
The optional bag accepts `telemetry`, `logger`, `clientArtifactsProvider`,
|
|
130
|
-
`discoveryPatterns`, `defaultSinkTypeId`, `reactorResultHandler`,
|
|
131
|
-
`artifactActivator`, and `readModelNamingPolicy`. `defaultSinkTypeId` defaults
|
|
132
|
-
to `WellKnownSinks.MongoDB`.
|
|
133
|
-
|
|
134
|
-
> `programIdentifier`, `softwareVersion`, and `softwareCommit` exist on the type
|
|
135
|
-
> but **neither public factory forwards them**, so they cannot be set.
|
|
136
|
-
> Do not write guidance that configures them.
|
|
137
|
-
|
|
138
|
-
### The connection string
|
|
139
|
-
|
|
140
|
-
Schemes `chronicle://` and `chronicle+srv://`, default port `35000`
|
|
141
|
-
(`Source/connection/ChronicleConnectionString.ts`). Query parameters: `apiKey`,
|
|
142
|
-
`disableTls`, `skipTlsValidation`, `certificatePath`, `certificatePassword`,
|
|
143
|
-
`loadBalancer`, `srvNameServer`.
|
|
144
|
-
|
|
145
|
-
Two facts to carry into production guidance:
|
|
146
|
-
|
|
147
|
-
- **`skipTlsValidation` defaults to `true`.** TLS is on but the certificate chain
|
|
148
|
-
is not validated, because a development kernel serves a self-signed
|
|
149
|
-
certificate. Set `?skipTlsValidation=false` against a real server.
|
|
150
|
-
- **A connection string with no credentials silently falls back to the
|
|
151
|
-
development client credentials** (`Source/connection/ChronicleConnection.ts`).
|
|
152
|
-
An anonymous-looking connection string is not anonymous; it is
|
|
153
|
-
`chronicle-dev-client`.
|
|
154
|
-
|
|
155
|
-
> **There is no `./connection` subpath export.** `ChronicleConnectionString`,
|
|
156
|
-
> `ChronicleConnectionStringBuilder`, `AuthenticationMode`, and `LoadBalancerMode`
|
|
157
|
-
> are unreachable from the public entry points — `Source/index.ts` never
|
|
158
|
-
> re-exports them and `Source/package.json`'s `exports` map has no
|
|
159
|
-
> `"./connection"` key. **Application code passes a connection *string*.** Do not
|
|
160
|
-
> write an example that imports a connection-string type.
|
|
161
|
-
|
|
162
|
-
The subpath exports that do exist: `.`, `./events`, `./eventSequences`,
|
|
163
|
-
`./eventStoreSubscriptions`, `./compliance`, `./reactors`, `./reducers`,
|
|
164
|
-
`./seeding`, `./readModels`, `./projections`, `./jobs`, `./webhooks`,
|
|
165
|
-
`./externalServices`, `./identities`, `./observation`, `./sinks`, `./schemas`,
|
|
166
|
-
`./types`, `./artifacts`, `./identity`, `./auditing`, `./correlation`,
|
|
167
|
-
`./transactions`, `./confidentiality`, `./patterns`, `./testing`, and
|
|
168
|
-
`./package.json`. Event-source APIs are root exports; there is no
|
|
169
|
-
`./eventSources` subpath. `IncompatibleChronicleServer` and
|
|
170
|
-
`RejectedChronicleCredentials` are also root exports.
|
|
94
|
+
Read [references/connection-options.md](references/connection-options.md) when building `ChronicleOptions`, writing a connection string, or listing the public subpath exports. Pass a connection string; there is no `./connection` export.
|
|
171
95
|
|
|
172
96
|
## Event types
|
|
173
97
|
|
|
@@ -339,31 +263,7 @@ in parallel, and re-runs for every cached event store on reconnect.
|
|
|
339
263
|
|
|
340
264
|
## Lifecycle
|
|
341
265
|
|
|
342
|
-
|
|
343
|
-
failure; the interval handle is `unref()`'d so it does not hold the process open.
|
|
344
|
-
- Reconnect uses exponential backoff with jitter, capped at 30 seconds, rebuilding
|
|
345
|
-
the gRPC channel on every attempt.
|
|
346
|
-
- **Keepalive registration is what keeps observers alive.** Losing it triggers a
|
|
347
|
-
full reconnect, because the kernel tears down the client's observers otherwise.
|
|
348
|
-
- Failed operations are retried once after reconnecting, keyed on gRPC status
|
|
349
|
-
codes 4/13/14 plus a substring match over the error text.
|
|
350
|
-
|
|
351
|
-
The client reports its **installed package version**, read from
|
|
352
|
-
`@cratis/chronicle/package.json`, and performs `CheckCompatibility` with
|
|
353
|
-
`ProtocolVersion` and the contracts descriptor set before a connection is usable
|
|
354
|
-
and before event-sequence calls. `IncompatibleChronicleServer` is a permanent
|
|
355
|
-
verdict, not retried (`Source/connection/CompatibilityPreflight.ts`).
|
|
356
|
-
Three consecutive credential rejections cause `RejectedChronicleCredentials`.
|
|
357
|
-
A failed token request is logged and the call proceeds without a token (allowing
|
|
358
|
-
an auth-less kernel); tokens come from the selected server, not the first host.
|
|
359
|
-
|
|
360
|
-
Requires `@cratis/chronicle` 6.43.0 for the built-in spans below.
|
|
361
|
-
|
|
362
|
-
Built-in spans use `cratis.chronicle.client.*` and scope
|
|
363
|
-
`Cratis.Chronicle.Client`; metrics use seconds. Legacy millisecond metrics and
|
|
364
|
-
`chronicle.*` attributes are retired except the retained exact-string
|
|
365
|
-
`chronicle.sequence_number`. The old constants, `ChronicleMetrics`, and
|
|
366
|
-
`telemetry.spanNames` are deprecated; migrate dashboards.
|
|
266
|
+
Read [references/lifecycle.md](references/lifecycle.md) when diagnosing reconnects, keepalive, rejected credentials or telemetry names. The client reports its installed package version, and `IncompatibleChronicleServer` is a permanent verdict, not retried.
|
|
367
267
|
|
|
368
268
|
## Artifact activation
|
|
369
269
|
|
package/package/corpus/skills/cratis-chronicle-client-typescript/references/connection-options.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Options and connection strings
|
|
2
|
+
|
|
3
|
+
This reference holds the `ChronicleOptions` factories and bag, the connection string scheme and parameters, and the public subpath exports.
|
|
4
|
+
|
|
5
|
+
### Options
|
|
6
|
+
|
|
7
|
+
`ChronicleOptions` has a **private constructor** (`Source/ChronicleOptions.ts`);
|
|
8
|
+
use `ChronicleOptions.fromConnectionString(connectionString, options?)` or
|
|
9
|
+
`ChronicleOptions.development(options?)`.
|
|
10
|
+
|
|
11
|
+
The optional bag accepts `telemetry`, `logger`, `clientArtifactsProvider`,
|
|
12
|
+
`discoveryPatterns`, `defaultSinkTypeId`, `reactorResultHandler`,
|
|
13
|
+
`artifactActivator`, and `readModelNamingPolicy`. `defaultSinkTypeId` defaults
|
|
14
|
+
to `WellKnownSinks.MongoDB`.
|
|
15
|
+
|
|
16
|
+
> `programIdentifier`, `softwareVersion`, and `softwareCommit` exist on the type
|
|
17
|
+
> but **neither public factory forwards them**, so they cannot be set.
|
|
18
|
+
> Do not write guidance that configures them.
|
|
19
|
+
|
|
20
|
+
### The connection string
|
|
21
|
+
|
|
22
|
+
Schemes `chronicle://` and `chronicle+srv://`, default port `35000`
|
|
23
|
+
(`Source/connection/ChronicleConnectionString.ts`). Query parameters: `apiKey`,
|
|
24
|
+
`disableTls`, `skipTlsValidation`, `certificatePath`, `certificatePassword`,
|
|
25
|
+
`loadBalancer`, `srvNameServer`.
|
|
26
|
+
|
|
27
|
+
Two facts to carry into production guidance:
|
|
28
|
+
|
|
29
|
+
- **`skipTlsValidation` defaults to `true`.** TLS is on but the certificate chain
|
|
30
|
+
is not validated, because a development kernel serves a self-signed
|
|
31
|
+
certificate. Set `?skipTlsValidation=false` against a real server.
|
|
32
|
+
- **A connection string with no credentials silently falls back to the
|
|
33
|
+
development client credentials** (`Source/connection/ChronicleConnection.ts`).
|
|
34
|
+
An anonymous-looking connection string is not anonymous; it is
|
|
35
|
+
`chronicle-dev-client`.
|
|
36
|
+
|
|
37
|
+
> **There is no `./connection` subpath export.** `ChronicleConnectionString`,
|
|
38
|
+
> `ChronicleConnectionStringBuilder`, `AuthenticationMode`, and `LoadBalancerMode`
|
|
39
|
+
> are unreachable from the public entry points — `Source/index.ts` never
|
|
40
|
+
> re-exports them and `Source/package.json`'s `exports` map has no
|
|
41
|
+
> `"./connection"` key. **Application code passes a connection *string*.** Do not
|
|
42
|
+
> write an example that imports a connection-string type.
|
|
43
|
+
|
|
44
|
+
The subpath exports that do exist: `.`, `./events`, `./eventSequences`,
|
|
45
|
+
`./eventStoreSubscriptions`, `./compliance`, `./reactors`, `./reducers`,
|
|
46
|
+
`./seeding`, `./readModels`, `./projections`, `./jobs`, `./webhooks`,
|
|
47
|
+
`./externalServices`, `./identities`, `./observation`, `./sinks`, `./schemas`,
|
|
48
|
+
`./types`, `./artifacts`, `./identity`, `./auditing`, `./correlation`,
|
|
49
|
+
`./transactions`, `./confidentiality`, `./patterns`, `./testing`, and
|
|
50
|
+
`./package.json`. Event-source APIs are root exports; there is no
|
|
51
|
+
`./eventSources` subpath. `IncompatibleChronicleServer` and
|
|
52
|
+
`RejectedChronicleCredentials` are also root exports.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Connection lifecycle
|
|
2
|
+
|
|
3
|
+
This reference holds the watchdog, reconnect, keepalive, compatibility check and telemetry behavior.
|
|
4
|
+
|
|
5
|
+
## Lifecycle
|
|
6
|
+
|
|
7
|
+
- A health-check watchdog runs `getVersionInfo` every 5 seconds and reconnects on
|
|
8
|
+
failure; the interval handle is `unref()`'d so it does not hold the process open.
|
|
9
|
+
- Reconnect uses exponential backoff with jitter, capped at 30 seconds, rebuilding
|
|
10
|
+
the gRPC channel on every attempt.
|
|
11
|
+
- **Keepalive registration is what keeps observers alive.** Losing it triggers a
|
|
12
|
+
full reconnect, because the kernel tears down the client's observers otherwise.
|
|
13
|
+
- Failed operations are retried once after reconnecting, keyed on gRPC status
|
|
14
|
+
codes 4/13/14 plus a substring match over the error text.
|
|
15
|
+
|
|
16
|
+
The client reports its **installed package version**, read from
|
|
17
|
+
`@cratis/chronicle/package.json`, and performs `CheckCompatibility` with
|
|
18
|
+
`ProtocolVersion` and the contracts descriptor set before a connection is usable
|
|
19
|
+
and before event-sequence calls. `IncompatibleChronicleServer` is a permanent
|
|
20
|
+
verdict, not retried (`Source/connection/CompatibilityPreflight.ts`).
|
|
21
|
+
Three consecutive credential rejections cause `RejectedChronicleCredentials`.
|
|
22
|
+
A failed token request is logged and the call proceeds without a token (allowing
|
|
23
|
+
an auth-less kernel); tokens come from the selected server, not the first host.
|
|
24
|
+
|
|
25
|
+
Requires `@cratis/chronicle` 6.43.0 for the built-in spans below.
|
|
26
|
+
|
|
27
|
+
Built-in spans use `cratis.chronicle.client.*` and scope
|
|
28
|
+
`Cratis.Chronicle.Client`; metrics use seconds. Legacy millisecond metrics and
|
|
29
|
+
`chronicle.*` attributes are retired except the retained exact-string
|
|
30
|
+
`chronicle.sequence_number`. The old constants, `ChronicleMetrics`, and
|
|
31
|
+
`telemetry.spanNames` are deprecated; migrate dashboards.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Project setup
|
|
2
|
+
|
|
3
|
+
This reference holds installation, the entry-point import, and decorator compiler settings.
|
|
4
|
+
|
|
5
|
+
## Project setup
|
|
6
|
+
|
|
7
|
+
```shell
|
|
8
|
+
yarn add @cratis/chronicle @cratis/fundamentals reflect-metadata
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
`@cratis/fundamentals` is a peer dependency, so it does not arrive on its own.
|
|
12
|
+
`reflect-metadata` is now a regular dependency. Import it **once, at the entry
|
|
13
|
+
point**, before any decorated class is loaded:
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import 'reflect-metadata';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The package is **ESM-only** and needs Node.js **22.19+** for its `undici`
|
|
20
|
+
dependency (the client itself has no `engines` field). Standard TC39 decorators
|
|
21
|
+
are supported (TypeScript 5.2+) and are the documentation default:
|
|
22
|
+
|
|
23
|
+
```jsonc
|
|
24
|
+
// tsconfig.json — standard decorator mode
|
|
25
|
+
{
|
|
26
|
+
"compilerOptions": {
|
|
27
|
+
"target": "ES2022",
|
|
28
|
+
"lib": ["ES2022", "ESNext.Decorators"]
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Legacy mode with `experimentalDecorators: true` and
|
|
34
|
+
`emitDecoratorMetadata: true` still works. Standard decorators and esbuild/tsx
|
|
35
|
+
emit no type metadata: declare every serialized property with `@field(Type)`
|
|
36
|
+
from `@cratis/fundamentals`; default values are only an inference fallback.
|
|
@@ -259,27 +259,7 @@ property)]` and `[FromEvery(property, contextProperty)]`. Name them.
|
|
|
259
259
|
|
|
260
260
|
## Definition changes replay
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
classifies a changed definition as no action, partial replay, or full replay.
|
|
264
|
-
`observers.definitionEvolution` defaults to `Automatic`; `PartialOnly` applies
|
|
265
|
-
partial/no-action plans but recommends full replay; `Manual` recommends both
|
|
266
|
-
replay kinds. Mapping, key, filter, join and child changes require full replay
|
|
267
|
-
when independence cannot be proved. Counters and joins are repaired by replay,
|
|
268
|
-
not by deploying corrected mappings: earlier double-counts remain until rebuilt.
|
|
269
|
-
A `FromAll` subscription change redefines existing projections.
|
|
270
|
-
|
|
271
|
-
Projection replay and catch-up each walk the sequence in **one globally ordered
|
|
272
|
-
job step**, not parallel per-source steps. A new failure during catch-up stops
|
|
273
|
-
that ordered step even if other sources are healthy. Full replay keeps the
|
|
274
|
-
observer inactive; completion routes to catch-up/live unless quarantined.
|
|
275
|
-
A next-event storage error leaves the cursor unchanged and waits for
|
|
276
|
-
retry; only `NotFound` proves absence. It does not certify previously skipped
|
|
277
|
-
history. Sources: `Documentation/projections/registration-lifecycle.md`,
|
|
278
|
-
`Documentation/concepts/observers.mdx`, `Observation/Jobs/{CatchUpObserver,ReplayObserver}.cs`
|
|
279
|
-
and `Observation/States/Routing.cs` (under `Source/Kernel/Core/`).
|
|
280
|
-
|
|
281
|
-
Closing a stream does not erase its events or prevent a projection replay.
|
|
282
|
-
Keep the closing fact as history; see **cratis-chronicle-event-constraints**.
|
|
262
|
+
Read [references/definition-changes.md](references/definition-changes.md) when a changed mapping, key, filter, join or child must replay, or when a corrected mapping does not repair existing counters and joins (replay rebuilds them; deploying alone does not).
|
|
283
263
|
|
|
284
264
|
## After creating
|
|
285
265
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Definition changes replay
|
|
2
|
+
|
|
3
|
+
This reference holds how the kernel classifies a changed projection definition into no action, partial replay or full replay.
|
|
4
|
+
|
|
5
|
+
## Definition changes replay
|
|
6
|
+
|
|
7
|
+
Per `Documentation/hosting/configuration/observers.md`, the kernel
|
|
8
|
+
classifies a changed definition as no action, partial replay, or full replay.
|
|
9
|
+
`observers.definitionEvolution` defaults to `Automatic`; `PartialOnly` applies
|
|
10
|
+
partial/no-action plans but recommends full replay; `Manual` recommends both
|
|
11
|
+
replay kinds. Mapping, key, filter, join and child changes require full replay
|
|
12
|
+
when independence cannot be proved. Counters and joins are repaired by replay,
|
|
13
|
+
not by deploying corrected mappings: earlier double-counts remain until rebuilt.
|
|
14
|
+
A `FromAll` subscription change redefines existing projections.
|
|
15
|
+
|
|
16
|
+
Projection replay and catch-up each walk the sequence in **one globally ordered
|
|
17
|
+
job step**, not parallel per-source steps. A new failure during catch-up stops
|
|
18
|
+
that ordered step even if other sources are healthy. Full replay keeps the
|
|
19
|
+
observer inactive; completion routes to catch-up/live unless quarantined.
|
|
20
|
+
A next-event storage error leaves the cursor unchanged and waits for
|
|
21
|
+
retry; only `NotFound` proves absence. It does not certify previously skipped
|
|
22
|
+
history. Sources: `Documentation/projections/registration-lifecycle.md`,
|
|
23
|
+
`Documentation/concepts/observers.mdx`, `Observation/Jobs/{CatchUpObserver,ReplayObserver}.cs`
|
|
24
|
+
and `Observation/States/Routing.cs` (under `Source/Kernel/Core/`).
|
|
25
|
+
|
|
26
|
+
Closing a stream does not erase its events or prevent a projection replay.
|
|
27
|
+
Keep the closing fact as history; see **cratis-chronicle-event-constraints**.
|