@hailstails/hone 0.1.0-pre.5 → 0.1.0-pre.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/ADOPTING.md +151 -42
  2. package/MIGRATING.md +55 -4
  3. package/README.md +120 -43
  4. package/THIRD-PARTY-NOTICES.md +1 -1
  5. package/api/audit.d.ts +3 -0
  6. package/api/audit.js +10 -0
  7. package/api/rule-set.js +0 -0
  8. package/api/testing.d.ts +5 -0
  9. package/api/testing.js +211 -0
  10. package/chunks/chunk-3LCKBX5T.js +2134 -0
  11. package/chunks/chunk-5LCLBXP7.js +76 -0
  12. package/chunks/{chunk-7PVPPH4C.js → chunk-LDQUT742.js} +3 -1
  13. package/chunks/{chunk-VUG3DJHN.js → chunk-MYX7GAVM.js} +9 -9
  14. package/chunks/{chunk-SWPCKTJV.js → chunk-NCDYOPHG.js} +7340 -2124
  15. package/chunks/{chunk-HVABJ7T4.js → chunk-NRXSM7BY.js} +73 -12
  16. package/chunks/{chunk-YBWVUDIG.js → chunk-P3NLETF5.js} +1 -1
  17. package/chunks/{chunk-IIMK5BCL.js → chunk-POZL7G62.js} +15 -13
  18. package/chunks/{chunk-7OVV6NEU.js → chunk-WPRR2MPJ.js} +1 -1
  19. package/core/check/tool-command.js +531 -1967
  20. package/core/conformance/conformance-testing-types.d.ts +28 -0
  21. package/core/conformance/conformance-types.d.ts +7 -0
  22. package/docs/adding-a-discipline-or-mechanism.md +27 -14
  23. package/docs/extending.md +22 -11
  24. package/docs/output-contract.md +326 -0
  25. package/mechanisms/audit/CD-19/import-boundaries.js +3 -3
  26. package/mechanisms/audit/CD-2/piece.json +6 -1
  27. package/mechanisms/audit/CD-5/comments-directives.js +10 -26
  28. package/mechanisms/audit/runner/README.md +3 -2
  29. package/mechanisms/audit/runner/runner.js +97 -35
  30. package/mechanisms/eslint/CD-2/README.md +12 -0
  31. package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +16 -0
  32. package/mechanisms/eslint/CD-2/piece.json +25 -0
  33. package/mechanisms/eslint/runner/README.md +12 -5
  34. package/mechanisms/eslint/runner/runner.js +900 -242
  35. package/methods/README.md +2 -0
  36. package/methods/assessment-template.md +35 -0
  37. package/methods/lenses/clean-architecture.md +2 -2
  38. package/methods/lenses/decomposition.md +2 -2
  39. package/methods/lenses/defended-on-intent.md +7 -7
  40. package/methods/lenses/di-discipline.md +38 -26
  41. package/methods/lenses/errors-as-data.md +2 -2
  42. package/methods/lenses/function-first.md +2 -2
  43. package/methods/lenses/naming.md +2 -2
  44. package/methods/lenses/test-discipline.md +15 -13
  45. package/methods/lenses/type-soundness.md +2 -2
  46. package/methods/lenses/zod-boundary.md +2 -2
  47. package/package.json +8 -3
  48. package/rules/CD-1/CHECKS.md +37 -0
  49. package/rules/CD-1/README.md +17 -32
  50. package/rules/CD-10/CHECKS.md +49 -0
  51. package/rules/CD-10/README.md +21 -49
  52. package/rules/CD-11/CHECKS.md +13 -0
  53. package/rules/CD-11/README.md +14 -8
  54. package/rules/CD-12/CHECKS.md +13 -0
  55. package/rules/CD-12/README.md +14 -8
  56. package/rules/CD-13/CHECKS.md +13 -0
  57. package/rules/CD-13/README.md +14 -8
  58. package/rules/CD-14/CHECKS.md +49 -0
  59. package/rules/CD-14/README.md +22 -48
  60. package/rules/CD-15/CHECKS.md +40 -0
  61. package/rules/CD-15/README.md +22 -40
  62. package/rules/CD-16/CHECKS.md +7 -0
  63. package/rules/CD-16/README.md +3 -5
  64. package/rules/CD-17/CHECKS.md +37 -0
  65. package/rules/CD-17/README.md +17 -31
  66. package/rules/CD-18/CHECKS.md +13 -0
  67. package/rules/CD-18/README.md +15 -9
  68. package/rules/CD-19/CHECKS.md +49 -0
  69. package/rules/CD-19/README.md +18 -44
  70. package/rules/CD-2/CHECKS.md +56 -0
  71. package/rules/CD-2/README.md +18 -35
  72. package/rules/CD-2/discipline.json +68 -0
  73. package/rules/CD-20/CHECKS.md +7 -0
  74. package/rules/CD-20/README.md +3 -5
  75. package/rules/CD-21/CHECKS.md +13 -0
  76. package/rules/CD-21/README.md +14 -9
  77. package/rules/CD-22/CHECKS.md +13 -0
  78. package/rules/CD-22/README.md +13 -8
  79. package/rules/CD-23/CHECKS.md +35 -0
  80. package/rules/CD-23/README.md +14 -29
  81. package/rules/CD-24/CHECKS.md +7 -0
  82. package/rules/CD-24/README.md +3 -5
  83. package/rules/CD-25/CHECKS.md +38 -0
  84. package/rules/CD-25/README.md +20 -32
  85. package/rules/CD-26/CHECKS.md +36 -0
  86. package/rules/CD-26/README.md +18 -31
  87. package/rules/CD-27/CHECKS.md +45 -0
  88. package/rules/CD-27/README.md +18 -40
  89. package/rules/CD-28/CHECKS.md +13 -0
  90. package/rules/CD-28/README.md +14 -8
  91. package/rules/CD-29/CHECKS.md +13 -0
  92. package/rules/CD-29/README.md +12 -8
  93. package/rules/CD-3/CHECKS.md +42 -0
  94. package/rules/CD-3/README.md +20 -42
  95. package/rules/CD-30/CHECKS.md +13 -0
  96. package/rules/CD-30/README.md +13 -8
  97. package/rules/CD-31/CHECKS.md +13 -0
  98. package/rules/CD-31/README.md +12 -8
  99. package/rules/CD-32/CHECKS.md +13 -0
  100. package/rules/CD-32/README.md +13 -8
  101. package/rules/CD-33/CHECKS.md +13 -0
  102. package/rules/CD-33/README.md +13 -8
  103. package/rules/CD-34/CHECKS.md +13 -0
  104. package/rules/CD-34/README.md +12 -8
  105. package/rules/CD-39/CHECKS.md +13 -0
  106. package/rules/CD-39/README.md +13 -8
  107. package/rules/CD-4/CHECKS.md +13 -0
  108. package/rules/CD-4/README.md +15 -8
  109. package/rules/CD-40/CHECKS.md +39 -0
  110. package/rules/CD-40/README.md +17 -33
  111. package/rules/CD-41/CHECKS.md +54 -0
  112. package/rules/CD-41/README.md +23 -54
  113. package/rules/CD-42/CHECKS.md +47 -0
  114. package/rules/CD-42/README.md +19 -47
  115. package/rules/CD-43/CHECKS.md +37 -0
  116. package/rules/CD-43/README.md +15 -31
  117. package/rules/CD-44/CHECKS.md +48 -0
  118. package/rules/CD-44/README.md +20 -48
  119. package/rules/CD-45/CHECKS.md +13 -0
  120. package/rules/CD-45/README.md +14 -8
  121. package/rules/CD-46/CHECKS.md +7 -0
  122. package/rules/CD-46/README.md +16 -4
  123. package/rules/CD-47/CHECKS.md +37 -0
  124. package/rules/CD-47/README.md +16 -32
  125. package/rules/CD-5/CHECKS.md +52 -0
  126. package/rules/CD-5/README.md +22 -52
  127. package/rules/CD-6/CHECKS.md +51 -0
  128. package/rules/CD-6/README.md +22 -51
  129. package/rules/CD-7/CHECKS.md +46 -0
  130. package/rules/CD-7/README.md +23 -46
  131. package/rules/CD-7a/CHECKS.md +38 -0
  132. package/rules/CD-7a/README.md +14 -32
  133. package/rules/CD-8/CHECKS.md +42 -0
  134. package/rules/CD-8/README.md +20 -42
  135. package/rules/CD-9/CHECKS.md +13 -0
  136. package/rules/CD-9/README.md +15 -8
  137. package/rules/README.md +5 -3
  138. package/rules/SPIRIT.md +50 -0
  139. package/api/audit.mjs +0 -1
  140. package/api/rule-set.mjs +0 -1
@@ -2,41 +2,27 @@
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 fake clock and advance it deterministically. Bare time construction anywhere else makes behaviour un-fakeable and non-deterministic.
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 fake clock and advance it deterministically. Bare time construction anywhere else makes behaviour impossible to replace with a test double, and non-deterministic.
6
6
 
7
- The sections below describe what the audit check covers.
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
 
9
- ## Clauses
9
+ ## Spirit
10
10
 
11
- | Clause | Mechanism | Checks |
12
- | --- | --- | --- |
13
- | `CD-17#clock-sources` | audit | `Date.now()` and `new Date` |
11
+ **What the friction is for.** Code that reads the time itself behaves differently depending on when it runs. The friction makes time an input, so logic is deterministic and tests can set and advance time on demand.
14
12
 
15
- 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.
13
+ **What a finding points at.** Match the sites against these causes.
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
+ - *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 fake clock and advance it.
17
+ - *Tests that build their own instants.* A test making dates for itself is choosing time outside the clock. Take instants from the fake clock.
16
18
 
17
- ## What the check flags
18
- - `.ts` and `.tsx` files, including tests. Generated folders (`node_modules`, `dist`, `build`, `coverage`, `.git`, root `vendor`) are skipped; any other folder or file can be left out with `exclude` in disciplines.json.
19
- - Any line containing `Date.now()` or `new Date`, one finding per line. Comments and strings are matched too.
20
- - Other time sources (`performance.now`, timers) are not checked; they are left to review.
19
+ **Where to go.** One clock abstraction reads real time. Everything else receives an instant or the clock. Tests set the time they need.
21
20
 
22
- ## Example violation
23
- ```ts
24
- const startedAt = Date.now();
25
- ```
21
+ **Reactions to distrust.**
22
+ - "It's just a log timestamp." It is still output nobody can pin in a test. Read it through the clock.
23
+ - "It's just tests." The rule covers tests. A test that reads real time cannot be repeated exactly.
24
+ - "Exclude that folder." Then that folder's behaviour depends on the hour it runs. Find the clock port it is missing.
26
25
 
27
- ## How to fix
28
- ```ts
29
- const startedAt = clock.now();
30
- ```
31
- Accept a clock as a dependency and read time only through it. The one real implementation lives in an adapter.
32
-
33
- ## Exceptions
34
- 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 needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
35
-
36
- ```json
37
- { "version": 1, "exceptions": [
38
- { "kind": "authorised-location", "clause": "CD-17#clock-sources", "file": "src/adapters/system-clock.ts", "reason": "..." }
39
- ] }
40
- ```
41
-
42
- Every record, `authorised-location` included, 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`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
26
+ **Principles behind it.**
27
+ - *Dependency Inversion Principle* (Robert C. Martin, SOLID). Time is a detail; the logic depends on a clock abstraction it is given.
28
+ - *Functional core, imperative shell* (Gary Bernhardt). Reading the clock is an effect at the shell. The core receives the instant as a value and stays pure.
@@ -0,0 +1,13 @@
1
+ # CD-18 checks
2
+
3
+ Read [the rule and its spirit](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
4
+
5
+ ## Clauses
6
+
7
+ | Clause | Mechanism | Checks |
8
+ | --- | --- | --- |
9
+ | `CD-18#process-lifecycle-ports` | review | process signals, exit, kill and high-resolution timing arrive through an injected port |
10
+
11
+ ## How it is checked
12
+
13
+ Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the rule](README.md) with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
@@ -2,18 +2,24 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- Process-lifecycle side effects — signal handlers, exit, kill, high-resolution timing — are a capability that arrives through an injected port, not reached for ambiently on the runtime's process global. Confining them behind a port makes lifecycle behaviour composable and fakeable in tests, instead of a hidden dependency on the running process.
5
+ Process-lifecycle side effects — signal handlers, exit, kill, high-resolution timing — are a capability that arrives through an injected port, not reached for ambiently on the runtime's process global. Confining them behind a port makes lifecycle behaviour composable and replaceable with a test double in tests, instead of a hidden dependency on the running process.
6
6
 
7
- The sections below describe how the rule is checked.
7
+ Review lens: [di-discipline](../../methods/lenses/di-discipline.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
8
8
 
9
- ## Clauses
9
+ ## Spirit
10
10
 
11
- | Clause | Mechanism | Checks |
12
- | --- | --- | --- |
13
- | `CD-18#process-lifecycle-ports` | review | process signals, exit, kill and high-resolution timing arrive through an injected port |
11
+ **What the friction is for.** Exiting, handling signals and reading process timers are side effects on the running program. The friction makes them a port the code receives, so lifecycle behaviour can be composed and tested.
14
12
 
15
- Review lens: [di-discipline](../../methods/lenses/di-discipline.md). The lens reviews the whole rule, including what no check flags.
13
+ **What a finding points at.** Match the sites against these causes.
14
+ - *Exit called deep inside.* A function ends the process instead of returning. Return the outcome; let the entry point decide to exit.
15
+ - *Signal handling scattered.* Several modules register handlers. Gather lifecycle in one port wired at startup.
16
+ - *Timing read from the process.* Code measures time through the process global. Inject it.
16
17
 
17
- ## How it is checked
18
+ **Where to go.** Lifecycle operations arrive through one injected port. Only the composition root touches the real process.
18
19
 
19
- Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies the rule above with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
20
+ **Reactions to distrust.**
21
+ - "It's a CLI, exit is normal." Exit at the entry point. Everywhere else, return.
22
+
23
+ **Principles behind it.**
24
+ - *Dependency Inversion Principle* (Robert C. Martin, SOLID). Code depends on a lifecycle abstraction, not the runtime global.
25
+ - *Functional core, imperative shell* (Gary Bernhardt). The decision to stop is a value; stopping happens at the shell.
@@ -0,0 +1,49 @@
1
+ # CD-19 checks
2
+
3
+ Read [the rule and its spirit](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
4
+
5
+ ## Clauses
6
+
7
+ | Clause | Mechanism | Checks |
8
+ | --- | --- | --- |
9
+ | `CD-19#import-boundaries` | audit | imports of the packages the repository confines, and any `node:` import |
10
+
11
+ ## What the check flags
12
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
13
+ - A line with `from "<specifier>"` where the specifier is a package listed in the clause's `confinedPackages` setting (see [Settings](#settings)) or a subpath of one: `hono` covers `hono` and `hono/cors`, and `@scope/name` covers `@scope/name` and `@scope/name/client`. A longer name is a different package, so `hono` does not cover `honox` or `hono-extra`. With no packages listed, which is the default, no library import is flagged. Type-only imports and matches inside strings are flagged too.
14
+ - A `node:` specifier in an import, `export ... from`, `import("node:...")`, `import type`, `import x = require(...)` or `require("node:...")`. Unprefixed `fs` is not detected.
15
+ - The source rule covers every third-party dependency; the check covers only the listed packages. The rest is left to review.
16
+
17
+ ## Settings
18
+ List each package the repository confines behind a wrapping port in `disciplines.json`, then record each wrapping file as an `authorised-location`:
19
+
20
+ ```json
21
+ "clauseSettings": {
22
+ "CD-19#import-boundaries": { "confinedPackages": ["winston", "uuid"] }
23
+ }
24
+ ```
25
+
26
+ ## Example violation
27
+ With `"confinedPackages": ["uuid"]`, both lines are flagged; with the default, only the first.
28
+ ```ts
29
+ import { readFileSync } from "node:fs";
30
+ import { v4 } from "uuid";
31
+ ```
32
+
33
+ ## How to fix
34
+ ```ts
35
+ import { createFileReader } from "./file-reader.ts";
36
+ import { createIdGenerator } from "./id-generator.ts";
37
+ ```
38
+ Import your own port. Only the wrapping file imports the library.
39
+
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 needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
42
+
43
+ ```json
44
+ { "version": 1, "exceptions": [
45
+ { "kind": "authorised-location", "clause": "CD-19#import-boundaries", "file": "src/adapters/file-reader.ts", "reason": "..." }
46
+ ] }
47
+ ```
48
+
49
+ Every record, `authorised-location` included, 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`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
@@ -2,54 +2,28 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- Every dependency on code the project does not own — a third-party library or the runtime's own standard library alike — is confined to a single wrapping port at the boundary; the rest of the codebase depends on that port, never the vendor or platform surface, runtime or type-only. A dependency swap then touches one file, the vendor's types never leak inward, and each confined capability is nameable and fakeable in tests. There is no inline carve-out: a stdlib call in the middle of business logic is as much a violation as a scattered library import. Opening a new wrapping site for a new dependency is a deliberate, recorded decision.
5
+ Every dependency on code the project does not own — a third-party library or the runtime's own standard library alike — is confined to a single wrapping port at the boundary; the rest of the codebase depends on that port, never the vendor or platform surface, runtime or type-only. A dependency swap then touches one file, the vendor's types never leak inward, and each confined capability is nameable and replaceable with a test double. There is no inline carve-out: a stdlib call in the middle of business logic is as much a violation as a scattered library import. Opening a new wrapping site for a new dependency is a deliberate, recorded decision.
6
6
 
7
- The sections below describe what the audit check covers.
7
+ Review lens: [function-first](../../methods/lenses/function-first.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
 
9
- ## Clauses
9
+ ## Spirit
10
10
 
11
- | Clause | Mechanism | Checks |
12
- | --- | --- | --- |
13
- | `CD-19#import-boundaries` | audit | imports of the packages the repository confines, and any `node:` import |
11
+ **What the friction is for.** Depending on code you do not own hands that code a say in the shape of yours. The friction makes depending on your own port the easy path, so a swap touches one file, vendor types stay out, and every capability has a name and a test double.
14
12
 
15
- Review lens: [function-first](../../methods/lenses/function-first.md). The lens reviews the whole rule, including what no check flags.
13
+ **What a finding points at.** Match the sites against these causes.
14
+ - *A capability with no name.* Many files import the same library or runtime module. Name the capability, wrap it once, inject it.
15
+ - *A port that leaks.* A wrapper exists but passes vendor types or objects through, so callers import the vendor anyway. Make the port speak your types.
16
+ - *Decisions doing I/O.* A runtime call sits in the middle of business logic. Separate the decision from the effect; the effect arrives through a port.
17
+ - *Construction spread everywhere.* Each module builds its own dependencies. Move construction to one composition root that passes ports in.
16
18
 
17
- ## What the check flags
18
- - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
19
- - A line with `from "<specifier>"` where the specifier is a package listed in the clause's `confinedPackages` setting (see [Settings](#settings)) or a subpath of one: `hono` covers `hono` and `hono/cors`, and `@scope/name` covers `@scope/name` and `@scope/name/client`. A longer name is a different package, so `hono` does not cover `honox` or `hono-extra`. With no packages listed, which is the default, no library import is flagged. Type-only imports and matches inside strings are flagged too.
20
- - A `node:` specifier in an import, `export ... from`, `import("node:...")`, `import type`, `import x = require(...)` or `require("node:...")`. Unprefixed `fs` is not detected.
21
- - The source rule covers every third-party dependency; the check covers only the listed packages. The rest is left to review.
19
+ **Where to go.** Each external capability has one wrapping file, recorded as its authorised location. Everything else imports your port. Opening a new wrapper is a recorded decision, not an inline one.
22
20
 
23
- ## Settings
24
- List each package the repository confines behind a wrapping port in `disciplines.json`, then record each wrapping file as an `authorised-location`:
21
+ **Reactions to distrust.**
22
+ - "It's only the standard library." The same reasons apply: it cannot be replaced in a test and it ties logic to a platform. The rule makes no stdlib carve-out.
23
+ - "Wrapping is boilerplate." One small file per capability, against the whole codebase knowing a vendor's surface.
24
+ - "Exclude that folder." An excluded folder is a boundary nobody designed. Design it, then authorise the one file.
25
25
 
26
- ```json
27
- "clauseSettings": {
28
- "CD-19#import-boundaries": { "confinedPackages": ["winston", "uuid"] }
29
- }
30
- ```
31
-
32
- ## Example violation
33
- With `"confinedPackages": ["uuid"]`, both lines are flagged; with the default, only the first.
34
- ```ts
35
- import { readFileSync } from "node:fs";
36
- import { v4 } from "uuid";
37
- ```
38
-
39
- ## How to fix
40
- ```ts
41
- import { createFileReader } from "./file-reader.ts";
42
- import { createIdGenerator } from "./id-generator.ts";
43
- ```
44
- Import your own port. Only the wrapping file imports the library.
45
-
46
- ## Exceptions
47
- 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 needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
48
-
49
- ```json
50
- { "version": 1, "exceptions": [
51
- { "kind": "authorised-location", "clause": "CD-19#import-boundaries", "file": "src/adapters/file-reader.ts", "reason": "..." }
52
- ] }
53
- ```
54
-
55
- Every record, `authorised-location` included, 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`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
26
+ **Principles behind it.**
27
+ - *Dependency Inversion Principle* (Robert C. Martin, SOLID). Your code depends on an abstraction you own; the vendor detail depends on it, not the other way round.
28
+ - *Ports and adapters* (Alistair Cockburn, hexagonal architecture). The application talks through ports; one adapter per outside system translates. Swapping the system means swapping the adapter.
29
+ - *Functional core, imperative shell* (Gary Bernhardt). Decisions stay pure; effects live at the edge and arrive through ports.
@@ -0,0 +1,56 @@
1
+ # CD-2 checks
2
+
3
+ Read [the rule and its spirit](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
4
+
5
+ ## Clauses
6
+
7
+ | Clause | Mechanism | Checks |
8
+ | --- | --- | --- |
9
+ | `CD-2#cast-expressions` | audit | a type assertion that is not on the permitted list |
10
+ | `CD-2#non-null-assertions` | eslint | a non-null assertion, `x!`, or a definite assignment assertion, `let x!: T` or `field!: T` |
11
+
12
+ ## What the check flags
13
+ - `.ts` and `.tsx` files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
14
+ - Every `x as T` and `<T>x` assertion except a const assertion, `as const` or `<const>x`. Assertions whose type contains `any` are CD-1's and are not repeated here.
15
+ - `as unknown` and `<unknown>x` are flagged. Widening never needs an assertion: annotate instead, `const parsed: unknown = JSON.parse(text)`.
16
+ - A cast through `unknown`, such as `raw as unknown as User`, `(<unknown>raw) as User` or one wrapped in `!` or `satisfies`, is flagged with its own message, and so is its `unknown` half. It is the escape hatch that turns any value into any type; check the value's shape at runtime at the boundary instead.
17
+ - `@ts-expect-error`, `@ts-ignore` and `@ts-nocheck` in the `.ts` and `.tsx` files this clause checks are reported as `inline-disable` native exceptions of this clause, where the compiler honours them and whether or not they hide a cast. Directives in `.mts`, `.cts` and JavaScript files are not read. Each is debt on this clause in its file: an `authorised-location` or `file-carve-out` on the file covers it, a `clause-wide-carve-out` does not, and a tracked reference on the comment (CD-5) does not stand in for the record.
18
+ - Test files, test helpers and scripts are checked like any other source; a test that needs a cast needs a typed stub or a narrower port.
19
+ - There are no settings: a boundary that forces a cast is an exception record, as below.
20
+
21
+ ## What the ESLint check flags
22
+ Needs ESLint adopted through the projection; see [the ESLint piece](../../mechanisms/eslint/CD-2/README.md).
23
+ - `hone-cd2/no-restricted-syntax` is ESLint's `no-restricted-syntax` with two selectors, one per form.
24
+ - `TSNonNullExpression` flags every non-null assertion, `x!`, wherever it sits: a read such as `user.name!`, a call such as `totals.get(key)!.toFixed(2)`, an assignment target such as `basket.total! = 0`. It is the same node typescript-eslint's `no-non-null-assertion` reports.
25
+ - `[definite=true]` flags every definite assignment assertion: `let total!: number` and a class field `balance!: number`.
26
+ - Each finding sits on the line where the asserted expression or the declared name starts.
27
+ - Allowed: logical not `!ready`, `!==`, an optional property `total?: number`, `??` fallbacks, and an initialised binding.
28
+ - There are no settings. No `audit` mechanism checks this clause, so a repository without ESLint lists it as `"not-run"`, and review owes it.
29
+
30
+ ## Example violation
31
+ ```ts
32
+ const user = response as User;
33
+ const name = user.name!;
34
+ ```
35
+
36
+ ## How to fix
37
+ ```ts
38
+ const user = userSchema.parse(response);
39
+ const name = user.name ?? "anonymous";
40
+ ```
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
+
43
+ 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
+
45
+ ## 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 needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
47
+
48
+ ```json
49
+ { "version": 1, "exceptions": [
50
+ { "kind": "authorised-location", "clause": "CD-2#cast-expressions", "file": "src/adapters/row-reader.ts", "reason": "..." }
51
+ ] }
52
+ ```
53
+
54
+ 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
+
56
+ Every record, `authorised-location` included, 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`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
@@ -4,44 +4,27 @@
4
4
 
5
5
  A type assertion tells the compiler the value is something the compiler cannot see — it is a claim the type system can no longer check. Casting is therefore permitted only at a closed, enumerated list of sites where an external boundary genuinely forces it, each one an exception record for the file at that boundary. Everywhere else a cast is a design smell: the type is wrong, so fix the type rather than assert over it. Adding a site to the permitted list is a deliberate, recorded amendment, not an inline decision.
6
6
 
7
- The sections below describe what the audit check covers.
7
+ Review lens: [type-soundness](../../methods/lenses/type-soundness.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
 
9
- ## Clauses
9
+ ## Spirit
10
10
 
11
- | Clause | Mechanism | Checks |
12
- | --- | --- | --- |
13
- | `CD-2#cast-expressions` | audit | a type assertion that is not on the permitted list |
11
+ **What the friction is for.** A cast is a claim the compiler cannot check. The friction makes the honest route, parsing the value or fixing its type, the easy one. The few claims that remain are visible and sit in known places.
14
12
 
15
- Review lens: [type-soundness](../../methods/lenses/type-soundness.md). The lens reviews the whole rule, including what no check flags.
13
+ **What a finding points at.** Match the sites against these causes.
14
+ - *Parsing skipped at a boundary.* Raw input is asserted into shape instead of checked. Parse it once where it enters and the type follows.
15
+ - *A declared type that is wrong.* The code builds something its type does not describe. Fix the declaration and the cast goes.
16
+ - *A boundary that is missing.* Casts cluster around one library or data source across many files. Make one wrapping file the boundary and keep the rest cast-free.
17
+ - *A return type wider than its use.* A function returns a broad type and every caller narrows it. Return the narrow type.
18
+ - *A parameter type wider than its use.* A function asks for a whole record but reads two fields. It shows in tests, where someone casts a two-field object through to the full type rather than build it all. The function asks for more than it needs. Accept only the fields it uses; the test then builds those two fields honestly.
16
19
 
17
- ## What the check flags
18
- - `.ts` and `.tsx` files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
19
- - Every `x as T` and `<T>x` assertion except a const assertion, `as const` or `<const>x`. Assertions whose type contains `any` are CD-1's and are not repeated here.
20
- - `as unknown` and `<unknown>x` are flagged. Widening never needs an assertion: annotate instead, `const parsed: unknown = JSON.parse(text)`.
21
- - A cast through `unknown`, such as `raw as unknown as User`, `(<unknown>raw) as User` or one wrapped in `!` or `satisfies`, is flagged with its own message, and so is its `unknown` half. It is the escape hatch that turns any value into any type; check the value's shape at runtime at the boundary instead.
22
- - Test files, test helpers and scripts are checked like any other source; a test that needs a cast needs a typed fake or a narrower port.
23
- - There are no settings: a boundary that forces a cast is an exception record, as below.
20
+ **Where to go.** Casts live only in a few named boundary files, each recorded as an authorised location. Clean boundaries make that cheap; that is what authorised locations are for. Everywhere else the type follows from a check.
24
21
 
25
- ## Example violation
26
- ```ts
27
- const user = response as User;
28
- ```
22
+ **Reactions to distrust.**
23
+ - "It's just tests." Tests are violations too. A test that casts is building a value its type does not allow. Either build it properly, or the unit asks for more than it uses.
24
+ - "Add a permission for this shape." Measure first. A permission can hide a real defect, such as database rows that were never parsed.
25
+ - "The library forces it." It forces one site. Put that site in the wrapping file.
29
26
 
30
- ## How to fix
31
- ```ts
32
- const user = userSchema.parse(response);
33
- ```
34
- Parse or narrow the value so the type follows from a check rather than from an assertion.
35
-
36
- 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.
37
-
38
- ## Exceptions
39
- 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 needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
40
-
41
- ```json
42
- { "version": 1, "exceptions": [
43
- { "kind": "authorised-location", "clause": "CD-2#cast-expressions", "file": "src/adapters/row-reader.ts", "reason": "..." }
44
- ] }
45
- ```
46
-
47
- Every record, `authorised-location` included, 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`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
27
+ **Principles behind it.**
28
+ - *Parse, don't validate* (Alexis King). A parse produces the type; a cast only claims it. Parse once at the boundary and the claim is never needed.
29
+ - *Interface Segregation Principle* (Robert C. Martin, SOLID). Depend only on what you use. A parameter that asks for exactly the fields it reads needs no cast to satisfy, in production or in tests.
30
+ - *Ports and adapters* (Alistair Cockburn, hexagonal architecture). The adapter at the edge is where outside shapes are translated, so it is the one place an unavoidable assertion belongs.
@@ -78,6 +78,74 @@
78
78
  }
79
79
  ]
80
80
  }
81
+ },
82
+ {
83
+ "kind": "mechanical",
84
+ "id": "non-null-assertions",
85
+ "summary": "No non-null or definite assignment assertions",
86
+ "mechanisms": [
87
+ "eslint"
88
+ ],
89
+ "anchor": {
90
+ "kind": "keyword",
91
+ "keyword": "!"
92
+ },
93
+ "cases": {
94
+ "flag": [
95
+ {
96
+ "name": "non-null assertion on a property read",
97
+ "fileName": "non-null-read.ts",
98
+ "source": "declare const user: { readonly name?: string };\nexport const name = user.name!;\n",
99
+ "expectedLines": [
100
+ 2
101
+ ]
102
+ },
103
+ {
104
+ "name": "non-null assertion before a member call",
105
+ "fileName": "non-null-call.ts",
106
+ "source": "declare const totals: ReadonlyMap<string, number>;\nexport const shown = totals.get(\"basket\")!.toFixed(2);\n",
107
+ "expectedLines": [
108
+ 2
109
+ ]
110
+ },
111
+ {
112
+ "name": "definite assignment assertion on a let",
113
+ "fileName": "definite-let.ts",
114
+ "source": "declare const load: (assign: (value: number) => void) => void;\nlet total!: number;\nload((value) => {\n total = value;\n});\nexport { total };\n",
115
+ "expectedLines": [
116
+ 2
117
+ ]
118
+ },
119
+ {
120
+ "name": "definite assignment assertion on a class field",
121
+ "fileName": "definite-field.ts",
122
+ "source": "export class Account {\n balance!: number;\n}\n",
123
+ "expectedLines": [
124
+ 2
125
+ ]
126
+ }
127
+ ],
128
+ "allow": [
129
+ {
130
+ "name": "fallback for an absent value",
131
+ "fileName": "fallback.ts",
132
+ "source": "declare const user: { readonly name?: string };\nexport const name = user.name ?? \"anonymous\";\n",
133
+ "expectedLines": []
134
+ },
135
+ {
136
+ "name": "logical not and strict inequality",
137
+ "fileName": "negation.ts",
138
+ "source": "declare const ready: boolean;\nexport const waiting = !ready;\nexport const differs = (left: number, right: number): boolean => left !== right;\n",
139
+ "expectedLines": []
140
+ },
141
+ {
142
+ "name": "initialised let and class field",
143
+ "fileName": "initialised.ts",
144
+ "source": "let total: number = 0;\nexport class Account {\n balance: number = total;\n}\nexport { total };\n",
145
+ "expectedLines": []
146
+ }
147
+ ]
148
+ }
81
149
  }
82
150
  ]
83
151
  }
@@ -0,0 +1,7 @@
1
+ # CD-20 checks
2
+
3
+ Read [the rule and its spirit](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
4
+
5
+ ## How it is checked
6
+
7
+ This discipline has no clauses of its own. Its rule is carried by [CD-19](../CD-19/README.md); select that discipline's clauses instead.
@@ -8,10 +8,8 @@ confining a third-party dependency (CD-20 was originally split out of CD-19). CD
8
8
  now covers both third-party and stdlib dependencies. This id is retained as a
9
9
  redirect so existing citations resolve; it is not independently enforced.
10
10
 
11
- The sections below describe how the rule is checked.
11
+ Review lens: [di-discipline](../../methods/lenses/di-discipline.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
12
12
 
13
- Review lens: [di-discipline](../../methods/lenses/di-discipline.md). The lens reviews the whole rule, including what no check flags.
13
+ ## Spirit
14
14
 
15
- ## How it is checked
16
-
17
- This discipline has no clauses of its own. Its rule is carried by [CD-19](../CD-19/README.md); select that discipline's clauses instead.
15
+ See [CD-19's Spirit section](../CD-19/README.md#spirit). A runtime standard-library import is the same signal as any other unwrapped dependency: a capability with no port.
@@ -0,0 +1,13 @@
1
+ # CD-21 checks
2
+
3
+ Read [the rule and its spirit](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
4
+
5
+ ## Clauses
6
+
7
+ | Clause | Mechanism | Checks |
8
+ | --- | --- | --- |
9
+ | `CD-21#default-factories` | review | each injected port ships one default production factory |
10
+
11
+ ## How it is checked
12
+
13
+ Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the rule](README.md) with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
@@ -2,18 +2,23 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- A port is not just an interface — it ships its own default production implementation, co-located in the same module. Wiring is then trivial and there is exactly one canonical construction site per capability; production wires the default, tests supply their own fakes. A port with no default factory is an incomplete capability.
5
+ A port is not just an interface — it ships its own default production implementation, co-located in the same module. Wiring is then trivial and there is exactly one canonical construction site per capability; production wires the default, tests supply their own test doubles. A port with no default factory is an incomplete capability.
6
6
 
7
- The sections below describe how the rule is checked.
7
+ Review lens: [di-discipline](../../methods/lenses/di-discipline.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
8
8
 
9
- ## Clauses
9
+ ## Spirit
10
10
 
11
- | Clause | Mechanism | Checks |
12
- | --- | --- | --- |
13
- | `CD-21#default-factories` | review | each injected port ships one default production factory |
11
+ **What the friction is for.** A port with no default implementation leaves every caller to work out how to build one. The friction makes the production wiring sit beside the port, so there is one obvious way to construct each capability.
14
12
 
15
- Review lens: [di-discipline](../../methods/lenses/di-discipline.md). The lens reviews the whole rule, including what no check flags.
13
+ **What a finding points at.** Match the ports against these causes.
14
+ - *Construction scattered.* Several places build the real implementation differently. Move it into a default factory beside the port.
15
+ - *A port invented only for tests.* It has test doubles but no real implementation. Either give it a default or question whether it is a port.
16
16
 
17
- ## How it is checked
17
+ **Where to go.** Each port's module exports its default production factory. Production wires the default; tests pass test doubles.
18
18
 
19
- Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies the rule above with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
19
+ **Reactions to distrust.**
20
+ - "The composition root builds it." It still calls one canonical factory, not its own construction.
21
+
22
+ **Principles behind it.**
23
+ - *Composition root.* All wiring happens in one place, from canonical factories.
24
+ - *Dependency Inversion Principle* (Robert C. Martin, SOLID). Callers depend on the port; the default is one implementation of it.
@@ -0,0 +1,13 @@
1
+ # CD-22 checks
2
+
3
+ Read [the rule and its spirit](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
4
+
5
+ ## Clauses
6
+
7
+ | Clause | Mechanism | Checks |
8
+ | --- | --- | --- |
9
+ | `CD-22#middleware-context` | review | middleware reads its context through a constrained generic, not an open property bag |
10
+
11
+ ## How it is checked
12
+
13
+ Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the rule](README.md) with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
@@ -4,16 +4,21 @@
4
4
 
5
5
  Middleware carries the context it consumes through a constrained generic that each layer widens, not an open property bag — so a capability the middleware reads from context (time, logging, correlation) is guaranteed present by the type rather than defensively re-checked or defaulted. A middleware that reads a context field but leaves its context generic unbounded is the violation.
6
6
 
7
- The sections below describe how the rule is checked.
7
+ Review lens: [di-discipline](../../methods/lenses/di-discipline.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
8
8
 
9
- ## Clauses
9
+ ## Spirit
10
10
 
11
- | Clause | Mechanism | Checks |
12
- | --- | --- | --- |
13
- | `CD-22#middleware-context` | review | middleware reads its context through a constrained generic, not an open property bag |
11
+ **What the friction is for.** Middleware that reads from an open property bag has to check whether what it needs is there. The friction makes the type guarantee it, so capabilities are present by construction.
14
12
 
15
- Review lens: [di-discipline](../../methods/lenses/di-discipline.md). The lens reviews the whole rule, including what no check flags.
13
+ **What a finding points at.** Match the sites against these causes.
14
+ - *Context read defensively.* Middleware checks or defaults a field like the clock or logger. Constrain its context type so the field must exist.
15
+ - *Layers that add capabilities untyped.* Earlier layers add fields the type never records. Widen the generic at each layer.
16
16
 
17
- ## How it is checked
17
+ **Where to go.** Each middleware declares the context it needs through a constrained generic. A missing capability is a compile error.
18
18
 
19
- Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies the rule above with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
19
+ **Reactions to distrust.**
20
+ - "A default is safer." A default hides wiring mistakes until they matter.
21
+
22
+ **Principles behind it.**
23
+ - *Make illegal states unrepresentable* (Yaron Minsky). A context type that requires the field cannot be built without it.
24
+ - *Explicit dependencies.* A unit states what it needs in its signature, not by reaching into a shared bag.
@@ -0,0 +1,35 @@
1
+ # CD-23 checks
2
+
3
+ Read [the rule and its spirit](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
4
+
5
+ ## Clauses
6
+
7
+ | Clause | Mechanism | Checks |
8
+ | --- | --- | --- |
9
+ | `CD-23#export-test-sibling` | audit | a production file with a runtime export and no `.test` sibling |
10
+
11
+ ## What the check flags
12
+ - Production `.ts` and `.tsx` files. Skipped: `*.test.ts(x)`, `.d.ts` and anything under `__tests__`. Generated folders (`node_modules`, `dist`, `build`, `coverage`, `.git`, root `vendor`) are skipped; any other folder or file can be left out with `exclude` in disciplines.json.
13
+ - A file with a runtime export (`export const`, `function`, `class`, `enum`, `export default`, or `export { name }`) and no `<name>.test.ts` beside it (`<name>.test.tsx` for `.tsx`). The sibling must be in the repository's file list.
14
+ - Allowed: files with only `export type`, `export interface`, `export declare`, type-only named exports or `export * from`, and files with no exports.
15
+ - The source rule asks for a test beside every source file; files without runtime exports are left to review.
16
+
17
+ ## Example violation
18
+ ```ts
19
+ export const price = 1;
20
+ ```
21
+ This is `src/price.ts` with no `src/price.test.ts` beside it.
22
+
23
+ ## How to fix
24
+ Add `src/price.test.ts` next to the file, with at least one test of its behaviour.
25
+
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 needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
28
+
29
+ ```json
30
+ { "version": 1, "exceptions": [
31
+ { "kind": "authorised-location", "clause": "CD-23#export-test-sibling", "file": "src/index.ts", "reason": "..." }
32
+ ] }
33
+ ```
34
+
35
+ Every record, `authorised-location` included, 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`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.