@cratis/pi 7.10.0 → 7.11.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.
Files changed (70) hide show
  1. package/package/corpus/agents/backend-developer.md +1 -1
  2. package/package/corpus/agents/code-reviewer.md +2 -2
  3. package/package/corpus/agents/coordinator.md +1 -1
  4. package/package/corpus/agents/frontend-developer.md +1 -1
  5. package/package/corpus/agents/orchestrator.md +1 -1
  6. package/package/corpus/agents/planner.md +2 -2
  7. package/package/corpus/agents/screenplay-modeler.md +1 -1
  8. package/package/corpus/agents/slice-implementer.md +1 -1
  9. package/package/corpus/agents/spec-writer.md +1 -1
  10. package/package/corpus/harnesses/pi/extensions/cratis-hooks/index.ts +6 -5
  11. package/package/corpus/harnesses/pi/extensions/cratis-hooks/quality-gate.ts +25 -4
  12. package/package/corpus/hooks/README.md +33 -7
  13. package/package/corpus/hooks/scripts/cratis-quality-gate.sh +246 -79
  14. package/package/corpus/hooks/scripts/quality-gates.json +17 -3
  15. package/package/corpus/prompts/add-reactor.prompt.md +1 -1
  16. package/package/corpus/prompts/new-vertical-slice.prompt.md +2 -2
  17. package/package/corpus/prompts/write-specs.prompt.md +2 -2
  18. package/package/corpus/rules/application-profile.md +1 -1
  19. package/package/corpus/rules/cratis-folder-is-configuration.md +28 -0
  20. package/package/corpus/rules/general.md +6 -1
  21. package/package/corpus/rules/profiles.md +4 -3
  22. package/package/corpus/rules/reactors.md +1 -1
  23. package/package/corpus/rules/vertical-slices.md +1 -1
  24. package/package/corpus/skills/cratis-application-react-specifications/SKILL.md +1 -1
  25. package/package/corpus/skills/cratis-application-slice-conformance/SKILL.md +2 -2
  26. package/package/corpus/skills/cratis-application-slice-conformance/references/contract-and-precedence.md +1 -1
  27. package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +1 -1
  28. package/package/corpus/skills/cratis-arc-command/SKILL.md +1 -1
  29. package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +1 -1
  30. package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +1 -1
  31. package/package/corpus/skills/cratis-arc-observable-query-http/SKILL.md +1 -1
  32. package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +1 -1
  33. package/package/corpus/skills/cratis-arc-react-page/SKILL.md +1 -1
  34. package/package/corpus/skills/cratis-chronicle-event-constraints/SKILL.md +1 -1
  35. package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +2 -2
  36. package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +1 -1
  37. package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +1 -1
  38. package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +2 -2
  39. package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +1 -1
  40. package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +1 -1
  41. package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +1 -1
  42. package/package/corpus/skills/cratis-components-stepper-command-dialog/SKILL.md +1 -1
  43. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/SKILL.md +5 -2
  44. package/package/corpus/skills/cratis-screenplay-captures-and-reactions/verification.json +2 -2
  45. package/package/corpus/skills/cratis-screenplay-command-surface/SKILL.md +5 -2
  46. package/package/corpus/skills/cratis-screenplay-command-surface/verification.json +2 -2
  47. package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +1 -1
  48. package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +9 -6
  49. package/package/corpus/skills/cratis-screenplay-event-modeling/verification.json +2 -2
  50. package/package/corpus/skills/cratis-screenplay-model-authoring/SKILL.md +12 -10
  51. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-loop.md +3 -4
  52. package/package/corpus/skills/cratis-screenplay-model-authoring/references/mcp-tools.md +3 -3
  53. package/package/corpus/skills/cratis-screenplay-model-authoring/verification.json +3 -3
  54. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +5 -5
  55. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/opt-in.md +4 -4
  56. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +1 -1
  57. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/verdicts-and-modes.md +1 -1
  58. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/verification.json +1 -1
  59. package/package/corpus/skills/cratis-screenplay-projections/SKILL.md +5 -2
  60. package/package/corpus/skills/cratis-screenplay-projections/verification.json +2 -2
  61. package/package/corpus/skills/cratis-screenplay-read-surface/SKILL.md +5 -2
  62. package/package/corpus/skills/cratis-screenplay-read-surface/verification.json +2 -2
  63. package/package/corpus/skills/cratis-screenplay-specifications/SKILL.md +5 -2
  64. package/package/corpus/skills/cratis-screenplay-specifications/verification.json +2 -2
  65. package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +1 -1
  66. package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +5 -2
  67. package/package/corpus/skills/cratis-screenplay-ui-composition/verification.json +2 -2
  68. package/package/corpus/skills/cratis-specification-by-example/SKILL.md +1 -1
  69. package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +1 -1
  70. package/package.json +1 -1
@@ -3,8 +3,8 @@
3
3
  #
4
4
  # Looks at what actually changed in the working tree, runs only the gates that change touches,
5
5
  # and exits 2 (blocking turn-end, stderr fed back to the model) when one fails. It never edits
6
- # code: it only builds, tests and lints. If nothing relevant changed it exits immediately and
7
- # silently, so a documentation- or corpus-only turn costs nothing.
6
+ # code: it only builds, tests and lints. With no changes it exits silently. An empty plan for
7
+ # a changed tree reports on stderr that no product verification was performed, without running gates.
8
8
  #
9
9
  # Gate commands are data (quality-gates.json), not code — see that file for the schema.
10
10
  #
@@ -31,7 +31,7 @@ if [ -n "$input" ] && [ "$(hook_json "$input" '.stop_hook_active')" = "true" ];
31
31
  fi
32
32
 
33
33
  root="$(hook_repo_root)"
34
- here="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
34
+ here="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
35
35
  config="${CRATIS_HOOKS_GATES:-$here/quality-gates.json}"
36
36
  dryrun="${CRATIS_HOOKS_GATE_DRYRUN:-0}"
37
37
 
@@ -117,20 +117,144 @@ repository_paths() {
117
117
  printf '%s\n' "$repo_paths"
118
118
  }
119
119
 
120
- # Print the repository path a gate should be located by, given newline-separated globs.
121
- # The globs are tried IN ORDER and the first one with a match wins, so a configuration can
122
- # state a preference ("a solution at the root, else one anywhere") rather than depending on
123
- # where a path happens to sort. Prints nothing when nothing matches.
124
- discover_path() {
125
- local g match
126
- while IFS= read -r g; do
127
- [ -n "$g" ] || continue
128
- match="$(repository_paths | hook_glob_first_match "$g" || true)"
129
- [ -n "$match" ] && { printf '%s\n' "$match"; return 0; }
120
+ # An install manifest distinguishes a managed copy from the corpus's authored source.
121
+ # Resolve actual targets, not adapter names: a product may legitimately own .agents (etc.).
122
+ physical_root="$(cd -P "$root" && pwd -P)"
123
+ managed_root=""
124
+ if [ -f "$root/.cratis/ai.manifest.json" ] && [ -d "$root/.cratis/ai" ]; then
125
+ managed_root="$(cd -P "$root/.cratis/ai" && pwd -P)"
126
+ fi
127
+
128
+ repository_contains_path() {
129
+ case "$1" in
130
+ "$physical_root"|"$physical_root"/*) ;;
131
+ *) return 1 ;;
132
+ esac
133
+ if [ -n "$managed_root" ]; then
134
+ case "$1" in
135
+ "$managed_root"|"$managed_root"/*) return 1 ;;
136
+ esac
137
+ fi
138
+ }
139
+
140
+ repository_execution_directory() {
141
+ local dir
142
+ dir="$(cd -P "$root/$1" 2>/dev/null && pwd -P)" || return 1
143
+ repository_contains_path "$dir"
144
+ }
145
+
146
+ repository_project_path() {
147
+ local path="$root/$1" parent dir target hops=0
148
+ [ -f "$path" ] || return 1
149
+ parent=${1%/*}
150
+ [ "$parent" != "$1" ] || parent=.
151
+ # The execution directory must be owned too, even if the file links back into the repo.
152
+ repository_execution_directory "$parent" || return 1
153
+ while :; do
154
+ dir="$(cd -P "${path%/*}" 2>/dev/null && pwd -P)" || return 1
155
+ path="$dir/${path##*/}"
156
+ [ -L "$path" ] || break
157
+ hops=$((hops + 1))
158
+ [ "$hops" -le 40 ] || return 1
159
+ target="$(readlink "$path")" || return 1
160
+ case "$target" in
161
+ /*) path="$target" ;;
162
+ *) path="$dir/$target" ;;
163
+ esac
164
+ done
165
+ repository_contains_path "$path"
166
+ }
167
+
168
+ # Indexed arrays work on Bash 3.2. Populate caches in the parent shell, not a command
169
+ # substitution: identical frontend gates share one listing and one physical resolution.
170
+ project_cache_paths=()
171
+ project_cache_valid=()
172
+ candidate_cache_globs=()
173
+ candidate_cache_dirs=()
174
+ candidate_dirs=""
175
+ prepare_candidates() {
176
+ local globs="$1" i group selected_group="" candidate dir candidates valid
177
+ for ((i=0; i<${#candidate_cache_globs[@]}; i++)); do
178
+ if [ "${candidate_cache_globs[$i]}" = "$globs" ]; then
179
+ candidate_dirs="${candidate_cache_dirs[$i]}"
180
+ return 0
181
+ fi
182
+ done
183
+ repository_paths >/dev/null
184
+ # One pass matches all globs; the first group with an eligible candidate retains priority.
185
+ candidates="$(printf '%s\n' "$repo_paths" | CRATIS_GLOBS="$globs" awk "$hook_glob_awk_lib"'
186
+ BEGIN {
187
+ count = split(ENVIRON["CRATIS_GLOBS"], globs, "\n")
188
+ for (i = 1; i <= count; i++) res[i] = g2re(globs[i])
189
+ }
190
+ { paths[++n] = $0 }
191
+ END {
192
+ for (i = 1; i <= count; i++) for (j = 1; j <= n; j++)
193
+ if (!seen[paths[j]] && paths[j] ~ res[i]) { print i "\t" paths[j]; seen[paths[j]] = 1 }
194
+ }
195
+ ')"
196
+ candidate_dirs=""
197
+ while IFS=$'\t' read -r group candidate; do
198
+ [ -n "$candidate" ] || continue
199
+ if [ -n "$selected_group" ] && [ "$group" != "$selected_group" ]; then
200
+ break
201
+ fi
202
+ valid=""
203
+ for ((i=0; i<${#project_cache_paths[@]}; i++)); do
204
+ if [ "${project_cache_paths[$i]}" = "$candidate" ]; then
205
+ valid="${project_cache_valid[$i]}"
206
+ break
207
+ fi
208
+ done
209
+ if [ -z "$valid" ]; then
210
+ valid=0
211
+ repository_project_path "$candidate" && valid=1
212
+ project_cache_paths+=("$candidate")
213
+ project_cache_valid+=("$valid")
214
+ fi
215
+ [ "$valid" = 1 ] || continue
216
+ selected_group="$group"
217
+ dir=${candidate%/*}
218
+ [ "$dir" != "$candidate" ] || dir=.
219
+ candidate_dirs="${candidate_dirs}${candidate_dirs:+
220
+ }$dir"
221
+ # Keep main's root workspace/solution dispatch; it owns dependent-workspace coverage.
222
+ [ "$dir" != "." ] || { candidate_dirs="."; break; }
130
223
  done <<EOF
131
- $1
224
+ $candidates
132
225
  EOF
133
- return 1
226
+ candidate_cache_globs+=("$globs")
227
+ candidate_cache_dirs+=("$candidate_dirs")
228
+ }
229
+
230
+ # With no eligible root project, select the deepest containing directory per trigger.
231
+ # Prefix lookup is one awk pass, not a subprocess for every path/candidate pair.
232
+ discover_workdirs() {
233
+ [ -n "$candidate_dirs" ] || return 1
234
+ [ "$candidate_dirs" != "." ] || { printf '.\n'; return 0; }
235
+ printf '%s\n' "$1" | CRATIS_PROJECT_DIRS="$candidate_dirs" awk '
236
+ BEGIN {
237
+ n = split(ENVIRON["CRATIS_PROJECT_DIRS"], dirs, "\n")
238
+ for (i = 1; i <= n; i++) if (!known[dirs[i]]++) ordered[++count] = dirs[i]
239
+ }
240
+ NF {
241
+ parent = $0; found = 0
242
+ while (sub("/[^/]*$", "", parent)) {
243
+ if (known[parent]) { selected[parent] = 1; found = 1; break }
244
+ }
245
+ if (!found) {
246
+ if (count == 1) selected[ordered[1]] = 1
247
+ else {
248
+ printf "cratis-quality-gate: UNVERIFIED — no containing project for %s among multiple candidates. Configure workingDirectory.\n", $0 > "/dev/stderr"
249
+ failed = 1
250
+ }
251
+ }
252
+ }
253
+ END {
254
+ if (failed) exit 2
255
+ for (i = 1; i <= count; i++) if (selected[ordered[i]]) print ordered[i]
256
+ }
257
+ '
134
258
  }
135
259
 
136
260
  gate_count="$(jq -r '.gates | length' "$config")"
@@ -142,23 +266,26 @@ tmp_root="$(hook_state_dir "$(hook_json "$input" '.session_id')")" || tmp_root="
142
266
  log_dir="$tmp_root/gate-logs"
143
267
  mkdir -p "$log_dir" 2>/dev/null || log_dir="${TMPDIR:-/tmp}"
144
268
 
145
- # Does any changed path match this gate's globs (and survive its excludes)?
146
- gate_triggered() {
147
- local idx="$1" inc exc p
269
+ # Collect ALL paths matching this gate's globs after its exclusions, for discovery too.
270
+ gate_changed_paths() {
271
+ local idx="$1" inc exc
148
272
  inc="$(jq -r --argjson i "$idx" '.gates[$i].changed // [] | .[]' "$config")"
149
273
  exc="$(jq -r --argjson i "$idx" '.gates[$i].excludeChanged // [] | .[]' "$config")"
150
- [ -n "$inc" ] || return 1
151
- while IFS= read -r p; do
152
- [ -n "$p" ] || continue
153
- printf '%s\n' "$inc" | hook_glob_match "$p" || continue
154
- if [ -n "$exc" ]; then
155
- printf '%s\n' "$exc" | hook_glob_match "$p" && continue
156
- fi
157
- return 0
158
- done <<EOF
159
- $changed
160
- EOF
161
- return 1
274
+ printf '%s\n' "$changed" | CRATIS_INCLUDES="$inc" CRATIS_EXCLUDES="$exc" awk "$hook_glob_awk_lib"'
275
+ BEGIN {
276
+ ni = split(ENVIRON["CRATIS_INCLUDES"], includes, "\n")
277
+ ne = split(ENVIRON["CRATIS_EXCLUDES"], excludes, "\n")
278
+ for (i = 1; i <= ni; i++) if (includes[i] != "") inc[++ic] = g2re(includes[i])
279
+ for (i = 1; i <= ne; i++) if (excludes[i] != "") exc[++ec] = g2re(excludes[i])
280
+ }
281
+ NF {
282
+ matches = 0
283
+ for (i = 1; i <= ic; i++) if ($0 ~ inc[i]) { matches = 1; break }
284
+ if (!matches) next
285
+ for (i = 1; i <= ec; i++) if ($0 ~ exc[i]) { matches = 0; break }
286
+ if (matches) print
287
+ }
288
+ '
162
289
  }
163
290
 
164
291
  # Does the package.json at $1 define the script named $2? A missing file or a file that is not
@@ -167,21 +294,21 @@ package_defines_script() {
167
294
  [ -f "$1" ] && jq -e --arg s "$2" '.scripts[$s] != null' "$1" >/dev/null 2>&1
168
295
  }
169
296
 
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.
297
+ # Requirements are read once per gate, not once per affected directory.
298
+ # Report the first unmet requirement for the repo-relative execution directory $1.
172
299
  gate_unmet() {
173
- local idx="$1" dir="$2" c p s
300
+ local dir="$1" c p s
174
301
  while IFS= read -r c; do
175
302
  [ -n "$c" ] || continue
176
303
  hook_have "$c" || { printf "command '%s' is not on PATH" "$c"; return 0; }
177
304
  done <<EOF
178
- $(jq -r --argjson i "$idx" '.gates[$i].requires.commands // [] | .[]' "$config")
305
+ $required_commands
179
306
  EOF
180
307
  while IFS= read -r p; do
181
308
  [ -n "$p" ] || continue
182
309
  [ -e "$root/$p" ] || { printf "'%s' does not exist in this repository" "$p"; return 0; }
183
310
  done <<EOF
184
- $(jq -r --argjson i "$idx" '.gates[$i].requires.paths // [] | .[]' "$config")
311
+ $required_paths
185
312
  EOF
186
313
  # A package.json script a gate invokes must exist, or yarn fails with "Couldn't find a script"
187
314
  # instead of the gate being a NO-OP. A global script (g:) may live in the root package.json
@@ -197,91 +324,131 @@ EOF
197
324
  printf "script '%s' is not defined in %s" "$s" "$dir/package.json"
198
325
  return 0
199
326
  done <<EOF
200
- $(jq -r --argjson i "$idx" '.gates[$i].requires.packageScripts // [] | .[]' "$config")
327
+ $required_scripts
201
328
  EOF
202
329
  return 0
203
330
  }
204
331
 
205
332
  idx=0
206
333
  ran=0
334
+ planned_gates=0
335
+ planned_directories=()
207
336
  while [ "$idx" -lt "$gate_count" ]; do
208
337
  id="$(jq -r --argjson i "$idx" '.gates[$i].id' "$config")"
209
338
  desc="$(jq -r --argjson i "$idx" '.gates[$i].description // ""' "$config")"
210
339
  wd="$(jq -r --argjson i "$idx" '.gates[$i].workingDirectory // ""' "$config")"
211
340
 
212
- if ! gate_triggered "$idx"; then
341
+ gate_changes="$(gate_changed_paths "$idx")"
342
+ if [ -z "$gate_changes" ]; then
213
343
  [ "$dryrun" = "1" ] && printf 'cratis-quality-gate: SKIP %-24s (no matching change)\n' "$id" >&2
214
344
  idx=$((idx + 1))
215
345
  continue
216
346
  fi
217
347
 
218
- # workingDirectoryFrom is discovery AND requirement in one: the gate runs in the directory
219
- # of the discovered project file, and a repository holding no such file is a NO-OP.
220
- if [ -z "$wd" ]; then
348
+ # Discovery is a requirement and can select multiple affected project directories.
349
+ workdirs="$wd"
350
+ if [ -z "$workdirs" ]; then
221
351
  wd_globs="$(jq -r --argjson i "$idx" '.gates[$i].workingDirectoryFrom // [] | .[]' "$config")"
222
352
  if [ -n "$wd_globs" ]; then
223
- wd_path="$(discover_path "$wd_globs" || true)"
224
- if [ -z "$wd_path" ]; then
353
+ prepare_candidates "$wd_globs"
354
+ discovery_rc=0
355
+ workdirs="$(discover_workdirs "$gate_changes")" || discovery_rc=$?
356
+ if [ "$discovery_rc" -eq 2 ]; then
357
+ printf 'cratis-quality-gate: UNVERIFIED %-24s — ambiguous project discovery.\n' "$id" >&2
358
+ exit 2
359
+ fi
360
+ if [ -z "$workdirs" ]; then
225
361
  printf 'cratis-quality-gate: NO-OP %-24s — no repository path matches %s. Configure it in %s.\n' \
226
362
  "$id" "$(printf '%s' "$wd_globs" | tr '\n' ' ')" "${config#"$root"/}" >&2
227
363
  idx=$((idx + 1))
228
364
  continue
229
365
  fi
230
- wd="$(dirname "$wd_path")"
231
366
  fi
232
367
  fi
233
- [ -n "$wd" ] || wd="."
234
-
235
- unmet="$(gate_unmet "$idx" "$wd")"
236
- if [ -n "$unmet" ]; then
237
- printf 'cratis-quality-gate: NO-OP %-24s — %s. Configure it in %s.\n' \
238
- "$id" "$unmet" "${config#"$root"/}" >&2
239
- idx=$((idx + 1))
240
- continue
241
- fi
368
+ [ -n "$workdirs" ] || workdirs="."
242
369
 
370
+ required_commands="$(jq -r --argjson i "$idx" '.gates[$i].requires.commands // [] | .[]' "$config")"
371
+ required_paths="$(jq -r --argjson i "$idx" '.gates[$i].requires.paths // [] | .[]' "$config")"
372
+ required_scripts="$(jq -r --argjson i "$idx" '.gates[$i].requires.packageScripts // [] | .[]' "$config")"
243
373
  cmd=()
244
374
  while IFS= read -r arg; do
245
375
  cmd+=("$arg")
246
376
  done <<EOF
247
377
  $(jq -r --argjson i "$idx" '.gates[$i].command // [] | .[]' "$config")
248
378
  EOF
249
- if [ "${#cmd[@]}" -eq 0 ]; then
250
- idx=$((idx + 1))
251
- continue
252
- fi
253
379
 
254
- if [ "$dryrun" = "1" ]; then
255
- printf 'cratis-quality-gate: RUN %-24s %s\n $ %s (cwd: %s)\n' \
256
- "$id" "$desc" "${cmd[*]}" "$wd" >&2
257
- idx=$((idx + 1))
258
- ran=$((ran + 1))
259
- continue
260
- fi
380
+ project_index=0
381
+ gate_ran=0
382
+ gate_noops=0
383
+ while IFS= read -r wd; do
384
+ project_index=$((project_index + 1))
385
+ if ! repository_execution_directory "$wd"; then
386
+ printf 'cratis-quality-gate: UNVERIFIED %-24s — execution directory %s is outside the repository or inside the managed corpus.\n' "$id" "$wd" >&2
387
+ exit 2
388
+ fi
389
+ unmet="$(gate_unmet "$wd")"
390
+ if [ -n "$unmet" ]; then
391
+ printf 'cratis-quality-gate: NO-OP %-24s — %s. Configure it in %s.\n' \
392
+ "$id" "$unmet" "${config#"$root"/}" >&2
393
+ gate_noops=$((gate_noops + 1))
394
+ continue
395
+ fi
396
+ if [ "${#cmd[@]}" -eq 0 ]; then
397
+ continue
398
+ fi
261
399
 
262
- log="$log_dir/$id.log"
263
- rc=0
264
- (cd "$root/$wd" && "${cmd[@]}") >"$log" 2>&1 || rc=$?
265
- ran=$((ran + 1))
400
+ gate_ran=$((gate_ran + 1))
401
+ if [ "$dryrun" = "1" ]; then
402
+ [ "$gate_ran" -ne 1 ] || planned_gates=$((planned_gates + 1))
403
+ directory_seen=0
404
+ if [ "${#planned_directories[@]}" -gt 0 ]; then
405
+ for directory in "${planned_directories[@]}"; do
406
+ [ "$directory" != "$wd" ] || directory_seen=1
407
+ done
408
+ fi
409
+ [ "$directory_seen" -ne 0 ] || planned_directories+=("$wd")
410
+ printf 'cratis-quality-gate: RUN %-24s %s\n $ %s (cwd: %s)\n' \
411
+ "$id" "$desc" "${cmd[*]}" "$wd" >&2
412
+ ran=$((ran + 1))
413
+ continue
414
+ fi
266
415
 
267
- if [ "$rc" -ne 0 ]; then
416
+ log="$log_dir/$id.log"
417
+ [ "$project_index" -eq 1 ] || log="$log_dir/$id-$project_index.log"
418
+ rc=0
268
419
  {
269
- printf 'QUALITY GATE FAILED: %s (exit %s)\n' "$id" "$rc"
270
- printf ' %s\n' "$desc"
271
- printf ' $ %s (cwd: %s)\n\n' "${cmd[*]}" "$wd"
272
- printf -- '--- last %s lines ---\n' "$max_lines"
273
- tail -n "$max_lines" "$log" 2>/dev/null || true
274
- printf -- '--- end ---\n\n'
275
- printf 'Fix the failure and re-run the gate. Never change code merely to make a gate pass,\n'
276
- printf 'and never suppress warnings. Full log: %s\n' "$log"
277
- } >&2
420
+ printf 'cratis-quality-gate: LOG %s (cwd: %s)\n' "$id" "$wd"
421
+ (cd -P "$root/$wd" && "${cmd[@]}") </dev/null
422
+ } >"$log" 2>&1 || rc=$?
423
+ ran=$((ran + 1))
424
+
425
+ if [ "$rc" -ne 0 ]; then
426
+ {
427
+ printf 'QUALITY GATE FAILED: %s (exit %s)\n' "$id" "$rc"
428
+ printf ' %s\n' "$desc"
429
+ printf ' $ %s (cwd: %s)\n\n' "${cmd[*]}" "$wd"
430
+ printf -- '--- last %s lines ---\n' "$max_lines"
431
+ tail -n "$max_lines" "$log" 2>/dev/null || true
432
+ printf -- '--- end ---\n\n'
433
+ printf 'Fix the failure and re-run the gate. Never change code merely to make a gate pass,\n'
434
+ printf 'and never suppress warnings. Full log: %s\n' "$log"
435
+ } >&2
436
+ [ "$fail_fast" = "true" ] && exit 2
437
+ failed=1
438
+ fi
439
+ done <<EOF
440
+ $workdirs
441
+ EOF
442
+ if [ "$gate_ran" -gt 0 ] && [ "$gate_noops" -gt 0 ]; then
443
+ printf 'cratis-quality-gate: UNVERIFIED %-24s — %s affected project(s) did not meet requirements; the gate is incomplete.\n' "$id" "$gate_noops" >&2
278
444
  [ "$fail_fast" = "true" ] && exit 2
279
445
  failed=1
280
446
  fi
281
-
282
447
  idx=$((idx + 1))
283
448
  done
284
449
 
285
450
  [ "${failed:-0}" -eq 0 ] || exit 2
286
- [ "$dryrun" = "1" ] && printf 'cratis-quality-gate: dry run complete — %s gate(s) would run.\n' "$ran" >&2
451
+ [ "$dryrun" = "1" ] && printf 'cratis-quality-gate: dry run complete — %s gate(s) would run across %s project directory(s) (%s run(s)).\n' \
452
+ "$planned_gates" "${#planned_directories[@]}" "$ran" >&2
453
+ [ "$ran" -eq 0 ] && printf 'cratis-quality-gate: no gates selected — product verification was not performed.\n' >&2
287
454
  exit 0
@@ -24,8 +24,22 @@
24
24
  " workingDirectory repo-relative directory the command runs in",
25
25
  " workingDirectoryFrom globs identifying the project file this gate builds; the command runs",
26
26
  " in that file's directory, and a repository holding none makes the gate a",
27
- " NO-OP. Globs are tried in order, so the list states a preference. Ignored",
28
- " when workingDirectory is set.",
27
+ " NO-OP. The first glob with an eligible project wins. Ignored",
28
+ " when workingDirectory is set. Discovery excludes the installed .cratis/ai tree",
29
+ " when .cratis/ai.manifest.json exists, including symlinks resolving into that tree.",
30
+ " Symlinks outside the task-owning repository are never discovered. Without the install",
31
+ " manifest the corpus is authored source and its packages remain eligible. Physical",
32
+ " resolution preserves symlink/.. semantics. Only changed paths surviving this gate's",
33
+ " changed/excludeChanged filters select projects: the deepest containing project per",
34
+ " path wins within that glob when no eligible root project exists. The default root-first",
35
+ " globs preserve workspace/solution dispatch. A root workspace or solution keeps",
36
+ " repository-wide dispatch; otherwise the gate runs once per affected directory. A single project",
37
+ " may own source outside its directory; multiple candidates with an uncontained trigger",
38
+ " report UNVERIFIED and exit 2 rather than silently checking an arbitrary project.",
39
+ " Both the project-file target and the execution directory must pass containment.",
40
+ " Candidate resolution is cached across gates; filtering and prefix lookup are batched.",
41
+ " Mixed RUN/NO-OP directories report UNVERIFIED and exit 2, not a partial success.",
42
+ " Gate commands read /dev/null so they cannot consume remaining directories.",
29
43
  " command argv array \u2014 executed directly, never through a shell (no eval)",
30
44
  "",
31
45
  "Managed corpus and adapter trees (.cratis/**, .pi/**, .claude/**) never count as a relevant change:",
@@ -35,7 +49,7 @@
35
49
  "silently no-op in every repository except the one it was written for. The .NET and frontend",
36
50
  "gates discover the repository's own solution/package instead, so they activate unchanged in",
37
51
  "an application repository, a framework repository, and (as nothing to run) in a corpus-only",
38
- "repository such as this one, which carries no .NET or Node project at all.",
52
+ "repository. An empty plan reports that no product verification was performed.",
39
53
  "",
40
54
  "The override model, in order of increasing force: a repository states only what differs in its",
41
55
  "own .cratis/ai/quality-gates.project.json, which the runner merges over this file by gate id",
@@ -9,7 +9,7 @@ Add a reactor that observes events and produces side effects. Invoke the **crati
9
9
 
10
10
  ## Confirm first
11
11
 
12
- - **Model first:** if an accepted model under the model root covers this scope, or the repository is opted in (the model root (default `.cratis/screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in (master: `cratis-screenplay-modeling-lifecycle`)), the automation belongs in the model (`produces` / `invokes`); check there before writing code and follow the model-first routing in `.cratis/ai/rules/general.md`. Reactor code is then gap-fill against the modeled contract. If not opted in, stay code-first.
12
+ - **Model first:** if an accepted model under the model root covers this scope, or the repository is opted in (the model root (the folder holding the project's `.play` files) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in (master: `cratis-screenplay-modeling-lifecycle`)), the automation belongs in the model (`produces` / `invokes`); check there before writing code and follow the model-first routing in `.cratis/ai/rules/general.md`. Reactor code is then gap-fill against the modeled contract. If not opted in, stay code-first.
13
13
  - **Events to react to**, the **side effect**, and the slice type: `Automation` (our own event causes an external side effect, a follow-up event, or a follow-up command) or `Translation` (data from an outside system recorded as our own facts).
14
14
  - **Contract details to settle:** where each output field comes from (the trigger event, an injected read model, or a stated mapping), every condition that skips an event, and what must not happen twice.
15
15
 
@@ -11,8 +11,8 @@ Implement a complete **vertical slice** end-to-end. Follow the Implementation Wo
11
11
 
12
12
  Before any slice code, find what the code must match. Decide the route once:
13
13
 
14
- 1. **The slice is in an accepted Screenplay model** (search the model root for the slice, command, event and read-model names; default `.cratis/screenplay/**/*.play`, or the configured root). The `.play` slice and its specifications are the contract. Change behavior in the model first (the `cratis-screenplay-*` skills), then render it (`cratis-stage-rendering-and-sandbox`). Hand-write C# only for scope the renderer rejects, or for adapters, infrastructure and clients; the model stays the oracle for that code (`cratis-application-slice-conformance`). Never hand-edit rendered, managed output, and never change the model to match existing code.
15
- 2. **The repository is opted in, but the slice is not modeled** (opted in means the model root (default `.cratis/screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in (master: `cratis-screenplay-modeling-lifecycle`); an accepted model elsewhere that does not cover this slice does not by itself opt in): model it first, then continue with route 1. Write code first only when the user chooses to, or the behavior cannot be expressed in `.play`; say then that the model lags the code.
14
+ 1. **The slice is in an accepted Screenplay model** (search the model root for the slice, command, event and read-model names; the project's `**/*.play`, or the configured root). The `.play` slice and its specifications are the contract. Change behavior in the model first (the `cratis-screenplay-*` skills), then render it (`cratis-stage-rendering-and-sandbox`). Hand-write C# only for scope the renderer rejects, or for adapters, infrastructure and clients; the model stays the oracle for that code (`cratis-application-slice-conformance`). Never hand-edit rendered, managed output, and never change the model to match existing code.
15
+ 2. **The repository is opted in, but the slice is not modeled** (opted in means the model root (the folder holding the project's `.play` files) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in (master: `cratis-screenplay-modeling-lifecycle`); an accepted model elsewhere that does not cover this slice does not by itself opt in): model it first, then continue with route 1. Write code first only when the user chooses to, or the behavior cannot be expressed in `.play`; say then that the model lags the code.
16
16
  3. **No accepted model covers this scope and the repository is not opted in:** stay code-first and never force a model. Only the entry-point session may propose one, at most once per session, never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work, and not again if declined. Framework, brownfield, infrastructure, client and adapter work keep their code-first path. For new behavior or unclear event vocabulary, run **cratis-chronicle-event-modeling** first; the agreed outline (fields, events, rules, scenarios) is the contract, recorded where the team tracks work, if anywhere.
17
17
 
18
18
  Whether the Screenplay skills are installed is a separate question from consent: if the route needs them and they are missing, say so and ask; do not author `.play` from memory.
@@ -9,11 +9,11 @@ Write **comprehensive specs** for an existing slice. Invoke the **cratis-applica
9
9
 
10
10
  ## What to provide
11
11
 
12
- The slice file (`.cs`) **and its contract**: the `.play` slice with its specifications when the slice is modeled (search the model root, default `.cratis/screenplay/`), otherwise the agreed slice outline.
12
+ The slice file (`.cs`) **and its contract**: the `.play` slice with its specifications when the slice is modeled (search the model root, the folder holding the project's `.play` files), otherwise the agreed slice outline.
13
13
 
14
14
  If no contract can be found, decide once:
15
15
 
16
- - **An accepted model under the model root covers the scope, or the repository is opted in** (the model root (default `.cratis/screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in (master: `cratis-screenplay-modeling-lifecycle`)): do not write code-derived specs in its place. Route to the `cratis-screenplay-*` skills (`cratis-screenplay-specifications`, `cratis-screenplay-scenario-coverage`) to add the slice's specifications to the model first. If those skills are not installed, say so and stop; do not author `.play` from memory.
16
+ - **An accepted model under the model root covers the scope, or the repository is opted in** (the model root (the folder holding the project's `.play` files) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in (master: `cratis-screenplay-modeling-lifecycle`)): do not write code-derived specs in its place. Route to the `cratis-screenplay-*` skills (`cratis-screenplay-specifications`, `cratis-screenplay-scenario-coverage`) to add the slice's specifications to the model first. If those skills are not installed, say so and stop; do not author `.play` from memory.
17
17
  - **No model coverage and no opt-in:** stay code-first. Write from the code, report every case as a proposal rather than as agreed behavior. A model is proposed only by the entry-point session, at most once per session, and not for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work.
18
18
 
19
19
  ## Coverage (every slice type)
@@ -53,7 +53,7 @@ Tagged **[contract]** (framework-enforced) or **[convention]** (house default).
53
53
  ## Implementation Workflow
54
54
 
55
55
  - **Phase 0 — Find the contract / choose the level.** Before writing slice code, find what the code must match, and choose the level once for the whole scope.
56
- 1. **Look for a Screenplay model** under the model root (default `.cratis/screenplay/`, or the root set by `mcpServers.screenplay.root` in `.cratis/ai.json`; search `**/*.play`) for the slice, command, event and read-model names. A `.play` file outside the root, an untracked or uncommitted draft, an empty directory, or an installed profile or skill is not opt-in; the repository is opted in only when the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project set that root explicitly (master definition: **cratis-screenplay-modeling-lifecycle**, "Decide the level first").
56
+ 1. **Look for a Screenplay model** under the model root (the folder holding the project's `.play` files, or the root set by `mcpServers.screenplay.root` in `.cratis/ai.json`; search `**/*.play`) for the slice, command, event and read-model names. A `.play` file outside the root, an untracked or uncommitted draft, an empty directory, or an installed profile or skill is not opt-in; the repository is opted in only when the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project set that root explicitly (master definition: **cratis-screenplay-modeling-lifecycle**, "Decide the level first").
57
57
  2. **Model level** — an accepted model under the root covers the scope, or the repository is opted in and this scope has no model yet. The `.play` slice and its specs are the contract: change the model first (new behavior starts in discovery), verify it (V1–V3), get an independent review, then render with Stage or gap-fill by hand only what the renderer rejects. Hand-written code stays checked against the model (**cratis-application-slice-conformance**). Never edit Stage-managed output, never implement behavior the model does not state, never change the model to match existing code, never weaken protection to make it compile or render. Start with **cratis-screenplay-event-modeling** (decision rule), then **cratis-screenplay-modeling-lifecycle**. If the Screenplay skills are not installed, say so; do not author `.play` from memory.
58
58
  3. **Code level** — infrastructure (hosting, DI composition, identity wiring, CI, deployment), clients, Screenplay code attachments and handlers, adapters in the render's customization area, and scope Stage cannot render yet (the model remains the contract). Framework repositories and brownfield work that is not opted in also stay code-first. Only the entry-point session may propose a model, at most once per session and never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work; if declined, do not ask again. Confirm Module/Feature, slice name, slice type and domain requirements as before; for new behavior or unclear event vocabulary run **cratis-chronicle-event-modeling** first, and record the agreed outline (fields, events, rules, scenarios) where the team tracks work, if anywhere. If you write code first where a model exists, say the model now lags.
59
59
  4. **Trivial changes** keep the proportional-delegation policy; Phases 1–3 below apply to code you write at either level.
@@ -0,0 +1,28 @@
1
+ ---
2
+ applyTo: "**/*"
3
+ ---
4
+
5
+ # `.cratis/` is configuration, never a place to produce things
6
+
7
+ The `.cratis/` folder is a configuration folder, like `.vscode/` or `.github/`. It holds
8
+ project configuration and the shared AI corpus itself, and nothing else.
9
+
10
+ - **Allowed:** `.cratis/ai.json` and `.cratis/ai.manifest.json`, the installed corpus under
11
+ `.cratis/ai/`, and other tool configuration a Cratis tool reads (settings, profiles,
12
+ connection and environment descriptors).
13
+ - **Never produce anything there that can end up in production or that a person or
14
+ product consumes as a deliverable:** Screenplay models and `.play` files, source code,
15
+ generated code, specifications, documentation, migrations, assets, data, build output.
16
+ Those belong in the project's own structure: `Source/` or `src/`, `Documentation/`,
17
+ the product's own folders. A Screenplay model goes where the project's `.play` files
18
+ already are, else under `Source/` or `src/`, else in a `Screenplay/` folder at the
19
+ repository root.
20
+ - **Work records are not exempt from a home.** Plans, handovers and scratch notes go in
21
+ `.ai-work/`, never in `.cratis/`; see [local-work-artifacts.md](./local-work-artifacts.md).
22
+ - **Never hand-edit installed corpus files under `.cratis/ai/`** in a consuming
23
+ repository; they are managed by the channel that installed them.
24
+ - If a request would put a deliverable under `.cratis/`, put it in the project structure
25
+ instead and say so in one line; do not ask permission to follow this rule.
26
+ - A repository that already keeps a model under `.cratis/screenplay/` keeps working: read
27
+ it where it is, but do not add new deliverables there, and offer to move it to the
28
+ project structure when the user is changing it anyway.
@@ -104,7 +104,7 @@ A claim is only as good as the signal behind it — a build result, a test run,
104
104
 
105
105
  > **Building an application on Cratis?** Project layout, slice types, slice naming, the seventeen slice rules, the implementation workflow and the application quality gates are in [application-profile.md](./application-profile.md), which loads only for repositories that select an application profile. If you are contributing to a Cratis framework repo, see **Framework profile** below.
106
106
 
107
- **Model first.** When an accepted `.play` model covers the scope, or the repository has opted in, the `.play` model is the source of truth for behavior: change the model first, verify it, then render it or gap-fill from it, and never edit Stage-managed output, take code as a shortcut around the model, or weaken protection (authorization, `@pii`, rules) to make a model compile or render. Opted in means the model root (default `.cratis/screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it), or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed profile or skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in, and a behavior is a contract only when an accepted model under the root covers it (accepted means committed: staged or untracked files under the root are drafts; a committed file with uncommitted working-tree edits is a model change in progress, and its HEAD version is the contract until the change is committed; committing a model under the root is the team's act of acceptance and opts the repository in; an explicitly configured but empty root also counts as opted in). Otherwise stay code-first; the entry-point session may propose a model at most once per session (never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work), and infrastructure, client and adapter work stays in code at any level. Trivial changes keep the proportional-delegation policy. The master decision rule is in **cratis-screenplay-modeling-lifecycle** (router: **cratis-screenplay-event-modeling**); if the Screenplay skills are not installed, say so and do not author `.play` from memory.
107
+ **Model first.** When an accepted `.play` model covers the scope, or the repository has opted in, the `.play` model is the source of truth for behavior: change the model first, verify it, then render it or gap-fill from it, and never edit Stage-managed output, take code as a shortcut around the model, or weaken protection (authorization, `@pii`, rules) to make a model compile or render. Opted in means the model root (the folder holding the project's `.play` files) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an installed profile or skill, a `.play` file outside the root or an untracked or uncommitted draft is not opt-in, and a behavior is a contract only when an accepted model under the root covers it (accepted means committed: staged or untracked files under the root are drafts; a committed file with uncommitted working-tree edits is a model change in progress, and its HEAD version is the contract until the change is committed; committing a model under the root is the team's act of acceptance and opts the repository in; an explicitly configured but empty root also counts as opted in). Otherwise stay code-first; the entry-point session may propose a model at most once per session (never for trivial, bug-fix, infrastructure, client, framework or brownfield-maintenance work), and infrastructure, client and adapter work stays in code at any level. Trivial changes keep the proportional-delegation policy. The master decision rule is in **cratis-screenplay-modeling-lifecycle** (router: **cratis-screenplay-event-modeling**); if the Screenplay skills are not installed, say so and do not author `.play` from memory.
108
108
 
109
109
  ---
110
110
 
@@ -146,6 +146,7 @@ A claim is only as good as the signal behind it — a build result, a test run,
146
146
  | What must stop and ask a human | `capability-is-not-authority.md` (absent authority for a consequential effect: stop and ask) |
147
147
  | What counts as evidence that something works | `verification-discipline.md` |
148
148
  | Where session notes, plans and handovers may live | `local-work-artifacts.md` |
149
+ | What may be written into the `.cratis/` folder (configuration and the corpus only, never deliverables) | `cratis-folder-is-configuration.md` |
149
150
  | Exit-code meaning and wrappers that lose a verdict | `exit-codes-and-wrappers.md` |
150
151
  | Writing a scan, allowlist or destructive pass that cannot pass vacuously | `guards-and-fuses.md` |
151
152
  | How the shared corpus is installed, updated and rolled back | `ai-distribution.md` |
@@ -177,6 +178,10 @@ A claim is only as good as the signal behind it — a build result, a test run,
177
178
  // Licensed under the MIT license. See LICENSE file in the project root for full license information.
178
179
  ```
179
180
 
181
+ ## `.cratis/` is configuration only
182
+
183
+ Never produce deliverables - Screenplay models, source, generated code, specifications, documentation, anything that can ship - into `.cratis/`. It holds configuration and the shared AI corpus itself. Full rule: [cratis-folder-is-configuration.md](./cratis-folder-is-configuration.md).
184
+
180
185
  ## Local AI work artifacts — `.ai-work/` only
181
186
 
182
187
  Plans, handovers, session notes, scratch analyses and research dumps are **work records, not documentation**: they live only in the gitignored `.ai-work/` at the repository root, never enter git history, and are never the only copy of a durable decision (those go in `decisions/`). A follow-up that must outlive the session is an issue, not a file. Full rule: [local-work-artifacts.md](./local-work-artifacts.md).
@@ -151,7 +151,7 @@ Standalone Chronicle client usage (no Arc) in TypeScript is
151
151
  ### Event modeling with Screenplay
152
152
 
153
153
  **Model first.** A repository is opted in only when its model root (where the project's
154
- `.play` files live: normally under `Source/` or `src/`, else `Screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set
154
+ `.play` files live: normally under `Source/` or `src/`, else `Screenplay/`) holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set
155
155
  `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install output, an
156
156
  installed profile or skill, a `.play` file outside the root or an untracked or uncommitted draft is not
157
157
  opt-in. An accepted model under the root covering the scope is the contract and the source
@@ -205,8 +205,9 @@ The profile also selects the corpus-owned Screenplay MCP declaration from
205
205
  `mcp-servers.json`. The Cratis CLI hosts the server as `cratis screenplay mcp`
206
206
  and registers a scoped entry for supported clients without replacing their other
207
207
  servers. Inspect install/status results for adapter support or configuration
208
- conflicts. The conventional model root is `.cratis/screenplay/`; project-owned
209
- configuration can choose another root.
208
+ conflicts. The model is wherever the project keeps its `.play` files, else under `Source/` or
209
+ `src/`, else in a `Screenplay/` folder at the repository root; never under `.cratis/`.
210
+ Project-owned configuration can name a root explicitly.
210
211
 
211
212
  ## How to Use Profiles
212
213
 
@@ -9,7 +9,7 @@ profile: application
9
9
 
10
10
  Reactors are the "if this then that" of event sourcing — they observe events and produce side effects. Unlike projections (which build state), reactors *do things*: send emails, trigger commands in other slices, call external APIs.
11
11
 
12
- **Model first:** when an accepted model under the model root covers this scope (or the repository is opted in: the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD -- <root>` lists it) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; master definition in `cratis-screenplay-modeling-lifecycle`), a reactor implements an automation that the model owns (`produces` / `invokes`); read the modeled slice first and keep the reactor to what the model leaves to code (gap-fill). Otherwise (not opted in) stay code-first: this file and the **cratis-chronicle-reactor** skill are the guide, and the entry-point session may propose a model at most once per session. A `.play` file outside the root, an untracked or uncommitted draft or an empty directory is not consent.
12
+ **Model first:** when an accepted model under the model root covers this scope (or the repository is opted in: the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured) or the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json`; master definition in `cratis-screenplay-modeling-lifecycle`), a reactor implements an automation that the model owns (`produces` / `invokes`); read the modeled slice first and keep the reactor to what the model leaves to code (gap-fill). Otherwise (not opted in) stay code-first: this file and the **cratis-chronicle-reactor** skill are the guide, and the entry-point session may propose a model at most once per session. A `.play` file outside the root, an untracked or uncommitted draft or an empty directory is not consent.
13
13
 
14
14
  ## IReactor — Marker Interface
15
15