@hailstails/hone 1.4.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 (121) hide show
  1. package/ADOPTING.md +8 -8
  2. package/CHANGELOG.md +14 -0
  3. package/MIGRATING.md +17 -0
  4. package/README.md +10 -10
  5. package/api/testing.js +2 -2
  6. package/chunks/{chunk-FEWCJU7H.js → chunk-2O46EB4E.js} +6 -0
  7. package/chunks/{chunk-6SM3HKWO.js → chunk-5U4VTFD5.js} +88 -51
  8. package/core/check/tool-command.js +379 -56
  9. package/core/mechanism-port/runner-result-types.d.ts +4 -0
  10. package/docs/adding-a-discipline-or-mechanism.md +2 -0
  11. package/docs/extending.md +1 -0
  12. package/docs/output-contract.md +17 -6
  13. package/mechanisms/audit/CD-27/test-body-logic.js +5 -2
  14. package/mechanisms/audit/runner/runner.js +5 -3
  15. package/mechanisms/eslint/runner/runner.js +7 -3
  16. package/methods/assessment-template.md +2 -2
  17. package/methods/lenses/clean-architecture.md +7 -8
  18. package/methods/lenses/defended-on-intent.md +2 -2
  19. package/methods/lenses/di-discipline.md +10 -13
  20. package/methods/lenses/function-first.md +16 -18
  21. package/package.json +1 -1
  22. package/rules/CD-1/CHECKS.md +4 -2
  23. package/rules/CD-1/README.md +6 -19
  24. package/rules/CD-10/CHECKS.md +5 -3
  25. package/rules/CD-10/README.md +6 -18
  26. package/rules/CD-11/CHECKS.md +4 -2
  27. package/rules/CD-11/README.md +6 -16
  28. package/rules/CD-12/CHECKS.md +4 -2
  29. package/rules/CD-12/README.md +6 -16
  30. package/rules/CD-13/CHECKS.md +4 -2
  31. package/rules/CD-13/README.md +6 -16
  32. package/rules/CD-14/CHECKS.md +3 -1
  33. package/rules/CD-14/README.md +6 -19
  34. package/rules/CD-15/CHECKS.md +3 -1
  35. package/rules/CD-15/README.md +5 -20
  36. package/rules/CD-16/CHECKS.md +3 -1
  37. package/rules/CD-16/README.md +6 -6
  38. package/rules/CD-17/CHECKS.md +3 -1
  39. package/rules/CD-17/README.md +6 -19
  40. package/rules/CD-18/CHECKS.md +4 -2
  41. package/rules/CD-18/README.md +6 -16
  42. package/rules/CD-19/CHECKS.md +8 -6
  43. package/rules/CD-19/README.md +6 -20
  44. package/rules/CD-2/CHECKS.md +5 -3
  45. package/rules/CD-2/README.md +6 -21
  46. package/rules/CD-20/CHECKS.md +3 -1
  47. package/rules/CD-20/README.md +6 -6
  48. package/rules/CD-21/CHECKS.md +4 -2
  49. package/rules/CD-21/README.md +6 -15
  50. package/rules/CD-22/CHECKS.md +4 -2
  51. package/rules/CD-22/README.md +6 -15
  52. package/rules/CD-23/CHECKS.md +5 -3
  53. package/rules/CD-23/README.md +6 -17
  54. package/rules/CD-24/CHECKS.md +3 -1
  55. package/rules/CD-24/README.md +6 -6
  56. package/rules/CD-25/CHECKS.md +3 -1
  57. package/rules/CD-25/README.md +5 -21
  58. package/rules/CD-26/CHECKS.md +5 -3
  59. package/rules/CD-26/README.md +6 -20
  60. package/rules/CD-27/CHECKS.md +16 -7
  61. package/rules/CD-27/README.md +6 -20
  62. package/rules/CD-28/CHECKS.md +4 -2
  63. package/rules/CD-28/README.md +6 -16
  64. package/rules/CD-29/CHECKS.md +4 -2
  65. package/rules/CD-29/README.md +6 -14
  66. package/rules/CD-3/CHECKS.md +3 -1
  67. package/rules/CD-3/README.md +6 -17
  68. package/rules/CD-30/CHECKS.md +4 -2
  69. package/rules/CD-30/README.md +6 -15
  70. package/rules/CD-31/CHECKS.md +4 -2
  71. package/rules/CD-31/README.md +6 -14
  72. package/rules/CD-32/CHECKS.md +3 -1
  73. package/rules/CD-32/README.md +2 -0
  74. package/rules/CD-33/CHECKS.md +3 -1
  75. package/rules/CD-33/README.md +2 -0
  76. package/rules/CD-34/CHECKS.md +3 -1
  77. package/rules/CD-34/README.md +2 -0
  78. package/rules/CD-39/CHECKS.md +3 -1
  79. package/rules/CD-39/README.md +2 -0
  80. package/rules/CD-4/CHECKS.md +4 -2
  81. package/rules/CD-4/README.md +6 -17
  82. package/rules/CD-40/CHECKS.md +3 -1
  83. package/rules/CD-40/README.md +6 -20
  84. package/rules/CD-41/CHECKS.md +4 -2
  85. package/rules/CD-41/README.md +6 -22
  86. package/rules/CD-42/CHECKS.md +3 -1
  87. package/rules/CD-42/README.md +6 -16
  88. package/rules/CD-43/CHECKS.md +3 -1
  89. package/rules/CD-43/README.md +6 -18
  90. package/rules/CD-44/CHECKS.md +3 -1
  91. package/rules/CD-44/README.md +6 -17
  92. package/rules/CD-45/CHECKS.md +4 -2
  93. package/rules/CD-45/README.md +6 -16
  94. package/rules/CD-46/CHECKS.md +3 -1
  95. package/rules/CD-46/README.md +2 -0
  96. package/rules/CD-47/CHECKS.md +4 -2
  97. package/rules/CD-47/README.md +4 -20
  98. package/rules/CD-5/CHECKS.md +4 -2
  99. package/rules/CD-5/README.md +6 -19
  100. package/rules/CD-6/CHECKS.md +3 -1
  101. package/rules/CD-6/README.md +6 -19
  102. package/rules/CD-7/CHECKS.md +3 -1
  103. package/rules/CD-7/README.md +6 -20
  104. package/rules/CD-7a/CHECKS.md +3 -1
  105. package/rules/CD-7a/README.md +6 -17
  106. package/rules/CD-8/CHECKS.md +3 -1
  107. package/rules/CD-8/README.md +6 -17
  108. package/rules/CD-9/CHECKS.md +4 -2
  109. package/rules/CD-9/README.md +6 -17
  110. package/rules/README.md +71 -54
  111. package/rules/SPIRIT.md +3 -3
  112. package/rules/cases.md +94 -0
  113. package/rules/numbers.md +155 -0
  114. package/rules/principles.md +89 -0
  115. package/rules/records.md +150 -0
  116. package/rules/rules.md +149 -0
  117. package/rules/sources.md +142 -0
  118. package/rules/typescript/checks.md +219 -0
  119. package/rules/typescript/recipes.md +361 -0
  120. package/rules/typescript/symptoms.json +1005 -0
  121. package/rules/typescript/symptoms.md +612 -0
@@ -0,0 +1,155 @@
1
+ # Every CD
2
+
3
+ Rules, principles, cases, recipes and symptoms are named, not numbered. This is the one page that gives the old numbers: each CD, its verdict, and where it went. Selections, records and findings still use the numbered clause addresses.
4
+
5
+ | Verdict | Meaning |
6
+ |---|---|
7
+ | Keeps | A rule under one principle. |
8
+ | Merges | Same reason to change as another rule. |
9
+ | Splits | The discipline's content went to more than one rule. |
10
+ | Recipe | A method for another rule. |
11
+ | Cases | A list of cases of an existing rule or principle. |
12
+ | Symptom or Check | Something seen in code, or how it is found. |
13
+ | Outside | Outside the cases. |
14
+
15
+ | CD | Verdict | Where |
16
+ |---|---|---|
17
+ | [CD-1](CD-1/README.md) | Symptom | of [Declared, not asserted](rules.md#declared-not-asserted) |
18
+ | [CD-2](CD-2/README.md) | Keeps | [Declared, not asserted](rules.md#declared-not-asserted) |
19
+ | [CD-3](CD-3/README.md) | Cases | strictest checker setting |
20
+ | [CD-4](CD-4/README.md) | Recipe | for the No leak case: [Zod at the producer's adapter](typescript/recipes.md#zod-at-the-producers-adapter) |
21
+ | [CD-5](CD-5/README.md) | Splits | One word everywhere; Declared, not asserted; records |
22
+ | [CD-6](CD-6/README.md) | Keeps | [One word everywhere](rules.md#one-word-everywhere); casing a check |
23
+ | [CD-7](CD-7/README.md) | Splits | One reason per module; One word everywhere; filename case a check |
24
+ | [CD-7a](CD-7a/README.md) | Symptom | of [Outside dependencies stay at boundaries](rules.md#outside-dependencies-stay-at-boundaries) |
25
+ | [CD-8](CD-8/README.md) | Symptom | of [Kinds are named](rules.md#kinds-are-named) |
26
+ | [CD-9](CD-9/README.md) | Keeps | [Failures are values](rules.md#failures-are-values) |
27
+ | [CD-10](CD-10/README.md) | Splits | Failures are values; Straight-through tests; throw-only-error a check |
28
+ | [CD-11](CD-11/README.md) | Recipe | for [Failures are values](rules.md#failures-are-values) |
29
+ | [CD-12](CD-12/README.md) | Recipe | for [Ports declared inside](rules.md#ports-declared-inside) |
30
+ | [CD-13](CD-13/README.md) | Keeps | [Ports declared inside](rules.md#ports-declared-inside) |
31
+ | [CD-14](CD-14/README.md) | Splits | no-class recipe; Outside dependencies stay at boundaries; state a case |
32
+ | [CD-15](CD-15/README.md) | Cases | of [No hidden effects](principles.md#no-hidden-effects) |
33
+ | [CD-16](CD-16/README.md) | Merges | with CD-15 |
34
+ | [CD-17](CD-17/README.md) | Cases | under Handed what it uses and One reason per module |
35
+ | [CD-18](CD-18/README.md) | Cases | under [Ports declared inside](rules.md#ports-declared-inside) |
36
+ | [CD-19](CD-19/README.md) | Splits | Outside dependencies stay at boundaries; Ports declared inside; construction and ids cases |
37
+ | [CD-20](CD-20/README.md) | Merges | with CD-19 |
38
+ | [CD-21](CD-21/README.md) | Cases | built at the entry point |
39
+ | [CD-22](CD-22/README.md) | Recipe | for [Declared, not asserted](rules.md#declared-not-asserted) |
40
+ | [CD-23](CD-23/README.md) | Keeps | [Tested where it's owned](rules.md#tested-where-its-owned) |
41
+ | [CD-24](CD-24/README.md) | Merges | with CD-23 |
42
+ | [CD-25](CD-25/README.md) | Keeps | [Written-out answers](rules.md#written-out-answers) |
43
+ | [CD-26](CD-26/README.md) | Symptom | of Written-out answers, Ports declared inside |
44
+ | [CD-27](CD-27/README.md) | Splits | Straight-through tests; Tested where it's owned |
45
+ | [CD-28](CD-28/README.md) | Merges | into [Written-out answers](rules.md#written-out-answers) |
46
+ | [CD-29](CD-29/README.md) | Merges | into [Tested where it's owned](rules.md#tested-where-its-owned) |
47
+ | [CD-30](CD-30/README.md) | Merges | into [Tested where it's owned](rules.md#tested-where-its-owned) |
48
+ | [CD-31](CD-31/README.md) | Check | of [Tested where it's owned](rules.md#tested-where-its-owned) |
49
+ | [CD-32](CD-32/README.md) | Outside | safety |
50
+ | [CD-33](CD-33/README.md) | Outside | safety |
51
+ | [CD-34](CD-34/README.md) | Outside | safety |
52
+ | [CD-39](CD-39/README.md) | Outside | records |
53
+ | [CD-40](CD-40/README.md) | Cases | of One word everywhere, Handed what it uses |
54
+ | [CD-41](CD-41/README.md) | Keeps | [Doer or orchestrator](rules.md#doer-or-orchestrator) |
55
+ | [CD-42](CD-42/README.md) | Keeps | [Guard first](rules.md#guard-first) |
56
+ | [CD-43](CD-43/README.md) | Keeps | [Kinds are named](rules.md#kinds-are-named) |
57
+ | [CD-44](CD-44/README.md) | Cases | of [No hidden effects](principles.md#no-hidden-effects) |
58
+ | [CD-45](CD-45/README.md) | Cases | of [No leak across a boundary](principles.md#no-leak-across-a-boundary) |
59
+ | [CD-46](CD-46/README.md) | Outside | records |
60
+ | [CD-47](CD-47/README.md) | Cases | under [Tested where it's owned](rules.md#tested-where-its-owned) |
61
+
62
+ ## Every mechanical clause
63
+
64
+ Each mechanical clause and the [symptom](typescript/symptoms.md) it sees.
65
+
66
+ | Clause | Symptom |
67
+ |---|---|
68
+ | CD-1 (3 clauses) | [Claimed type](typescript/symptoms.md#claimed-type); [Untyped value](typescript/symptoms.md#untyped-value) |
69
+ | CD-2 (2 clauses) | [Claimed type](typescript/symptoms.md#claimed-type) |
70
+ | CD-3 (7 clauses) | [Strictness weakened](typescript/symptoms.md#strictness-weakened) |
71
+ | CD-5 | [Untracked escape](typescript/symptoms.md#untracked-escape) |
72
+ | CD-6#identifier-names | [Shorthand name](typescript/symptoms.md#shorthand-name) |
73
+ | CD-6#naming-convention | [Name off its casing](typescript/symptoms.md#name-off-its-casing) |
74
+ | CD-7#categorical-paths | [Drawer path](typescript/symptoms.md#drawer-path) |
75
+ | CD-7#filename-case | [Name off its casing](typescript/symptoms.md#name-off-its-casing) |
76
+ | CD-7a | [Type derived from code](typescript/symptoms.md#type-derived-from-code) |
77
+ | CD-8 | [Default on a closed union](typescript/symptoms.md#default-on-a-closed-union) |
78
+ | CD-10#throws-in-tests | [Throw or catch in a test](typescript/symptoms.md#throw-or-catch-in-a-test) |
79
+ | CD-10#throw-only-error | [Thrown non-error](typescript/symptoms.md#thrown-non-error) |
80
+ | CD-14#class-syntax, CD-14#static-only-class | [Authored class or this](typescript/symptoms.md#authored-class-or-this) |
81
+ | CD-15 | [Loop keyword](typescript/symptoms.md#loop-keyword) |
82
+ | CD-17 | [Date used directly](typescript/symptoms.md#date-used-directly) |
83
+ | CD-19 | [Outside import past a boundary](typescript/symptoms.md#outside-import-past-a-boundary) |
84
+ | CD-23 | [Unit without a running test](typescript/symptoms.md#unit-without-a-running-test) |
85
+ | CD-25 | [Double with a body](typescript/symptoms.md#double-with-a-body) |
86
+ | CD-26 | [Module or global patched](typescript/symptoms.md#module-or-global-patched) |
87
+ | CD-27#test-body-logic | [Branch in a test](typescript/symptoms.md#branch-in-a-test); [Computed value in a test](typescript/symptoms.md#computed-value-in-a-test); [Rebinding](typescript/symptoms.md#rebinding); [Text past its reader](typescript/symptoms.md#text-past-its-reader) |
88
+ | CD-27#focused-tests, CD-27#skipped-tests | [Test switched off](typescript/symptoms.md#test-switched-off) |
89
+ | CD-40#parameter-count | [Positional parameters](typescript/symptoms.md#positional-parameters) |
90
+ | CD-41#cognitive-complexity | [Tangled function](typescript/symptoms.md#tangled-function) |
91
+ | CD-41#function-length | [Long function](typescript/symptoms.md#long-function) |
92
+ | CD-42 | [Work inside a condition](typescript/symptoms.md#work-inside-a-condition) |
93
+ | CD-43 | [Boolean in a signature](typescript/symptoms.md#boolean-in-a-signature) |
94
+ | CD-44#parameter-mutation | [Write into a parameter](typescript/symptoms.md#write-into-a-parameter) |
95
+ | CD-44#parameter-reassignment | [Rebinding](typescript/symptoms.md#rebinding) |
96
+ | CD-47 | [Inherited environment in a subprocess](typescript/symptoms.md#inherited-environment-in-a-subprocess) |
97
+
98
+ The test-logic check, CD-27#test-body-logic, also sees the `let` form of [Answer set in a hook](typescript/symptoms.md#answer-set-in-a-hook), and `try`, a form of [Throw or catch in a test](typescript/symptoms.md#throw-or-catch-in-a-test).
99
+
100
+ Review clauses that demand a method (CD-4, CD-9, CD-11, CD-12, CD-21 and CD-22) map to their [recipes](typescript/recipes.md). The outcome each protects is seen by Schema past its adapter, Throw between our units, Failure shaped as success, Port outside the domain, Adapter built outside the root and Default for a required value.
101
+
102
+ Sensitive data and citation clauses (CD-32, CD-33, CD-34 and CD-39) have no symptom: they are outside the cases.
103
+
104
+ ## Every numbered discipline
105
+
106
+ Each numbered discipline as its folder holds it today: its title, its clause addresses, the files its checks read, and its review lens.
107
+
108
+ 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 CHECKS.md lists, or listed as `"not-adopted"`; 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.
109
+
110
+ | ID | Title | Clauses | Files checked | Review lens |
111
+ | --- | --- | --- | --- | --- |
112
+ | [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) |
113
+ | [CD-2](CD-2/README.md) | Closed enumerated list of permitted cast sites | `CD-2#cast-expressions`, `CD-2#non-null-assertions` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
114
+ | [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) |
115
+ | [CD-4](CD-4/README.md) | Zod at every external boundary | `CD-4#boundary-validation` (review) | — | [zod-boundary](../methods/lenses/zod-boundary.md) |
116
+ | [CD-5](CD-5/README.md) | No comments, no JSDoc | `CD-5#comments-directives` | `.ts`, `.tsx` | [naming](../methods/lenses/naming.md) |
117
+ | [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) |
118
+ | [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) |
119
+ | [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) |
120
+ | [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) |
121
+ | [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) |
122
+ | [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) |
123
+ | [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) |
124
+ | [CD-12](CD-12/README.md) | Repositories are the primary storage abstraction | `CD-12#repository-ports` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
125
+ | [CD-13](CD-13/README.md) | Kernel layer boundaries are non-negotiable | `CD-13#layer-boundaries` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
126
+ | [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) |
127
+ | [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) |
128
+ | [CD-16](CD-16/README.md) | No counted for loops | see CD-15 | — | [function-first](../methods/lenses/function-first.md) |
129
+ | [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) |
130
+ | [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) |
131
+ | [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) |
132
+ | [CD-20](CD-20/README.md) | Runtime stdlib imports arrive through injected ports | see CD-19 | — | [di-discipline](../methods/lenses/di-discipline.md) |
133
+ | [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) |
134
+ | [CD-22](CD-22/README.md) | Middleware generic context constraint | `CD-22#middleware-context` (review) | — | [di-discipline](../methods/lenses/di-discipline.md) |
135
+ | [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) |
136
+ | [CD-24](CD-24/README.md) | Every file is unit-tested | see CD-23 | — | [test-discipline](../methods/lenses/test-discipline.md) |
137
+ | [CD-25](CD-25/README.md) | Unit tests replace everything outside the unit with test doubles | `CD-25#dependency-isolation` | `*.test.ts`, `*.test.tsx` | [di-discipline](../methods/lenses/di-discipline.md), [test-discipline](../methods/lenses/test-discipline.md) |
138
+ | [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) |
139
+ | [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) |
140
+ | [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) |
141
+ | [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) |
142
+ | [CD-30](CD-30/README.md) | Integration tests catch composition bugs only | `CD-30#composition-only` (review) | — | [test-discipline](../methods/lenses/test-discipline.md) |
143
+ | [CD-31](CD-31/README.md) | No coverage thresholds | `CD-31#no-coverage-thresholds` (review) | — | [test-discipline](../methods/lenses/test-discipline.md) |
144
+ | [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) |
145
+ | [CD-33](CD-33/README.md) | Sensitive types brand-redact unconditionally | `CD-33#sensitive-brands` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
146
+ | [CD-34](CD-34/README.md) | Secrets never enter the repo | `CD-34#no-repo-secrets` (review) | — | [clean-architecture](../methods/lenses/clean-architecture.md) |
147
+ | [CD-39](CD-39/README.md) | Cite principles by Roman numeral and rules by ID | `CD-39#cite-by-id` (review) | — | none |
148
+ | [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) |
149
+ | [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) |
150
+ | [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) |
151
+ | [CD-43](CD-43/README.md) | Booleans are evaluative, not declarative | `CD-43#boolean-signatures` | `.ts`, `.tsx` | [type-soundness](../methods/lenses/type-soundness.md) |
152
+ | [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) |
153
+ | [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) |
154
+ | [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 |
155
+ | [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) |
@@ -0,0 +1,89 @@
1
+ # Principles
2
+
3
+ A principle is a why: what it protects and its reason to change. Each is stated in the same four lines: what must hold, what it protects, its reason to change, and where a breach sits.
4
+
5
+ The principles hold in combination, not one at a time. "The principles are not to hold my rulings on their own but in combination."
6
+
7
+ Principles name no language, tool or library. [Cases](cases.md) say what to do for each thing code is trying to do, and [rules](rules.md) say what must hold under each principle.
8
+
9
+ ## Tests are ours
10
+
11
+ - **Must hold:** A test fails only when what the code it tests returns or calls changes.
12
+ - **Protects:** Red means "this unit broke" and nothing else.
13
+ - **Reason to change:** The world around the unit changes: a clock, a machine, a collaborator.
14
+ - **Breach:** In the unit that reads the world itself (also a breach of External behaviour sits at a boundary), or whose port cannot take a plain stub (also a breach of One place decides). Shows in the test: computed expectations, stubs with logic, module mocks, waits.
15
+ - **Rules under it:** [Written-out answers](rules.md#written-out-answers), [Straight-through tests](rules.md#straight-through-tests), [Tested where it's owned](rules.md#tested-where-its-owned).
16
+ - **Source:** Freeman and Pryce teach that you mock only types you own; this principle keeps tests on what is ours.
17
+
18
+ ## One place decides
19
+
20
+ - **Must hold:** Each unit makes one decision, and each decision is made by one unit of ours.
21
+ - **Protects:** A change to one decision is one edit in one unit.
22
+ - **Reason to change:** A decision changes.
23
+ - **Breach:** In the unit holding a second decision, the second unit re-making one, or the library making one that is ours. Shows as long or nested functions, mode flags, a clock or id read inside a job that is not dating or numbering.
24
+ - **Rules under it:** [Doer or orchestrator](rules.md#doer-or-orchestrator), [Handed what it uses](rules.md#handed-what-it-uses), [Guard first](rules.md#guard-first), [One reason per module](rules.md#one-reason-per-module).
25
+ - **Source:** Parnas hides each decision that may change inside one module; Martin gathers what changes for the same reason.
26
+
27
+ ## No hidden effects
28
+
29
+ - **Must hold:** A unit changes nothing: it gives back the value it returns and calls ports passed in to it.
30
+ - **Protects:** Every effect is visible at the call site, and no unit works by holding state and changing it.
31
+ - **Reason to change:** What a call affects changes.
32
+ - **Breach:** In the function that writes to something it was not passed, changes its input, or changes a value of its own after making it. Shows as tests that patch a global to see an effect.
33
+ - **Rules under it:** none. The principle decides.
34
+ - **Source:** This is Bernhardt's functional core, imperative shell: decisions stay pure and effects stay in sight.
35
+
36
+ ## External behaviour sits at a boundary
37
+
38
+ - **Must hold:** Business logic calls only other business logic, ports passed in to it, and operations that depend on nothing but their arguments and change nothing.
39
+ - **Protects:** A change in a service, a runtime, a clock or a protocol never edits business logic.
40
+ - **Reason to change:** The thing we call changes its behaviour.
41
+ - **Breach:** In the business-logic file that makes the call. Shows as a vendor or adapter import in business logic, a module mock, or a result that differs per machine.
42
+ - **Rules under it:** [Outside dependencies stay at boundaries](rules.md#outside-dependencies-stay-at-boundaries), [Ports declared inside](rules.md#ports-declared-inside).
43
+ - **Source:** This is Cockburn's ports and adapters, and Martin's rule that dependencies point inwards.
44
+
45
+ ## No leak across a boundary
46
+
47
+ - **Must hold:** Data and failures cross a boundary only through an adapter that maps between their outside form and a type of our own.
48
+ - **Protects:** A sender's change of shape stops at the adapter.
49
+ - **Reason to change:** The shape of the data we receive changes.
50
+ - **Breach:** In the adapter that is missing or passes the outside form inward. Shows far inward: presence checks, re-parsing, casts.
51
+ - **Outside data:** anything read at a boundary, our own stored rows and files included.
52
+ - **Record:** an externally defined model adopted as the definitive thing. Evans's *Conformist*. It is a statement on a [boundary record](records.md#boundary-record).
53
+ - **Rules under it:** none. The principle decides.
54
+ - **Source:** This is Evans's anticorruption layer, applied to failures as well as data, in both directions.
55
+
56
+ ## The type checker proves it
57
+
58
+ - **Must hold:** Every fact the code relies on about a value is proven by the type checker.
59
+ - **Protects:** A wrong shape, an unhandled case or an unhandled failure fails the build, not production.
60
+ - **Reason to change:** A type gains a case or changes shape.
61
+ - **Breach:** At the declaration that admits too much. Shows at uses: casts.
62
+ - **Rules under it:** [Failures are values](rules.md#failures-are-values), [Declared, not asserted](rules.md#declared-not-asserted), [Kinds are named](rules.md#kinds-are-named).
63
+ - **Source:** Minsky makes illegal states unrepresentable; King parses once at the edge, so the types carry the proof.
64
+
65
+ ## Our code reads in the common language
66
+
67
+ - **Must hold:** The meaning of our code is carried only by language constructs engineers in the space already know and by the domain's own names.
68
+ - **Protects:** An engineer reads our code knowing two languages only: the programming language and the domain.
69
+ - **Reason to change:** Who reads the code changes.
70
+ - **Breach:** At the declaration or call that borrows a library's vocabulary or leaves meaning to prose. Shows as comments and utility-type outside dependencies.
71
+ - **Rules under it:** [One word everywhere](rules.md#one-word-everywhere).
72
+ - **Source:** This is Evans's ubiquitous language, held across the whole codebase rather than one context.
73
+
74
+ ## Outside risk is carried on purpose
75
+
76
+ - **Must hold:** No outside code or tool is used by us, or changes version, except by a recorded decision of ours.
77
+ - **Protects:** The upkeep we carry for other people's code (upgrades, vulnerabilities, drift) is upkeep we chose.
78
+ - **Reason to change:** The risk an outside party's code puts on our upkeep changes: a release, a vulnerability, a compromise, an abandoned project.
79
+ - **Breach:** In the manifest, the lock file, the pipeline or a vendored copy. Shows as an outside dependency with no record, a version that floats, a tool fetched at run time, a copy of upstream code that has drifted.
80
+ - **Differs from External behaviour sits at a boundary:** that principle keeps an outside change from editing business logic. This one decides whether the outside thing is here at all, and at which version.
81
+ - **Rules under it:** [Outside dependencies justified](rules.md#outside-dependencies-justified), [Fixed versions](rules.md#fixed-versions), [Tools live in the repo](rules.md#tools-live-in-the-repo), [Upstream stays untouched](rules.md#upstream-stays-untouched). Proposed, not accepted: [Shipped risk declared](rules.md#shipped-risk-declared).
82
+ - **Source:** This follows Twelve-Factor, OpenSSF and the SBOM: every dependency is declared, pinned and recorded.
83
+
84
+ ## Not principles
85
+
86
+ - **Failures as values.** A rule under The type checker proves it.
87
+ - **Sensitive data.** Its rules stand on their own with safety as their why.
88
+ - **Determinism.** The test half is in Tests are ours ("inputs the test writes out"). The other half is in One place decides (one unit dates, one numbers) and External behaviour sits at a boundary (a clock depends on more than its arguments).
89
+ - **Reasons to change.** The test that says what one decision is, not a principle.
@@ -0,0 +1,150 @@
1
+ # Records
2
+
3
+ A record is how a person, or the tool for legacy debt, answers a symptom at a place. "That's why checks have authorised locations and disables. They are imperfect and allow for the correct usage of each thing that is by default a symptom of not thinking it through." A record is more work than the fix.
4
+
5
+ Today's record formats are listed [beside the kinds](#todays-formats-and-the-kinds).
6
+
7
+ ## The kinds
8
+
9
+ Five kinds cover everything.
10
+
11
+ ### Authorised location
12
+
13
+ - **Answers:** A symptom whose correct use a case makes right at one place: Claimed type forced by an outside contract, Throw between our units at an adapter whose caller expects a throw, Loop keyword draining a stream, Shorthand name or Name off its casing fixed by an outside contract, Text past its reader at one test site, Edit inside vendored code.
14
+ - **Must state:** The symptom; the site; the case that makes it correct here and the rule or principle that case owes; a why-chain whose root, if it changed, would remove the need; an owner.
15
+ - **Scope:** One symptom at one site: a file, or a span within it.
16
+ - **Stale or paid when:** Stale when the symptom is no longer at the site. A vendored edit is also re-tested when the vendored version moves. A person removes it.
17
+ - **Industry name:** suppression with justification; a MISRA deviation permit. A suppression with a stated justification, as .NET and MISRA permits do.
18
+
19
+ ### Deviation
20
+
21
+ - **Answers:** A method other than a recipe, where the rule still holds: a fake in place of Stub with vi.fn, or any other recipe.
22
+ - **Must state:** The recipe by name; the reason it was chosen, as its recipe states it; why that reason does not hold at this site, with evidence; how the rule still holds.
23
+ - **Scope:** One recipe at one site.
24
+ - **Stale or paid when:** Stale when the symptom is gone. Review owes "the reason holds again".
25
+ - **Industry name:** a MISRA deviation record. Aviation's alternative means of compliance, held to a stricter proof.
26
+
27
+ ### Debt
28
+
29
+ - **Answers:** Any symptom at a site, a known breach not yet paid.
30
+ - **Must state:** The symptom and the site. Nothing more: "All debt is debt. Reason doesn't matter."
31
+ - **Scope:** One symptom in one file.
32
+ - **Stale or paid when:** Forfeited once the file is touched, so the change pays it. Stale when the symptom is gone. Removed by the tool when the file is gone.
33
+ - **Industry name:** a baseline with a ratchet. Record-debt is the baseline, and forfeit-on-touch is the ratchet. A lint baseline, as in ESLint bulk suppressions, that ratchets down.
34
+
35
+ ### Boundary record
36
+
37
+ - **Answers:** The symptoms a boundary makes correct inside an adapter: Date used directly, Ambient randomness, Process global used in place, Outside import past a boundary, Library class built in place, Outside type in a signature, Text past its reader in the producer's adapter. With a **Conformist** statement, also Schema past its adapter and Outside type in a signature beyond the adapter.
38
+ - **Must state:** The outside party, the port or ports it fulfils, and the module. For Conformist: the outside model adopted as ours, and why it is "a persisted concept that pushes into other boundaries as the definitive thing".
39
+ - **Scope:** One module: a file or a folder.
40
+ - **Stale or paid when:** Stale when the module no longer reaches that outside party. A person removes it.
41
+ - **Industry name:** an architecture decision record (Nygard). Evans's anticorruption layer, recorded.
42
+
43
+ ### Dependency record
44
+
45
+ - **Answers:** Outside dependencies justified, and Dependency without a record.
46
+ - **Must state:** The outside dependency; the native way weighed; why it fell short. For a peer dependency, the risk to whoever runs it.
47
+ - **Scope:** One direct outside dependency.
48
+ - **Stale or paid when:** Stale when the dependency is removed.
49
+ - **Industry name:** an architecture decision record (Nygard). An architecture decision record for each dependency.
50
+
51
+ ### Who may create each one without a person
52
+
53
+ Only the tool, and only debt, for findings the base revision already held ("record-debt", today). Every other kind is written by a person or an agent, and does the reasoning itself.
54
+
55
+ ### Merged into the kinds, or not a kind
56
+
57
+ - **Site-level record for one symptom:** merged. Every kind names a symptom, not a whole clause, so a record can say "this symptom, here".
58
+ - **Conformist:** merged into Boundary record. It is a decision about one outside party's model crossing a boundary.
59
+ - **Drift record:** merged into Authorised location, on the symptom Edit inside vendored code. Its case: "justified as additional drift as impossible to apply as an extension instead". It states when it should be dropped.
60
+ - **Inline suppression:** not a kind. It is where a record shows at the site. An inline disable or a tool directive is held only by a record of its symptom at that site.
61
+ - **Tracked pointer:** not a record. It is an allowed annotation.
62
+ - **Safety opt-in:** outside the cases. It is not in this model.
63
+ - **Clause-wide carve-out:** not a record. A rule a codebase does not want everywhere is not adopted: "Yes opting out means this codebase is not beholden to the rule flat out. Which is any tech leads choice to make for a codebase."
64
+
65
+ ## What is not a record
66
+
67
+ - **Scope.** "Exclude is any codebases choice to say this is not in scope. It's never bound by any rules."
68
+ - **Adopter config:** layer folders, casing, test-file naming and folder-scoped conventions. Hone does not read these as config yet. "A simple manifest of top level folders is config. Not hand kept manifest." A folder setting never switches a rule off.
69
+ - **A threshold.** "Line and complexity are symptoms that flag many things." Where a symptom fires is a check setting.
70
+ - **A named ban.** "Lodash is banned. Personal rule." No record makes it correct. Existing use is still held as debt, like any symptom: "All rules have to allow the checks to be debt. As existing repos need the opportunity to adopt and improve. Debt is debt. Not blockers."
71
+ - **A tracked pointer.** A TODO is tracked when it holds a reference to an issue or spec, in the form the adopter's config declares for its tracker (`#42`, `owner/repo#42`, `PROJ-7`), and nothing else. It is a pointer, not an explanation. A TODO beside a breach does not hold the breach: the breach still needs a record of its own.
72
+
73
+ ## What is refused
74
+
75
+ A record must contain what its kind states. Anything less is refused, as follows.
76
+
77
+ | Refused | Why | Does Hone refuse it from the form today? |
78
+ |---|---|---|
79
+ | A why that only restates the symptom ("needed here", "the check flags this") | the why-chain's purpose: "to ensure an agent has thought deeply about what its doing" | Partly, as today: the why-chain checks refuse stock restatements and answers with no new cause. A reworded restatement is left to review. |
80
+ | A thought-through record that names no case, or a case not in the [case list](cases.md) | a thought-through use names its case | Not yet enforced. In the model a machine refuses a missing or unknown case name; whether the case is true is left to review. |
81
+ | An authorised location on a symptom that no case makes correct, such as a branch in a test | "who the heck added an authorised location for an if in a test?" | No. In spirit it is not allowed, and a reviewer refuses it. The form accepts it for any symptom, because a check is never assumed perfect: "while authorised location in spirit isn't supposed to be allowed. It's mechanically always allowed as our checks for symptoms is never assumed perfect." |
82
+ | A deviation that only shows another method works | "The proof of burden is on the deviation to show that the reason it was chosen no longer holds." | Not yet enforced. In the model the form must name the recipe and use its reason's words; whether the reason fails here is left to review. |
83
+ | A fake with no showing that a stub cannot do the test | "Moving a fake is only allowed if the test cannot be done with deterministic stubs or hardcoded things." | No; review. |
84
+ | A deviation or a dependency record that makes a named ban correct. Debt is not refused; nor, by the form, is an authorised location, which answers a check that is wrong at that place. | "Lodash is banned." and "Debt is debt. Not blockers." | Not yet enforced. |
85
+ | Debt written by the tool for a file the base did not hold | today's `new-file` | Yes, as today. |
86
+ | A record standing in for a design fix, where friction points at the design | "if we have such a complex test that needs exemption we have a code architecture problem" | No; review. A machine can show records clustering on one symptom or one cause. Only review rules on it. |
87
+ | An option that weakens the whole run (`--rule`, `-c`) | today | Yes, as today: it cannot be recorded. |
88
+
89
+ This is a list of what each record must contain. It is not a ladder of exceptions.
90
+
91
+ ## The cost side
92
+
93
+ **What holds today:**
94
+ - An authorised location costs a five-step why-chain with a root check and an owner.
95
+ - Debt is visible in every report, fails the run when it forfeits on touch, and fails when stale.
96
+ - An unrecorded inline disable fails the run.
97
+ - The diff of the records is the review.
98
+ - Hotfixes do not block on debt: forfeiture can be assessed elsewhere ("blocking a hot fix on debt is not suitable practice").
99
+
100
+ **What the model adds:**
101
+ - A thought-through record names its case and the rule owed. It no longer answers only "why this file".
102
+ - A deviation must engage the recipe's own reason.
103
+ - Records are per symptom, so a record cannot quietly hold a new form of a clause, and paying one symptom is visible.
104
+ - Records are counted per symptom and cause. That makes friction measurable ("Always look for what friction is trying to tell us"), without a new step.
105
+
106
+ **What an agent gets when it cannot fix:** two honest exits, debt (visible, and it forfeits) or a thought-through record (it costs the reasoning). Neither is "give up and ask": "telling agents to give up and ask me has in experience made them just never even try and increased my workload".
107
+
108
+ ## Which kind answers which symptom
109
+
110
+ | Symptom | Kind |
111
+ |---|---|
112
+ | Date used directly (clock adapter) | Boundary record |
113
+ | Ambient randomness | Boundary record |
114
+ | Process global used in place | Boundary record |
115
+ | Outside import past a boundary | Boundary record |
116
+ | Library class built in place | Boundary record |
117
+ | Text past its reader, in the producer's adapter | Boundary record |
118
+ | Text past its reader, at one test site | Authorised location |
119
+ | Schema past its adapter (outside model adopted as ours) | Boundary record, with a Conformist statement |
120
+ | Claimed type forced by an outside contract | Authorised location |
121
+ | Untyped value | Debt |
122
+ | Throw between our units | Authorised location ("Throwing in specific places allowed is just authorised locations as prose.") |
123
+ | Loop keyword, draining a stream | Authorised location |
124
+ | Double with a body (a fake) | Deviation from Stub with vi.fn |
125
+ | Unit without a running test | Debt |
126
+ | Shorthand name, Name off its casing (outside contract) | Authorised location |
127
+ | Edit inside vendored code | Authorised location (drift) |
128
+
129
+ | Method | Kind |
130
+ |---|---|
131
+ | A fake | Deviation from Stub with vi.fn |
132
+ | A hermetic setup in an integration test | Not a record: it is the recipe |
133
+ | A real file, subprocess or temp directory in a unit test | Debt. It breaks Tested where it's owned, which is a rule, not a recipe. |
134
+ | A stream drain | Authorised location |
135
+ | A throw at the edge | Authorised location |
136
+ | Any other method in place of a recipe | Deviation |
137
+
138
+ ## Today's formats and the kinds
139
+
140
+ Records today are written in these formats. Each answers one of the kinds.
141
+
142
+ | Today | Kind | What differs from the kind |
143
+ |---|---|---|
144
+ | `authorised-location` (clause, file, reason, whyChain) | Authorised location, or Boundary record for sites of Outside import past a boundary | Names a clause, not a symptom. The site is a file. It does not name the case and the rule owed. |
145
+ | `file-carve-out` (clause, file, optional reason) | Debt | Names a clause, not a symptom. One record on the test-logic clause covers up to four symptoms. |
146
+ | `clause-wide-carve-out` | Not a record: the clause is not adopted | It sits in the records, not the selection. |
147
+ | `provenance` (imported) | The same kind, imported | Nothing. |
148
+ | Legacy why-chains | The kind of the record that holds them | Accepted while unchanged against the base. |
149
+ | Inline disables and `@ts-*` directives | Held by a record of their symptom | The record names the clause, not the symptom. |
150
+ | — | Deviation, Dependency record | No format yet. |
package/rules/rules.md ADDED
@@ -0,0 +1,149 @@
1
+ # Rules
2
+
3
+ A rule states what must hold. It carries no exceptions. A rule's id is its name, hyphenated.
4
+
5
+ Each rule passes two tests: it names no language feature, and the other rules together do not already give it. Where a rule only restated its principle, it was dropped and the principle decides. The room for a correct exception is a [record](records.md), never softness in the text.
6
+
7
+ ## Tests are ours
8
+
9
+ ### Written-out answers
10
+
11
+ - **What must hold:** Every collaborator whose result the code under test uses is passed in; the test writes out each result it gives back, and checks what the code returns and every call it makes.
12
+ - **Cases served:** Uses what a collaborator gives back; Causes an effect.
13
+ - **Source:** Meszaros calls this Literal Value: the test states its inputs and answers in place.
14
+
15
+ ### Straight-through tests
16
+
17
+ - **What must hold:** A test runs straight through: each case is distinct and complete, its input and expected output are written out in it as typed values, nothing in the test builds or picks them, nothing in it branches or catches, and no code of ours runs but the code under test.
18
+ - **Cases served:** States what the unit gives back; Checks a value that may be one of several outcomes.
19
+ - **Source:** Meszaros names branching in a test Conditional Test Logic; this rule removes it.
20
+
21
+ ### Tested where it's owned
22
+
23
+ - **What must hold:** Every unit has a running test of its own in the file beside it, and no coverage figure stands in for it. Each behaviour is tested only at the level that owns it: a unit's logic in its own test, a binding to the outside in an integration test.
24
+ - **Cases served:** Gives each unit its test; Tests across units or against a real system.
25
+ - **Source:** This is Fowler's narrow integration test; Freeman and Pryce warn against mocks at boundary objects.
26
+
27
+ Both halves answer one reason to change, which test owns a behaviour, so it stays one rule written as two sentences. A test that inherits nothing from the machine is the principle's own must-hold, so it is a case, not a rule.
28
+
29
+ ## One place decides
30
+
31
+ ### Doer or orchestrator
32
+
33
+ - **What must hold:** An orchestrator only calls our own units, on one value or on each of several, and passes each result on, a failed one returned unchanged. A doer calls, or hands to anything that calls, no unit of ours but an adapter, reached through a port passed in.
34
+ - **Cases served:** Coordinates other units; Does one job.
35
+ - **Source:** This is Westphal's Integration Operation Segregation Principle.
36
+
37
+ ### Handed what it uses
38
+
39
+ - **What must hold:** A unit is handed only what it uses: a port holds only the methods its one consumer calls; a doer takes only the fields it reads, or the entity whose module it is in; an orchestrator may pass an entity whole.
40
+ - **Cases served:** Does one job; Gives a value its type.
41
+ - **Source:** This is dependency injection, as Fowler describes it, serving Martin's DIP.
42
+
43
+ ### Guard first
44
+
45
+ - **What must hold:** Conditions sit at one level, never one inside another, and each condition that ends the work returns at once, before the work.
46
+ - **Cases served:** Checks conditions before its work.
47
+ - **Source:** Fowler's guard-clause refactoring, made the required shape.
48
+
49
+ ### One reason per module
50
+
51
+ - **What must hold:** A module holds exactly the code that changes for one reason.
52
+ - **Cases served:** Puts code in a file or folder; Reuses behaviour from another unit or type.
53
+ - **Source:** This is Martin's Single Responsibility Principle: one reason to change.
54
+
55
+ Building every real implementation in one place at start-up is a case: Doer or orchestrator plus Ports declared inside give it. DRY is held here: "dry is true but it must be held with reasons to change not "same functional code right now"".
56
+
57
+ ## No hidden effects
58
+
59
+ No rule. The principle decides. State that changes between calls lives only in an adapter: No hidden effects plus External behaviour sits at a boundary give it, so it is a case.
60
+
61
+ ## External behaviour sits at a boundary
62
+
63
+ Outside dependency: what was called a package. An internal package is our own code, under One reason per module and the layering.
64
+
65
+ ### Outside dependencies stay at boundaries
66
+
67
+ - **What must hold:** Production code uses an outside dependency only inside a recorded boundary, and no type from an outside dependency or a runtime library appears in business logic.
68
+ - **Cases served:** Uses a system or service outside the program; Takes an outside dependency.
69
+ - **Source:** Freeman and Pryce wrap outside types thinly; this rule does so for every outside dependency.
70
+
71
+ ### Ports declared inside
72
+
73
+ - **What must hold:** Business logic declares every port it is handed and names it for the capability it needs, never for the mechanism behind it.
74
+ - **Cases served:** Uses a system or service outside the program; Causes an effect.
75
+ - **Source:** Martin's DIP: the abstraction belongs to the side that uses it.
76
+
77
+ The clock, random values, new ids and outside ordering are a case: the principle plus Ports declared inside give it. An outside dependency is not wrapped: it is used inside the boundary that needs it.
78
+
79
+ ## No leak across a boundary
80
+
81
+ No rule. The principle, now covering data and failures, plus One reason per module, gives one adapter per outside party that maps both ways. That is a case.
82
+
83
+ ## The type checker proves it
84
+
85
+ ### Failures are values
86
+
87
+ - **What must hold:** Between units of ours, every way an operation can fail is a named variant in its return type, and no failure is returned as a success, a default or an empty value.
88
+ - **Cases served:** An operation can fail.
89
+ - **Source:** Wlaschin's expected failures as values; Clean Code teaches exceptions instead.
90
+
91
+ ### Declared, not asserted
92
+
93
+ - **What must hold:** A value's type comes only from a declaration of our own, never derived from an implementation, or from a parse at a boundary; no code of ours claims a type the checker does not verify.
94
+ - **Cases served:** Gives a value its type.
95
+ - **Source:** King's parse, don't validate.
96
+
97
+ ### Kinds are named
98
+
99
+ - **What must hold:** A value of several kinds or states is a closed set of named kinds of our own, and wherever code chooses by kind, the checker proves every kind is chosen.
100
+ - **Cases served:** A value is one of several kinds or states.
101
+ - **Source:** Minsky's named variants.
102
+
103
+ "Of ours" matters in Declared, not asserted: a test framework's assertion that narrows a value is not a claim of ours. The strictest checker setting is a case; the principle gives it.
104
+
105
+ ## Our code reads in the common language
106
+
107
+ ### One word everywhere
108
+
109
+ - **What must hold:** Every value, unit, field and module is named with the domain's one word for what it is, spelt the same everywhere and at every scope; no meaning rests on position, and our code carries no prose, not even prose that repeats the code.
110
+ - **Cases served:** Names something; Explains something in prose.
111
+ - **Source:** Evans's ubiquitous language, across the whole codebase.
112
+
113
+ One word everywhere keeps "no meaning rests on position". A unit whose signature is ours takes one argument; a callback shaped by an outside API takes what that API passes.
114
+
115
+ Casing is a check under this rule. Writing basic logic in the language's own constructs is a case; the principle gives it.
116
+
117
+ ## Outside risk is carried on purpose
118
+
119
+ ### Outside dependencies justified
120
+
121
+ - **What must hold:** Every direct dependency, tools included, has a record that names the native way it was weighed against and why that way was not enough.
122
+ - **Cases served:** Takes an outside dependency.
123
+ - **Source:** Ours: a written reason for every outside dependency.
124
+
125
+ ### Fixed versions
126
+
127
+ - **What must hold:** Every version we run is fixed exactly in the repository, by a pin or a lock file.
128
+ - **Cases served:** Takes an outside dependency.
129
+ - **Source:** OpenSSF Scorecard pins dependencies against supply-chain compromise.
130
+
131
+ ### Tools live in the repo
132
+
133
+ - **What must hold:** Every tool we run is a dependency of the repository; none is fetched when it runs.
134
+ - **Cases served:** Takes an outside dependency.
135
+ - **Source:** Twelve-Factor: no reliance on system-wide tools.
136
+
137
+ ### Upstream stays untouched
138
+
139
+ - **What must hold:** Vendored outside code is never edited; our change sits in an extension of ours outside it.
140
+ - **Cases served:** Takes an outside dependency.
141
+ - **Source:** Martin's Open-Closed Principle, applied to code we do not own.
142
+
143
+ ### Shipped risk declared
144
+
145
+ Proposed, not accepted.
146
+
147
+ - **Proposed wording:** "Every outside dependency we ship is declared to whoever runs it, never hidden inside our build."
148
+ - **Case it would serve:** [Ships code for others](cases.md#proposed-cases) (proposed): what we ship is visible to an adopter's scanner.
149
+ - **Source:** The NTIA SBOM: a formal record of what we ship.