@cratis/pi 7.3.0 → 7.3.2
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/slice-implementer.md +1 -1
- package/package/corpus/hooks/README.md +18 -2
- package/package/corpus/hooks/scripts/cratis-quality-gate.sh +38 -5
- package/package/corpus/hooks/scripts/quality-gates.json +45 -8
- package/package/corpus/prompts/add-business-rule.prompt.md +1 -1
- package/package/corpus/prompts/add-concept.prompt.md +1 -1
- package/package/corpus/prompts/add-ef-migration.prompt.md +1 -1
- package/package/corpus/prompts/add-projection.prompt.md +1 -1
- package/package/corpus/prompts/add-reactor.prompt.md +1 -1
- package/package/corpus/prompts/add-reducer.prompt.md +1 -1
- package/package/corpus/prompts/new-vertical-slice.prompt.md +2 -2
- package/package/corpus/prompts/scaffold-feature.prompt.md +2 -2
- package/package/corpus/prompts/write-specs.prompt.md +1 -1
- package/package/corpus/rules/application-profile.md +1 -1
- package/package/corpus/rules/framework.md +1 -1
- package/package/corpus/rules/frontend-testing.md +1 -1
- package/package/corpus/rules/specs.csharp.md +2 -2
- package/package/corpus/rules/specs.scenarios.csharp.md +1 -1
- package/package/corpus/rules/vertical-slices.md +9 -9
- package/package.json +1 -1
|
@@ -38,7 +38,7 @@ A new vertical slice (State Change, State View, Automation, Translation), or a n
|
|
|
38
38
|
## Workflow — phase gates; don't start the next until the current passes
|
|
39
39
|
|
|
40
40
|
### Phase 1 — Plan
|
|
41
|
-
For new behavior, unclear event names/stream boundaries, or multi-slice flows, run the
|
|
41
|
+
For new behavior, unclear event names/stream boundaries, or multi-slice flows, run the **cratis-chronicle-event-modeling** skill first. Confirm Module/Feature/slice name + type, the behavior in one sentence, whether a UI surface is needed, and the event/read-model/scenario outline. Ask only when a real product/domain choice can't be answered from the repo.
|
|
42
42
|
|
|
43
43
|
### Phase 2 — Backend
|
|
44
44
|
Write `<Module>/<Feature>/<Slice>/<Slice>.cs` with all backend artifacts (declaration order per `general.md`). **Gate:** build clean in **Debug and Release** (zero errors/warnings — Debug validates `#if DEBUG` spec code and regenerates the TypeScript proxies; build Release with `-p:CratisProxiesOutputPath=` to skip re-running proxy generation).
|
|
@@ -340,10 +340,26 @@ script. A consuming repository customises all three without forking anything:
|
|
|
340
340
|
| `scripts/cratis-store-mutations.json` | the store-mutation guard's read-only allowlist and known-mutating list, each entry with its reason or effect, and the CLI options it skips; its header `$comment` documents every field and the CLI version the lists were derived from |
|
|
341
341
|
| `scripts/cratis-store-mutations.local.json` | optional; its lists are appended to the above. It can classify a command a newer CLI adds, or list a shipped read-only command as mutating (a command on the mutating list always blocks); only a replacement file can make a known mutation read-only |
|
|
342
342
|
|
|
343
|
-
A gate whose `requires.commands` are not on `PATH`, whose `requires.paths` do not exist,
|
|
344
|
-
`
|
|
343
|
+
A gate whose `requires.commands` are not on `PATH`, whose `requires.paths` do not exist, whose
|
|
344
|
+
`requires.packageScripts` are not defined in the `package.json` of its working directory (a `g:`
|
|
345
|
+
script may instead be defined in the root `package.json` — this assumes Yarn Berry, where a
|
|
346
|
+
root-defined `g:` script runs from every workspace, and no workspace `package.json` is inspected), or whose `workingDirectoryFrom` matches
|
|
347
|
+
nothing in the repository, is a **no-op with a message on stderr**
|
|
345
348
|
rather than a failure — that is how a repository with no .NET solution or no frontend stays quiet.
|
|
346
349
|
|
|
350
|
+
An override in `.cratis/ai/quality-gates.project.json` is merged shallowly: a field it states
|
|
351
|
+
replaces the managed one. The one exception is `requires.packageScripts`: an override that sets
|
|
352
|
+
`command` without stating `requires` drops the managed gate's `packageScripts`, because they guard
|
|
353
|
+
the managed command (`yarn g:compile`), not the replacement. Without that, a repository replacing
|
|
354
|
+
`command` would silently turn the gate into a no-op whenever it lacks the managed script. An
|
|
355
|
+
override that does state `requires` replaces it whole, so list `packageScripts` again if the new
|
|
356
|
+
command needs them.
|
|
357
|
+
|
|
358
|
+
Every shipped gate ignores the managed corpus and adapter trees (`.cratis/**`, `.pi/**`,
|
|
359
|
+
`.claude/**`) through `excludeChanged`, so a `cratis ai update` never runs a repository's application
|
|
360
|
+
gates. A repository whose own source lives there, like this corpus, restates `excludeChanged` for the
|
|
361
|
+
gates it needs in `.cratis/ai/quality-gates.project.json`.
|
|
362
|
+
|
|
347
363
|
**No shipped gate names a product's file.** A default that did would activate in exactly one
|
|
348
364
|
repository and silently no-op in every other, which is the worst of both: it looks configured and
|
|
349
365
|
checks nothing. So the .NET and frontend gates state *what kind of project* they build and let the
|
|
@@ -47,6 +47,11 @@ jq -e . "$config" >/dev/null 2>&1 || {
|
|
|
47
47
|
# quality-gates.json mixes project facts into Cratis-owned content, so the next managed update
|
|
48
48
|
# either reports drift or silently discards the repository's own configuration. The override
|
|
49
49
|
# states only what differs, keyed by gate id, and nothing here needs a script fork.
|
|
50
|
+
#
|
|
51
|
+
# The merge is shallow (a patch field replaces the base field), with one exception: a patch that
|
|
52
|
+
# replaces `command` but does not state `requires` also drops the base gate's
|
|
53
|
+
# requires.packageScripts. Those scripts guard the base command; keeping them would make the
|
|
54
|
+
# overriding repository's own command a silent NO-OP whenever it lacks e.g. g:compile.
|
|
50
55
|
overrides="$root/.cratis/ai/quality-gates.project.json"
|
|
51
56
|
if [ -f "$overrides" ]; then
|
|
52
57
|
if jq -e . "$overrides" >/dev/null 2>&1; then
|
|
@@ -54,11 +59,16 @@ if [ -f "$overrides" ]; then
|
|
|
54
59
|
if jq -s '
|
|
55
60
|
.[0] as $base | .[1] as $over
|
|
56
61
|
| ($over.gates // []) as $gates
|
|
57
|
-
| $
|
|
62
|
+
| def patched($gate; $patch):
|
|
63
|
+
($gate + ($patch | del(.id))) as $m
|
|
64
|
+
| if ($patch | has("command")) and (($patch | has("requires")) | not) and ($m.requires != null)
|
|
65
|
+
then $m | .requires |= del(.packageScripts)
|
|
66
|
+
else $m end;
|
|
67
|
+
$base
|
|
58
68
|
+ ($over | del(.gates))
|
|
59
69
|
+ { gates: [ $base.gates[] as $gate
|
|
60
70
|
| ($gates | map(select(.id == $gate.id)) | first) as $patch
|
|
61
|
-
| if $patch == null then $gate else $gate
|
|
71
|
+
| if $patch == null then $gate else patched($gate; $patch) end ] }
|
|
62
72
|
' "$config" "$overrides" >"$merged" 2>/dev/null; then
|
|
63
73
|
unknown="$(jq -r --slurpfile base "$config" '[.gates // [] | .[].id] - [$base[0].gates[].id] | .[]' "$overrides" 2>/dev/null || true)"
|
|
64
74
|
[ -n "$unknown" ] && printf 'cratis-quality-gate: %s overrides unknown gate(s): %s\n' \
|
|
@@ -151,9 +161,16 @@ EOF
|
|
|
151
161
|
return 1
|
|
152
162
|
}
|
|
153
163
|
|
|
154
|
-
#
|
|
164
|
+
# Does the package.json at $1 define the script named $2? A missing file or a file that is not
|
|
165
|
+
# valid JSON defines nothing.
|
|
166
|
+
package_defines_script() {
|
|
167
|
+
[ -f "$1" ] && jq -e --arg s "$2" '.scripts[$s] != null' "$1" >/dev/null 2>&1
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
# Report the first unmet requirement, or nothing when the gate can run here. $2 is the directory,
|
|
171
|
+
# relative to the repository root, the gate runs in.
|
|
155
172
|
gate_unmet() {
|
|
156
|
-
local idx="$1" c p
|
|
173
|
+
local idx="$1" dir="$2" c p s
|
|
157
174
|
while IFS= read -r c; do
|
|
158
175
|
[ -n "$c" ] || continue
|
|
159
176
|
hook_have "$c" || { printf "command '%s' is not on PATH" "$c"; return 0; }
|
|
@@ -165,6 +182,22 @@ EOF
|
|
|
165
182
|
[ -e "$root/$p" ] || { printf "'%s' does not exist in this repository" "$p"; return 0; }
|
|
166
183
|
done <<EOF
|
|
167
184
|
$(jq -r --argjson i "$idx" '.gates[$i].requires.paths // [] | .[]' "$config")
|
|
185
|
+
EOF
|
|
186
|
+
# A package.json script a gate invokes must exist, or yarn fails with "Couldn't find a script"
|
|
187
|
+
# instead of the gate being a NO-OP. A global script (g:) may live in the root package.json
|
|
188
|
+
# that the workspace's own package.json defers to. That fallback assumes Yarn Berry, where
|
|
189
|
+
# a g: script defined at the root is runnable from every workspace; no workspace package.json
|
|
190
|
+
# is inspected.
|
|
191
|
+
while IFS= read -r s; do
|
|
192
|
+
[ -n "$s" ] || continue
|
|
193
|
+
package_defines_script "$root/$dir/package.json" "$s" && continue
|
|
194
|
+
case "$s" in
|
|
195
|
+
g:*) package_defines_script "$root/package.json" "$s" && continue ;;
|
|
196
|
+
esac
|
|
197
|
+
printf "script '%s' is not defined in %s" "$s" "$dir/package.json"
|
|
198
|
+
return 0
|
|
199
|
+
done <<EOF
|
|
200
|
+
$(jq -r --argjson i "$idx" '.gates[$i].requires.packageScripts // [] | .[]' "$config")
|
|
168
201
|
EOF
|
|
169
202
|
return 0
|
|
170
203
|
}
|
|
@@ -199,7 +232,7 @@ while [ "$idx" -lt "$gate_count" ]; do
|
|
|
199
232
|
fi
|
|
200
233
|
[ -n "$wd" ] || wd="."
|
|
201
234
|
|
|
202
|
-
unmet="$(gate_unmet "$idx")"
|
|
235
|
+
unmet="$(gate_unmet "$idx" "$wd")"
|
|
203
236
|
if [ -n "$unmet" ]; then
|
|
204
237
|
printf 'cratis-quality-gate: NO-OP %-24s — %s. Configure it in %s.\n' \
|
|
205
238
|
"$id" "$unmet" "${config#"$root"/}" >&2
|
|
@@ -16,6 +16,11 @@
|
|
|
16
16
|
" excludeChanged globs that never count as a relevant change",
|
|
17
17
|
" requires.commands executables that must be on PATH",
|
|
18
18
|
" requires.paths repo-relative literal paths that must all exist (no globbing)",
|
|
19
|
+
" requires.packageScripts package.json scripts that must be defined in the gate's working directory",
|
|
20
|
+
" (a g: script may instead be defined in the repository root package.json, which assumes",
|
|
21
|
+
" Yarn Berry, where a root-defined g: script runs from every workspace; no workspace",
|
|
22
|
+
" package.json is inspected); a missing script makes the gate a NO-OP instead of a",
|
|
23
|
+
" \"Couldn't find a script\" failure",
|
|
19
24
|
" workingDirectory repo-relative directory the command runs in",
|
|
20
25
|
" workingDirectoryFrom globs identifying the project file this gate builds; the command runs",
|
|
21
26
|
" in that file's directory, and a repository holding none makes the gate a",
|
|
@@ -23,6 +28,9 @@
|
|
|
23
28
|
" when workingDirectory is set.",
|
|
24
29
|
" command argv array \u2014 executed directly, never through a shell (no eval)",
|
|
25
30
|
"",
|
|
31
|
+
"Managed corpus and adapter trees (.cratis/**, .pi/**, .claude/**) never count as a relevant change:",
|
|
32
|
+
"a corpus update must not run a repository's application gates over files that are not its application.",
|
|
33
|
+
"",
|
|
26
34
|
"No gate names a product's solution, package or source root \u2014 a default that does would",
|
|
27
35
|
"silently no-op in every repository except the one it was written for. The .NET and frontend",
|
|
28
36
|
"gates discover the repository's own solution/package instead, so they activate unchanged in",
|
|
@@ -33,7 +41,9 @@
|
|
|
33
41
|
"own .cratis/ai/quality-gates.project.json, which the runner merges over this file by gate id",
|
|
34
42
|
"(a project fact belongs there, never edited into this managed file, or the next managed update",
|
|
35
43
|
"reports drift or discards it); or it points CRATIS_HOOKS_GATES at a file anywhere. Neither",
|
|
36
|
-
"requires a script fork.",
|
|
44
|
+
"requires a script fork. The merge is shallow: a field the override states replaces the managed one.",
|
|
45
|
+
"The one exception: an override that sets \"command\" without \"requires\" also drops this gate's",
|
|
46
|
+
"requires.packageScripts, since those guard the managed command, not the override's.",
|
|
37
47
|
"",
|
|
38
48
|
"Example .cratis/ai/quality-gates.project.json, for a repository whose frontend is not at the root:",
|
|
39
49
|
" { \"gates\": [ { \"id\": \"frontend-lint\", \"workingDirectory\": \"Source/App\" } ] }",
|
|
@@ -64,7 +74,10 @@
|
|
|
64
74
|
],
|
|
65
75
|
"excludeChanged": [
|
|
66
76
|
"**/obj/**",
|
|
67
|
-
"**/bin/**"
|
|
77
|
+
"**/bin/**",
|
|
78
|
+
".cratis/**",
|
|
79
|
+
".pi/**",
|
|
80
|
+
".claude/**"
|
|
68
81
|
],
|
|
69
82
|
"requires": {
|
|
70
83
|
"commands": [
|
|
@@ -95,7 +108,10 @@
|
|
|
95
108
|
],
|
|
96
109
|
"excludeChanged": [
|
|
97
110
|
"**/obj/**",
|
|
98
|
-
"**/bin/**"
|
|
111
|
+
"**/bin/**",
|
|
112
|
+
".cratis/**",
|
|
113
|
+
".pi/**",
|
|
114
|
+
".claude/**"
|
|
99
115
|
],
|
|
100
116
|
"requires": {
|
|
101
117
|
"commands": [
|
|
@@ -129,7 +145,10 @@
|
|
|
129
145
|
],
|
|
130
146
|
"excludeChanged": [
|
|
131
147
|
"**/obj/**",
|
|
132
|
-
"**/bin/**"
|
|
148
|
+
"**/bin/**",
|
|
149
|
+
".cratis/**",
|
|
150
|
+
".pi/**",
|
|
151
|
+
".claude/**"
|
|
133
152
|
],
|
|
134
153
|
"requires": {
|
|
135
154
|
"commands": [
|
|
@@ -162,7 +181,10 @@
|
|
|
162
181
|
"**/wwwroot/**",
|
|
163
182
|
"**/dist/**",
|
|
164
183
|
"**/obj/**",
|
|
165
|
-
"**/bin/**"
|
|
184
|
+
"**/bin/**",
|
|
185
|
+
".cratis/**",
|
|
186
|
+
".pi/**",
|
|
187
|
+
".claude/**"
|
|
166
188
|
],
|
|
167
189
|
"requires": {
|
|
168
190
|
"commands": [
|
|
@@ -190,11 +212,17 @@
|
|
|
190
212
|
"**/wwwroot/**",
|
|
191
213
|
"**/dist/**",
|
|
192
214
|
"**/obj/**",
|
|
193
|
-
"**/bin/**"
|
|
215
|
+
"**/bin/**",
|
|
216
|
+
".cratis/**",
|
|
217
|
+
".pi/**",
|
|
218
|
+
".claude/**"
|
|
194
219
|
],
|
|
195
220
|
"requires": {
|
|
196
221
|
"commands": [
|
|
197
222
|
"yarn"
|
|
223
|
+
],
|
|
224
|
+
"packageScripts": [
|
|
225
|
+
"g:compile"
|
|
198
226
|
]
|
|
199
227
|
},
|
|
200
228
|
"workingDirectoryFrom": [
|
|
@@ -218,11 +246,17 @@
|
|
|
218
246
|
"**/wwwroot/**",
|
|
219
247
|
"**/dist/**",
|
|
220
248
|
"**/obj/**",
|
|
221
|
-
"**/bin/**"
|
|
249
|
+
"**/bin/**",
|
|
250
|
+
".cratis/**",
|
|
251
|
+
".pi/**",
|
|
252
|
+
".claude/**"
|
|
222
253
|
],
|
|
223
254
|
"requires": {
|
|
224
255
|
"commands": [
|
|
225
256
|
"yarn"
|
|
257
|
+
],
|
|
258
|
+
"packageScripts": [
|
|
259
|
+
"g:compile:specs"
|
|
226
260
|
]
|
|
227
261
|
},
|
|
228
262
|
"workingDirectoryFrom": [
|
|
@@ -246,7 +280,10 @@
|
|
|
246
280
|
"**/wwwroot/**",
|
|
247
281
|
"**/dist/**",
|
|
248
282
|
"**/obj/**",
|
|
249
|
-
"**/bin/**"
|
|
283
|
+
"**/bin/**",
|
|
284
|
+
".cratis/**",
|
|
285
|
+
".pi/**",
|
|
286
|
+
".claude/**"
|
|
250
287
|
],
|
|
251
288
|
"requires": {
|
|
252
289
|
"commands": [
|
|
@@ -5,7 +5,7 @@ description: Add a business rule or event-store constraint to an existing comman
|
|
|
5
5
|
|
|
6
6
|
# Add a Business Rule or Constraint
|
|
7
7
|
|
|
8
|
-
Enforce a new rule on an existing command. Invoke the **
|
|
8
|
+
Enforce a new rule on an existing command. Invoke the **cratis-arc-command-validation** skill, or the **cratis-chronicle-event-constraints** skill for uniqueness and other append-time constraints, and follow `.cratis/ai/rules/vertical-slices.md` (the decision matrix).
|
|
9
9
|
|
|
10
10
|
## Confirm first
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ description: Create a strongly-typed Concept for a primitive domain value or an
|
|
|
5
5
|
|
|
6
6
|
# Add a Concept
|
|
7
7
|
|
|
8
|
-
Create a strongly-typed concept to replace a raw primitive. Invoke the **
|
|
8
|
+
Create a strongly-typed concept to replace a raw primitive. Invoke the **cratis-fundamentals-concept** skill and follow `.cratis/ai/rules/concepts.md`.
|
|
9
9
|
|
|
10
10
|
## Confirm first
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ description: Add or update an Entity Framework Core DbContext, table column, or
|
|
|
5
5
|
|
|
6
6
|
# Add an EF Core Migration
|
|
7
7
|
|
|
8
|
-
Make a database schema change via EF Core. Invoke the **
|
|
8
|
+
Make a database schema change via EF Core. Invoke the **cratis-arc-ef-core-migration** skill and follow `.cratis/ai/rules/efcore.md` (+ `.cratis/ai/rules/efcore.specs.md`).
|
|
9
9
|
|
|
10
10
|
> Applies only to projects that use EF Core.
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ description: Add a Chronicle projection to an existing read model slice.
|
|
|
5
5
|
|
|
6
6
|
# Add a Projection
|
|
7
7
|
|
|
8
|
-
Add a Chronicle projection that populates a read model from events. Invoke the **
|
|
8
|
+
Add a Chronicle projection that populates a read model from events. Invoke the **cratis-chronicle-projection** skill and follow `.cratis/ai/rules/vertical-slices.md` (projections). For reactors, use the **add-reactor** prompt instead.
|
|
9
9
|
|
|
10
10
|
## Confirm first
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ description: Add a Chronicle reactor (automation or translation) that reacts to
|
|
|
5
5
|
|
|
6
6
|
# Add a Reactor
|
|
7
7
|
|
|
8
|
-
Add a reactor that observes events and produces side effects. Invoke the **
|
|
8
|
+
Add a reactor that observes events and produces side effects. Invoke the **cratis-chronicle-reactor** skill and follow `.cratis/ai/rules/reactors.md`.
|
|
9
9
|
|
|
10
10
|
## Confirm first
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ description: Add a Chronicle reducer to a read model when model-bound and fluent
|
|
|
5
5
|
|
|
6
6
|
# Add a Reducer
|
|
7
7
|
|
|
8
|
-
Add an `IReducerFor<T>` reducer — the last-resort escape hatch for a "current state + event → next state" transition that model-bound projection attributes and fluent `IProjectionFor<T>` cannot express. Invoke the **
|
|
8
|
+
Add an `IReducerFor<T>` reducer — the last-resort escape hatch for a "current state + event → next state" transition that model-bound projection attributes and fluent `IProjectionFor<T>` cannot express. Invoke the **cratis-chronicle-reducer** skill and follow `.cratis/ai/rules/vertical-slices.md`. For ordinary projections, use the **add-projection** prompt instead.
|
|
9
9
|
|
|
10
10
|
## Confirm first
|
|
11
11
|
|
|
@@ -5,7 +5,7 @@ description: Scaffold a complete vertical slice (backend + specs + frontend) for
|
|
|
5
5
|
|
|
6
6
|
# New Vertical Slice
|
|
7
7
|
|
|
8
|
-
Implement a complete **vertical slice** end-to-end.
|
|
8
|
+
Implement a complete **vertical slice** end-to-end. Follow the Implementation Workflow in `.cratis/ai/rules/application-profile.md` exactly; for a full backend + specs + frontend slice you may hand the work to the **Slice Implementer** agent.
|
|
9
9
|
|
|
10
10
|
## Confirm first
|
|
11
11
|
|
|
@@ -15,4 +15,4 @@ Implement a complete **vertical slice** end-to-end. Invoke the **new-vertical-sl
|
|
|
15
15
|
|
|
16
16
|
## How it runs
|
|
17
17
|
|
|
18
|
-
Backend → build (Debug + Release) → specs (the in-process `*Scenario` family) → frontend → compose/route, with each quality gate green before the next phase. The authoritative rules are `.cratis/ai/rules/general.md` and `.cratis/ai/rules/vertical-slices.md`; the
|
|
18
|
+
Backend → build (Debug + Release) → specs (the in-process `*Scenario` family) → frontend → compose/route, with each quality gate green before the next phase. The authoritative rules are `.cratis/ai/rules/general.md` and `.cratis/ai/rules/vertical-slices.md`; the rules carry the step-by-step detail. Do not duplicate that detail here.
|
|
@@ -5,7 +5,7 @@ description: Scaffold a new feature — folder structure, composition page, rout
|
|
|
5
5
|
|
|
6
6
|
# Scaffold a Feature
|
|
7
7
|
|
|
8
|
-
Scaffold a brand-new feature folder (composition page, routing, navigation) — ready for slices. Invoke the **
|
|
8
|
+
Scaffold a brand-new feature folder (composition page, routing, navigation) — ready for slices. Follow the Project Layout in `.cratis/ai/rules/application-profile.md` exactly, and Phase 3 of its Implementation Workflow plus the Composition section of `.cratis/ai/rules/react.md` for the composition page and routing. Invoke the **cratis-arc-react-page** skill for the page itself.
|
|
9
9
|
|
|
10
10
|
## Confirm first
|
|
11
11
|
|
|
@@ -13,4 +13,4 @@ Scaffold a brand-new feature folder (composition page, routing, navigation) —
|
|
|
13
13
|
- **Route path** — kebab-case (e.g. `/projects`)
|
|
14
14
|
- **Navigation label** and **icon** (from `react-icons/md`)
|
|
15
15
|
|
|
16
|
-
The feature folder lives directly under the app source root (or under an optional `<Module>/`) — there is no top-level `Features/` wrapper. After scaffolding, add behavior with the **new-vertical-slice** prompt
|
|
16
|
+
The feature folder lives directly under the app source root (or under an optional `<Module>/`) — there is no top-level `Features/` wrapper. After scaffolding, add behavior with the **new-vertical-slice** prompt. The rules carry the step-by-step detail; don't duplicate it here.
|
|
@@ -5,7 +5,7 @@ description: Write comprehensive BDD specs for an existing vertical slice comman
|
|
|
5
5
|
|
|
6
6
|
# Write Specs
|
|
7
7
|
|
|
8
|
-
Write **comprehensive specs** for an existing slice. Invoke the **
|
|
8
|
+
Write **comprehensive specs** for an existing slice. Invoke the **cratis-application-slice-specifications** skill (and **cratis-chronicle-event-specifications** / **cratis-chronicle-read-model-specifications** for constraints and projections); follow `.cratis/ai/rules/specs.md` and `.cratis/ai/rules/specs.csharp.md`.
|
|
9
9
|
|
|
10
10
|
## What to provide
|
|
11
11
|
|
|
@@ -50,7 +50,7 @@ Tagged **[contract]** (framework-enforced) or **[convention]** (house default).
|
|
|
50
50
|
|
|
51
51
|
## Implementation Workflow
|
|
52
52
|
|
|
53
|
-
- **Phase 0 — Model.** Confirm Module/Feature, slice name, slice type, domain rules; for new behavior or unclear event vocabulary run the **event-modeling** skill first.
|
|
53
|
+
- **Phase 0 — Model.** Confirm Module/Feature, slice name, slice type, domain rules; for new behavior or unclear event vocabulary run the **cratis-chronicle-event-modeling** skill first.
|
|
54
54
|
- **Phase 1 — Backend.** Implement a coherent slice change. **Gate:** incremental Debug build of the affected project (regenerates proxies, compiles `#if DEBUG` spec code).
|
|
55
55
|
- **Phase 2 — Specs.** Mandatory for every slice type, in-process scenario family first (`CommandScenario<T>`, `EventScenario`, `ReadModelScenario<T>`, `ReactorScenario<T>`). **Gate:** tests pass.
|
|
56
56
|
- **Phase 3 — Frontend.** Build from the generated proxies, register in the composition page, wire routing. **Gate:** lint, conditional test, build.
|
|
@@ -11,7 +11,7 @@ The framework repos are **libraries**, not event-sourced applications. The appli
|
|
|
11
11
|
|
|
12
12
|
## What still applies (universal rules)
|
|
13
13
|
|
|
14
|
-
Everything tagged `profile: universal` holds in framework repos exactly as in apps: **C# conventions** (`csharp.md`), **TypeScript conventions** (`typescript.md`), **code quality** (`code-quality*.md`), **specs** (`specs.md` / `specs.csharp.md` / `specs.typescript.md` — `Cratis.Specifications` is how the framework tests itself, using the plain `Specification` base + NSubstitute against the classes under test — this is the dominant mode in framework repos. The in-process `*Scenario` family lives in `specs.scenarios.csharp.md` (`profile: application`); it is the *application* default, and a framework repo reaches for it only to test the very engine it provides — Arc → `CommandScenario`, Chronicle → `EventScenario`/`ReadModelScenario`/`ReactorScenario` — not as a general testing mode. The **
|
|
14
|
+
Everything tagged `profile: universal` holds in framework repos exactly as in apps: **C# conventions** (`csharp.md`), **TypeScript conventions** (`typescript.md`), **code quality** (`code-quality*.md`), **specs** (`specs.md` / `specs.csharp.md` / `specs.typescript.md` — `Cratis.Specifications` is how the framework tests itself, using the plain `Specification` base + NSubstitute against the classes under test — this is the dominant mode in framework repos. The in-process `*Scenario` family lives in `specs.scenarios.csharp.md` (`profile: application`); it is the *application* default, and a framework repo reaches for it only to test the very engine it provides — Arc → `CommandScenario`, Chronicle → `EventScenario`/`ReadModelScenario`/`ReactorScenario` — not as a general testing mode. The **cratis-application-slice-specifications** skill is application-oriented), **documentation**, **git-commits**, **pull-requests**, **concepts** (`ConceptAs<T>` / `EventSourceId<T>` are Fundamentals/Chronicle primitives the framework defines and uses), and **American English**.
|
|
15
15
|
|
|
16
16
|
## What does NOT apply
|
|
17
17
|
|
|
@@ -123,4 +123,4 @@ Run the project's frontend test gate (e.g. `yarn test`) for frontend changes; it
|
|
|
123
123
|
- [react.md](./react.md) — MVVM, view-model testability, Arc hooks.
|
|
124
124
|
- [frontend-quality.md](./frontend-quality.md) — the engineering bar these specs serve.
|
|
125
125
|
- [specs.md](./specs.md) — the backend BDD language this mirrors.
|
|
126
|
-
- skill: **
|
|
126
|
+
- skill: **cratis-application-react-specifications** — the step-by-step workflow that applies these conventions.
|
|
@@ -10,8 +10,8 @@ paths:
|
|
|
10
10
|
Extends the base [specs.md](./specs.md) (folder structure, naming, philosophy) with C#-specific conventions. This file is the **universal foundation** used in **both** profiles — the `Cratis.Specifications` pattern (`Establish → Because → should_`) with NSubstitute.
|
|
11
11
|
|
|
12
12
|
> **Which spec surface?**
|
|
13
|
-
> - **Framework / library code** (Chronicle kernel, Arc pipeline, source generators, Fundamentals): the `Specification` base + NSubstitute in this file is the dominant mode — unit-test the classes under test in isolation. Reach for a `*Scenario` helper (in [specs.scenarios.csharp.md](./specs.scenarios.csharp.md)) **only** when testing the very engine your repo provides — Arc → `CommandScenario`, Chronicle → the event/projection/reactor scenarios. The **
|
|
14
|
-
> - **Event-sourced applications on Cratis** (commands, projections, reducers, reactors, constraints): use this base **plus** the in-process scenario family — see **[specs.scenarios.csharp.md](./specs.scenarios.csharp.md)** (`profile: application`) and the **
|
|
13
|
+
> - **Framework / library code** (Chronicle kernel, Arc pipeline, source generators, Fundamentals): the `Specification` base + NSubstitute in this file is the dominant mode — unit-test the classes under test in isolation. Reach for a `*Scenario` helper (in [specs.scenarios.csharp.md](./specs.scenarios.csharp.md)) **only** when testing the very engine your repo provides — Arc → `CommandScenario`, Chronicle → the event/projection/reactor scenarios. The **cratis-application-slice-specifications** skill is application-oriented, not for general framework specs.
|
|
14
|
+
> - **Event-sourced applications on Cratis** (commands, projections, reducers, reactors, constraints): use this base **plus** the in-process scenario family — see **[specs.scenarios.csharp.md](./specs.scenarios.csharp.md)** (`profile: application`) and the **cratis-application-slice-specifications** skill.
|
|
15
15
|
|
|
16
16
|
`Cratis.Specifications` keeps the approach of Machine.Specifications (MSpec): `Establish → Because → should_` maps to "Given → When → Then" and keeps each spec focused on *one setup, one action, one set of assertions*.
|
|
17
17
|
|
|
@@ -184,4 +184,4 @@ These supplement the universal conventions in [specs.csharp.md](./specs.csharp.m
|
|
|
184
184
|
- [specs.csharp.md](./specs.csharp.md) — the universal `Specification` + NSubstitute base this builds on (and what framework specs use).
|
|
185
185
|
- [vertical-slices.md](./vertical-slices.md) — what each artifact promises (the contract under spec).
|
|
186
186
|
- [efcore.specs.md](./efcore.specs.md) — `DbContext` specs with SQLite in-memory.
|
|
187
|
-
- skills: **
|
|
187
|
+
- skills: **cratis-application-slice-specifications**, **cratis-chronicle-event-specifications**, **cratis-chronicle-read-model-specifications**.
|
|
@@ -65,11 +65,11 @@ public record AuthorName(string Value) : ConceptAs<string>(Value)
|
|
|
65
65
|
}
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
**[convention] Placement:** slice-specific concept → in the slice file; feature-shared → feature folder; module-shared → module folder; app-wide → `Common/`. Scan `Common/` and the feature folder before creating a new concept. See [concepts.md](./concepts.md) for full patterns, or invoke the **
|
|
68
|
+
**[convention] Placement:** slice-specific concept → in the slice file; feature-shared → feature folder; module-shared → module folder; app-wide → `Common/`. Scan `Common/` and the feature folder before creating a new concept. See [concepts.md](./concepts.md) for full patterns, or invoke the **cratis-fundamentals-concept** skill.
|
|
69
69
|
|
|
70
70
|
## Commands
|
|
71
71
|
|
|
72
|
-
The command carries input from the caller. `Handle()` is defined directly on the record — never a separate handler class. For step-by-step creation, invoke the **cratis-command** skill.
|
|
72
|
+
The command carries input from the caller. `Handle()` is defined directly on the record — never a separate handler class. For step-by-step creation, invoke the **cratis-arc-command** skill.
|
|
73
73
|
|
|
74
74
|
> This application is event-sourced, so the guidance below assumes a command's `Handle()` returns event(s) that Arc+Chronicle appends. Arc itself is a standalone CQRS framework (see [general.md](./general.md)) — a command may legitimately return a response or `void` and do its work through injected services when a slice isn't event-sourced; the return-shape and "never inject `IEventLog`" rules are the event-sourced default, not universal Arc laws.
|
|
75
75
|
|
|
@@ -86,7 +86,7 @@ The command carries input from the caller. `Handle()` is defined directly on the
|
|
|
86
86
|
| Uniqueness | Chronicle `[Unique]` / `IConstraint` (race-safe) — not a read-model pre-check |
|
|
87
87
|
| Genuinely exceptional failure (bug, missing infra) | `throw` a domain exception |
|
|
88
88
|
|
|
89
|
-
**Do not throw for normal business rejection.** A thrown exception (from `Provide()` or `Handle()`) surfaces as an exception/HTTP 500, *not* a validation result. Recoverable, user-facing rejections are validation: `ValidationResult.Error(...)` via a validator or `Result<,>`. (For step-by-step business-rule placement, invoke the **
|
|
89
|
+
**Do not throw for normal business rejection.** A thrown exception (from `Provide()` or `Handle()`) surfaces as an exception/HTTP 500, *not* a validation result. Recoverable, user-facing rejections are validation: `ValidationResult.Error(...)` via a validator or `Result<,>`. (For step-by-step business-rule placement, invoke the **cratis-arc-command-validation** skill.)
|
|
90
90
|
|
|
91
91
|
### Causation — what a command records **[contract]**
|
|
92
92
|
|
|
@@ -185,7 +185,7 @@ Apply authorization attributes on the `[Command]` record or query method. **[con
|
|
|
185
185
|
|
|
186
186
|
`[EventType]` records are the schema-bound truth of the system.
|
|
187
187
|
|
|
188
|
-
- **[contract] No arguments for new events** — the type name is the identifier. Use `generation:`/id only when evolving an existing contract (invoke the **event-type-
|
|
188
|
+
- **[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).
|
|
189
189
|
- **[contract] Past-tense, one-purpose names** (`AuthorRegistered`, not `Updated`/`FormSubmitted`) — Chronicle requires past-tense, single-purpose facts. Self-describing without slice context.
|
|
190
190
|
- **[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.
|
|
191
191
|
- **[contract] Never carry the event-source id** — it's implicit in the event context.
|
|
@@ -210,13 +210,13 @@ public record AuthorRegistered(AuthorName Name);
|
|
|
210
210
|
|
|
211
211
|
## Read Models and Queries
|
|
212
212
|
|
|
213
|
-
**[contract]** `[ReadModel]` records expose queries as `public static` methods; dependencies are plain method parameters (no `[FromServices]`). Default to model-bound projection shape; drop to fluent only when needed. For step-by-step creation, invoke the **cratis-
|
|
213
|
+
**[contract]** `[ReadModel]` records expose queries as `public static` methods; dependencies are plain method parameters (no `[FromServices]`). Default to model-bound projection shape; drop to fluent only when needed. For step-by-step creation, invoke the **cratis-chronicle-read-model** skill.
|
|
214
214
|
|
|
215
215
|
### Query return shapes **[contract]**
|
|
216
216
|
|
|
217
217
|
Stay within analyzer-supported shapes: the read model, `T?`, a collection/array/`IQueryable<T>` of it, `Task<...>` of those, `IAsyncEnumerable<T>`, or `ISubject<...>` of read model/collection.
|
|
218
218
|
|
|
219
|
-
- **`IQueryable<TReadModel>`** → automatic server-side paging/sorting (frontend `useWithPaging` — see the **query-paging** skill). Use it whenever a list can grow.
|
|
219
|
+
- **`IQueryable<TReadModel>`** → automatic server-side paging/sorting (frontend `useWithPaging` — see the **cratis-arc-query-paging** skill). Use it whenever a list can grow.
|
|
220
220
|
- **`ISubject<...>`** → live/observable queries. Return it directly — **never** `Task<ISubject<...>>`.
|
|
221
221
|
- **[contract] Custom paths use `[Path("...")]`** (`PathAttribute`), not ASP.NET `[Route]`. Reserve `[Route]` for controller endpoints (which this convention avoids).
|
|
222
222
|
|
|
@@ -257,7 +257,7 @@ Ladder, first that fits: (1) direct read-model (DCB) injection — only when key
|
|
|
257
257
|
|
|
258
258
|
## Projections **[contract]**
|
|
259
259
|
|
|
260
|
-
Projections build read models from **events** (never from other read models). Use the ladder — for adding one to an existing model, invoke the **
|
|
260
|
+
Projections build read models from **events** (never from other read models). Use the ladder — for adding one to an existing model, invoke the **cratis-chronicle-projection** skill:
|
|
261
261
|
|
|
262
262
|
1. **Model-bound attributes** on the `[ReadModel]`: `[FromEvent<T>]`, `[SetFrom<T>]`, `[SetFromContext<T>]`, `[ChildrenFrom<T>]`, `[RemovedWith<T>]`, `[Nested]`, `[ClearWith<T>]`, counters, `[FromAll]`.
|
|
263
263
|
2. **Fluent `IProjectionFor<T>`** for joins, composite/constant keys, parent-key extraction, context mapping, `.NotRewindable()`, or supported conditional setters. Declarative metadata only — no DI side effects, no imperative `Define()` body, builder lambdas are member access only.
|
|
@@ -280,7 +280,7 @@ Group multi-event constraints under a shared name constant (`<Module>ConstraintN
|
|
|
280
280
|
|
|
281
281
|
## Reactors **[contract]**
|
|
282
282
|
|
|
283
|
-
`IReactor` is a marker interface; dispatch is by the first parameter type. Reactors live only in Automation/Translation slices. See [reactors.md](./reactors.md) for full rules, or invoke the **
|
|
283
|
+
`IReactor` is a marker interface; dispatch is by the first parameter type. Reactors live only in Automation/Translation slices. See [reactors.md](./reactors.md) for full rules, or invoke the **cratis-chronicle-reactor** skill.
|
|
284
284
|
|
|
285
285
|
```csharp
|
|
286
286
|
public Task AuthorRegistered(AuthorRegistered @event, EventContext context) => ...
|
|
@@ -340,4 +340,4 @@ Frontend commands run through the Cratis dialogs — never a vendor or hand-roll
|
|
|
340
340
|
- [concepts.md](./concepts.md) — `ConceptAs<T>` / `EventSourceId<T>` full patterns.
|
|
341
341
|
- [reactors.md](./reactors.md) — reactor signatures and side-effect rules.
|
|
342
342
|
- [specs.md](./specs.md) — `CommandScenario` / `EventScenario` / `ReadModelScenario` / `ReactorScenario`.
|
|
343
|
-
- skills: **event-modeling**, **
|
|
343
|
+
- skills: **cratis-chronicle-event-modeling**, **cratis-arc-command**, **cratis-chronicle-read-model**, **cratis-fundamentals-concept**, **cratis-chronicle-projection**, **cratis-chronicle-reactor**, **cratis-arc-command-validation**, **cratis-chronicle-event-type-migration**, **cratis-arc-command-execution**, **cratis-arc-query-paging**, **cratis-chronicle-multi-tenancy**.
|