@cratis/pi 7.176.0 → 7.176.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package/corpus/agents/spec-writer.md +3 -3
- 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/spec-writer.md +3 -3
- 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/decisions-and-routing.md +16 -13
- package/package/corpus/skills/cratis-arc-command-validation/SKILL.md +10 -5
- 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
|
@@ -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.
|
|
@@ -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
|
|
|
@@ -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.
|
|
@@ -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)
|
|
@@ -190,20 +190,23 @@ source id/type and stream route; reactor tuples/collections cannot mix it with e
|
|
|
190
190
|
## Decision specifications
|
|
191
191
|
|
|
192
192
|
Call `Handle()` and validators directly with read-model state for pure business
|
|
193
|
-
decisions
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
copies left rejects).
|
|
193
|
+
decisions; validators own refusals. `Provide()` acquires data and only short-circuits
|
|
194
|
+
(`ValidationResult`/`AuthorizationResult`) when acquisition yields nothing usable,
|
|
195
|
+
not for ordinary validation rules. Follow
|
|
196
|
+
the [scenario rule](../../../rules/specs.scenarios.csharp.md): ordinary application
|
|
197
|
+
specs do not re-prove Arc/Chronicle's platform concurrency, conflict-refusal or
|
|
198
|
+
isolation matrix. Typed scenarios select decision reads automatically;
|
|
199
|
+
`UseDecisionReads()` is obsolete. Keep one assembly-level shape-admission check;
|
|
200
|
+
explicit body reads need their own admission check or focused scenario. Never
|
|
201
|
+
weaken production guards for speed; report harness state-setup gaps upstream.
|
|
202
|
+
|
|
203
|
+
Add scenarios for pipeline/authorization wiring or constraints. Assert the business
|
|
204
|
+
outcome from supplied state (for example, no copies left rejects in the validator).
|
|
205
|
+
An unusual application-owned explicit guard policy may need a focused regression
|
|
206
|
+
a plain call cannot prove, not a generic race matrix. Read
|
|
205
207
|
[query and decision scenarios](../../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
206
|
-
for the
|
|
208
|
+
for the admission example, limits and advanced hook boundary. Keep shared
|
|
209
|
+
lifecycle on and measure the added cost.
|
|
207
210
|
|
|
208
211
|
## Sources
|
|
209
212
|
|
|
@@ -272,11 +272,16 @@ Every rule gets a failure specification: instantiate the validator with its
|
|
|
272
272
|
read-model state and validate directly, asserting the specific rejection. Add
|
|
273
273
|
`CommandScenario<TCommand>` only for pipeline/authorization wiring, constraints.
|
|
274
274
|
Follow the
|
|
275
|
-
[scenario rule](../../rules/specs.scenarios.csharp.md): application specs
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
application-shape admission
|
|
279
|
-
|
|
275
|
+
[scenario rule](../../rules/specs.scenarios.csharp.md): ordinary application specs
|
|
276
|
+
supply state, not a replay of the platform guard matrix. Typed scenarios select
|
|
277
|
+
decision reads automatically; `UseDecisionReads()` is obsolete. Keep one
|
|
278
|
+
assembly-level application-shape admission check; explicit body reads need their
|
|
279
|
+
own admission check or focused scenario. An unusual application-owned explicit
|
|
280
|
+
guard policy can justify a focused regression a plain call cannot prove; read the
|
|
281
|
+
[decision guidance](../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
282
|
+
for the example, limits and advanced hook boundary. Validators own refusals;
|
|
283
|
+
`Provide()` only short-circuits (`ValidationResult`/`AuthorizationResult`) when
|
|
284
|
+
acquisition yields nothing usable, not for ordinary validation rules. Report harness gaps upstream; never weaken
|
|
280
285
|
production guards for speed.
|
|
281
286
|
|
|
282
287
|
For a pipeline validation rejection, assert **both** that the command did not
|
|
@@ -191,13 +191,18 @@ deciding writer is guarded or the rule is a constraint.
|
|
|
191
191
|
- Review production enrollment in the intended store, namespace and stream;
|
|
192
192
|
surface refusal and never replace it with an unprotected read. One owner completes.
|
|
193
193
|
- Application specs call `Handle()` or the validator directly with supplied state.
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
[scenario rule](../../rules/specs.scenarios.csharp.md)
|
|
194
|
+
Keep one assembly-level `DecisionReadAdmissions.ShouldAdmitDecisionReadsIn(assembly)`
|
|
195
|
+
check of discoverable application shapes; explicit body reads need their own
|
|
196
|
+
admission check or focused scenario. See the
|
|
197
|
+
[scenario rule](../../rules/specs.scenarios.csharp.md) and
|
|
198
|
+
[decision guidance](../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
199
|
+
for the example, admission limits and advanced hook boundary.
|
|
198
200
|
- Arc/Chronicle specs alone prove platform conflict refusal, relevant/irrelevant
|
|
199
201
|
changes, absence guards, empty checked appends, isolation and commit lifecycle.
|
|
200
202
|
Their real-client/kernel integration proves the boundary; a default
|
|
201
203
|
`EventScenario` scope strategy returning `None` is not concurrency evidence.
|
|
202
|
-
-
|
|
203
|
-
|
|
204
|
+
- Ordinary application specs do not repeat that matrix. An unusual
|
|
205
|
+
application-owned explicit guard policy may need a focused regression a plain
|
|
206
|
+
call cannot prove, not a routine race template. Typed scenarios select decision
|
|
207
|
+
reads automatically; `UseDecisionReads()` is obsolete. Never weaken production
|
|
208
|
+
guards for spec speed.
|
|
@@ -340,20 +340,23 @@ justified opt-out, then remove the property and any per-command
|
|
|
340
340
|
## Specify the business decision
|
|
341
341
|
|
|
342
342
|
Start with a plain `Handle()` or validator call supplied with read-model state.
|
|
343
|
-
Follow the [scenario rule](../../../rules/specs.scenarios.csharp.md):
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
343
|
+
Follow the [scenario rule](../../../rules/specs.scenarios.csharp.md): ordinary
|
|
344
|
+
application specs prove the decision, not Arc/Chronicle's platform concurrency,
|
|
345
|
+
conflict-refusal or isolation matrix. Typed scenarios select decision reads
|
|
346
|
+
automatically; `UseDecisionReads()` is obsolete. Keep one assembly-level
|
|
347
|
+
`DecisionReadAdmissions.ShouldAdmitDecisionReadsIn(assembly)` check of discoverable
|
|
348
|
+
application models/projections. Explicit body reads need their own admission check
|
|
349
|
+
or focused scenario; see the
|
|
350
|
+
[decision guidance](../../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
351
|
+
for the example, limits and advanced hook boundary. Production protection stays
|
|
352
|
+
unchanged regardless of spec cost.
|
|
353
|
+
|
|
354
|
+
For two borrowers competing for the last copy, give no-copy state to the validator
|
|
355
|
+
and assert rejection; Arc/Chronicle prove the guard. `Provide()` acquires data and
|
|
356
|
+
only short-circuits (`ValidationResult`/`AuthorizationResult`) when acquisition
|
|
357
|
+
yields nothing usable, not for ordinary validation rules. An unusual application-owned explicit guard
|
|
358
|
+
policy may need a focused regression a plain call cannot prove, not a generic
|
|
359
|
+
race matrix. Report harness state gaps upstream rather than inventing guard doubles.
|
|
357
360
|
|
|
358
361
|
## Costs
|
|
359
362
|
|
|
@@ -164,7 +164,11 @@ degradations a reviewer can see without measuring:
|
|
|
164
164
|
per-artifact decision table of `specs.scenarios.csharp.md` (pipeline and
|
|
165
165
|
authorization, constraints, projection and reducer dispatch, reactor dispatch
|
|
166
166
|
and routing) and none beyond it. A rule that must hold under concurrent
|
|
167
|
-
writers is proven from supplied read-model state, not a race scenario
|
|
167
|
+
writers is proven from supplied read-model state, not a race scenario
|
|
168
|
+
re-proving the platform matrix. For an unusual application-owned explicit
|
|
169
|
+
guard policy, accept only a focused regression a plain call cannot prove;
|
|
170
|
+
check the [decision guidance](../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
171
|
+
for the assembly-level admission check, body-read limits and advanced hook boundary.
|
|
168
172
|
- Every State Change command has a happy-path specification.
|
|
169
173
|
- Every validation rule has a direct-call failure spec. Pipeline validation
|
|
170
174
|
specs assert **both** `ShouldNotBeSuccessful()` and `ShouldHaveValidationErrors()`.
|
|
@@ -90,22 +90,23 @@ before changing runner or package family.
|
|
|
90
90
|
The plain `Specification` base is the universal foundation and the dominant mode
|
|
91
91
|
in library and framework code. In applications, start pure decisions with a
|
|
92
92
|
plain call, including direct validator calls, and add the scenarios the
|
|
93
|
-
per-artifact decision table in `specs.scenarios.csharp.md` obligates. Keep shared lifecycle on;
|
|
94
|
-
[running-specs.md](references/running-specs.md). Read
|
|
93
|
+
per-artifact decision table in `specs.scenarios.csharp.md` obligates. Keep shared lifecycle on; diagnose runner startup, lifecycle and scenario cost
|
|
94
|
+
before rewriting, using [running-specs.md](references/running-specs.md). Read
|
|
95
95
|
[application-scenarios.md](references/application-scenarios.md) before using
|
|
96
96
|
one. Out-of-process integration specifications are an advanced case reserved for
|
|
97
97
|
boundaries the scenario helpers cannot reach — see
|
|
98
98
|
[integration-specs.md](references/integration-specs.md).
|
|
99
99
|
|
|
100
|
-
⚠️
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
⚠️ An unguarded in-process append using the default no-scope strategy is not
|
|
101
|
+
concurrency evidence: its no-conflict assertion can pass vacuously. This is not
|
|
102
|
+
a claim about every guarded scenario or explicit scope. Arc/Chronicle own the
|
|
103
|
+
platform concurrency/isolation matrix. Ordinary applications supply state in
|
|
104
|
+
plain `Handle()`/validator calls and keep one assembly-level admission check;
|
|
105
|
+
see the [scenario rule](../../rules/specs.scenarios.csharp.md). For an unusual
|
|
106
|
+
application-owned explicit guard policy, use only a focused regression that a
|
|
107
|
+
plain call cannot prove; read the
|
|
108
|
+
[decision guidance](../cratis-application-slice-specifications/references/query-and-decision-scenarios.md)
|
|
109
|
+
for admission limits and the advanced hook's boundary.
|
|
109
110
|
|
|
110
111
|
For a class-based `ReactorScenario<TReactor>` on a recent Chronicle (Requires Chronicle 19.46.0), seed each
|
|
111
112
|
handler read-model parameter with `Given.ForEventSourceId(id).ReadModel(instance)`
|
|
@@ -20,7 +20,8 @@ Check package versions and the actual configuration/TFM; the 4.x migration check
|
|
|
20
20
|
below applies only when migrating, not as a prerequisite to running an existing suite.
|
|
21
21
|
|
|
22
22
|
Sources: [Running specifications fast](https://github.com/Cratis/Specifications/blob/main/Documentation/running-fast.md),
|
|
23
|
-
[The native runner](https://github.com/Cratis/Specifications/blob/main/Documentation/runner.md)
|
|
23
|
+
[The native runner](https://github.com/Cratis/Specifications/blob/main/Documentation/runner.md),
|
|
24
|
+
[Phase timings](https://github.com/Cratis/Specifications/blob/main/Documentation/phase-timings.md) and
|
|
24
25
|
[Upgrading to 5.0](https://github.com/Cratis/Specifications/blob/main/Documentation/upgrading-5.0.md).
|
|
25
26
|
|
|
26
27
|
## Project shape
|
|
@@ -44,9 +45,10 @@ is a worked example, including the CI step that runs the built executable.
|
|
|
44
45
|
|
|
45
46
|
## Local loop
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
In the upstream reported benchmark of 1,500 trivial tests on a loaded Mac, an
|
|
49
|
+
xUnit v3 suite used about 4.5 times more CPU through `dotnet test` than as the
|
|
50
|
+
built executable. This is a measurement, not a universal ratio. Restore and build
|
|
51
|
+
once, then run the executable:
|
|
50
52
|
|
|
51
53
|
```bash
|
|
52
54
|
dotnet restore Source/MyProject.Specs
|
|
@@ -84,6 +86,62 @@ versions, configuration, filters, concurrency/shards and machine fixed; preserve
|
|
|
84
86
|
discovered/passed/failed/skipped counts and investigate any change. Do not count
|
|
85
87
|
restore/build time as test execution or repeat unchanged runs merely for reassurance.
|
|
86
88
|
|
|
89
|
+
### Diagnose before changing the harness
|
|
90
|
+
|
|
91
|
+
Measure the existing suite before a rewrite. Separate restore/build, runner
|
|
92
|
+
startup/discovery and reporting from specification execution. Phase timings do
|
|
93
|
+
not measure total process startup or discovery; compare launch wall time separately.
|
|
94
|
+
For repeated local runs, use the built executable rather than repeatedly invoking
|
|
95
|
+
`dotnet test`/MSBuild. Keep the evaluated runner and its supported flags.
|
|
96
|
+
|
|
97
|
+
Enable phase diagnostics without changing pass/fail behavior. This example assumes
|
|
98
|
+
the Release/net10.0 executable built above and runs from the repository root:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
mkdir -p .ai-work/spec-timings
|
|
102
|
+
CRATIS_SPECS_TIMINGS=1 CRATIS_SPECS_TIMINGS_FILE="$PWD/.ai-work/spec-timings/phases.json" \
|
|
103
|
+
./Source/MyProject.Specs/bin/Release/net10.0/MyProject.Specs
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Alternatively, set `<CratisSpecificationsPhaseTimings>true</CratisSpecificationsPhaseTimings>`
|
|
107
|
+
in the project. Slow phases default to a 1,000 ms threshold; set
|
|
108
|
+
`<CratisSpecificationsSlowPhaseThreshold>500</CratisSpecificationsSlowPhaseThreshold>`
|
|
109
|
+
for a 500 ms diagnostic threshold, not a performance budget. The JSON file records
|
|
110
|
+
`Establish`, `Because` and `Destroy` durations; native-runner output also records
|
|
111
|
+
facts. Other frameworks time facts through their own runner output. Timings are
|
|
112
|
+
off by default, additive when enabled, and never change whether a spec passes.
|
|
113
|
+
|
|
114
|
+
| Cost observed | Next check |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| Restore/build | Keep it outside the execution comparison; restore/build once for the local loop. |
|
|
117
|
+
| Runner startup/discovery | Compare the built executable's launch path, not just fact durations. |
|
|
118
|
+
| Repeated `Establish`/`Because` | Check shared lifecycle eligibility and opt-outs before changing packages. |
|
|
119
|
+
| Scenario setup/action | Identify pipeline, mapping or append-time proof a plain call cannot provide. |
|
|
120
|
+
| Slow fact | Keep assertions read-only; inspect the measured operation rather than adding sleeps. |
|
|
121
|
+
| `Destroy` | Measure disposal/cleanup separately from setup and action. |
|
|
122
|
+
|
|
123
|
+
Specifications 5 shares eligible xUnit v2/v3 lifecycle by default. `Establish` and
|
|
124
|
+
`Because` run once per class; facts only read that shared context. Repeating a
|
|
125
|
+
200 ms `Because` across five facts costs about 1 s instead of about 200 ms in
|
|
126
|
+
this illustrative calculation, before other costs. Remove accidental opt-outs
|
|
127
|
+
rather than weakening assertions; retain `[PerFactSpecificationLifecycle]` only
|
|
128
|
+
where mutation genuinely cannot move into `Because`.
|
|
129
|
+
|
|
130
|
+
Record a before/after comparison, not a claimed universal timing:
|
|
131
|
+
|
|
132
|
+
| Field | Keep or report |
|
|
133
|
+
| --- | --- |
|
|
134
|
+
| Environment | Machine, package versions, configuration/TFM, launch command, filters and unchanged concurrency/shards. |
|
|
135
|
+
| Coverage | Discovered, passed, failed and skipped counts plus the class/method list; investigate any difference. |
|
|
136
|
+
| Execution | Suite wall time, class totals and phase/fact durations in separate result files. |
|
|
137
|
+
| Change | Name the removed repeated cost or the extra framework proof that justifies scenario cost. |
|
|
138
|
+
|
|
139
|
+
Do not merge unrelated behaviors, remove facts or turn off production guards to
|
|
140
|
+
meet a timing target. One class per declarative read model remains the default:
|
|
141
|
+
share a meaningful event sequence, capture intermediate states and assert them
|
|
142
|
+
with many read-only facts; add a class only for a sequence that cannot share it.
|
|
143
|
+
A slow mandatory scenario is an upstream harness gap, not permission to drop proof.
|
|
144
|
+
|
|
87
145
|
## Filters
|
|
88
146
|
|
|
89
147
|
The executable accepts the filters of the xUnit v3 runner flavor the project
|