@cratis/pi 7.150.2 → 7.151.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 (24) hide show
  1. package/package/corpus/agents/backend-developer.md +2 -2
  2. package/package/corpus/agents/slice-implementer.md +1 -1
  3. package/package/corpus/harnesses/copilot/instructions/application-profile.instructions.md +1 -1
  4. package/package/corpus/harnesses/copilot/instructions/code-quality.instructions.md +4 -0
  5. package/package/corpus/harnesses/copilot/instructions/csharp.instructions.md +1 -1
  6. package/package/corpus/harnesses/copilot/instructions/documentation.instructions.md +1 -1
  7. package/package/corpus/harnesses/copilot/instructions/local-work-artifacts.instructions.md +14 -14
  8. package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +1 -1
  9. package/package/corpus/harnesses/pi/agents/backend-developer.md +2 -2
  10. package/package/corpus/harnesses/pi/agents/slice-implementer.md +1 -1
  11. package/package/corpus/hooks/README.md +1 -1
  12. package/package/corpus/hooks/scripts/cratis-guard-secrets.sh +76 -8
  13. package/package/corpus/rules/application-profile.md +1 -1
  14. package/package/corpus/rules/code-quality.md +4 -0
  15. package/package/corpus/rules/csharp.md +1 -1
  16. package/package/corpus/rules/documentation.md +1 -1
  17. package/package/corpus/rules/general.md +6 -8
  18. package/package/corpus/rules/local-work-artifacts.md +14 -14
  19. package/package/corpus/rules/vertical-slices.md +1 -1
  20. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/SKILL.md +7 -0
  21. package/package/corpus/skills/cratis-chronicle-event-type-migration/SKILL.md +11 -3
  22. package/package/corpus/skills/cratis-screenplay-toolchain/references/renderable-subset.md +1 -1
  23. package/package/corpus/skills/cratis-stage-rendering-and-sandbox/references/admission.md +1 -1
  24. package/package.json +1 -1
@@ -97,7 +97,7 @@ public record RegisterProject(ProjectName Name)
97
97
 
98
98
  ## Events — critical rules
99
99
 
100
- - Record decorated with `[EventType]` (from `Cratis.Chronicle.Events`) with **no arguments** for new events — the type name is the identifier.
100
+ - Record decorated with `[EventType]` (from `Cratis.Chronicle.Events`) plain for new events — the type name is the identifier; an explicit id only to retain an already-persisted id or resolve a cross-package short-name collision, never to change a persisted id.
101
101
  - Past-tense, one purpose, never nullable, never carries the event-source id. Add an XML `<summary>`.
102
102
 
103
103
  ```csharp
@@ -128,7 +128,7 @@ Before handing back:
128
128
  - [ ] Namespace mirrors the folder path under the source root
129
129
  - [ ] File header present; no separate handler classes
130
130
  - [ ] Business rejection returns a `ValidationResult`/`Result<,>` — never thrown
131
- - [ ] `[EventType]` has no arguments; events carry no event-source id and no nullable properties
131
+ - [ ] New events use plain `[EventType]` (explicit id only to retain a persisted id or resolve a cross-package collision); events carry no event-source id and no nullable properties
132
132
  - [ ] No `.AutoMap()` call anywhere (it is on by default)
133
133
 
134
134
  ---
@@ -94,7 +94,7 @@ Proxies now exist. Build React components from the generated proxies (`react.md`
94
94
  - All backend artifacts in one `<Slice>.cs`; namespace mirrors the path; layout per `general.md` (no `Features/` wrapper; `<Module>` optional).
95
95
  - `Handle()` returns the event/result directly (no `Task.FromResult` without `await`); validation in `CommandValidator<T>`/`ConceptValidator<T>`/`Provide()`; **never throw for normal business rejection** — return `ValidationResult`/`Result<,>`.
96
96
  - Start with model-bound attributes, fluent for structured mappings, reducer code for clearer prior-state branches/calculations/guards; **never `.AutoMap()`**. New .NET reducers default to static `Reduce` on the model; separate `IReducerFor<T>` for DI/replay instance behavior/separation; plain-class nomination only when its assembly cannot reference Chronicle. Follow the read-model/reducer skills for Arc query discovery, exact signatures and builder ownership. Preserve admission/ordering guards when converting; do not infer Stage renders the self form or apply it to other SDKs.
97
- - Events: no arguments on `[EventType]`, non-nullable, past tense, `<summary>`, never carry the event-source id.
97
+ - Events: plain `[EventType]` for new events (explicit id only to retain a persisted id or resolve a cross-package short-name collision; never change a persisted id), non-nullable, past tense, `<summary>`, never carry the event-source id.
98
98
  - `[OnceOnly]` on non-idempotent reactor side effects; reactors return side-effect events or use `ICommandPipeline` (never `IEventLog`).
99
99
  - Specs compiled into the application assembly use `#if DEBUG`; dedicated spec projects need no wrapper. Command aliased, per-test unique values.
100
100
  - Never hand-edit Stage-managed (rendered) output, and never leave a modeled rule living only in code.
@@ -51,7 +51,7 @@ Tagged **[contract]** (framework-enforced) or **[convention]** (house default).
51
51
  4. **[contract] Events never carry the event-source id** — it is implicit in the event context.
52
52
  5. **[contract] `[Key]` / `[Subject]` are distinct.** `[Key]` is for event-source/read-model/projection key resolution; `[Subject]` is compliance identity only. Don't put either on an `EventSourceId<T>` value (it already is both); use them only for non-`EventSourceId<T>` values.
53
53
  6. **[contract] Avoid nullable event properties** — Chronicle's analyzer warns on them. Model optional facts as a separate event; resolve nullable command inputs to a non-null sentinel before constructing the event. **Likewise `Handle()` never returns a nullable event or `null` for "nothing to do"** — Arc treats a `null` result as success with nothing appended, so the caller is told a command succeeded that never happened. Missing state or a failed rule is a rejection: return `Result<TEvent, ValidationResult>` with `ValidationResult.Error(...)`, or reject in a validator or `Provide()`. Optional `ICommandOperation` returns are a separate contract and unaffected.
54
- 7. **[contract] `[EventType]` takes no arguments for new events** — the type name is the identifier. Use `generation:`/id only when evolving an existing contract; schema changes get a new generation + an `EventTypeMigration<TUpgrade,TPrevious>` (never edit stored-event semantics silently). An enum that only gains a member, or has one renamed, is the exception — Chronicle accepts that in place; a *removed* or *renumbered* member still needs a generation, plus a value map saying what the old values became.
54
+ 7. **[convention] New events use plain `[EventType]`** — the type name is the id, public contracts included; "public" never implies a UUID or any explicit id. This is a house convention (decision 152), not a Chronicle contract: Chronicle accepts any string id. An explicit id is allowed only (a) to keep an already-persisted id after a CLR rename, or (b) to resolve a cross-package short-name collision (`MultipleEventTypesWithSameIdFound`). Never change an existing persisted id. Schema changes get a new generation + an `EventTypeMigration<TUpgrade,TPrevious>` (never edit stored-event semantics silently). An enum that only gains a member, or has one renamed, is the exception — Chronicle accepts that in place; a *removed* or *renumbered* member still needs a generation, plus a value map saying what the old values became.
55
55
  8. **[convention] Every `[EventType]` has an XML `<summary>`** — a Cratis C# documentation convention (not a Chronicle rule); events live in the log forever, so record why they exist.
56
56
  9. **[convention] `[ReadModel]` properties carry no default values** except semantically meaningful enum initial states and `[SetValue<T>]`-driven `bool` flags. False defaults hide missing projection wiring.
57
57
  10. **[contract] AutoMap is on by default — never call `.AutoMap()`.** Match property names so AutoMap wires them; diverge with `[SetFrom<T>]` / fluent `.Set().To()` only for genuine name differences. Re-enable `.AutoMap()` only inside a scope where it was disabled with `.NoAutoMap()`.
@@ -29,6 +29,10 @@ Prefer composing behavior from smaller, focused collaborators over building clas
29
29
  - Never extend a concrete class to add or change behavior — inject a collaborator instead.
30
30
  - Inheritance is acceptable only for framework integration points where a base class is part of a well-defined extension mechanism.
31
31
 
32
+ ## Comments carry no issue or spec references
33
+
34
+ Code comments never cite issue numbers, PR numbers or spec sections; that context belongs in the commit message and pull request. A comment says why code is non-obvious.
35
+
32
36
  ## Single Responsibility Principle
33
37
 
34
38
  Every type and every method should have **one reason to change** — it should do one thing and do it well. A class that fetches data, transforms it, validates it, and sends an email has four reasons to change. When any of those concerns shifts, you have to touch — and risk breaking — all the others.
@@ -332,7 +332,7 @@ These are the building blocks. Each type has a specific role in the vertical sli
332
332
  | --- | --- |
333
333
  | `ConceptAs<T>` | Strongly-typed domain *value* wrapper (see [concepts.md](./concepts.instructions.md)) |
334
334
  | `EventSourceId<T>` | Strongly-typed *identity* base — derive event-source ids from this, not `ConceptAs<T>` |
335
- | `[EventType]` | Marks a record as a Chronicle event — **never** pass arguments for a new event |
335
+ | `[EventType]` | Marks a record as a Chronicle event — plain for a new event (explicit id only per application-profile.md item 7) |
336
336
  | `[Command]` | Marks a record as a model-bound command — define `Handle()` directly on the record |
337
337
  | `[ReadModel]` | Marks a record as a model-bound query — define static query methods on the record |
338
338
  | `CommandValidator<T>` | FluentValidation validator for commands |
@@ -85,7 +85,7 @@ The project's voice is **direct, practical, and opinionated**. Write like an exp
85
85
  ## Code examples
86
86
 
87
87
  - Prefer `record` types for events, commands, and read models — match the codebase.
88
- - Use argument-free `[EventType]` for new events. A new generation or an explicit legacy identifier is valid only when documenting evolution of an existing stored-event contract.
88
+ - Use plain `[EventType]` for new events. A new generation or an explicit id is valid only when documenting evolution of an existing stored-event contract (a retained persisted id) or a cross-package short-name collision.
89
89
  - A standalone example must be **complete and correct** at its stated scope. Mark a partial excerpt as an excerpt, state its prerequisites, and never leave an essential step behind `// ...`. Do not offer an incomplete block as click-to-copy code.
90
90
  - **State version requirements, not the test log.** Name minimum, fixed or breaking releases and meaningful compatibility or peer ranges. Ordinary installation follows the supported latest-release path, not universal exact-patch pins; latest does not imply every package combination is compatible. Keep resolved versions in maintained manifests/lockfiles, or pin deliberately reproducible tutorials when needed. Preserve required security/deployment constraints and production image policy. Do not end a page with verification provenance (SDK build, image digest or SHA, date, "tested with", unrun samples); that belongs in the change summary. See **cratis-technical-examples**.
91
91
  - **Short illustrative snippets** may be purpose-built after checking their framework APIs against source. Derive substantial or runnable examples from compiled, tested sample or spec code; extract or check displayed snippets with the owning repository's tooling so they do not drift. Never substitute a bare “see the repository” link for showing the code.
@@ -38,21 +38,21 @@ dumps, and similar coordination files. These are **work records, not documentati
38
38
  replace the prompt.
39
39
  - **A worktree is a work record too.** Create it outside the repository tree, for
40
40
  example in a sibling `../.worktrees/` directory. A nested worktree inherits the
41
- parent's `.globalconfig`, causing .NET's `MultipleGlobalAnalyzerKeys`
42
- errors or silently changing analyzer severities. **Delivered work is cleaned up by
41
+ parent's `.globalconfig`, causing .NET `MultipleGlobalAnalyzerKeys` errors or silently
42
+ changing analyzer severities. In a container worker whose checkout is the workspace root
43
+ with a read-only parent (such as `/workspace`), use `$HOME/.worktrees/<name>`,
44
+ never `..` outside the workspace or inside the checkout. **Delivered work is cleaned up by
43
45
  `.cratis/ai/hooks/scripts/cratis-cleanup-worktrees.sh`, not by memory:** run it from the
44
- main checkout when a pull request merges or you finish a task (hooks also run it after
45
- `gh pr merge` and at session start where the harness supports them, and **ship-changes**
46
- ends with it). It removes a worktree and its branch only on evidence the work reached the
47
- default branch — pushed is not merged — and never forces. It keeps worktrees with non-empty
48
- `.ai-work/` directories; manual `--include-work-records` deletes those records after you
49
- preserve what you need, and automatic hooks never opt in. Pin a long-lived worktree with `git worktree lock <path>`;
50
- locked worktrees are always kept, even with opt-in. Other ignored files such as `.env` files
51
- and local databases can still be deleted with a removed worktree, so move anything you
52
- still need out first. Do not hand-remove worktrees or `git branch -D` a delivered branch
53
- when the script can; and `gh pr merge --delete-branch` from inside a worktree leaves the
54
- worktree and branch behind, which is why the script exists. If the branch must outlive the
55
- task unmerged, leave the worktree and say so in the handoff. Never `--force` a removal; a
46
+ main checkout when a PR merges or you finish a task (hooks and **ship-changes** also run it). It
47
+ removes a worktree and its branch only on evidence the work reached the default branch —
48
+ pushed is not merged — and never forces. It keeps worktrees with non-empty `.ai-work/`
49
+ directories; manual `--include-work-records` deletes them once you have preserved what you
50
+ need; hooks never opt in. Pin a long-lived worktree with `git worktree lock <path>`;
51
+ locked worktrees are always kept, even with opt-in. Ignored files (`.env`, local databases) are
52
+ deleted with a removed worktree: move what you need out first. Do not hand-remove worktrees
53
+ or `git branch -D` a delivered branch when the script can; `gh pr merge --delete-branch`
54
+ inside a worktree leaves the worktree and branch behind. If the branch must outlive the task
55
+ unmerged, leave the worktree and say so in the handoff. Never `--force` a removal; a
56
56
  refusal means look, not push harder.
57
57
  - **Scan for secrets before archiving or sharing.** Before anything from `.ai-work/` is archived,
58
58
  attached or shared, run `gitleaks detect --no-git --source <dir>` (or the repository's equivalent)
@@ -231,7 +231,7 @@ Apply authorization attributes on the `[Command]` record or query method. **[con
231
231
 
232
232
  `[EventType]` records are the schema-bound truth of the system.
233
233
 
234
- - **[contract] No arguments for new events** — the type name is the identifier. Use `generation:`/id only when evolving an existing contract (invoke the **cratis-chronicle-event-type-migration** skill).
234
+ - **[convention] Plain `[EventType]` for new events, public ones included** — the type name is the id; an explicit id only to retain a persisted id or resolve a cross-package collision, never to change one (application-profile.md item 7, decision 152). Evolve a contract with `generation:` (invoke the **cratis-chronicle-event-type-migration** skill).
235
235
  - **[contract] Past-tense, one-purpose names** (`AuthorRegistered`, not `Updated`/`FormSubmitted`) — Chronicle requires past-tense, single-purpose facts. Self-describing without slice context.
236
236
  - **[contract] Avoid nullable properties** — Chronicle's analyzer warns on nullable event members; model optional facts as a separate event, or resolve a nullable command input to a non-null sentinel before constructing the event.
237
237
  - **[contract] `Handle()` never returns a nullable event or `null` for "nothing to do"** — Arc treats a `null` result as success with nothing appended, so the caller is told a command succeeded that never happened. Missing state or a failed rule is a rejection: return `Result<TEvent, ValidationResult>` with `ValidationResult.Error(...)`, or reject in a validator or `Provide()`. Optional `ICommandOperation` returns are a separate contract and unaffected.
@@ -92,7 +92,7 @@ public record RegisterProject(ProjectName Name)
92
92
 
93
93
  ## Events — critical rules
94
94
 
95
- - Record decorated with `[EventType]` (from `Cratis.Chronicle.Events`) with **no arguments** for new events — the type name is the identifier.
95
+ - Record decorated with `[EventType]` (from `Cratis.Chronicle.Events`) plain for new events — the type name is the identifier; an explicit id only to retain an already-persisted id or resolve a cross-package short-name collision, never to change a persisted id.
96
96
  - Past-tense, one purpose, never nullable, never carries the event-source id. Add an XML `<summary>`.
97
97
 
98
98
  ```csharp
@@ -123,7 +123,7 @@ Before handing back:
123
123
  - [ ] Namespace mirrors the folder path under the source root
124
124
  - [ ] File header present; no separate handler classes
125
125
  - [ ] Business rejection returns a `ValidationResult`/`Result<,>` — never thrown
126
- - [ ] `[EventType]` has no arguments; events carry no event-source id and no nullable properties
126
+ - [ ] New events use plain `[EventType]` (explicit id only to retain a persisted id or resolve a cross-package collision); events carry no event-source id and no nullable properties
127
127
  - [ ] No `.AutoMap()` call anywhere (it is on by default)
128
128
 
129
129
  ---
@@ -89,7 +89,7 @@ Proxies now exist. Build React components from the generated proxies (`react.md`
89
89
  - All backend artifacts in one `<Slice>.cs`; namespace mirrors the path; layout per `general.md` (no `Features/` wrapper; `<Module>` optional).
90
90
  - `Handle()` returns the event/result directly (no `Task.FromResult` without `await`); validation in `CommandValidator<T>`/`ConceptValidator<T>`/`Provide()`; **never throw for normal business rejection** — return `ValidationResult`/`Result<,>`.
91
91
  - Start with model-bound attributes, fluent for structured mappings, reducer code for clearer prior-state branches/calculations/guards; **never `.AutoMap()`**. New .NET reducers default to static `Reduce` on the model; separate `IReducerFor<T>` for DI/replay instance behavior/separation; plain-class nomination only when its assembly cannot reference Chronicle. Follow the read-model/reducer skills for Arc query discovery, exact signatures and builder ownership. Preserve admission/ordering guards when converting; do not infer Stage renders the self form or apply it to other SDKs.
92
- - Events: no arguments on `[EventType]`, non-nullable, past tense, `<summary>`, never carry the event-source id.
92
+ - Events: plain `[EventType]` for new events (explicit id only to retain a persisted id or resolve a cross-package short-name collision; never change a persisted id), non-nullable, past tense, `<summary>`, never carry the event-source id.
93
93
  - `[OnceOnly]` on non-idempotent reactor side effects; reactors return side-effect events or use `ICommandPipeline` (never `IEventLog`).
94
94
  - Specs compiled into the application assembly use `#if DEBUG`; dedicated spec projects need no wrapper. Command aliased, per-test unique values.
95
95
  - Never hand-edit Stage-managed (rendered) output, and never leave a modeled rule living only in code.
@@ -12,7 +12,7 @@ Three layers:
12
12
  | Hard block | `PreToolUse` on a write | `scripts/cratis-guard-writes.sh` | zero | exits **2** — the write does not happen |
13
13
  | Hard block | `PreToolUse` on `Bash` | `scripts/cratis-guard-shell-writes.sh` | zero tokens; one batch Write/Edit classification | exits **2** — a protected reference requires read-only syntax throughout the command; best-effort, not a sandbox |
14
14
  | Hard block | `PreToolUse` on `Bash` | `scripts/cratis-guard-store-mutations.sh` | zero; parses only commands that mention `cratis` | exits **2** — the store-changing `cratis chronicle` command does not run |
15
- | Hard block | `PreToolUse` on `Bash` | `scripts/cratis-guard-secrets.sh` | zero; parses only commands that mention a credential-bearing tool or file | exits **2** — the guard is a **best-effort, defense-in-depth text filter, NOT a sandbox**: it refuses some harmless commands rather than model the whole shell. Real protection requires **OS-level sandboxing or file permissions**. A command is *tainted* when a protected file-name stem appears in any token, including option values, in any letter case, after quotes, backslashes and line continuations are removed. Only search regex text is exempt: `-e`/`--regexp` values, or the first operand when neither `-e` nor `-f` is present. `-f`/`--file` values and all other operands are paths, not exempt patterns. The stems are `.env`, `.pem`, `.p12`, `.pfx`, `id_rsa`, `id_ed25519`, `id_ecdsa`, `id_dsa`, `.netrc`, `.npmrc`, `.pgpass`, `.pypirc`, `.git-credentials`, `.kube/`, `kubeconfig`, `credentials`, `.docker/`, `/environ` and `run/secrets`. The `.env` stem is a whole-stem rule: a letter or digit right after it releases the word (`Org.DS.EnvironmentalReporting`, `Environments.Specs`, `a.environment.txt`), while `.env`, `.env.local`, `.env_local`, `.env-prod`, `app.env` and `.envrc` stay protected, as do named copies such as `app.env.old`, `prod.env.local` and `app.env~` unless the name ends in `.example`, `.sample`, `.template`, `.dist` or `.defaults`, or in a source, documentation, project, build or markup extension (`.csproj`, `.sln`, `.props`, `.targets`, `.css`, `.html`, `.razor`, `.resx`, `.xaml` and similar); `.json`, `.yaml`, `.xml`, `.config`, `.ini`, `.txt` and extensionless names stay protected. Stars, question marks, bracket expressions and grouped pathname patterns count as the characters they can match when the pattern retains at least two literal stem characters. For `credentials` only, an embedded occurrence in a longer directory component or a recognized source filename (for example `Specs/for_ApplicationCredentials/a.cs` or `CredentialsProvider.cs`) is not a stem hit; exact `credentials`, `credentials.*` and a `credentials/` component remain protected. A command is also tainted when an assignment value or any expanded word can contain a stem. A tainted command runs only when it is a single simple command with every word literal: `cat`, `head`, `tail`, `less`, `more`, `wc`, `grep`, `egrep`, `fgrep` or `rg` of paths that are not protected (such as `cat .env.example`); `test` of literal paths; or `cp SOURCE DEST` with no options and a source that is not protected (for example, `cp .env.example example.txt`; the shell-write guard separately refuses `.env` destinations). A single simple `ls` or `stat` may also take glob operands, but not variables, substitutions, wrappers or other shell structure. Tainted searches cannot recurse, search a directory with `rg`, omit `rg` path operands, or use value-taking options other than `-e`/`--regexp`. Every other tainted command is refused, including variables, command substitution, globs for content readers, loops, conditionals, pipes, redirections, here-strings, here-documents, wrappers, `bash -c`, `eval` and transfer tools. Shell-option changes are checked even without a protected stem: modifying `shopt`, `setopt`, `unsetopt` and `emulate` are refused. `extglob` is refused as an option, not merely as text. Shell invocation `-o`/`-O` options, including clustered flags, must name a supported option. Expanded `set` arguments are refused. Only `set` flags `e`, `u`, `x`, `f`, `v`, `E`, `T` and named options `errexit`, `nounset`, `pipefail`, `xtrace`, `verbose`, `noglob`, `errtrace`, `functrace` (including their `+` forms) are supported. The message names the stem: list the directory with `ls`, then name exact non-credential paths, or use `rg -l PATTERN literal-file`. Narrowing to safe literal files is supported remediation, not a workaround; disguising the same secret read behind a variable, glob, wrapper, script or alias remains prohibited. Commands without a stem keep the full analysis. In that analysis a variable can hold any value the command assigns to it anywhere, a positional parameter or an unquoted expansion with glob or space characters is unknown, and an unknown file operand is refused. Residual classes include **shell glob grammar across bash and zsh, option toggles, option arity and quote concatenation**, as well as runtime-generated names, inherited state, filesystem indirection, user-defined commands, external programs and scripts, and searches without a named protected path. These classes are not modeled exhaustively. Use OS-level sandboxing or file permissions, harness isolation and least privilege as the primary boundary. A `jq`, `yq`, `gojq`, `jaq`, `awk`, `gawk`, `mawk`, `nawk` or `busybox awk` command is refused like `env` and `printenv` when any of its words, after quote and backslash removal, holds `env`, `ENV`, `ENVIRON`, `strenv`, `envsubst`, `getenv`, `PROCINFO` or `SYMTAB` as a whole token (so a field named `env` is refused while `environment` and `envelope` are readable); the flag layout is not parsed, and programs read from a file (`jq -f`, `awk -f`) or built from variables are not inspected. Token files and key-extension globs (`*.key`, `*.jks`) are refused only through the listed reader, input, `dd` and transfer commands; see [`secrets.md`](../rules/secrets.md) |
15
+ | Hard block | `PreToolUse` on `Bash` | `scripts/cratis-guard-secrets.sh` | zero; parses only commands that mention a credential-bearing tool or file | exits **2** — the guard is a **best-effort, defense-in-depth text filter, NOT a sandbox**: it refuses some harmless commands rather than model the whole shell. Real protection requires **OS-level sandboxing or file permissions**. A command is *tainted* when a protected file-name stem appears in any token, including option values, in any letter case, after quotes, backslashes and line continuations are removed. Only search regex text is exempt: `-e`/`--regexp` values, or the first operand when neither `-e` nor `-f` is present. `-f`/`--file` values and all other operands are paths, not exempt patterns. The stems are `.env`, `.pem`, `.p12`, `.pfx`, `id_rsa`, `id_ed25519`, `id_ecdsa`, `id_dsa`, `.netrc`, `.npmrc`, `.pgpass`, `.pypirc`, `.git-credentials`, `.kube/`, `kubeconfig`, `credentials`, `.docker/`, `/environ` and `run/secrets`. The `.env` stem is a whole-stem rule: a letter or digit right after it releases the word (`Org.DS.EnvironmentalReporting`, `Environments.Specs`, `a.environment.txt`), while `.env`, `.env.local`, `.env_local`, `.env-prod`, `app.env` and `.envrc` stay protected, as do named copies such as `app.env.old`, `prod.env.local` and `app.env~` unless the name ends in `.example`, `.sample`, `.template`, `.dist` or `.defaults`, or in a source, documentation, project, build or markup extension (`.csproj`, `.sln`, `.props`, `.targets`, `.css`, `.html`, `.razor`, `.resx`, `.xaml` and similar); `.json`, `.yaml`, `.xml`, `.config`, `.ini`, `.txt` and extensionless names stay protected. Stars, question marks, bracket expressions and grouped pathname patterns count as the characters they can match when the pattern retains at least two literal stem characters. For `credentials` only, an embedded occurrence in a longer directory component or a recognized source, documentation, project, build or markup filename (for example `Specs/for_ApplicationCredentials/a.cs`, `RecordingCredentials.ts`, `credentials.md` or `Credentials.csproj`) is not a stem hit. Source extensions include `.ts`, `.tsx`, `.js`, `.jsx`, `.mjs`, `.cjs`, `.cs`, `.fs`, `.vb`, `.kt`, `.kts`, `.java`, `.go`, `.ex`, `.exs`, `.py`, `.rb`, `.rs`, `.swift`, `.md` and `.mdx`; the build/markup extensions above also qualify. Only resolved literal path words qualify: variables, command substitution, backticks, unquoted globs and brace expansion never receive the source-filename exemption. Exact `credentials`, non-source `credentials.*` and a `credentials/` component remain protected. Secret-carrier extensions (`.json`, `.yaml`, `.yml`, `.xml`, `.ini`, `.toml`, `.txt`, `.conf`, `.properties`, `.config`) do not qualify; an inner carrier suffix such as `credentials.json.ts` stays protected, as do `secrets.yaml`, `secrets.yml` and their dotted copies. `Credentials.ts.bak` is not source, but remains an allowed literal read and a non-secret path for Git operations. A source destination never releases a secret copy source (`cp credentials.json x.ts`). Other protected patterns, including environment files, private keys and kubeconfigs, retain their classification. Literal path-only `git add`, `git checkout` (including `--ours`/`--theirs`), `git restore`, `git rm`, `git mv`, `git diff`, `git log` and `git show` accept non-secret repository paths regardless of extension or credential vocabulary, including `-- <path>` and `HEAD:<path>`. This exemption applies only to positional operands and uses a strict allowlist, not a Git grammar parser: a plain relative path containing only letters, digits, `.`, `_`, `/` and `-`, or an object operand with exactly one colon in `rev:path`. Tokens beginning with `-` never receive the path exemption; both the original option-looking word and its extracted value are checked for sensitive file patterns. Long attached values (`--option=value`), short attached values (`-Fvalue`, `-ovalue`) and separated values receive the same sensitive-file checks, even when an option-looking token follows `--`; secret values such as `token` or `.env` remain refused. The revision may contain only those same characters with an optional trailing `~N` or `^N` (digits required); the path must satisfy the plain-path rule. Absolute paths, `~`, `..` path components, braces, multiple colons, index-stage syntax, pathspec magic, `--no-index` and unresolved expansions receive no Git exemption and fall through to the conservative checks. Secret-file classification always applies to the allowed path component; unsupported operands retain their original spelling for conservative component and protected-stem checks instead of guessing Git's revision/path boundary. Known source credential directories remain usable only after protected ancestor checks; actual secret-file patterns remain refused even behind these prefixes (`git show :0:id_rsa`, `git diff -- ':(literal).envrc'`, `git show HEAD:.env`, `git diff -- credentials.json`, `git add .env`). Unresolved expansions never receive this Git exemption: `cat Cre$(echo 'dentials.json x').cs`, its backtick variant and `git show HEAD:Cre$(echo dentials.json)` are refused rather than inferred to be source paths. A command is also tainted when an assignment value or any expanded word can contain a stem. A tainted command runs only when it is a single simple command with every word literal: `cat`, `head`, `tail`, `less`, `more`, `wc`, `grep`, `egrep`, `fgrep` or `rg` of paths that are not protected (such as `cat .env.example`); `test` of literal paths; or `cp SOURCE DEST` with no options and a source that is not protected (for example, `cp .env.example example.txt`; the shell-write guard separately refuses `.env` destinations). A single simple `ls` or `stat` may also take glob operands, but not variables, substitutions, wrappers or other shell structure. Tainted searches cannot recurse, search a directory with `rg`, omit `rg` path operands, or use value-taking options other than `-e`/`--regexp`. Every other tainted command is refused, including variables, command substitution, globs for content readers, loops, conditionals, pipes, redirections, here-strings, here-documents, wrappers, `bash -c`, `eval` and transfer tools. Shell-option changes are checked even without a protected stem: modifying `shopt`, `setopt`, `unsetopt` and `emulate` are refused. `extglob` is refused as an option, not merely as text. Shell invocation `-o`/`-O` options, including clustered flags, must name a supported option. Expanded `set` arguments are refused. Only `set` flags `e`, `u`, `x`, `f`, `v`, `E`, `T` and named options `errexit`, `nounset`, `pipefail`, `xtrace`, `verbose`, `noglob`, `errtrace`, `functrace` (including their `+` forms) are supported. The message names the stem: list the directory with `ls`, then name exact non-credential paths, or use `rg -l PATTERN literal-file`. Narrowing to safe literal files is supported remediation, not a workaround; disguising the same secret read behind a variable, glob, wrapper, script or alias remains prohibited. Commands without a stem keep the full analysis. In that analysis a variable can hold any value the command assigns to it anywhere, a positional parameter or an unquoted expansion with glob or space characters is unknown, and an unknown file operand is refused. Residual classes include **shell glob grammar across bash and zsh, option toggles, option arity and quote concatenation**, as well as runtime-generated names, inherited state, filesystem indirection, user-defined commands, external programs and scripts, and searches without a named protected path. These classes are not modeled exhaustively. Use OS-level sandboxing or file permissions, harness isolation and least privilege as the primary boundary. A `jq`, `yq`, `gojq`, `jaq`, `awk`, `gawk`, `mawk`, `nawk` or `busybox awk` command is refused like `env` and `printenv` when any of its words, after quote and backslash removal, holds `env`, `ENV`, `ENVIRON`, `strenv`, `envsubst`, `getenv`, `PROCINFO` or `SYMTAB` as a whole token (so a field named `env` is refused while `environment` and `envelope` are readable); the flag layout is not parsed, and programs read from a file (`jq -f`, `awk -f`) or built from variables are not inspected. Token files and key-extension globs (`*.key`, `*.jks`) are refused only through the listed reader, input, `dd` and transfer commands; see [`secrets.md`](../rules/secrets.md) |
16
16
  | Hard block | `PreToolUse` on `Bash` | `scripts/cratis-guard-pr-body.sh` | fetches shared rules only for `gh pr create/edit` | exits **2** for inline bodies, invalid notes or conflicting release labels; warns and allows when offline with no cache |
17
17
  | Cleanup of delivered work | `PostToolUse` on `Bash` (`gh pr merge`, `git pull/merge/worktree`) and `SessionStart` (Pi: `tool_result` and `session_start`) | `scripts/cratis-cleanup-worktrees.sh --hook` | zero when the command is unrelated | never blocks; removes delivered worktrees and branches, reports what it kept |
18
18
  | Quality gate (Claude) | `Stop` | `scripts/cratis-quality-gate.sh` | one build/test run, only when relevant files changed | exits **2** — the turn does not end |
@@ -141,9 +141,10 @@ function stem_boundary(t, start, finish, stem, nonliteral, a, b, before, afte
141
141
  component = substr(t, left, right - left + 1)
142
142
  if (literal && component !~ /^credentials([.]|$)/ && substr(t, right + 1, 1) == "/") return 0
143
143
  # Never infer a source file from a partial component or an expansion. JSON is not source.
144
- if (literal && code_file(component)) return 0
144
+ if (literal && !nonliteral && (code_file(component) || build_file(component)) &&
145
+ component !~ /credential.*\.(json|yaml|yml|xml|ini|toml|txt|conf|properties|config)([.]|$)/) return 0
145
146
  # The singular word is ordinary vocabulary; it marks a protected file only in credential JSON names.
146
- if (stem == "credential" && literal && component !~ /credential[^\/]*\.json[.]*$/) return 0
147
+ if (stem == "credential" && literal && component !~ /credential[^\/]*\.json([.]|$)/) return 0
147
148
  }
148
149
  before = substr(t, a - 1, 1); after = substr(t, b + 1)
149
150
  return !(before == "$" || before == "-" || (before == "{" && substr(t, a - 2, 1) == "$") || after ~ /^(=|\+=)/)
@@ -309,7 +310,55 @@ function git_metadata(words, count, subcommand, k, w, ended, summary) {
309
310
  }
310
311
  return subcommand != "diff" || summary
311
312
  }
313
+ # Path-only Git operations do not turn credential vocabulary into a secret filename.
314
+ # Exempt only plain relative paths or one-colon object specs with a simple ref.
315
+ # Never interpret complex Git grammar; keep the original operand for conservative checks.
316
+ function git_path_kind(w, pathspec, repo_only, parts, count, k, kind, path, allowed, option, directory) {
317
+ option = w ~ /^-/
318
+ if (option) {
319
+ kind = sensitive_path(w)
320
+ if (kind != "") return kind
321
+ }
322
+ if (w ~ /^--[^=]*=/) sub(/^--[^=]*=/, "", w)
323
+ else if (w ~ /^-[A-Za-z].+/) sub(/^-[A-Za-z]=?/, "", w)
324
+ count = split(w, parts, ":")
325
+ path = w
326
+ allowed = !option && count == 1
327
+ if (!option && !pathspec && count == 2 && parts[1] ~ /^[A-Za-z0-9_.\/-]+([~^][0-9]+)?$/) {
328
+ path = parts[2]
329
+ allowed = 1
330
+ }
331
+ allowed = allowed && path ~ /^[A-Za-z0-9_.\/-]+$/ && path !~ /^\// && path !~ /(^|\/)\.\.(\/|$)/
332
+ if (repo_only && !allowed) return "an operand outside the Git path allowlist"
333
+ if (allowed) w = path
334
+ directory = allowed && tolower(base(w)) == "credentials" && tolower(w) !~ /(^|\/)\.aws\/credentials$/ && directory_operand(w)
335
+ kind = sensitive_path(w)
336
+ if (kind != "" && !(directory && kind == "a credentials file")) return kind
337
+ # Inspect every component without guessing where unsupported revision/pathspec syntax ends.
338
+ count = split(w, parts, /[\/:]/)
339
+ for (k = 1; k <= count; k++) {
340
+ if ((k == count && index(w, ":") == 0) || (k < count && tolower(parts[k]) == "credentials")) continue
341
+ kind = sensitive_path(parts[k])
342
+ if (kind != "") return kind
343
+ }
344
+ if (!allowed && stem_scan(w, "raw") != "") return "a protected Git operand"
345
+ return ""
346
+ }
347
+ function git_paths(A, M, n, k, ended, pathspec) {
348
+ if (A[1] != "git" || A[2] !~ /^(add|checkout|restore|rm|mv|diff|log|show)$/) return 0
349
+ for (k = 1; k <= n; k++) {
350
+ if (expands(A[k], M[k]) || !literal_word(A[k], M[k]) || A[k] ~ /[*?\[]/) return 0
351
+ if (k <= 2) continue
352
+ if (!ended && A[k] == "--") { ended = 1; continue }
353
+ if (!ended && A[2] == "diff" && A[k] ~ /^--no-index($|=)/) return 0
354
+ pathspec = ended || A[2] ~ /^(add|checkout|restore|rm|mv)$/
355
+ # Options are checked for sensitive values but are never positional path exemptions.
356
+ if (git_path_kind(A[k], pathspec, A[k] !~ /^-/) != "") return 0
357
+ }
358
+ return 1
359
+ }
312
360
  function literal_shape(A, M, n, k, j, b, words, count, pattern, ended, w, paths, flags) {
361
+ if (git_paths(A, M, n)) return 1
313
362
  if (metadata_shape(A, M, n)) return 1
314
363
  delete words
315
364
  for (k = 1; k <= n; k++) {
@@ -387,12 +436,14 @@ function split_scan(w, m, k, r, hit) {
387
436
  }
388
437
  return ""
389
438
  }
390
- function end_cmd( k, m, w, j, hit, exempt) {
439
+ function end_cmd( k, m, w, j, hit, exempt, path_git) {
391
440
  flush_word()
392
441
  if (nw > 0) {
393
442
  commands++
394
443
  regex_slots(W, 1, nw)
444
+ path_git = git_paths(W, WM, nw)
395
445
  for (k = 1; k <= nw; k++) {
446
+ if (path_git && W[k] !~ /^-/) continue
396
447
  if (is_assign(W[k])) set_var(W[k], WM[k])
397
448
  exempt = (k in RP) && !WU[k]
398
449
  if (exempt && RP[k] < 0) continue
@@ -405,7 +456,14 @@ function end_cmd( k, m, w, j, hit, exempt) {
405
456
  }
406
457
  if (!exempt && expands(W[k], WM[k])) {
407
458
  resolve(W[k], WM[k])
408
- for (j = 1; j <= nalt; j++) { hit = stem_scan(ALT[j], "resolved"); if (TAINT == "") TAINT = hit }
459
+ for (j = 1; j <= nalt; j++) {
460
+ w = ALT[j]
461
+ if (w ~ /[\001\003]/) {
462
+ gsub(/[\001\003]/, "*", w)
463
+ hit = stem_scan(w, "raw", "expanding")
464
+ } else hit = stem_scan(w, "resolved")
465
+ if (TAINT == "") TAINT = hit
466
+ }
409
467
  }
410
468
  }
411
469
  if (!literal_shape(W, WM, nw)) simple_ok = 0
@@ -651,7 +709,7 @@ function skipopts(A, s, n, vals) {
651
709
  function is_assign(w) { return w ~ /^[A-Za-z_][A-Za-z0-9_]*(\[[^]]*\])?\+?=/ }
652
710
 
653
711
  # ── file classification for the reader commands ──
654
- function code_file(b) { return b ~ /\.(cs|ts|tsx|js|jsx|mjs|cjs|go|py|java|kt|rs|md)$/ }
712
+ function code_file(b) { return b ~ /\.(cs|fs|vb|ts|tsx|js|jsx|mjs|cjs|go|py|java|kt|kts|ex|exs|rb|rs|swift|md|mdx)$/ }
655
713
  # Build and markup files cannot hold values, so a dotted Env segment in their names (Cratis.Env.Tool.csproj) is not an env copy.
656
714
  function build_file(b) { return b ~ /\.(csproj|fsproj|vbproj|sln|slnx|props|targets|css|scss|less|html|htm|razor|cshtml|resx|xaml)$/ }
657
715
  # A design-token file is not a credential: a stylesheet, or a file under a design, theme or style directory, is
@@ -673,7 +731,9 @@ function sensitive_path(w, l, b) {
673
731
  if (b == "id_rsa" || b == "id_ed25519" || b == "id_ecdsa" || b == "id_dsa") return "a private key"
674
732
  if (b ~ /(^|[._-])tokens?($|[._-])/ && !code_file(b) && !token_ok(l, b)) return "a token file"
675
733
  if (b == ".netrc" || b == ".npmrc" || b == ".pgpass" || b == ".pypirc" || b == ".git-credentials") return "a credentials file"
676
- if (b == "credentials" || b ~ /credential.*\.json[.]*$/) return "a credentials file"
734
+ if (b == "credentials" || b ~ /credential.*\.json([.]|$)/ ||
735
+ b ~ /credentials.*\.(yaml|yml|xml|ini|toml|txt|conf|properties|config)([.]|$)/ ||
736
+ b ~ /secrets\.ya?ml([.]|$)/) return "a credentials file"
677
737
  if (l ~ /\.docker\/config\.json$/) return "the Docker registry credentials"
678
738
  if (l ~ /\/proc\/[^\/]*\/environ$/) return "a process environment"
679
739
  if (l ~ /^\/(var\/)?run\/secrets\//) return "mounted secrets"
@@ -1359,8 +1419,16 @@ function transfer_files(A, s, n, b, k, last, options, kind, w, eq, off, ended
1359
1419
  }
1360
1420
  }
1361
1421
  # Git grep reuses pattern/file separation; ls-files never reaches this content path.
1362
- function git_content(A, s, n, subcommand, k, w) {
1422
+ function git_content(A, s, n, subcommand, k, w, kind, ended, pathspec) {
1363
1423
  subcommand = A[s + 1]
1424
+ if (subcommand ~ /^(add|checkout|restore|rm|mv|diff|log|show)$/) {
1425
+ for (k = s + 2; k <= n; k++) {
1426
+ if (!ended && A[k] == "--") { ended = 1; continue }
1427
+ pathspec = ended || subcommand ~ /^(add|checkout|restore|rm|mv)$/
1428
+ kind = git_path_kind(A[k], pathspec)
1429
+ if (kind != "") report("git " subcommand " names " kind, "name only non-credential source files; list filenames with git ls-files")
1430
+ }
1431
+ }
1364
1432
  if (subcommand !~ /^(grep|show|cat-file)$/) return
1365
1433
  if (subcommand == "grep") reader(A, s + 1, n)
1366
1434
  for (k = s + 2; k <= n; k++) {
@@ -1491,7 +1559,7 @@ BEGIN {
1491
1559
  nprobe2 = split(".kube/config .aws/credentials .docker/config.json /proc/1/environ /run/secrets/token /var/run/secrets/token", PROBE2, " ")
1492
1560
  nextension = split("pem key p12 pfx jks keystore kdbx kubeconfig env", EXT, " ")
1493
1561
  ndispatch = split("cat tac nl less more head tail bat batcat strings xxd od hexdump cut sort uniq base64 wc dd cp mv ln rsync scp tar zip shopt set setopt unsetopt emulate grep egrep fgrep rg ag sed awk gawk mawk nawk busybox jq yq gojq jaq kubectl oc docker podman docker-compose gh vault aws az gcloud pulumi cratis printenv export declare typeset env bash sh zsh dash ksh eval", DN, " ")
1494
- nstem = split(".env .pem .key .p12 .pfx .jks .keystore .kdbx id_rsa id_ed25519 id_ecdsa id_dsa .netrc .npmrc .pgpass .pypirc .git-credentials .kube/ kubeconfig credentials credential .docker/ /environ run/secrets", STEM, " ")
1562
+ nstem = split(".env .pem .key .p12 .pfx .jks .keystore .kdbx id_rsa id_ed25519 id_ecdsa id_dsa .netrc .npmrc .pgpass .pypirc .git-credentials .kube/ kubeconfig credentials credential secrets.yaml secrets.yml .docker/ /environ run/secrets", STEM, " ")
1495
1563
  CMD = ENVIRON["GS_COMMAND"]
1496
1564
  for (pass = 1; pass <= 2; pass++) {
1497
1565
  delete queue; queued = 0; qi = 0; delete seen; reports = ""
@@ -50,7 +50,7 @@ Tagged **[contract]** (framework-enforced) or **[convention]** (house default).
50
50
  4. **[contract] Events never carry the event-source id** — it is implicit in the event context.
51
51
  5. **[contract] `[Key]` / `[Subject]` are distinct.** `[Key]` is for event-source/read-model/projection key resolution; `[Subject]` is compliance identity only. Don't put either on an `EventSourceId<T>` value (it already is both); use them only for non-`EventSourceId<T>` values.
52
52
  6. **[contract] Avoid nullable event properties** — Chronicle's analyzer warns on them. Model optional facts as a separate event; resolve nullable command inputs to a non-null sentinel before constructing the event. **Likewise `Handle()` never returns a nullable event or `null` for "nothing to do"** — Arc treats a `null` result as success with nothing appended, so the caller is told a command succeeded that never happened. Missing state or a failed rule is a rejection: return `Result<TEvent, ValidationResult>` with `ValidationResult.Error(...)`, or reject in a validator or `Provide()`. Optional `ICommandOperation` returns are a separate contract and unaffected.
53
- 7. **[contract] `[EventType]` takes no arguments for new events** — the type name is the identifier. Use `generation:`/id only when evolving an existing contract; schema changes get a new generation + an `EventTypeMigration<TUpgrade,TPrevious>` (never edit stored-event semantics silently). An enum that only gains a member, or has one renamed, is the exception — Chronicle accepts that in place; a *removed* or *renumbered* member still needs a generation, plus a value map saying what the old values became.
53
+ 7. **[convention] New events use plain `[EventType]`** — the type name is the id, public contracts included; "public" never implies a UUID or any explicit id. This is a house convention (decision 152), not a Chronicle contract: Chronicle accepts any string id. An explicit id is allowed only (a) to keep an already-persisted id after a CLR rename, or (b) to resolve a cross-package short-name collision (`MultipleEventTypesWithSameIdFound`). Never change an existing persisted id. Schema changes get a new generation + an `EventTypeMigration<TUpgrade,TPrevious>` (never edit stored-event semantics silently). An enum that only gains a member, or has one renamed, is the exception — Chronicle accepts that in place; a *removed* or *renumbered* member still needs a generation, plus a value map saying what the old values became.
54
54
  8. **[convention] Every `[EventType]` has an XML `<summary>`** — a Cratis C# documentation convention (not a Chronicle rule); events live in the log forever, so record why they exist.
55
55
  9. **[convention] `[ReadModel]` properties carry no default values** except semantically meaningful enum initial states and `[SetValue<T>]`-driven `bool` flags. False defaults hide missing projection wiring.
56
56
  10. **[contract] AutoMap is on by default — never call `.AutoMap()`.** Match property names so AutoMap wires them; diverge with `[SetFrom<T>]` / fluent `.Set().To()` only for genuine name differences. Re-enable `.AutoMap()` only inside a scope where it was disabled with `.NoAutoMap()`.
@@ -28,6 +28,10 @@ Prefer composing behavior from smaller, focused collaborators over building clas
28
28
  - Never extend a concrete class to add or change behavior — inject a collaborator instead.
29
29
  - Inheritance is acceptable only for framework integration points where a base class is part of a well-defined extension mechanism.
30
30
 
31
+ ## Comments carry no issue or spec references
32
+
33
+ Code comments never cite issue numbers, PR numbers or spec sections; that context belongs in the commit message and pull request. A comment says why code is non-obvious.
34
+
31
35
  ## Single Responsibility Principle
32
36
 
33
37
  Every type and every method should have **one reason to change** — it should do one thing and do it well. A class that fetches data, transforms it, validates it, and sends an email has four reasons to change. When any of those concerns shifts, you have to touch — and risk breaking — all the others.
@@ -331,7 +331,7 @@ These are the building blocks. Each type has a specific role in the vertical sli
331
331
  | --- | --- |
332
332
  | `ConceptAs<T>` | Strongly-typed domain *value* wrapper (see [concepts.md](./concepts.md)) |
333
333
  | `EventSourceId<T>` | Strongly-typed *identity* base — derive event-source ids from this, not `ConceptAs<T>` |
334
- | `[EventType]` | Marks a record as a Chronicle event — **never** pass arguments for a new event |
334
+ | `[EventType]` | Marks a record as a Chronicle event — plain for a new event (explicit id only per application-profile.md item 7) |
335
335
  | `[Command]` | Marks a record as a model-bound command — define `Handle()` directly on the record |
336
336
  | `[ReadModel]` | Marks a record as a model-bound query — define static query methods on the record |
337
337
  | `CommandValidator<T>` | FluentValidation validator for commands |
@@ -84,7 +84,7 @@ The project's voice is **direct, practical, and opinionated**. Write like an exp
84
84
  ## Code examples
85
85
 
86
86
  - Prefer `record` types for events, commands, and read models — match the codebase.
87
- - Use argument-free `[EventType]` for new events. A new generation or an explicit legacy identifier is valid only when documenting evolution of an existing stored-event contract.
87
+ - Use plain `[EventType]` for new events. A new generation or an explicit id is valid only when documenting evolution of an existing stored-event contract (a retained persisted id) or a cross-package short-name collision.
88
88
  - A standalone example must be **complete and correct** at its stated scope. Mark a partial excerpt as an excerpt, state its prerequisites, and never leave an essential step behind `// ...`. Do not offer an incomplete block as click-to-copy code.
89
89
  - **State version requirements, not the test log.** Name minimum, fixed or breaking releases and meaningful compatibility or peer ranges. Ordinary installation follows the supported latest-release path, not universal exact-patch pins; latest does not imply every package combination is compatible. Keep resolved versions in maintained manifests/lockfiles, or pin deliberately reproducible tutorials when needed. Preserve required security/deployment constraints and production image policy. Do not end a page with verification provenance (SDK build, image digest or SHA, date, "tested with", unrun samples); that belongs in the change summary. See **cratis-technical-examples**.
90
90
  - **Short illustrative snippets** may be purpose-built after checking their framework APIs against source. Derive substantial or runnable examples from compiled, tested sample or spec code; extract or check displayed snippets with the owning repository's tooling so they do not drift. Never substitute a bare “see the repository” link for showing the code.
@@ -3,17 +3,17 @@
3
3
  Cratis repositories come in **two profiles**, and the rules are scoped to them. **Identify your profile first** — it decides which rules apply.
4
4
 
5
5
  - **Application profile (default)** — you are *building an application on Cratis*: event-sourced CQRS with **Cratis Chronicle** + **Cratis Arc**, vertical slices, read models persisted to MongoDB/EF Core, and a React + Cratis Components (4.x) frontend in MVVM. Most of this corpus targets this profile.
6
- - **Framework profile** — you are *contributing to a Cratis framework repository itself* (Arc, Chronicle, Fundamentals, Components, …). These are **libraries** — source generators, the Chronicle kernel (Orleans grains + storage), client SDKs, a React component library — **not** vertical-slice event-sourced apps. The application-architecture rules here **do not apply**; follow **[framework.md](./framework.md)**.
6
+ - **Framework profile** — you are *contributing to a Cratis framework repository itself* (Arc, Chronicle, Fundamentals, Components, …). These are **libraries** (source generators, the Chronicle kernel, client SDKs, a React component library), **not** vertical-slice event-sourced apps. The application-architecture rules here **do not apply**; follow **[framework.md](./framework.md)**.
7
7
 
8
8
  **How to tell:** if the repo's own package is `Cratis.*` / `@cratis/*` and it *builds* the framework, you are in the framework profile. If it *consumes* Cratis to build a product, you are in the application profile.
9
9
 
10
- **See [profiles.md](./profiles.md) for a complete list of all available profiles and how to configure them.**
10
+ **See [profiles.md](./profiles.md) for all profiles and how to configure them.**
11
11
 
12
- Profile-specific rules declare a **`profile:`** in their frontmatter (`application` or `framework`); a rule **without** one is **universal** and applies everywhere — C#/TypeScript style, code quality, specs (`Cratis.Specifications`), documentation, commits/PRs, American English. In this file, everything from **Project Layout** through the **Implementation Workflow** is *application profile* (skip to the Framework profile section if you're contributing to the framework); Philosophy, Authority, Verification, Quality Gates, and the closing sections are universal.
12
+ Profile-specific rules declare a **`profile:`** in their frontmatter (`application` or `framework`); a rule **without** one is **universal** and applies everywhere — C#/TypeScript style, code quality, specs (`Cratis.Specifications`), documentation, commits/PRs, American English. In this file, everything from **Project Layout** through the **Implementation Workflow** is *application profile* (framework contributors: skip to the Framework profile section); Philosophy, Authority, Verification, Quality Gates, and the closing sections are universal.
13
13
 
14
14
  > **Arc is a standalone CQRS framework — not bound to event sourcing.** Even within the application profile, Arc provides model-bound commands/queries, validation, authorization, and full-stack proxy generation, and works **without** Chronicle (Arc.Core does not depend on Chronicle). A `[Command]` `Handle()` does not *have* to append events — it can return a response, return `void`, or work through injected services. The event-sourcing behavior (a returned event gets appended; `EventForEventSourceId`; "never inject `IEventLog`") comes from the **Arc + Chronicle** integration. This application is event-sourced, so the slice guidance assumes event-sourced commands — read the event-centric rules as the *house default for this app*, not universal Arc laws.
15
15
 
16
- The framework is convention-over-configuration. **Idiomatic Cratis is the goal — not custom abstractions over it.** Always recommend the idiomatic way unless explicitly needed otherwise. When something is unclear, prefer the Cratis convention; do not invent. The rules and skills under `.cratis/ai/` are the authoritative answer — if your question is not answered there, ask rather than inferring framework behavior from package internals.
16
+ The framework is convention-over-configuration. **Idiomatic Cratis is the goal — not custom abstractions over it.** Recommend the idiomatic way; when unclear, prefer the Cratis convention, do not invent. The rules and skills under `.cratis/ai/` are the authoritative answer — if your question is not answered there, ask rather than inferring framework behavior from package internals.
17
17
 
18
18
  ## Project Philosophy
19
19
 
@@ -22,7 +22,7 @@ Every rule here serves **ease of use**, **productivity**, and **maintainability*
22
22
  - **Lovable APIs** — APIs should be pleasant to use: sane defaults, flexible, extensible, overridable. If an API feels awkward, it is wrong.
23
23
  - **Easy to do things right, hard to do things wrong** — convention over configuration; artifact discovery by naming/attributes; minimal boilerplate. The framework guides you into the pit of success.
24
24
  - **Events are facts** — immutable records of what happened. Past tense, one purpose, never ambiguous. If you reach for a nullable property on an event, you need a second event.
25
- - **Strongly-typed primitives are the foundation — get them right first.** The most important, load-bearing decisions in every slice are the domain primitives: `ConceptAs<T>` value types and `EventSourceId<T>` identities (never raw `Guid`/`string`/`int` for a domain value); `ConceptValidator<T>` for invariants that travel with a value everywhere it appears; `CommandValidator<T>` for command-level rules; and past-tense, self-describing `[EventType]` names. These are not boilerplate or an afterthought — they are what makes the model type-safe end to end, the rules enforceable in one place, the events trustworthy forever, and the generated proxies meaningful. Treat naming and typing them precisely as the highest-value craftsmanship in the codebase; a slice built on sloppy primitives is wrong no matter how good the rest is.
25
+ - **Strongly-typed primitives are the foundation — get them right first.** The most important, load-bearing decisions in every slice are the domain primitives: `ConceptAs<T>` value types and `EventSourceId<T>` identities (never raw `Guid`/`string`/`int` for a domain value); `ConceptValidator<T>` for invariants that travel with a value everywhere it appears; `CommandValidator<T>` for command-level rules; and past-tense, self-describing `[EventType]` names. They make the model type-safe end to end, rules enforceable in one place and events trustworthy forever; a slice built on sloppy primitives is wrong however good the rest is.
26
26
  - **High cohesion through vertical slices** — everything for a behavior lives together: backend, frontend, specs. Navigate by feature, not by technical layer.
27
27
  - **Full-stack type safety** — shared models flow from C# through proxy generation to TypeScript. End-to-end typing without manual synchronization.
28
28
  - **Specialization over reuse** — focused, purpose-built read models over one model reused across conflicting scenarios.
@@ -53,9 +53,7 @@ obtaining credentials, and other local conventions ("Product policy" above).
53
53
  use, but it must never contain credential values, tokens, keys, passwords, or
54
54
  other secrets.
55
55
  - A repository's accepted decision records (`decisions/`) and project rules bind AI work: read those matching your paths, follow them, never work around one.
56
- - Project-specific guidance wins when it deliberately narrows shared behavior,
57
- but it may not weaken organization security, authorization, or required
58
- quality gates.
56
+ - Project-specific guidance wins when it narrows shared behavior for product policy, but may not weaken organization security, authorization, or required quality gates. For `[convention]` idioms the corpus wins over repository-local specs, design docs, and existing code or checks; a deviation needs an accepted ADR in the repository's decisions folder naming the corpus rule it replaces. It never relaxes `[contract]` rules, security, authorization or gates, or rewrites persisted ids.
59
57
  - Scope project file concerns with `paths`; put operational workflows in
60
58
  `.agents/skills/`, not global `applyTo: "**/*"` rules.
61
59
 
@@ -37,21 +37,21 @@ dumps, and similar coordination files. These are **work records, not documentati
37
37
  replace the prompt.
38
38
  - **A worktree is a work record too.** Create it outside the repository tree, for
39
39
  example in a sibling `../.worktrees/` directory. A nested worktree inherits the
40
- parent's `.globalconfig`, causing .NET's `MultipleGlobalAnalyzerKeys`
41
- errors or silently changing analyzer severities. **Delivered work is cleaned up by
40
+ parent's `.globalconfig`, causing .NET `MultipleGlobalAnalyzerKeys` errors or silently
41
+ changing analyzer severities. In a container worker whose checkout is the workspace root
42
+ with a read-only parent (such as `/workspace`), use `$HOME/.worktrees/<name>`,
43
+ never `..` outside the workspace or inside the checkout. **Delivered work is cleaned up by
42
44
  `.cratis/ai/hooks/scripts/cratis-cleanup-worktrees.sh`, not by memory:** run it from the
43
- main checkout when a pull request merges or you finish a task (hooks also run it after
44
- `gh pr merge` and at session start where the harness supports them, and **ship-changes**
45
- ends with it). It removes a worktree and its branch only on evidence the work reached the
46
- default branch — pushed is not merged — and never forces. It keeps worktrees with non-empty
47
- `.ai-work/` directories; manual `--include-work-records` deletes those records after you
48
- preserve what you need, and automatic hooks never opt in. Pin a long-lived worktree with `git worktree lock <path>`;
49
- locked worktrees are always kept, even with opt-in. Other ignored files such as `.env` files
50
- and local databases can still be deleted with a removed worktree, so move anything you
51
- still need out first. Do not hand-remove worktrees or `git branch -D` a delivered branch
52
- when the script can; and `gh pr merge --delete-branch` from inside a worktree leaves the
53
- worktree and branch behind, which is why the script exists. If the branch must outlive the
54
- task unmerged, leave the worktree and say so in the handoff. Never `--force` a removal; a
45
+ main checkout when a PR merges or you finish a task (hooks and **ship-changes** also run it). It
46
+ removes a worktree and its branch only on evidence the work reached the default branch —
47
+ pushed is not merged — and never forces. It keeps worktrees with non-empty `.ai-work/`
48
+ directories; manual `--include-work-records` deletes them once you have preserved what you
49
+ need; hooks never opt in. Pin a long-lived worktree with `git worktree lock <path>`;
50
+ locked worktrees are always kept, even with opt-in. Ignored files (`.env`, local databases) are
51
+ deleted with a removed worktree: move what you need out first. Do not hand-remove worktrees
52
+ or `git branch -D` a delivered branch when the script can; `gh pr merge --delete-branch`
53
+ inside a worktree leaves the worktree and branch behind. If the branch must outlive the task
54
+ unmerged, leave the worktree and say so in the handoff. Never `--force` a removal; a
55
55
  refusal means look, not push harder.
56
56
  - **Scan for secrets before archiving or sharing.** Before anything from `.ai-work/` is archived,
57
57
  attached or shared, run `gitleaks detect --no-git --source <dir>` (or the repository's equivalent)
@@ -230,7 +230,7 @@ Apply authorization attributes on the `[Command]` record or query method. **[con
230
230
 
231
231
  `[EventType]` records are the schema-bound truth of the system.
232
232
 
233
- - **[contract] No arguments for new events** — the type name is the identifier. Use `generation:`/id only when evolving an existing contract (invoke the **cratis-chronicle-event-type-migration** skill).
233
+ - **[convention] Plain `[EventType]` for new events, public ones included** — the type name is the id; an explicit id only to retain a persisted id or resolve a cross-package collision, never to change one (application-profile.md item 7, decision 152). Evolve a contract with `generation:` (invoke the **cratis-chronicle-event-type-migration** skill).
234
234
  - **[contract] Past-tense, one-purpose names** (`AuthorRegistered`, not `Updated`/`FormSubmitted`) — Chronicle requires past-tense, single-purpose facts. Self-describing without slice context.
235
235
  - **[contract] Avoid nullable properties** — Chronicle's analyzer warns on nullable event members; model optional facts as a separate event, or resolve a nullable command input to a non-null sentinel before constructing the event.
236
236
  - **[contract] `Handle()` never returns a nullable event or `null` for "nothing to do"** — Arc treats a `null` result as success with nothing appended, so the caller is told a command succeeded that never happened. Missing state or a failed rule is a rejection: return `Result<TEvent, ValidationResult>` with `ValidationResult.Error(...)`, or reject in a validator or `Provide()`. Optional `ICommandOperation` returns are a separate contract and unaffected.
@@ -212,6 +212,13 @@ behavior.
212
212
  Arc tenancy is request-scoped tenant *resolution*. It is not Chronicle's tenant
213
213
  namespace isolation — that is separate guidance.
214
214
 
215
+ ## Headless reusable modules
216
+
217
+ A reusable module that must work in any host ships backend contracts only:
218
+ commands, queries, events and the identity/claims integration. It has no pages,
219
+ routes, styling or UI components. Sign-in, consent and profile UI belong to the
220
+ host application, which composes the module's endpoints.
221
+
215
222
  ## Frontend
216
223
 
217
224
  Read [references/frontend.md](references/frontend.md#identity-hook-examples) when you need the `<Arc>` provider and `useIdentity`/`RequireRole` examples.
@@ -83,10 +83,15 @@ generation. There is no id argument, which is the point: the event type id is
83
83
  resolved from the current record's `[EventType]`, so the two generations cannot
84
84
  end up with mismatched ids.
85
85
 
86
+ Persisted event type ids are immutable identity, and an explicit id is a house
87
+ exception (decision 152): new events use plain `[EventType]`, and an id string is
88
+ written only to retain an already-persisted id after a rename (below) or to
89
+ resolve a cross-package short-name collision. Never change or "normalize" one.
90
+
86
91
  The older style — giving the prior record its own
87
92
  `[EventType("<explicit-id>", generation: 1)]` with an id string identical to the
88
- current generation's — is still supported and still works. Prefer
89
- `[EventTypeGenerationFor<T>]` for anything new: with the explicit-id style, an
93
+ current generation's — is still supported and still works, as a retained id.
94
+ Prefer `[EventTypeGenerationFor<T>]` for anything new: with the explicit-id style, an
90
95
  omitted or mistyped id silently defaults to the CLR type name, Chronicle then
91
96
  treats the two as unrelated event types, and the migration never applies.
92
97
 
@@ -183,7 +188,7 @@ Adding/removing an **optional** property at any depth still needs a migration
183
188
  class to complete the new generation chain, but no property operations: the
184
189
  target schema supplies absence/drops undeclared properties. That is a migration
185
190
  fact, not a reason to put nullable facts on newly authored events. Schema `title`
186
- is ignored, so renaming a CLR record with a pinned `[EventType("id")]` does not
191
+ is ignored, so renaming a CLR record whose persisted id is retained with `[EventType("id")]` does not
187
192
  raise `EventTypeSchemaChanged`. A property described only by `default` may gain
188
193
  `type`/`format` without that error. Source:
189
194
  `Documentation/migrations/dotnet-client.mdx` and the kernel event-type schema comparison.
@@ -297,6 +302,7 @@ is expected, since the prior generation records history rather than new intent.
297
302
  | Adding a nullable property to represent "missing on old events" | CHR0012; supply a `DefaultValue` instead |
298
303
  | Splitting one event into two inside `Upcast` | a migration produces one event; model a split as a reactor or a command |
299
304
  | Adding a new generation for a renamed enum member | not needed; only removal or renumbering requires one |
305
+ | Deriving an operational identity from the event type id (outbox deduplication key, derived fact id, fence-log key, replay receipt) and then renaming | generations do not cover it; keep the old id value or migrate that store |
300
306
 
301
307
  ## Verify
302
308
 
@@ -307,6 +313,8 @@ is expected, since the prior generation records history rather than new intent.
307
313
  implements both `Upcast` and `Downcast` with the correct generic order.
308
314
  - `MapValues` is overridden only where a value's meaning changed.
309
315
  - No nullable property was added to an `[EventType]` record.
316
+ - Any explicit id retains a persisted id or resolves a collision, and no store
317
+ keyed by an event type id (deduplication keys, receipts) was left behind.
310
318
  - The build is clean with no `CHR0012`, `CHR0037`, `CHR0049`, or `CHR0050`
311
319
  outstanding.
312
320
  - Old-generation events replay into the current shape through the read-model
@@ -67,7 +67,7 @@ This table is a reading of the renderer's admission, not a render result: run th
67
67
  | Enum numbers / compliance | explicit enum numbers (v12); concept `[PII]` or scoped `[Encrypted]` + `[NotAudited]` (v13), property-level `[NotAudited]` for protected command inputs | protected identities/enums (`-040`); explicit subject lineage remains unadmitted |
68
68
  | Specifications | command scenarios and supported single-hop reaction appends; Stage's `admission.md` | appends outside the single-hop subset and commands cascading into reactions (`-011`); `then no readmodel` (`-027`); an unauthenticated caller carrying roles or claims (`-011`); command `given clock` renders only whole milliseconds at or after 1970 |
69
69
  | v9 and v10 | reaction/reducer `from` filters; role/authenticated `runs as`; bounded source-event captures and outbound public projection | unsupported public-event production (`-032`), foreign-event uses (`-033`) and Translate shapes (`-024`); claim-reading/opaque `runs as` gates (`-034`); legacy `from` (`-035`); per-production route overrides (`-036`) |
70
- | Stored event names (v16) | `[EventType("storedName")]` retains stored identity while the class follows the model name | changed/unreadable destination event ids: `STAGE-EVENT-002`, CLI `CLI-RENDER-016` |
70
+ | Stored event names (v16) | `[EventType("storedName")]` is a retained id (stored identity) while the class follows the model name | changed/unreadable destination event ids: `STAGE-EVENT-002`, CLI `CLI-RENDER-016` |
71
71
  | No events / redelivery (v17) | otherwise admitted command no-event specs; one production-only reaction no-effect spec; located redelivery to one trigger with productions or one supported invocation | fan-out, deeper cascades, constraints, read/query expectations, redelivery with refusal branches, appends with no observer: `-011` |
72
72
  | Refusal branches (v19) | ordered Arc `OnRefused`/`Acknowledge`, refusal values and supported single-hop append specs | same-event multi-trigger refusal groups, localized `$refusal.message`, ambiguous multiple-constraint `$refusal.constraint`: `-039`; specification limits: `-011` |
73
73
  | Evolved events | initial revisions only (migrations are not rendered) | `STAGE-ESM-026` |
@@ -151,7 +151,7 @@ multi-trigger refusal groups, localized `$refusal.message`, or `$refusal.constra
151
151
  when several constraints can fail together report STAGE-ESM-039. Unsupported branch
152
152
  conditions/routes/mappings retain -039, specification shapes -011.
153
153
 
154
- Differing event pins render as `[EventType("storedName")]`; the class follows the
154
+ Differing event pins render as `[EventType("storedName")]` (a retained stored id); the class follows the
155
155
  model name. Destination event-id changes or unreadable existing ids block every
156
156
  publication scope with STAGE-EVENT-002 / CLI-RENDER-016, even under `--force`.
157
157
  Requires Cratis CLI 3.60.0 (`cratis --version`) for this publication check; older
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.150.2",
3
+ "version": "7.151.0",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [