@hailstails/hone 1.2.0 → 1.4.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/ADOPTING.md +6 -6
- package/CHANGELOG.md +38 -0
- package/MIGRATING.md +28 -5
- package/README.md +41 -14
- package/api/audit.d.ts +1 -1
- package/api/testing.js +3 -3
- package/chunks/chunk-335ITLPO.js +7 -0
- package/chunks/{chunk-5VXHQC4A.js → chunk-6SM3HKWO.js} +302 -637
- package/chunks/{chunk-PL2PNPAR.js → chunk-E6VR3VRV.js} +1 -6
- package/chunks/{chunk-H4V72FCW.js → chunk-FEWCJU7H.js} +9 -1
- package/chunks/chunk-WF3PPYRR.js +27 -0
- package/core/check/tool-command.js +797 -88
- package/core/mechanism-port/runner-result-types.d.ts +6 -0
- package/docs/adding-a-discipline-or-mechanism.md +4 -4
- package/docs/extending.md +5 -5
- package/docs/output-contract.md +60 -14
- package/mechanisms/audit/CD-27/test-body-logic.js +394 -46
- package/mechanisms/audit/runner/runner.js +1 -1
- package/mechanisms/audit/runner/typescript-parse.d.ts +2 -0
- package/mechanisms/audit/runner/walker-piece.d.ts +2 -1
- package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +7 -4
- package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +21 -11
- package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +15 -5
- package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +7 -3
- package/mechanisms/eslint/CD-41/README.md +1 -1
- package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +100 -28
- package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +8 -4
- package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +8 -4
- package/mechanisms/eslint/runner/README.md +10 -3
- package/mechanisms/eslint/runner/runner.js +1410 -1351
- package/methods/lenses/di-discipline.md +4 -5
- package/methods/lenses/test-discipline.md +1 -1
- package/package.json +1 -1
- package/rules/CD-1/CHECKS.md +2 -0
- package/rules/CD-10/CHECKS.md +2 -2
- package/rules/CD-12/README.md +1 -1
- package/rules/CD-14/CHECKS.md +2 -2
- package/rules/CD-15/CHECKS.md +4 -2
- package/rules/CD-17/CHECKS.md +2 -2
- package/rules/CD-17/README.md +3 -3
- package/rules/CD-19/CHECKS.md +2 -2
- package/rules/CD-2/CHECKS.md +4 -2
- package/rules/CD-23/CHECKS.md +2 -2
- package/rules/CD-25/CHECKS.md +3 -3
- package/rules/CD-25/README.md +3 -3
- package/rules/CD-26/CHECKS.md +2 -2
- package/rules/CD-27/CHECKS.md +384 -8
- package/rules/CD-27/README.md +1 -1
- package/rules/CD-27/discipline.json +130 -0
- package/rules/CD-3/CHECKS.md +2 -2
- package/rules/CD-40/CHECKS.md +2 -2
- package/rules/CD-41/CHECKS.md +12 -2
- package/rules/CD-41/README.md +2 -0
- package/rules/CD-41/discipline.json +14 -0
- package/rules/CD-42/CHECKS.md +2 -2
- package/rules/CD-43/CHECKS.md +2 -2
- package/rules/CD-44/CHECKS.md +2 -2
- package/rules/CD-47/CHECKS.md +2 -2
- package/rules/CD-5/CHECKS.md +2 -2
- package/rules/CD-6/CHECKS.md +2 -2
- package/rules/CD-7/CHECKS.md +2 -2
- package/rules/CD-7a/CHECKS.md +2 -2
- package/rules/CD-8/CHECKS.md +2 -2
- package/chunks/chunk-YLZ73C7O.js +0 -0
|
@@ -117,10 +117,9 @@ reached for through the module system). Walk the diff for both.
|
|
|
117
117
|
attached to**: a DI-delivered test double (permitted) or an imported binding
|
|
118
118
|
(violation).
|
|
119
119
|
- **Test doubles through the seam are not module interception.** A test that
|
|
120
|
-
constructs a stub or spy as an object literal, a factory-built stub, a
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
channels toward — not a finding. In common speech "mock" covers both a double
|
|
120
|
+
constructs a stub or spy as an object literal, a factory-built stub, or a
|
|
121
|
+
recording spy function, and delivers it through the unit's constructor or
|
|
122
|
+
argument, is the exact pattern the discipline channels toward — not a finding. In common speech "mock" covers both a double
|
|
124
123
|
passed through the seam and module interception. In the taxonomy a mock is only
|
|
125
124
|
a double that verifies expectations set on it, and module interception is not a
|
|
126
125
|
double at all: the rules permit doubles through the seam and forbid
|
|
@@ -149,7 +148,7 @@ raw global call on a "convenience" path; a default factory present but the boot
|
|
|
149
148
|
path constructing the port inline beside it; a middleware generic that compiles
|
|
150
149
|
because its context happens to carry the field, yet is unbound so a different
|
|
151
150
|
pipeline would crash; a spy that looks like clean observation but is attached to
|
|
152
|
-
an imported module;
|
|
151
|
+
an imported module; a stub that is actually wired through module
|
|
153
152
|
interception rather than the seam. A finding here must explain *how the code reads
|
|
154
153
|
DI-clean yet the dependency is still reached for ambiently*, grounded in the
|
|
155
154
|
specific loaded rule. Vague phrasings ("tight coupling", "hard to test") are the
|
|
@@ -20,7 +20,7 @@ recur across codebases under different names:
|
|
|
20
20
|
threshold.
|
|
21
21
|
- **Zero-everything tests.** A test body is a straight line: arrange → act →
|
|
22
22
|
assert. No control flow, no loops, no branches, no mutated capture, no
|
|
23
|
-
unpredictability. N cases means N tests. Uniform cases, such as the rows of a table, are one parameterised test over the rows (the framework's `each`), never a loop inside a test body, and never one hand-written test per row. Variability is supplied by injected test doubles (stubs with canned answers
|
|
23
|
+
unpredictability. N cases means N tests. Uniform cases, such as the rows of a table, are one parameterised test over the rows (the framework's `each`), never a loop inside a test body, and never one hand-written test per row. Variability is supplied by injected test doubles (stubs with canned answers), never computed inside the test.
|
|
24
24
|
- **Assert only the unit's own responsibility.** A test inspects what its unit
|
|
25
25
|
produces and how it calls its collaborators — never the internal logic of a
|
|
26
26
|
delegate reached transitively.
|
package/package.json
CHANGED
package/rules/CD-1/CHECKS.md
CHANGED
|
@@ -33,5 +33,7 @@ const order = orderSchema.parse(JSON.parse(text));
|
|
|
33
33
|
```
|
|
34
34
|
Give it a concrete type where it enters: parse it with a schema or a type guard at the boundary, checked at runtime.
|
|
35
35
|
|
|
36
|
+
In a test file, edition 2 of `CD-27#test-body-logic` flags `JSON.parse`; edition 1, the default, does not.
|
|
37
|
+
|
|
36
38
|
## Exceptions
|
|
37
39
|
CD-1 is exempted like any other discipline: record an `authorised-location`, a `file-carve-out` for existing debt, or a clause-wide carve-out in `discipline-exceptions.json`. A carved or authorised file keeps its existing `any`; an `any` anywhere else still fails. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
package/rules/CD-10/CHECKS.md
CHANGED
|
@@ -38,7 +38,7 @@ it("loads the account", () => {
|
|
|
38
38
|
Assert on the whole result. Branching in tests is also reported by CD-27.
|
|
39
39
|
|
|
40
40
|
## Exceptions
|
|
41
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs a throw, such as a shared test harness. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
41
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs a throw, such as a shared test harness. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
42
42
|
|
|
43
43
|
```json
|
|
44
44
|
{ "version": 1, "exceptions": [
|
|
@@ -46,4 +46,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
46
46
|
] }
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-12/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Review lens: [clean-architecture](../../methods/lenses/clean-architecture.md). T
|
|
|
18
18
|
**Where to go.** The domain depends on repository ports. Adapters compose the driver behind them.
|
|
19
19
|
|
|
20
20
|
**Reactions to distrust.**
|
|
21
|
-
- "We'll never change the database." The port is also what lets tests
|
|
21
|
+
- "We'll never change the database." The port is also what lets tests stub storage.
|
|
22
22
|
|
|
23
23
|
**Principles behind it.**
|
|
24
24
|
- *Repository* (Martin Fowler, *Patterns of Enterprise Application Architecture*). A collection-like interface between the domain and data mapping.
|
package/rules/CD-14/CHECKS.md
CHANGED
|
@@ -38,7 +38,7 @@ export const createCounter = () => {
|
|
|
38
38
|
Return an object of functions from a factory that closes over its state.
|
|
39
39
|
|
|
40
40
|
## Exceptions
|
|
41
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a class is required, such as an adapter extending a library base class. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
41
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a class is required, such as an adapter extending a library base class. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
42
42
|
|
|
43
43
|
```json
|
|
44
44
|
{ "version": 1, "exceptions": [
|
|
@@ -46,4 +46,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
46
46
|
] }
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-15/CHECKS.md
CHANGED
|
@@ -28,8 +28,10 @@ const totals = orders.map((order) => order.total);
|
|
|
28
28
|
```
|
|
29
29
|
Replace a counted loop with `Array.from({ length }, (_, position) => ...)`.
|
|
30
30
|
|
|
31
|
+
In a test file, `CD-27#test-body-logic` flags `map` at either edition, and its edition 2 flags `Array.from`: write the values out instead, as [CD-27's allowed forms](../CD-27/CHECKS.md#allowed-forms-in-a-test) show.
|
|
32
|
+
|
|
31
33
|
## Exceptions
|
|
32
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file drains an async stream and cannot use a functional form. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
34
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file drains an async stream and cannot use a functional form. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
33
35
|
|
|
34
36
|
```json
|
|
35
37
|
{ "version": 1, "exceptions": [
|
|
@@ -37,4 +39,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
37
39
|
] }
|
|
38
40
|
```
|
|
39
41
|
|
|
40
|
-
|
|
42
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-17/CHECKS.md
CHANGED
|
@@ -26,7 +26,7 @@ const startedAt = clock.now();
|
|
|
26
26
|
Accept a clock as a dependency and read time only through it. The one real implementation lives in an adapter.
|
|
27
27
|
|
|
28
28
|
## Exceptions
|
|
29
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` for the file that is the single real clock implementation. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
29
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` for the file that is the single real clock implementation. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
30
30
|
|
|
31
31
|
```json
|
|
32
32
|
{ "version": 1, "exceptions": [
|
|
@@ -34,4 +34,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
34
34
|
] }
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-17/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Rule
|
|
4
4
|
|
|
5
|
-
Time is an injected capability, not an ambient global: domain code never calls the runtime's now-primitives directly, it reads the current instant through a clock port. Real time enters through exactly one clock abstraction; tests inject a
|
|
5
|
+
Time is an injected capability, not an ambient global: domain code never calls the runtime's now-primitives directly, it reads the current instant through a clock port. Real time enters through exactly one clock abstraction; tests inject a stub clock that returns written-out instants. Bare time construction anywhere else makes behaviour impossible to replace with a test double, and non-deterministic.
|
|
6
6
|
|
|
7
7
|
Review lens: [di-discipline](../../methods/lenses/di-discipline.md), [test-discipline](../../methods/lenses/test-discipline.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
8
8
|
|
|
@@ -13,8 +13,8 @@ Review lens: [di-discipline](../../methods/lenses/di-discipline.md), [test-disci
|
|
|
13
13
|
**What a finding points at.** Match the sites against these causes.
|
|
14
14
|
- *Decisions that read the clock.* Business logic asks for the current time in the middle of a calculation. Pass the instant in, or inject the clock.
|
|
15
15
|
- *Time stamped in many places.* Many sites stamp records or events. One clock port at the edge; the instant travels inward as data.
|
|
16
|
-
- *Tests that wait or depend on wall time.* Flaky or slow tests point at a missing clock port. Inject a
|
|
17
|
-
- *Tests that build their own instants.* A test making dates for itself is choosing time outside the clock. Take instants from the
|
|
16
|
+
- *Tests that wait or depend on wall time.* Flaky or slow tests point at a missing clock port. Inject a stub clock that returns written-out instants.
|
|
17
|
+
- *Tests that build their own instants.* A test making dates for itself is choosing time outside the clock. Take instants from the stub clock.
|
|
18
18
|
|
|
19
19
|
**Where to go.** One clock abstraction reads real time. Everything else receives an instant or the clock. Tests set the time they need.
|
|
20
20
|
|
package/rules/CD-19/CHECKS.md
CHANGED
|
@@ -38,7 +38,7 @@ import { createIdGenerator } from "./id-generator.ts";
|
|
|
38
38
|
Import your own port. Only the wrapping file imports the library.
|
|
39
39
|
|
|
40
40
|
## Exceptions
|
|
41
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` for the file that is the wrapping boundary for that dependency. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
41
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` for the file that is the wrapping boundary for that dependency. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
42
42
|
|
|
43
43
|
```json
|
|
44
44
|
{ "version": 1, "exceptions": [
|
|
@@ -46,4 +46,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
46
46
|
] }
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-2/CHECKS.md
CHANGED
|
@@ -40,10 +40,12 @@ const name = user.name ?? "anonymous";
|
|
|
40
40
|
```
|
|
41
41
|
Parse or narrow the value so the type follows from a check rather than from an assertion. For a value that may be absent, handle the absent case with a check, a fallback or an early return; for a binding assigned later, initialise it where it is declared or make it a `const` built from what it needs.
|
|
42
42
|
|
|
43
|
+
In a test file, `CD-27#test-body-logic` flags an `if` check at either edition, and its edition 2 flags the `??` fallback: there, `assert.isDefined` a value that may be missing before reading it, as [CD-27's allowed forms](../CD-27/CHECKS.md#a-short-circuit) show.
|
|
44
|
+
|
|
43
45
|
When handing a value across a boundary truly forces a cast, such as a library that types its schemas loosely or a database driver that returns unparsed rows, put the cast in the one adapter file at that boundary and record that file as an `authorised-location` with a why-chain. With clean boundaries that is one file and one record; casts scattered across many files are the sign the boundary is missing.
|
|
44
46
|
|
|
45
47
|
## Exceptions
|
|
46
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file sits on an external boundary that forces an assertion, such as an adapter. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
48
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file sits on an external boundary that forces an assertion, such as an adapter. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
47
49
|
|
|
48
50
|
```json
|
|
49
51
|
{ "version": 1, "exceptions": [
|
|
@@ -53,4 +55,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
53
55
|
|
|
54
56
|
Records on `CD-2#non-null-assertions` take the same kinds. Existing `!` debt is usually a `file-carve-out` per file, or one `clause-wide-carve-out` while an assessment's steps pay it down. An `eslint-disable` naming `hone-cd2/no-restricted-syntax`, or naming no rule, is held only by an `authorised-location` or `file-carve-out` on this clause and its file; a `clause-wide-carve-out` does not hold it. The projection carries every record for it, so run `hone project` after recording one.
|
|
55
57
|
|
|
56
|
-
|
|
58
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-23/CHECKS.md
CHANGED
|
@@ -24,7 +24,7 @@ This is `src/price.ts` with no `src/price.test.ts` beside it.
|
|
|
24
24
|
Add `src/price.test.ts` next to the file, with at least one test of its behaviour.
|
|
25
25
|
|
|
26
26
|
## Exceptions
|
|
27
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file only wires exports together and has no behaviour of its own to test. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
27
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file only wires exports together and has no behaviour of its own to test. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
28
28
|
|
|
29
29
|
```json
|
|
30
30
|
{ "version": 1, "exceptions": [
|
|
@@ -32,4 +32,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
32
32
|
] }
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-25/CHECKS.md
CHANGED
|
@@ -24,10 +24,10 @@ const clock = { now: vi.fn(() => 1) };
|
|
|
24
24
|
```ts
|
|
25
25
|
const clock = { now: vi.fn().mockReturnValue(1) };
|
|
26
26
|
```
|
|
27
|
-
Return a canned value: that double is a stub. If the double needs logic, the seam is probably too wide
|
|
27
|
+
Return a canned value: that double is a stub. If the double needs logic, the seam is probably too wide.
|
|
28
28
|
|
|
29
29
|
## Exceptions
|
|
30
|
-
|
|
30
|
+
For debt in one file, add a `file-carve-out` entry to `discipline-exceptions.json` at the repository root: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
31
31
|
|
|
32
32
|
```json
|
|
33
33
|
{ "version": 1, "exceptions": [
|
|
@@ -35,4 +35,4 @@ A double that legitimately needs behaviour is a fake: write it once as an in-mem
|
|
|
35
35
|
] }
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|
package/rules/CD-25/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
A unit test replaces everything outside the unit under test with a test double, injected through the unit's own seam — no real I/O, no real collaborators. The test exercises exactly one unit's logic, with every dependency a controlled double, so a failure points at that unit and nowhere else.
|
|
6
6
|
|
|
7
|
-
**Test doubles.** These rules use Gerard Meszaros's names from *xUnit Test Patterns*, and only in these senses. A *dummy* is passed but never used. A *stub* returns canned answers. A *spy* is a stub that also records how it was called, for the test to assert afterwards. A *mock* is set up with expectations and verifies them itself. A *fake* is a working, lightweight implementation, such as an in-memory repository. The doubles a unit test
|
|
7
|
+
**Test doubles.** These rules use Gerard Meszaros's names from *xUnit Test Patterns*, and only in these senses. A *dummy* is passed but never used. A *stub* returns canned answers. A *spy* is a stub that also records how it was called, for the test to assert afterwards. A *mock* is set up with expectations and verifies them itself. A *fake* is a working, lightweight implementation, such as an in-memory repository. The doubles a unit test uses are dummies, stubs and spies, with their answers written out. A double that needs behaviour of its own is a finding about the unit's seam or its collaborator.
|
|
8
8
|
|
|
9
9
|
Review lens: [di-discipline](../../methods/lenses/di-discipline.md), [test-discipline](../../methods/lenses/test-discipline.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
|
|
10
10
|
|
|
@@ -15,10 +15,10 @@ Review lens: [di-discipline](../../methods/lenses/di-discipline.md), [test-disci
|
|
|
15
15
|
**What a finding points at.** Match the sites against these causes.
|
|
16
16
|
- *A seam wider than its use.* The double needs logic because the port does many things or takes rich input. Narrow the port, and its inputs, to what this unit uses; a stub then answers its one question.
|
|
17
17
|
- *Behaviour hiding in a collaborator.* The double re-implements logic the unit relies on. That logic is a unit of its own with its own tests; a stub returns its result.
|
|
18
|
-
- *Real I/O in a unit test.* Files, on-disk fixtures, network, the clock. A dependency was reached for, not injected. Inject a port and give the test a stub
|
|
18
|
+
- *Real I/O in a unit test.* Files, on-disk fixtures, network, the clock. A dependency was reached for, not injected. Inject a port and give the test a stub.
|
|
19
19
|
- *An integration test with a unit suffix.* It wires several units over real backings. Move it to the integration layer, and keep that layer thin.
|
|
20
20
|
|
|
21
|
-
**Where to go.** Unit tests give every collaborator a stub or spy with canned answers
|
|
21
|
+
**Where to go.** Unit tests give every collaborator a stub or spy with canned answers. On-disk fixtures are integration test tools: used at a bare minimum, only where the composition under test demands a real backing.
|
|
22
22
|
|
|
23
23
|
**Reactions to distrust.**
|
|
24
24
|
- "It's just tests." The test is the unit's first consumer. A collaborator that is hard to replace with a double is a design finding.
|
package/rules/CD-26/CHECKS.md
CHANGED
|
@@ -25,7 +25,7 @@ const subject = createSubject({ store: storeStub });
|
|
|
25
25
|
Pass the collaborator in as a dependency and hand the test a stub.
|
|
26
26
|
|
|
27
27
|
## Exceptions
|
|
28
|
-
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs to intercept a module. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs
|
|
28
|
+
Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs to intercept a module. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
|
|
29
29
|
|
|
30
30
|
```json
|
|
31
31
|
{ "version": 1, "exceptions": [
|
|
@@ -33,4 +33,4 @@ Add an entry to `discipline-exceptions.json` at the repository root. Use `author
|
|
|
33
33
|
] }
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
An `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. A record imported from an earlier system carries `provenance` instead. A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note, and a `whyChain` or `provenance` it gives anyway is still judged. With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` may give only its `reason`, which will be refused in the next major release. [The exceptions format](../../README.md#discipline-exceptionsjson) gives each shape.
|