@cratis/pi 7.170.10 → 7.170.12

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 (22) hide show
  1. package/package/corpus/harnesses/copilot/instructions/application-profile.instructions.md +1 -1
  2. package/package/corpus/harnesses/copilot/instructions/glossary.instructions.md +1 -1
  3. package/package/corpus/harnesses/copilot/instructions/vertical-slices.instructions.md +3 -3
  4. package/package/corpus/harnesses/pi/extensions/cratis-hooks/index.ts +21 -10
  5. package/package/corpus/hooks/README.md +25 -11
  6. package/package/corpus/hooks/scripts/cratis-guard-writes.sh +43 -15
  7. package/package/corpus/prompts/add-business-rule.prompt.md +1 -1
  8. package/package/corpus/rules/application-profile.md +1 -1
  9. package/package/corpus/rules/glossary.md +1 -1
  10. package/package/corpus/rules/vertical-slices.md +3 -3
  11. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/SKILL.md +1 -1
  12. package/package/corpus/skills/cratis-arc-authentication-authorization-and-identity/references/authorization.md +1 -1
  13. package/package/corpus/skills/cratis-arc-command/SKILL.md +1 -1
  14. package/package/corpus/skills/cratis-arc-command/references/decisions-and-routing.md +2 -2
  15. package/package/corpus/skills/cratis-arc-command/references/read-model-injection.md +1 -1
  16. package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +7 -6
  17. package/package/corpus/skills/cratis-chronicle-decision-reads/SKILL.md +4 -5
  18. package/package/corpus/skills/cratis-chronicle-decision-reads/references/choosing-how-a-rule-holds.md +5 -4
  19. package/package/corpus/skills/cratis-chronicle-event-constraints/SKILL.md +1 -1
  20. package/package/corpus/skills/cratis-code-review/SKILL.md +1 -1
  21. package/package/corpus/skills/cratis-screenplay-streams-and-consistency/references/consistency-and-concurrency.md +1 -1
  22. package/package.json +1 -1
@@ -46,7 +46,7 @@ Commands are imperative intents (`Register`, `Create`); the slice folder is the
46
46
  Tagged **[contract]** (framework-enforced) or **[convention]** (house default). Mechanics and examples live in `vertical-slices.md`.
47
47
 
48
48
  1. **[contract] Model-bound — no controllers.** Commands are `[Command]` records with a public instance `Handle()` (Arc analyzers enforce this); queries are `static` methods on `[ReadModel]` records; projections/constraints/authorization use attributes. Arc generates the HTTP surface. For read-model style follow rule 11's ladder; for constraints use `IConstraint` when attributes cannot express the rule.
49
- 2. **[contract] Command validation & data flow.** Put command rejection in `CommandValidator<T>`, global value invariants in `ConceptValidator<T>`, and fetched/computed handler data in **`Provide()`** (runs after validation/authorization; may short-circuit with `ValidationResult.Error` / `Result<TProvided, ValidationResult>`). Keep `Handle()` focused on event construction. For a state-dependent rule that must hold **under concurrency**, start new code with read protection `On` (`<CratisReadProtection>On</CratisReadProtection>`): put the rule in a `CommandValidator<T>` with the read model as a constructor parameter and return the events from `Handle()`. Use a constraint for uniqueness, a per-stream read model or `IStreamReads`/`StreamDecision` for one stream, an aggregate for a rich lifecycle; `[ProtectedDecision]` with `DecisionRead<T>` is the older per-command opt-in. Under `Off` (the default when nothing is set) a validator over a plain read is a hint, not a guard. Return a typed rejection via `Result<TEvent, ValidationResult>` where needed; the result alone adds no guard. **Throwing from `Provide()`/`Handle()` is an exception (HTTP 500), not a validation rejection** — throw only for genuinely exceptional conditions, never for normal business rejection.
49
+ 2. **[contract] Command validation & data flow.** Put command rejection in `CommandValidator<T>`, global value invariants in `ConceptValidator<T>`, and fetched/computed handler data in **`Provide()`** (runs after validation/authorization; may short-circuit with `ValidationResult.Error` / `Result<TProvided, ValidationResult>`). Keep `Handle()` focused on event construction. For a state-dependent rule that must hold **under concurrency**, use read protection `On` (the default from Arc 23; on Arc 22 set `<CratisReadProtection>On</CratisReadProtection>`): put the rule in a `CommandValidator<T>` with the read model as a constructor parameter and return the events from `Handle()`. Use a constraint for uniqueness, a per-stream read model or `IStreamReads`/`StreamDecision` for one stream, an aggregate for a rich lifecycle; `[ProtectedDecision]` with `DecisionRead<T>` is the older per-command opt-in. Under `Off` (set explicitly, or the Arc 22 behavior) a validator over a plain read is a hint, not a guard. Return a typed rejection via `Result<TEvent, ValidationResult>` where needed; the result alone adds no guard. **Throwing from `Provide()`/`Handle()` is an exception (HTTP 500), not a validation rejection** — throw only for genuinely exceptional conditions, never for normal business rejection.
50
50
  3. **[contract] Event-source id resolution:** `ICanProvideEventSourceId` first; else the first qualifying property in declaration order — an `EventSourceId`/`EventSourceId<T>`-derived value *or* a `[Key]` property (no priority between them; two candidates is `ARCCHR0002`); else Arc generates one. A value actually used as a Chronicle stream identity derives from `EventSourceId<T>` with the underlying `IComparable` primitive — never `ConceptAs<Guid>` for that stream identity. `NotSet`, `New()`, and primitive→derived-id operators are optional domain/API conveniences, not Chronicle requirements; typed empty/zero values are real specified stream IDs, not `EventSourceId.Unspecified`.
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.
@@ -55,7 +55,7 @@ One precise line per load-bearing term, so the same word means the same thing ev
55
55
  - **Observation command** — a command whose input comes from outside the model's own decisions (webhook, poll, sweep, retry, classifier). It compares with current state and appends nothing when nothing changed; looking is not a fact.
56
56
  - **Signal event** — an event appended only to make a reactor do something (`…Requested`, `…Started`, `…Skipped`). Not a domain fact; use a job, state machine, command operation or `ICommandPipeline`.
57
57
  - **Constraint** — `IConstraint`; an **append-time** invariant (uniqueness / concurrency) enforced at the event-store level.
58
- - **DCB (Dynamic Consistency Boundary)** — enforcing a state-dependent rule under concurrency over explicitly enrolled event-state reads: read-model parameters under Arc read protection `On`, stream decisions/exact scopes, or protected, admitted projection decision reads. Plain injected models under `Off` (the default) and `Result<TEvent, ValidationResult>` alone are advisory, not a guard.
58
+ - **DCB (Dynamic Consistency Boundary)** — enforcing a state-dependent rule under concurrency over explicitly enrolled event-state reads: read-model parameters under Arc read protection `On`, stream decisions/exact scopes, or protected, admitted projection decision reads. Plain injected models under `Off` (set explicitly, or the Arc 22 behavior) and `Result<TEvent, ValidationResult>` alone are advisory, not a guard.
59
59
  - **Consistency boundary** — the scope within which an invariant holds atomically (an event source, a routed stream, or the event state enrolled by an admitted protected read).
60
60
  - **EventForEventSourceId** — self-describing wrapper to append an event to a **specific** (cross-stream) event source, from a command `Handle()` or from a reactor handler (reactor support has shipped since Chronicle 15.35). It carries the event stream type and id, source type, subject, occurred time, tags and causation, so it is also how a reactor sets those explicitly.
61
61
  - **ReactorDelivery** — the identity of one delivery of one event to one reactor partition; declare it as a handler parameter and Chronicle passes it in. Stable across a replay and across recovering a failed partition, so a receipt kept under its `Id` is what makes a side effect survive re-delivery. An identity, not a guarantee — Chronicle does not know whether the effect ran.
@@ -89,7 +89,7 @@ The command carries input from the caller. `Handle()` is defined directly on the
89
89
  | Reusable value invariant (length, format, range) | `ConceptValidator<T>` on the concept type |
90
90
  | Command-input / cross-field / pre-handler rule (incl. injected read-model/service/identity checks) | `CommandValidator<TCommand>` with `RuleFor(...)` |
91
91
  | Handler needs fetched/computed data before it can build the event | `Provide()` — fetches the data; may validate it and short-circuit |
92
- | State-dependent rule that must hold **under concurrency** | Read protection `On`: the read model as a `CommandValidator<T>` constructor (or `Handle()`) parameter; a per-stream read model or `IStreamReads`/`StreamDecision` for one stream; an aggregate for a rich lifecycle. `[ProtectedDecision]` + `DecisionRead<T>` is the older per-command opt-in. Under `Off` (default) injection is a hint |
92
+ | State-dependent rule that must hold **under concurrency** | Read protection `On`: the read model as a `CommandValidator<T>` constructor (or `Handle()`) parameter; a per-stream read model or `IStreamReads`/`StreamDecision` for one stream; an aggregate for a rich lifecycle. `[ProtectedDecision]` + `DecisionRead<T>` is the older per-command opt-in. Under `Off` (set explicitly, or the Arc 22 behavior) injection is a hint |
93
93
  | Uniqueness | Chronicle `[Unique]` / `IConstraint` (race-safe) — not a read-model pre-check |
94
94
  | Genuinely exceptional failure (bug, missing infra) | `throw` a domain exception |
95
95
 
@@ -183,7 +183,7 @@ Three attributes scope an append broad→narrow, and each one *also* (only with
183
183
 
184
184
  Each attribute always tags the appended events (visible in `EventContext`). **Only when the command also carries `concurrency: true`** does each dimension join the server-side `ConcurrencyScope` (plus the event source id), with the optimistic strategy supplying the expected tail sequence number. A command **without** `concurrency: true` contributes no scope of its own, and the append falls to whatever concurrency strategy the event sequence is configured with — by default the optimistic one, scoped to the event source. So the attribute chooses *which dimensions* bound the check, not whether a check happens at all. Reach for it on high-contention state transitions where a stale read would let two commands both "win" — it narrows the boundary so appends that are genuinely independent stop colliding (concurrency failures surface on `CommandResult`/`AppendResult`). Adopt it deliberately per behavior, not as a blanket default.
185
185
 
186
- New code sets `<CratisReadProtection>On</CratisReadProtection>` (Arc 22.106.0).
186
+ Read protection `On` is the default from Arc 23; on Arc 22 (22.106.0 or later) set `<CratisReadProtection>On</CratisReadProtection>`. A project that sets the property keeps its mode.
187
187
  Under `On`, a read-model parameter of `Handle()` or of a `CommandValidator<T>`
188
188
  constructor is read fresh and guards the append; the state rule goes in the
189
189
  validator. Two entities: two parameters, `[LookUpBy(nameof(Cmd.Prop))]` on the
@@ -194,7 +194,7 @@ routed with `[EventSource<TSource>("Stream")]` and `[EventStreamId("{Prop}")]`,
194
194
  A deliberate advisory read is `[Unprotected("why")]`. Models must be admitted
195
195
  (source-keyed projection with a string or Guid `Id`, or an unfiltered reducer
196
196
  without constructor dependencies); joins, children and event-property keys are
197
- refused. Under `Off` (the default) injection and keyed reads are advisory,
197
+ refused. Under `Off` (set explicitly, or the Arc 22 behavior) injection and keyed reads are advisory,
198
198
  including in `Handle()`; `[ProtectedDecision]` + `DecisionRead<T>` is the older
199
199
  per-command opt-in and still works. Exact returned scopes replace automatic
200
200
  `concurrency: true` capture. Refusals: [choosing how a rule holds](../../../skills/cratis-chronicle-decision-reads/references/choosing-how-a-rule-holds.md).
@@ -84,11 +84,12 @@ interface ScriptRun {
84
84
  * writes it exists to refuse. Callers decide what to do with `failed`; this function only reports
85
85
  * it honestly.
86
86
  */
87
- function runScript(script: string, stdinJson: string, cwd: string, signal?: AbortSignal, args: string[] = []): Promise<ScriptRun> {
87
+ function runScript(script: string, stdinJson: string, cwd: string, signal?: AbortSignal, options: { args?: string[]; env?: NodeJS.ProcessEnv } = {}): Promise<ScriptRun> {
88
+ const { args = [], env } = options;
88
89
  return new Promise<ScriptRun>((resolve) => {
89
90
  let proc: ReturnType<typeof spawn>;
90
91
  try {
91
- proc = spawn("bash", [script, ...args], { cwd, stdio: ["pipe", "pipe", "pipe"] });
92
+ proc = spawn("bash", [script, ...args], { cwd, env, stdio: ["pipe", "pipe", "pipe"] });
92
93
  } catch (error) {
93
94
  resolve({ code: 127, stdout: "", stderr: String(error), failed: true });
94
95
  return;
@@ -147,9 +148,10 @@ async function runBlockingGuard(
147
148
  subject: string,
148
149
  payload: object,
149
150
  ctx: ToolCallContext,
150
- fixTarget = "this guard",
151
+ options: { fixTarget?: string; env?: NodeJS.ProcessEnv } = {},
151
152
  ): Promise<{ block: true; reason: string } | undefined> {
152
- const run = await runScript(script, JSON.stringify(payload), ctx.cwd, ctx.signal);
153
+ const { fixTarget = "this guard", env } = options;
154
+ const run = await runScript(script, JSON.stringify(payload), ctx.cwd, ctx.signal, { env });
153
155
  if (run.failed) {
154
156
  return {
155
157
  block: true,
@@ -168,9 +170,10 @@ async function runCommandGuards(
168
170
  guards: Array<[script: string, name: string]>,
169
171
  payload: object,
170
172
  ctx: ToolCallContext,
173
+ sessionEnv?: (script: string) => NodeJS.ProcessEnv | undefined,
171
174
  ): Promise<{ block: true; reason: string } | undefined> {
172
175
  for (const [script, name] of guards.filter(([guard]) => isInstalled(guard))) {
173
- const blocked = await runBlockingGuard(script, name, "command", payload, ctx);
176
+ const blocked = await runBlockingGuard(script, name, "command", payload, ctx, { env: sessionEnv?.(script) });
174
177
  if (blocked) return blocked;
175
178
  }
176
179
  return undefined;
@@ -195,6 +198,7 @@ function isInstalled(script: string): boolean {
195
198
  }
196
199
  }
197
200
 
201
+
198
202
  export default function (pi: ExtensionAPI) {
199
203
  if (isPackagedExtension && fs.existsSync(path.join(process.cwd(), ".cratis", "ai.manifest.json"))) return;
200
204
  const managedScriptsDir = path.join(process.cwd(), ".cratis", "ai", "hooks", "scripts");
@@ -203,6 +207,13 @@ export default function (pi: ExtensionAPI) {
203
207
  const guardStoreMutations = path.join(scriptsDir, "cratis-guard-store-mutations.sh");
204
208
  const guardSecrets = path.join(scriptsDir, "cratis-guard-secrets.sh");
205
209
  const guardShellWrites = path.join(scriptsDir, "cratis-guard-shell-writes.sh");
210
+ // The dependency-manifest policy belongs to the session, so the two write guards are told which repository the session
211
+ // is in. It is fixed here, at start-up, not read from ctx.cwd, which follows the model's own directory changes. The
212
+ // bundled-script fallback would otherwise resolve to the Pi package. The root is always passed, so a session directory
213
+ // that is no longer usable makes the guards fail closed instead of falling back to the script's checkout.
214
+ const sessionRoot = process.cwd();
215
+ const writeGuardEnv = (script: string): NodeJS.ProcessEnv | undefined =>
216
+ script === guardWrites || script === guardShellWrites ? { ...process.env, CLAUDE_PROJECT_DIR: sessionRoot } : undefined;
206
217
  const guardPrBody = path.join(scriptsDir, "cratis-guard-pr-body.sh");
207
218
  const patternScan = path.join(scriptsDir, "cratis-pattern-scan.sh");
208
219
  const qualityGate = path.join(scriptsDir, "cratis-quality-gate.sh");
@@ -231,7 +242,7 @@ export default function (pi: ExtensionAPI) {
231
242
  const command = (event as any).input?.command;
232
243
  if (typeof command !== "string" || !command.trim()) return;
233
244
  const payload = { cwd: ctx.cwd, tool_name: "Bash", tool_input: { command } };
234
- const blocked = await runCommandGuards([[guardStoreMutations, "cratis-guard-store-mutations"], [guardSecrets, "cratis-guard-secrets"], [guardShellWrites, "cratis-guard-shell-writes"]], payload, ctx);
245
+ const blocked = await runCommandGuards([[guardStoreMutations, "cratis-guard-store-mutations"], [guardSecrets, "cratis-guard-secrets"], [guardShellWrites, "cratis-guard-shell-writes"]], payload, ctx, writeGuardEnv);
235
246
  if (blocked) return blocked;
236
247
  if (isInstalled(guardPrBody)) {
237
248
  const run = await runScript(guardPrBody, JSON.stringify(payload), ctx.cwd, ctx.signal);
@@ -245,9 +256,9 @@ export default function (pi: ExtensionAPI) {
245
256
  if (!filePath) return;
246
257
  if (!isInstalled(guardWrites)) return; // no guard installed in this repository - nothing to enforce
247
258
  const payload = { cwd: ctx.cwd, tool_input: { file_path: filePath, content, new_string: newString } };
248
- // The shared script resolves the write target's Git origin and allowDependencyManifestWrites setting;
249
- // keep manifest defaults and generated/.env protection identical to Claude Code.
250
- return runBlockingGuard(guardWrites, "cratis-guard-writes", "write", payload, ctx, "write guards");
259
+ // The shared script takes the manifest policy (allowDependencyManifestWrites, else Git origin) from the session
260
+ // repository, never the write target; keep that and generated/.env protection identical to Claude Code.
261
+ return runBlockingGuard(guardWrites, "cratis-guard-writes", "write", payload, ctx, { fixTarget: "write guards", env: writeGuardEnv(guardWrites) });
251
262
  });
252
263
 
253
264
  // ── Cleanup of delivered worktrees and branches ──
@@ -257,7 +268,7 @@ export default function (pi: ExtensionAPI) {
257
268
  async function sweepDelivered(hookEvent: "PostToolUse" | "SessionStart", command: string | undefined, cwd: string, signal?: AbortSignal): Promise<string> {
258
269
  if (!isInstalled(cleanupWorktrees)) return "";
259
270
  const payload = JSON.stringify({ hook_event_name: hookEvent, cwd, tool_input: command ? { command } : undefined });
260
- const run = await runScript(cleanupWorktrees, payload, cwd, signal, ["--hook"]);
271
+ const run = await runScript(cleanupWorktrees, payload, cwd, signal, { args: ["--hook"] });
261
272
  if (run.failed) return "cratis-cleanup-worktrees is installed but could not be run, so delivered worktrees were not cleaned up.";
262
273
  try {
263
274
  return JSON.parse(run.stdout)?.hookSpecificOutput?.additionalContext?.trim() ?? run.stderr.trim();
@@ -36,9 +36,14 @@ payload omits cwd; glob probing does not. Filesystem check/use races remain: thi
36
36
 
37
37
  The Bash write guard checks manifest and environment-file names against both logical and resolved physical basenames; run `cratis ai update` to receive this change.
38
38
 
39
- A Pi session runs guards from its starting checkout. Refresh the corpus there with `cratis ai update`,
40
- or start a new session in the checkout you change. Selecting a newer installed guard corpus per call
41
- is tracked in [Cratis/AI#1114](https://github.com/Cratis/AI/issues/1114).
39
+ A Pi session runs guards from its starting checkout (or the bundled corpus when that checkout has none). A command or
40
+ file path that targets another checkout is judged by those guards; the bridge never runs the other checkout's scripts,
41
+ because a checkout the agent can write cannot be a trust anchor. The guards do read policy data about the write target's
42
+ repository for dependency-manifest writes, but only to tighten: the session's policy decides, and a target can block
43
+ but never unlock ([Cratis/AI#1256](https://github.com/Cratis/AI/issues/1256); see *Dependency-manifest writes* below). Refresh the corpus in the starting checkout with
44
+ `cratis ai update` (scripts are read per call, so no restart), or start a new session in the checkout you change.
45
+ Proposed in Cratis/AI#1114 and drafted as `decisions/153-pi-hook-bridge-runs-only-the-starting-checkouts-guards.md`
46
+ (status: proposed): do not select the guard corpus per call.
42
47
 
43
48
  Reader glob probes skip directories only when decoded options establish a nonrecursive reader;
44
49
  unknown or recursive grep options keep directory matches conservative. Simple sed print/substitution
@@ -464,14 +469,23 @@ Other protected classes still apply regardless of a generated header.
464
469
 
465
470
  ### Dependency-manifest writes
466
471
 
467
- Manifest writes are allowed **silently by default** when Git's `origin` points to
472
+ The policy comes from the **session**, not from the file being written. The session repository is
473
+ `CLAUDE_PROJECT_DIR` (else the checkout that holds the installed hook; in Pi, the working directory
474
+ Pi was started in). Its `.cratis/ai.json` `allowDependencyManifestWrites` decides; without a boolean, manifest
475
+ writes are allowed **silently by default** when that repository's Git `origin` points to
468
476
  `github.com/Cratis/<repo>` over HTTPS or SSH (including `git@github.com:Cratis/<repo>.git`;
469
- host and owner are case-insensitive). The hook resolves the policy repository from the write
470
- target, resolving relative paths against the tool's working directory, lexically collapsing
471
- repeated separators, `.` and `..`, then walking up to the nearest existing directory for new
472
- files. That directory is resolved physically before Git lookup, so symlinked directories use
473
- the repository they actually point into. Nested directories and linked worktrees work too.
474
- A missing or non-Cratis origin keeps the block; targets outside any Git repository are blocked. Installed corpus files and selected profiles do **not** prove organization
477
+ host and owner are case-insensitive). A missing or non-Cratis origin keeps the block.
478
+
479
+ The repository that owns the write target is consulted only to **tighten** the decision. The hook
480
+ resolves it from the target, resolving relative paths against the tool's working directory, lexically
481
+ collapsing repeated separators, `.` and `..`, then walking up to the nearest existing directory for new
482
+ files; that directory is resolved physically before Git lookup, so symlinked directories use the
483
+ repository they actually point into. The write is allowed only if the session policy **and** the target
484
+ repository's own policy (same rule: its setting, else its Cratis origin) both allow it. A target's `true`
485
+ or Cratis origin can never unlock a session that blocks, so an agent-created repository cannot opt itself
486
+ in. A target outside any Git repository is blocked, and so is any session whose repository cannot be
487
+ determined. `.cratis/ai.json` is itself a protected control, so the agent cannot edit the session policy.
488
+ Installed corpus files and selected profiles do **not** prove organization
475
489
  ownership: consumer applications can have exactly the same installation and profiles.
476
490
 
477
491
  Set a repository-owned boolean in `.cratis/ai.json` to override that default in both Claude Code
@@ -482,7 +496,7 @@ and Pi:
482
496
  ```
483
497
 
484
498
  `false` re-enables the manifest block in a Cratis repository; `true` allows manifest writes
485
- in any repository. Merge this property into the existing configuration. An absent, malformed,
499
+ in any repository, for targets that do not themselves block (see above). Merge this property into the existing configuration. An absent, malformed,
486
500
  or non-boolean setting uses the origin-based default. This setting never permits `.env` writes.
487
501
  The protected basename list is unchanged; `package.json` is not part of this guard's manifest category.
488
502
 
@@ -9,8 +9,12 @@
9
9
  #
10
10
  # While jq is missing the guard cannot read the tool call, so it refuses every call.
11
11
  #
12
- # .cratis/ai.json allowDependencyManifestWrites overrides only the manifest policy:
13
- # true allows them in any repository; false blocks them even in a Cratis repository.
12
+ # The manifest policy belongs to the session, never to the write target. The session repository is
13
+ # CLAUDE_PROJECT_DIR (else the checkout holding this script); its .cratis/ai.json
14
+ # allowDependencyManifestWrites (true allows, false blocks) decides, else its github.com/Cratis origin.
15
+ # The target repository can only tighten that: an explicit false, a non-Cratis origin without a setting,
16
+ # or no Git repository blocks; a target's true or Cratis origin never unlocks a blocking session.
17
+ # A session that cannot be determined blocks. Only manifests are affected; .env stays blocked.
14
18
  #
15
19
  # Escape hatch for the "unless explicitly asked" case — the user asks, you set it for the call:
16
20
  # CRATIS_HOOKS_ALLOW_PROTECTED_WRITES=1
@@ -374,9 +378,43 @@ agent_control_target() {
374
378
  }
375
379
 
376
380
  # ── Dependency manifests, lockfiles, SDK and NuGet configuration ──────────────
381
+ # Policy of one repository root: a boolean allowDependencyManifestWrites wins, else a github.com/Cratis origin.
382
+ repository_manifest_policy() {
383
+ local setting="" root="$1"
384
+ if [ -f "$root/.cratis/ai.json" ]; then
385
+ # Only actual booleans override the default; jq's `// empty` would discard false.
386
+ setting="$(jq -r '.allowDependencyManifestWrites | select(type == "boolean") | tostring' "$root/.cratis/ai.json" 2>/dev/null)" || parser_failed
387
+ fi
388
+ case "$setting" in
389
+ true) return 0 ;;
390
+ false) return 1 ;;
391
+ esac
392
+ repository_origin "$root"
393
+ # Anchor host, owner and the single repository segment; never infer ownership from profiles.
394
+ origin_matches '^(https://github\.com/|git@github\.com:|ssh://git@github\.com(:[0-9]+)?/)cratis/[a-z0-9_.-]+/?$'
395
+ }
396
+
397
+ # The session's policy, computed once. The session is fixed by the harness (CLAUDE_PROJECT_DIR, else the checkout
398
+ # holding this script), never by the write target, the payload cwd or the shell's working directory.
399
+ # Anything that cannot be determined blocks.
400
+ session_manifest_policy=""
401
+ session_manifests_allowed() {
402
+ if [ -z "$session_manifest_policy" ]; then
403
+ local session_root
404
+ session_manifest_policy=1
405
+ # A session the harness named but that is not a directory is undeterminable, never the script's checkout.
406
+ if [ -n "${CLAUDE_PROJECT_DIR:-}" ] && [ ! -d "$CLAUDE_PROJECT_DIR" ]; then return 1; fi
407
+ if session_root="$(hook_repo_root 2>/dev/null)" && session_root="$(git -C "$session_root" rev-parse --show-toplevel 2>/dev/null)"; then
408
+ if repository_manifest_policy "$session_root"; then session_manifest_policy=0; fi
409
+ fi
410
+ fi
411
+ return "$session_manifest_policy"
412
+ }
413
+
377
414
  manifest_writes_allowed() {
378
- local setting="" directory policy_root start="$PWD"
379
- # Authorization belongs to the write target, which may be outside the session's checkout.
415
+ local directory policy_root start="$PWD"
416
+ # The session decides first; the target is only consulted to tighten it.
417
+ session_manifests_allowed || return 1
380
418
  # New files can have nonexistent parents; find their nearest existing directory first.
381
419
  dir_of "$file"
382
420
  directory="$REPLY"
@@ -390,17 +428,7 @@ manifest_writes_allowed() {
390
428
  directory="$PWD"
391
429
  cd "$start" 2>/dev/null || true
392
430
  policy_root="$(git -C "$directory" rev-parse --show-toplevel 2>/dev/null)" || return 1
393
- if [ -f "$policy_root/.cratis/ai.json" ]; then
394
- # Only actual booleans override the default; jq's `// empty` would discard false.
395
- setting="$(jq -r '.allowDependencyManifestWrites | select(type == "boolean") | tostring' "$policy_root/.cratis/ai.json" 2>/dev/null)" || parser_failed
396
- fi
397
- case "$setting" in
398
- true) return 0 ;;
399
- false) return 1 ;;
400
- esac
401
- repository_origin "$policy_root"
402
- # Anchor host, owner and the single repository segment; never infer ownership from profiles.
403
- origin_matches '^(https://github\.com/|git@github\.com:|ssh://git@github\.com(:[0-9]+)?/)cratis/[a-z0-9_.-]+/?$'
431
+ repository_manifest_policy "$policy_root"
404
432
  }
405
433
 
406
434
  # Return the category, leaving normal Write/Edit diagnostics unchanged below.
@@ -16,7 +16,7 @@ Enforce a new rule on an existing command. Invoke the **cratis-arc-command-valid
16
16
  - Reusable value invariant → `ConceptValidator<T>`.
17
17
  - Command-input / cross-field / pre-handler rule → `CommandValidator<T>`.
18
18
  - Handler needs fetched data first → `Provide()`.
19
- - State rule that must hold **under concurrency** → new code sets read protection `On` (`<CratisReadProtection>On</CratisReadProtection>`): the read model is a `CommandValidator<T>` constructor parameter and `Handle()` returns the events; add `[LookUpBy]` for a second entity, a per-stream read model or `IStreamReads`/`StreamDecision` for one stream. `[ProtectedDecision]` with `DecisionRead<T>` is the older per-command opt-in. Under `Off` (the default) a validator over a plain read is a hint, and `Result<TEvent, ValidationResult>` alone adds no guard. Specify the business decision by calling `Handle()` or the validator directly with supplied read-model state. Follow `.cratis/ai/rules/specs.scenarios.csharp.md`: keep one cheap assembly-level shape-admission spec; the platform's concurrency/guard matrix belongs only in Arc/Chronicle specs.
19
+ - State rule that must hold **under concurrency** → read protection `On` (the default from Arc 23; on Arc 22 set `<CratisReadProtection>On</CratisReadProtection>`): the read model is a `CommandValidator<T>` constructor parameter and `Handle()` returns the events; add `[LookUpBy]` for a second entity, a per-stream read model or `IStreamReads`/`StreamDecision` for one stream. `[ProtectedDecision]` with `DecisionRead<T>` is the older per-command opt-in. Under `Off` (set explicitly, or the Arc 22 behavior) a validator over a plain read is a hint, and `Result<TEvent, ValidationResult>` alone adds no guard. Specify the business decision by calling `Handle()` or the validator directly with supplied read-model state. Follow `.cratis/ai/rules/specs.scenarios.csharp.md`: keep one cheap assembly-level shape-admission spec; the platform's concurrency/guard matrix belongs only in Arc/Chronicle specs.
20
20
  - Uniqueness → `[Unique]` / `IConstraint`.
21
21
 
22
22
  > **Never throw for normal business rejection** — a throw is HTTP 500, not a validation error. Recoverable rejection is a `ValidationResult` / `Result<,>`. Add a direct-call failure spec; a pipeline validation spec asserts both not-successful and has-validation-errors. The skill carries the detail; don't duplicate it here.
@@ -45,7 +45,7 @@ Commands are imperative intents (`Register`, `Create`); the slice folder is the
45
45
  Tagged **[contract]** (framework-enforced) or **[convention]** (house default). Mechanics and examples live in `vertical-slices.md`.
46
46
 
47
47
  1. **[contract] Model-bound — no controllers.** Commands are `[Command]` records with a public instance `Handle()` (Arc analyzers enforce this); queries are `static` methods on `[ReadModel]` records; projections/constraints/authorization use attributes. Arc generates the HTTP surface. For read-model style follow rule 11's ladder; for constraints use `IConstraint` when attributes cannot express the rule.
48
- 2. **[contract] Command validation & data flow.** Put command rejection in `CommandValidator<T>`, global value invariants in `ConceptValidator<T>`, and fetched/computed handler data in **`Provide()`** (runs after validation/authorization; may short-circuit with `ValidationResult.Error` / `Result<TProvided, ValidationResult>`). Keep `Handle()` focused on event construction. For a state-dependent rule that must hold **under concurrency**, start new code with read protection `On` (`<CratisReadProtection>On</CratisReadProtection>`): put the rule in a `CommandValidator<T>` with the read model as a constructor parameter and return the events from `Handle()`. Use a constraint for uniqueness, a per-stream read model or `IStreamReads`/`StreamDecision` for one stream, an aggregate for a rich lifecycle; `[ProtectedDecision]` with `DecisionRead<T>` is the older per-command opt-in. Under `Off` (the default when nothing is set) a validator over a plain read is a hint, not a guard. Return a typed rejection via `Result<TEvent, ValidationResult>` where needed; the result alone adds no guard. **Throwing from `Provide()`/`Handle()` is an exception (HTTP 500), not a validation rejection** — throw only for genuinely exceptional conditions, never for normal business rejection.
48
+ 2. **[contract] Command validation & data flow.** Put command rejection in `CommandValidator<T>`, global value invariants in `ConceptValidator<T>`, and fetched/computed handler data in **`Provide()`** (runs after validation/authorization; may short-circuit with `ValidationResult.Error` / `Result<TProvided, ValidationResult>`). Keep `Handle()` focused on event construction. For a state-dependent rule that must hold **under concurrency**, use read protection `On` (the default from Arc 23; on Arc 22 set `<CratisReadProtection>On</CratisReadProtection>`): put the rule in a `CommandValidator<T>` with the read model as a constructor parameter and return the events from `Handle()`. Use a constraint for uniqueness, a per-stream read model or `IStreamReads`/`StreamDecision` for one stream, an aggregate for a rich lifecycle; `[ProtectedDecision]` with `DecisionRead<T>` is the older per-command opt-in. Under `Off` (set explicitly, or the Arc 22 behavior) a validator over a plain read is a hint, not a guard. Return a typed rejection via `Result<TEvent, ValidationResult>` where needed; the result alone adds no guard. **Throwing from `Provide()`/`Handle()` is an exception (HTTP 500), not a validation rejection** — throw only for genuinely exceptional conditions, never for normal business rejection.
49
49
  3. **[contract] Event-source id resolution:** `ICanProvideEventSourceId` first; else the first qualifying property in declaration order — an `EventSourceId`/`EventSourceId<T>`-derived value *or* a `[Key]` property (no priority between them; two candidates is `ARCCHR0002`); else Arc generates one. A value actually used as a Chronicle stream identity derives from `EventSourceId<T>` with the underlying `IComparable` primitive — never `ConceptAs<Guid>` for that stream identity. `NotSet`, `New()`, and primitive→derived-id operators are optional domain/API conveniences, not Chronicle requirements; typed empty/zero values are real specified stream IDs, not `EventSourceId.Unspecified`.
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.
@@ -54,7 +54,7 @@ One precise line per load-bearing term, so the same word means the same thing ev
54
54
  - **Observation command** — a command whose input comes from outside the model's own decisions (webhook, poll, sweep, retry, classifier). It compares with current state and appends nothing when nothing changed; looking is not a fact.
55
55
  - **Signal event** — an event appended only to make a reactor do something (`…Requested`, `…Started`, `…Skipped`). Not a domain fact; use a job, state machine, command operation or `ICommandPipeline`.
56
56
  - **Constraint** — `IConstraint`; an **append-time** invariant (uniqueness / concurrency) enforced at the event-store level.
57
- - **DCB (Dynamic Consistency Boundary)** — enforcing a state-dependent rule under concurrency over explicitly enrolled event-state reads: read-model parameters under Arc read protection `On`, stream decisions/exact scopes, or protected, admitted projection decision reads. Plain injected models under `Off` (the default) and `Result<TEvent, ValidationResult>` alone are advisory, not a guard.
57
+ - **DCB (Dynamic Consistency Boundary)** — enforcing a state-dependent rule under concurrency over explicitly enrolled event-state reads: read-model parameters under Arc read protection `On`, stream decisions/exact scopes, or protected, admitted projection decision reads. Plain injected models under `Off` (set explicitly, or the Arc 22 behavior) and `Result<TEvent, ValidationResult>` alone are advisory, not a guard.
58
58
  - **Consistency boundary** — the scope within which an invariant holds atomically (an event source, a routed stream, or the event state enrolled by an admitted protected read).
59
59
  - **EventForEventSourceId** — self-describing wrapper to append an event to a **specific** (cross-stream) event source, from a command `Handle()` or from a reactor handler (reactor support has shipped since Chronicle 15.35). It carries the event stream type and id, source type, subject, occurred time, tags and causation, so it is also how a reactor sets those explicitly.
60
60
  - **ReactorDelivery** — the identity of one delivery of one event to one reactor partition; declare it as a handler parameter and Chronicle passes it in. Stable across a replay and across recovering a failed partition, so a receipt kept under its `Id` is what makes a side effect survive re-delivery. An identity, not a guarantee — Chronicle does not know whether the effect ran.
@@ -88,7 +88,7 @@ The command carries input from the caller. `Handle()` is defined directly on the
88
88
  | Reusable value invariant (length, format, range) | `ConceptValidator<T>` on the concept type |
89
89
  | Command-input / cross-field / pre-handler rule (incl. injected read-model/service/identity checks) | `CommandValidator<TCommand>` with `RuleFor(...)` |
90
90
  | Handler needs fetched/computed data before it can build the event | `Provide()` — fetches the data; may validate it and short-circuit |
91
- | State-dependent rule that must hold **under concurrency** | Read protection `On`: the read model as a `CommandValidator<T>` constructor (or `Handle()`) parameter; a per-stream read model or `IStreamReads`/`StreamDecision` for one stream; an aggregate for a rich lifecycle. `[ProtectedDecision]` + `DecisionRead<T>` is the older per-command opt-in. Under `Off` (default) injection is a hint |
91
+ | State-dependent rule that must hold **under concurrency** | Read protection `On`: the read model as a `CommandValidator<T>` constructor (or `Handle()`) parameter; a per-stream read model or `IStreamReads`/`StreamDecision` for one stream; an aggregate for a rich lifecycle. `[ProtectedDecision]` + `DecisionRead<T>` is the older per-command opt-in. Under `Off` (set explicitly, or the Arc 22 behavior) injection is a hint |
92
92
  | Uniqueness | Chronicle `[Unique]` / `IConstraint` (race-safe) — not a read-model pre-check |
93
93
  | Genuinely exceptional failure (bug, missing infra) | `throw` a domain exception |
94
94
 
@@ -182,7 +182,7 @@ Three attributes scope an append broad→narrow, and each one *also* (only with
182
182
 
183
183
  Each attribute always tags the appended events (visible in `EventContext`). **Only when the command also carries `concurrency: true`** does each dimension join the server-side `ConcurrencyScope` (plus the event source id), with the optimistic strategy supplying the expected tail sequence number. A command **without** `concurrency: true` contributes no scope of its own, and the append falls to whatever concurrency strategy the event sequence is configured with — by default the optimistic one, scoped to the event source. So the attribute chooses *which dimensions* bound the check, not whether a check happens at all. Reach for it on high-contention state transitions where a stale read would let two commands both "win" — it narrows the boundary so appends that are genuinely independent stop colliding (concurrency failures surface on `CommandResult`/`AppendResult`). Adopt it deliberately per behavior, not as a blanket default.
184
184
 
185
- New code sets `<CratisReadProtection>On</CratisReadProtection>` (Arc 22.106.0).
185
+ Read protection `On` is the default from Arc 23; on Arc 22 (22.106.0 or later) set `<CratisReadProtection>On</CratisReadProtection>`. A project that sets the property keeps its mode.
186
186
  Under `On`, a read-model parameter of `Handle()` or of a `CommandValidator<T>`
187
187
  constructor is read fresh and guards the append; the state rule goes in the
188
188
  validator. Two entities: two parameters, `[LookUpBy(nameof(Cmd.Prop))]` on the
@@ -193,7 +193,7 @@ routed with `[EventSource<TSource>("Stream")]` and `[EventStreamId("{Prop}")]`,
193
193
  A deliberate advisory read is `[Unprotected("why")]`. Models must be admitted
194
194
  (source-keyed projection with a string or Guid `Id`, or an unfiltered reducer
195
195
  without constructor dependencies); joins, children and event-property keys are
196
- refused. Under `Off` (the default) injection and keyed reads are advisory,
196
+ refused. Under `Off` (set explicitly, or the Arc 22 behavior) injection and keyed reads are advisory,
197
197
  including in `Handle()`; `[ProtectedDecision]` + `DecisionRead<T>` is the older
198
198
  per-command opt-in and still works. Exact returned scopes replace automatic
199
199
  `concurrency: true` capture. Refusals: [choosing how a rule holds](../skills/cratis-chronicle-decision-reads/references/choosing-how-a-rule-holds.md).
@@ -170,7 +170,7 @@ Authorization runs before validation, so a caller who may not act never reaches
170
170
  validator. Express who may act through policies, roles and `[Authorize]`, not a
171
171
  validator. A state rule ("the order is still open") belongs in a
172
172
  `CommandValidator<T>` with the read model as a constructor parameter; under read
173
- protection `On` that read guards the append, under `Off` (the default) it is a
173
+ protection `On` that read guards the append, under `Off` (set explicitly, or the Arc 22 behavior) it is a
174
174
  hint, and in an `[Unprotected]` command it is advisory. A state-dependent
175
175
  permission or ownership rule (this member owns the order) may sit there too, with
176
176
  the same limit. Under `[ProtectedDecision]` without `On`, only a parameterless
@@ -404,7 +404,7 @@ privileged.
404
404
  Under read protection `On`, the read models in a convention-registered
405
405
  `CommandValidator<T>` constructor are read fresh and guard the command's append, so
406
406
  a state-dependent permission or ownership rule written there is decision-safe. Under
407
- `Off` (the default) and `Measure` the same validator reads a plain model: a hint. In
407
+ `Off` (set explicitly, or the Arc 22 behavior) and `Measure` the same validator reads a plain model: a hint. In
408
408
  an `[Unprotected]` command (or a model or method marked `[Unprotected("why")]`) the
409
409
  read is advisory, so the rule is **not decision-safe**. A `[ProtectedDecision]`
410
410
  command without `On` runs only certified, parameterless validators and refuses a
@@ -176,7 +176,7 @@ silently takes the first declared. Implement `ICanProvideEventSourceId`.
176
176
  Read [decisions and routing](references/decisions-and-routing.md) when a command
177
177
  needs guarded state, stream-id templates, definition-backed routes, event tags or
178
178
  post-commit `CompleteStream`. A read-model parameter guards the append only under
179
- read protection `On`; under `Off` (the default) it is advisory. `Result<,>` and
179
+ read protection `On`; under `Off` (set explicitly, or the Arc 22 behavior) it is advisory. `Result<,>` and
180
180
  `concurrency: true` are not protection; see
181
181
  [choosing how a rule holds](../cratis-chronicle-decision-reads/references/choosing-how-a-rule-holds.md).
182
182
  A returned `EventForEventSourceId` route wins over command context.
@@ -25,8 +25,8 @@ Arc will pin protected parameters so the idiomatic shape needs no further ceremo
25
25
  Under read protection `On` (`<CratisReadProtection>On</CratisReadProtection>`, or
26
26
  `[ReadProtection(ReadProtectionMode.On)]` on a command), a read model that is a
27
27
  parameter of `Handle()` or of a `CommandValidator<T>` constructor is read fresh from
28
- the event log and guards the command's append. `Off` is the default when nothing is
29
- set; under `Off` and `Measure` those reads are plain, a hint that guards nothing.
28
+ the event log and guards the command's append. `On` is the default from Arc 23 when nothing is
29
+ set (`Off` was the Arc 22 behavior); under `Off` and `Measure` those reads are plain, a hint that guards nothing.
30
30
  A `Result<TEvent, ValidationResult>` rejects a request but does not enroll a guard.
31
31
  Uniqueness and create-once belong to a Chronicle constraint, not to any read. For the
32
32
  routing by rule shape, the matrix and the traps read
@@ -7,7 +7,7 @@
7
7
  - Which provider owns a read model type
8
8
 
9
9
  Source: [read models in commands](https://github.com/Cratis/Arc/blob/main/Documentation/backend/csharp/chronicle/read-models/injecting-into-commands.md).
10
- Under read protection `Off` (the default) and `Measure`, injected models and keyed
10
+ Under read protection `Off` (set explicitly, or the Arc 22 behavior) and `Measure`, injected models and keyed
11
11
  reads are plain reads, not concurrency guards. Under `On`, a read-model parameter of
12
12
  `Handle()` or a validator constructor is guarded; `IReadModels.GetInstanceById` in a
13
13
  command is refused, so read another entity's model with a second parameter and
@@ -60,7 +60,7 @@ Which mechanism makes a rule hold under concurrent writers (constraint, protecte
60
60
  decision, stream decision, aggregate, scope, reactor repair) is routed in
61
61
  [choosing how a rule holds](../cratis-chronicle-decision-reads/references/choosing-how-a-rule-holds.md).
62
62
  A validator holds a state rule only when the project is on read protection `On`;
63
- under `Off` (the default) it is a hint, never the mechanism.
63
+ under `Off` (set explicitly, or the Arc 22 behavior) it is a hint, never the mechanism.
64
64
 
65
65
  | The rule is… | Put it in |
66
66
  | --- | --- |
@@ -123,8 +123,8 @@ public class TransferFundsValidator : CommandValidator<TransferFunds>
123
123
  Step 5. **State rules ("may this proceed") belong here**, with the read model as a
124
124
  constructor parameter. Under read protection `On` that read is fresh from the log
125
125
  and guards the append: if an event of the model's types for that key arrives
126
- after the read, nothing from the command is written. Under `Off` (the default
127
- when nothing is set) and `Measure` the same validator reads a plain model: a hint
126
+ after the read, nothing from the command is written. Under `Off` (set explicitly,
127
+ or the Arc 22 behavior) and `Measure` the same validator reads a plain model: a hint
128
128
  with a friendly message that guards nothing. Under `On` the validator must be
129
129
  convention-registered (transient); hand-registered scoped, singleton, factory or
130
130
  instance validators are refused. Under `[ProtectedDecision]` without `On`, a
@@ -175,11 +175,12 @@ public async Task<Result<Customer, ValidationResult>> Provide(IReadModels readMo
175
175
 
176
176
  ## Step 5 — Guard a concurrency-sensitive decision
177
177
 
178
- Set read protection `On` for new code: `<CratisReadProtection>On</CratisReadProtection>`
178
+ Read protection `On` is the default from Arc 23; on Arc 22 set
179
+ `<CratisReadProtection>On</CratisReadProtection>`
179
180
  in the project (or `[ReadProtection(ReadProtectionMode.On)]` on one command). Under
180
181
  `On`, the read-model parameters of `Handle()` and of the validator constructor are
181
182
  the guard, so the state rule is a validator and `Handle()` returns the events.
182
- Requires Arc 22.106.0. Under `Off` (the default) a plain read guards nothing, even
183
+ Requires Arc 22.106.0. Under `Off` (set explicitly, or the Arc 22 behavior) a plain read guards nothing, even
183
184
  inside `Handle()` returning `Result<,>`. Choose the first boundary that fits:
184
185
 
185
186
  1. A unique value or create-once: a Chronicle constraint, not a read.
@@ -303,7 +304,7 @@ the fact. See
303
304
  - **The rule never fires.** The read-model type has no backing Chronicle
304
305
  projection, reducer, `DbSet<T>`, or MongoDB collection, so nothing registered
305
306
  it for command-side resolution.
306
- - **Two requests both win.** The project is on `Off` (the default) or `Measure`, so
307
+ - **Two requests both win.** The project is on `Off` (set explicitly, or Arc 22) or `Measure`, so
307
308
  the validator read is a hint; moving it to `Handle()` or returning `Result<,>`
308
309
  does not guard it. Set `On`, or use a stream decision or a constraint.
309
310
  - **`ARC0005` on build.** `Provide()` returns a value no `Handle()` parameter
@@ -20,9 +20,8 @@ when the question is which mechanism to use, or before writing code that reads
20
20
  state and then appends. It carries the routing by rule shape, the matrix with what
21
21
  not to use, the refusals, rollout with Measure, testing and the traps.
22
22
 
23
- In an Arc application new code sets read protection `On`
24
- (`<CratisReadProtection>On</CratisReadProtection>`); `Off` is the default when
25
- nothing is set. Under `On` the read model is a parameter of `Handle()` or of the
23
+ In an Arc application using `Cratis.Arc.Chronicle`, read protection `On` is the default from Arc 23 (on Arc 22 set
24
+ `<CratisReadProtection>On</CratisReadProtection>`; `Off` was the Arc 22 behavior). Under `On` the read model is a parameter of `Handle()` or of the
26
25
  `CommandValidator<T>` constructor, and the read guards the append; under `Off` and
27
26
  `Measure` a validator over a plain read is a hint that guards nothing. A plain read under
28
27
  `Off`, `Result<,>` and `concurrency: true` are never the guard.
@@ -183,8 +182,8 @@ deciding writer is guarded or the rule is a constraint.
183
182
  - The unit commits in the ASP.NET Core middleware: it commits after the response
184
183
  and reports no concurrency violation. Call
185
184
  `IUnitOfWorkCompletionFeature.CommitAsync()` before responding.
186
- - Arc under `Off` (the default when nothing is set): a command with a read model
187
- is unguarded unless it carries `[ProtectedDecision]`. Set `On` for new code.
185
+ - Arc under `Off` (set explicitly, or the Arc 22 behavior): a command with a read model
186
+ is unguarded unless it carries `[ProtectedDecision]`. `On` is the default from Arc 23.
188
187
 
189
188
  ## Verify
190
189
 
@@ -31,8 +31,9 @@ Published guides this agrees with:
31
31
 
32
32
  ## Defaults
33
33
 
34
- - Read protection is `Off` unless the project sets it. New code starts with
35
- `On`: `<CratisReadProtection>On</CratisReadProtection>` in the project (it
34
+ - Read protection is `On` unless the project sets it (the default from Arc 23;
35
+ `Off` was the Arc 22 behavior). On Arc 22 set
36
+ `<CratisReadProtection>On</CratisReadProtection>` in the project (it
36
37
  emits `[assembly: ReadProtection(ReadProtectionMode.On)]`; an invalid value
37
38
  fails the build). Existing code moves `Off` to `Measure` to `On`; see
38
39
  [Roll out with Measure](#roll-out-with-measure).
@@ -107,7 +108,7 @@ append, a reactor, or an `ExpectedRevision` never passed into a scope.
107
108
 
108
109
  | Mode | Read-model parameter, validator constructor | Results and status codes |
109
110
  | --- | --- | --- |
110
- | `Off` (default) | plain read; a hint, guards nothing | as today |
111
+ | `Off` (Arc 22 behavior, or set explicitly) | plain read; a hint, guards nothing | as today |
111
112
  | `Measure` | plain read; Arc reports what `On` would do | same as `Off` |
112
113
  | `On` | read fresh from the log; guards the command's append | a lost race is HTTP 400 |
113
114
 
@@ -336,7 +337,7 @@ append. Decision reads exist in the .NET and Elixir clients.
336
337
  - Name the mechanism and say why the rule shape needs it. A plain read, a
337
338
  validator under `Off`, `Result<,>` or `concurrency: true` is never presented as
338
339
  the guard.
339
- - New code sets `On`. Uniqueness is a constraint. A state rule is a read-model
340
+ - `On` is the default from Arc 23 (set it on Arc 22). Uniqueness is a constraint. A state rule is a read-model
340
341
  parameter in a validator, a per-stream model, a stream decision, an aggregate or
341
342
  an explicit scope, enrolled **before** the events are staged.
342
343
  - The model is admitted (source-keyed projection or admitted reducer, `Id`).
@@ -56,7 +56,7 @@ memory.
56
56
  - The rule is state-dependent (a count, a capacity, a status) and needs
57
57
  concurrency protection: use read protection `On` or stream decision reads with
58
58
  `cratis-arc-command-validation` and `cratis-chronicle-decision-reads`. Injected
59
- models and validators under `Off` (the default), and `Result<,>` alone, remain advisory.
59
+ models and validators under `Off` (set explicitly, or the Arc 22 behavior), and `Result<,>` alone, remain advisory.
60
60
  - You are creating or changing a read model that the rule reads: use
61
61
  `cratis-chronicle-read-model`.
62
62
  - You are writing the specification and want the `EventScenario` mechanics in
@@ -84,7 +84,7 @@ there is nothing to review under a red build.
84
84
  - Logging lives in a `*Logging.cs` partial with `[LoggerMessage]`, not inline in
85
85
  domain code.
86
86
  - No shared mutable state between commands.
87
- - Read protection is `Off` by default; new code sets `<CratisReadProtection>On</CratisReadProtection>`.
87
+ - Read protection is `On` by default from Arc 23; on Arc 22 new code sets `<CratisReadProtection>On</CratisReadProtection>`.
88
88
  Under `Off` an injected model or validator read is advisory, not a concurrency guard.
89
89
  Under `On`, review that state rules sit in validators or handlers with the model as
90
90
  a parameter and `[Unprotected("why")]` carries a real reason. Apply
@@ -108,7 +108,7 @@ another event source) in `Provide()`/`Handle()` and returning a validation resul
108
108
  at commit is reported as a concurrency violation. Equivalently a Chronicle decision-consistency
109
109
  read with a `concurrency` scope on the event source or stream. A passive read is fresh
110
110
  computation, not an atomic read-and-append; a plain materialized view and a validator are
111
- advisory under Arc read protection `Off` (the default); under `On` (Arc 22.106.0 or later) the read
111
+ advisory under Arc read protection `Off` (set explicitly, or the Arc 22 behavior); `On` is the default from Arc 23 (Arc 22.106.0 or later can set it) and the read
112
112
  model parameters of `Handle()` and of a validator constructor are guarded. Protection covers a single
113
113
  projection keyed directly by the event source id (routing key empty or `$eventSourceId`) and an
114
114
  unfiltered reducer without constructor dependencies. Filtered reducers, reducers with dependencies,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/pi",
3
- "version": "7.170.10",
3
+ "version": "7.170.12",
4
4
  "description": "Configuration-aware Cratis AI integration for Pi",
5
5
  "type": "module",
6
6
  "files": [