@hailstails/hone 0.0.0-stage → 0.1.0-pre.2

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 (186) hide show
  1. package/ADOPTING.md +314 -0
  2. package/LICENSE +17 -0
  3. package/MIGRATING.md +238 -0
  4. package/README.md +216 -2
  5. package/THIRD-PARTY-NOTICES.md +354 -0
  6. package/chunks/chunk-233U4FBA.js +42 -0
  7. package/chunks/chunk-7ZJZZBSS.js +14909 -0
  8. package/chunks/chunk-HBY4ZWSP.js +79 -0
  9. package/chunks/chunk-HJA4CX7C.js +24 -0
  10. package/chunks/chunk-NZLE2WMY.js +35 -0
  11. package/chunks/chunk-QWA6OVLC.js +11 -0
  12. package/chunks/chunk-TRCB27ET.js +202 -0
  13. package/core/check/tool-command.js +2305 -0
  14. package/docs/adding-a-discipline-or-mechanism.md +195 -0
  15. package/docs/why-chain-contract.md +78 -0
  16. package/mechanisms/audit/CD-1/any-cast.js +81 -0
  17. package/mechanisms/audit/CD-1/piece.json +13 -0
  18. package/mechanisms/audit/CD-10/piece.json +13 -0
  19. package/mechanisms/audit/CD-10/throws-in-tests.js +49 -0
  20. package/mechanisms/audit/CD-14/class-syntax.js +70 -0
  21. package/mechanisms/audit/CD-14/piece.json +13 -0
  22. package/mechanisms/audit/CD-15/loops.js +40 -0
  23. package/mechanisms/audit/CD-15/piece.json +13 -0
  24. package/mechanisms/audit/CD-17/clock-sources.js +29 -0
  25. package/mechanisms/audit/CD-17/piece.json +13 -0
  26. package/mechanisms/audit/CD-19/import-boundaries.js +80 -0
  27. package/mechanisms/audit/CD-19/piece.json +13 -0
  28. package/mechanisms/audit/CD-2/cast-expressions.js +81 -0
  29. package/mechanisms/audit/CD-2/piece.json +13 -0
  30. package/mechanisms/audit/CD-23/export-test-sibling.js +56 -0
  31. package/mechanisms/audit/CD-23/piece.json +13 -0
  32. package/mechanisms/audit/CD-25/dependency-isolation.js +53 -0
  33. package/mechanisms/audit/CD-25/piece.json +13 -0
  34. package/mechanisms/audit/CD-26/module-mocking.js +51 -0
  35. package/mechanisms/audit/CD-26/piece.json +13 -0
  36. package/mechanisms/audit/CD-27/piece.json +13 -0
  37. package/mechanisms/audit/CD-27/test-body-logic.js +107 -0
  38. package/mechanisms/audit/CD-3/compiler-overrides.js +955 -0
  39. package/mechanisms/audit/CD-3/piece.json +49 -0
  40. package/mechanisms/audit/CD-43/boolean-signatures.js +55 -0
  41. package/mechanisms/audit/CD-43/piece.json +13 -0
  42. package/mechanisms/audit/CD-44/parameter-mutation.js +92 -0
  43. package/mechanisms/audit/CD-44/piece.json +13 -0
  44. package/mechanisms/audit/CD-47/hermetic-git-spawns.js +44 -0
  45. package/mechanisms/audit/CD-47/piece.json +13 -0
  46. package/mechanisms/audit/CD-5/comments-directives.js +73 -0
  47. package/mechanisms/audit/CD-5/piece.json +13 -0
  48. package/mechanisms/audit/CD-6/identifier-names.js +132 -0
  49. package/mechanisms/audit/CD-6/piece.json +13 -0
  50. package/mechanisms/audit/CD-7/categorical-paths.js +55 -0
  51. package/mechanisms/audit/CD-7/piece.json +13 -0
  52. package/mechanisms/audit/CD-7a/factory-return-types.js +42 -0
  53. package/mechanisms/audit/CD-7a/piece.json +13 -0
  54. package/mechanisms/audit/CD-8/piece.json +13 -0
  55. package/mechanisms/audit/CD-8/switch-defaults.js +43 -0
  56. package/mechanisms/audit/runner/README.md +38 -0
  57. package/mechanisms/audit/runner/runner.js +546 -0
  58. package/mechanisms/eslint/CD-1/README.md +12 -0
  59. package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +50 -0
  60. package/mechanisms/eslint/CD-1/piece.json +23 -0
  61. package/mechanisms/eslint/CD-10/README.md +9 -0
  62. package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +55 -0
  63. package/mechanisms/eslint/CD-10/piece.json +15 -0
  64. package/mechanisms/eslint/CD-14/README.md +11 -0
  65. package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +88 -0
  66. package/mechanisms/eslint/CD-14/piece.json +31 -0
  67. package/mechanisms/eslint/CD-27/README.md +12 -0
  68. package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +83 -0
  69. package/mechanisms/eslint/CD-27/piece.json +23 -0
  70. package/mechanisms/eslint/CD-40/README.md +7 -0
  71. package/mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js +16 -0
  72. package/mechanisms/eslint/CD-40/piece.json +21 -0
  73. package/mechanisms/eslint/CD-41/README.md +12 -0
  74. package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +228 -0
  75. package/mechanisms/eslint/CD-41/piece.json +23 -0
  76. package/mechanisms/eslint/CD-42/README.md +9 -0
  77. package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +75 -0
  78. package/mechanisms/eslint/CD-42/piece.json +15 -0
  79. package/mechanisms/eslint/CD-44/README.md +7 -0
  80. package/mechanisms/eslint/CD-44/cd44/cd44.eslint-plugin.js +16 -0
  81. package/mechanisms/eslint/CD-44/piece.json +20 -0
  82. package/mechanisms/eslint/CD-6/README.md +9 -0
  83. package/mechanisms/eslint/CD-6/cd6/cd6.eslint-plugin.js +16 -0
  84. package/mechanisms/eslint/CD-6/piece.json +217 -0
  85. package/mechanisms/eslint/CD-7/README.md +9 -0
  86. package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +52 -0
  87. package/mechanisms/eslint/CD-7/piece.json +15 -0
  88. package/mechanisms/eslint/runner/README.md +43 -0
  89. package/mechanisms/eslint/runner/runner.js +4248 -0
  90. package/methods/README.md +18 -0
  91. package/methods/lenses/clean-architecture.md +167 -0
  92. package/methods/lenses/decomposition.md +159 -0
  93. package/methods/lenses/defended-on-intent.md +178 -0
  94. package/methods/lenses/di-discipline.md +156 -0
  95. package/methods/lenses/errors-as-data.md +88 -0
  96. package/methods/lenses/function-first.md +193 -0
  97. package/methods/lenses/naming.md +127 -0
  98. package/methods/lenses/test-discipline.md +166 -0
  99. package/methods/lenses/type-soundness.md +135 -0
  100. package/methods/lenses/zod-boundary.md +158 -0
  101. package/package.json +65 -4
  102. package/rules/CD-1/README.md +43 -0
  103. package/rules/CD-1/discipline.json +185 -0
  104. package/rules/CD-10/README.md +55 -0
  105. package/rules/CD-10/discipline.json +133 -0
  106. package/rules/CD-11/README.md +19 -0
  107. package/rules/CD-11/discipline.json +12 -0
  108. package/rules/CD-12/README.md +19 -0
  109. package/rules/CD-12/discipline.json +12 -0
  110. package/rules/CD-13/README.md +19 -0
  111. package/rules/CD-13/discipline.json +12 -0
  112. package/rules/CD-14/README.md +54 -0
  113. package/rules/CD-14/discipline.json +173 -0
  114. package/rules/CD-15/README.md +48 -0
  115. package/rules/CD-15/discipline.json +73 -0
  116. package/rules/CD-16/README.md +17 -0
  117. package/rules/CD-17/README.md +42 -0
  118. package/rules/CD-17/discipline.json +51 -0
  119. package/rules/CD-18/README.md +19 -0
  120. package/rules/CD-18/discipline.json +12 -0
  121. package/rules/CD-19/README.md +45 -0
  122. package/rules/CD-19/discipline.json +65 -0
  123. package/rules/CD-2/README.md +43 -0
  124. package/rules/CD-2/discipline.json +65 -0
  125. package/rules/CD-20/README.md +17 -0
  126. package/rules/CD-21/README.md +19 -0
  127. package/rules/CD-21/discipline.json +12 -0
  128. package/rules/CD-22/README.md +19 -0
  129. package/rules/CD-22/discipline.json +12 -0
  130. package/rules/CD-23/README.md +41 -0
  131. package/rules/CD-23/discipline.json +57 -0
  132. package/rules/CD-24/README.md +17 -0
  133. package/rules/CD-25/README.md +43 -0
  134. package/rules/CD-25/discipline.json +57 -0
  135. package/rules/CD-26/README.md +42 -0
  136. package/rules/CD-26/discipline.json +57 -0
  137. package/rules/CD-27/README.md +51 -0
  138. package/rules/CD-27/discipline.json +233 -0
  139. package/rules/CD-28/README.md +19 -0
  140. package/rules/CD-28/discipline.json +12 -0
  141. package/rules/CD-29/README.md +19 -0
  142. package/rules/CD-29/discipline.json +12 -0
  143. package/rules/CD-3/README.md +48 -0
  144. package/rules/CD-3/discipline.json +363 -0
  145. package/rules/CD-30/README.md +19 -0
  146. package/rules/CD-30/discipline.json +12 -0
  147. package/rules/CD-31/README.md +19 -0
  148. package/rules/CD-31/discipline.json +12 -0
  149. package/rules/CD-32/README.md +19 -0
  150. package/rules/CD-32/discipline.json +12 -0
  151. package/rules/CD-33/README.md +19 -0
  152. package/rules/CD-33/discipline.json +12 -0
  153. package/rules/CD-34/README.md +19 -0
  154. package/rules/CD-34/discipline.json +12 -0
  155. package/rules/CD-39/README.md +19 -0
  156. package/rules/CD-39/discipline.json +12 -0
  157. package/rules/CD-4/README.md +19 -0
  158. package/rules/CD-4/discipline.json +12 -0
  159. package/rules/CD-40/README.md +45 -0
  160. package/rules/CD-40/discipline.json +58 -0
  161. package/rules/CD-41/README.md +60 -0
  162. package/rules/CD-41/discipline.json +124 -0
  163. package/rules/CD-42/README.md +53 -0
  164. package/rules/CD-42/discipline.json +61 -0
  165. package/rules/CD-43/README.md +43 -0
  166. package/rules/CD-43/discipline.json +65 -0
  167. package/rules/CD-44/README.md +54 -0
  168. package/rules/CD-44/discipline.json +111 -0
  169. package/rules/CD-45/README.md +19 -0
  170. package/rules/CD-45/discipline.json +12 -0
  171. package/rules/CD-46/README.md +13 -0
  172. package/rules/CD-47/README.md +47 -0
  173. package/rules/CD-47/discipline.json +57 -0
  174. package/rules/CD-5/README.md +46 -0
  175. package/rules/CD-5/discipline.json +65 -0
  176. package/rules/CD-6/README.md +57 -0
  177. package/rules/CD-6/discipline.json +165 -0
  178. package/rules/CD-7/README.md +52 -0
  179. package/rules/CD-7/discipline.json +142 -0
  180. package/rules/CD-7a/README.md +44 -0
  181. package/rules/CD-7a/discipline.json +57 -0
  182. package/rules/CD-8/README.md +48 -0
  183. package/rules/CD-8/discipline.json +57 -0
  184. package/rules/CD-9/README.md +19 -0
  185. package/rules/CD-9/discipline.json +12 -0
  186. package/rules/README.md +52 -0
@@ -0,0 +1,44 @@
1
+ # CD-7a: No ReturnType<typeof X> for our own codebase
2
+
3
+ ## Rule
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.
6
+
7
+ The sections below describe what the audit check covers.
8
+
9
+ ## Clauses
10
+
11
+ | Clause | Mechanism | Checks |
12
+ | --- | --- | --- |
13
+ | `CD-7a#factory-return-types` | audit | a line containing `ReturnType<typeof` |
14
+
15
+ Review lens: [type-soundness](../../methods/lenses/type-soundness.md). The lens reviews the whole rule, including what no check flags.
16
+
17
+ ## What the check flags
18
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
19
+ - Any line matching `ReturnType<typeof`, one finding per line. This includes `Awaited<ReturnType<typeof ...>>` and matches inside strings.
20
+ - Lines starting with `//`, `/*` or `*` are ignored. A `ReturnType<` and `typeof` split across lines are not seen.
21
+ - The source rule's carve-out, an external library symbol with no exported return type, is not detected; record it as an exception.
22
+
23
+ ## Example violation
24
+ ```ts
25
+ type Client = ReturnType<typeof createClient>;
26
+ ```
27
+
28
+ ## How to fix
29
+ ```ts
30
+ export type Client = { readonly send: (message: string) => void };
31
+ const createClient = (): Client => ({ send: () => undefined });
32
+ ```
33
+ Declare and export the type, then annotate the factory with it.
34
+
35
+ ## Exceptions
36
+ Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when the type comes from a library whose package exports no named return type. Use `file-carve-out` for debt in one file: it needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
37
+
38
+ ```json
39
+ { "version": 1, "exceptions": [
40
+ { "kind": "authorised-location", "clause": "CD-7a#factory-return-types", "file": "src/adapters/vendor-client.ts", "reason": "..." }
41
+ ] }
42
+ ```
43
+
44
+ Every record, `authorised-location` included, also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
@@ -0,0 +1,57 @@
1
+ {
2
+ "version": 1,
3
+ "id": "CD-7a",
4
+ "clauses": [
5
+ {
6
+ "kind": "mechanical",
7
+ "id": "factory-return-types",
8
+ "summary": "No ReturnType<typeof X> for our own codebase",
9
+ "mechanisms": [
10
+ "audit"
11
+ ],
12
+ "anchor": {
13
+ "kind": "file"
14
+ },
15
+ "cases": {
16
+ "flag": [
17
+ {
18
+ "name": "ReturnType of a factory",
19
+ "fileName": "client.ts",
20
+ "source": "declare const createClient: () => unknown;\nexport type Client = ReturnType<typeof createClient>;\n",
21
+ "expectedLines": [
22
+ 2
23
+ ]
24
+ },
25
+ {
26
+ "name": "awaited ReturnType of a factory",
27
+ "fileName": "awaited.ts",
28
+ "source": "declare const createClient: () => Promise<unknown>;\nexport type Client = Awaited<ReturnType<typeof createClient>>;\n",
29
+ "expectedLines": [
30
+ 2
31
+ ]
32
+ }
33
+ ],
34
+ "allow": [
35
+ {
36
+ "name": "named exported type",
37
+ "fileName": "named.ts",
38
+ "source": "export interface Client { readonly id: string }\nexport const createClient = (): Client => ({ id: \"a\" });\n",
39
+ "expectedLines": []
40
+ },
41
+ {
42
+ "name": "ReturnType in a comment line",
43
+ "fileName": "commented.ts",
44
+ "source": "// type Client = ReturnType<typeof createClient>;\nexport const value = 1;\n",
45
+ "expectedLines": []
46
+ },
47
+ {
48
+ "name": "ReturnType of a type parameter",
49
+ "fileName": "generic.ts",
50
+ "source": "export type Result<Factory extends () => unknown> = ReturnType<Factory>;\n",
51
+ "expectedLines": []
52
+ }
53
+ ]
54
+ }
55
+ }
56
+ ]
57
+ }
@@ -0,0 +1,48 @@
1
+ # CD-8: No default on switch over a closed discriminated union
2
+
3
+ ## Rule
4
+
5
+ A switch over a closed discriminated union carries no `default:` arm. Exhaustiveness is the type system's job: with no default, adding a variant surfaces as a compile error at every switch that has not handled it. A `default:` swallows that signal and lets the new variant slip through silently at runtime.
6
+
7
+ The sections below describe what the audit check covers.
8
+
9
+ ## Clauses
10
+
11
+ | Clause | Mechanism | Checks |
12
+ | --- | --- | --- |
13
+ | `CD-8#switch-defaults` | audit | a `default:` arm inside a `switch` |
14
+
15
+ Review lens: [type-soundness](../../methods/lenses/type-soundness.md). The lens reviews the whole rule, including what no check flags.
16
+
17
+ ## What the check flags
18
+ - `.ts` and `.tsx` files, including tests and declaration files; generated folders such as `node_modules`, `dist`, `build` and `coverage` are skipped.
19
+ - A line matching `default:` while inside a `switch (`, tracked line by line by counting braces. One finding per line; comment lines are ignored.
20
+ - Every `default:` is flagged. The check cannot tell whether the switch is over a closed union, so a switch over an open set (a plain string) needs an exception. Other `default:` text inside a switch, such as an object key, is flagged too.
21
+
22
+ ## Example violation
23
+ ```ts
24
+ switch (event.kind) {
25
+ case "opened": return open();
26
+ default: return ignore();
27
+ }
28
+ ```
29
+
30
+ ## How to fix
31
+ ```ts
32
+ switch (event.kind) {
33
+ case "opened": return open();
34
+ case "closed": return ignore();
35
+ }
36
+ ```
37
+ Name each remaining variant so the compiler checks exhaustiveness.
38
+
39
+ ## Exceptions
40
+ Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a switch is over an open set of values and needs a fallback. Use `file-carve-out` for debt in one file: it needs a `whyChain` and is forfeited once the file is touched. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
41
+
42
+ ```json
43
+ { "version": 1, "exceptions": [
44
+ { "kind": "authorised-location", "clause": "CD-8#switch-defaults", "file": "src/parsing/token-reader.ts", "reason": "..." }
45
+ ] }
46
+ ```
47
+
48
+ Every record, `authorised-location` included, also needs a `whyChain` that follows the [why-chain contract](../../docs/why-chain-contract.md): five whys chained cause to cause, a `rootCause`, its `rootCheck`, a `readback` and an `owner`. The one exception is a record imported from an earlier system, which carries `provenance` instead. [The exceptions format](../../README.md#discipline-exceptionsjson) gives both shapes.
@@ -0,0 +1,57 @@
1
+ {
2
+ "version": 1,
3
+ "id": "CD-8",
4
+ "clauses": [
5
+ {
6
+ "kind": "mechanical",
7
+ "id": "switch-defaults",
8
+ "summary": "No default on switch over a closed discriminated union",
9
+ "mechanisms": [
10
+ "audit"
11
+ ],
12
+ "anchor": {
13
+ "kind": "file"
14
+ },
15
+ "cases": {
16
+ "flag": [
17
+ {
18
+ "name": "default arm",
19
+ "fileName": "dispatch.ts",
20
+ "source": "export const dispatch = (kind: \"opened\" | \"closed\"): number => {\n switch (kind) {\n case \"opened\": return 1;\n default: return 0;\n }\n};\n",
21
+ "expectedLines": [
22
+ 4
23
+ ]
24
+ },
25
+ {
26
+ "name": "default arm on the switch line",
27
+ "fileName": "inline.ts",
28
+ "source": "declare const stop: () => void;\ndeclare const kind: string;\nswitch (kind) { default: stop(); }\n",
29
+ "expectedLines": [
30
+ 3
31
+ ]
32
+ }
33
+ ],
34
+ "allow": [
35
+ {
36
+ "name": "exhaustive cases",
37
+ "fileName": "exhaustive.ts",
38
+ "source": "export const dispatch = (kind: \"opened\" | \"closed\"): number => {\n switch (kind) {\n case \"opened\": return 1;\n case \"closed\": return 0;\n }\n};\n",
39
+ "expectedLines": []
40
+ },
41
+ {
42
+ "name": "default key outside a switch",
43
+ "fileName": "object.ts",
44
+ "source": "export const config = { default: \"literal\" };\n",
45
+ "expectedLines": []
46
+ },
47
+ {
48
+ "name": "default in a comment line",
49
+ "fileName": "commented.ts",
50
+ "source": "// switch (kind) { default: stop(); }\nexport const value = 1;\n",
51
+ "expectedLines": []
52
+ }
53
+ ]
54
+ }
55
+ }
56
+ ]
57
+ }
@@ -0,0 +1,19 @@
1
+ # CD-9: All operational failures return Result<T, E>
2
+
3
+ ## Rule
4
+
5
+ Every expected, operational failure is modelled as data — a result-shaped return carrying a tagged error union that enumerates each way the operation can fail — not raised as an exception. Infrastructure failure is an operational outcome, not an escape into throwing. Callers dispatch on the error as a value, so no failure path is invisible in the type.
6
+
7
+ The sections below describe how the rule is checked.
8
+
9
+ ## Clauses
10
+
11
+ | Clause | Mechanism | Checks |
12
+ | --- | --- | --- |
13
+ | `CD-9#result-failures` | review | expected operational failures are returned as a Result with a tagged error union, not thrown |
14
+
15
+ Review lens: [errors-as-data](../../methods/lenses/errors-as-data.md). The lens reviews the whole rule, including what no check flags.
16
+
17
+ ## How it is checked
18
+
19
+ Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies the rule above with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
@@ -0,0 +1,12 @@
1
+ {
2
+ "version": 1,
3
+ "id": "CD-9",
4
+ "clauses": [
5
+ {
6
+ "kind": "judgement",
7
+ "id": "result-failures",
8
+ "summary": "expected operational failures are returned as a Result with a tagged error union, not thrown",
9
+ "enforcedBy": "review"
10
+ }
11
+ ]
12
+ }
@@ -0,0 +1,52 @@
1
+ # Disciplines
2
+
3
+ Adopters select clauses in `disciplines.json`. Selecting one clause adopts its discipline, so every mechanical clause of an adopted discipline must be selected, each through a mechanism its page lists; the check reports the rest as uncovered. Clauses marked (review) are judgement clauses: they cannot be selected and are applied in review with the discipline's review lens, as [ADOPTING.md](../ADOPTING.md#9-apply-the-judgement-rules) describes.
4
+
5
+ | ID | Title | Clauses | Files checked | Review lens |
6
+ | --- | --- | --- | --- | --- |
7
+ | [CD-1](CD-1/README.md) | No any, ever | `CD-1#any-cast`, `CD-1#explicit-any`, `CD-1#implicit-any-let` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
8
+ | [CD-2](CD-2/README.md) | Closed enumerated list of permitted cast sites | `CD-2#cast-expressions` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
9
+ | [CD-3](CD-3/README.md) | Strict mode flags inherited, never overridden | `CD-3#strict`, `#no-unchecked-indexed-access`, `#exact-optional-property-types`, `#no-implicit-override`, `#no-fallthrough-cases-in-switch`, `#no-property-access-from-index-signature`, `#use-unknown-in-catch-variables` | `tsconfig.json` | [type-soundness](../methods/lenses/type-soundness.md) |
10
+ | [CD-4](CD-4/README.md) | Zod at every external boundary | `CD-4#boundary-validation` (review) | — | [zod-boundary](../methods/lenses/zod-boundary.md) |
11
+ | [CD-5](CD-5/README.md) | No comments, no JSDoc | `CD-5#comments-directives` | `.ts`, `.tsx` | [naming](../methods/lenses/naming.md) |
12
+ | [CD-6](CD-6/README.md) | Meaningful names always — no shorthand, no filler words | `CD-6#identifier-names`, `CD-6#naming-convention` | `.ts`, `.tsx` | [naming](../methods/lenses/naming.md) |
13
+ | [CD-7](CD-7/README.md) | No categorical filenames or folder names | `CD-7#categorical-paths`, `CD-7#filename-case` | `.ts`, `.tsx` paths | [naming](../methods/lenses/naming.md) |
14
+ | [CD-7a](CD-7a/README.md) | No ReturnType<typeof X> for our own codebase | `CD-7a#factory-return-types` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
15
+ | [CD-8](CD-8/README.md) | No default on switch over a closed discriminated union | `CD-8#switch-defaults` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
16
+ | [CD-9](CD-9/README.md) | All operational failures return Result<T, E> | `CD-9#result-failures` (review) | — | [errors-as-data](../methods/lenses/errors-as-data.md) |
17
+ | [CD-10](CD-10/README.md) | Throws permitted in exactly two contexts | `CD-10#throws-in-tests`, `CD-10#throw-only-error` | `*.test.ts`, `*.test.tsx` | [errors-as-data](../methods/lenses/errors-as-data.md) |
18
+ | [CD-11](CD-11/README.md) | Operational error envelopes are plain data, not classes | `CD-11#error-envelopes` (review) | — | [errors-as-data](../methods/lenses/errors-as-data.md) |
19
+ | [CD-12](CD-12/README.md) | Repositories are the primary storage abstraction | `CD-12#repository-ports` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
20
+ | [CD-13](CD-13/README.md) | Kernel layer boundaries are non-negotiable | `CD-13#layer-boundaries` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
21
+ | [CD-14](CD-14/README.md) | Zero class authoring; classes only at external-library call sites | `CD-14#class-syntax`, `CD-14#static-only-class`, `CD-14#library-construction` (review) | TypeScript, not `.d.ts` | [function-first](../methods/lenses/function-first.md) |
22
+ | [CD-15](CD-15/README.md) | Iteration is functional transformation, never an imperative loop | `CD-15#loops` | `.ts`, `.tsx` | [function-first](../methods/lenses/function-first.md) |
23
+ | [CD-16](CD-16/README.md) | No counted for loops | see CD-15 | — | [function-first](../methods/lenses/function-first.md) |
24
+ | [CD-17](CD-17/README.md) | Clock is the only time source | `CD-17#clock-sources` | `.ts`, `.tsx` | [di-discipline](../methods/lenses/di-discipline.md), [test-discipline](../methods/lenses/test-discipline.md) |
25
+ | [CD-18](CD-18/README.md) | Process-lifecycle operations arrive through an injected port | `CD-18#process-lifecycle-ports` (review) | — | [di-discipline](../methods/lenses/di-discipline.md) |
26
+ | [CD-19](CD-19/README.md) | External dependencies confined to wrapping ports at the boundary | `CD-19#import-boundaries` | `.ts`, `.tsx` | [function-first](../methods/lenses/function-first.md) |
27
+ | [CD-20](CD-20/README.md) | Runtime stdlib imports arrive through injected ports | see CD-19 | — | [di-discipline](../methods/lenses/di-discipline.md) |
28
+ | [CD-21](CD-21/README.md) | Every injected port ships a default production factory | `CD-21#default-factories` (review) | — | [di-discipline](../methods/lenses/di-discipline.md) |
29
+ | [CD-22](CD-22/README.md) | Middleware generic context constraint | `CD-22#middleware-context` (review) | — | [di-discipline](../methods/lenses/di-discipline.md) |
30
+ | [CD-23](CD-23/README.md) | Every unit has a co-located test sibling | `CD-23#export-test-sibling` | production `.ts`, `.tsx` | [test-discipline](../methods/lenses/test-discipline.md) |
31
+ | [CD-24](CD-24/README.md) | Every file is unit-tested | see CD-23 | — | [test-discipline](../methods/lenses/test-discipline.md) |
32
+ | [CD-25](CD-25/README.md) | Unit tests fake everything outside the unit | `CD-25#dependency-isolation` | `*.test.ts`, `*.test.tsx` | [di-discipline](../methods/lenses/di-discipline.md), [test-discipline](../methods/lenses/test-discipline.md) |
33
+ | [CD-26](CD-26/README.md) | No module-mocking — module-mock means DI is wrong | `CD-26#module-mocking` | `*.test.ts`, `*.test.tsx` | [di-discipline](../methods/lenses/di-discipline.md), [test-discipline](../methods/lenses/test-discipline.md) |
34
+ | [CD-27](CD-27/README.md) | Tests are zero-everything — zero logic, zero branches, zero unpredictability | `CD-27#test-body-logic`, `CD-27#focused-tests`, `CD-27#skipped-tests` | `*.test.ts`, `*.test.tsx` | [test-discipline](../methods/lenses/test-discipline.md) |
35
+ | [CD-28](CD-28/README.md) | Tests assert only what the unit is directly responsible for | `CD-28#unit-responsibility` (review) | — | [test-discipline](../methods/lenses/test-discipline.md) |
36
+ | [CD-29](CD-29/README.md) | Component/integration tests are the minimum, not the bulk | `CD-29#test-pyramid` (review) | — | [test-discipline](../methods/lenses/test-discipline.md) |
37
+ | [CD-30](CD-30/README.md) | Integration tests catch composition bugs only | `CD-30#composition-only` (review) | — | [test-discipline](../methods/lenses/test-discipline.md) |
38
+ | [CD-31](CD-31/README.md) | No coverage thresholds | `CD-31#no-coverage-thresholds` (review) | — | [test-discipline](../methods/lenses/test-discipline.md) |
39
+ | [CD-32](CD-32/README.md) | PII strings redact-by-default in structured logs | `CD-32#pii-redaction` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
40
+ | [CD-33](CD-33/README.md) | Sensitive types brand-redact unconditionally | `CD-33#sensitive-brands` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
41
+ | [CD-34](CD-34/README.md) | Secrets never enter the repo | `CD-34#no-repo-secrets` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
42
+ | [CD-39](CD-39/README.md) | Cite principles by Roman numeral and rules by ID | `CD-39#cite-by-id` (review) | — | none |
43
+ | [CD-40](CD-40/README.md) | Single-object-argument functions | `CD-40#parameter-count`, `CD-40#named-object-argument` (review) | files the ESLint run includes | [function-first](../methods/lenses/function-first.md) |
44
+ | [CD-41](CD-41/README.md) | Orchestrators contain only orchestration | `CD-41#cognitive-complexity`, `CD-41#function-length`, `CD-41#orchestration-only` (review) | files the ESLint run includes | [decomposition](../methods/lenses/decomposition.md) |
45
+ | [CD-42](CD-42/README.md) | Unhappy paths are early returns; happy path is the final return | `CD-42#useless-else` | files the ESLint run includes | [decomposition](../methods/lenses/decomposition.md) |
46
+ | [CD-43](CD-43/README.md) | Booleans are evaluative, not declarative | `CD-43#boolean-signatures` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
47
+ | [CD-44](CD-44/README.md) | Functions must not mutate fields of parameters they receive | `CD-44#parameter-mutation`, `CD-44#parameter-reassignment` | `.ts`, `.tsx` | [decomposition](../methods/lenses/decomposition.md) |
48
+ | [CD-45](CD-45/README.md) | Zod runs exactly once per external-boundary crossing | `CD-45#parse-once` (review) | — | [zod-boundary](../methods/lenses/zod-boundary.md) |
49
+ | [CD-46](CD-46/README.md) | Touching a carved-out file revokes its carve-out — leave it clean | applied to every file carve-out | — | none |
50
+ | [CD-47](CD-47/README.md) | Tests are hermetic — no real side effects on anything real | `CD-47#hermetic-git-spawns` | `*.test.{ts,tsx,mjs,js}`, `*.spec.{ts,mjs}` | [test-discipline](../methods/lenses/test-discipline.md) |
51
+
52
+ Exceptions are recorded in `discipline-exceptions.json`; see [the package README](../README.md#discipline-exceptionsjson).