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

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 (130) hide show
  1. package/ADOPTING.md +151 -42
  2. package/MIGRATING.md +55 -4
  3. package/README.md +98 -35
  4. package/THIRD-PARTY-NOTICES.md +1 -1
  5. package/chunks/chunk-5LCLBXP7.js +76 -0
  6. package/chunks/{chunk-IIMK5BCL.js → chunk-ET5EBSJX.js} +15 -13
  7. package/chunks/{chunk-7PVPPH4C.js → chunk-LDQUT742.js} +3 -1
  8. package/chunks/{chunk-VUG3DJHN.js → chunk-LOYT2AGY.js} +8 -9
  9. package/chunks/{chunk-HVABJ7T4.js → chunk-MVK5KFJI.js} +72 -12
  10. package/chunks/{chunk-SWPCKTJV.js → chunk-NCDYOPHG.js} +7340 -2124
  11. package/chunks/{chunk-7OVV6NEU.js → chunk-WPRR2MPJ.js} +1 -1
  12. package/chunks/{chunk-YBWVUDIG.js → chunk-XB4PCY3Q.js} +1 -1
  13. package/core/check/tool-command.js +938 -313
  14. package/docs/adding-a-discipline-or-mechanism.md +27 -14
  15. package/docs/extending.md +4 -3
  16. package/docs/output-contract.md +326 -0
  17. package/mechanisms/audit/CD-19/import-boundaries.js +3 -3
  18. package/mechanisms/audit/CD-2/piece.json +6 -1
  19. package/mechanisms/audit/CD-5/comments-directives.js +10 -26
  20. package/mechanisms/audit/runner/README.md +3 -2
  21. package/mechanisms/audit/runner/runner.js +97 -35
  22. package/mechanisms/eslint/CD-2/README.md +12 -0
  23. package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +16 -0
  24. package/mechanisms/eslint/CD-2/piece.json +25 -0
  25. package/mechanisms/eslint/runner/README.md +12 -5
  26. package/mechanisms/eslint/runner/runner.js +900 -242
  27. package/methods/README.md +2 -0
  28. package/methods/assessment-template.md +35 -0
  29. package/methods/lenses/clean-architecture.md +2 -2
  30. package/methods/lenses/decomposition.md +2 -2
  31. package/methods/lenses/defended-on-intent.md +7 -7
  32. package/methods/lenses/di-discipline.md +38 -26
  33. package/methods/lenses/errors-as-data.md +2 -2
  34. package/methods/lenses/function-first.md +2 -2
  35. package/methods/lenses/naming.md +2 -2
  36. package/methods/lenses/test-discipline.md +15 -13
  37. package/methods/lenses/type-soundness.md +2 -2
  38. package/methods/lenses/zod-boundary.md +2 -2
  39. package/package.json +2 -1
  40. package/rules/CD-1/CHECKS.md +37 -0
  41. package/rules/CD-1/README.md +17 -32
  42. package/rules/CD-10/CHECKS.md +49 -0
  43. package/rules/CD-10/README.md +21 -49
  44. package/rules/CD-11/CHECKS.md +13 -0
  45. package/rules/CD-11/README.md +14 -8
  46. package/rules/CD-12/CHECKS.md +13 -0
  47. package/rules/CD-12/README.md +14 -8
  48. package/rules/CD-13/CHECKS.md +13 -0
  49. package/rules/CD-13/README.md +14 -8
  50. package/rules/CD-14/CHECKS.md +49 -0
  51. package/rules/CD-14/README.md +22 -48
  52. package/rules/CD-15/CHECKS.md +40 -0
  53. package/rules/CD-15/README.md +22 -40
  54. package/rules/CD-16/CHECKS.md +7 -0
  55. package/rules/CD-16/README.md +3 -5
  56. package/rules/CD-17/CHECKS.md +37 -0
  57. package/rules/CD-17/README.md +17 -31
  58. package/rules/CD-18/CHECKS.md +13 -0
  59. package/rules/CD-18/README.md +15 -9
  60. package/rules/CD-19/CHECKS.md +49 -0
  61. package/rules/CD-19/README.md +18 -44
  62. package/rules/CD-2/CHECKS.md +56 -0
  63. package/rules/CD-2/README.md +18 -35
  64. package/rules/CD-2/discipline.json +68 -0
  65. package/rules/CD-20/CHECKS.md +7 -0
  66. package/rules/CD-20/README.md +3 -5
  67. package/rules/CD-21/CHECKS.md +13 -0
  68. package/rules/CD-21/README.md +14 -9
  69. package/rules/CD-22/CHECKS.md +13 -0
  70. package/rules/CD-22/README.md +13 -8
  71. package/rules/CD-23/CHECKS.md +35 -0
  72. package/rules/CD-23/README.md +14 -29
  73. package/rules/CD-24/CHECKS.md +7 -0
  74. package/rules/CD-24/README.md +3 -5
  75. package/rules/CD-25/CHECKS.md +38 -0
  76. package/rules/CD-25/README.md +20 -32
  77. package/rules/CD-26/CHECKS.md +36 -0
  78. package/rules/CD-26/README.md +18 -31
  79. package/rules/CD-27/CHECKS.md +45 -0
  80. package/rules/CD-27/README.md +18 -40
  81. package/rules/CD-28/CHECKS.md +13 -0
  82. package/rules/CD-28/README.md +14 -8
  83. package/rules/CD-29/CHECKS.md +13 -0
  84. package/rules/CD-29/README.md +12 -8
  85. package/rules/CD-3/CHECKS.md +42 -0
  86. package/rules/CD-3/README.md +20 -42
  87. package/rules/CD-30/CHECKS.md +13 -0
  88. package/rules/CD-30/README.md +13 -8
  89. package/rules/CD-31/CHECKS.md +13 -0
  90. package/rules/CD-31/README.md +12 -8
  91. package/rules/CD-32/CHECKS.md +13 -0
  92. package/rules/CD-32/README.md +13 -8
  93. package/rules/CD-33/CHECKS.md +13 -0
  94. package/rules/CD-33/README.md +13 -8
  95. package/rules/CD-34/CHECKS.md +13 -0
  96. package/rules/CD-34/README.md +12 -8
  97. package/rules/CD-39/CHECKS.md +13 -0
  98. package/rules/CD-39/README.md +13 -8
  99. package/rules/CD-4/CHECKS.md +13 -0
  100. package/rules/CD-4/README.md +15 -8
  101. package/rules/CD-40/CHECKS.md +39 -0
  102. package/rules/CD-40/README.md +17 -33
  103. package/rules/CD-41/CHECKS.md +54 -0
  104. package/rules/CD-41/README.md +23 -54
  105. package/rules/CD-42/CHECKS.md +47 -0
  106. package/rules/CD-42/README.md +19 -47
  107. package/rules/CD-43/CHECKS.md +37 -0
  108. package/rules/CD-43/README.md +15 -31
  109. package/rules/CD-44/CHECKS.md +48 -0
  110. package/rules/CD-44/README.md +20 -48
  111. package/rules/CD-45/CHECKS.md +13 -0
  112. package/rules/CD-45/README.md +14 -8
  113. package/rules/CD-46/CHECKS.md +7 -0
  114. package/rules/CD-46/README.md +16 -4
  115. package/rules/CD-47/CHECKS.md +37 -0
  116. package/rules/CD-47/README.md +16 -32
  117. package/rules/CD-5/CHECKS.md +52 -0
  118. package/rules/CD-5/README.md +22 -52
  119. package/rules/CD-6/CHECKS.md +51 -0
  120. package/rules/CD-6/README.md +22 -51
  121. package/rules/CD-7/CHECKS.md +46 -0
  122. package/rules/CD-7/README.md +23 -46
  123. package/rules/CD-7a/CHECKS.md +38 -0
  124. package/rules/CD-7a/README.md +14 -32
  125. package/rules/CD-8/CHECKS.md +42 -0
  126. package/rules/CD-8/README.md +20 -42
  127. package/rules/CD-9/CHECKS.md +13 -0
  128. package/rules/CD-9/README.md +15 -8
  129. package/rules/README.md +5 -3
  130. package/rules/SPIRIT.md +50 -0
package/methods/README.md CHANGED
@@ -16,3 +16,5 @@ These are review methods for applying the rule pages' judgement clauses, and for
16
16
  | [defended-on-intent](lenses/defended-on-intent.md) | This lens defends **intent over letter**: a PASS is only a PASS when the artefact satisfies both the literal text of the cited rule *and* the principle that rule exists to encode. |
17
17
 
18
18
  The defended-on-intent lens runs last, over the other lenses' findings.
19
+
20
+ [assessment-template.md](assessment-template.md) is the template for a repository's `disciplines.assessment.md`: what each high-count clause's findings mean in that codebase and where the code is going. [ADOPTING step 5a](../ADOPTING.md#5a-write-the-assessment) says how to write it.
@@ -0,0 +1,35 @@
1
+ # Disciplines assessment
2
+
3
+ What this repository's checks are telling us, and where the code is going. Each clause section sharpens that rule's Spirit section for this codebase; it does not repeat the rule. Read a clause's section before changing code to make its check pass.
4
+
5
+ ## Rules adopted
6
+
7
+ - `<discipline ID>`: <why it matters in this codebase, in one line>
8
+
9
+ ## Clauses not adopted
10
+
11
+ The rule does not apply to this codebase.
12
+
13
+ - `<clause address>`: <why it does not apply>
14
+
15
+ ## Clauses adopted, mechanism not run
16
+
17
+ The rule binds, but its check is not a true measure of the intent here, or cannot work here. Review carries the intent.
18
+
19
+ - `<clause address>`: <why the check does not fit here>; <how review covers the intent>
20
+
21
+ ## Judgement rules adopted
22
+
23
+ Applied in review with the lens each rule page names.
24
+
25
+ - `<clause address>`: <lens>
26
+
27
+ ## <clause address>
28
+
29
+ - **Cause here:** <a cause from the rule's Spirit list, named as the rule names it>. <How it shows in this codebase.>
30
+ - **Sites:** <count> at <commit>, in <folders or files>. For example <file:line>, <file:line>.
31
+ - **Forward goal:** <the cleaner design, in this codebase's terms>.
32
+ - **Steps:** 1. <the step that unlocks the rest> 2. <the next step>
33
+ - **Debt:** held by <owner>; recorded as <how it is recorded in discipline-exceptions.json>, or none.
34
+
35
+ Repeat **Cause here** and **Sites** for each cause the sites show. Write one section per clause whose findings are not all fixed in the change that adopts it, with the clause address alone as its heading.
@@ -46,7 +46,7 @@ Read them first; they override any default intuition.
46
46
 
47
47
  1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
48
48
  2. Keep the pages whose `Review lens` line names `clean-architecture`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved** — an unloadable ruleset is never a codebase without discipline, and reviewing zero rules would emit a PASS that means nothing.
49
- 3. Read each kept page in full, including its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a rule names exact permitted sites (a single adapter file, a single redaction layer, a closed list of binding counts), those are the only permitted sites.
49
+ 3. Read each kept page in full together with its sibling `CHECKS.md`, including the `## Exceptions` section in `CHECKS.md` and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a rule names exact permitted sites (a single adapter file, a single redaction layer, a closed list of binding counts), those are the only permitted sites.
50
50
  4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no clean-architecture discipline and produce an empty finding set — do not invent rules.
51
51
 
52
52
  ## Inspection procedure
@@ -163,5 +163,5 @@ outward-arrow / cross-layer violations, inner-code-importing-driver violations,
163
163
  ambient-global call sites, unannotated-PII log emissions, unbranded-secret
164
164
  declarations, secret-at-forbidden-surface hits, minimal-surface cap breaches).
165
165
  Every finding is `file:line | quoted code | <rule-id> | defect-named`, citing the
166
- loaded rule by the discipline id and clause address on the rule page (for example `CD-9#result-failures`). State the code-discipline path you
166
+ loaded rule by the discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`). State the code-discipline path you
167
167
  resolved and which rule ids you loaded under this lens.
@@ -41,7 +41,7 @@ forbidden. Read them first; they override any default intuition.
41
41
 
42
42
  1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
43
43
  2. Keep the pages whose `Review lens` line names `decomposition`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved** — an unloadable ruleset is never a codebase without discipline, and reviewing zero rules would emit a PASS that means nothing.
44
- 3. Read each kept page in full, including its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a clause on a rule page lists a deterministic check (a lint rule, an audit script) in its `## Clauses` table, treat that as a partial mechanical floor: the enforcer catches the obvious cases, but the structural read on diff-touched functions is the lens's job and is not mechanically covered.
44
+ 3. Read each kept page in full together with its sibling `CHECKS.md`, including the `## Exceptions` section in `CHECKS.md` and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a clause lists a deterministic check (a lint rule, an audit script) in the `## Clauses` table of its `CHECKS.md`, treat that as a partial mechanical floor: the enforcer catches the obvious cases, but the structural read on diff-touched functions is the lens's job and is not mechanically covered.
45
45
  4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no decomposition discipline and produce an empty finding set — do not invent rules or thresholds.
46
46
 
47
47
  ## Inspection procedure
@@ -154,6 +154,6 @@ inspected, complexity/length ceilings crossed by type, orchestrator-purity
154
154
  violations, early-return inversions, parameter-mutation findings (split by
155
155
  script-confirmed vs code-review category), and untracked suppressions. Every
156
156
  finding is `file:line | quoted code | <rule-id> | defect-named`, citing the
157
- loaded rule by the discipline id and clause address on the rule page (for example `CD-9#result-failures`), and — where extraction is
157
+ loaded rule by the discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`), and — where extraction is
158
158
  recommended — the suggested split per the four questions above. State the
159
159
  rule-page paths you resolved and which rule ids you loaded under this lens.
@@ -44,8 +44,8 @@ This lens applies **no lens filter to the rule pages**. Instead:
44
44
  2. For each PASS, the rule pages are consulted **solely to
45
45
  look up the literal text of the cited clause** — never to find new clauses to
46
46
  test. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`. Every rule page in scope is loaded, not filtered by lens. If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved — an unloadable ruleset is never a codebase without discipline. Each PASS
47
- cites a rule by the discipline id and clause address on the rule page (for example `CD-9#result-failures`), and that rule page is where the literal
48
- text and its governing principle live, together with its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline.
47
+ cites a rule by the discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`), and that rule page is where the literal
48
+ text and its governing principle live, together with the `## Exceptions` section of its sibling `CHECKS.md` and the repository's `discipline-exceptions.json` entries for that discipline.
49
49
  3. If the bundle carries zero PASS claims with cited artefacts, produce an empty
50
50
  gap set — do not invent claims to test.
51
51
 
@@ -125,15 +125,15 @@ intent sentence as a test. Three outcomes:
125
125
  This lens *is* the letter-vs-intent test, so its own catch-rate is the test's
126
126
  fidelity. The canonical pattern: a rule's letter enumerates a specific mechanism
127
127
  ("module mocks are forbidden — these named mechanisms"), an artefact uses a
128
- *different* mechanism not enumerated (a global stub, a monkey-patch, a
128
+ *different* mechanism not enumerated (an overwritten global, a monkey-patch, a
129
129
  module-system reach-around) and the PASS reads "that mechanism is not on the
130
130
  list, so the rule does not apply". The intent of the rule — derived from its
131
- principle (e.g. "every dependency outside the unit boundary is faked through
132
- dependency injection, never reached around") — is "no faking outside DI". The
133
- unlisted mechanism *is* faking outside DI; it passes the letter and fails the
131
+ principle (e.g. "every dependency outside the unit boundary is replaced by a test double through
132
+ dependency injection, never reached around") — is "no substitution outside DI". The
133
+ unlisted mechanism *is* substitution outside DI; it passes the letter and fails the
134
134
  intent. The structural reframing: the unit consumes the dependency as an
135
135
  injected port through its argument seam, production wires the real
136
- implementation in the wrapping-factory file, the test injects a fake directly;
136
+ implementation in the wrapping-factory file, the test injects a test double directly;
137
137
  the PASS retracts and becomes a DI/testing VIOLATION on the owning lens.
138
138
 
139
139
  The three properties that make a finding sound — and that an author can
@@ -17,35 +17,43 @@ and third-party services — arrives through a named port the unit receives as a
17
17
  constructor parameter or function argument, never reached for through a global,
18
18
  an ambient import, or the module system. Each port ships a default factory in
19
19
  its own module so production wires the real implementation once at the
20
- composition root and tests inject a fake of the same shape. The test face is the
21
- mirror image: a unit test fakes *everything* outside the unit's boundary, and it
22
- delivers those fakes the same way production delivers the real ones — through the
20
+ composition root and tests inject a test double of the same shape. The test face is the
21
+ mirror image: a unit test replaces *everything* outside the unit's boundary with a
22
+ test double, and it delivers those doubles the same way production delivers the
23
+ real ones — through the
23
24
  unit's own signature — so the unit is byte-identical under test and under
24
25
  production and never knows which it received. The moment a test reaches for the
25
- module system to control a dependency (mock an import, stub a global,
26
+ module system to control a dependency (replace an import, overwrite a global,
26
27
  monkey-patch a binding), the unit's DI is wrong: the dependency was not a port.
27
28
 
29
+ Test-double names follow the loaded rules' definitions, which use Meszaros's
30
+ taxonomy: a dummy is passed but never used, a stub returns canned answers, a spy
31
+ also records its calls, a mock verifies expectations set on it, and a fake is a
32
+ working lightweight implementation such as an in-memory repository. "Module
33
+ mock" is the test runner's name for module-system interception, not a mock in
34
+ that sense.
35
+
28
36
  Across codebases the concept recurs under different names (constructor
29
37
  injection, hexagonal ports-and-adapters, "no ambient singletons", "depend on
30
38
  abstractions"). The loaded rules tell you this codebase's exact shape: which
31
39
  capabilities are named ports, the single permitted site for each ambient
32
40
  binding (the wrapping factory), the default-factory naming convention, any
33
41
  type-level constraint on context-consuming middleware, and the closed list of
34
- banned test-faking mechanisms. Read them first; they override any default
42
+ banned module-interception mechanisms. Read them first; they override any default
35
43
  intuition.
36
44
 
37
45
  ## Loading the ruleset
38
46
 
39
47
  1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
40
48
  2. Keep the pages whose `Review lens` line names `di-discipline`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved** — an unloadable ruleset is never a codebase without discipline, and reviewing zero rules would emit a PASS that means nothing.
41
- 3. Read each kept page in full, including its `## Exceptions` section and any examples, and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a rule names the single permitted site for an ambient binding (a factory file, a port-module directory), that is the *only* permitted site; everywhere else the same call is a violation.
49
+ 3. Read each kept page in full together with its sibling `CHECKS.md`, including the `## Exceptions` section in `CHECKS.md` and any examples, and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a rule names the single permitted site for an ambient binding (a factory file, a port-module directory), that is the *only* permitted site; everywhere else the same call is a violation.
42
50
  4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no DI discipline and produce an empty finding set — do not invent rules.
43
51
 
44
52
  ## Inspection procedure
45
53
 
46
54
  This lens reads two faces and reports them separately: the **production side**
47
55
  (are bindings ports, wired from defaults, threaded to the units that need them)
48
- and the **test side** (are dependencies faked through the unit's own seam, or
56
+ and the **test side** (are dependencies replaced by test doubles through the unit's own seam, or
49
57
  reached for through the module system). Walk the diff for both.
50
58
 
51
59
  ### Production side
@@ -88,7 +96,7 @@ reached for through the module system). Walk the diff for both.
88
96
 
89
97
  ### Test side
90
98
 
91
- - **Module-system interception.** Every test-faking mechanism that reaches the
99
+ - **Module-system interception.** Every substitution mechanism that reaches the
92
100
  module system rather than the unit's signature is a finding the instant it
93
101
  appears — no further analysis of test outcome, library lineage, or local
94
102
  ergonomics is needed. This covers module mocks, deferred module mocks, hoisted
@@ -96,29 +104,33 @@ reached for through the module system). Walk the diff for both.
96
104
  equivalents, direct property assignment or property-descriptor patching on an
97
105
  imported binding, proxy wrappers around a real module, HTTP-interception
98
106
  libraries standing in for an injected client, and older rewire-style loaders.
99
- The remediation is always identical: lift the faked dependency into the unit's
107
+ The remediation is always identical: lift the replaced dependency into the unit's
100
108
  signature as a port, supply the production default at the composition root, and
101
- inject the fake directly in the test.
109
+ inject a test double directly in the test.
102
110
  - **The spy edge case — discriminate by attachment target.** A spy is the one
103
111
  mechanism that requires per-call classification. A spy attached to a method on
104
- a fake the test itself constructed and passed through the unit's seam is
112
+ a test double the test itself constructed and passed through the unit's seam is
105
113
  *observation* — permitted; it reads interaction without replacing anything. A
106
114
  spy attached to a method on an imported module (replacing or even merely
107
115
  observing its real behaviour) is *module-system reach* — the same shape as a
108
116
  module mock, a violation. The discriminator is solely **what object the spy is
109
- attached to**: a DI-delivered fake (permitted) or an imported binding
117
+ attached to**: a DI-delivered test double (permitted) or an imported binding
110
118
  (violation).
111
- - **Fakes that are permitted are not mocks.** A test that constructs an object
112
- literal, a factory-built fake, an in-memory implementation of a port, or a
113
- recording test-double function, and delivers it through the unit's constructor
114
- or argument, is the exact pattern the discipline channels toward — not a
115
- finding. "Mock" in common speech covers both shapes; the rules treat them as
116
- opposites. The affordance is the port's type; no library wraps it.
117
- - **Boundary gap that forces a mock.** If a dependency the test needs to control
118
- is *not in the unit's signature*, that is a structural finding even before any
119
- mock appears: the unit needs a port added before DI-clean testing is possible.
120
- A test-only subclass overriding a method, or a test-only env/flag the unit
121
- reads to choose fake-vs-real, are both this gap surfacing — the fake should
119
+ - **Test doubles through the seam are not module interception.** A test that
120
+ constructs a stub or spy as an object literal, a factory-built stub, a shared
121
+ in-memory fake of a port, or a recording spy function, and delivers it through
122
+ the unit's constructor or argument, is the exact pattern the discipline
123
+ channels toward — not a finding. In common speech "mock" covers both a double
124
+ passed through the seam and module interception. In the taxonomy a mock is only
125
+ a double that verifies expectations set on it, and module interception is not a
126
+ double at all: the rules permit doubles through the seam and forbid
127
+ interception. The affordance is the port's type; no library wraps it.
128
+ - **Boundary gap that forces module interception.** If a dependency the test
129
+ needs to control is *not in the unit's signature*, that is a structural finding
130
+ even before any interception appears: the unit needs a port added before
131
+ DI-clean testing is possible. A test-only subclass overriding a method, or a
132
+ test-only env/flag the unit reads to choose double-vs-real, are both this gap
133
+ surfacing — the double should
122
134
  arrive through the seam, and (for the env/flag case) the unit must not know it
123
135
  is under test.
124
136
 
@@ -137,8 +149,8 @@ raw global call on a "convenience" path; a default factory present but the boot
137
149
  path constructing the port inline beside it; a middleware generic that compiles
138
150
  because its context happens to carry the field, yet is unbound so a different
139
151
  pipeline would crash; a spy that looks like clean observation but is attached to
140
- an imported module; an in-memory fake that is actually wired through a module
141
- mock rather than the seam. A finding here must explain *how the code reads
152
+ an imported module; an in-memory fake that is actually wired through module
153
+ interception rather than the seam. A finding here must explain *how the code reads
142
154
  DI-clean yet the dependency is still reached for ambiently*, grounded in the
143
155
  specific loaded rule. Vague phrasings ("tight coupling", "hard to test") are the
144
156
  lens's own failure mode.
@@ -151,6 +163,6 @@ threading gaps, unbound context generics) and a test-side block
151
163
  (module-interception violations by mechanism, spy classifications, structural
152
164
  boundary gaps). Every finding is
153
165
  `file:line | quoted code | <rule-id> | defect-named`, citing the loaded rule by
154
- the discipline id and clause address on the rule page (for example `CD-9#result-failures`), and — for a test-side mock — naming the port
166
+ the discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`), and — for a test-side mock — naming the port
155
167
  shape the remediating refactor would lift into the unit's signature. State the
156
168
  rule-page paths you resolved and which rule ids you loaded under this lens.
@@ -29,7 +29,7 @@ intuition.
29
29
 
30
30
  1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
31
31
  2. Keep the pages whose `Review lens` line names `errors-as-data`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved** — an unloadable ruleset is never a codebase without discipline, and reviewing zero rules would emit a PASS that means nothing.
32
- 3. Read each kept page in full, including its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. If a rule names exact permitted sites (files, factory names, class names), those are the only permitted sites.
32
+ 3. Read each kept page in full together with its sibling `CHECKS.md`, including the `## Exceptions` section in `CHECKS.md` and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. If a rule names exact permitted sites (files, factory names, class names), those are the only permitted sites.
33
33
  4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no errors-as-data discipline and produce an empty finding set — do not invent rules.
34
34
 
35
35
  ## Inspection procedure
@@ -84,5 +84,5 @@ Produce the counts the review asks for (e.g. throws by
84
84
  classification, authored-error-classes by classification, under-enumerated error
85
85
  types, superseded-discriminator accesses). Every finding is
86
86
  `file:line | quoted code | <rule-id> | defect-named`, citing the loaded rule by
87
- the discipline id and clause address on the rule page (for example `CD-9#result-failures`). State the rule-page paths you resolved and
87
+ the discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`). State the rule-page paths you resolved and
88
88
  which rule ids you loaded under this lens.
@@ -56,7 +56,7 @@ default intuition.
56
56
 
57
57
  1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
58
58
  2. Keep the pages whose `Review lens` line names `function-first`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved** — an unloadable ruleset is never a codebase without discipline, and reviewing zero rules would emit a PASS that means nothing.
59
- 3. Read each kept page in full, including its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a rule names exact permitted sites (the one permitted class and its file, the closed table of wrapping-factory files, the closed list of library-callback signatures), those are the only permitted sites.
59
+ 3. Read each kept page in full together with its sibling `CHECKS.md`, including the `## Exceptions` section in `CHECKS.md` and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a rule names exact permitted sites (the one permitted class and its file, the closed table of wrapping-factory files, the closed list of library-callback signatures), those are the only permitted sites.
60
60
  4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no function-first discipline and produce an empty finding set — do not invent rules.
61
61
 
62
62
  ## Inspection procedure
@@ -186,7 +186,7 @@ declarations by classification (justified / closure-candidate / pure-fn-candidat
186
186
  raw-library-import and `new X(...)` sites by in-factory vs out-of-factory, and
187
187
  multi-argument authored signatures by carve-out vs finding. Every finding is
188
188
  `file:line | quoted code | <rule-id> | defect-named`, citing the loaded rule by
189
- the discipline id and clause address on the rule page (for example `CD-9#result-failures`), plus the bucket or the named-field/composition
189
+ the discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`), plus the bucket or the named-field/composition
190
190
  replacement. Where a finding touches another lens's rule (the context-generic
191
191
  binding, the port/boundary discipline), name that as a cross-reference — do not
192
192
  re-tag or re-own it. State the rule-page paths you resolved and which rule
@@ -43,7 +43,7 @@ first; they override any default intuition.
43
43
 
44
44
  1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
45
45
  2. Keep the pages whose `Review lens` line names `naming`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved.** That is an unloadable ruleset, never a codebase without discipline. Reviewing zero rules would emit a PASS that means nothing.
46
- 3. Read each kept page in full, including its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Carve-outs that name an exact permitted token (the single allowed single-character name), an exact permitted file (the one allowed barrel root), or a version history are load-bearing: a carve-out the current rule page reinstated or reverted changes the finding count, so cite the version when one is in play.
46
+ 3. Read each kept page in full together with its sibling `CHECKS.md`, including the `## Exceptions` section in `CHECKS.md` and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Carve-outs that name an exact permitted token (the single allowed single-character name), an exact permitted file (the one allowed barrel root), or a version history are load-bearing: a carve-out the current rule page reinstated or reverted changes the finding count, so cite the version when one is in play.
47
47
  4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no naming discipline and produce an empty finding set — do not invent rules.
48
48
 
49
49
  ## Inspection procedure
@@ -121,7 +121,7 @@ Produce the counts the review asks for (e.g. shorthand identifiers,
121
121
  filler-word identifiers, categorical filenames, categorical folders, untracked or
122
122
  forbidden annotations, scoped overrides to narrow/retire). Every finding is
123
123
  `file:line | quoted code | <rule-id> | defect-named`, citing the loaded rule by
124
- the discipline id and clause address on the rule page (for example `CD-9#result-failures`) and naming the expected replacement (the
124
+ the discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`) and naming the expected replacement (the
125
125
  domain-meaningful identifier, the re-derived abstraction filename, or the
126
126
  tracker-completed annotation). State the rule-page paths you resolved and
127
127
  which rule ids you loaded under this lens.
@@ -20,7 +20,7 @@ recur across codebases under different names:
20
20
  threshold.
21
21
  - **Zero-everything tests.** A test body is a straight line: arrange → act →
22
22
  assert. No control flow, no loops, no branches, no mutated capture, no
23
- unpredictability. N cases means N tests. Uniform cases, such as the rows of a table, are one parameterised test over the rows (the framework's `each`), never a loop inside a test body, and never one hand-written test per row. Variability is supplied by injected fakes, never computed inside the test.
23
+ unpredictability. N cases means N tests. Uniform cases, such as the rows of a table, are one parameterised test over the rows (the framework's `each`), never a loop inside a test body, and never one hand-written test per row. Variability is supplied by injected test doubles (stubs with canned answers, or a fake clock that the test advances), never computed inside the test.
24
24
  - **Assert only the unit's own responsibility.** A test inspects what its unit
25
25
  produces and how it calls its collaborators — never the internal logic of a
26
26
  delegate reached transitively.
@@ -42,14 +42,14 @@ they override any default intuition.
42
42
 
43
43
  1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
44
44
  2. Keep the pages whose `Review lens` line names `test-discipline`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved** — an unloadable ruleset is never a codebase without discipline, and reviewing zero rules would emit a PASS that means nothing.
45
- 3. Read each kept page in full, including its `## Exceptions` section, any in-body exception clause, and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. If a rule names exact allowed constructs, idioms, or excluded file kinds, those are the only ones permitted.
45
+ 3. Read each kept page in full together with its sibling `CHECKS.md`, including the `## Exceptions` section in `CHECKS.md`, any in-body exception clause, and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. If a rule names exact allowed constructs, idioms, or excluded file kinds, those are the only ones permitted.
46
46
  4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no test-discipline rules and produce an empty finding set — do not invent rules.
47
47
 
48
48
  ## Inspection procedure
49
49
 
50
50
  Walk the test files and the authored files in the diff. The strands below are
51
51
  the generic detection insight; each maps to a loaded rule, which you cite by the
52
- discipline id and clause address on the rule page (for example `CD-9#result-failures`).
52
+ discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`).
53
53
 
54
54
  ### Sibling floor
55
55
 
@@ -73,7 +73,9 @@ finding citing the construct. Know the rule's *allowed* patterns so you do not
73
73
  false-positive: an inline narrowing assertion that the rule blesses is not a
74
74
  branch; full-envelope matchers replace try/catch around thrown errors; `const`
75
75
  destructuring with defaults is not a branch; data fixtures living outside the
76
- test-file source are out of scope. The fix for a banned construct is almost
76
+ test-file source are out of scope for this zero-logic scan only; they remain
77
+ integration test tools, used at a bare minimum, and a unit test that reads one
78
+ is doing real I/O. The fix for a banned construct is almost
77
79
  always "split into N linear tests" or "use the matcher the framework already
78
80
  provides" — name that in the finding.
79
81
 
@@ -87,7 +89,7 @@ falsy/defined/not-null check over an envelope, object, array, or tuple accepts
87
89
  malformed shapes the unit should never produce — that is a finding; replace with
88
90
  a full-envelope equality or structural match against the exact expected value. A
89
91
  bare call-occurrence assertion where the call *arguments* carry the unit's
90
- correctness is the same defect on a fake — replace with an exact-argument match.
92
+ correctness is the same defect on a spy — replace with an exact-argument match.
91
93
  If the honest answer to "what would it accept that it shouldn't?" is "nothing
92
94
  meaningful" (e.g. a boolean-returning predicate asserted with a boolean literal),
93
95
  the matcher is not vague. The lens is not "always demand the strictest matcher";
@@ -97,21 +99,21 @@ it is "do not accept assertions that lose shape on values that have shape".
97
99
 
98
100
  A test must assert the unit's own output and the *call shape* it makes on its
99
101
  collaborators — never the internal result of a delegate. Flag assertions that
100
- reach into a fake's configured return value (asserting on what arrange already
102
+ reach into a stub's configured return value (asserting on what arrange already
101
103
  set), that drill into a delegate's nested return shape, that exercise a partial
102
- fake which itself runs real delegate logic, or that assert a value the unit
103
- merely passed through from a fake. The wanted shape is an exact-argument call
104
- assertion on the fake plus an equality on the unit's *own* computed output.
104
+ double which itself runs real delegate logic, or that assert a value the unit
105
+ merely passed through from a stub. The wanted shape is an exact-argument call
106
+ assertion on the spy plus an equality on the unit's *own* computed output.
105
107
 
106
108
  ### Pyramid mis-scope
107
109
 
108
110
  Check each test sits at the right layer. **Mis-scoped down:** an integration-
109
- suffixed test built entirely from fakes (a unit test wearing the wrong suffix),
111
+ suffixed test built entirely from test doubles (a unit test wearing the wrong suffix),
110
112
  or one that spins up a real backing the unit never touches (decorative
111
113
  ceremony) — move it to the unit layer. **Mis-scoped up:** a unit-suffixed test
112
- that wires several units together with no fakes between them and asserts on the
114
+ that wires several units together with no test doubles between them and asserts on the
113
115
  cross-unit output — that belongs at the integration layer; the unit layer should
114
- fake each cross-boundary collaborator. **Missing-unit signal:** an integration
116
+ replace each cross-boundary collaborator with a test double. **Missing-unit signal:** an integration
115
117
  test failing on a bug localisable to one unit's body — the bug should have failed
116
118
  a unit test first; the finding is the missing unit test, not the integration
117
119
  test.
@@ -161,6 +163,6 @@ inspected, siblings present vs missing, test files inspected, zero-logic
161
163
  construct violations, vague-matcher assertions, delegation leaks, mis-scoped
162
164
  tests by direction, tautological-act tests, valueless tests, uniform cases written out by hand). Every finding is
163
165
  `file:line | quoted code | <rule-id> | defect-named`, citing the loaded rule by
164
- the discipline id and clause address on the rule page (for example `CD-9#result-failures`), and — for a mis-scope, delegation, or act
166
+ the discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`), and — for a mis-scope, delegation, or act
165
167
  finding — naming what fixes it (the layer to move to, the call-shape assertion
166
168
  to use, or the upstream bound that deletes the test). State the rule-page paths you resolved and which rule ids you loaded under this lens.
@@ -45,7 +45,7 @@ return-type carve-out. Read them first; they override any default intuition.
45
45
 
46
46
  1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
47
47
  2. Keep the pages whose `Review lens` line names `type-soundness`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved** — an unloadable ruleset is never a codebase without discipline, and reviewing zero rules would emit a PASS that means nothing.
48
- 3. Read each kept page in full, including its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a rule names exact permitted sites (file paths, cast shapes, predicate forms, flag names), those are the only permitted sites, and a site matching the *kind* but not the exact named location is still a finding.
48
+ 3. Read each kept page in full together with its sibling `CHECKS.md`, including the `## Exceptions` section in `CHECKS.md` and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a rule names exact permitted sites (file paths, cast shapes, predicate forms, flag names), those are the only permitted sites, and a site matching the *kind* but not the exact named location is still a finding.
49
49
  4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no type-soundness discipline and produce an empty finding set — do not invent rules.
50
50
 
51
51
  ## Inspection procedure
@@ -130,6 +130,6 @@ return-type-of-own-symbol sites, closed-union `default:` arms, declarative-boole
130
130
  sites by carve-out invoked). Record the compiler version / config you read where
131
131
  the rules call for it. Every finding is
132
132
  `file:line | quoted code | <rule-id> | defect-named`, citing the loaded rule by
133
- the discipline id and clause address on the rule page (for example `CD-9#result-failures`); where a carve-out was invoked, state which one
133
+ the discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`); where a carve-out was invoked, state which one
134
134
  and why it does not apply. State the rule-page paths you resolved and which
135
135
  rule ids you loaded under this lens.
@@ -38,7 +38,7 @@ the library. Read them first; they override any default intuition.
38
38
 
39
39
  1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
40
40
  2. Keep the pages whose `Review lens` line names `zod-boundary`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved** — an unloadable ruleset is never a codebase without discipline, and reviewing zero rules would emit a PASS that means nothing.
41
- 3. Read each kept page in full, including its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. If a rule names the exact closed list of boundary-only sites, those are the only places the validation library may run; if it names the inner layers where the library is forbidden, those are the only places a schema import is an automatic finding.
41
+ 3. Read each kept page in full together with its sibling `CHECKS.md`, including the `## Exceptions` section in `CHECKS.md` and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. If a rule names the exact closed list of boundary-only sites, those are the only places the validation library may run; if it names the inner layers where the library is forbidden, those are the only places a schema import is an automatic finding.
42
42
  4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no boundary-validation discipline and produce an empty finding set — do not invent rules.
43
43
 
44
44
  ## Inspection procedure
@@ -151,7 +151,7 @@ is mandatory and so are the counts it yields: crossings inspected / validated /
151
151
  typeless; library returns inspected / validated / accepted-at-face-value;
152
152
  internal validation-library imports; seam ambiguities. Every finding is
153
153
  `file:line | quoted code | <rule-id> | defect-named`, citing the loaded rule by
154
- the discipline id and clause address on the rule page (for example `CD-9#result-failures`). For any missing-schema finding whose observable
154
+ the discipline id and clause address in its CHECKS.md Clauses table (for example `CD-9#result-failures`). For any missing-schema finding whose observable
155
155
  symptom is a cast, name the cast as the symptom and the missing schema as the
156
156
  defect (the cast itself belongs to the type-soundness lens). For any seam
157
157
  ambiguity, name the upstream architectural cause. State the code-discipline path
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hailstails/hone",
3
- "version": "0.1.0-pre.5",
3
+ "version": "0.1.0-pre.6",
4
4
  "description": "Checks a repository against the disciplines it selects, applies its recorded exceptions and prints one verdict.",
5
5
  "keywords": [
6
6
  "disciplines",
@@ -39,6 +39,7 @@
39
39
  "./mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js": "./mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js",
40
40
  "./mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js": "./mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js",
41
41
  "./mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js": "./mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js",
42
+ "./mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js": "./mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js",
42
43
  "./mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js": "./mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js",
43
44
  "./mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js": "./mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js",
44
45
  "./mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js": "./mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js",
@@ -0,0 +1,37 @@
1
+ # CD-1 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-1#any-cast` | audit | a type assertion whose type contains `any` |
10
+ | `CD-1#explicit-any` | eslint | an `any` type anywhere in a type position |
11
+ | `CD-1#implicit-any-let` | eslint | a `let` or `var` with neither a type annotation nor an initialiser |
12
+
13
+ ## What the check flags
14
+ - `.ts` and `.tsx` files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
15
+ - A type assertion (`x as T` or `<T>x`) whose type contains the `any` keyword at any depth: `as any`, `<any>x`, `as Array<any>`, `as Record<string, any>`, `as Map<string, any>` or `as { field: any }`. The check reads the syntax tree, so an `any` elsewhere on the line is not attributed to the cast.
16
+ - CD-1 judges these before CD-2 and has no settings; every other assertion is CD-2's.
17
+ - A bare annotation such as `let value: any` is not flagged by this clause; `CD-1#explicit-any` covers it.
18
+
19
+ ## What the ESLint check flags
20
+ Needs ESLint adopted through the projection; see [the ESLint piece](../../mechanisms/eslint/CD-1/README.md).
21
+ - `hone-cd1/no-explicit-any` is typescript-eslint's `no-explicit-any` with default options. It flags every `any` type: annotations, type arguments such as `Map<string, any>`, and `as any`.
22
+ - `hone-cd1/implicit-any-let` flags a `let` or `var` declaration in a `.ts` or `.tsx` file that has neither a type annotation nor an initialiser, one report per declaration at its first such binding. Declaration files (`.d.ts`), `const`, and `for-in` and `for-of` heads are not flagged.
23
+ - Allowed: `unknown`, `let total = 0` and `let total: number`.
24
+
25
+ ## Example violation
26
+ ```ts
27
+ const parsed = JSON.parse(text) as any;
28
+ ```
29
+
30
+ ## How to fix
31
+ ```ts
32
+ const order = orderSchema.parse(JSON.parse(text));
33
+ ```
34
+ Give it a concrete type where it enters: parse it with a schema or a type guard at the boundary, checked at runtime.
35
+
36
+ ## Exceptions
37
+ CD-1 is exempted like any other discipline: record an `authorised-location`, a `file-carve-out` for existing debt, or a clause-wide carve-out in `discipline-exceptions.json`. A carved or authorised file keeps its existing `any`; an `any` anywhere else still fails. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
@@ -2,42 +2,27 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- `any` is the absence of a type: it tells the compiler to stop checking, and that hole propagates silently through every call site that consumes the value. The whole reason a type system exists — catching shape errors before runtime — is forfeited at each `any`. Reach for `unknown` and narrow at the read site, or a precise union. Every `any` is a violation regardless of stated reason: no code form or setting permits one. Debt a repository carries while adopting the rule is held only in exception records.
5
+ `any` is the absence of a type: it tells the compiler to stop checking, and that hole propagates silently through every call site that consumes the value. The whole reason a type system exists — catching shape errors before runtime — is forfeited at each `any`. Give the value a concrete type where it enters, checked at runtime, or a precise union. Every `any` is a violation regardless of stated reason: no code form or setting permits one. Debt a repository carries while adopting the rule is held only in exception records.
6
6
 
7
- The sections below describe what the audit and ESLint checks cover.
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-1#any-cast` | audit | a type assertion whose type contains `any` |
14
- | `CD-1#explicit-any` | eslint | an `any` type anywhere in a type position |
15
- | `CD-1#implicit-any-let` | eslint | a `let` or `var` with neither a type annotation nor an initialiser |
11
+ **What the friction is for.** A value with no type switches off checking for everything it touches. The friction makes "this value has a known shape" the cheapest thing to write, so the compiler keeps doing the work at every use instead of a reader doing it in their head.
16
12
 
17
- 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
+ - *Input never typed where it entered.* A request, file, parse or database row crossed in and nobody said what it is. Give it a concrete type at that boundary, checked at runtime.
15
+ - *A shape nobody named.* The value has a shape that was never declared. Declare it as a type or a union.
16
+ - *A library kept at arm's length.* The vendor's types were awkward, so they were dropped. Wrap the library once and hand the rest of the code your own type.
17
+ - *One function serving many shapes.* It takes anything because its callers differ. Split it, or make the variants an explicit union.
18
18
 
19
- ## What the check flags
20
- - `.ts` and `.tsx` files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
21
- - A type assertion (`x as T` or `<T>x`) whose type contains the `any` keyword at any depth: `as any`, `<any>x`, `as Array<any>`, `as Record<string, any>`, `as Map<string, any>` or `as { field: any }`. The check reads the syntax tree, so an `any` elsewhere on the line is not attributed to the cast.
22
- - CD-1 judges these before CD-2 and has no settings; every other assertion is CD-2's.
23
- - A bare annotation such as `let value: any` is not flagged by this clause; `CD-1#explicit-any` covers it.
19
+ **Where to go.** Every value inside the codebase has a known type. Unknown data becomes concrete where it arrives, not somewhere further in. A high count is usually one or two boundaries that were never built; build those first and most sites go with them.
24
20
 
25
- ## What the ESLint check flags
26
- Needs ESLint adopted through the projection; see [the ESLint piece](../../mechanisms/eslint/CD-1/README.md).
27
- - `hone-cd1/no-explicit-any` is typescript-eslint's `no-explicit-any` with default options. It flags every `any` type: annotations, type arguments such as `Map<string, any>`, and `as any`.
28
- - `hone-cd1/implicit-any-let` flags a `let` or `var` declaration in a `.ts` or `.tsx` file that has neither a type annotation nor an initialiser, one report per declaration at its first such binding. Declaration files (`.d.ts`), `const`, and `for-in` and `for-of` heads are not flagged.
29
- - Allowed: `unknown`, `let total = 0` and `let total: number`.
21
+ **Reactions to distrust.**
22
+ - "It's just tests." A test that needs an untyped value builds its input the wrong way. Build the real type.
23
+ - "The library forces it." It forces it at one call. One wrapping file holds that.
24
+ - "Swap it for unknown." Unknown carried inward is the same debt, deferred. Very few values should stay unknown past the boundary.
30
25
 
31
- ## Example violation
32
- ```ts
33
- const parsed = JSON.parse(text) as any;
34
- ```
35
-
36
- ## How to fix
37
- ```ts
38
- const parsed: unknown = JSON.parse(text);
39
- ```
40
- Narrow `unknown` with a schema or a type guard at the point of use.
41
-
42
- ## Exceptions
43
- CD-1 is exempted like any other discipline: record an `authorised-location`, a `file-carve-out` for existing debt, or a clause-wide carve-out in `discipline-exceptions.json`. A carved or authorised file keeps its existing `any`; an `any` anywhere else still fails. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
26
+ **Principles behind it.**
27
+ - *Parse, don't validate* (Alexis King). Turn untyped input into a typed value once, where it arrives, so everything after it can rely on the type.
28
+ - *Make illegal states unrepresentable* (Yaron Minsky). A precise type or union rules out shapes the code cannot handle; an untyped value rules out nothing.