@hailstails/hone 1.3.0 → 1.5.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.
Files changed (140) hide show
  1. package/ADOPTING.md +8 -8
  2. package/CHANGELOG.md +36 -0
  3. package/MIGRATING.md +40 -0
  4. package/README.md +28 -7
  5. package/api/audit.d.ts +1 -1
  6. package/api/testing.js +3 -3
  7. package/chunks/{chunk-H4V72FCW.js → chunk-2O46EB4E.js} +15 -1
  8. package/chunks/chunk-335ITLPO.js +7 -0
  9. package/chunks/{chunk-YSN46EB3.js → chunk-5U4VTFD5.js} +347 -664
  10. package/chunks/{chunk-PL2PNPAR.js → chunk-E6VR3VRV.js} +1 -6
  11. package/chunks/chunk-WF3PPYRR.js +27 -0
  12. package/core/check/tool-command.js +1120 -105
  13. package/core/mechanism-port/runner-result-types.d.ts +10 -0
  14. package/docs/adding-a-discipline-or-mechanism.md +5 -3
  15. package/docs/extending.md +2 -0
  16. package/docs/output-contract.md +64 -11
  17. package/mechanisms/audit/CD-27/test-body-logic.js +397 -46
  18. package/mechanisms/audit/runner/runner.js +5 -3
  19. package/mechanisms/audit/runner/typescript-parse.d.ts +2 -0
  20. package/mechanisms/audit/runner/walker-piece.d.ts +2 -1
  21. package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +7 -4
  22. package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +21 -11
  23. package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +15 -5
  24. package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +7 -3
  25. package/mechanisms/eslint/CD-41/README.md +1 -1
  26. package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +100 -28
  27. package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +8 -4
  28. package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +8 -4
  29. package/mechanisms/eslint/runner/README.md +9 -2
  30. package/mechanisms/eslint/runner/runner.js +1410 -1384
  31. package/methods/assessment-template.md +2 -2
  32. package/methods/lenses/clean-architecture.md +7 -8
  33. package/methods/lenses/defended-on-intent.md +2 -2
  34. package/methods/lenses/di-discipline.md +14 -18
  35. package/methods/lenses/function-first.md +16 -18
  36. package/methods/lenses/test-discipline.md +1 -1
  37. package/package.json +1 -1
  38. package/rules/CD-1/CHECKS.md +6 -2
  39. package/rules/CD-1/README.md +6 -19
  40. package/rules/CD-10/CHECKS.md +5 -3
  41. package/rules/CD-10/README.md +6 -18
  42. package/rules/CD-11/CHECKS.md +4 -2
  43. package/rules/CD-11/README.md +6 -16
  44. package/rules/CD-12/CHECKS.md +4 -2
  45. package/rules/CD-12/README.md +6 -16
  46. package/rules/CD-13/CHECKS.md +4 -2
  47. package/rules/CD-13/README.md +6 -16
  48. package/rules/CD-14/CHECKS.md +3 -1
  49. package/rules/CD-14/README.md +6 -19
  50. package/rules/CD-15/CHECKS.md +5 -1
  51. package/rules/CD-15/README.md +5 -20
  52. package/rules/CD-16/CHECKS.md +3 -1
  53. package/rules/CD-16/README.md +6 -6
  54. package/rules/CD-17/CHECKS.md +3 -1
  55. package/rules/CD-17/README.md +6 -19
  56. package/rules/CD-18/CHECKS.md +4 -2
  57. package/rules/CD-18/README.md +6 -16
  58. package/rules/CD-19/CHECKS.md +8 -6
  59. package/rules/CD-19/README.md +6 -20
  60. package/rules/CD-2/CHECKS.md +7 -3
  61. package/rules/CD-2/README.md +6 -21
  62. package/rules/CD-20/CHECKS.md +3 -1
  63. package/rules/CD-20/README.md +6 -6
  64. package/rules/CD-21/CHECKS.md +4 -2
  65. package/rules/CD-21/README.md +6 -15
  66. package/rules/CD-22/CHECKS.md +4 -2
  67. package/rules/CD-22/README.md +6 -15
  68. package/rules/CD-23/CHECKS.md +5 -3
  69. package/rules/CD-23/README.md +6 -17
  70. package/rules/CD-24/CHECKS.md +3 -1
  71. package/rules/CD-24/README.md +6 -6
  72. package/rules/CD-25/CHECKS.md +5 -3
  73. package/rules/CD-25/README.md +5 -21
  74. package/rules/CD-26/CHECKS.md +5 -3
  75. package/rules/CD-26/README.md +6 -20
  76. package/rules/CD-27/CHECKS.md +394 -9
  77. package/rules/CD-27/README.md +6 -20
  78. package/rules/CD-27/discipline.json +130 -0
  79. package/rules/CD-28/CHECKS.md +4 -2
  80. package/rules/CD-28/README.md +6 -16
  81. package/rules/CD-29/CHECKS.md +4 -2
  82. package/rules/CD-29/README.md +6 -14
  83. package/rules/CD-3/CHECKS.md +3 -1
  84. package/rules/CD-3/README.md +6 -17
  85. package/rules/CD-30/CHECKS.md +4 -2
  86. package/rules/CD-30/README.md +6 -15
  87. package/rules/CD-31/CHECKS.md +4 -2
  88. package/rules/CD-31/README.md +6 -14
  89. package/rules/CD-32/CHECKS.md +3 -1
  90. package/rules/CD-32/README.md +2 -0
  91. package/rules/CD-33/CHECKS.md +3 -1
  92. package/rules/CD-33/README.md +2 -0
  93. package/rules/CD-34/CHECKS.md +3 -1
  94. package/rules/CD-34/README.md +2 -0
  95. package/rules/CD-39/CHECKS.md +3 -1
  96. package/rules/CD-39/README.md +2 -0
  97. package/rules/CD-4/CHECKS.md +4 -2
  98. package/rules/CD-4/README.md +6 -17
  99. package/rules/CD-40/CHECKS.md +3 -1
  100. package/rules/CD-40/README.md +6 -20
  101. package/rules/CD-41/CHECKS.md +14 -2
  102. package/rules/CD-41/README.md +6 -20
  103. package/rules/CD-41/discipline.json +14 -0
  104. package/rules/CD-42/CHECKS.md +3 -1
  105. package/rules/CD-42/README.md +6 -16
  106. package/rules/CD-43/CHECKS.md +3 -1
  107. package/rules/CD-43/README.md +6 -18
  108. package/rules/CD-44/CHECKS.md +3 -1
  109. package/rules/CD-44/README.md +6 -17
  110. package/rules/CD-45/CHECKS.md +4 -2
  111. package/rules/CD-45/README.md +6 -16
  112. package/rules/CD-46/CHECKS.md +3 -1
  113. package/rules/CD-46/README.md +2 -0
  114. package/rules/CD-47/CHECKS.md +4 -2
  115. package/rules/CD-47/README.md +4 -20
  116. package/rules/CD-5/CHECKS.md +4 -2
  117. package/rules/CD-5/README.md +6 -19
  118. package/rules/CD-6/CHECKS.md +3 -1
  119. package/rules/CD-6/README.md +6 -19
  120. package/rules/CD-7/CHECKS.md +3 -1
  121. package/rules/CD-7/README.md +6 -20
  122. package/rules/CD-7a/CHECKS.md +3 -1
  123. package/rules/CD-7a/README.md +6 -17
  124. package/rules/CD-8/CHECKS.md +3 -1
  125. package/rules/CD-8/README.md +6 -17
  126. package/rules/CD-9/CHECKS.md +4 -2
  127. package/rules/CD-9/README.md +6 -17
  128. package/rules/README.md +71 -54
  129. package/rules/SPIRIT.md +3 -3
  130. package/rules/cases.md +94 -0
  131. package/rules/numbers.md +155 -0
  132. package/rules/principles.md +89 -0
  133. package/rules/records.md +150 -0
  134. package/rules/rules.md +149 -0
  135. package/rules/sources.md +142 -0
  136. package/rules/typescript/checks.md +219 -0
  137. package/rules/typescript/recipes.md +361 -0
  138. package/rules/typescript/symptoms.json +1005 -0
  139. package/rules/typescript/symptoms.md +612 -0
  140. package/chunks/chunk-YLZ73C7O.js +0 -0
@@ -1,6 +1,8 @@
1
1
  # CD-41 checks
2
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.
3
+ Symptoms: [Long function](../typescript/symptoms.md#long-function), [Tangled function](../typescript/symptoms.md#tangled-function) and [Orchestrator that computes](../typescript/symptoms.md#orchestrator-that-computes).
4
+
5
+ Read [the verdict and the named pages it points at](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
6
 
5
7
  ## Clauses
6
8
 
@@ -19,6 +21,16 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: wha
19
21
  - A nested function is scored on its own, starting one level deeper, and its score is not added to its parent.
20
22
  - Reported at the function's name.
21
23
  - `hone-cd41/function-length`: a function body may span at most 50 lines. Blank and comment lines count; lines holding only `{` or `}` do not. Getters and setters are not checked. Reported at the function.
24
+ - A test suite's body is not checked. A suite body is a function passed as an argument to the call that runs a suite:
25
+ - `describe`, `suite`, `fdescribe`, `xdescribe`, `fsuite` or `xsuite`, alone or followed only by the modifiers `each`, `for`, `only`, `skip`, `todo`, `concurrent`, `sequential`, `shuffle`, `skipIf` and `runIf`, such as `describe.each(table)(name, fn)`, `describe.each` with a template table, `describe.only.each(table)(name, fn)` or `describe.skipIf(condition)(name, fn)`;
26
+ - Playwright's `test.describe`, alone or followed only by `only`, `skip`, `fixme`, `serial` and `parallel`, such as `test.describe.serial.only(name, fn)`.
27
+ - A suite nested in a suite is not checked either.
28
+ - Everything else is checked as any function is:
29
+ - each function inside a suite's body: each `it` and `test` callback, each hook and each helper declared there;
30
+ - a function given to `describe.each` as a table entry;
31
+ - a callback on any other member of those names, such as `test.describe.configure(fn)` or `suite.add(name, fn)` on a benchmark suite;
32
+ - mocha's `context`, and any other suite function not listed above.
33
+ - The check matches names, not bindings, so a local function of the repository's own named `describe` or `suite` is treated as a suite when called that way.
22
34
  - `orchestration-only` is a judgement clause. It cannot be selected and is enforced by review.
23
35
 
24
36
  ## Example violation
@@ -40,7 +52,7 @@ const settle = (orders: Order[]) => {
40
52
  ```ts
41
53
  const settle = (orders: Order[]) => orders.filter(isPaid).forEach(refundEligibleLines);
42
54
  ```
43
- Move each branch into a named helper so the orchestrator only composes calls.
55
+ Move any computing or branching between calls into a named doer, so the orchestrator only composes calls.
44
56
 
45
57
  ## Exceptions
46
58
  Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file holds a function whose shape is fixed by an external contract. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. Judgement clauses cannot be selected and need no exception record. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
@@ -2,28 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- An orchestrator's body composes helper calls and assembles their results — nothing else. Inline branching or computation inside an orchestrator mixes two altitudes: the coordination it owns and the logic that belongs in a named helper. Keep orchestrators pure coordination so each level reads at one altitude.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [decomposition](../../methods/lenses/decomposition.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
-
9
- ## Spirit
7
+ **Verdict.** Keeps: [Doer or orchestrator](../rules.md#doer-or-orchestrator).
10
8
 
11
- **What the friction is for.** A function that coordinates and computes at once has to be read at two levels of detail at once. The friction makes small named steps the easy shape, so each level reads as one idea.
9
+ **Read.** [Doer or orchestrator](../rules.md#doer-or-orchestrator) and [Composed orchestrator](../typescript/recipes.md#composed-orchestrator).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *Logic that never got a name.* A block of branching or computation sits inside a coordinator. Extract it into a named helper; the name says what it decides.
15
- - *One function with several jobs.* It validates, decides and performs, so it grows long and tangled. Split it by job.
16
- - *Failures checked inline.* Nesting deepens because each failure is handled in place. Return early on failure, or let helpers return results the coordinator only routes.
17
- - *Shapes that do not meet.* The coordinator reshapes data between calls because its helpers disagree. Align the helpers' inputs and outputs.
18
-
19
- **Where to go.** Coordinators read as a short list of named steps. Each helper does one thing at one level of detail.
11
+ Review lens: [decomposition](../../methods/lenses/decomposition.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).
20
12
 
21
- **Reactions to distrust.**
22
- - "It's only a little logic." A little logic in a coordinator is still a second level of detail to read. Give it a name.
23
- - "Splitting makes it harder to follow." Named steps read faster than inline logic once the names are honest.
24
- - "This branch is just plumbing." If it decides anything, it is logic. Name what it decides.
13
+ ## Spirit
25
14
 
26
- **Principles behind it.**
27
- - *Composed Method* (Kent Beck, *Smalltalk Best Practice Patterns*). A method is a sequence of calls to other methods, all at the same level of abstraction.
28
- - *One level of abstraction per function* (Robert C. Martin, *Clean Code*). Mixing coordination with detail forces the reader to switch levels mid-function.
29
- - *Functions should do one thing* (Robert C. Martin, *Clean Code*). A coordinator's one thing is coordinating; computing is a second thing.
15
+ Start from the symptom a finding names: [Long function](../typescript/symptoms.md#long-function), [Tangled function](../typescript/symptoms.md#tangled-function) and [Orchestrator that computes](../typescript/symptoms.md#orchestrator-that-computes). Each symptom names the cases it may indicate and the rules they point at. The why is on [One place decides](../principles.md#one-place-decides).
@@ -96,6 +96,14 @@
96
96
  "expectedLines": [
97
97
  1
98
98
  ]
99
+ },
100
+ {
101
+ "name": "an it callback inside a describe",
102
+ "fileName": "src/steps.test.ts",
103
+ "source": "describe(\"steps\", () => {\n it(\"runs\", () => {\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n });\n});\n",
104
+ "expectedLines": [
105
+ 2
106
+ ]
99
107
  }
100
108
  ],
101
109
  "allow": [
@@ -110,6 +118,12 @@
110
118
  "fileName": "src/steps.ts",
111
119
  "source": "export function steps(): void {\n step0();\n step1();\n step2();\n step3();\n step4();\n step5();\n step6();\n step7();\n step8();\n step9();\n step10();\n step11();\n step12();\n step13();\n step14();\n step15();\n step16();\n step17();\n step18();\n step19();\n step20();\n step21();\n step22();\n step23();\n step24();\n step25();\n step26();\n step27();\n step28();\n step29();\n step30();\n step31();\n step32();\n step33();\n step34();\n step35();\n step36();\n step37();\n step38();\n step39();\n step40();\n step41();\n step42();\n step43();\n if (ready0) {\n run();\n }\n if (ready1) {\n run();\n }\n if (ready2) {\n run();\n }\n}\n",
112
120
  "expectedLines": []
121
+ },
122
+ {
123
+ "name": "a describe callback is not a function to shorten",
124
+ "fileName": "src/steps.test.ts",
125
+ "source": "describe(\"steps\", () => {\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n step();\n});\n",
126
+ "expectedLines": []
113
127
  }
114
128
  ]
115
129
  }
@@ -1,6 +1,8 @@
1
1
  # CD-42 checks
2
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.
3
+ Symptom: [Work inside a condition](../typescript/symptoms.md#work-inside-a-condition).
4
+
5
+ Read [the verdict and the named pages it points at](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
6
 
5
7
  ## Clauses
6
8
 
@@ -2,24 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- Unhappy paths are handled first as guard clauses that return early; the happy path is the final, un-nested return at the bottom. There is no `else` after an early return. Guarding first keeps the main path flat and readable, instead of burying it inside nested conditionals.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [decomposition](../../methods/lenses/decomposition.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
-
9
- ## Spirit
7
+ **Verdict.** Keeps: [Guard first](../rules.md#guard-first).
10
8
 
11
- **What the friction is for.** Nested conditions bury the main path. The friction makes "handle the failures first, then do the work" the easy shape, so the main path reads flat at the bottom.
9
+ **Read.** [Guard first](../rules.md#guard-first) and [Guard clauses](../typescript/recipes.md#guard-clauses).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *Failures handled after success.* The happy path sits inside an if and the failure in the else. Invert it: return early on failure.
15
- - *Several checks nested inside each other.* Each guard adds a level. Make each a separate early return.
16
- - *A function with two jobs.* Both branches do real work. Split it into two functions.
17
-
18
- **Where to go.** Guards at the top, each returning early. The final return is the happy path, with no else.
11
+ Review lens: [decomposition](../../methods/lenses/decomposition.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).
19
12
 
20
- **Reactions to distrust.**
21
- - "Single exit is cleaner." It forces nesting and a variable to carry the answer. Early returns keep each case in one place.
22
- - "The else makes it explicit." After a return, the else adds only indentation.
13
+ ## Spirit
23
14
 
24
- **Principles behind it.**
25
- - *Replace Nested Conditional with Guard Clauses* (Martin Fowler, *Refactoring*). Unusual cases leave early; the normal case reads straight down.
15
+ Start from the symptom a finding names: [Work inside a condition](../typescript/symptoms.md#work-inside-a-condition). Each symptom names the cases it may indicate and the rules they point at. The why is on [One place decides](../principles.md#one-place-decides).
@@ -1,6 +1,8 @@
1
1
  # CD-43 checks
2
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.
3
+ Symptom: [Boolean in a signature](../typescript/symptoms.md#boolean-in-a-signature).
4
+
5
+ Read [the verdict and the named pages it points at](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
6
 
5
7
  ## Clauses
6
8
 
@@ -2,26 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- A boolean parameter, field, or return is an evaluative predicate the reader must decode at every call site — `true` for what? Prefer a string-literal or discriminated union that states the meaning in the value itself. Booleans that name a state or mode hide that meaning behind a bare truth value.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
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
-
9
- ## Spirit
7
+ **Verdict.** Keeps: [Kinds are named](../rules.md#kinds-are-named).
10
8
 
11
- **What the friction is for.** A bare true or false says nothing about what it means. The friction makes naming the state the easy path, so a call site reads as what it does.
9
+ **Read.** [Kinds are named](../rules.md#kinds-are-named) and [Tagged union and exhaustive switch](../typescript/recipes.md#tagged-union-and-exhaustive-switch).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *A mode passed as a flag.* A parameter switches the function between behaviours. Split the function, or name the modes as a union.
15
- - *A state that will grow.* Today it is on or off; tomorrow there is a third case and a second flag. Name the states now.
16
- - *Two flags that cannot both be true.* Pairs of booleans allow combinations that make no sense. One union rules them out.
17
- - *An outcome as a boolean.* A result says success or not, and the reason is lost. Return a tagged outcome.
18
-
19
- **Where to go.** States and modes are named values. A reader learns the meaning from the value itself.
11
+ 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).
20
12
 
21
- **Reactions to distrust.**
22
- - "It's obviously a yes or no." Then name what yes means. If that is easy, the union is easy.
23
- - "The library returns a boolean." Read it at the boundary and turn it into your own named state there.
13
+ ## Spirit
24
14
 
25
- **Principles behind it.**
26
- - *Make illegal states unrepresentable* (Yaron Minsky). A union of named states rules out the combinations flags allow.
27
- - *Flag arguments* (Robert C. Martin, *Clean Code*). A boolean argument announces that the function does more than one thing.
15
+ Start from the symptom a finding names: [Boolean in a signature](../typescript/symptoms.md#boolean-in-a-signature). Each symptom names the cases it may indicate and the rules they point at. The why is on [The type checker proves it](../principles.md#the-type-checker-proves-it).
@@ -1,6 +1,8 @@
1
1
  # CD-44 checks
2
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.
3
+ Symptoms: [Write into a parameter](../typescript/symptoms.md#write-into-a-parameter) and [Rebinding](../typescript/symptoms.md#rebinding).
4
+
5
+ Read [the verdict and the named pages it points at](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
6
 
5
7
  ## Clauses
6
8
 
@@ -2,25 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- A function never mutates the fields of the parameters it receives — no assigning to a parameter's property, no pushing into a parameter's array, no sorting it in place. It returns new data instead. Mutating an input makes the function's effect invisible at the call site and couples the caller to an order of operations it cannot see.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [decomposition](../../methods/lenses/decomposition.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
-
9
- ## Spirit
7
+ **Verdict.** Cases of [No hidden effects](../principles.md#no-hidden-effects).
10
8
 
11
- **What the friction is for.** A function that changes its inputs has an effect the call site cannot see. The friction makes returning new data the easy path, so every change is visible where it is used.
9
+ **Read.** [No hidden effects](../principles.md#no-hidden-effects) and [Copy, never write in](../typescript/recipes.md#copy-never-write-in).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *A function that both answers and changes.* It returns something and also edits what it was given. Return the new value; leave the input alone.
15
- - *Ownership nobody decided.* Several functions edit one shared object in turn. Decide who builds the value, and pass results forward instead.
16
- - *In-place sorting or pushing for convenience.* A library call mutates by default. Use the copying form, or copy first.
17
- - *Accumulators passed in.* A collection is handed in to be filled. Return the items and let the caller combine them.
18
-
19
- **Where to go.** Inputs are read-only. Functions return new values, and the caller decides what to keep.
11
+ Review lens: [decomposition](../../methods/lenses/decomposition.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).
20
12
 
21
- **Reactions to distrust.**
22
- - "Copying is slow." Usually unmeasured, and the rule makes no performance carve-out.
23
- - "The caller wants the change." Then return it, and the caller can see it.
13
+ ## Spirit
24
14
 
25
- **Principles behind it.**
26
- - *Functional core, imperative shell* (Gary Bernhardt). The core takes values and returns values; changes happen at the edge.
15
+ Start from the symptom a finding names: [Write into a parameter](../typescript/symptoms.md#write-into-a-parameter) and [Rebinding](../typescript/symptoms.md#rebinding). Each symptom names the cases it may indicate and the rules they point at. The why is on [No hidden effects](../principles.md#no-hidden-effects).
@@ -1,6 +1,8 @@
1
1
  # CD-45 checks
2
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.
3
+ Symptom: [Schema past its adapter](../typescript/symptoms.md#schema-past-its-adapter).
4
+
5
+ Read [the verdict and the named pages it points at](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
6
 
5
7
  ## Clauses
6
8
 
@@ -10,4 +12,4 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: how
10
12
 
11
13
  ## How it is checked
12
14
 
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.
15
+ 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 named rules](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,24 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- Validation runs exactly once, at the boundary crossing, and yields a plain internal shape the rest of the code trusts by construction — it is never re-run deeper in, and the validation library's types never leak inward. Parse once at the seam, map to a domain shape, and let the inner layers depend on that shape, not on the validator.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [zod-boundary](../../methods/lenses/zod-boundary.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
-
9
- ## Spirit
7
+ **Verdict.** Cases of [No leak across a boundary](../principles.md#no-leak-across-a-boundary).
10
8
 
11
- **What the friction is for.** Checking the same data twice means nobody trusts the first check, and the validator's types spread inward. The friction makes parsing once and handing on a plain shape the easy path.
9
+ **Read.** [No leak across a boundary](../principles.md#no-leak-across-a-boundary), Reads data from outside ([cases](../cases.md#no-leak-across-a-boundary)) and [Zod at the producer's adapter](../typescript/recipes.md#zod-at-the-producers-adapter).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *A boundary that does not finish its job.* The seam parses but passes the raw or validator-typed value on. Map it to a plain domain shape there.
15
- - *Inner code that does not trust its inputs.* Inner functions parse again. Give them the parsed type so the check is unnecessary.
16
- - *Validator types used as domain types.* The validation library's types appear in inner signatures. Declare your own types; the boundary maps to them.
17
-
18
- **Where to go.** One parse per crossing, at the seam. Inner layers depend on your own types, never on the validator.
11
+ Review lens: [zod-boundary](../../methods/lenses/zod-boundary.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).
19
12
 
20
- **Reactions to distrust.**
21
- - "Parsing again is safer." It is a sign the types inside cannot be trusted. Fix that instead.
13
+ ## Spirit
22
14
 
23
- **Principles behind it.**
24
- - *Parse, don't validate* (Alexis King). After one parse the type carries the proof; checking again adds nothing.
25
- - *Dependency Inversion Principle* (Robert C. Martin, SOLID). Inner layers depend on their own types, not on a library's.
15
+ Start from the symptom a finding names: [Schema past its adapter](../typescript/symptoms.md#schema-past-its-adapter). Each symptom names the cases it may indicate and the rules they point at. The why is on [No leak across a boundary](../principles.md#no-leak-across-a-boundary).
@@ -1,6 +1,8 @@
1
1
  # CD-46 checks
2
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.
3
+ Record kind: [Debt](../records.md#debt).
4
+
5
+ Read [the rule and its spirit](README.md) first; the [named pages](../README.md) govern where they differ. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
4
6
 
5
7
  ## How it is checked
6
8
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  ## Rule
4
4
 
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ: only [debt](../records.md#debt) is forfeited on touch.
6
+
5
7
  A suppression or exemption is inherited debt held at rest, not a standing licence: it buys "leave this file alone", nothing more. The moment a change edits an exempt file, that file forfeits its exemption — the change must bring the whole file into compliance for the exempted rule (the new lines and the pre-existing ones the exemption was masking) and remove the exemption entry, in the same change. There is no partial credit and no extracting the touched code into a clean helper while the exempt file stays dirty. If full compliance is out of scope, the move is to not touch the file. This rule governs how every other exemption decays and can never itself be exempted.
6
8
 
7
9
  Review lens: none. A reviewer applies the rule text directly. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
@@ -1,6 +1,8 @@
1
1
  # CD-47 checks
2
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.
3
+ Symptom: [Inherited environment in a subprocess](../typescript/symptoms.md#inherited-environment-in-a-subprocess).
4
+
5
+ Read [the verdict and the named pages it points at](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
6
 
5
7
  ## Clauses
6
8
 
@@ -11,7 +13,7 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: how
11
13
  ## What the check flags
12
14
  - Test files: `*.test.ts`, `*.test.tsx`, `*.test.mjs`, `*.test.js`, `*.spec.ts`, `*.spec.mjs`. Generated folders (`node_modules`, `dist`, `build`, `coverage`, `.git`, root `vendor`) are skipped; any other folder can be left out with `exclude` in disciplines.json.
13
15
  - A line calling `spawnSync`, `spawn`, `execFileSync`, `execFile`, `execSync`, `exec`, `execa` or `execaSync` with `"git"` (or `'git'`, or a template literal) as the first argument.
14
- - Allowed when, within that line and the next seven, an `env:` names `hermeticGitEnvironment`, `withoutInheritedGitBindings` or `environment`, and no nearby `env:` uses `process.env`. The helper is yours to provide.
16
+ - Allowed when, within that line and the next seven, an `env:` names `hermeticGitEnvironment`, `withoutInheritedGitBindings` or `environment`, and no nearby `env:` uses `process.env`. The environment comes from a unit of ours with its own test, not a test helper.
15
17
  - Not detected: a command string such as `execSync("git status")`, a split call, or a non-literal command. Whether the spawn is warranted at all is left to review.
16
18
 
17
19
  ## Example violation
@@ -2,30 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- A test may not touch its environment or cause any real side effect on anything real. "Anything real" is everything the test did not itself create and does not itself dispose: the developer's repository, their user configuration and home directory, any network or live service, shared filesystem paths, the system clock, and the ambient process environment.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- A test replaces the real subsystem with a test double. Spawning it is permitted in exactly one closed case: the subsystem's own observable behaviour is the assertion's subject and no test double can stand in for it. Setup, realism and convenience never qualify; state which assertion cannot be written against a test double, and if that sentence cannot be written, the test does not qualify. A qualifying test brings its own instance in a location it created and removes it afterwards; it never borrows the machine's.
7
+ **Verdict.** Cases under [Tested where it's owned](../rules.md#tested-where-its-owned).
8
8
 
9
- Real git is the mechanically checked class: a test that spawns a real `git` subprocess passes an explicit hermetic environment at that call site, and never inherits the ambient one.
9
+ **Read.** [Tested where it's owned](../rules.md#tested-where-its-owned) and [Integration test owns its scratch](../typescript/recipes.md#integration-test-owns-its-scratch).
10
10
 
11
11
  Review lens: [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).
12
12
 
13
13
  ## Spirit
14
14
 
15
- **What the friction is for.** A test that touches real things can damage them, and can pass or fail depending on the machine. The friction makes replacing the subsystem with a test double the easy path, so tests are safe to run anywhere and give the same answer every time.
16
-
17
- **What a finding points at.** Match the sites against these causes.
18
- - *A subsystem reached directly.* The code under test calls the real process, network, or filesystem. Inject a port and pass a test double.
19
- - *Environment inherited by accident.* A spawned process picks up the developer's settings. Pass an explicit, created environment, or replace the process with a test double.
20
- - *Setup that borrows the machine.* The test uses shared paths, home configuration, or the system clock. Create what it needs and remove it afterwards, or use a test double.
21
- - *A real call used for convenience.* Realism or setup speed is the reason. Those never qualify; use a test double.
22
-
23
- **Where to go.** Tests replace every real subsystem with a test double. The rare test whose subject is a subsystem's own behaviour brings its own instance and removes it.
24
-
25
- **Reactions to distrust.**
26
- - "It works on my machine." That is the problem: it depends on your machine.
27
- - "A test double is more work." Once per subsystem, against every developer's environment being at risk.
28
-
29
- **Principles behind it.**
30
- - *Hermetic tests.* A test depends only on what it creates, so its result is the same on every machine.
31
- - *Erratic Test* (a test smell in Gerard Meszaros, *xUnit Test Patterns*). Tests that share or leak real resources pass or fail by circumstance.
15
+ Start from the symptom a finding names: [Inherited environment in a subprocess](../typescript/symptoms.md#inherited-environment-in-a-subprocess) and [Machine touched in a unit test](../typescript/symptoms.md#machine-touched-in-a-unit-test). Each symptom names the cases it may indicate and the rules they point at. The why is on [Tests are ours](../principles.md#tests-are-ours).
@@ -1,6 +1,8 @@
1
1
  # CD-5 checks
2
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.
3
+ Symptom: [Untracked escape](../typescript/symptoms.md#untracked-escape).
4
+
5
+ Read [the verdict and the named pages it points at](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
6
 
5
7
  ## Clauses
6
8
 
@@ -38,7 +40,7 @@ const first = items[0]!;
38
40
  ```ts
39
41
  const first = items[0];
40
42
  ```
41
- Remove the need for the directive. If it must stay, add a tracked reference to the work that removes it: `// biome-ignore lint/style/noNonNullAssertion: until items is typed as a non-empty tuple (#42)`. The reference satisfies this clause only. A directive that escapes a selected clause, such as an `eslint-disable` naming a selected rule or a `@ts-expect-error` under `CD-2#cast-expressions`, still needs a file record on that clause, and that record does not satisfy this clause.
43
+ Remove the need for the directive. If it must stay, add a tracked reference to the work that removes it: `// biome-ignore lint/style/noNonNullAssertion: until items is typed as non-empty (#42)`. The reference satisfies this clause only. A directive that escapes a selected clause, such as an `eslint-disable` naming a selected rule or a `@ts-expect-error` under `CD-2#cast-expressions`, still needs a file record on that clause, and that record does not satisfy this clause.
42
44
 
43
45
  ## Exceptions
44
46
  Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a file legitimately carries untracked directives, such as generated code. 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).
@@ -2,27 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- Code is self-documenting: the names, types, and schemas carry the meaning. A prose comment is almost always there to excuse an unclear name or a convoluted expression — so the fix is to clarify the code, not annotate it. The only permitted annotations are machine-meaningful directives that carry a tracked reference; explanatory comments and doc-comments are not.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [naming](../../methods/lenses/naming.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
-
9
- ## Spirit
7
+ **Verdict.** Splits: One word everywhere; Declared, not asserted; records.
10
8
 
11
- **What the friction is for.** Prose beside code drifts from the code, and nothing checks it. The friction makes a clear name the cheap fix, and makes every "the checker is wrong here" marker point at the work that removes it.
9
+ **Read.** [One word everywhere](../rules.md#one-word-everywhere), [Declared, not asserted](../rules.md#declared-not-asserted), [Meaning in names, not comments](../typescript/recipes.md#meaning-in-names-not-comments) and [records](../records.md).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *A name that says too little.* The comment explains what the name should. Rename, or extract a named function.
15
- - *A rule the types do not hold.* The comment states an invariant. Move it into a type, a union or a schema, where it is checked.
16
- - *A suppression standing in for a fix.* The directive silences another rule. That rule's finding is the real one; read its Spirit section.
17
- - *A promise nobody holds.* An untracked TODO. Track it or do it.
18
-
19
- **Where to go.** Names, types and schemas carry the meaning, with no prose beside them. Each directive that remains carries a tracked reference to the work that retires it, so the count of directives falls over time rather than settling.
11
+ Review lens: [naming](../../methods/lenses/naming.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).
20
12
 
21
- **Reactions to distrust.**
22
- - "This needs explaining." Then the code is not yet clear. The explanation is the brief for a better name.
23
- - "Add a tracked reference and move on." A reference that excuses the escape instead of retiring it is the same hole with a label.
24
- - "It's generated." Then that file is a boundary. Authorise it, and keep hand-written code clean.
13
+ ## Spirit
25
14
 
26
- **Principles behind it.**
27
- - *Intention-revealing names* (Robert C. Martin, *Clean Code*). Clean Code treats a comment as compensating for code that failed to express its intent; the fix is in the code.
28
- - *Make illegal states unrepresentable* (Yaron Minsky). An invariant stated in a type is checked on every change; the same invariant in a comment is checked by nobody.
15
+ Start from the symptom a finding names: [Untracked escape](../typescript/symptoms.md#untracked-escape) and [Prose in code](../typescript/symptoms.md#prose-in-code). Each symptom names the cases it may indicate and the rules they point at. The why is on [Our code reads in the common language](../principles.md#our-code-reads-in-the-common-language).
@@ -1,6 +1,8 @@
1
1
  # CD-6 checks
2
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.
3
+ Symptoms: [Shorthand name](../typescript/symptoms.md#shorthand-name) and [Name off its casing](../typescript/symptoms.md#name-off-its-casing).
4
+
5
+ Read [the verdict and the named pages it points at](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
6
 
5
7
  ## Clauses
6
8
 
@@ -2,27 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- A name states the concept the value represents, not its shape or its category. Shorthand (single letters, truncations) and filler words (data, info, value, result, manager, handler) force the reader to reconstruct meaning the name should have carried — at every scope, including callback parameters and destructures. The name is the documentation.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [naming](../../methods/lenses/naming.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
-
9
- ## Spirit
7
+ **Verdict.** Keeps: [One word everywhere](../rules.md#one-word-everywhere); casing a check.
10
8
 
11
- **What the friction is for.** A reader meets a name far more often than its definition. The friction makes stating the concept the easy path, so meaning lives where it is read.
9
+ **Read.** [One word everywhere](../rules.md#one-word-everywhere) and [Whole words](../typescript/recipes.md#whole-words).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *A concept not yet understood.* `data` or `result` because the writer did not know what the value was. Find out, then name it.
15
- - *A function returning a mix.* `result` is the only honest name because the function returns several things. Split it.
16
- - *No shared vocabulary.* The team has no agreed words for the domain, so names fall back to shapes. Agree the terms and use them in code.
17
- - *A framework's habit copied inward.* `req`, `res`, `e` from library examples. Name it for what it is in your code.
18
-
19
- **Where to go.** Every name states the concept, in the domain's words, at every scope.
11
+ Review lens: [naming](../../methods/lenses/naming.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).
20
12
 
21
- **Reactions to distrust.**
22
- - "Everyone knows what `i` means." They know it is an index, not an index of what.
23
- - "Short scopes don't need long names." The rule covers every scope. The reader of a short scope still has to reconstruct the meaning.
24
- - "It's the library's convention." Conventions belong at the boundary. Inside, use your words.
13
+ ## Spirit
25
14
 
26
- **Principles behind it.**
27
- - *Intention-revealing names* (Robert C. Martin, *Clean Code*). A name should say why the thing exists and what it does, so no comment is needed.
28
- - *Ubiquitous language* (Eric Evans, *Domain-Driven Design*). The code uses the same words as the people who know the domain.
15
+ Start from the symptom a finding names: [Shorthand name](../typescript/symptoms.md#shorthand-name) and [Name off its casing](../typescript/symptoms.md#name-off-its-casing). Each symptom names the cases it may indicate and the rules they point at. The why is on [Our code reads in the common language](../principles.md#our-code-reads-in-the-common-language).
@@ -1,6 +1,8 @@
1
1
  # CD-7 checks
2
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.
3
+ Symptoms: [Drawer path](../typescript/symptoms.md#drawer-path) and [Name off its casing](../typescript/symptoms.md#name-off-its-casing).
4
+
5
+ Read [the verdict and the named pages it points at](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
6
 
5
7
  ## Clauses
6
8
 
@@ -2,28 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- A file or folder is named for the abstraction it holds, not for a category of things. A junk-drawer name (utils, helpers, common, shared, types, misc) signals a missing primitive: the code inside wants a real home named for what it does. Category names accrete unrelated code because anything can be justified into them.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [naming](../../methods/lenses/naming.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
-
9
- ## Spirit
7
+ **Verdict.** Splits: One reason per module; One word everywhere; filename case a check.
10
8
 
11
- **What the friction is for.** A name is the first design decision a reader meets. A category name accepts anything, so code drifts into it without anyone deciding where it belongs. The friction forces the question "what is this?" at the moment it is cheapest to answer.
9
+ **Read.** [One reason per module](../rules.md#one-reason-per-module), [One word everywhere](../rules.md#one-word-everywhere) and [Screaming folders](../typescript/recipes.md#screaming-folders).
12
10
 
13
- **What a finding points at.** Match the paths against these causes.
14
- - *A concept nobody named.* The drawer holds functions that all serve one idea the codebase never named, such as money, dates or identifiers. Name the idea and give it a module.
15
- - *Shared by accident.* Code moved to a common place because two callers needed it. Decide whether it belongs to one of them or is a concept of its own.
16
- - *Shapes separated from their owners.* A types file holds shapes far from the code that uses them. Put each shape beside the code it describes.
17
- - *Folders sorted by kind.* The tree groups things by what they are, not by what they do. Group by capability.
18
-
19
- **Where to go.** Every file and folder name says what it holds, so a reader finds code by asking what it does. The rename is the small part; finding the concept behind it is the work.
11
+ Review lens: [naming](../../methods/lenses/naming.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).
20
12
 
21
- **Reactions to distrust.**
22
- - "It's just a name." The name is where the missing concept shows. A synonym such as "core" or "base" keeps the drawer.
23
- - "The framework requires that path." Then authorise that path. What you add under it still needs a real home.
24
- - "We'll sort it later." Category folders only grow.
13
+ ## Spirit
25
14
 
26
- **Principles behind it.**
27
- - *Screaming architecture* (Robert C. Martin). The folder structure should tell a reader what the system does, not which kinds of file it contains.
28
- - *Single Responsibility Principle* (Robert C. Martin, SOLID). A module has one reason to change. A drawer of unrelated helpers has as many reasons as it has helpers.
29
- - *Primitive Obsession* (a code smell in Fowler's *Refactoring*). Helpers that all handle one raw value, such as an amount or a date string, usually mark a domain type nobody created.
15
+ Start from the symptom a finding names: [Drawer path](../typescript/symptoms.md#drawer-path) and [Name off its casing](../typescript/symptoms.md#name-off-its-casing). Each symptom names the cases it may indicate and the rules they point at. The why is on [One place decides](../principles.md#one-place-decides) and [Our code reads in the common language](../principles.md#our-code-reads-in-the-common-language).
@@ -1,6 +1,8 @@
1
1
  # CD-7a checks
2
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.
3
+ Symptom: [Type derived from code](../typescript/symptoms.md#type-derived-from-code).
4
+
5
+ Read [the verdict and the named pages it points at](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
6
 
5
7
  ## Clauses
6
8
 
@@ -2,25 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- Every type the code produces is named and exported, and callers use that named type. Deriving a type from a factory's inferred return couples the type to the implementation, hides it from find-usages, and breaks the moment the factory's internals shift. The single carve-out is an external library symbol whose package exports no named return type.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
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
-
9
- ## Spirit
7
+ **Verdict.** Symptom of [Outside dependencies stay at boundaries](../rules.md#outside-dependencies-stay-at-boundaries).
10
8
 
11
- **What the friction is for.** A type derived from what a function happens to return changes whenever the implementation does. The friction makes naming the type the easy path, so the contract is declared, findable, and stable.
9
+ **Read.** [Outside dependencies stay at boundaries](../rules.md#outside-dependencies-stay-at-boundaries) and [Named, exported type](../typescript/recipes.md#named-exported-type).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *A contract nobody wrote down.* The factory's output was never named, so callers derive it. Name and export the type, and let the factory declare it returns that.
15
- - *Implementation details leaking out.* The derived type exposes everything the factory builds. Declare only what callers should rely on.
16
- - *A library with a named type you missed.* The package exports the type already. Use it.
17
-
18
- **Where to go.** Every type the code produces has a name, and callers use the name.
11
+ 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).
19
12
 
20
- **Reactions to distrust.**
21
- - "Deriving keeps it in sync." It keeps it in sync with whatever the implementation does, including mistakes.
22
- - "Naming it is duplication." The name is the contract; the implementation is one way to meet it.
13
+ ## Spirit
23
14
 
24
- **Principles behind it.**
25
- - *Program to an interface, not an implementation* (Gamma, Helm, Johnson and Vlissides, *Design Patterns*). Callers depend on a declared contract, not on the shape the implementation produces.
26
- - *Intention-revealing names* (Robert C. Martin, *Clean Code*). A named type says what the value is for.
15
+ Start from the symptom a finding names: [Type derived from code](../typescript/symptoms.md#type-derived-from-code). Each symptom names the cases it may indicate and the rules they point at. The why is on [External behaviour sits at a boundary](../principles.md#external-behaviour-sits-at-a-boundary) and [The type checker proves it](../principles.md#the-type-checker-proves-it).