@cratis/pi 7.54.0 → 7.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/package/corpus/agents/backend-developer.md +1 -1
  2. package/package/corpus/agents/code-reviewer.md +1 -1
  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 +1 -1
  7. package/package/corpus/agents/screenplay-modeler.md +1 -1
  8. package/package/corpus/agents/slice-implementer.md +2 -2
  9. package/package/corpus/agents/spec-writer.md +1 -1
  10. package/package/corpus/harnesses/copilot/instructions/application-profile.instructions.md +1 -1
  11. package/package/corpus/harnesses/copilot/instructions/profiles.instructions.md +1 -5
  12. package/package/corpus/harnesses/copilot/instructions/reactors.instructions.md +1 -1
  13. package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +1 -1
  14. package/package/corpus/prompts/add-reactor.prompt.md +1 -1
  15. package/package/corpus/prompts/new-vertical-slice.prompt.md +1 -1
  16. package/package/corpus/prompts/write-specs.prompt.md +1 -1
  17. package/package/corpus/rules/application-profile.md +1 -1
  18. package/package/corpus/rules/profiles.md +1 -5
  19. package/package/corpus/rules/reactors.md +1 -1
  20. package/package/corpus/rules/vertical-slices.md +1 -1
  21. package/package/corpus/skills/cratis-application-react-specifications/SKILL.md +1 -4
  22. package/package/corpus/skills/cratis-application-slice-conformance/SKILL.md +6 -10
  23. package/package/corpus/skills/cratis-application-slice-conformance/references/contract-and-precedence.md +3 -8
  24. package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +1 -3
  25. package/package/corpus/skills/cratis-arc-command/SKILL.md +1 -4
  26. package/package/corpus/skills/cratis-arc-command-execution/SKILL.md +1 -4
  27. package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +1 -4
  28. package/package/corpus/skills/cratis-arc-observable-query-http/SKILL.md +1 -4
  29. package/package/corpus/skills/cratis-arc-query-paging/SKILL.md +1 -4
  30. package/package/corpus/skills/cratis-arc-react-page/SKILL.md +1 -4
  31. package/package/corpus/skills/cratis-chronicle-event-constraints/SKILL.md +1 -4
  32. package/package/corpus/skills/cratis-chronicle-event-modeling/SKILL.md +2 -5
  33. package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +1 -4
  34. package/package/corpus/skills/cratis-chronicle-projection/SKILL.md +1 -4
  35. package/package/corpus/skills/cratis-chronicle-reactor/SKILL.md +1 -3
  36. package/package/corpus/skills/cratis-chronicle-read-model/SKILL.md +1 -4
  37. package/package/corpus/skills/cratis-chronicle-read-model-specifications/SKILL.md +1 -3
  38. package/package/corpus/skills/cratis-chronicle-reducer/SKILL.md +1 -4
  39. package/package/corpus/skills/cratis-components-stepper-command-dialog/SKILL.md +1 -4
  40. package/package/corpus/skills/cratis-screenplay-discovery/SKILL.md +1 -2
  41. package/package/corpus/skills/cratis-screenplay-event-modeling/SKILL.md +1 -7
  42. package/package/corpus/skills/cratis-screenplay-legacy-extraction/references/generate-notes.md +6 -0
  43. package/package/corpus/skills/cratis-screenplay-model-review/SKILL.md +1 -1
  44. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/SKILL.md +9 -9
  45. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/opt-in.md +3 -33
  46. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/references/phases.md +2 -5
  47. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/scripts/model-first-self-test.mjs +104 -0
  48. package/package/corpus/skills/cratis-screenplay-modeling-lifecycle/scripts/model-first-status.mjs +141 -0
  49. package/package/corpus/skills/cratis-screenplay-toolchain/SKILL.md +1 -1
  50. package/package/corpus/skills/cratis-screenplay-ui-composition/SKILL.md +2 -0
  51. package/package/corpus/skills/cratis-specification-by-example/SKILL.md +1 -3
  52. package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +1 -4
  53. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/SKILL.md +17 -14
  54. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/behavior-walk.md +77 -0
  55. package/package.json +1 -1
@@ -272,10 +272,7 @@ prove transport, replay, encryption, erasure or sink migration. Cover, at minimu
272
272
  ## Route near misses
273
273
 
274
274
  - An accepted `.play` model under the model root covers the behavior, or the
275
- repository is opted in (the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the project set
276
- `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
277
- output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
278
- `cratis-screenplay-modeling-lifecycle`): change the model first with
275
+ repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
279
276
  `cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
280
277
  say so and do not author `.play` from memory.
281
278
  Edit code here only for infrastructure, clients, adapters, Screenplay code
@@ -207,10 +207,7 @@ validation failures), and guards against double submission.
207
207
  ## Route near misses
208
208
 
209
209
  - An accepted `.play` model under the model root covers the behavior, or the
210
- repository is opted in (the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the project set
211
- `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
212
- output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
213
- `cratis-screenplay-modeling-lifecycle`): change the model first with
210
+ repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
214
211
  `cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
215
212
  say so and do not author `.play` from memory.
216
213
  Edit code here only for infrastructure, clients, adapters, Screenplay code
@@ -28,8 +28,7 @@ syntax and tool commands in `cratis-screenplay-toolchain`.
28
28
  existing code or a database as the source (`cratis-screenplay-legacy-extraction`).
29
29
  - Small change to an existing model (one or two events): enter at step 5.
30
30
  - Model-first: work in `.play` where an accepted model under the model root covers the scope or
31
- 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
32
- `mcpServers.screenplay.root` in `.cratis/ai.json`). Otherwise stay code-first; only the
31
+ the repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`). Otherwise stay code-first; only the
33
32
  entry-point session proposes a model, at most once per session; the master definition is in
34
33
  `cratis-screenplay-modeling-lifecycle`. A direct request to model this scope is itself consent.
35
34
 
@@ -29,13 +29,7 @@ into the work that acts on them. Flag a real trade-off to the user instead of re
29
29
 
30
30
  **1. Decide the level (short form; master copy in `cratis-screenplay-modeling-lifecycle`).**
31
31
  Check first that the method skills are installed; installing them never opts a
32
- repository in. The work is **model-first** only in an opted-in repository: the model
33
- 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
34
- `mcpServers.screenplay.root` in `.cratis/ai.json`. An empty directory, install output,
35
- an installed skill, a `.play` file outside the root or an untracked or uncommitted draft is not
36
- opt-in; staged or untracked files under the root are drafts. A committed file with uncommitted
37
- working-tree edits is a model change in progress; its HEAD version is the contract until the
38
- change is committed. A behavior is a contract only when an accepted model under the root covers it.
32
+ repository in. Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` for the decision, model root and drafts.
39
33
  Otherwise stay code-first. Only the entry-point session proposes a model (at most once
40
34
  per session, never for trivial, bug-fix, infrastructure, client, framework or
41
35
  brownfield-maintenance work; unattended: record the recommendation in the final report).
@@ -101,6 +101,12 @@ An unconditional `result.ShouldNotBeAuthorized()` on a scenario's command result
101
101
 
102
102
  Requires Arc.Screenplay 22.98.0 or later for `then denied`; older releases withhold every denial specification with `SP0039`.
103
103
 
104
+ ### Literal-case tables
105
+
106
+ When body-less concrete specification classes pass literal values to the primary constructor of one abstract scenario (`class Ada() : Registering("Ada")`), the generator states the scenario once with typed `parameter` lines and one `case` row per class. It folds the rows only when substituting each row's values into the base reproduces that row's steps, outcomes and caller exactly; textual similarity is not enough. Otherwise every row is stated individually and Information `SP0076` names why.
107
+
108
+ Requires Arc.Screenplay 22.99.0 or later for case tables; older releases state every row individually.
109
+
104
110
  ## Diagnostics are the loss list
105
111
  - Families: `SP####` (Arc), `MARTEN####`, `WOLVERINE####`, `VOG####`, `GEN####`,
106
112
  `DOTNETSP####` (placement), `CLI####` (host). Each one is an evidence row or a loss-report
@@ -134,7 +134,7 @@ origin, NOT-enforced rules marked, coverage matrix filled, personas with their d
134
134
  fixed or explained before P5. The list: [quick self-check](references/quick-self-check.md).
135
135
 
136
136
  ## Business-question pass (explain brief)
137
- Be a sharp business analyst seeing the domain fresh: walk each persona's journey and ask only what a domain person must decide, in plain language with no engineering words (could a non-technical product owner read it and immediately understand what is being asked?), anchored to a place in the model, at most 12 questions (zero is valid). Method, element prompts and the model-word translation table: `references/business-questions.md`.
137
+ Be a sharp business analyst seeing the domain fresh: walk each persona's journey and ask only what a domain person must decide, in plain language with no engineering words (could a non-technical product owner read it and immediately understand what is being asked?), anchored to a place in the model, at most 12 questions (zero is valid). Method, element prompts and the model-word translation table: `references/business-questions.md`. A behavior walk in the Stage sandbox (`cratis-stage-rendering-and-sandbox`) is a separate, optional check; its findings arrive here as review findings.
138
138
 
139
139
  ## Independent review
140
140
  P5 uses a fresh reviewer who authored nothing in scope; record reviewer/author models or `model: not exposed`, label a same-model review and let the user decide sufficiency. Read lifecycle "Independent review" when arranging P5; the model-family rationale is in `references/report-template.md` ("Independent review").
@@ -18,16 +18,16 @@ an unproven pass.
18
18
 
19
19
  ## Decide the level first (master copy; run once per request, from any entry point)
20
20
 
21
- 1. **Opted in?** Only when (a) the model root (the folder holding the project's `.play` files, or the project's
22
- configured root) holds a `.play` file **in the committed tree** (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or (b)
23
- the project explicitly set `mcpServers.screenplay.root` in `.cratis/ai.json` (an empty configured
24
- root counts). **Not opt-in:** an empty model folder or the MCP entry that `cratis ai
25
- install`/`update` creates; an installed profile or skill; a `.play` file outside the root; a
26
- staged or untracked `.play` file under the root (a draft). Committing a model under the root
27
- is the team's act of acceptance and opts the repository in.
28
- A committed file with uncommitted working-tree edits is a model change in progress: its HEAD version is the contract until the change is committed.
21
+ 1. **Opted in?** A committed `.play` file under the model root or an explicitly configured
22
+ `mcpServers.screenplay.root` in `.cratis/ai.json` opts in (even an empty configured root).
23
+ The invariant is in `general.md` ("Model first").
29
24
  A behavior is a **contract** only when an accepted (committed) model under the root covers it.
30
- A direct user request to model a scope is consent for that scope. Evidence: `references/opt-in.md`. Read `references/opt-in.md` when checking opt-in evidence or model-root edge cases.
25
+ A direct user request to model a scope is consent for that scope. Run `scripts/model-first-status.mjs` from the repository with Node.js and Git:
26
+ `node <skill-directory>/scripts/model-first-status.mjs [--root <repository-relative-dir>] [--json]`.
27
+ Read-only roots: `--root`, configuration, then discovery from HEAD project paths (drafts only if none). Discovery prefers legacy `.cratis/screenplay/`, else the common folder, else `Source/`, `src/`, `Screenplay/`. It excludes hidden/build/docs/samples/examples/scratch/test fixtures from discovery and acceptance, including at `.`; explicit roots include everything beneath them.
28
+ Output: root, reason, file counts, drafts and model changes. Exits: **0 opted in**, **1 not opted in**, **2 could not run** (Git/configuration/arguments). Treat 2 as blocked, not code-first.
29
+ Run `scripts/model-first-status.mjs --self-test` to plant and check verdict fixtures; it executes `scripts/model-first-self-test.mjs` and prints the checked count on success.
30
+ Read `references/opt-in.md` when checking the project configuration mechanism.
31
31
  2. **Not opted in:** continue code-first; never force a model (framework, brownfield,
32
32
  infrastructure, client and adapter work stays code-first). Only the entry-point agent or session
33
33
  may **propose a model**: at most once per session, never for trivial, bug-fix, infrastructure,
@@ -23,40 +23,10 @@ project-owned `mcpServers` property in `.cratis/ai.json` overrides the model dir
23
23
  disables registration"; `AiConfiguration.McpServers`, read by `AiMcpDescriptor.Root`). Verify with
24
24
  `Source/Cli/Commands/Ai/AiMcpDescriptor.cs` in the CLI repository.
25
25
 
26
- ## Model root and the committed-`.play` test
27
- The model root is the folder holding the project's `.play` files; absent an existing
28
- model, use `Source/` or `src/`, else `Screenplay/` at the repository root, never
29
- under `.cratis/`. An explicitly configured `mcpServers.screenplay.root` selects
30
- the root. A committed `.play` there is rule (a)'s opt-in signal without requiring
31
- the setting; setting a root is independently rule (b), even when empty. The legacy
32
- CLI discovery behavior above is historical evidence, not a default corpus root.
33
- Do not count unrelated documentation, samples or scratch files as the project model.
34
-
35
- ## Edge cases
36
- - `.play` files only under `.ai-work/`, a docs folder or a sample: not under the root, so not opt-in.
37
- - Acceptance is visible in the repository: the model root holds at least one `.play` file in
38
- the committed tree (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured). Committing a model
39
- under the root is the team's act of acceptance and opts the repository in. P6 commits the
40
- accepted `.play` files and `.screenplay/identities.json` when present.
41
- - Staged or untracked files under the root are drafts: they do not opt the repository in and
42
- are not a contract for code agents. The modeler writes drafts into the root as before; they
43
- stay drafts until committed. A local STATE.md alone proves nothing to another clone.
44
- - A committed file with uncommitted working-tree edits is a model change in progress. Its HEAD
45
- version is the contract until the change is committed; `git diff --quiet HEAD -- <file>`
46
- detects whether the working copy differs.
47
- - An explicitly configured root (`mcpServers.screenplay.root`) that is empty still counts as
48
- opted in; rule (b) is independent of rule (a).
26
+ ## Model root and edge cases
27
+ Run `cratis-screenplay-modeling-lifecycle`'s `scripts/model-first-status.mjs` for root resolution, the opt-in verdict, drafts and model changes in progress.
49
28
  - Declined proposals: a team that wants a lasting "no model" answer writes it in its own
50
29
  repository instructions, never in managed corpus files.
51
30
 
52
31
  ## Acceptance test cases
53
- Assume no other committed `.play` file under the root and no explicit root configuration,
54
- except in the last row. A committed model is a contract only for the slice it covers.
55
-
56
- | Case under the model root | Opted in? | Contract for code agents |
57
- |---|---|---|
58
- | Untracked `.play` file | No | None; draft |
59
- | Staged-only `.play` file, absent from HEAD | No | None; draft |
60
- | Committed `.play` file | Yes | Its HEAD version |
61
- | Committed `.play` file with working-tree edits | Yes | Its HEAD version; edits are a model change in progress until committed |
62
- | Explicitly configured empty root | Yes | None yet; model the slice first |
32
+ Run `scripts/model-first-status.mjs --self-test` for the executable verdict fixtures.
@@ -111,11 +111,7 @@ phase, a decision important enough that a later reader could misread the model (
111
111
  - **Carry-forward**: the accepted **source identity** (`verdicts-and-modes.md`).
112
112
  - **Commit at P6**: the accepted `.play` files and `.screenplay/identities.json` when present.
113
113
  The user commits, or explicitly authorizes the owning session to commit; the modeler never
114
- commits on its own. Committing a model under the model root is the team's act of acceptance
115
- and opts the repository in (`git ls-tree -r --name-only HEAD -- <root>` lists the `.play`
116
- file). Staged or untracked files under the root are drafts, not contracts for code agents.
117
- A committed file with working-tree edits is a model change in progress; its HEAD version is
118
- the contract until the change is committed.
114
+ commits on its own. Run `cratis-screenplay-modeling-lifecycle`'s `scripts/model-first-status.mjs` to check acceptance, drafts and model changes in progress.
119
115
  - **Gate**: explicit acceptance and the model commit before P7-P9. After committing, recompute
120
116
  the source identity. Its digest must equal the digest reviewed at P5; only the commit part may
121
117
  differ. If the digest differs, return to P4/P5 for the changed scope. Record the post-commit
@@ -126,6 +122,7 @@ phase, a decision important enough that a later reader could misread the model (
126
122
  - **Input**: the accepted identity.
127
123
  - **Carry-forward**: V3, and V4 where a route exists.
128
124
  - **Gate**: V3 ready; V4 result or "V4 not run: no route". Specs written or bound is never "specs pass".
125
+ - **Optional after V3**: a behavior walk in the Stage sandbox (`cratis-stage-rendering-and-sandbox`); findings go to the model owner, and it is not V3, V4 or V5 evidence.
129
126
  - **Skip when**: design mode.
130
127
 
131
128
  ## P8 Render or fall back (`cratis-screenplay-render-and-gap-fill`)
@@ -0,0 +1,104 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import assert from 'node:assert/strict';
5
+ import { spawnSync } from 'node:child_process';
6
+ import { mkdirSync, mkdtempSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';
7
+ import { tmpdir } from 'node:os';
8
+ import { dirname, join, resolve } from 'node:path';
9
+ import { fileURLToPath } from 'node:url';
10
+ export function selfTest(modelFirstStatus) {
11
+ const temporary = mkdtempSync(join(tmpdir(), 'model-first-self-test-'));
12
+ let cases = 0;
13
+ const write = (path, content) => {
14
+ mkdirSync(dirname(path), { recursive: true });
15
+ writeFileSync(path, content);
16
+ };
17
+ const git = (repository, args) => {
18
+ const result = spawnSync('git', ['-c', 'user.name=Model first self-test', '-c', 'user.email=specs@example.invalid',
19
+ '-c', 'commit.gpgsign=false', '-c', 'core.hooksPath=/dev/null', ...args], { cwd: repository, encoding: 'utf8', timeout: 10000 });
20
+ assert.equal(result.status, 0, result.stderr || result.error?.message);
21
+ };
22
+ const repo = name => {
23
+ const repository = join(temporary, name);
24
+ mkdirSync(repository);
25
+ git(repository, ['init', '--quiet']);
26
+ return repository;
27
+ };
28
+ const check = (repository, expected, root) => {
29
+ const report = modelFirstStatus(repository, root);
30
+ assert.equal(report.optedIn, expected);
31
+ cases++;
32
+ return report;
33
+ };
34
+ try {
35
+ const drafts = repo('drafts');
36
+ check(drafts, false);
37
+ write(join(drafts, 'Screenplay/model.play'), 'module Test\n');
38
+ assert.equal(check(drafts, false).drafts.untracked.length, 1);
39
+ git(drafts, ['add', 'Screenplay/model.play']);
40
+ assert.equal(check(drafts, false).drafts.staged.length, 1);
41
+ git(drafts, ['commit', '--quiet', '-m', 'Accept model']);
42
+ assert.equal(check(drafts, true).contract, 'HEAD');
43
+ write(join(drafts, 'Screenplay/model.play'), 'module Changed\n');
44
+ assert.equal(check(drafts, true).modelChangesInProgress.length, 1);
45
+ const configured = repo('configured');
46
+ write(join(configured, '.cratis/ai.json'), JSON.stringify({ mcpServers: { screenplay: { root: 'Models' } } }));
47
+ check(configured, true, 'Models');
48
+ write(join(configured, 'Models/model.play'), 'module Test\n');
49
+ assert.equal(check(configured, true, 'Models').committed.length, 0);
50
+ const outside = repo('outside');
51
+ write(join(outside, 'docs/example.play'), 'module Example\n');
52
+ git(outside, ['add', '.']);
53
+ git(outside, ['commit', '--quiet', '-m', 'Add example']);
54
+ check(outside, false);
55
+ assert.throws(() => modelFirstStatus(temporary), /git rev-parse/);
56
+ cases++;
57
+ write(join(configured, '.cratis/ai.json'), '{');
58
+ assert.throws(() => modelFirstStatus(configured));
59
+ cases++;
60
+ for (const [name, path] of [
61
+ ['fixture', 'Source/X.Specs/Projections/for_model/Cases/fixture.play'],
62
+ ['example', 'Source/examples/example.play'],
63
+ ['docs', 'src/docs/example.play'],
64
+ ]) {
65
+ const repository = repo(name);
66
+ write(join(repository, path), 'module Example\n');
67
+ git(repository, ['add', '.']);
68
+ git(repository, ['commit', '--quiet', '-m', 'Add non-project model']);
69
+ assert.equal(check(repository, false, undefined).modelFilesExamined, 0);
70
+ }
71
+ const project = repo('project');
72
+ write(join(project, 'Source/model.play'), 'module Test\n');
73
+ git(project, ['add', '.']);
74
+ git(project, ['commit', '--quiet', '-m', 'Accept project model']);
75
+ assert.equal(check(project, true, undefined).modelRoot, 'Source');
76
+ write(join(project, '.cratis/screenplay/draft.play'), 'module Draft\n');
77
+ assert.equal(check(project, true, undefined).modelRoot, 'Source');
78
+ git(project, ['add', '.cratis/screenplay/draft.play']);
79
+ assert.equal(check(project, true, undefined).modelRoot, 'Source');
80
+ const broad = repo('broad');
81
+ for (const path of ['Source/model.play', 'Other/model.play', 'Source/samples/example.play']) {
82
+ write(join(broad, path), 'module Test\n');
83
+ }
84
+ git(broad, ['add', '.']);
85
+ git(broad, ['commit', '--quiet', '-m', 'Add project and sample models']);
86
+ const broadReport = check(broad, true, undefined);
87
+ assert.equal(broadReport.modelRoot, '.');
88
+ assert.equal(broadReport.committed.length, 2);
89
+ write(join(broad, '.cratis/ai.json'), JSON.stringify({ mcpServers: { screenplay: { root: '.' } } }));
90
+ assert.equal(check(broad, true, undefined).committed.length, 3);
91
+ const aliasRepository = repo('alias');
92
+ const alias = join(aliasRepository, 'skills');
93
+ symlinkSync(resolve(dirname(fileURLToPath(import.meta.url)), '../..'), alias, 'dir');
94
+ const result = spawnSync(process.execPath, [join(alias, 'cratis-screenplay-modeling-lifecycle/scripts/model-first-status.mjs'), '--json'], {
95
+ cwd: aliasRepository, encoding: 'utf8', timeout: 20000,
96
+ });
97
+ assert.equal(result.status, 1, result.stderr);
98
+ assert.equal(JSON.parse(result.stdout).optedIn, false);
99
+ cases++;
100
+ console.log(`model-first-status self-test: checked ${cases} fixtures/verdicts; passed`);
101
+ } finally {
102
+ rmSync(temporary, { recursive: true, force: true });
103
+ }
104
+ }
@@ -0,0 +1,141 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { spawnSync } from 'node:child_process';
5
+ import { readFileSync, realpathSync, statSync } from 'node:fs';
6
+ import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
7
+ import { fileURLToPath } from 'node:url';
8
+
9
+ function git(repository, args, allowed = [0]) {
10
+ const result = spawnSync('git', args, { cwd: repository, encoding: 'utf8', timeout: 10000, maxBuffer: 16 * 1024 * 1024 });
11
+ if (result.error || !allowed.includes(result.status)) {
12
+ throw new Error(`git ${args[0]}: ${result.error?.message ?? result.stderr.trim() ?? result.status}`);
13
+ }
14
+ return result;
15
+ }
16
+
17
+ const names = result => result.stdout.split('\0').filter(Boolean);
18
+ const play = path => path.toLowerCase().endsWith('.play');
19
+ const under = (path, root) => root === '.' || path.startsWith(`${root}/`);
20
+ const ignored = /(^|\/)(\.[^/]+|node_modules|bin|obj|build|artifacts|dist|out|packages|documentation|docs|samples?|examples?|scratch|[^/]+\.(?:Specs|Tests)|Specs|Tests|for_[^/]+|fixtures|Cases|test[-_]?assets)(\/|$)/i;
21
+ // The legacy model location is a project root, not arbitrary hidden-folder content.
22
+ const projectModel = path => !ignored.test(path.startsWith('.cratis/screenplay/') ? path.slice('.cratis/screenplay/'.length) : path);
23
+
24
+ function configuredRoot(repository) {
25
+ let text;
26
+ try {
27
+ text = readFileSync(join(repository, '.cratis/ai.json'), 'utf8');
28
+ } catch (error) {
29
+ if (error.code === 'ENOENT') return undefined;
30
+ throw error;
31
+ }
32
+ const config = JSON.parse(text);
33
+ if (!config || typeof config !== 'object' || Array.isArray(config)) throw new Error('.cratis/ai.json must be an object');
34
+ const root = config.mcpServers?.screenplay?.root;
35
+ if (root === undefined || root === null) return undefined;
36
+ if (typeof root !== 'string' || !root.trim()) throw new Error('mcpServers.screenplay.root must be a nonempty directory path');
37
+ return root;
38
+ }
39
+
40
+ function normalizeRoot(repository, root) {
41
+ if (typeof root !== 'string' || !root.trim()) throw new Error('--root requires a nonempty directory path');
42
+ if (isAbsolute(root)) throw new Error('Model root must be repository-relative');
43
+ const path = relative(repository, resolve(repository, root)).replaceAll('\\', '/');
44
+ if (path === '..' || path.startsWith('../')) throw new Error('Model root must stay inside the repository');
45
+ try {
46
+ if (!statSync(join(repository, path)).isDirectory()) throw new Error(`Model root is not a directory: ${root}`);
47
+ } catch (error) {
48
+ if (error.code !== 'ENOENT') throw error;
49
+ }
50
+ return path || '.';
51
+ }
52
+
53
+ function locateRoot(repository, paths) {
54
+ if (paths.some(path => path.startsWith('.cratis/screenplay/'))) return '.cratis/screenplay';
55
+ const directories = paths.map(path => dirname(path));
56
+ if (directories.length) {
57
+ let common = directories[0].split('/');
58
+ for (const directory of directories.slice(1)) {
59
+ const parts = directory.split('/');
60
+ const mismatch = common.findIndex((part, index) => part !== parts[index]);
61
+ if (mismatch >= 0) common = common.slice(0, mismatch);
62
+ }
63
+ return common.join('/') || '.';
64
+ }
65
+ for (const folder of ['Source', 'src']) {
66
+ try {
67
+ if (statSync(join(repository, folder)).isDirectory()) return folder;
68
+ } catch (error) {
69
+ if (error.code !== 'ENOENT') throw error;
70
+ }
71
+ }
72
+ return 'Screenplay';
73
+ }
74
+
75
+ /** Inspect HEAD and drafts without writing, staging or accepting a model. */
76
+ export function modelFirstStatus(cwd = process.cwd(), rootOverride) {
77
+ const repository = git(cwd, ['rev-parse', '--show-toplevel']).stdout.trim();
78
+ const configured = configuredRoot(repository);
79
+ const head = git(repository, ['rev-parse', '--verify', '--quiet', 'HEAD'], [0, 1]);
80
+ const committed = head.status === 0
81
+ ? names(git(repository, ['ls-tree', '-r', '--name-only', '-z', 'HEAD'])).filter(play) : [];
82
+ const indexed = names(git(repository, ['ls-files', '-z', '--cached'])).filter(play);
83
+ const untracked = names(git(repository, ['ls-files', '-z', '--others', '--exclude-standard'])).filter(play);
84
+ const paths = [...new Set([...committed, ...indexed, ...untracked])].sort();
85
+ const projectCommitted = committed.filter(projectModel);
86
+ const discoveryPaths = projectCommitted.length ? projectCommitted : paths.filter(projectModel);
87
+ const root = normalizeRoot(repository, rootOverride ?? configured ?? locateRoot(repository, discoveryPaths));
88
+ const inModel = path => under(path, root) && (rootOverride !== undefined || configured !== undefined || projectModel(path));
89
+ const accepted = committed.filter(inModel).sort();
90
+ const staged = indexed.filter(path => inModel(path) && !committed.includes(path)).sort();
91
+ const drafts = { untracked: untracked.filter(inModel).sort(), staged };
92
+ const modified = head.status === 0
93
+ ? names(git(repository, ['diff', '--name-only', '-z', 'HEAD', '--'])).filter(path => accepted.includes(path)).sort() : [];
94
+ const optedIn = configured !== undefined || accepted.length > 0;
95
+ return {
96
+ optedIn,
97
+ reason: configured !== undefined ? 'configured-root' : accepted.length ? 'committed-model' : 'no-accepted-model',
98
+ repository, modelRoot: root,
99
+ rootSource: rootOverride !== undefined ? 'argument' : configured !== undefined ? 'configuration' : 'discovery',
100
+ filesExamined: paths.length, modelFilesExamined: paths.filter(inModel).length,
101
+ committed: accepted, drafts, modelChangesInProgress: modified,
102
+ contract: accepted.length ? 'HEAD' : null,
103
+ };
104
+ }
105
+
106
+ function argumentsFor(args) {
107
+ const options = {};
108
+ for (let index = 0; index < args.length; index++) {
109
+ if (args[index] === '--json') options.json = true;
110
+ else if (args[index] === '--self-test') options.selfTest = true;
111
+ else if (args[index] === '--root' && args[index + 1] && !args[index + 1].startsWith('--')) options.root = args[++index];
112
+ else throw new Error('Usage: node model-first-status.mjs [--root <dir>] [--json] | --self-test');
113
+ }
114
+ return options;
115
+ }
116
+
117
+ async function main() {
118
+ let options;
119
+ try {
120
+ options = argumentsFor(process.argv.slice(2));
121
+ if (options.selfTest) {
122
+ const { selfTest } = await import('./model-first-self-test.mjs');
123
+ selfTest(modelFirstStatus);
124
+ return;
125
+ }
126
+ const report = modelFirstStatus(process.cwd(), options.root);
127
+ console.log(options.json ? JSON.stringify(report) : [
128
+ `Model first: ${report.optedIn ? 'opted in' : 'not opted in'} (${report.reason}); root=${report.modelRoot}`,
129
+ `Examined ${report.filesExamined} .play files; ${report.modelFilesExamined} under the root; ${report.committed.length} committed`,
130
+ `Drafts: ${report.drafts.untracked.length} untracked, ${report.drafts.staged.length} staged; ${report.modelChangesInProgress.length} model changes in progress; contract=${report.contract ?? 'none'}`,
131
+ ].join('\n'));
132
+ process.exitCode = report.optedIn ? 0 : 1;
133
+ } catch (error) {
134
+ const message = error instanceof Error ? error.message : String(error);
135
+ if (options?.json || process.argv.includes('--json')) console.log(JSON.stringify({ error: message }));
136
+ console.error(`model-first-status: could not run: ${message}`);
137
+ process.exitCode = 2;
138
+ }
139
+ }
140
+
141
+ if (process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))) await main();
@@ -17,7 +17,7 @@ skill answers "does it compile, bind, render, and which compiler said so". The m
17
17
 
18
18
  ## Locate the model
19
19
 
20
- Look first in the model root: the folder holding the project's `.play` files (else `Source/` or `src/`, else `Screenplay/`), or the root the project set with `mcpServers.screenplay.root` in `.cratis/ai.json`. A folder of `.play`
20
+ Decide opt-in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs` to locate the model root. A folder of `.play`
21
21
  files is one application: always check the folder, never one file of it.
22
22
 
23
23
  ## Tool versions and the contract
@@ -61,6 +61,8 @@ work on a screen whose purpose is unsettled is rework.
61
61
  a board; that is optional, and the text review is enough. Do not
62
62
  use the Stage sandbox as the review: it renders only part of a screen, and
63
63
  nothing here establishes that Stage renders an authored screen faithfully.
64
+ A behavior walk of what commands change is a separate, optional check owned by
65
+ `cratis-stage-rendering-and-sandbox`.
64
66
  3. **Add structure only to screens whose Level 1 is agreed**: template, sections,
65
67
  forms, `on`/`uses`. Use Level 3 inline code last, only where Level 2 cannot
66
68
  say it.
@@ -61,9 +61,7 @@ the documentation it produces.
61
61
  model). Decide this with the decision rule in
62
62
  `cratis-screenplay-modeling-lifecycle`: model-first only when an accepted
63
63
  model under the model root covers this scope, or the repository is opted in
64
- (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 `mcpServers.screenplay.root`
65
- in `.cratis/ai.json`); an empty directory, install output, a `.play` file
66
- outside the root or an uncommitted draft does not count, and framework, infrastructure, client, adapter and not-opted-in
64
+ (opted in per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`); framework, infrastructure, client, adapter and not-opted-in
67
65
  brownfield work stays code-first. Opted in but no model for this scope: model
68
66
  it first (`cratis-screenplay-discovery`, then `cratis-screenplay-slice-design`)
69
67
  before writing specifications. If those Screenplay skills are not installed,
@@ -54,10 +54,7 @@ another version. Never translate an assertion or helper name from memory.
54
54
  plain `Specification` base in this file and do not reach for the scenario
55
55
  family except to test the very engine that repository provides.
56
56
  - An accepted `.play` model under the model root covers the behavior, or the
57
- repository is opted in (the root holds a committed `.play` file (`git ls-tree -r --name-only HEAD` lists a `.play` file there, narrowed to `-- <root>` when a root is configured), or the project set
58
- `mcpServers.screenplay.root` in `.cratis/ai.json`; an empty directory, install
59
- output, an uncommitted `.play` draft or a `.play` file outside the root does not count; master definition:
60
- `cratis-screenplay-modeling-lifecycle`): change the model first with
57
+ repository is opted in (per `general.md` "Model first"; where `cratis-screenplay-modeling-lifecycle` is installed, run its `scripts/model-first-status.mjs`): change the model first with
61
58
  `cratis-screenplay-event-modeling`. If the Screenplay skills are not installed,
62
59
  say so and do not author `.play` from memory.
63
60
  Edit code here only for infrastructure, clients, adapters, Screenplay code
@@ -22,11 +22,10 @@ Requires cratis CLI ≥ 3.57 (`cratis --version`) to render ESM v14 and v15 mode
22
22
  - Deciding whether a model can be rendered, or reading a blocked render.
23
23
  - Re-rendering safely after the model or a managed file changed.
24
24
  - Checking what the generated UI does and does not prove.
25
- - Running the sandbox or the specification runner.
25
+ - Running the sandbox or the specification runner, or a behavior walk.
26
26
 
27
- Not for authoring the model (`cratis-screenplay-model-authoring`), the end-to-end
28
- render and gap-fill workflow (`cratis-screenplay-render-and-gap-fill`), or the C# of a
29
- generated command or read model (`cratis-arc-command`, `cratis-chronicle-read-model`).
27
+ Not for authoring the model (`cratis-screenplay-model-authoring`), the render and gap-fill
28
+ workflow (`cratis-screenplay-render-and-gap-fill`), or generated C# (`cratis-arc-command`, `cratis-chronicle-read-model`).
30
29
 
31
30
  ## Model-first rule
32
31
 
@@ -60,8 +59,8 @@ cratis render --workspace ./application.workspace.json --destination ./out
60
59
  | `--package-set <FILE>` | Approved package set (JSON) of custom runtime packages the `ui profile` may use; the frontend installs exactly these |
61
60
  | `--force` | See "Publication and recovery" |
62
61
 
63
- Order of events: recover any interrupted earlier publication, compile, bind, build the
64
- execution plan, plan the target (Stage admission), validate artifacts, then publish.
62
+ Order: recover any interrupted publication, compile, bind, build the plan, plan the target
63
+ (Stage admission), validate artifacts, then publish.
65
64
  Exit `0` is a published render, `5` is a refusal with nothing published (diagnostics are
66
65
  printed), `1` is a missing input. Add `-o json` for the counts and the publication receipt.
67
66
 
@@ -104,8 +103,7 @@ backups). Never stage `.cratis-render/` in git; commit the manifest with the out
104
103
  - Recovery runs before planning, even when planning then fails. **`recovered: true` in the
105
104
  result means stop and reconcile**: the receipt does not describe what recovery changed.
106
105
  - An unchanged re-render writes nothing (`unchanged` equals the artifact count).
107
- - Use exclusive access to the destination; a receipt is a filesystem result, not a Git
108
- commit, and the command creates no branch, commit or PR.
106
+ - Use exclusive access to the destination; a receipt is a filesystem result, not a Git commit, and the command creates no branch, commit or PR.
109
107
  - Drift: `cratis render ... --check` is the first probe; exit `6` means pending changes.
110
108
  Otherwise compare successive manifests' `semanticRevision` for renders with the same
111
109
  `--name` and inputs. Do not compare the MCP `modelRevision` with the manifest: their
@@ -204,12 +202,18 @@ Specification runner exit codes: `0` means the run completed and the results fil
204
202
  written **even when a specification failed**, so read the outcomes; `1` is a missing or
205
203
  uncompilable input; `2` a missing required argument or an invalid semantic option.
206
204
 
205
+ ## Behavior walk (optional, after V3)
206
+
207
+ Walk each persona's commands and screens in the sandbox's semantic engine and record what
208
+ changes, when a domain expert should check the model by using it. It yields findings for
209
+ the model owner only, changes nothing, is not UI review and is not V4 or V5 evidence.
210
+ Prerequisites, the walk, finding kinds, limits and hand-off:
211
+ Read [references/behavior-walk.md](references/behavior-walk.md) when planning or running it.
212
+
207
213
  ## Legacy direct-write rendering
208
214
 
209
- The syntax-based `IRenderer` and the optional `Cratis.Stage.Rendering.Cratis.Scaffolding`
210
- package write directly to disk, with no managed staging and no safe stale-file removal; a
211
- failure can leave the target unsafe and incomplete. Use `cratis render` (journaled,
212
- recoverable publication) instead.
215
+ The syntax-based `IRenderer` and `Cratis.Stage.Rendering.Cratis.Scaffolding` write directly
216
+ to disk with no managed staging and no safe stale-file removal; a failure can leave the target unsafe and incomplete. Use `cratis render`.
213
217
 
214
218
  ## Verify
215
219
 
@@ -224,8 +228,7 @@ recoverable publication) instead.
224
228
  file. The fix is an intent-preserving model change or a recorded gap, never an edit of
225
229
  managed output and never a weakened model.
226
230
  - No file under `.cratis-render/` is staged; managed files carry no local edits.
227
- - Stage's plan is deterministic (same input, same bytes and hashes); that is not a review,
228
- and Stage never reviews, stages or approves anything.
231
+ - Stage's plan is deterministic (same bytes and hashes); that is not a review, and Stage never reviews, stages or approves anything.
229
232
  - Sandbox expectations account for unenforced validation, authorization and query
230
233
  authorization on the default engine.
231
234
  - Runtime screen smoke coverage uses the same model root or workspace export as
@@ -0,0 +1,77 @@
1
+ # Behavior walk in the sandbox
2
+
3
+ An optional check after V3: use the model as each persona would and record what changes.
4
+ It produces **findings for the model owner and changes nothing**: no code fix, no model
5
+ edit, no Stage-managed edit by the walker. It is not a UI-faithfulness review
6
+ (`cratis-screenplay-ui-composition`), and it is not V3, V4 or
7
+ V5 evidence.
8
+
9
+ ## Prerequisites
10
+
11
+ - V3 passed, and `cratis render` admits the model (a model Stage refuses cannot be walked
12
+ as the application it describes).
13
+ - Docker, and the `cratis/stage` image at the tag `cratis run` would use (by default the
14
+ Stage version the CLI renders with).
15
+ - The **semantic engine**. `cratis run` has no `--engine` option and passes no environment
16
+ to the container, so it starts the default EventModel engine, which enforces no
17
+ validation or authorization and refuses routed models. Start the same image directly:
18
+
19
+ ```bash
20
+ docker run --rm -p 127.0.0.1:9090:9090 -p 127.0.0.1:35000:35000 \
21
+ -e Stage__Runtime__Engine=semantic \
22
+ -v "$PWD/model":/eventmodel:ro cratis/stage:<tag>
23
+ ```
24
+
25
+ Wait until `GET /stage/status` reports `ready` and `engine: "semantic"`. `unsupported`
26
+ means the engine cannot execute the model and `/api/**` answers 501: stop, and record the
27
+ issues from `GET /stage/semantic/admission`; nothing was walked. `GET /stage/routes` lists
28
+ the command and query routes, and `/scalar/v1` is the API reference.
29
+
30
+ ## The walk
31
+
32
+ For each persona, list the commands and screens that persona can reach (from the model's
33
+ `authorize`, `persona` and `screen` declarations), then for each one:
34
+
35
+ 1. Note the state first: the persona's queries before acting.
36
+ 2. Act: call the command as that persona with realistic input. Callers are built from the
37
+ unsigned `x-ms-client-principal` header, so set the persona's roles and claims there.
38
+ 3. Look at what changed: the HTTP outcome (accepted; `403` denied; `400` validation or
39
+ constraint; `501` unsupported), the persona's queries again, and the queries of the
40
+ other personas the change should reach.
41
+ 4. Repeat the action, then try the obvious refusals a person would expect (an empty value,
42
+ a repeat, the wrong persona, a step out of order).
43
+
44
+ Read models on the semantic engine live in the process and the history is unbounded, so
45
+ keep a session short and restart it for a clean state.
46
+
47
+ ## Finding kinds
48
+
49
+ | Finding | Evidence to record |
50
+ | --- | --- |
51
+ | An action that changes nothing visible | Persona, command, input, outcome, and the queries before and after that stayed identical |
52
+ | A screen whose data stays empty because nothing feeds it | Screen, its read model and query, the events that should fill it, and that no walked command produces them |
53
+ | A pending-work or to-do view that never empties | The view, the item added, the action expected to clear it, and the unchanged view afterward |
54
+ | A refusal the person expected but the model lacks | The action tried, the accepted outcome, and the rule the person expected |
55
+ | An action the persona can take but should not, or cannot take but should | Persona, command, outcome, and the `authorize` line involved |
56
+ | A command or query the engine cannot execute | The `501` or admission entry with its reported reason |
57
+
58
+ Every finding names the persona, the steps in order, the observed outcome (status and
59
+ payload) and the model declaration it points at. Keep observations apart from opinions.
60
+
61
+ ## What the walk cannot show
62
+
63
+ - A partial UI: the sandbox renders only part of a screen, so it says nothing about whether
64
+ an authored screen, template or form is rendered faithfully.
65
+ - Production authorization: callers come from forgeable headers, so a pass is not a
66
+ security result. Authorization on rendered applications is checked by their Debug tests.
67
+ - Anything the engine refuses: an unsupported model is not walked, and artifacts listed as
68
+ unsupported are blind spots, not passes.
69
+ - Chronicle projections in the Workbench: the semantic engine's read models are in-process.
70
+ - Rendered behavior: it is not a build, not Debug tests and not the specification runner.
71
+
72
+ ## Hand-off
73
+
74
+ Give the findings to the model owner. A finding becomes an edit request
75
+ (`cratis-screenplay-model-authoring`) or a review finding (`cratis-screenplay-model-review`),
76
+ followed by the usual verdicts. Never turn a finding into a code fix, a change to
77
+ Stage-managed output or a weakened model, and never report the walk as an acceptance.