@cratis/pi 7.14.2 → 7.14.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/skills/cratis-application-slice-conformance/SKILL.md +11 -2
- package/package/corpus/skills/cratis-application-slice-conformance/references/build-prompts.md +8 -0
- package/package/corpus/skills/cratis-application-slice-conformance/references/checklists.md +10 -6
- package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/SKILL.md +11 -7
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authentication.md +12 -2
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authorization.md +16 -1
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/frontend.md +7 -0
- package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/observable-emission-guards.md +9 -0
- package/package/corpus/skills/cratis-arc-command/SKILL.md +20 -15
- package/package/corpus/skills/cratis-arc-command/references/command-result.md +7 -0
- package/package/corpus/skills/cratis-arc-command/references/handler-shapes.md +10 -3
- package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-command-operation/SKILL.md +5 -1
- package/package/corpus/skills/cratis-arc-command-operation/references/execution-and-recovery.md +12 -0
- package/package/corpus/skills/cratis-arc-command-operation/references/testing.md +10 -3
- package/package/corpus/skills/cratis-arc-command-typescript/SKILL.md +20 -116
- package/package/corpus/skills/cratis-arc-command-typescript/references/chronicle-events.md +11 -8
- package/package/corpus/skills/cratis-arc-command-typescript/references/command-specifications.md +63 -0
- package/package/corpus/skills/cratis-arc-command-typescript/references/hosting-and-storage.md +10 -0
- package/package/corpus/skills/cratis-arc-command-typescript/references/proxy-generation.md +38 -0
- package/package/corpus/skills/cratis-arc-command-typescript/references/slice-layout.md +19 -0
- package/package/corpus/skills/cratis-arc-command-typescript/verification.json +1 -1
- package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +1 -1
- package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +11 -10
- package/package/corpus/skills/cratis-arc-react-page/SKILL.md +30 -19
- package/package/corpus/skills/cratis-arc-react-page/references/data-page.md +11 -0
- package/package/corpus/skills/cratis-arc-react-page/references/data-tables.md +10 -0
- package/package/corpus/skills/cratis-arc-react-page/references/dialogs.md +12 -10
- package/package/corpus/skills/cratis-arc-react-page/references/from-screenplay.md +10 -0
- package/package/corpus/skills/cratis-arc-react-page/references/mvvm.md +11 -0
- package/package/corpus/skills/cratis-arc-react-page/references/queries-and-commands.md +7 -0
- package/package/corpus/skills/cratis-chronicle-client-dotnet/SKILL.md +58 -122
- package/package/corpus/skills/cratis-chronicle-client-dotnet/references/compatibility-check.md +26 -0
- package/package/corpus/skills/cratis-chronicle-client-dotnet/references/discovery.md +22 -0
- package/package/corpus/skills/cratis-chronicle-client-dotnet/references/hosting.md +31 -0
- package/package/corpus/skills/cratis-chronicle-client-elixir/SKILL.md +52 -131
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/append-api.md +19 -0
- package/package/corpus/skills/cratis-chronicle-client-elixir/references/variants.md +73 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/SKILL.md +29 -232
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/connection-lifecycle.md +20 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/discovery-and-registration.md +44 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/java-api.md +33 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/spring-boot.md +54 -0
- package/package/corpus/skills/cratis-chronicle-client-kotlin/references/variants.md +77 -0
- package/package/corpus/skills/cratis-chronicle-client-typescript/SKILL.md +26 -102
- package/package/corpus/skills/cratis-chronicle-client-typescript/references/read-models-and-projections.md +23 -0
- package/package/corpus/skills/cratis-chronicle-client-typescript/references/variants.md +63 -0
- package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +13 -13
- package/package/corpus/skills/cratis-chronicle-mcp-inspection/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +13 -4
- package/package/corpus/skills/cratis-chronicle-projection/references/fluent-builder.md +10 -0
- package/package/corpus/skills/cratis-chronicle-projection/references/model-bound-attributes.md +14 -6
- package/package/corpus/skills/cratis-chronicle-projection/references/variants.md +9 -0
- package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +7 -49
- package/package/corpus/skills/cratis-chronicle-reactor/references/domain-failures.md +19 -0
- package/package/corpus/skills/cratis-chronicle-reactor/references/specifications.md +33 -0
- package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +2 -2
- package/package/corpus/skills/cratis-chronicle-read-model/references/queries.md +11 -0
- package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +1 -0
- package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +1 -1
- package/package/corpus/skills/cratis-chronicle-web-workbench/SKILL.md +24 -24
- package/package/corpus/skills/cratis-content-length/SKILL.md +1 -1
- package/package/corpus/skills/cratis-content-length/references/length-evidence.md +12 -0
- package/package/corpus/skills/cratis-developer-marketing/SKILL.md +19 -19
- package/package/corpus/skills/cratis-developer-marketing/references/measurement.md +10 -0
- package/package/corpus/skills/cratis-developer-marketing/references/playbook-evidence.md +10 -0
- package/package/corpus/skills/cratis-engineering-csharp-conventions/SKILL.md +5 -0
- package/package/corpus/skills/cratis-engineering-csharp-conventions/references/code-style.md +15 -0
- package/package/corpus/skills/cratis-engineering-csharp-conventions/references/exceptions-logging-and-di.md +9 -4
- package/package/corpus/skills/cratis-engineering-decision-record/SKILL.md +1 -2
- package/package/corpus/skills/cratis-engineering-decision-record/references/record-format.md +8 -0
- package/package/corpus/skills/cratis-engineering-docs-authoring/SKILL.md +1 -2
- package/package/corpus/skills/cratis-engineering-effect-boundaries/references/failure-archetypes.md +10 -0
- package/package/corpus/skills/cratis-fundamentals-concept/SKILL.md +1 -1
- package/package/corpus/skills/cratis-fundamentals-type-discovery/SKILL.md +1 -1
- package/package/corpus/skills/cratis-lens-browser-extension/SKILL.md +18 -18
- package/package/corpus/skills/cratis-performance-review/SKILL.md +1 -1
- package/package/corpus/skills/cratis-release-notes/SKILL.md +1 -0
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/SKILL.md +29 -4
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/automation-patterns.md +16 -4
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/effects-and-idempotency.md +4 -15
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/todo-list-example.md +6 -2
- package/package/corpus/skills/cratis-screenplay-automations-and-translations/references/translation-patterns.md +1 -6
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +45 -245
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/capture-map-and-example.md +42 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/complete-examples.md +155 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/specifying-triggers-and-clock.md +27 -0
- package/package/corpus/skills/cratis-screenplay-captures-and-reactions/references/trigger-reads-example.md +21 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +69 -227
- package/package/corpus/skills/cratis-screenplay-command-surface/references/context.md +10 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/generated-values-and-responses.md +51 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/inline-events.md +62 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/policy-persona-seed.md +46 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/references/validate-rules.md +36 -0
- package/package/corpus/skills/cratis-screenplay-command-surface/verification.json +11 -11
- package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +10 -3
- package/package/corpus/skills/cratis-screenplay-discovery/references/facilitation.md +1 -6
- package/package/corpus/skills/cratis-screenplay-discovery/references/human-workshop.md +13 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/personas-and-causes.md +8 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/plotting-and-handoff.md +11 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/storming-loop.md +7 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +75 -198
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/file-layout.md +89 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/naming-primitives.md +26 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/nine-steps.md +14 -1
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/parsed-not-runnable.md +8 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/provenance.md +10 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/slice-type-rules.md +12 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/verification.json +12 -6
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/SKILL.md +5 -6
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/candidate-inventory.md +11 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/prologue-safety.md +8 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/side-car-migration.md +11 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/ui-observation.md +1 -1
- package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +33 -10
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/language-reference.md +8 -0
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-loop.md +13 -17
- package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-tools.md +11 -0
- package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +9 -9
- package/package/corpus/skills/cratis-screenplay-model-review/references/business-questions.md +9 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +15 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/report-template.md +9 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/worked-example.md +9 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +17 -8
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/handoff-template.md +8 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/identity-and-edits.md +1 -6
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +19 -0
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/safety.md +1 -1
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/verdicts-and-modes.md +11 -1
- package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/vocabulary-map.md +2 -2
- package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +3 -4
- package/package/corpus/skills/cratis-screenplay-projections/references/pdl-grammar.md +8 -0
- package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +2 -2
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +3 -3
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/gap-fill-handoff.md +1 -1
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/worked-example.md +8 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/SKILL.md +10 -10
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/coverage-matrix.md +8 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/invoicing-dues-example.md +4 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md +17 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-examples.md +10 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-workshop.md +11 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/view-and-story-specs.md +12 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/SKILL.md +2 -2
- package/package/corpus/skills/cratis-screenplay-slice-design/references/command-inventory.md +7 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/field-lineage.md +8 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/read-model-design.md +16 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/slicing.md +10 -0
- package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +52 -360
- package/package/corpus/skills/cratis-screenplay-specifications/references/actions-beyond-commands.md +34 -0
- package/package/corpus/skills/cratis-screenplay-specifications/references/concept-rules.md +77 -0
- package/package/corpus/skills/cratis-screenplay-specifications/references/generated-fixtures.md +39 -0
- package/package/corpus/skills/cratis-screenplay-specifications/references/reactions-and-cascades.md +72 -0
- package/package/corpus/skills/cratis-screenplay-specifications/references/worked-example.md +110 -0
- package/package/corpus/skills/cratis-screenplay-specifications/verification.json +6 -6
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/SKILL.md +21 -1
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/boundaries.md +13 -0
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/chronicle-boundaries.md +1 -1
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/consistency-and-concurrency.md +16 -20
- package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/stream-patterns.md +16 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +13 -7
- package/package/corpus/skills/cratis-screenplay-toolchain/references/diagnostics.md +10 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/executable-subset.md +10 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/generated-responses-example.md +1 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/traps.md +1 -1
- package/package/corpus/skills/cratis-screenplay-toolchain/references/verdicts.md +10 -0
- package/package/corpus/skills/cratis-screenplay-toolchain/references/versions.md +12 -0
- package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +11 -13
- package/package/corpus/skills/cratis-screenplay-ui-composition/references/flow-review.md +1 -1
- package/package/corpus/skills/cratis-social-feed-post/SKILL.md +10 -10
- package/package/corpus/skills/cratis-social-feed-post/references/engagement-evidence.md +12 -0
- package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +13 -2
- package/package/corpus/skills/cratis-specifications-csharp/references/application-scenarios.md +10 -10
- package/package/corpus/skills/cratis-specifications-csharp/references/csharp-patterns.md +10 -0
- package/package/corpus/skills/cratis-specifications-csharp/references/integration-specs.md +9 -0
- package/package/corpus/skills/cratis-specifications-typescript/SKILL.md +1 -2
- package/package/corpus/skills/cratis-specifications-typescript/references/typescript-patterns.md +11 -1
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +30 -21
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/admission.md +9 -0
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/render-example.md +5 -0
- package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/sandbox-and-specrunner.md +2 -4
- package/package/corpus/skills/cratis-studio-mcp-safety-guidance/SKILL.md +2 -2
- package/package/corpus/skills/cratis-writing-voice-and-cadence/SKILL.md +39 -39
- package/package/corpus/skills/cratis-writing-voice-and-cadence/references/ai-tells.md +10 -0
- package/package.json +1 -1
package/package/corpus/skills/cratis-chronicle-client-kotlin/references/connection-lifecycle.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
## Connection lifecycle
|
|
2
|
+
|
|
3
|
+
- **Keepalive is two-way.** The kernel pushes a keep-alive down the `Connect`
|
|
4
|
+
stream and the client answers with a separate unary `connectionKeepAlive` RPC
|
|
5
|
+
(`connection/ConnectionManager.kt:30`). A watchdog checks every
|
|
6
|
+
`WATCHDOG_INTERVAL_MS = 1_000L` and treats a gap longer than
|
|
7
|
+
`KEEP_ALIVE_TIMEOUT_MS = 5_000L` as a lost connection (`:126-128`, `:164`,
|
|
8
|
+
`:171`). **Silence, not an error, is how the connection dies** — nothing throws.
|
|
9
|
+
- Reconnect is an infinite loop with jittered exponential backoff, base 1s,
|
|
10
|
+
capped at 30s, re-resolving DNS/SRV on every attempt
|
|
11
|
+
(`ConnectionManager.kt:75-101`, `:155-158`).
|
|
12
|
+
- The client identifies itself to the kernel as `"Kotlin"`
|
|
13
|
+
(`ConnectionManager.kt:161`).
|
|
14
|
+
- `dispose()` cancels the connection manager, shuts the channel down with a
|
|
15
|
+
5-second `awaitTermination`, then `shutdownNow`
|
|
16
|
+
(`connection/ChronicleConnection.kt:116-125`).
|
|
17
|
+
- **Your process must stay alive** for reactors and reducers to keep receiving —
|
|
18
|
+
observation is a live gRPC stream, and each observer runs on its own
|
|
19
|
+
`CoroutineScope(Dispatchers.IO)` (`observation/ReactorsService.kt:57`,
|
|
20
|
+
`observation/ReducersService.kt:59`).
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
## Discovery and registration
|
|
2
|
+
|
|
3
|
+
`ClientArtifacts` scans the classpath with ClassGraph
|
|
4
|
+
(`artifacts/ClientArtifacts.kt:66-98`), and `ClientArtifacts.default` is a
|
|
5
|
+
process-wide lazy singleton (`:156`). What it looks for (`:66-98`):
|
|
6
|
+
|
|
7
|
+
| Kind | Rule |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
| event types | `@EventType` |
|
|
10
|
+
| event type migrations | implements `IEventTypeMigration` |
|
|
11
|
+
| read models | `@ReadModel` |
|
|
12
|
+
| declarative projections | implements `IProjectionFor` |
|
|
13
|
+
| model-bound projections | `@FromEvent` **and** the synthetic `FromEvent$Container` |
|
|
14
|
+
| reactors | `@Reactor` |
|
|
15
|
+
| reducers | `@Reducer` |
|
|
16
|
+
| constraints | implements `IConstraint` |
|
|
17
|
+
| seeders | implements `ICanSeedEvents` |
|
|
18
|
+
| webhooks | implements `IWebhookDefiner` |
|
|
19
|
+
| captures | implements `ICapture` |
|
|
20
|
+
| reactor middlewares | implements `IReactorMiddleware` or `BlockingReactorMiddleware` |
|
|
21
|
+
| reactor argument resolvers | implements `IReactorMethodArgumentResolver` or `BlockingReactorMethodArgumentResolver` |
|
|
22
|
+
|
|
23
|
+
> The `FromEvent$Container` entry is not incidental: Kotlin's `@Repeatable`
|
|
24
|
+
> replaces repeated annotations with a synthetic container, so a class carrying
|
|
25
|
+
> more than one `@FromEvent` is **not** annotated with `@FromEvent` at runtime.
|
|
26
|
+
> A scan that looks only for the annotation silently misses every multi-event
|
|
27
|
+
> projection.
|
|
28
|
+
|
|
29
|
+
Registration order is fixed and matters
|
|
30
|
+
(`artifacts/ArtifactRegistrations.kt:59-91`): event types and migrations →
|
|
31
|
+
unowned read models → constraints → model-bound constraints → projections →
|
|
32
|
+
webhooks → reactors → reducers → captures → seeders. Reactors and reducers are
|
|
33
|
+
started only on the first pass (`:78-82`).
|
|
34
|
+
|
|
35
|
+
**Registration re-runs on every reconnect.** `EventStore.kt:226-241` launches a
|
|
36
|
+
coroutine on `Dispatchers.IO` collecting the connection lifecycle and
|
|
37
|
+
re-registers each time. The connection id rotates on every disconnect because
|
|
38
|
+
the kernel keys observer subscriptions by it
|
|
39
|
+
(`connection/ConnectionLifecycle.kt:24-32`), so observers must re-register — and
|
|
40
|
+
they do.
|
|
41
|
+
|
|
42
|
+
`store.awaitRegistration()` (`IEventStore.kt:92`) waits for the first pass.
|
|
43
|
+
`store.registerAll()` (`:83`) runs it by hand when
|
|
44
|
+
`autoDiscoverAndRegister = false`.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
## Java
|
|
2
|
+
|
|
3
|
+
Java is a first-class target here, not an afterthought: there is a compile-only
|
|
4
|
+
Java conformance suite under `Source/src/test/java` whose whole point is stated
|
|
5
|
+
in `conformance/JavaConformance.java:71-74` — *"It is never run — compiling it is
|
|
6
|
+
the assertion"*.
|
|
7
|
+
|
|
8
|
+
**Start Java code at `BlockingChronicleClient`**, not at the raw `ChronicleClient`
|
|
9
|
+
plus static bridges. Verbatim from the compile-checked fixture
|
|
10
|
+
(`Source/src/test/java/io/cratis/chronicle/java/JavaClientFlowUsage.java:29-34`):
|
|
11
|
+
|
|
12
|
+
```java
|
|
13
|
+
var client = BlockingChronicleClient.connect(ChronicleOptions.development());
|
|
14
|
+
var eventStore = client.getEventStore("<EventStoreName>");
|
|
15
|
+
|
|
16
|
+
eventStore.getEventLog().append("<event-source-id>", new <EventName>("<value>"));
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`BlockingChronicleClient` is `AutoCloseable`, so `try (var client = ...)` works
|
|
20
|
+
(`java/BlockingChronicleClient.kt:35`, `connect` at `:74-76`). The blocking
|
|
21
|
+
surface continues through `BlockingEventStore`, `BlockingEventSequence`,
|
|
22
|
+
`BlockingReadModels`, `BlockingReactors`, `BlockingReducers`,
|
|
23
|
+
`BlockingUnitOfWork`, and `AppendOptionsBuilder`.
|
|
24
|
+
|
|
25
|
+
> The repository's own README shows the **older** low-level route —
|
|
26
|
+
> `new ChronicleClient(...)` plus `EventStoreJavaBridge` / `EventLogJavaBridge`
|
|
27
|
+
> (`README.md:225-244`). Both APIs are real, but the reference documentation and
|
|
28
|
+
> the compile-checked fixture both start at `BlockingChronicleClient`. Write new
|
|
29
|
+
> Java against that; reach for the `*JavaBridge` statics only for a corner the
|
|
30
|
+
> blocking client does not wrap.
|
|
31
|
+
|
|
32
|
+
In Spring Boot, Java injects the `Chronicle` bean instead — it already takes
|
|
33
|
+
`Class<T>` and returns plain values.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
## Spring Boot
|
|
2
|
+
|
|
3
|
+
The starter registers exactly two auto-configurations —
|
|
4
|
+
`Integrations/SpringBoot/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports`:
|
|
5
|
+
|
|
6
|
+
- `io.cratis.chronicle.spring.ChronicleAutoConfiguration`
|
|
7
|
+
- `io.cratis.chronicle.spring.ChronicleWebAutoConfiguration`
|
|
8
|
+
|
|
9
|
+
Configuration binds under the prefix `cratis.chronicle` —
|
|
10
|
+
`ChronicleProperties.kt:42-43`. The minimum real configuration is one key, as in
|
|
11
|
+
the shipped sample (`Samples/Kotlin/SpringBoot/src/main/resources/application.yml`):
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
cratis:
|
|
15
|
+
chronicle:
|
|
16
|
+
event-store: <EventStoreName>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Everything else has a default (`ChronicleProperties.kt:44-55`):
|
|
20
|
+
|
|
21
|
+
| Key under `cratis.chronicle` | Default | Line |
|
|
22
|
+
| --- | --- | --- |
|
|
23
|
+
| `connection-string` | the development connection string | `:44` |
|
|
24
|
+
| `event-store` | `"Default"` | `:45` |
|
|
25
|
+
| `namespace` | `"Default"` | `:46` |
|
|
26
|
+
| `auto-discover-and-register` | `true` | `:47` |
|
|
27
|
+
| `artifact-packages` | empty — falls back to Spring's auto-configuration packages | `:48` |
|
|
28
|
+
| `default-sink-type-id` | `null` | `:49` |
|
|
29
|
+
| `program-identifier` | `null` — falls back to `spring.application.name` | `:50` |
|
|
30
|
+
| `registration-timeout` | `PT30S` | `:51` |
|
|
31
|
+
| `namespace-resolution.strategy` | `FIXED` | `:65` |
|
|
32
|
+
| `namespace-resolution.http-header` | `"x-cratis-tenant-id"` | `:66` |
|
|
33
|
+
| `namespace-resolution.claim` | `"tenant_id"` | `:67` |
|
|
34
|
+
|
|
35
|
+
`NamespaceResolution.Strategy` is `FIXED`, `HTTP_HEADER`, `SUBDOMAIN`,
|
|
36
|
+
`AUTHENTICATION` (`ChronicleProperties.kt:70-82`).
|
|
37
|
+
|
|
38
|
+
The beans you inject are `IChronicleClient`, `IEventStore`, and the convenience
|
|
39
|
+
facade `Chronicle` (`ChronicleAutoConfiguration.kt:93-114`). `Chronicle` wraps
|
|
40
|
+
the suspending API in blocking calls and takes `Class<T>` rather than
|
|
41
|
+
`KClass<T>`, so Java can use it unchanged —
|
|
42
|
+
`Integrations/SpringBoot/src/main/kotlin/io/cratis/chronicle/spring/Chronicle.kt:47`,
|
|
43
|
+
`append` at `:57`, `appendMany` at `:69`.
|
|
44
|
+
|
|
45
|
+
`ChronicleWebAutoConfiguration` is **servlet-only**
|
|
46
|
+
(`@ConditionalOnWebApplication(SERVLET)`, `ChronicleWebAutoConfiguration.kt:29`).
|
|
47
|
+
A WebFlux application gets no per-request namespace, identity, causation, or
|
|
48
|
+
unit-of-work filter.
|
|
49
|
+
|
|
50
|
+
**Artifacts are Spring beans.** `SpringArtifactActivator` resolves a discovered
|
|
51
|
+
artifact from the container when it is uniquely defined and otherwise builds it
|
|
52
|
+
through `autowireCapableBeanFactory.createBean`
|
|
53
|
+
(`SpringArtifactActivator.kt:28-43`), so a reactor takes constructor
|
|
54
|
+
dependencies exactly like a `@Service` would.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
## Variants — mutually exclusive read models for one entity's lifecycle
|
|
2
|
+
|
|
3
|
+
> Requires `io.cratis:chronicle` `6.3.0` or later — newer than this skill's
|
|
4
|
+
> `5.1.0` baseline (`Source/src/main/kotlin/io/cratis/chronicle/projections/VariantOf.kt`
|
|
5
|
+
> and siblings). Reverify before claiming support; take the version from Maven
|
|
6
|
+
> Central, not the checked-in source.
|
|
7
|
+
|
|
8
|
+
Some entities do not have one shape for their whole lifetime — a work item is a
|
|
9
|
+
backlog entry until a pull request exists for it, then it is a pull request
|
|
10
|
+
until it merges. **Variants** let several read models share one logical
|
|
11
|
+
identity and be mutually exclusive: entering one variant removes the entity
|
|
12
|
+
from every other variant in the group, and only the event named by
|
|
13
|
+
`@EntersOn`/`entersOn(...)` can create or resurrect a variant — every other
|
|
14
|
+
event it handles is automatically reclassified into an update-only join.
|
|
15
|
+
|
|
16
|
+
**Model-bound** (the annotations are ordinary Java annotations, so Kotlin and
|
|
17
|
+
Java use the identical shape):
|
|
18
|
+
|
|
19
|
+
```kotlin
|
|
20
|
+
class WorkItem // anchors the group; not itself a read model
|
|
21
|
+
|
|
22
|
+
@ReadModel
|
|
23
|
+
@VariantOf(WorkItem::class, key = "id")
|
|
24
|
+
@EntersOn(IssueCreated::class)
|
|
25
|
+
@FromEvent(IssueCreated::class)
|
|
26
|
+
data class BacklogItem(
|
|
27
|
+
@FromEventSourceId val id: String = "",
|
|
28
|
+
@SetFrom("title", IssueCreated::class) val title: String = ""
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
@ReadModel
|
|
32
|
+
@VariantOf(WorkItem::class, key = "id")
|
|
33
|
+
@EntersOn(PullRequestCreated::class)
|
|
34
|
+
@FromEvent(PullRequestCreated::class)
|
|
35
|
+
@FromEvent(BuildCompleted::class) // not the entering event -> update-only join
|
|
36
|
+
data class PullRequestItem(
|
|
37
|
+
@FromEventSourceId val id: String = "",
|
|
38
|
+
@SetFrom("pullRequestUrl", PullRequestCreated::class) val pullRequestUrl: String = "",
|
|
39
|
+
@SetFrom("buildStatus", BuildCompleted::class) val buildStatus: String = ""
|
|
40
|
+
)
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`@VariantOf(identity, key)` — **`key` is always an explicit property-name
|
|
44
|
+
string**, on both Kotlin and Java, because reflection resolves it rather than a
|
|
45
|
+
compile-time property reference. `@EntersOn(eventType, key = "EventSourceId")`
|
|
46
|
+
is repeatable — a variant may enter on more than one event — and its `key`
|
|
47
|
+
names an *event* property (not the read model's), defaulting to the event
|
|
48
|
+
source id. A mapping shared by every variant of an identity goes on a type
|
|
49
|
+
annotated `@GlobalFor(identity)` instead of being repeated per variant; every
|
|
50
|
+
variant it targets must actually have the member it maps, or
|
|
51
|
+
`GlobalHandlerPropertyNotOnVariant` is thrown at registration.
|
|
52
|
+
|
|
53
|
+
**Declarative** — `variantOf` and `entersOn` are members of
|
|
54
|
+
`IProjectionBuilderFor<TReadModel>` itself:
|
|
55
|
+
|
|
56
|
+
```kotlin
|
|
57
|
+
class PullRequestItemProjection : IProjectionFor<PullRequestItem> {
|
|
58
|
+
override fun define(builder: IProjectionBuilderFor<PullRequestItem>) {
|
|
59
|
+
builder
|
|
60
|
+
.variantOf(WorkItem::class, PullRequestItem::id) // or variantOf(WorkItem::class, "id")
|
|
61
|
+
.entersOn(PullRequestCreated::class)
|
|
62
|
+
.from(BuildCompleted::class) // update-only, same reason
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Java calls the same builder with a `Class` and a string key — there is no
|
|
68
|
+
property-reference overload in Java:
|
|
69
|
+
|
|
70
|
+
```java
|
|
71
|
+
builder.variantOf(WorkItem.class, "id").entersOn(PullRequestCreated.class);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**A variant that declares no `@EntersOn`/`entersOn(...)` throws
|
|
75
|
+
`VariantMustDeclareEntersOnEvent`** at registration — a variant that could
|
|
76
|
+
never be entered could never be written to at all, since every other handler
|
|
77
|
+
on it is update-only.
|
|
@@ -11,6 +11,28 @@ Chronicle server. It is not a browser library and it is not the Arc TypeScript
|
|
|
11
11
|
proxy layer — an Arc frontend calls generated command and query proxies over
|
|
12
12
|
HTTP and never sees this package.
|
|
13
13
|
|
|
14
|
+
## Common pitfalls
|
|
15
|
+
|
|
16
|
+
| Pitfall | Why it bites |
|
|
17
|
+
| --- | --- |
|
|
18
|
+
| Naming a reactor method after the handler's purpose | Dispatch is by the camelCase event class name; a mismatch is silently never called |
|
|
19
|
+
| `instanceof` on the event inside a handler | It is a `JSON.parse`d plain object, not your class |
|
|
20
|
+
| Event class with no default constructor values under `tsx` | No decorator metadata is emitted, so the schema comes out empty |
|
|
21
|
+
| Two `@eventType()` classes sharing a class name | The id defaults to the class name and they collide |
|
|
22
|
+
| Deploying compiled `dist/*.js` with default discovery | The default glob matches `**/*.ts`; nothing is discovered |
|
|
23
|
+
| Omitting a side-effect import of an artifact module | Its decorator never runs, so it is never registered |
|
|
24
|
+
| Forgetting `import 'reflect-metadata'` at the entry point | Decorators do not work at runtime |
|
|
25
|
+
| Forgetting to install `@cratis/fundamentals` | It is a peer dependency and is not installed for you |
|
|
26
|
+
| Importing `ChronicleConnectionString` | There is no `./connection` export; pass a string |
|
|
27
|
+
| Expecting single `append()` to set a stream or subject | Those fields are hardcoded; use the `EventForEventSourceId[]` overload |
|
|
28
|
+
| A connection string with no credentials | Silently falls back to the development client credentials |
|
|
29
|
+
| Shipping the default TLS behavior | `skipTlsValidation` defaults to `true` |
|
|
30
|
+
| Constructor-injecting a dependency into a reactor | There is no DI; the client constructs it |
|
|
31
|
+
| Carrying a `3.x` example forward | Tags, the reducer context parameter, and two RPC names changed in `4.0.0` |
|
|
32
|
+
| Reading `result.sequenceNumber` as a number | It is a `bigint` behind `.value` |
|
|
33
|
+
| A `@globalFor` mapping targeting a property one variant lacks | `GlobalHandlerPropertyNotOnVariant` when the group is built, not a silently skipped mapping |
|
|
34
|
+
| Expecting a `@globalFor`-only class to appear as a projection | It is never registered on its own; it is merged into its variants |
|
|
35
|
+
|
|
14
36
|
## Verified product sources
|
|
15
37
|
|
|
16
38
|
This skill was written against `Cratis/Chronicle.TypeScript` at tag `v4.0.0`
|
|
@@ -295,91 +317,15 @@ Restrict an observer to tagged events with `@filterEventsByTag(value)` —
|
|
|
295
317
|
|
|
296
318
|
### Read models and projections
|
|
297
319
|
|
|
298
|
-
`store.readModels
|
|
299
|
-
(`:38`), `getInstances(type, eventCount?)` (`:46`), `getSnapshotsById` (`:54`),
|
|
300
|
-
`watch(type): AsyncIterable<ReadModelChangeset<T>>` (`:61`), plus `materialized`
|
|
301
|
-
for paged access.
|
|
302
|
-
|
|
303
|
-
Two projection styles:
|
|
320
|
+
Read models are read through `store.readModels`; projections are model-bound (decorators) or declarative (`@projection`), and constraints are class-plus-builder only.
|
|
304
321
|
|
|
305
|
-
|
|
306
|
-
`@cratis/chronicle/projections`: `fromEvent`, `fromEvery`, `fromAll`, `setFrom`,
|
|
307
|
-
`setFromContext`, `setValue`, `join`, `addFrom`, `subtractFrom`, `increment`,
|
|
308
|
-
`decrement`, `count`, `childrenFrom`, `nested`, `clearWith`, `removedWith`,
|
|
309
|
-
`removedWithJoin`, `noAutoMap`, `notRewindable`, `passive`.
|
|
310
|
-
- **Declarative** — `@projection(id?, readModelType?, eventSequenceId?)` on a class
|
|
311
|
-
implementing `IProjectionFor<TReadModel>` with
|
|
312
|
-
`define(builder: IProjectionBuilderFor<TReadModel>): void`.
|
|
313
|
-
|
|
314
|
-
Constraints are `@constraint()` on a class implementing `IConstraint` with a
|
|
315
|
-
`define(builder)`; the builder gives `unique(...)`, `uniqueFor(...)`,
|
|
316
|
-
`perEventSourceType`, `perEventStreamType`, `perEventStreamId`. **There are no
|
|
317
|
-
model-bound constraint decorators in this client** — the class-plus-builder form
|
|
318
|
-
is the only one.
|
|
322
|
+
Read [references/read-models-and-projections.md](references/read-models-and-projections.md) when reading a read model instance, choosing a projection style, or declaring a constraint.
|
|
319
323
|
|
|
320
324
|
### Variants — mutually exclusive read models for one entity's lifecycle
|
|
321
325
|
|
|
322
|
-
|
|
323
|
-
> `5.1.0` baseline (`Source/projections/VariantReclassifier.ts` and siblings).
|
|
324
|
-
> Reverify before claiming support; take the version from npm.
|
|
325
|
-
|
|
326
|
-
Some entities do not have one shape for their whole lifetime — a work item is a
|
|
327
|
-
backlog entry until a pull request exists for it, then it is a pull request
|
|
328
|
-
until it merges. **Model-bound** — `@variantOf(identity, key)` and
|
|
329
|
-
`@entersOn(eventType, key?)`, alongside the ordinary `@fromEvent`/`@setFrom`
|
|
330
|
-
decorators:
|
|
331
|
-
|
|
332
|
-
```typescript
|
|
333
|
-
class WorkItem {} // anchors the group; not itself a read model
|
|
334
|
-
|
|
335
|
-
@variantOf(WorkItem, 'id')
|
|
336
|
-
@entersOn(IssueCreated)
|
|
337
|
-
@fromEvent(IssueCreated)
|
|
338
|
-
@readModel()
|
|
339
|
-
class BacklogItem {
|
|
340
|
-
id = '';
|
|
341
|
-
@setFrom(IssueCreated, 'title') title = '';
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
@variantOf(WorkItem, 'id')
|
|
345
|
-
@entersOn(PullRequestCreated)
|
|
346
|
-
@fromEvent(PullRequestCreated)
|
|
347
|
-
@fromEvent(BuildCompleted) // not the entering event -> update-only join
|
|
348
|
-
@readModel()
|
|
349
|
-
class PullRequestItem {
|
|
350
|
-
id = '';
|
|
351
|
-
@setFrom(PullRequestCreated, 'pullRequestUrl') pullRequestUrl = '';
|
|
352
|
-
@setFrom(BuildCompleted, 'buildStatus') buildStatus = '';
|
|
353
|
-
}
|
|
354
|
-
```
|
|
355
|
-
|
|
356
|
-
`entersOn` is repeatable (a variant may enter on more than one event) and its
|
|
357
|
-
`key` argument names an *event* property, defaulting to the event source id. A
|
|
358
|
-
mapping shared by every variant of an identity goes on a class decorated
|
|
359
|
-
`@globalFor(identity)` instead of being repeated on each variant — every
|
|
360
|
-
variant it targets must actually declare the property it maps, or
|
|
361
|
-
`GlobalHandlerPropertyNotOnVariant` is thrown when the group is built. A class
|
|
362
|
-
carrying only `@globalFor` is never itself registered as a projection.
|
|
363
|
-
|
|
364
|
-
**Declarative** — `variantOf` and `entersOn` are members of
|
|
365
|
-
`IProjectionBuilderFor<TReadModel>` itself:
|
|
366
|
-
|
|
367
|
-
```typescript
|
|
368
|
-
@projection()
|
|
369
|
-
class PullRequestItemProjection implements IProjectionFor<PullRequestItem> {
|
|
370
|
-
define(builder: IProjectionBuilderFor<PullRequestItem>): void {
|
|
371
|
-
builder
|
|
372
|
-
.variantOf(WorkItem, m => m.id)
|
|
373
|
-
.entersOn(PullRequestCreated)
|
|
374
|
-
.from(BuildCompleted); // update-only, same reason
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
```
|
|
326
|
+
One entity with mutually exclusive lifecycle shapes is modeled as variants, with `@variantOf`/`@entersOn`/`@globalFor` or the fluent `.variantOf()`/`.entersOn()`; every variant needs an entering event.
|
|
378
327
|
|
|
379
|
-
|
|
380
|
-
`VariantMustDeclareEntersOnEvent`** when the group is built — a variant that
|
|
381
|
-
could never be entered could never be written to at all, since every other
|
|
382
|
-
handler on it is update-only.
|
|
328
|
+
Read [references/variants.md](references/variants.md) when a read model for one entity changes shape over its lifecycle, or when you meet `VariantMustDeclareEntersOnEvent` or `GlobalHandlerPropertyNotOnVariant`.
|
|
383
329
|
|
|
384
330
|
## Discovery is a runtime file glob — this is the biggest difference
|
|
385
331
|
|
|
@@ -427,28 +373,6 @@ There is none, and none is planned in the source: no container integration, no
|
|
|
427
373
|
and seeders are instantiated by the client itself, so **constructor injection does
|
|
428
374
|
not work**. Use module-scope collaborators, as the shipped sample does.
|
|
429
375
|
|
|
430
|
-
## Common pitfalls
|
|
431
|
-
|
|
432
|
-
| Pitfall | Why it bites |
|
|
433
|
-
| --- | --- |
|
|
434
|
-
| Naming a reactor method after the handler's purpose | Dispatch is by the camelCase event class name; a mismatch is silently never called |
|
|
435
|
-
| `instanceof` on the event inside a handler | It is a `JSON.parse`d plain object, not your class |
|
|
436
|
-
| Event class with no default constructor values under `tsx` | No decorator metadata is emitted, so the schema comes out empty |
|
|
437
|
-
| Two `@eventType()` classes sharing a class name | The id defaults to the class name and they collide |
|
|
438
|
-
| Deploying compiled `dist/*.js` with default discovery | The default glob matches `**/*.ts`; nothing is discovered |
|
|
439
|
-
| Omitting a side-effect import of an artifact module | Its decorator never runs, so it is never registered |
|
|
440
|
-
| Forgetting `import 'reflect-metadata'` at the entry point | Decorators do not work at runtime |
|
|
441
|
-
| Forgetting to install `@cratis/fundamentals` | It is a peer dependency and is not installed for you |
|
|
442
|
-
| Importing `ChronicleConnectionString` | There is no `./connection` export; pass a string |
|
|
443
|
-
| Expecting single `append()` to set a stream or subject | Those fields are hardcoded; use the `EventForEventSourceId[]` overload |
|
|
444
|
-
| A connection string with no credentials | Silently falls back to the development client credentials |
|
|
445
|
-
| Shipping the default TLS behavior | `skipTlsValidation` defaults to `true` |
|
|
446
|
-
| Constructor-injecting a dependency into a reactor | There is no DI; the client constructs it |
|
|
447
|
-
| Carrying a `3.x` example forward | Tags, the reducer context parameter, and two RPC names changed in `4.0.0` |
|
|
448
|
-
| Reading `result.sequenceNumber` as a number | It is a `bigint` behind `.value` |
|
|
449
|
-
| A `@globalFor` mapping targeting a property one variant lacks | `GlobalHandlerPropertyNotOnVariant` when the group is built, not a silently skipped mapping |
|
|
450
|
-
| Expecting a `@globalFor`-only class to appear as a projection | It is never registered on its own; it is merged into its variants |
|
|
451
|
-
|
|
452
376
|
## Verify
|
|
453
377
|
|
|
454
378
|
- The installed version is the one you intended, taken from npm, and
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
## Read models and projections
|
|
2
|
+
|
|
3
|
+
`store.readModels` — `Source/readModels/IReadModels.ts`: `getInstanceById(type, key, sessionId?)`
|
|
4
|
+
(`:38`), `getInstances(type, eventCount?)` (`:46`), `getSnapshotsById` (`:54`),
|
|
5
|
+
`watch(type): AsyncIterable<ReadModelChangeset<T>>` (`:61`), plus `materialized`
|
|
6
|
+
for paged access.
|
|
7
|
+
|
|
8
|
+
Two projection styles:
|
|
9
|
+
|
|
10
|
+
- **Model-bound** — decorators on the read model, from
|
|
11
|
+
`@cratis/chronicle/projections`: `fromEvent`, `fromEvery`, `fromAll`, `setFrom`,
|
|
12
|
+
`setFromContext`, `setValue`, `join`, `addFrom`, `subtractFrom`, `increment`,
|
|
13
|
+
`decrement`, `count`, `childrenFrom`, `nested`, `clearWith`, `removedWith`,
|
|
14
|
+
`removedWithJoin`, `noAutoMap`, `notRewindable`, `passive`.
|
|
15
|
+
- **Declarative** — `@projection(id?, readModelType?, eventSequenceId?)` on a class
|
|
16
|
+
implementing `IProjectionFor<TReadModel>` with
|
|
17
|
+
`define(builder: IProjectionBuilderFor<TReadModel>): void`.
|
|
18
|
+
|
|
19
|
+
Constraints are `@constraint()` on a class implementing `IConstraint` with a
|
|
20
|
+
`define(builder)`; the builder gives `unique(...)`, `uniqueFor(...)`,
|
|
21
|
+
`perEventSourceType`, `perEventStreamType`, `perEventStreamId`. **There are no
|
|
22
|
+
model-bound constraint decorators in this client** — the class-plus-builder form
|
|
23
|
+
is the only one.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
## Variants — mutually exclusive read models for one entity's lifecycle
|
|
2
|
+
|
|
3
|
+
> Requires `@cratis/chronicle` `6.2.0` or later — newer than this skill's
|
|
4
|
+
> `5.1.0` baseline (`Source/projections/VariantReclassifier.ts` and siblings).
|
|
5
|
+
> Reverify before claiming support; take the version from npm.
|
|
6
|
+
|
|
7
|
+
Some entities do not have one shape for their whole lifetime — a work item is a
|
|
8
|
+
backlog entry until a pull request exists for it, then it is a pull request
|
|
9
|
+
until it merges. **Model-bound** — `@variantOf(identity, key)` and
|
|
10
|
+
`@entersOn(eventType, key?)`, alongside the ordinary `@fromEvent`/`@setFrom`
|
|
11
|
+
decorators:
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
class WorkItem {} // anchors the group; not itself a read model
|
|
15
|
+
|
|
16
|
+
@variantOf(WorkItem, 'id')
|
|
17
|
+
@entersOn(IssueCreated)
|
|
18
|
+
@fromEvent(IssueCreated)
|
|
19
|
+
@readModel()
|
|
20
|
+
class BacklogItem {
|
|
21
|
+
id = '';
|
|
22
|
+
@setFrom(IssueCreated, 'title') title = '';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@variantOf(WorkItem, 'id')
|
|
26
|
+
@entersOn(PullRequestCreated)
|
|
27
|
+
@fromEvent(PullRequestCreated)
|
|
28
|
+
@fromEvent(BuildCompleted) // not the entering event -> update-only join
|
|
29
|
+
@readModel()
|
|
30
|
+
class PullRequestItem {
|
|
31
|
+
id = '';
|
|
32
|
+
@setFrom(PullRequestCreated, 'pullRequestUrl') pullRequestUrl = '';
|
|
33
|
+
@setFrom(BuildCompleted, 'buildStatus') buildStatus = '';
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`entersOn` is repeatable (a variant may enter on more than one event) and its
|
|
38
|
+
`key` argument names an *event* property, defaulting to the event source id. A
|
|
39
|
+
mapping shared by every variant of an identity goes on a class decorated
|
|
40
|
+
`@globalFor(identity)` instead of being repeated on each variant — every
|
|
41
|
+
variant it targets must actually declare the property it maps, or
|
|
42
|
+
`GlobalHandlerPropertyNotOnVariant` is thrown when the group is built. A class
|
|
43
|
+
carrying only `@globalFor` is never itself registered as a projection.
|
|
44
|
+
|
|
45
|
+
**Declarative** — `variantOf` and `entersOn` are members of
|
|
46
|
+
`IProjectionBuilderFor<TReadModel>` itself:
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
@projection()
|
|
50
|
+
class PullRequestItemProjection implements IProjectionFor<PullRequestItem> {
|
|
51
|
+
define(builder: IProjectionBuilderFor<PullRequestItem>): void {
|
|
52
|
+
builder
|
|
53
|
+
.variantOf(WorkItem, m => m.id)
|
|
54
|
+
.entersOn(PullRequestCreated)
|
|
55
|
+
.from(BuildCompleted); // update-only, same reason
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
**A variant that declares no `@entersOn`/`entersOn(...)` throws
|
|
61
|
+
`VariantMustDeclareEntersOnEvent`** when the group is built — a variant that
|
|
62
|
+
could never be entered could never be written to at all, since every other
|
|
63
|
+
handler on it is update-only.
|
|
@@ -16,6 +16,19 @@ events.
|
|
|
16
16
|
> event types and change schemas freely. A migration written too early is dead
|
|
17
17
|
> code that hides the real schema in the history.
|
|
18
18
|
|
|
19
|
+
## Route near misses
|
|
20
|
+
|
|
21
|
+
- An accepted `.play` model under the model root covers the behavior, or the
|
|
22
|
+
repository is opted in (the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the project set
|
|
23
|
+
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
24
|
+
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
25
|
+
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
26
|
+
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
27
|
+
say so and do not author `.play` from memory.
|
|
28
|
+
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
29
|
+
attachments, or gap-fill scope (`cratis-screenplay-render-and-gap-fill`);
|
|
30
|
+
never edit Stage-managed output.
|
|
31
|
+
|
|
19
32
|
## Verified product sources
|
|
20
33
|
|
|
21
34
|
This skill is verified against these exact sources:
|
|
@@ -220,19 +233,6 @@ is expected, since the prior generation records history rather than new intent.
|
|
|
220
233
|
| Splitting one event into two inside `Upcast` | a migration produces one event; model a split as a reactor or a command |
|
|
221
234
|
| Adding a new generation for a renamed enum member | not needed; only removal or renumbering requires one |
|
|
222
235
|
|
|
223
|
-
## Route near misses
|
|
224
|
-
|
|
225
|
-
- An accepted `.play` model under the model root covers the behavior, or the
|
|
226
|
-
repository is opted in (the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the project set
|
|
227
|
-
`mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
|
|
228
|
-
output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
|
|
229
|
-
`cratis-screenplay-modeling-lifecycle`): change the model first with
|
|
230
|
-
`cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
|
|
231
|
-
say so and do not author `.play` from memory.
|
|
232
|
-
Edit code here only for infrastructure, clients, adapters, Screenplay code
|
|
233
|
-
attachments, or gap-fill scope (`cratis-screenplay-render-and-gap-fill`);
|
|
234
|
-
never edit Stage-managed output.
|
|
235
|
-
|
|
236
236
|
## Verify
|
|
237
237
|
|
|
238
238
|
- The current record carries the bumped `[EventType(generation: N)]`.
|
|
@@ -18,7 +18,7 @@ contract is unverified, so every tool and prompt remains evidence-blocked.
|
|
|
18
18
|
Read the generated classifications before answering:
|
|
19
19
|
|
|
20
20
|
- [Observational guidance](references/observational-tools.md) records subjects
|
|
21
|
-
admitted for bounded read-only guidance.
|
|
21
|
+
admitted for bounded read-only guidance. The admitted observational inventory is empty.
|
|
22
22
|
- [Blocked guidance](references/blocked-tools.md) records the deny-all boundary.
|
|
23
23
|
|
|
24
24
|
Do not invoke, simulate, install, configure, or provide an invocation payload
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: cratis-chronicle-projection
|
|
3
|
-
description: Add Chronicle projection behavior to an existing read model - model-bound attributes first, the fluent IProjectionFor
|
|
3
|
+
description: Add Chronicle projection behavior to an existing read model - model-bound attributes first, the fluent IProjectionFor builder when they cannot express the shape. Covers AutoMap, keys, children and nested types, counters, event-sequence selection, variants (VariantOf and EntersOn, as attributes or fluent calls) for an entity with mutually exclusive lifecycle shapes such as a work item that is a backlog entry then a pull request then closed, and the startup-crash traps. Use when populating a read model from events; do not use to create the read model and its query surface, and do not reach for a reducer before exhausting these options.
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -26,6 +26,15 @@ Reverify product sources before claiming support for another version.
|
|
|
26
26
|
> target needs no `[ReadModel]` at all — that attribute is what gives it an Arc
|
|
27
27
|
> query surface.
|
|
28
28
|
|
|
29
|
+
## What makes a type a model-bound projection
|
|
30
|
+
|
|
31
|
+
Chronicle treats a type as a model-bound projection when the class, its primary
|
|
32
|
+
constructor parameters, or its public instance properties carry an
|
|
33
|
+
`[EventSequence]` attribute or any projection annotation — **except
|
|
34
|
+
`[Passive]`**, which is deliberately excluded. `[Passive]` on its own therefore
|
|
35
|
+
does not make a read model a projection; it changes how an existing projection
|
|
36
|
+
is registered.
|
|
37
|
+
|
|
29
38
|
## Model-bound projections — the default
|
|
30
39
|
|
|
31
40
|
Put the projection on the read model with attributes. No separate class.
|
|
@@ -47,7 +56,7 @@ except inside a scope where you disabled it.
|
|
|
47
56
|
`[Key]` is `Cratis.Chronicle.Keys.KeyAttribute`. It has no arguments and targets
|
|
48
57
|
a property or a record constructor parameter, never the class.
|
|
49
58
|
|
|
50
|
-
|
|
59
|
+
When authoring a model-bound projection, read [references/model-bound-attributes.md](references/model-bound-attributes.md)
|
|
51
60
|
for the complete attribute list with exact arities, parameter names, and valid
|
|
52
61
|
targets. Two things there are worth knowing before you write anything:
|
|
53
62
|
|
|
@@ -78,7 +87,7 @@ public class <ReadModelName>Projection : IProjectionFor<<ReadModelName>>
|
|
|
78
87
|
the interface** — do not add one. Use `[Projection(id: "<id>")]` when the
|
|
79
88
|
identity must be explicit.
|
|
80
89
|
|
|
81
|
-
|
|
90
|
+
When attributes cannot express the shape and you use the fluent builder, read [references/fluent-builder.md](references/fluent-builder.md) for the real
|
|
82
91
|
member list. The trap that costs the most time: **`UsingKey`, `UsingParentKey`,
|
|
83
92
|
`UsingCompositeKey`, and `UsingConstantKey` are not on the projection builder.**
|
|
84
93
|
They live on the per-event builder that `From<TEvent>` hands to your callback.
|
|
@@ -171,7 +180,7 @@ join, so an out-of-order or replayed event can never resurrect a variant the
|
|
|
171
180
|
entity has since left. A variant that declares no entering event at all throws
|
|
172
181
|
`VariantMustDeclareEntersOnEvent` at startup.
|
|
173
182
|
|
|
174
|
-
|
|
183
|
+
When declaring a variant group or shared variant mappings, read [references/variants.md](references/variants.md) for the complete group
|
|
175
184
|
declaration, the update-only reclassification in full, `[GlobalFor<T>]` rules
|
|
176
185
|
and its declaration-error trap, and best practices for picking an identity
|
|
177
186
|
type.
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# The fluent projection builder
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- The interfaces
|
|
6
|
+
- `IProjectionBuilderFor<TReadModel>` — its own members
|
|
7
|
+
- Inherited from `IProjectionBuilder<TReadModel, TBuilder>`
|
|
8
|
+
- Keys live on the per-event builder
|
|
9
|
+
- `Set(...).To(...)`
|
|
10
|
+
- When the fluent form is the only option
|
|
11
|
+
- AutoMap default
|
|
12
|
+
|
|
3
13
|
Verified against `Cratis.Chronicle` `18.3.0`, namespace
|
|
4
14
|
`Cratis.Chronicle.Projections`.
|
|
5
15
|
|
package/package/corpus/skills/cratis-chronicle-projection/references/model-bound-attributes.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Model-bound projection attributes
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Namespaces that are not `Projections.ModelBound`
|
|
6
|
+
- Source and shape
|
|
7
|
+
- Setting values
|
|
8
|
+
- Counters
|
|
9
|
+
- Variants
|
|
10
|
+
- Relationships
|
|
11
|
+
- Source selection
|
|
12
|
+
- Labels, not filters
|
|
13
|
+
- What makes a type a model-bound projection
|
|
14
|
+
- AutoMap
|
|
15
|
+
|
|
3
16
|
Verified against `Cratis.Chronicle` `18.3.0`.
|
|
4
17
|
|
|
5
18
|
Unless noted, every attribute below lives in
|
|
@@ -116,12 +129,7 @@ for reducers and reactors.
|
|
|
116
129
|
|
|
117
130
|
## What makes a type a model-bound projection
|
|
118
131
|
|
|
119
|
-
|
|
120
|
-
constructor parameters, or its public instance properties carry an
|
|
121
|
-
`[EventSequence]` attribute or any projection annotation — **except
|
|
122
|
-
`[Passive]`**, which is deliberately excluded. `[Passive]` on its own therefore
|
|
123
|
-
does not make a read model a projection; it changes how an existing projection
|
|
124
|
-
is registered.
|
|
132
|
+
See "What makes a type a model-bound projection" in SKILL.md.
|
|
125
133
|
|
|
126
134
|
## AutoMap
|
|
127
135
|
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Variants — mutually exclusive read models for one entity
|
|
2
2
|
|
|
3
|
+
## Contents
|
|
4
|
+
|
|
5
|
+
- Declaring a group — model-bound
|
|
6
|
+
- Declaring a group — fluent (`IProjectionFor<T>`)
|
|
7
|
+
- Only the entering event can create a variant
|
|
8
|
+
- Sharing handlers across variants
|
|
9
|
+
- Startup-crash trap
|
|
10
|
+
- Best practices
|
|
11
|
+
|
|
3
12
|
Verified against `Cratis.Chronicle` `19.1.0` (first version carrying this
|
|
4
13
|
feature; the skill's own baseline in `SKILL.md` is `18.3.0` — variants need at
|
|
5
14
|
least `19.1.0`).
|