@cratis/pi 7.13.0 → 7.14.1
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/rules/application-profile.md +1 -1
- package/package/corpus/rules/vertical-slices.md +1 -0
- package/package/corpus/skills/cratis-arc-command/SKILL.md +9 -0
- package/package/corpus/skills/cratis-arc-command/references/read-model-injection.md +4 -1
- package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +3 -1
- package/package/corpus/skills/cratis-arc-ef-core-migration/SKILL.md +2 -1
- package/package.json +1 -1
|
@@ -35,7 +35,7 @@ Tagged **[contract]** (framework-enforced) or **[convention]** (house default).
|
|
|
35
35
|
3. **[contract] Event-source id resolution:** `ICanProvideEventSourceId` first; else the first qualifying property in declaration order — an `EventSourceId`/`EventSourceId<T>`-derived value *or* a `[Key]` property (no priority between them; two candidates is `ARCCHR0002`); else Arc generates one. A value actually used as a Chronicle stream identity derives from `EventSourceId<T>` with the underlying `IComparable` primitive — never `ConceptAs<Guid>` for that stream identity. `NotSet`, `New()`, and primitive→derived-id operators are optional domain/API conveniences, not Chronicle requirements; typed empty/zero values are real specified stream IDs, not `EventSourceId.Unspecified`.
|
|
36
36
|
4. **[contract] Events never carry the event-source id** — it is implicit in the event context.
|
|
37
37
|
5. **[contract] `[Key]` / `[Subject]` are distinct.** `[Key]` is for event-source/read-model/projection key resolution; `[Subject]` is compliance identity only. Don't put either on an `EventSourceId<T>` value (it already is both); use them only for non-`EventSourceId<T>` values.
|
|
38
|
-
6. **[contract] Avoid nullable event properties** — Chronicle's analyzer warns on them. Model optional facts as a separate event; resolve nullable command inputs to a non-null sentinel before constructing the event.
|
|
38
|
+
6. **[contract] Avoid nullable event properties** — Chronicle's analyzer warns on them. Model optional facts as a separate event; resolve nullable command inputs to a non-null sentinel before constructing the event. **Likewise `Handle()` never returns a nullable event or `null` for "nothing to do"** — Arc treats a `null` result as success with nothing appended, so the caller is told a command succeeded that never happened. Missing state or a failed rule is a rejection: return `Result<TEvent, ValidationResult>` with `ValidationResult.Error(...)`, or reject in a validator or `Provide()`. Optional `ICommandOperation` returns are a separate contract and unaffected.
|
|
39
39
|
7. **[contract] `[EventType]` takes no arguments for new events** — the type name is the identifier. Use `generation:`/id only when evolving an existing contract; schema changes get a new generation + an `EventTypeMigration<TUpgrade,TPrevious>` (never edit stored-event semantics silently). An enum that only gains a member, or has one renamed, is the exception — Chronicle accepts that in place; a *removed* or *renumbered* member still needs a generation, plus a value map saying what the old values became.
|
|
40
40
|
8. **[convention] Every `[EventType]` has an XML `<summary>`** — a Cratis C# documentation convention (not a Chronicle rule); events live in the log forever, so record why they exist.
|
|
41
41
|
9. **[convention] `[ReadModel]` properties carry no default values** except semantically meaningful enum initial states and `[SetValue<T>]`-driven `bool` flags. False defaults hide missing projection wiring.
|
|
@@ -204,6 +204,7 @@ Apply authorization attributes on the `[Command]` record or query method. **[con
|
|
|
204
204
|
- **[contract] No arguments for new events** — the type name is the identifier. Use `generation:`/id only when evolving an existing contract (invoke the **cratis-chronicle-event-type-migration** skill).
|
|
205
205
|
- **[contract] Past-tense, one-purpose names** (`AuthorRegistered`, not `Updated`/`FormSubmitted`) — Chronicle requires past-tense, single-purpose facts. Self-describing without slice context.
|
|
206
206
|
- **[contract] Avoid nullable properties** — Chronicle's analyzer warns on nullable event members; model optional facts as a separate event, or resolve a nullable command input to a non-null sentinel before constructing the event.
|
|
207
|
+
- **[contract] `Handle()` never returns a nullable event or `null` for "nothing to do"** — Arc treats a `null` result as success with nothing appended, so the caller is told a command succeeded that never happened. Missing state or a failed rule is a rejection: return `Result<TEvent, ValidationResult>` with `ValidationResult.Error(...)`, or reject in a validator or `Provide()`. Optional `ICommandOperation` returns are a separate contract and unaffected.
|
|
207
208
|
- **[contract] Never carry the event-source id** — it's implicit in the event context.
|
|
208
209
|
- **[convention] No `DateTimeOffset`/`DateTime` properties** that duplicate `EventContext.Occurred` — Chronicle records the wall-clock timestamp of every event there. Read it in projections/reducers via `[SetFromContext<T>]` or fluent `.Set(m => m.X).ToEventContextProperty(c => c.Occurred)`. Use `DateOnly` only for a business date the user explicitly supplies.
|
|
209
210
|
- **[convention] Every `[EventType]` has an XML `<summary>`** (Cratis C# doc convention) recording why the event exists and what each value means.
|
|
@@ -105,6 +105,15 @@ after-commit work belongs in reactors/outboxes/workflows. Use
|
|
|
105
105
|
`cratis-arc-command-operation` rather than a custom response handler or rollback
|
|
106
106
|
stack for this application work.
|
|
107
107
|
|
|
108
|
+
**Never return a nullable event or `null` to mean "nothing to do".** Arc only
|
|
109
|
+
processes a non-null result, so a `null` is success with nothing appended and the
|
|
110
|
+
caller is told a command succeeded that never happened. Missing state or a failed
|
|
111
|
+
rule is a rejection: return `Result<TEvent, ValidationResult>` with
|
|
112
|
+
`ValidationResult.Error(...)`, or reject in a validator or `Provide()`. Optional
|
|
113
|
+
`ICommandOperation` returns are a separate contract and unaffected. A nullable
|
|
114
|
+
read-model parameter (`ARC0006`) is handled by rejecting, never by returning a
|
|
115
|
+
nullable event.
|
|
116
|
+
|
|
108
117
|
Two consequences worth knowing before writing the first command:
|
|
109
118
|
|
|
110
119
|
- **The tuple is how a create command returns its new id.** An
|
|
@@ -46,7 +46,10 @@ failure rather than a server fault.
|
|
|
46
46
|
`ARC0006` warns when a read-model parameter is non-nullable, precisely because a
|
|
47
47
|
command-scoped read model can be missing. Make it nullable when absence is part
|
|
48
48
|
of the command's valid behavior; keep it non-nullable when absence really is a
|
|
49
|
-
rejection.
|
|
49
|
+
rejection. When absence is a rejection, check the nullable parameter and return
|
|
50
|
+
`ValidationResult.Error(...)` through `Result<TEvent, ValidationResult>`; never
|
|
51
|
+
return a nullable event or `null` from `Handle()`, which Arc treats as success
|
|
52
|
+
with nothing appended.
|
|
50
53
|
|
|
51
54
|
## `null` is not always what absence looks like
|
|
52
55
|
|
|
@@ -196,7 +196,9 @@ var other = await readModels.GetInstanceById<Other>((EventSourceId)otherId);
|
|
|
196
196
|
A missing instance resolves to `null`, never to a default object. A nullable
|
|
197
197
|
parameter receives that `null`; a non-nullable one is **rejected as a validation
|
|
198
198
|
failure (400)**, not crashed. `ARC0006` warns on a non-nullable command-scoped
|
|
199
|
-
read-model parameter for exactly this reason.
|
|
199
|
+
read-model parameter for exactly this reason. Handle a nullable parameter by rejecting (a validator,
|
|
200
|
+
`Provide()`, or `Result<TEvent, ValidationResult>`), never by returning a
|
|
201
|
+
nullable event from `Handle()`. `cratis-arc-command` carries the
|
|
200
202
|
full resolution and nullability reference, including the passive-projection case
|
|
201
203
|
where absence is *not* `null`.
|
|
202
204
|
|
|
@@ -117,7 +117,8 @@ from the command's resolved key; a composite key throws
|
|
|
117
117
|
(HTTP 400) rather than a server fault.
|
|
118
118
|
|
|
119
119
|
`ARC0006` warns when such a parameter is non-nullable, because a command-scoped
|
|
120
|
-
read model can be missing
|
|
120
|
+
read model can be missing; reject a missing one rather than returning a nullable
|
|
121
|
+
event from `Handle()`. It is the only Arc diagnostic that touches EF Core
|
|
121
122
|
read models, and only because they share `[ReadModel]`.
|
|
122
123
|
|
|
123
124
|
## Write the migration
|