@cratis/pi 7.176.0 → 7.177.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.
- package/package/corpus/agents/frontend-developer.md +2 -0
- package/package/corpus/agents/spec-writer.md +3 -3
- package/package/corpus/harnesses/copilot/instructions/components.instructions.md +4 -4
- package/package/corpus/harnesses/copilot/instructions/react.instructions.md +3 -21
- package/package/corpus/harnesses/copilot/instructions/specs.csharp.instructions.md +1 -1
- package/package/corpus/harnesses/copilot/instructions/specs.scenarios.csharp.instructions.md +5 -5
- package/package/corpus/harnesses/pi/agents/frontend-developer.md +2 -0
- package/package/corpus/harnesses/pi/agents/spec-writer.md +3 -3
- package/package/corpus/rules/components.md +4 -4
- package/package/corpus/rules/react.md +3 -21
- package/package/corpus/rules/specs.csharp.md +1 -1
- package/package/corpus/rules/specs.scenarios.csharp.md +5 -5
- package/package/corpus/skills/cratis-application-slice-specifications/SKILL.md +16 -13
- package/package/corpus/skills/cratis-application-slice-specifications/references/query-and-decision-scenarios.md +73 -26
- package/package/corpus/skills/cratis-arc-command/references/command-result.md +69 -17
- package/package/corpus/skills/cratis-arc-command/references/decisions-and-routing.md +16 -13
- package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +10 -5
- package/package/corpus/skills/cratis-arc-react-page/SKILL.md +27 -8
- package/package/corpus/skills/cratis-arc-react-page/references/availability.md +65 -0
- package/package/corpus/skills/cratis-arc-react-page/references/data-page.md +78 -8
- package/package/corpus/skills/cratis-arc-react-page/references/dialogs.md +24 -0
- package/package/corpus/skills/cratis-arc-react-page/references/queries-and-commands.md +17 -45
- package/package/corpus/skills/cratis-chronicle-decision-reads/SKILL.md +11 -6
- package/package/corpus/skills/cratis-chronicle-decision-reads/references/choosing-how-a-rule-holds.md +17 -14
- package/package/corpus/skills/cratis-code-review/SKILL.md +5 -1
- package/package/corpus/skills/cratis-specifications-csharp/SKILL.md +12 -11
- package/package/corpus/skills/cratis-specifications-csharp/references/running-specs.md +62 -4
- package/package.json +1 -1
|
@@ -104,6 +104,8 @@ const handleSubmit = async () => {
|
|
|
104
104
|
|
|
105
105
|
---
|
|
106
106
|
|
|
107
|
+
Before handling command failures, read `.cratis/ai/skills/cratis-arc-command/references/command-result.md` for the complete result decision table, protected-read recovery and safe feedback. The success-only example above is not a failure-handling policy.
|
|
108
|
+
|
|
107
109
|
## Query usage pattern (with paging)
|
|
108
110
|
|
|
109
111
|
```tsx
|
|
@@ -46,7 +46,7 @@ Select from these canonical rules in `.cratis/ai/rules/` only after applying the
|
|
|
46
46
|
|
|
47
47
|
## C# specs — start with the plain call
|
|
48
48
|
|
|
49
|
-
Specify pure `Handle()`, validator, reducer and reactor decisions with plain calls and supplied read-model state. Follow `.cratis/ai/rules/specs.scenarios.csharp.md`: add exactly the scenarios its per-artifact decision table obligates (pipeline and authorization, constraints, projection and reducer dispatch, reactor dispatch and routing), not a platform guard matrix. Prove
|
|
49
|
+
Specify pure `Handle()`, validator, reducer and reactor decisions with plain calls and supplied read-model state. Follow `.cratis/ai/rules/specs.scenarios.csharp.md`: add exactly the scenarios its per-artifact decision table obligates (pipeline and authorization, constraints, projection and reducer dispatch, reactor dispatch and routing), not a platform guard matrix. Prove ordinary concurrent-writer decisions, such as the last seat, from supplied read-model state, not a replay of the platform matrix. Keep one assembly-level admission check for discoverable application shapes; explicit body reads need their own admission check or focused scenario. Typed scenarios select decision reads automatically; `UseDecisionReads()` is obsolete. For an unusual application-owned explicit guard policy, use only a focused regression a plain call cannot prove. See [decision guidance](../skills/cratis-application-slice-specifications/references/query-and-decision-scenarios.md) for the example, limits and advanced hook boundary; never weaken production guards for speed. Prefer in-process helpers over out-of-process Chronicle hosts for the applicable behaviors:
|
|
50
50
|
|
|
51
51
|
| Tool | Use for |
|
|
52
52
|
|---|---|
|
|
@@ -97,7 +97,7 @@ public class and_all_information_is_valid : Specification
|
|
|
97
97
|
0. **Every contract specification first** — one spec each, named after it, using the contract's example values. Then add the code-derived cases below that the contract lacks and report them as proposals for the contract (the `.play` model when one covers the slice, otherwise the agreed outline); never present them as contract coverage. A `.play` specification maps to a plain-call spec for a pure decision, with a scenario added only for the pipeline composition it proves (never a simulated race); never edit, skip or delete a spec derived from the contract to make code pass — change the code or return an edit request.
|
|
98
98
|
1. **Happy path** — succeeds, correct event(s) appended.
|
|
99
99
|
2. **Each validation failure** — call the validator directly with supplied state; pipeline validation specs assert **both** `ShouldNotBeSuccessful()` and `ShouldHaveValidationErrors()`. Do not assert on message strings by default; assert exact text only when that wording is the specified behavior, and name that behavior in the fact. Violate **only** the rule the spec is named after (build the command valid in every other respect), or a neighbouring rule makes it pass.
|
|
100
|
-
3. **Business-rule violations** — call
|
|
100
|
+
3. **Business-rule violations** — call the validator directly with the required model state and assert each rejection; `Provide()` acquires data and only short-circuits (`ValidationResult`/`AuthorizationResult`) when acquisition yields nothing usable, not for ordinary validation rules. Arc/Chronicle specs own platform concurrency, conflict refusal and isolation. Keep the assembly-level shape-admission check and any explicit-body-read checks above; do not repeat guard scenarios per decision.
|
|
101
101
|
4. **Constraint violations** — `ShouldHaveConstraintViolationFor(name)` via `EventScenario`.
|
|
102
102
|
5. **Authorization** — `ShouldNotBeAuthorized()` (an unauthorized result has no validation errors).
|
|
103
103
|
6. **Repeat execution**, when a reactor invokes the command — the same command twice for the same source; specify whether the second is rejected, a no-op, or appends again.
|
|
@@ -163,4 +163,4 @@ Before handing back:
|
|
|
163
163
|
- `Status: done | partial | blocked` (meanings in **cratis-application-slice-conformance**).
|
|
164
164
|
- Specification map: contract specification → spec class; code-derived extras listed separately as proposals.
|
|
165
165
|
- The contract used (`.play` slice path or agreed outline).
|
|
166
|
-
- Spec results (pending or unexecuted specs named honestly), and any open question or model edit request.
|
|
166
|
+
- Spec results (pending or unexecuted specs named honestly), naming the assembly-level admission check, any explicit-body-read checks or focused policy regression, and any open question, harness gap or model edit request.
|
|
@@ -40,8 +40,8 @@ The package root exports **only** setup (`CratisComponentsProvider`, configurati
|
|
|
40
40
|
| CSS foundation / area sheets | layer order / structural CSS | `@cratis/components/styles/base`, `<subpath>/styles` |
|
|
41
41
|
| Shared types | `JsonSchema`, `Json`, … | `@cratis/components/types` |
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
`>=20.3.1 <
|
|
43
|
+
The declared peers for React and React DOM are `^19.0.0`, Arc and Arc React are
|
|
44
|
+
`>=20.3.1 <24`, Fundamentals is `^7.10.3`, and `reflect-metadata` `0.2.2` is required
|
|
45
45
|
(import it at the entry point). `tsyringe` `4.10.0` is optional for Components;
|
|
46
46
|
Arc React installs it. `Canvas` and `PivotViewer` need the optional `pixi.js ^8.20.0`
|
|
47
47
|
peer; ordinary pages do not. No `motion-dom` or `motion-utils` resolution pin is needed.
|
|
@@ -126,8 +126,8 @@ import { DataPage, MenuItem, Column } from '@cratis/components/DataPage';
|
|
|
126
126
|
|
|
127
127
|
`MenuItem` is a declarative Components element read by `DataPage.MenuItems` (use `command`, not
|
|
128
128
|
`onClick`); `disableOnUnselected` greys it out until a row is selected; its `icon` is a **React
|
|
129
|
-
component type** (e.g. a `react-icons` icon), not an `Icon`.
|
|
130
|
-
|
|
129
|
+
component type** (e.g. a `react-icons` icon), not an `Icon`.
|
|
130
|
+
Read the **cratis-arc-react-page** skill's `references/data-page.md` for typed menu selection, reconciliation, search/server mapping and `landmark`.
|
|
131
131
|
|
|
132
132
|
## Composition over Monoliths
|
|
133
133
|
|
|
@@ -133,28 +133,10 @@ const result = await command.execute();
|
|
|
133
133
|
|
|
134
134
|
Inside dialogs, use `CommandDialog` + CommandForm fields rather than driving the command by hand — see [dialogs.md](./dialogs.instructions.md).
|
|
135
135
|
|
|
136
|
-
### Read
|
|
136
|
+
### Read command outcomes before choosing feedback
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
| `isSuccess` | `isAuthorized && isValid && !hasExceptions` | happy path |
|
|
141
|
-
| `isAuthorized` | `[Roles]`/policy rejected | redirect to login / "not allowed" |
|
|
142
|
-
| `isValid` | validation failed — `validationResults` has per-field messages | render inline field errors |
|
|
143
|
-
| `hasExceptions` | `Provide()`/`Handle()` threw — `exceptionMessages` carry diagnostics | generic error toast + log; never show stack traces |
|
|
144
|
-
|
|
145
|
-
`CommandDialog` handles all of this automatically; the flags matter most when executing a command **outside** a dialog. `validate()` returns the same shape with `response == null` (handler did not run). `result.validationResults` is a `ValidationResult[]` of `{ severity, message, members: string[], state, reason, reasonDetail? }` — `members` names the affected properties — render per-field UI from it, but **never branch on raw `.message` text**. `exceptionMessages`/`exceptionStackTrace` are for logging, never for users.
|
|
146
|
-
|
|
147
|
-
Out-of-dialog execution branches in this order:
|
|
148
|
-
|
|
149
|
-
```tsx
|
|
150
|
-
const result = await command.execute();
|
|
151
|
-
if (!result.isAuthorized) { redirectToLogin(); return; }
|
|
152
|
-
if (!result.isValid) { /* validationResults → inline field errors */ return; }
|
|
153
|
-
if (result.hasExceptions) { toast.error({ title: 'Something went wrong' }); console.error(result.exceptionMessages); return; }
|
|
154
|
-
// happy path — refresh queries, close, etc.
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
`toastCommandResult(result, opts)` from `@cratis/components/Notifications` collapses this whole branch into one call (with a `<Toaster />` mounted) — success/not-authorized/validation/exception → the right toast, no stack traces shown.
|
|
138
|
+
Read `.cratis/ai/skills/cratis-arc-command/references/command-result.md` for the complete result decision table, protected-read refusals and message safety; do not replace it with an `isSuccess`-only branch.
|
|
139
|
+
Read the **cratis-arc-react-page** skill's `references/queries-and-commands.md` for `/validate` feedback under read protection, and `references/availability.md` for presentation-only availability.
|
|
158
140
|
|
|
159
141
|
### Command helpers
|
|
160
142
|
|
|
@@ -18,7 +18,7 @@ Extends the base [specs.md](./specs.instructions.md) (folder structure, naming,
|
|
|
18
18
|
|
|
19
19
|
## Frameworks
|
|
20
20
|
|
|
21
|
-
- [xUnit v3](https://xunit.net/docs/getting-started/v3/migration) is the house default for new and migrated spec projects
|
|
21
|
+
- [xUnit v3](https://xunit.net/docs/getting-started/v3/migration) is the house default for new and migrated spec projects **run as the built executable** ([loop](../../../skills/cratis-specifications-csharp/references/running-specs.md#local-loop)); through `dotnet test` it can be slower (reported measurement). Reference `Cratis.Specifications.XUnit.v3` **5.0** with `xunit.v3.mtp-off`, `Microsoft.NET.Test.Sdk` and `xunit.runner.visualstudio`, and set `<OutputType>Exe</OutputType>` in the project. The package supplies the `Specification` base, convention lifecycle and `ShouldXxx` assertions; the namespace remains `Cratis.Specifications`. Its `Cratis.Specifications` dependency supplies `Catch` and `SpecificationMethods`.
|
|
22
22
|
- 5.0 targets `net10.0` only. A spec project that must stay on net8.0/net9.0 stays on 4.x, and net48 on 3.x. A project that stays on xUnit v2 uses `Cratis.Specifications.XUnit`, with the same base and conventions.
|
|
23
23
|
- `.NUnit`/`.NUnit5`, `.TUnit` and the experimental `.Runner` are alternatives for repositories already built on them.
|
|
24
24
|
- [NSubstitute](https://nsubstitute.github.io/) for mocking collaborators.
|
package/package/corpus/harnesses/copilot/instructions/specs.scenarios.csharp.instructions.md
CHANGED
|
@@ -15,15 +15,15 @@ Specs are **mandatory for every slice type**, including reactors.
|
|
|
15
15
|
|
|
16
16
|
## Start with the plain call; add a scenario where it adds proof
|
|
17
17
|
|
|
18
|
-
Call pure `Handle()`, validators, reducers and reactor decisions directly with their inputs, including read-model state. Add a scenario
|
|
18
|
+
Call pure `Handle()`, validators, reducers and reactor decisions directly with their inputs, including read-model state. Add a scenario for the wiring the decision table below obligates (pipeline and authorization, constraints, projection and reducer dispatch, reactor dispatch and routing). Do not repeat every decision through the pipeline; name the extra behavior each scenario proves.
|
|
19
19
|
|
|
20
|
-
**Decision table — apply it per artifact, without judgment.** A plain call proves the decision; a scenario is a coverage obligation for the wiring only the framework proves. These are obligations, not quotas: add a scenario for each behavior listed
|
|
20
|
+
**Decision table — apply it per artifact, without judgment.** A plain call proves the decision; a scenario is a coverage obligation for the wiring only the framework proves. These are obligations, not quotas: add a scenario for each behavior listed; only the explicit-policy exceptions below add guard scenarios.
|
|
21
21
|
|
|
22
22
|
| Artifact | Plain call (`Specification`) | Scenario obligation |
|
|
23
23
|
|---|---|---|
|
|
24
|
-
| Command with a pure `Handle(…)` | every outcome and rejection branch, with read-model state supplied | the pipeline path once (`CommandScenario`: discovery, DI, event source, appended events), plus a **negative proof for each wiring that can refuse before `Handle`**: authorization denies (`ShouldNotBeAuthorized`), validation rejects, `Provide()` short-circuits |
|
|
24
|
+
| Command with a pure `Handle(…)` | every outcome and rejection branch, with read-model state supplied | the pipeline path once (`CommandScenario`: discovery, DI, event source, appended events), plus a **negative proof for each wiring that can refuse before `Handle`**: authorization denies (`ShouldNotBeAuthorized`), validation rejects, `Provide()` short-circuits when acquisition yields nothing usable |
|
|
25
25
|
| `Handle` that needs `IEventStore`, `IReadModels` or services | none: do not substitute the store | keep the scenario; when touched, take the read model as a `Handle` parameter and use the row above |
|
|
26
|
-
| `CommandValidator`, `ConceptValidator
|
|
26
|
+
| `CommandValidator`, `ConceptValidator`; `Provide()` acquisition/derived values | each validator rule, provided value and acquisition-failure result, built with its state | the command's pipeline scenarios prove the wiring |
|
|
27
27
|
| Constraint (`[Unique]`, `IConstraint`) | none | an `EventScenario` per constraint: the violation and the nearest non-violation |
|
|
28
28
|
| Projection or read model | none | `ReadModelScenario` against the real engine, covering **each event, key, join, children and removal the projection declares**: one class per read model with one shared event sequence by default; add a class only for a sequence that cannot share it (a removal, another key) |
|
|
29
29
|
| Reducer | each transition: `Model.Reduce(event, current[, context])` | a `ReadModelScenario` for dispatch, filters and stream routing |
|
|
@@ -54,7 +54,7 @@ public class and_the_caller_is_not_a_maintainer : Specification
|
|
|
54
54
|
|
|
55
55
|
An unauthenticated scenario against an `[Authorize]`/`[Roles]` command is denied before `Handle`; pair it with the happy-path scenario that registers an allowed identity in `_scenario.Services`.
|
|
56
56
|
|
|
57
|
-
**Application
|
|
57
|
+
**Application decisions (judgment-shaped).** Supply read-model state to plain `Handle()`/validator calls; validators own refusals; `Provide()` only short-circuits (`ValidationResult`/`AuthorizationResult`) when acquisition yields nothing usable, not for ordinary validation rules. Keep one assembly-level `DecisionReadAdmissions.ShouldAdmitDecisionReadsIn(assembly)` check of discoverable application shapes, not per-decision guard scenarios. Ordinary application specs do not re-prove Arc/Chronicle's platform matrix. For an unusual application-owned explicit guard policy — hand-built `EventsWithConcurrencyScopes` or deliberately unguarded `[Unprotected]` reads — use a focused regression only when a plain call cannot prove it; see [decision specifications](../../../skills/cratis-application-slice-specifications/references/query-and-decision-scenarios.md) for admission limits and the advanced hook's boundary. Never weaken production guards for speed; report harness gaps upstream.
|
|
58
58
|
|
|
59
59
|
**Share setup and budget cost (judgment-shaped).** Keep shared lifecycle on; use `[PerFactSpecificationLifecycle]` only on a class whose facts genuinely mutate shared state and cannot move that mutation into `Because`. Plain decision specs should take roughly milliseconds; measure scenario facts and justify seconds by the extra behavior they prove. Compare TRX durations and suite wall time with unchanged concurrency; see [running-specs.md](../../../skills/cratis-specifications-csharp/references/running-specs.md). Do not multiply scenario startup by splitting assertions into classes or opting the project out of shared lifecycle.
|
|
60
60
|
|
|
@@ -99,6 +99,8 @@ const handleSubmit = async () => {
|
|
|
99
99
|
|
|
100
100
|
---
|
|
101
101
|
|
|
102
|
+
Before handling command failures, read `.cratis/ai/skills/cratis-arc-command/references/command-result.md` for the complete result decision table, protected-read recovery and safe feedback. The success-only example above is not a failure-handling policy.
|
|
103
|
+
|
|
102
104
|
## Query usage pattern (with paging)
|
|
103
105
|
|
|
104
106
|
```tsx
|
|
@@ -41,7 +41,7 @@ Select from these canonical rules in `.cratis/ai/rules/` only after applying the
|
|
|
41
41
|
|
|
42
42
|
## C# specs — start with the plain call
|
|
43
43
|
|
|
44
|
-
Specify pure `Handle()`, validator, reducer and reactor decisions with plain calls and supplied read-model state. Follow `.cratis/ai/rules/specs.scenarios.csharp.md`: add exactly the scenarios its per-artifact decision table obligates (pipeline and authorization, constraints, projection and reducer dispatch, reactor dispatch and routing), not a platform guard matrix. Prove
|
|
44
|
+
Specify pure `Handle()`, validator, reducer and reactor decisions with plain calls and supplied read-model state. Follow `.cratis/ai/rules/specs.scenarios.csharp.md`: add exactly the scenarios its per-artifact decision table obligates (pipeline and authorization, constraints, projection and reducer dispatch, reactor dispatch and routing), not a platform guard matrix. Prove ordinary concurrent-writer decisions, such as the last seat, from supplied read-model state, not a replay of the platform matrix. Keep one assembly-level admission check for discoverable application shapes; explicit body reads need their own admission check or focused scenario. Typed scenarios select decision reads automatically; `UseDecisionReads()` is obsolete. For an unusual application-owned explicit guard policy, use only a focused regression a plain call cannot prove. See [decision guidance](../skills/cratis-application-slice-specifications/references/query-and-decision-scenarios.md) for the example, limits and advanced hook boundary; never weaken production guards for speed. Prefer in-process helpers over out-of-process Chronicle hosts for the applicable behaviors:
|
|
45
45
|
|
|
46
46
|
| Tool | Use for |
|
|
47
47
|
|---|---|
|
|
@@ -92,7 +92,7 @@ public class and_all_information_is_valid : Specification
|
|
|
92
92
|
0. **Every contract specification first** — one spec each, named after it, using the contract's example values. Then add the code-derived cases below that the contract lacks and report them as proposals for the contract (the `.play` model when one covers the slice, otherwise the agreed outline); never present them as contract coverage. A `.play` specification maps to a plain-call spec for a pure decision, with a scenario added only for the pipeline composition it proves (never a simulated race); never edit, skip or delete a spec derived from the contract to make code pass — change the code or return an edit request.
|
|
93
93
|
1. **Happy path** — succeeds, correct event(s) appended.
|
|
94
94
|
2. **Each validation failure** — call the validator directly with supplied state; pipeline validation specs assert **both** `ShouldNotBeSuccessful()` and `ShouldHaveValidationErrors()`. Do not assert on message strings by default; assert exact text only when that wording is the specified behavior, and name that behavior in the fact. Violate **only** the rule the spec is named after (build the command valid in every other respect), or a neighbouring rule makes it pass.
|
|
95
|
-
3. **Business-rule violations** — call
|
|
95
|
+
3. **Business-rule violations** — call the validator directly with the required model state and assert each rejection; `Provide()` acquires data and only short-circuits (`ValidationResult`/`AuthorizationResult`) when acquisition yields nothing usable, not for ordinary validation rules. Arc/Chronicle specs own platform concurrency, conflict refusal and isolation. Keep the assembly-level shape-admission check and any explicit-body-read checks above; do not repeat guard scenarios per decision.
|
|
96
96
|
4. **Constraint violations** — `ShouldHaveConstraintViolationFor(name)` via `EventScenario`.
|
|
97
97
|
5. **Authorization** — `ShouldNotBeAuthorized()` (an unauthorized result has no validation errors).
|
|
98
98
|
6. **Repeat execution**, when a reactor invokes the command — the same command twice for the same source; specify whether the second is rejected, a no-op, or appends again.
|
|
@@ -158,4 +158,4 @@ Before handing back:
|
|
|
158
158
|
- `Status: done | partial | blocked` (meanings in **cratis-application-slice-conformance**).
|
|
159
159
|
- Specification map: contract specification → spec class; code-derived extras listed separately as proposals.
|
|
160
160
|
- The contract used (`.play` slice path or agreed outline).
|
|
161
|
-
- Spec results (pending or unexecuted specs named honestly), and any open question or model edit request.
|
|
161
|
+
- Spec results (pending or unexecuted specs named honestly), naming the assembly-level admission check, any explicit-body-read checks or focused policy regression, and any open question, harness gap or model edit request.
|
|
@@ -39,8 +39,8 @@ The package root exports **only** setup (`CratisComponentsProvider`, configurati
|
|
|
39
39
|
| CSS foundation / area sheets | layer order / structural CSS | `@cratis/components/styles/base`, `<subpath>/styles` |
|
|
40
40
|
| Shared types | `JsonSchema`, `Json`, … | `@cratis/components/types` |
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
`>=20.3.1 <
|
|
42
|
+
The declared peers for React and React DOM are `^19.0.0`, Arc and Arc React are
|
|
43
|
+
`>=20.3.1 <24`, Fundamentals is `^7.10.3`, and `reflect-metadata` `0.2.2` is required
|
|
44
44
|
(import it at the entry point). `tsyringe` `4.10.0` is optional for Components;
|
|
45
45
|
Arc React installs it. `Canvas` and `PivotViewer` need the optional `pixi.js ^8.20.0`
|
|
46
46
|
peer; ordinary pages do not. No `motion-dom` or `motion-utils` resolution pin is needed.
|
|
@@ -125,8 +125,8 @@ import { DataPage, MenuItem, Column } from '@cratis/components/DataPage';
|
|
|
125
125
|
|
|
126
126
|
`MenuItem` is a declarative Components element read by `DataPage.MenuItems` (use `command`, not
|
|
127
127
|
`onClick`); `disableOnUnselected` greys it out until a row is selected; its `icon` is a **React
|
|
128
|
-
component type** (e.g. a `react-icons` icon), not an `Icon`.
|
|
129
|
-
|
|
128
|
+
component type** (e.g. a `react-icons` icon), not an `Icon`.
|
|
129
|
+
Read the **cratis-arc-react-page** skill's `references/data-page.md` for typed menu selection, reconciliation, search/server mapping and `landmark`.
|
|
130
130
|
|
|
131
131
|
## Composition over Monoliths
|
|
132
132
|
|
|
@@ -132,28 +132,10 @@ const result = await command.execute();
|
|
|
132
132
|
|
|
133
133
|
Inside dialogs, use `CommandDialog` + CommandForm fields rather than driving the command by hand — see [dialogs.md](./dialogs.md).
|
|
134
134
|
|
|
135
|
-
### Read
|
|
135
|
+
### Read command outcomes before choosing feedback
|
|
136
136
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
| `isSuccess` | `isAuthorized && isValid && !hasExceptions` | happy path |
|
|
140
|
-
| `isAuthorized` | `[Roles]`/policy rejected | redirect to login / "not allowed" |
|
|
141
|
-
| `isValid` | validation failed — `validationResults` has per-field messages | render inline field errors |
|
|
142
|
-
| `hasExceptions` | `Provide()`/`Handle()` threw — `exceptionMessages` carry diagnostics | generic error toast + log; never show stack traces |
|
|
143
|
-
|
|
144
|
-
`CommandDialog` handles all of this automatically; the flags matter most when executing a command **outside** a dialog. `validate()` returns the same shape with `response == null` (handler did not run). `result.validationResults` is a `ValidationResult[]` of `{ severity, message, members: string[], state, reason, reasonDetail? }` — `members` names the affected properties — render per-field UI from it, but **never branch on raw `.message` text**. `exceptionMessages`/`exceptionStackTrace` are for logging, never for users.
|
|
145
|
-
|
|
146
|
-
Out-of-dialog execution branches in this order:
|
|
147
|
-
|
|
148
|
-
```tsx
|
|
149
|
-
const result = await command.execute();
|
|
150
|
-
if (!result.isAuthorized) { redirectToLogin(); return; }
|
|
151
|
-
if (!result.isValid) { /* validationResults → inline field errors */ return; }
|
|
152
|
-
if (result.hasExceptions) { toast.error({ title: 'Something went wrong' }); console.error(result.exceptionMessages); return; }
|
|
153
|
-
// happy path — refresh queries, close, etc.
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
`toastCommandResult(result, opts)` from `@cratis/components/Notifications` collapses this whole branch into one call (with a `<Toaster />` mounted) — success/not-authorized/validation/exception → the right toast, no stack traces shown.
|
|
137
|
+
Read `.cratis/ai/skills/cratis-arc-command/references/command-result.md` for the complete result decision table, protected-read refusals and message safety; do not replace it with an `isSuccess`-only branch.
|
|
138
|
+
Read the **cratis-arc-react-page** skill's `references/queries-and-commands.md` for `/validate` feedback under read protection, and `references/availability.md` for presentation-only availability.
|
|
157
139
|
|
|
158
140
|
### Command helpers
|
|
159
141
|
|
|
@@ -17,7 +17,7 @@ Extends the base [specs.md](./specs.md) (folder structure, naming, philosophy) w
|
|
|
17
17
|
|
|
18
18
|
## Frameworks
|
|
19
19
|
|
|
20
|
-
- [xUnit v3](https://xunit.net/docs/getting-started/v3/migration) is the house default for new and migrated spec projects
|
|
20
|
+
- [xUnit v3](https://xunit.net/docs/getting-started/v3/migration) is the house default for new and migrated spec projects **run as the built executable** ([loop](../skills/cratis-specifications-csharp/references/running-specs.md#local-loop)); through `dotnet test` it can be slower (reported measurement). Reference `Cratis.Specifications.XUnit.v3` **5.0** with `xunit.v3.mtp-off`, `Microsoft.NET.Test.Sdk` and `xunit.runner.visualstudio`, and set `<OutputType>Exe</OutputType>` in the project. The package supplies the `Specification` base, convention lifecycle and `ShouldXxx` assertions; the namespace remains `Cratis.Specifications`. Its `Cratis.Specifications` dependency supplies `Catch` and `SpecificationMethods`.
|
|
21
21
|
- 5.0 targets `net10.0` only. A spec project that must stay on net8.0/net9.0 stays on 4.x, and net48 on 3.x. A project that stays on xUnit v2 uses `Cratis.Specifications.XUnit`, with the same base and conventions.
|
|
22
22
|
- `.NUnit`/`.NUnit5`, `.TUnit` and the experimental `.Runner` are alternatives for repositories already built on them.
|
|
23
23
|
- [NSubstitute](https://nsubstitute.github.io/) for mocking collaborators.
|
|
@@ -14,15 +14,15 @@ Specs are **mandatory for every slice type**, including reactors.
|
|
|
14
14
|
|
|
15
15
|
## Start with the plain call; add a scenario where it adds proof
|
|
16
16
|
|
|
17
|
-
Call pure `Handle()`, validators, reducers and reactor decisions directly with their inputs, including read-model state. Add a scenario
|
|
17
|
+
Call pure `Handle()`, validators, reducers and reactor decisions directly with their inputs, including read-model state. Add a scenario for the wiring the decision table below obligates (pipeline and authorization, constraints, projection and reducer dispatch, reactor dispatch and routing). Do not repeat every decision through the pipeline; name the extra behavior each scenario proves.
|
|
18
18
|
|
|
19
|
-
**Decision table — apply it per artifact, without judgment.** A plain call proves the decision; a scenario is a coverage obligation for the wiring only the framework proves. These are obligations, not quotas: add a scenario for each behavior listed
|
|
19
|
+
**Decision table — apply it per artifact, without judgment.** A plain call proves the decision; a scenario is a coverage obligation for the wiring only the framework proves. These are obligations, not quotas: add a scenario for each behavior listed; only the explicit-policy exceptions below add guard scenarios.
|
|
20
20
|
|
|
21
21
|
| Artifact | Plain call (`Specification`) | Scenario obligation |
|
|
22
22
|
|---|---|---|
|
|
23
|
-
| Command with a pure `Handle(…)` | every outcome and rejection branch, with read-model state supplied | the pipeline path once (`CommandScenario`: discovery, DI, event source, appended events), plus a **negative proof for each wiring that can refuse before `Handle`**: authorization denies (`ShouldNotBeAuthorized`), validation rejects, `Provide()` short-circuits |
|
|
23
|
+
| Command with a pure `Handle(…)` | every outcome and rejection branch, with read-model state supplied | the pipeline path once (`CommandScenario`: discovery, DI, event source, appended events), plus a **negative proof for each wiring that can refuse before `Handle`**: authorization denies (`ShouldNotBeAuthorized`), validation rejects, `Provide()` short-circuits when acquisition yields nothing usable |
|
|
24
24
|
| `Handle` that needs `IEventStore`, `IReadModels` or services | none: do not substitute the store | keep the scenario; when touched, take the read model as a `Handle` parameter and use the row above |
|
|
25
|
-
| `CommandValidator`, `ConceptValidator
|
|
25
|
+
| `CommandValidator`, `ConceptValidator`; `Provide()` acquisition/derived values | each validator rule, provided value and acquisition-failure result, built with its state | the command's pipeline scenarios prove the wiring |
|
|
26
26
|
| Constraint (`[Unique]`, `IConstraint`) | none | an `EventScenario` per constraint: the violation and the nearest non-violation |
|
|
27
27
|
| Projection or read model | none | `ReadModelScenario` against the real engine, covering **each event, key, join, children and removal the projection declares**: one class per read model with one shared event sequence by default; add a class only for a sequence that cannot share it (a removal, another key) |
|
|
28
28
|
| Reducer | each transition: `Model.Reduce(event, current[, context])` | a `ReadModelScenario` for dispatch, filters and stream routing |
|
|
@@ -53,7 +53,7 @@ public class and_the_caller_is_not_a_maintainer : Specification
|
|
|
53
53
|
|
|
54
54
|
An unauthenticated scenario against an `[Authorize]`/`[Roles]` command is denied before `Handle`; pair it with the happy-path scenario that registers an allowed identity in `_scenario.Services`.
|
|
55
55
|
|
|
56
|
-
**Application
|
|
56
|
+
**Application decisions (judgment-shaped).** Supply read-model state to plain `Handle()`/validator calls; validators own refusals; `Provide()` only short-circuits (`ValidationResult`/`AuthorizationResult`) when acquisition yields nothing usable, not for ordinary validation rules. Keep one assembly-level `DecisionReadAdmissions.ShouldAdmitDecisionReadsIn(assembly)` check of discoverable application shapes, not per-decision guard scenarios. Ordinary application specs do not re-prove Arc/Chronicle's platform matrix. For an unusual application-owned explicit guard policy — hand-built `EventsWithConcurrencyScopes` or deliberately unguarded `[Unprotected]` reads — use a focused regression only when a plain call cannot prove it; see [decision specifications](../skills/cratis-application-slice-specifications/references/query-and-decision-scenarios.md) for admission limits and the advanced hook's boundary. Never weaken production guards for speed; report harness gaps upstream.
|
|
57
57
|
|
|
58
58
|
**Share setup and budget cost (judgment-shaped).** Keep shared lifecycle on; use `[PerFactSpecificationLifecycle]` only on a class whose facts genuinely mutate shared state and cannot move that mutation into `Because`. Plain decision specs should take roughly milliseconds; measure scenario facts and justify seconds by the extra behavior they prove. Compare TRX durations and suite wall time with unchanged concurrency; see [running-specs.md](../skills/cratis-specifications-csharp/references/running-specs.md). Do not multiply scenario startup by splitting assertions into classes or opting the project out of shared lifecycle.
|
|
59
59
|
|
|
@@ -141,12 +141,14 @@ One specification class for **each** of:
|
|
|
141
141
|
|
|
142
142
|
1. **The happy path** — a plain call returns the expected event, plus one
|
|
143
143
|
`CommandScenario` happy path for the pipeline, and a negative scenario for
|
|
144
|
-
each authorization policy and `Provide()` short-circuit.
|
|
144
|
+
each authorization policy, validator refusal and `Provide()` acquisition-failure short-circuit.
|
|
145
145
|
2. **Each validation failure** — instantiate `CommandValidator` or
|
|
146
146
|
`ConceptValidator` with the required state and validate directly; the
|
|
147
147
|
command's pipeline scenario proves the wiring.
|
|
148
|
-
3. **Each business-rule rejection** — one `and_` class per
|
|
149
|
-
`
|
|
148
|
+
3. **Each business-rule rejection** — one `and_` class per validator rule using
|
|
149
|
+
supplied read-model state; `Provide()` only short-circuits
|
|
150
|
+
(`ValidationResult`/`AuthorizationResult`) when acquisition yields nothing usable,
|
|
151
|
+
not for ordinary validation rules.
|
|
150
152
|
4. **Each constraint violation** — one class per constraint, written with
|
|
151
153
|
`EventScenario`, because a constraint is enforced at the append and not by
|
|
152
154
|
the command.
|
|
@@ -211,16 +213,17 @@ do not replay a projection merely to feed a pure command decision.
|
|
|
211
213
|
|
|
212
214
|
Both builder methods return `void`; there is nothing to await.
|
|
213
215
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
`DecisionReadAdmissions.ShouldAdmitDecisionReadsIn(assembly)`
|
|
219
|
-
application
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
[query and decision scenarios](references/query-and-decision-scenarios.md) for
|
|
223
|
-
|
|
216
|
+
Ordinary application specs give state and assert the decision; they do not
|
|
217
|
+
re-prove Arc/Chronicle's platform concurrency/guard matrix or select protection
|
|
218
|
+
modes for test speed. Typed scenarios select decision reads automatically;
|
|
219
|
+
`UseDecisionReads()` is obsolete. Keep one assembly-level
|
|
220
|
+
`DecisionReadAdmissions.ShouldAdmitDecisionReadsIn(assembly)` check for discovered
|
|
221
|
+
application shapes. Explicit body reads need their own admission check or focused
|
|
222
|
+
scenario. An unusual application-owned explicit guard policy may need a focused
|
|
223
|
+
regression a plain call cannot prove. Read
|
|
224
|
+
[query and decision scenarios](references/query-and-decision-scenarios.md) for the
|
|
225
|
+
admission example, limitations and advanced hook boundary. Report harness gaps;
|
|
226
|
+
never weaken production guards for test speed.
|
|
224
227
|
|
|
225
228
|
Validator and `Provide()` dependencies are registered in `_scenario.Services`;
|
|
226
229
|
the concrete validator itself is discovered automatically.
|
|
@@ -69,36 +69,80 @@ cover those pipeline hooks.
|
|
|
69
69
|
|
|
70
70
|
## Decision specifications
|
|
71
71
|
|
|
72
|
-
Start with a direct
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
72
|
+
Start with a direct `Handle()` or validator call supplied with read-model state;
|
|
73
|
+
validators own refusals. `Provide()` acquires data and only short-circuits
|
|
74
|
+
(`ValidationResult`/`AuthorizationResult`) when acquisition yields nothing usable,
|
|
75
|
+
not for ordinary validation rules. Follow the
|
|
76
|
+
[scenario rule](../../../rules/specs.scenarios.csharp.md): ordinary application
|
|
77
|
+
specs prove business decisions, not Arc/Chronicle's concurrency, conflict-refusal
|
|
78
|
+
or isolation matrix. Add pipeline scenarios only for the wiring they prove.
|
|
79
|
+
For that wiring, an admitted flat model pinned with `.ReadModel(instance)` can
|
|
80
|
+
serve a plain `Handle` parameter under `On`; pins are not advisory-only. Use routed
|
|
81
|
+
events for per-stream models and advanced `DecisionRead<T>` parameters, or when
|
|
82
|
+
mapping/history is the proof. `Given` needs `Cratis.Arc.Chronicle.Testing`.
|
|
83
|
+
|
|
84
|
+
### One assembly-level admission check
|
|
85
|
+
|
|
86
|
+
Keep one cheap admission spec over the application's command assemblies, not one
|
|
87
|
+
scenario per decision. This excerpt assumes `RegisterAuthor` is an application
|
|
88
|
+
command; include each command assembly in a multi-assembly application:
|
|
79
89
|
|
|
80
90
|
```csharp
|
|
81
|
-
|
|
91
|
+
using Cratis.Arc.Chronicle.Testing.Commands;
|
|
92
|
+
|
|
93
|
+
public class when_checking_decision_read_admission
|
|
94
|
+
{
|
|
95
|
+
[Fact]
|
|
96
|
+
public void should_admit_every_declared_protected_read() =>
|
|
97
|
+
DecisionReadAdmissions.ShouldAdmitDecisionReadsIn(typeof(RegisterAuthor).Assembly);
|
|
98
|
+
}
|
|
82
99
|
```
|
|
83
100
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
101
|
+
The helper checks discovered declarations without executing commands or running
|
|
102
|
+
Chronicle. It inspects protected `Handle`/`Provide` decision-read parameters and,
|
|
103
|
+
under declared `On`, plain Chronicle-backed models and discoverable validator
|
|
104
|
+
constructor parameters, excluding advisory reads. Stream parameters use stream
|
|
105
|
+
admission; inherited methods are included and abstract commands are skipped in
|
|
106
|
+
assembly scans. It honors command/assembly declarations and ignores the runtime
|
|
107
|
+
cap. Keep discovered projections representative of production: a spec-local
|
|
108
|
+
projection for a production model can make admission ambiguous.
|
|
109
|
+
|
|
110
|
+
Explicit `IDecisionReads.Get<T>(key)` calls inside method bodies are not statically
|
|
111
|
+
visible. Give those models their own `Admit<T>()` check or a focused command
|
|
112
|
+
scenario. Do not treat the assembly check as coverage of those calls.
|
|
113
|
+
|
|
114
|
+
### Business decisions, not the platform race matrix
|
|
115
|
+
|
|
116
|
+
Do not add a scenario to prove a race already guaranteed by Arc/Chronicle. For
|
|
117
|
+
"two callers reserving the last seat yield one reservation", supply no-seat state
|
|
118
|
+
to the validator and assert rejection, then supply one-seat state and assert the
|
|
119
|
+
allowed decision. Direct calls do not prove the guard itself.
|
|
120
|
+
|
|
121
|
+
Typed `CommandScenario<TCommand>` selects decision reads from the command's
|
|
122
|
+
declarations. Do not call `UseDecisionReads()`; it is obsolete. For an untyped
|
|
123
|
+
`CommandScenario<object>` whose declarations cannot be selected at construction,
|
|
124
|
+
`EnableDecisionReads()` must run before seeding or the first `Execute`/`Validate`.
|
|
125
|
+
Do not change production protection for spec speed. If required state cannot be
|
|
126
|
+
supplied, report the harness gap rather than inventing guard doubles.
|
|
127
|
+
|
|
128
|
+
### Focused explicit-policy regression
|
|
129
|
+
|
|
130
|
+
An unusual application-owned explicit guard policy can justify a focused
|
|
131
|
+
regression that a plain call cannot prove. Examples are a revision captured during
|
|
132
|
+
a read and returned in `EventsWithConcurrencyScopes`, application-owned `[Unprotected]`
|
|
133
|
+
behavior on a command, model or parameter, or a deliberately non-atomic batch contract.
|
|
134
|
+
Test that chosen contract, not the platform's generic conflict/isolation matrix.
|
|
135
|
+
`EventsWithConcurrencyScopes` carries ordered events and supplied scopes into the
|
|
136
|
+
same command transaction, so the policy regression must exercise that boundary.
|
|
137
|
+
|
|
138
|
+
`AppendConcurrently` is an advanced framework-verification hook, hidden from normal
|
|
139
|
+
editor completion, not a routine application-spec template. Use it only for a
|
|
140
|
+
specific, explicit need: it works with or without decision mode and adds no guard
|
|
141
|
+
to an unguarded command. Queue it before the first execution; it appends competing
|
|
142
|
+
facts after response processing and before the owner's commit. Its route overload
|
|
143
|
+
preserves routing; nested commands do not drain the outer queue. It refuses custom
|
|
144
|
+
execution scopes whose ordering it cannot guarantee. Do not call `UseDecisionReads()`
|
|
145
|
+
to make the hook work, or hand-build a race matrix around it.
|
|
102
146
|
`ShouldHaveCompletedStream(ClosedStreamScope)` may assert that a decision completed a
|
|
103
147
|
stream at the exact source and route (`Cratis.Arc.Chronicle.Testing.Commands`).
|
|
104
148
|
Use event history only when it is part of the domain example.
|
|
@@ -113,4 +157,7 @@ Provider boundaries remain separate: state fixtures are not a MongoDB substitute
|
|
|
113
157
|
- [Query scenarios](https://github.com/Cratis/Arc/blob/main/Documentation/backend/csharp/testing/query-scenario.md)
|
|
114
158
|
- [Stream decisions and routed specs](https://github.com/Cratis/Arc/blob/main/Documentation/backend/csharp/chronicle/commands/stream-decisions.md)
|
|
115
159
|
- [Decision-mode extension](https://github.com/Cratis/Arc/blob/main/Source/DotNET/Chronicle.Testing/Commands/CommandScenarioChronicleExtensions.cs)
|
|
160
|
+
- [Admission helper](https://github.com/Cratis/Arc/blob/main/Source/DotNET/Chronicle.Testing/Commands/DecisionReadAdmissions.cs)
|
|
161
|
+
- [Explicit revision scopes](https://github.com/Cratis/Arc/blob/main/Documentation/backend/csharp/chronicle/commands/concurrency.md)
|
|
162
|
+
- [Advisory read declarations](https://github.com/Cratis/Arc/blob/main/Source/DotNET/Chronicle/ReadModels/UnprotectedAttribute.cs)
|
|
116
163
|
- [Application-shape admission assertion](https://github.com/Cratis/Arc/blob/main/Source/DotNET/Chronicle.Testing/Commands/DecisionReadAdmissions.cs)
|
|
@@ -27,6 +27,8 @@ Sources: `Source/DotNET/Arc.Core/Commands/CommandResult.cs`,
|
|
|
27
27
|
| `ExceptionMessages` | `IEnumerable<string>` | |
|
|
28
28
|
| `ExceptionStackTrace` | `string` | |
|
|
29
29
|
| `AuthorizationFailureReason` | `string` | |
|
|
30
|
+
| `IsRetryable` | `bool` | Temporary refusal; defaults to `false` |
|
|
31
|
+
| `IsMissingHandler` | `bool` | No handler: execution/validation did not run; defaults to `false` |
|
|
30
32
|
|
|
31
33
|
`CommandResult<TResult>` adds a `Response` of `TResult`.
|
|
32
34
|
|
|
@@ -94,6 +96,8 @@ readonly isSuccess: boolean;
|
|
|
94
96
|
readonly isAuthorized: boolean;
|
|
95
97
|
readonly isValid: boolean;
|
|
96
98
|
readonly hasExceptions: boolean;
|
|
99
|
+
readonly isRetryable?: boolean;
|
|
100
|
+
readonly isMissingHandler?: boolean;
|
|
97
101
|
readonly validationResults: ValidationResult[];
|
|
98
102
|
readonly exceptionMessages: string[];
|
|
99
103
|
readonly authorizationFailureReason: string;
|
|
@@ -117,22 +121,51 @@ failure to one or more `members`, and `severity` is the numeric
|
|
|
117
121
|
`ValidationResultSeverity` enum. Code that reads `v.propertyName` or compares
|
|
118
122
|
`v.severity === 'Error'` is reading fields that do not exist.
|
|
119
123
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
124
|
+
Validator refusals, explicit `ValidationResult` outcomes from `Provide()`/`Handle()`,
|
|
125
|
+
and `IEnumerable<ValidationResult>` outcomes from `Provide()` share
|
|
126
|
+
`validationResults`, subject to blocking severity. Validators own refusals when
|
|
127
|
+
usable facts exist; `Provide()` short-circuits only when acquisition yields
|
|
128
|
+
nothing usable, and `Handle()` must not duplicate business validation.
|
|
129
|
+
|
|
130
|
+
### Result decision table
|
|
131
|
+
|
|
132
|
+
Check `isMissingHandler` and `isRetryable` before the ordinary success path;
|
|
133
|
+
do not recompute success from only authorization, validity and exceptions.
|
|
134
|
+
The server's computed `IsSuccess` formula above does not include those flags.
|
|
135
|
+
Use `response` only after classifying the result as successful. The two interface
|
|
136
|
+
flags are optional: absence is not a positive retry or missing-handler signal.
|
|
137
|
+
|
|
138
|
+
| Outcome | Application response |
|
|
139
|
+
| --- | --- |
|
|
140
|
+
| `isMissingHandler === true` | safe unavailable-action feedback; log the integration/configuration fault, not field errors |
|
|
141
|
+
| `isRetryable === true` | temporary refusal, not a permanent denial or invalid input; preserve the draft and offer deliberate retry |
|
|
142
|
+
| `isSuccess` after those checks | use the typed response, then close/refresh |
|
|
143
|
+
| `!isAuthorized` | distinguish unavailable from forbidden via `isNotAvailable(result)` from `@cratis/arc/availability`; do not automatically redirect every refusal to login |
|
|
144
|
+
| `!isValid` with a protected-read refusal below | retain the draft, re-read, then let the user deliberately retry |
|
|
145
|
+
| `!isValid` with authored `rule` results | match approved user-facing rule copy to fields through `members` |
|
|
146
|
+
| Other invalid results | choose safe application copy by `reason`/`reasonDetail`, never parse `.message` |
|
|
147
|
+
| `hasExceptions` | generic fault feedback; diagnostics belong in logs |
|
|
148
|
+
|
|
149
|
+
A retryable flag does not imply that a protected-read result carries that flag:
|
|
150
|
+
classify the known reason pair independently, before generic field-error display.
|
|
151
|
+
|
|
152
|
+
### Protected-read refusals
|
|
153
|
+
|
|
154
|
+
`ValidationResultReason` is an open string set. Recognize only these exact pairs:
|
|
155
|
+
|
|
156
|
+
| `reason` | `reasonDetail` | Meaning |
|
|
157
|
+
| --- | --- | --- |
|
|
158
|
+
| `concurrencyViolation` | `ReadChanged` | the guarded read changed before effects could commit |
|
|
159
|
+
| `concurrencyViolation` | `ReadIncomplete` | a required read did not complete; no effects committed |
|
|
160
|
+
|
|
161
|
+
For both, keep the draft and dialog open, re-read the relevant state and allow a
|
|
162
|
+
**deliberate retry**. Never mark the user's input invalid or clear fields for
|
|
163
|
+
these refusals. They are not authored business-rule failures. Framework-composed
|
|
164
|
+
messages are developer English, not localized user-facing copy: never show them
|
|
165
|
+
raw. Do not render read state, keys or conflicting-event details in visible UI
|
|
166
|
+
or announcements. Choose application copy by the pair, not by parsing the
|
|
167
|
+
message. Unknown reasons or details are not automatically protected-read refusals or framework
|
|
168
|
+
errors; use a safe fallback unless the application explicitly approves their copy.
|
|
136
169
|
|
|
137
170
|
`members` is **camelCased on purpose**, so a form can match a server failure to
|
|
138
171
|
the field that caused it without transforming anything. A nested member is a
|
|
@@ -143,8 +176,27 @@ and names the field the same way.
|
|
|
143
176
|
|
|
144
177
|
`reason` also distinguishes a genuine rejection from a validator that threw
|
|
145
178
|
while validating hostile or partial input: the latter arrives as a single result
|
|
146
|
-
with a `ValidatorFailed` reason and a generic message, replacing every message
|
|
179
|
+
with a `ValidatorFailed` (`validatorFailed`) reason and a generic message, replacing every message
|
|
147
180
|
the validator's author wrote. Do not read the message to tell the two apart.
|
|
181
|
+
Other framework reasons include `dependencyUnavailable` (facts unavailable before
|
|
182
|
+
rules), `concurrencyViolation`, `constraintViolation` and `frameworkFailure`.
|
|
183
|
+
Use safe application feedback for these non-rule diagnostics, not blanket
|
|
184
|
+
field-error rendering. `reasonDetail` can identify a constraint; `state` is
|
|
185
|
+
application data, not proof that a message is safe. Never show
|
|
186
|
+
`exceptionMessages`/`exceptionStackTrace` to users.
|
|
187
|
+
|
|
188
|
+
### Feedback helpers are not sanitizers
|
|
189
|
+
|
|
190
|
+
`CommandForm` renders raw validation messages; `toastCommandResult` joins them
|
|
191
|
+
into its invalid-result toast. Neither sanitizes non-rule diagnostics. Use
|
|
192
|
+
application-owned feedback. `showErrors={false}` suppresses built-in form error
|
|
193
|
+
display, not every dialog announcement. `CommandDialog`'s default validation
|
|
194
|
+
announcement also includes a raw message; use application-owned safe
|
|
195
|
+
`validationAnnouncement` text when needed. `onValidationFailure` alone does not
|
|
196
|
+
suppress either display. See the React page skill's
|
|
197
|
+
[dialogs.md](../../cratis-arc-react-page/references/dialogs.md) for form composition,
|
|
198
|
+
and [queries-and-commands.md](../../cratis-arc-react-page/references/queries-and-commands.md)
|
|
199
|
+
for `/validate` feedback under read protection.
|
|
148
200
|
|
|
149
201
|
## Executing with a severity
|
|
150
202
|
|