@cratis/pi 7.48.3 → 7.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/agents/backend-developer.md +1 -1
- package/package/corpus/agents/screenplay-modeler.md +2 -1
- package/package/corpus/agents/screenplay-renderer.md +2 -2
- package/package/corpus/agents/screenplay-reviewer.md +1 -1
- package/package/corpus/agents/slice-implementer.md +15 -5
- package/package/corpus/harnesses/copilot/instructions/application-profile.instructions.md +3 -3
- package/package/corpus/harnesses/copilot/instructions/csharp.instructions.md +3 -1
- package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +3 -3
- package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +6 -3
- package/package/corpus/hooks/README.md +28 -1
- package/package/corpus/hooks/scripts/cratis-guard-writes.sh +75 -0
- package/package/corpus/prompts/add-projection.prompt.md +2 -1
- package/package/corpus/prompts/add-reducer.prompt.md +6 -4
- package/package/corpus/rules/application-profile.md +3 -3
- package/package/corpus/rules/csharp.md +3 -1
- package/package/corpus/rules/glossary.md +3 -3
- package/package/corpus/rules/vertical-slices.md +6 -3
- package/package/corpus/skills/cratis-application-slice-conformance/LICENSE +5 -0
- package/package/corpus/skills/cratis-application-slice-conformance/references/build-prompts.md +38 -19
- package/package/corpus/skills/cratis-application-slice-conformance/references/checklists.md +4 -0
- package/package/corpus/skills/cratis-application-slice-conformance/references/provenance.md +17 -0
- package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +27 -0
- package/package/corpus/skills/cratis-application-slice-specifications/references/provenance.md +6 -0
- package/package/corpus/skills/cratis-chronicle-client-dotnet/SKILL.md +16 -33
- package/package/corpus/skills/cratis-chronicle-client-dotnet/references/discovery.md +92 -7
- package/package/corpus/skills/cratis-chronicle-event-modeling/LICENSE +5 -0
- package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +4 -1
- package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +18 -10
- package/package/corpus/skills/cratis-chronicle-reactor/references/provenance.md +6 -0
- package/package/corpus/skills/cratis-chronicle-reactor/references/slice-delivery-checklist.md +5 -0
- package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +46 -18
- package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +34 -14
- package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +194 -38
- package/package/corpus/skills/cratis-screenplay-discovery/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +3 -0
- package/package/corpus/skills/cratis-screenplay-discovery/references/domain-analysis-template.md +26 -1
- package/package/corpus/skills/cratis-screenplay-discovery/references/provenance.md +9 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +7 -5
- package/package/corpus/skills/cratis-screenplay-event-modeling/references/provenance.md +10 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/SKILL.md +31 -34
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/evidence-table-template.md +64 -2
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/expert-verification.md +18 -1
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/interview-findings.md +5 -2
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/loss-report-template.md +5 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/provenance.md +20 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/re-entry-and-passes.md +89 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/rule-modeling.md +9 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/signal-to-intent.md +28 -1
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/ui-observation.md +4 -0
- package/package/corpus/skills/cratis-screenplay-legacy-extraction/verification.json +4 -0
- package/package/corpus/skills/cratis-screenplay-model-review/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +5 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/checklist.md +1 -1
- package/package/corpus/skills/cratis-screenplay-model-review/references/model-inventory-report.md +11 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/provenance.md +10 -0
- package/package/corpus/skills/cratis-screenplay-model-review/references/stressor-analysis.md +74 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/SKILL.md +12 -11
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/delivery-protocol.md +2 -2
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/{drift-and-ledger.md → drift-and-fallback-record.md} +53 -6
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/gap-fill-handoff.md +12 -11
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/provenance.md +11 -1
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/renderability-gate.md +3 -3
- package/package/corpus/skills/cratis-screenplay-render-and-gap-fill/references/worked-example.md +2 -2
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/SKILL.md +6 -6
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/coverage-matrix.md +7 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/provenance.md +9 -0
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-catalogue.md +29 -3
- package/package/corpus/skills/cratis-screenplay-scenario-coverage/references/scenario-examples.md +2 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/LICENSE +5 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/SKILL.md +5 -4
- package/package/corpus/skills/cratis-screenplay-slice-design/references/command-inventory.md +64 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/field-lineage.md +24 -0
- package/package/corpus/skills/cratis-screenplay-slice-design/references/provenance.md +10 -0
- package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +1 -0
- package/package.json +1 -1
package/package/corpus/skills/cratis-application-slice-conformance/references/build-prompts.md
CHANGED
|
@@ -23,7 +23,7 @@ coordinator's ownership of status, git and shared notes.
|
|
|
23
23
|
records in the repository) to understand the global structure.
|
|
24
24
|
- **Owned paths.** Edit only the slice's own folder (`<Module>/<Feature>/<Slice>/`, backend,
|
|
25
25
|
frontend and specifications together) and any path the brief names. Do not browse unrelated
|
|
26
|
-
slices. Bounded reads of what the contract references are allowed and expected: the events,
|
|
26
|
+
slices, except the single delivered sibling selected in section 2. Bounded reads of what the contract references are allowed and expected: the events,
|
|
27
27
|
views, concepts and inherited authorization the slice names, and shared contracts it depends
|
|
28
28
|
on. Leave routing and registration files alone unless the brief names them.
|
|
29
29
|
- Each slice is self-contained and focused on one behavior; keep concerns separated inside it.
|
|
@@ -45,7 +45,18 @@ invent, assume or guess a field or a rule that is not in it.
|
|
|
45
45
|
|
|
46
46
|
1. Read the slice from the contract in full: description, realization notes, specifications,
|
|
47
47
|
concepts, inherited authorization, referenced events and views.
|
|
48
|
-
2.
|
|
48
|
+
2. Search case-insensitively for the qualified slice folder and its command, event, read-model
|
|
49
|
+
and reactor names before writing. If a realization exists, diff it against the contract and
|
|
50
|
+
update it in place within owned paths; never build a second realization. Reuse referenced
|
|
51
|
+
Chronicle event types and read models, not parallel copies. Persisted event shape changes go
|
|
52
|
+
through `cratis-chronicle-event-type-migration`, never an in-place property removal or rename;
|
|
53
|
+
identity-affecting changes return to the identity owner. If the required path is not owned,
|
|
54
|
+
report it rather than widening scope.
|
|
55
|
+
3. For a new slice, read one delivered sibling of the same type: prefer the same feature, then
|
|
56
|
+
module, then shared events or read model. Read only its contract and realization files; mirror
|
|
57
|
+
file shape, naming, specification layout and authorized registration seams. The contract and
|
|
58
|
+
corpus rules outrank precedent; report a rule-breaking precedent rather than copying it.
|
|
59
|
+
4. Determine the slice type:
|
|
49
60
|
- `Translate` (a `capture`, or a translator `reaction` over an imported or captured event):
|
|
50
61
|
outside data becomes our events. Realize by the actual construct and trigger, not the slice
|
|
51
62
|
label: a capture is an ingestion adapter behind an effect boundary
|
|
@@ -59,18 +70,18 @@ invent, assume or guess a field or a rule that is not in it.
|
|
|
59
70
|
`cratis-chronicle-projection`.
|
|
60
71
|
- `StateChange` (the default: a `command` that `produces` events): `cratis-arc-command`,
|
|
61
72
|
`cratis-arc-command-validation`.
|
|
62
|
-
|
|
63
|
-
|
|
73
|
+
5. Invoke the matching skill and follow it completely; do not deviate.
|
|
74
|
+
6. Verify against the contract (`SKILL.md` step 3 and `references/checklists.md`): every
|
|
64
75
|
command field, event field, read-model property and specification appears in the
|
|
65
76
|
implementation. No invented fields: if it is not in the contract, it is not in the code.
|
|
66
|
-
|
|
77
|
+
7. **Iteration checks:** build the affected project and run the slice's own specifications while
|
|
67
78
|
you work.
|
|
68
|
-
|
|
79
|
+
8. **Completion gate:** before reporting `done`, run what the repository's CI-equivalent gate
|
|
69
80
|
requires (its Tier 1 checks, plus the integration evidence for the behavior claimed;
|
|
70
81
|
`cratis-screenplay-render-and-gap-fill` `references/gap-fill-handoff.md`, "What comes
|
|
71
82
|
back"). Slice-only runs are never the completion gate; an unavailable check is
|
|
72
83
|
`not run: <reason>`.
|
|
73
|
-
|
|
84
|
+
9. Git effects (commit, merge, push) happen only when the brief separately authorizes them, and
|
|
74
85
|
a commit contains only the files you own. Otherwise leave the changes in the working tree and
|
|
75
86
|
return the result.
|
|
76
87
|
|
|
@@ -93,9 +104,9 @@ ends the iteration; the brief, never the agent, changes scope.
|
|
|
93
104
|
and two workers can both write it. Rely on atomic claiming only where a tracker provides a
|
|
94
105
|
verified compare-and-set operation; there, a rejected claim means another worker owns the
|
|
95
106
|
slice: do not retry it, take the next one assigned to you, or report that nothing remains.
|
|
96
|
-
4. Work on one slice only; never chain two in one iteration. Under a
|
|
97
|
-
|
|
98
|
-
never select another scope; one slice per run stays the default outside a
|
|
107
|
+
4. Work on one slice only; never chain two in one iteration. Under a scoped brief (one assigned
|
|
108
|
+
scope, which may hold several slices), take one slice at a time within that scope and
|
|
109
|
+
never select another scope; one slice per run stays the default outside a scoped brief.
|
|
99
110
|
5. Read the slice's contract. Explicit realization requirements in the description bind the
|
|
100
111
|
implementation, cannot contradict executable parts and are never supplemented with inferred
|
|
101
112
|
rules; descriptive prose that is not an explicit requirement is a hint. Name each requirement
|
|
@@ -109,19 +120,24 @@ ends the iteration; the brief, never the agent, changes scope.
|
|
|
109
120
|
if the business logic is implemented as defined, the APIs exist, every scenario in the
|
|
110
121
|
contract is implemented in code and the slice fulfills the contract. **There must be no
|
|
111
122
|
specification in the contract without an executable equivalent in code.**
|
|
112
|
-
9. Run the iteration checks, then the completion gate (section 2, steps
|
|
123
|
+
9. Run the iteration checks, then the completion gate (section 2, steps 7 and 8).
|
|
113
124
|
10. Review the slice's specifications against `cratis-screenplay-scenario-coverage` when it is
|
|
114
125
|
installed, and list any applicable scenario the contract lacks as a proposal for the
|
|
115
126
|
contract (never add it as a second contract in code).
|
|
116
127
|
11. Report the result packet (section 4) and finish.
|
|
117
128
|
|
|
118
|
-
**Escalation.**
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
129
|
+
**Escalation.** Read the contract and slice-type skills fully before asking. Block that scope
|
|
130
|
+
with one question or edit request for a missing or conflicting rule, authorization, money, time
|
|
131
|
+
or identity behavior; an undecided event, command or field name; an undeclared/unimported
|
|
132
|
+
referenced event or view; or prose contradicting executable parts. The lifecycle's
|
|
133
|
+
`references/stop-or-assume.md` delivery triggers and unconditional stops apply and win.
|
|
134
|
+
For non-behavioral details only, assume visibly and continue: a missing label may use the spaced
|
|
135
|
+
command/property name, isolation may need fresh test identifiers, and file placement within the
|
|
136
|
+
slice, invalid spec-name conversion or an unspecified layout may follow local conventions.
|
|
137
|
+
Return each assumption with its address and consequence if wrong in the fallback record.
|
|
138
|
+
`blocked` means progress needs a person, not that confirmation seemed safer.
|
|
139
|
+
|
|
140
|
+
Stop conditions: after one slice, stop regardless of what else is assigned (under a scoped brief,
|
|
125
141
|
after one slice, or when the assigned scope is done or blocked, and never continue into another
|
|
126
142
|
scope); if nothing in the
|
|
127
143
|
scope is assigned, report that and stop; if every slice in the scope is `done`, report that.
|
|
@@ -130,7 +146,10 @@ scope is assigned, report that and stop; if every slice in the scope is `done`,
|
|
|
130
146
|
|
|
131
147
|
Use the lifecycle's report and state format (`cratis-screenplay-modeling-lifecycle`
|
|
132
148
|
`references/handoff-template.md`, with its `STATE.md` under `.ai-work/`) when it is installed,
|
|
133
|
-
otherwise this shape.
|
|
149
|
+
otherwise this shape. In either format, include the realization fields defined once in
|
|
150
|
+
`cratis-screenplay-render-and-gap-fill/references/drift-and-fallback-record.md`, "Fallback record";
|
|
151
|
+
do not create a second field schema. One packet per slice, returned to the coordinator, not
|
|
152
|
+
appended per step:
|
|
134
153
|
|
|
135
154
|
```text
|
|
136
155
|
Outcome: <qualified slice address> - done | partial | blocked
|
|
@@ -67,6 +67,10 @@ the renderer no right to browse managed output or implement rejected semantics.
|
|
|
67
67
|
## Automation and Translation
|
|
68
68
|
- Each field of the produced command or event maps from the trigger event, an injected read
|
|
69
69
|
model or a contract mapping, and from nothing else.
|
|
70
|
+
- If the reaction consumes a pending-work read model, its successful effect's recorded event
|
|
71
|
+
(directly or through the invoked command) removes that item; the view has a specification
|
|
72
|
+
seeding the trigger then completion and asserting absence. Otherwise the next occurrence or
|
|
73
|
+
redelivery can select completed work again.
|
|
70
74
|
- No filter condition the contract does not state.
|
|
71
75
|
- The repeated-delivery behaviour in the contract has a specification: what happens when the
|
|
72
76
|
trigger arrives twice.
|
|
@@ -21,3 +21,20 @@ by Martin Dilger and Nebulit GmbH (https://nebulit.de), used with the explicit c
|
|
|
21
21
|
| `.build-kit/AGENTS.md`: learnings that the repository pattern beats the template; a mapping-versus-notes conflict resolved in favor of notes | `references/contract-and-precedence.md`; `references/build-prompts.md` section 5 | Repository-pattern idea adapted; the notes-over-mapping rule is not adopted because executable parts beat prose here |
|
|
22
22
|
|
|
23
23
|
No TrogonStack/agentskills text is used in this skill.
|
|
24
|
+
|
|
25
|
+
### Eventmodelers Build-Kits
|
|
26
|
+
|
|
27
|
+
Source: https://github.com/Nebulit-GmbH/Eventmodelers-Build-Kits, by Martin Dilger and Nebulit GmbH
|
|
28
|
+
(https://nebulit.de), used with the explicit consent of Martin Dilger and Nebulit GmbH.
|
|
29
|
+
|
|
30
|
+
| Source skill | Used in | How |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| `record-evidence` (classic stack) | `build-prompts.md` result pointer; Slice Implementer output, using the fallback record in `cratis-screenplay-render-and-gap-fill` | adapted closely: one row per element, field and specification, files created and modified, shared seams, assumptions and checks, with no code excerpts; the board note dropped |
|
|
33
|
+
|
|
34
|
+
## Method lineage
|
|
35
|
+
|
|
36
|
+
| Idea | Used in | Credit |
|
|
37
|
+
| --- | --- | --- |
|
|
38
|
+
| Visible non-behavioral assumptions while decisions still block | `build-prompts.md` escalation; Slice Implementer contract gate | Martin Dilger / Nebulit GmbH, Eventmodelers build kits (`classic backend-prompt`, `classic CLAUDE.md`), used with their explicit consent; idea, our own wording |
|
|
39
|
+
| Look for an existing realization before selecting one delivered sibling | `build-prompts.md` mandatory flow; Slice Implementer realization search | Martin Dilger / Nebulit GmbH, Eventmodelers build kits (`classic build-state-change`, `classic build-state-view`), used with their explicit consent; idea, our own wording |
|
|
40
|
+
| Completed work leaves the pending-work view | `checklists.md` Automation and Translation | Martin Dilger / Nebulit GmbH, Eventmodelers build kits (`prototype`), used with their explicit consent; idea, our own wording |
|
|
@@ -81,6 +81,33 @@ list it in the report and, where a model exists, route it to
|
|
|
81
81
|
Without a contract (code-first scope), derive the list from Step 3 and say that
|
|
82
82
|
you did.
|
|
83
83
|
|
|
84
|
+
### Reading a `.play` specification
|
|
85
|
+
|
|
86
|
+
Read the actual assignments, not a prose retelling; syntax and supported forms belong to
|
|
87
|
+
`cratis-screenplay-specifications`.
|
|
88
|
+
- `given <Event>` becomes prior facts seeded with `Given.ForEventSource(...).Events(...)`.
|
|
89
|
+
`given readmodel <Type>` becomes a pinned complete `.ReadModel(...)` instance, including its
|
|
90
|
+
key: the contract deliberately makes event history irrelevant here. Protected decisions still
|
|
91
|
+
need event-backed guards (Step 5); report a pin that cannot witness the required enforcement.
|
|
92
|
+
- `when <Command>` assignments fill that command; `given caller` supplies the scenario's caller,
|
|
93
|
+
not an invented default role. Use the matching scenario for append, query or reaction actions.
|
|
94
|
+
- `then <Event>` assignments become the appended-event predicate;
|
|
95
|
+
`then readmodel` assignments become instance assertions. Assert every named value and honor
|
|
96
|
+
`exactly`, ordering and absence where stated. Do not assert an unmentioned generated identifier
|
|
97
|
+
or timestamp; still use required source identities to select the result. A broader property
|
|
98
|
+
coverage gap goes back to the contract owner rather than adding a new business assertion.
|
|
99
|
+
- `description` and slice `documentation` provide context for a name or XML summary, not extra
|
|
100
|
+
setup, assertions or inferred rules. Explicit realization requirements still bind delivery;
|
|
101
|
+
reconcile them with executable parts through `cratis-application-slice-conformance`.
|
|
102
|
+
- A `parameter`/`case` table yields independent examples by substituting each `case.<parameter>`
|
|
103
|
+
value. The reference runner identifies each row as `<Specification>_<Case>`; retain that name
|
|
104
|
+
in the specification map, while C# uses the repository's `when_.../and_<case>` convention.
|
|
105
|
+
Name parity is a mapping requirement, not a requirement to rename C# classes.
|
|
106
|
+
- `then error` requires unsuccessful execution plus the named validation/constraint reason where
|
|
107
|
+
stated (Step 6). A specified message must be checked, using equality when exact wording is
|
|
108
|
+
contracted. `then denied` instead requires unsuccessful execution and `ShouldNotBeAuthorized()`;
|
|
109
|
+
it is not a validation error. Keep every other rule satisfied so the named refusal is witnessed.
|
|
110
|
+
|
|
84
111
|
## Step 1 — Place the files
|
|
85
112
|
|
|
86
113
|
Specifications live **in the slice folder**, beside the `.cs` they specify, each
|
package/package/corpus/skills/cratis-application-slice-specifications/references/provenance.md
CHANGED
|
@@ -11,3 +11,9 @@ by Martin Dilger and Nebulit GmbH (https://nebulit.de), used with the explicit c
|
|
|
11
11
|
|---|---|---|
|
|
12
12
|
| `.claude/skills/build-automation/SKILL.md`: checklist question "what happens if the command fires twice" | `SKILL.md` Step 3 item 5 | idea; our own wording kept |
|
|
13
13
|
| `.claude/skills/build-automation/SKILL.md`: one error specification per rule; build from the slice definition first | `SKILL.md` Step 0 and Step 6 | idea; our own wording kept |
|
|
14
|
+
|
|
15
|
+
## Method lineage
|
|
16
|
+
|
|
17
|
+
| Idea | Used in | Credit |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| Scenario decision state and essential values become setup and assertions, while background notes stay context | `SKILL.md`, Reading a `.play` specification | Martin Dilger / Nebulit GmbH, Eventmodelers build kits (`place-element`, `examples`, `classic build-state-change`, `classic build-state-view`), used with their explicit consent; idea, our own wording |
|
|
@@ -21,7 +21,8 @@ from v19.50.0; earlier release numbers identify feature availability.
|
|
|
21
21
|
|
|
22
22
|
| Package | Version | Purpose |
|
|
23
23
|
| --- | --- | --- |
|
|
24
|
-
| `Cratis.Chronicle` | `19.50.1` | `ChronicleClient`, `IEventStore`, `[EventType]`, observers |
|
|
24
|
+
| `Cratis.Chronicle` | `19.50.1` | `ChronicleClient`, `IEventStore`, `[EventType]`, existing observers |
|
|
25
|
+
| `Cratis.Chronicle` | `19.59.4` | Reducer discovery/nomination at tag `v19.59.4`: `Source/Clients/DotNET/DefaultClientArtifactsProvider.cs`, `Reducers/{SelfReducerMethods,RegisteredReducerReadModel,ReducerCatalog}.cs`, `Registrations/ExplicitArtifacts.Types.cs` |
|
|
25
26
|
| `Cratis.Chronicle.Connections` | `19.50.1` | `ChronicleConnectionString`, connection lifecycle |
|
|
26
27
|
| `Cratis.Chronicle.AspNetCore` | `19.50.1` | ASP.NET Core wiring, header/subdomain namespace resolvers |
|
|
27
28
|
| `Cratis.Chronicle.Testing` | `19.50.1` | in-process scenarios |
|
|
@@ -323,46 +324,28 @@ results live on the unit of work.
|
|
|
323
324
|
| Artifact | Shape | Source |
|
|
324
325
|
| --- | --- | --- |
|
|
325
326
|
| Reactor | marker `IReactor` (empty interface), `[Reactor]` optional | `Reactors/IReactor.cs:9`, `Reactors/ReactorAttribute.cs:14` |
|
|
326
|
-
|
|
|
327
|
+
| Self model (.NET reducer default) | public static `Reduce(event, model? current[, EventContext])`, returns model or `Task<model>` (nullable results allowed); no marker | `Reducers/SelfReducerMethods.cs` |
|
|
328
|
+
| Separate reducer | `IReducerFor<TReadModel>` for DI, replay instance behavior or separation | `Reducers/IReducerFor.cs:10` |
|
|
329
|
+
| Plain reducer | instance handlers infer one model; nomination required | `Reducers/RegisteredReducerReadModel.cs` |
|
|
327
330
|
| Projection | `IProjectionFor<TReadModel>` with `Define(IProjectionBuilderFor<TReadModel>)` | `Projections/IProjectionFor.cs:10-17` |
|
|
328
331
|
| Model-bound projection | attributes on the read model | `Projections/ModelBound/` |
|
|
329
332
|
| Read model reactor | marker `IReadModelReactor`, methods `Added`/`Modified`/`Removed` | `ReadModels/IReadModelReactor.cs:10-18` |
|
|
330
333
|
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return may be `Task`, `void`, or a side-effect event type.
|
|
335
|
-
|
|
336
|
-
```csharp
|
|
337
|
-
using Cratis.Chronicle.Events;
|
|
338
|
-
using Cratis.Chronicle.Reactors;
|
|
339
|
-
|
|
340
|
-
public class <ReactorName>(<IDependency> <dependency>) : IReactor
|
|
341
|
-
{
|
|
342
|
-
public async Task <AnyMethodName>(<EventName> @event, EventContext context)
|
|
343
|
-
{
|
|
344
|
-
await <dependency>.<DoSomething>(context.EventSourceId, @event.<Property>);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
```
|
|
348
|
-
|
|
349
|
-
> **There is no `[Observer]` attribute and no `IObserver` client artifact.**
|
|
350
|
-
> "Observer" is the kernel's umbrella term for a projection, reducer, or reactor;
|
|
351
|
-
> it is not something you write. `Source/Clients/DotNET/Observation/` holds
|
|
352
|
-
> `ObserverId`, `ObserverRunningState`, and failed-partition types only.
|
|
353
|
-
|
|
354
|
-
Read models are queried through `eventStore.ReadModels`
|
|
355
|
-
(`Source/Clients/DotNET/ReadModels/IReadModels.cs`):
|
|
356
|
-
`GetInstanceById<TReadModel>(ReadModelKey, ReadModelSessionId?)` (`:38`),
|
|
357
|
-
`GetInstances<TReadModel>(EventCount?)` (`:55`),
|
|
358
|
-
`GetSnapshotsById<TReadModel>` (`:63`),
|
|
359
|
-
`IObservable<ReadModelChangeset<TReadModel>> Watch<TReadModel>()` (`:70`).
|
|
334
|
+
Read [observer handlers and reads](references/discovery.md#observer-handlers-and-reads)
|
|
335
|
+
for reactor dispatch, an instance-handler example and `eventStore.ReadModels` APIs.
|
|
336
|
+
There is no `[Observer]` attribute or `IObserver` client artifact.
|
|
360
337
|
|
|
361
338
|
## Discovery
|
|
362
339
|
|
|
363
|
-
|
|
340
|
+
Default scanning finds marked/interface artifacts and complete self shapes.
|
|
341
|
+
Plain instance reducers require nomination before store creation. Self models
|
|
342
|
+
need no activation or fold-time DI. See the [read-model ladder](../cratis-chronicle-read-model/SKILL.md#step-3--choose-a-projection-or-a-reducer)
|
|
343
|
+
and [reducer contract](../cratis-chronicle-reducer/SKILL.md) for placement,
|
|
344
|
+
upgrades, warnings and conflicts. Self reduction is
|
|
345
|
+
.NET-only (Cratis/Chronicle#4851), not an other-client or Stage contract.
|
|
364
346
|
|
|
365
|
-
Read [
|
|
347
|
+
Read [discovery and nomination](references/discovery.md) for missing artifacts,
|
|
348
|
+
plain-class registration or `AutoDiscoverAndRegister = false`.
|
|
366
349
|
|
|
367
350
|
## Common pitfalls
|
|
368
351
|
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
+
## Contents
|
|
2
|
+
|
|
3
|
+
- Discovery and explicit registration
|
|
4
|
+
- Plain-class reducer nomination
|
|
5
|
+
- Manual discovery and runtime registration
|
|
6
|
+
- Observer handlers and reads
|
|
7
|
+
|
|
1
8
|
<!-- Copyright (c) Cratis. All rights reserved. -->
|
|
2
9
|
<!-- Licensed under the MIT license. See LICENSE file in the project root for full license information. -->
|
|
3
10
|
|
|
4
11
|
## Discovery and explicit registration
|
|
5
12
|
|
|
6
|
-
|
|
13
|
+
Existing projection/reactor APIs were verified at **Cratis/Chronicle v19.50.0**.
|
|
14
|
+
Self and nominated reducer discovery were verified at **v19.59.4**:
|
|
7
15
|
`Source/Clients/DotNET/DefaultClientArtifactsProvider.cs`,
|
|
8
|
-
`
|
|
9
|
-
`
|
|
16
|
+
`Reducers/{SelfReducerMethods,RegisteredReducerReadModel,ReducerCatalog}.cs`,
|
|
17
|
+
`ReadModels/ReadModelBuilderOwnership.cs`,
|
|
18
|
+
`Registrations/{ExplicitArtifacts,ExplicitArtifacts.Types}.cs`.
|
|
10
19
|
|
|
11
20
|
`DefaultClientArtifactsProvider.Default` scans project- and package-referenced
|
|
12
21
|
assemblies. Discovered artifacts include:
|
|
@@ -17,7 +26,8 @@ assemblies. Discovered artifacts include:
|
|
|
17
26
|
| Projections | one `IProjectionFor<T>` per class, or model-bound projection annotations |
|
|
18
27
|
| Reactors | non-generic `IReactor` |
|
|
19
28
|
| Read-model reactors | non-generic `IReadModelReactor` |
|
|
20
|
-
|
|
|
29
|
+
| Separate reducers | non-generic class implementing one `IReducerFor<T>` |
|
|
30
|
+
| Self-reducing models | concrete non-generic non-`IReducer` class with public static non-generic `Reduce(event, model? current[, EventContext])`, returning model or `Task<model>`, including nullable results |
|
|
21
31
|
| Event source definitions | `IEventSource` |
|
|
22
32
|
| Constraints | `IConstraint`, plus `[Unique]`, `[RemoveConstraint]`, `[ClosesStream]` event declarations |
|
|
23
33
|
| Seeds / migrations | `ICanSeedEvents`, `IEventTypeMigrationFor<T>` |
|
|
@@ -27,20 +37,95 @@ Multiple projection or reducer targets in one class fail discovery with
|
|
|
27
37
|
`TypeImplementsMultipleProjectionInterfaces` / `TypeMustImplementOnlyOneReducer`
|
|
28
38
|
(analyzer CHR0057). They are not silently flattened into independent artifacts.
|
|
29
39
|
|
|
30
|
-
|
|
40
|
+
Complete self shapes are marker-free discovery signals (.NET-only since
|
|
41
|
+
19.58.0). Existing static helpers can therefore become reducers on upgrade.
|
|
42
|
+
No model is activated, and `Reduce` cannot take injected services. Static near
|
|
43
|
+
misses whose current/result refers to the model warn (CHR0058) and are skipped;
|
|
44
|
+
explicit nomination rejects them. Once a valid shape exists, malformed siblings
|
|
45
|
+
and hooks fail. A self model with another builder in the same catalog throws
|
|
46
|
+
`AmbiguousReadModelBuilder`. Configuration alone (`[Passive]`, `[Reducer]`,
|
|
47
|
+
filters, sequence selection) is not projection ownership. See the
|
|
48
|
+
[reducer skill](../../cratis-chronicle-reducer/SKILL.md) for selection and hooks.
|
|
49
|
+
|
|
50
|
+
Configure `ChronicleOptions.ExplicitArtifacts` **before creating stores**:
|
|
31
51
|
`RegisterProjection<TReadModel>(define, id)`, `RegisterReadModel<TReadModel>()`,
|
|
32
52
|
`RegisterReactor(id, builder)`. These participate in every normal registration
|
|
33
|
-
pass, including reconnects.
|
|
53
|
+
pass, including reconnects. Each store captures a snapshot at construction;
|
|
54
|
+
later options edits affect only subsequently created stores. For an existing store, use
|
|
34
55
|
`IProjections.Register<TReadModel>(define, id)` or `Register<TReadModel>()`,
|
|
35
56
|
`IReactors.Define/Register(id, builder)`, and the family-specific event type,
|
|
36
57
|
constraint, reducer and read-model registration APIs. Fluent reactors use typed
|
|
37
58
|
`On<TEvent>` handlers or catch-all `Subscribe`.
|
|
38
59
|
|
|
60
|
+
## Plain-class reducer nomination
|
|
61
|
+
|
|
62
|
+
Only nominate a plain instance reducer when its assembly cannot reference
|
|
63
|
+
Chronicle; new application reducers normally keep static transitions on the
|
|
64
|
+
model, or use `IReducerFor<T>` for DI/replay instance behavior/separation.
|
|
65
|
+
Nomination infers exactly one model from supported instance
|
|
66
|
+
`(event, model? current[, EventContext])` handlers against registered events.
|
|
67
|
+
Names do not dispatch; public/non-public instance methods are scanned. Nullable
|
|
68
|
+
or nullable-oblivious current is accepted; returns are model, `Task<model>`
|
|
69
|
+
(including nullable results) or classic bare `Task` (which leaves absent state).
|
|
70
|
+
Nomination does not relax validation or discover arbitrary plain classes.
|
|
71
|
+
|
|
72
|
+
```csharp
|
|
73
|
+
var options = new ChronicleOptions();
|
|
74
|
+
options.ExplicitArtifacts.RegisterReducer<PlainBalanceReducer>();
|
|
75
|
+
// Runtime-type equivalent; use one, not both:
|
|
76
|
+
// options.ExplicitArtifacts.RegisterReducer(typeof(PlainBalanceReducer));
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Import `Cratis.Chronicle` for options. Optional `ReducerId` configures identity.
|
|
80
|
+
The same APIs accept a self model: `RegisterReducer<AccountBalance>()` or
|
|
81
|
+
`RegisterReducer(typeof(AccountBalance))`; there is no special self API.
|
|
82
|
+
Register events with `[EventType]` or `RegisterEventType<T>()`: assembly
|
|
83
|
+
membership alone does not make an event registered. Equal explicit/discovered
|
|
84
|
+
declarations coalesce; incompatible identities fail, rather than overriding.
|
|
85
|
+
|
|
86
|
+
## Manual discovery and runtime registration
|
|
87
|
+
|
|
39
88
|
Runtime reactors also support `IReactors.Register(id, configure, handle)` and
|
|
40
89
|
`Unregister(id)`. Use an explicit stable id for side effects. Variant read models
|
|
41
90
|
cannot be registered explicitly (`VariantReadModelsCannotBeRegisteredExplicitly`).
|
|
42
91
|
|
|
43
92
|
`AutoDiscoverAndRegister = false` disables the automatic pass; owning explicit
|
|
44
|
-
registrations then also means
|
|
93
|
+
registrations then also means calling `DiscoverAll()` to apply recipes,
|
|
94
|
+
`RegisterAll()` when connected, and owning registration/subscription waits.
|
|
95
|
+
Reconnect reuses the captured recipes; `DiscoverAll()` can refresh discovery
|
|
96
|
+
without adopting later options edits.
|
|
45
97
|
Inspect `IEventStore.Discovery` and startup logs before guessing why an artifact
|
|
46
98
|
is missing.
|
|
99
|
+
|
|
100
|
+
## Observer handlers and reads
|
|
101
|
+
|
|
102
|
+
This existing handler/read surface was verified at **v19.50.1**.
|
|
103
|
+
**A reactor handler is found by its first parameter's type**, and further
|
|
104
|
+
parameters are resolved as dependencies — `EventContext`, a read model, a service
|
|
105
|
+
(`Source/Clients/DotNET/Reactors/EventHandlerMethods.cs:21-46`, `:89-103`). The
|
|
106
|
+
return may be `Task`, `void`, or a side-effect event type.
|
|
107
|
+
|
|
108
|
+
```csharp
|
|
109
|
+
using Cratis.Chronicle.Events;
|
|
110
|
+
using Cratis.Chronicle.Reactors;
|
|
111
|
+
|
|
112
|
+
public class <ReactorName>(<IDependency> <dependency>) : IReactor
|
|
113
|
+
{
|
|
114
|
+
public async Task <AnyMethodName>(<EventName> @event, EventContext context)
|
|
115
|
+
{
|
|
116
|
+
await <dependency>.<DoSomething>(context.EventSourceId, @event.<Property>);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**There is no `[Observer]` attribute and no `IObserver` client artifact.**
|
|
122
|
+
"Observer" is the kernel's umbrella term for a projection, reducer, or reactor;
|
|
123
|
+
it is not something you write. `Source/Clients/DotNET/Observation/` holds
|
|
124
|
+
`ObserverId`, `ObserverRunningState`, and failed-partition types only.
|
|
125
|
+
|
|
126
|
+
Read models are queried through `eventStore.ReadModels`
|
|
127
|
+
(`Source/Clients/DotNET/ReadModels/IReadModels.cs`):
|
|
128
|
+
`GetInstanceById<TReadModel>(ReadModelKey, ReadModelSessionId?)` (`:38`),
|
|
129
|
+
`GetInstances<TReadModel>(EventCount?)` (`:55`),
|
|
130
|
+
`GetSnapshotsById<TReadModel>` (`:63`),
|
|
131
|
+
`IObservable<ReadModelChangeset<TReadModel>> Watch<TReadModel>()` (`:70`).
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
Copyright (c) Cratis. All rights reserved.
|
|
2
2
|
Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
This skill also adapts material from the Eventmodelers Build-Kits skills by Martin Dilger and
|
|
5
|
+
Nebulit GmbH (https://github.com/Nebulit-GmbH/Eventmodelers-Build-Kits; https://nebulit.de), used
|
|
6
|
+
with the explicit consent of Martin Dilger and Nebulit GmbH. The adapted material remains credited
|
|
7
|
+
to Martin Dilger and Nebulit GmbH.
|
|
@@ -72,7 +72,10 @@ these are the `Automation` and `Translate` slice types.
|
|
|
72
72
|
|
|
73
73
|
- **Behavior name and type** for each step in the flow.
|
|
74
74
|
- **Commands** — their inputs and the authorization that gates them. Commands
|
|
75
|
-
are imperative intents.
|
|
75
|
+
are imperative intents. For each rejection condition, name the values it reads
|
|
76
|
+
as input, read state or context (time, caller, tenant). Context comes from the
|
|
77
|
+
command pipeline or an injected time source, never from the wall clock inside
|
|
78
|
+
the decision, so a specification can fix it.
|
|
76
79
|
- **Events** — past-tense, one-purpose facts. Names must be self-describing:
|
|
77
80
|
`<Entity><PastTenseVerb>`, never a bare `Created`.
|
|
78
81
|
- **The event-source id for every event.** Events never carry their own
|
|
@@ -8,8 +8,12 @@ license: MIT
|
|
|
8
8
|
|
|
9
9
|
A projection consumes **events** and produces read-model state. It is pure: no
|
|
10
10
|
side effects, and it never reads another read model. Prefer model-bound
|
|
11
|
-
attributes on the read model;
|
|
12
|
-
|
|
11
|
+
attributes on the read model; use the fluent builder when mappings need
|
|
12
|
+
structure or the model should stay attribute-free; choose reducer code when
|
|
13
|
+
state transitions read better as code. Follow the
|
|
14
|
+
[read-model style ladder](../cratis-chronicle-read-model/SKILL.md#step-3--choose-a-projection-or-a-reducer):
|
|
15
|
+
a self-reducing model is the new .NET reducer default, not a mandatory separate
|
|
16
|
+
class. See [reducers](../cratis-chronicle-reducer/SKILL.md) for that contract.
|
|
13
17
|
|
|
14
18
|
## Verified product sources
|
|
15
19
|
|
|
@@ -17,7 +21,8 @@ This skill is verified against this exact source:
|
|
|
17
21
|
|
|
18
22
|
| Package | Version | Purpose |
|
|
19
23
|
| --- | --- | --- |
|
|
20
|
-
| `Cratis.Chronicle` | `19.50.1` |
|
|
24
|
+
| `Cratis.Chronicle` | `19.50.1` | Existing projections, model-bound attributes, keys and event-sequence APIs |
|
|
25
|
+
| `Cratis.Chronicle` | `19.59.4` | Self-model builder conflicts: `Source/Clients/DotNET/ReadModels/ReadModelBuilderOwnership.cs`, `Reducers/SelfReducerMethods.cs` at tag `v19.59.4` |
|
|
21
26
|
|
|
22
27
|
Reverify product sources before claiming support for another version.
|
|
23
28
|
|
|
@@ -70,10 +75,10 @@ targets. Two things there are worth knowing before you write anything:
|
|
|
70
75
|
`[FromEvent<T>]` is an **object-initializer property**, never a constructor
|
|
71
76
|
argument: `[Count<TEvent>(ConstantKey = "<key>")]`.
|
|
72
77
|
|
|
73
|
-
## Fluent projections —
|
|
78
|
+
## Fluent projections — structured mappings
|
|
74
79
|
|
|
75
|
-
Use `Cratis.Chronicle.Projections.IProjectionFor<TReadModel>` when the
|
|
76
|
-
|
|
80
|
+
Use `Cratis.Chronicle.Projections.IProjectionFor<TReadModel>` when the mapping
|
|
81
|
+
needs structure or an attribute-free model — for example when two events feed one child collection
|
|
77
82
|
through different key properties.
|
|
78
83
|
|
|
79
84
|
```csharp
|
|
@@ -92,7 +97,7 @@ public class <ReadModelName>Projection : IProjectionFor<<ReadModelName>>
|
|
|
92
97
|
the interface** — do not add one. Use `[Projection(id: "<id>")]` when the
|
|
93
98
|
identity must be explicit.
|
|
94
99
|
|
|
95
|
-
When
|
|
100
|
+
When you use the fluent builder, read [references/fluent-builder.md](references/fluent-builder.md) for the real
|
|
96
101
|
member list. The trap that costs the most time: **`UsingKey`, `UsingParentKey`,
|
|
97
102
|
`UsingCompositeKey`, and `UsingConstantKey` are not on the projection builder.**
|
|
98
103
|
They live on the per-event builder that `From<TEvent>` hands to your callback.
|
|
@@ -108,7 +113,9 @@ one collection. Preserve security/compliance boundaries when choosing the shape.
|
|
|
108
113
|
|
|
109
114
|
When replacing a reducer, preserve creation/admission and late-event guards;
|
|
110
115
|
an unconditional `[SetValue<T>]` is not equivalent to guarded state transition
|
|
111
|
-
code.
|
|
116
|
+
code. A self model cannot also have a competing projection in the same catalog
|
|
117
|
+
(`AmbiguousReadModelBuilder`); remove the old builder when switching. See the
|
|
118
|
+
reducer skill's conversion guidance. Evaluate variants below when
|
|
112
119
|
shapes diverge; do not mandate them for every status field.
|
|
113
120
|
|
|
114
121
|
## Joins are on events, never on read models
|
|
@@ -297,8 +304,9 @@ projection spans streams.
|
|
|
297
304
|
|
|
298
305
|
## Verify
|
|
299
306
|
|
|
300
|
-
-
|
|
301
|
-
fluent
|
|
307
|
+
- The style follows the read-model ladder: attributes for clear mappings,
|
|
308
|
+
fluent for structure, reducer code for clearer state transitions; conversion
|
|
309
|
+
preserves guards and leaves no competing self-model builder.
|
|
302
310
|
- `.AutoMap()` is called only inside a `.NoAutoMap()` scope.
|
|
303
311
|
- Every join is on an event type; CHR0042 overlaps are deliberate.
|
|
304
312
|
- One class implements only one `IProjectionFor<T>` (CHR0057).
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Provenance
|
|
2
2
|
|
|
3
|
+
## Method lineage
|
|
4
|
+
|
|
5
|
+
| Idea | Used in | Credit |
|
|
6
|
+
| --- | --- | --- |
|
|
7
|
+
| Successful work is removed from its pending-work view and removal is specified | `slice-delivery-checklist.md`, Checklist and Specifications | Martin Dilger / Nebulit GmbH, Eventmodelers build kits (`prototype`), used with their explicit consent; idea, our own wording |
|
|
8
|
+
|
|
3
9
|
## Adapted closely (Martin Dilger and Nebulit GmbH)
|
|
4
10
|
|
|
5
11
|
Source: https://github.com/Nebulit-GmbH/agentic-engineer at commit `07b0f30648d663cb588d7e2c7aa031af9dfc21f2`,
|
package/package/corpus/skills/cratis-chronicle-reactor/references/slice-delivery-checklist.md
CHANGED
|
@@ -82,6 +82,8 @@ fact, not handled (`references/domain-failures.md`).
|
|
|
82
82
|
- [ ] Handlers that return events or commands carry `[OnceOnly]`; the effect is idempotent regardless
|
|
83
83
|
- [ ] A gated command has `[ExecuteCommandsAsSystem]` naming the role the command requires
|
|
84
84
|
- [ ] Repeated delivery of the same trigger is specified (what happens when it fires twice)
|
|
85
|
+
- [ ] For a pending-work read model, the successful effect records the event that removes the
|
|
86
|
+
selected item, directly or through the invoked command; success leaves no completed work pending
|
|
85
87
|
- [ ] A modeled slice matches its `.play` contract; the model was not edited to fit the code
|
|
86
88
|
- [ ] The reactor has no route; a command meant only for the automation is gated and the reactor runs it as that role; no processor or lock configuration, no dead-letter store
|
|
87
89
|
- [ ] The build has no `CHR0004`, `CHR0005`, `CHR0008`, `CHR0013`, `CHR0022`, `CHR0031` or `CHR0032` outstanding and the specifications pass
|
|
@@ -91,3 +93,6 @@ The trigger-to-command field mapping is part of the contract, so give it its own
|
|
|
91
93
|
direct call asserting the returned command, or a `ReactorScenario` where wiring matters). The
|
|
92
94
|
command's own `CommandScenario` covers the command side separately; neither replaces the other.
|
|
93
95
|
Details: `references/specifications.md`.
|
|
96
|
+
Where a pending-work view drives the reaction, its read-model specification seeds the trigger
|
|
97
|
+
and then the completion event and asserts that the item is absent. Link it from the reaction's
|
|
98
|
+
specification map: command success alone cannot show the queue will stop selecting that item.
|
|
@@ -23,7 +23,8 @@ This skill is verified against these exact sources:
|
|
|
23
23
|
|
|
24
24
|
| Package | Version | Purpose |
|
|
25
25
|
| --- | --- | --- |
|
|
26
|
-
| `Cratis.Chronicle` | `18.3.0` |
|
|
26
|
+
| `Cratis.Chronicle` | `18.3.0` | Existing event, key and read-model APIs |
|
|
27
|
+
| `Cratis.Chronicle` | `19.59.4` | Style/discovery: `Source/Clients/DotNET/Reducers/{SelfReducerMethods,RegisteredReducerReadModel}.cs`, `ReadModels/ReadModelBuilderOwnership.cs`, `DefaultClientArtifactsProvider.cs` at tag `v19.59.4` |
|
|
27
28
|
| `Cratis.Arc.Core` | `22.75.0` | `Cratis.Arc.Queries.ModelBound.ReadModelAttribute` and `PathAttribute` |
|
|
28
29
|
| `Cratis.Arc.MongoDB` | `22.75.0` | the `Observe` family of `IMongoCollection<T>` extensions |
|
|
29
30
|
|
|
@@ -94,27 +95,52 @@ and [query cost and composition](references/queries.md#cost-and-composition).
|
|
|
94
95
|
|
|
95
96
|
## Step 3 — Choose a projection or a reducer
|
|
96
97
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
state
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
98
|
+
For application code, work down this ladder:
|
|
99
|
+
|
|
100
|
+
1. **Model-bound attributes** when the mapping reads clearly on the model.
|
|
101
|
+
2. **Fluent `IProjectionFor<T>`** when the definition needs structure or an
|
|
102
|
+
attribute-free contract. Counters, joins, children and composite keys remain
|
|
103
|
+
projection features; fluent lambdas are not arbitrary per-event code.
|
|
104
|
+
3. **Reducer code** when branching on prior state, calculations or guards read
|
|
105
|
+
better as state transitions. A reducer is a normal choice, not a last resort.
|
|
106
|
+
For new .NET code default to a **self-reducing model**: public static
|
|
107
|
+
`Reduce(TEvent @event, TSelf? current[, EventContext context])` on the model,
|
|
108
|
+
returning `TSelf`/`TSelf?` or `Task` of it. No marker or model activation.
|
|
109
|
+
Use a separate **`IReducerFor<T>`** when the fold needs injected services,
|
|
110
|
+
replay-time instance state or separation from the model.
|
|
111
|
+
4. **Nominated plain instance class** only when the contract/reducer assembly
|
|
112
|
+
cannot reference Chronicle; configure `ChronicleOptions.ExplicitArtifacts`
|
|
113
|
+
at the composition root before creating stores.
|
|
114
|
+
|
|
115
|
+
**PDL** is for definitions authored outside application code (Workbench,
|
|
116
|
+
Screenplay, ad-hoc queries), not the code-first default. This ladder does not
|
|
117
|
+
claim Stage renders static self reducers. The self form is .NET-only
|
|
118
|
+
(Cratis/Chronicle#4851); other SDKs keep their own reducer contracts.
|
|
119
|
+
|
|
120
|
+
Default discovery finds projections, interface reducers and complete self shapes.
|
|
121
|
+
Explicit registration remains available, and plain instance reducers require
|
|
122
|
+
nomination; see [discovery](../cratis-chronicle-client-dotnet/references/discovery.md).
|
|
123
|
+
An existing complete static shape becomes a reducer on upgrade without adding a
|
|
124
|
+
marker. Near misses warn (CHR0058). A self model and a competing projection or
|
|
125
|
+
reducer in one catalog fail with `AmbiguousReadModelBuilder`; remove the old
|
|
126
|
+
builder when switching and verify storage/replay separately from output equality.
|
|
127
|
+
|
|
128
|
+
Read [projection behavior](../cratis-chronicle-projection/SKILL.md) for mappings
|
|
129
|
+
and [reducers](../cratis-chronicle-reducer/SKILL.md) for complete signatures,
|
|
130
|
+
null deletion, replay hooks and preserving admission/ordering guards. Reducers
|
|
131
|
+
are source-keyed, have no native joins and are refused by decision reads.
|
|
112
132
|
|
|
113
133
|
## Step 4 — Add a query surface, if the model is read from outside
|
|
114
134
|
|
|
115
135
|
Queries are **static** methods on the read-model record, discovered by Arc.
|
|
116
136
|
Marking the record with `[ReadModel]` from `Cratis.Arc.Queries.ModelBound` is
|
|
117
|
-
what gives it that surface.
|
|
137
|
+
what gives it that surface. For a self-reducing model, put its `Reduce` methods
|
|
138
|
+
and queries on this same record. Before Arc 22.90.0, use
|
|
139
|
+
`[ReadModel(RequireQueryAttribute = true)]` plus `[Query]` on intended queries to
|
|
140
|
+
avoid exposing folds. From Arc 22.90.0, Arc excludes methods taking the
|
|
141
|
+
model itself from query discovery, and Arc.Chronicle claims self models for
|
|
142
|
+
command injection. See the existing
|
|
143
|
+
[explicit query-discovery guidance](references/queries.md#discovery-rules).
|
|
118
144
|
|
|
119
145
|
```csharp
|
|
120
146
|
using System.Reactive.Subjects;
|
|
@@ -206,7 +232,7 @@ This access distinction was checked against Chronicle **v19.31.2**
|
|
|
206
232
|
|
|
207
233
|
`[Passive]` on its own does **not** make a read model a projection. It is
|
|
208
234
|
deliberately excluded from the annotations that do; it changes how an existing
|
|
209
|
-
projection is
|
|
235
|
+
projection or reducer is read; it is not a builder by itself.
|
|
210
236
|
|
|
211
237
|
## Step 6 — Build and verify
|
|
212
238
|
|
|
@@ -236,6 +262,8 @@ spans streams.
|
|
|
236
262
|
`EventSourceId<T>` value.
|
|
237
263
|
- No reserved compliance-subject property name is used.
|
|
238
264
|
- Read-model properties carry no defaults that could hide unwired projection.
|
|
265
|
+
- The style follows the ladder; a self model has no competing builder, and Arc
|
|
266
|
+
folds are excluded from query exposure for the consuming version.
|
|
239
267
|
- Query methods are `static` and declare `ISubject<...>` rather than a concrete
|
|
240
268
|
subject type.
|
|
241
269
|
- A direct `GetInstanceById` result is checked for absence before use.
|