@hailstails/hone 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/ADOPTING.md +8 -8
  2. package/CHANGELOG.md +36 -0
  3. package/MIGRATING.md +40 -0
  4. package/README.md +28 -7
  5. package/api/audit.d.ts +1 -1
  6. package/api/testing.js +3 -3
  7. package/chunks/{chunk-H4V72FCW.js → chunk-2O46EB4E.js} +15 -1
  8. package/chunks/chunk-335ITLPO.js +7 -0
  9. package/chunks/{chunk-YSN46EB3.js → chunk-5U4VTFD5.js} +347 -664
  10. package/chunks/{chunk-PL2PNPAR.js → chunk-E6VR3VRV.js} +1 -6
  11. package/chunks/chunk-WF3PPYRR.js +27 -0
  12. package/core/check/tool-command.js +1120 -105
  13. package/core/mechanism-port/runner-result-types.d.ts +10 -0
  14. package/docs/adding-a-discipline-or-mechanism.md +5 -3
  15. package/docs/extending.md +2 -0
  16. package/docs/output-contract.md +64 -11
  17. package/mechanisms/audit/CD-27/test-body-logic.js +397 -46
  18. package/mechanisms/audit/runner/runner.js +5 -3
  19. package/mechanisms/audit/runner/typescript-parse.d.ts +2 -0
  20. package/mechanisms/audit/runner/walker-piece.d.ts +2 -1
  21. package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +7 -4
  22. package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +21 -11
  23. package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +15 -5
  24. package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +7 -3
  25. package/mechanisms/eslint/CD-41/README.md +1 -1
  26. package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +100 -28
  27. package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +8 -4
  28. package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +8 -4
  29. package/mechanisms/eslint/runner/README.md +9 -2
  30. package/mechanisms/eslint/runner/runner.js +1410 -1384
  31. package/methods/assessment-template.md +2 -2
  32. package/methods/lenses/clean-architecture.md +7 -8
  33. package/methods/lenses/defended-on-intent.md +2 -2
  34. package/methods/lenses/di-discipline.md +14 -18
  35. package/methods/lenses/function-first.md +16 -18
  36. package/methods/lenses/test-discipline.md +1 -1
  37. package/package.json +1 -1
  38. package/rules/CD-1/CHECKS.md +6 -2
  39. package/rules/CD-1/README.md +6 -19
  40. package/rules/CD-10/CHECKS.md +5 -3
  41. package/rules/CD-10/README.md +6 -18
  42. package/rules/CD-11/CHECKS.md +4 -2
  43. package/rules/CD-11/README.md +6 -16
  44. package/rules/CD-12/CHECKS.md +4 -2
  45. package/rules/CD-12/README.md +6 -16
  46. package/rules/CD-13/CHECKS.md +4 -2
  47. package/rules/CD-13/README.md +6 -16
  48. package/rules/CD-14/CHECKS.md +3 -1
  49. package/rules/CD-14/README.md +6 -19
  50. package/rules/CD-15/CHECKS.md +5 -1
  51. package/rules/CD-15/README.md +5 -20
  52. package/rules/CD-16/CHECKS.md +3 -1
  53. package/rules/CD-16/README.md +6 -6
  54. package/rules/CD-17/CHECKS.md +3 -1
  55. package/rules/CD-17/README.md +6 -19
  56. package/rules/CD-18/CHECKS.md +4 -2
  57. package/rules/CD-18/README.md +6 -16
  58. package/rules/CD-19/CHECKS.md +8 -6
  59. package/rules/CD-19/README.md +6 -20
  60. package/rules/CD-2/CHECKS.md +7 -3
  61. package/rules/CD-2/README.md +6 -21
  62. package/rules/CD-20/CHECKS.md +3 -1
  63. package/rules/CD-20/README.md +6 -6
  64. package/rules/CD-21/CHECKS.md +4 -2
  65. package/rules/CD-21/README.md +6 -15
  66. package/rules/CD-22/CHECKS.md +4 -2
  67. package/rules/CD-22/README.md +6 -15
  68. package/rules/CD-23/CHECKS.md +5 -3
  69. package/rules/CD-23/README.md +6 -17
  70. package/rules/CD-24/CHECKS.md +3 -1
  71. package/rules/CD-24/README.md +6 -6
  72. package/rules/CD-25/CHECKS.md +5 -3
  73. package/rules/CD-25/README.md +5 -21
  74. package/rules/CD-26/CHECKS.md +5 -3
  75. package/rules/CD-26/README.md +6 -20
  76. package/rules/CD-27/CHECKS.md +394 -9
  77. package/rules/CD-27/README.md +6 -20
  78. package/rules/CD-27/discipline.json +130 -0
  79. package/rules/CD-28/CHECKS.md +4 -2
  80. package/rules/CD-28/README.md +6 -16
  81. package/rules/CD-29/CHECKS.md +4 -2
  82. package/rules/CD-29/README.md +6 -14
  83. package/rules/CD-3/CHECKS.md +3 -1
  84. package/rules/CD-3/README.md +6 -17
  85. package/rules/CD-30/CHECKS.md +4 -2
  86. package/rules/CD-30/README.md +6 -15
  87. package/rules/CD-31/CHECKS.md +4 -2
  88. package/rules/CD-31/README.md +6 -14
  89. package/rules/CD-32/CHECKS.md +3 -1
  90. package/rules/CD-32/README.md +2 -0
  91. package/rules/CD-33/CHECKS.md +3 -1
  92. package/rules/CD-33/README.md +2 -0
  93. package/rules/CD-34/CHECKS.md +3 -1
  94. package/rules/CD-34/README.md +2 -0
  95. package/rules/CD-39/CHECKS.md +3 -1
  96. package/rules/CD-39/README.md +2 -0
  97. package/rules/CD-4/CHECKS.md +4 -2
  98. package/rules/CD-4/README.md +6 -17
  99. package/rules/CD-40/CHECKS.md +3 -1
  100. package/rules/CD-40/README.md +6 -20
  101. package/rules/CD-41/CHECKS.md +14 -2
  102. package/rules/CD-41/README.md +6 -20
  103. package/rules/CD-41/discipline.json +14 -0
  104. package/rules/CD-42/CHECKS.md +3 -1
  105. package/rules/CD-42/README.md +6 -16
  106. package/rules/CD-43/CHECKS.md +3 -1
  107. package/rules/CD-43/README.md +6 -18
  108. package/rules/CD-44/CHECKS.md +3 -1
  109. package/rules/CD-44/README.md +6 -17
  110. package/rules/CD-45/CHECKS.md +4 -2
  111. package/rules/CD-45/README.md +6 -16
  112. package/rules/CD-46/CHECKS.md +3 -1
  113. package/rules/CD-46/README.md +2 -0
  114. package/rules/CD-47/CHECKS.md +4 -2
  115. package/rules/CD-47/README.md +4 -20
  116. package/rules/CD-5/CHECKS.md +4 -2
  117. package/rules/CD-5/README.md +6 -19
  118. package/rules/CD-6/CHECKS.md +3 -1
  119. package/rules/CD-6/README.md +6 -19
  120. package/rules/CD-7/CHECKS.md +3 -1
  121. package/rules/CD-7/README.md +6 -20
  122. package/rules/CD-7a/CHECKS.md +3 -1
  123. package/rules/CD-7a/README.md +6 -17
  124. package/rules/CD-8/CHECKS.md +3 -1
  125. package/rules/CD-8/README.md +6 -17
  126. package/rules/CD-9/CHECKS.md +4 -2
  127. package/rules/CD-9/README.md +6 -17
  128. package/rules/README.md +71 -54
  129. package/rules/SPIRIT.md +3 -3
  130. package/rules/cases.md +94 -0
  131. package/rules/numbers.md +155 -0
  132. package/rules/principles.md +89 -0
  133. package/rules/records.md +150 -0
  134. package/rules/rules.md +149 -0
  135. package/rules/sources.md +142 -0
  136. package/rules/typescript/checks.md +219 -0
  137. package/rules/typescript/recipes.md +361 -0
  138. package/rules/typescript/symptoms.json +1005 -0
  139. package/rules/typescript/symptoms.md +612 -0
  140. package/chunks/chunk-YLZ73C7O.js +0 -0
@@ -0,0 +1,612 @@
1
+ # Symptoms in TypeScript
2
+
3
+ A symptom is something seen in code. It is suspect by default, and it may point at several rules. Symptoms here name TypeScript constructs. "Clearly a symptom can exist with ambiguity about reasoning."
4
+
5
+ A finding has two addresses: where the symptom is seen, and where the breach sits. A symptom's id is its name, hyphenated.
6
+
7
+ Where the thing seen is correct use, a [record](../records.md) covers it. The record kind is named under "Breach usually sits". No symptom carries an exception.
8
+
9
+ **May indicate** lists cases, then the rules they point at, as case → rule.
10
+
11
+ **Seen by** is one of:
12
+ - **syntax:** the file's tree alone;
13
+ - **types:** needs the type checker;
14
+ - **graph:** needs the import graph;
15
+ - **app:** needs the app's structure;
16
+ - **files:** config, file names or build output;
17
+ - **history:** needs the change history;
18
+ - **person:** only a person sees it.
19
+
20
+ **Check today** is how near today's checks come, from the [checks page](checks.md): reuse, partial, review (only a review clause covers it), new (nothing covers it), or only review (a person sees it).
21
+
22
+ Outside dependency: what was called a package. An internal package is our own code.
23
+
24
+ ## The outside world reached directly
25
+
26
+ ### Date used directly
27
+
28
+ - **Seen:** Any use of `Date` (`Date.now()`, `new Date()`, `new Date(value)`, `Date.parse`) or `performance.now()` outside the places that handle dates.
29
+ - **May indicate:** Needs the current time → Ports declared inside; Written-out answers. Does one job → Doer or orchestrator ("Dating and numbering an order is not the same job as charging it").
30
+ - **Breach usually sits:** In the unit that should be passed the time; often a doer doing two jobs. Correct use: boundary record on the clock adapter.
31
+ - **Seen by:** syntax.
32
+ - **Check today:** reuse.
33
+
34
+ ### Ambient randomness
35
+
36
+ - **Seen:** `Math.random()`, `crypto.randomUUID()` or `crypto.getRandomValues()` outside their adapter.
37
+ - **May indicate:** Needs a random value or a new id → Ports declared inside; Written-out answers.
38
+ - **Breach usually sits:** In the unit that should be passed the value. Correct use: boundary record.
39
+ - **Seen by:** syntax.
40
+ - **Check today:** new.
41
+
42
+ ### Process global used in place
43
+
44
+ - **Seen:** `process.env`, `process.argv`, `process.exit`, `process.on`, `console.*` or `globalThis` read outside an adapter.
45
+ - **May indicate:** Reads data from outside → No leak; Causes an effect → Ports declared inside; Builds the real implementations → Ports declared inside.
46
+ - **Breach usually sits:** A missing port; or an adapter not built at the entry point. "Process env reader is just an external world being wrapped." Correct use: boundary record.
47
+ - **Seen by:** syntax.
48
+ - **Check today:** review.
49
+
50
+ ### Outside import past a boundary
51
+
52
+ - **Seen:** An import, `import()` or `require` of an outside dependency or runtime module (`node:*`) in a file with no boundary record.
53
+ - **May indicate:** Uses a system or service outside the program, Takes an outside dependency → Outside dependencies stay at boundaries; Ports declared inside.
54
+ - **Breach usually sits:** A missing adapter and port. Correct use: boundary record.
55
+ - **Seen by:** graph.
56
+ - **Check today:** partial.
57
+
58
+ ### Outside type in a signature
59
+
60
+ - **Seen:** A type from an outside dependency or runtime library in a business-logic parameter, field or return, imported or inferred.
61
+ - **May indicate:** Uses a system or service outside the program → Outside dependencies stay at boundaries; No leak.
62
+ - **Breach usually sits:** The adapter that hands the outside type inward.
63
+ - **Seen by:** types.
64
+ - **Check today:** new.
65
+
66
+ ### Library class built in place
67
+
68
+ - **Seen:** `new` on a class from an outside dependency, outside that dependency's adapter.
69
+ - **May indicate:** Takes an outside dependency → Outside dependencies stay at boundaries; Keeps state or settings across calls → No hidden effects.
70
+ - **Breach usually sits:** A missing adapter. Correct use: boundary record.
71
+ - **Seen by:** types.
72
+ - **Check today:** review.
73
+
74
+ ## Text and schemas past their reader
75
+
76
+ "Json use and Zod use both imply same sort of symptom". They are two symptoms because two different things are seen.
77
+
78
+ ### Text past its reader
79
+
80
+ - **Seen:** `JSON.parse`, `JSON.stringify` or a YAML parse or dump outside the adapter for whoever produced or receives the text, tests included.
81
+ - **May indicate:** Reads data from outside, Sends data out → No leak; Uses a system or service outside the program → External behaviour sits at a boundary. In a test: States what the unit gives back → Straight-through tests; Written-out answers.
82
+ - **Breach usually sits:** A port that takes or gives text where it should carry objects: "a boundary on whoever made json". Correct use: in the producer's adapter, a boundary record; at one test site, an authorised location for this symptom alone.
83
+ - **Seen by:** syntax; types to trace the port.
84
+ - **Check today:** partial (tests only).
85
+
86
+ ### Schema past its adapter
87
+
88
+ - **Seen:** A schema, a `.parse` call or a `z.infer` type outside the producer's adapter, or the same value parsed twice.
89
+ - **May indicate:** Reads data from outside → No leak; Gives a value its type → Declared, not asserted.
90
+ - **Breach usually sits:** The adapter, which hands the wire type inward instead of mapping it. Correct use: a boundary record with a Conformist statement, for an outside model adopted as ours.
91
+ - **Seen by:** graph.
92
+ - **Check today:** review.
93
+
94
+ ## Claimed or loose types
95
+
96
+ ### Claimed type
97
+
98
+ - **Seen:** `as T` other than `as const`, `<T>x`, `x!` or `x!:`, including `as unknown` and any cast whose type holds `any`.
99
+ - **May indicate:** Gives a value its type → Declared, not asserted. In a test: Checks a value that may be one of several outcomes → Straight-through tests; a cast to build an input → Handed what it uses.
100
+ - **Breach usually sits:** The declaration: an input too wide, a generic not bounded, a missing parse. "this feels like its hiding a problem with out modelling". Correct use: authorised location in the adapter whose outside contract forces it.
101
+ - **Seen by:** syntax.
102
+ - **Check today:** reuse.
103
+
104
+ ### Untyped value
105
+
106
+ - **Seen:** `any` in a type position, or a `let` with no type and no initial value.
107
+ - **May indicate:** Gives a value its type → Declared, not asserted; Reads data from outside → No leak.
108
+ - **Breach usually sits:** The boundary that let an unknown shape in. Correct use: debt.
109
+ - **Seen by:** syntax.
110
+ - **Check today:** reuse.
111
+
112
+ ### Own type guard
113
+
114
+ - **Seen:** A function of ours whose return type is `x is T` or `asserts x is T`.
115
+ - **May indicate:** Gives a value its type → Declared, not asserted; Reads data from outside → No leak.
116
+ - **Breach usually sits:** A missing schema parse at the adapter, or a declaration too wide.
117
+ - **Seen by:** syntax.
118
+ - **Check today:** new.
119
+
120
+ ### Type derived from code
121
+
122
+ - **Seen:** `ReturnType<typeof x>`, `Parameters<typeof x>` or `typeof x` used as a type of our own.
123
+ - **May indicate:** Gives a value its type → Declared, not asserted; Names something → One word everywhere.
124
+ - **Breach usually sits:** The producer, which has no named type.
125
+ - **Seen by:** syntax.
126
+ - **Check today:** reuse.
127
+
128
+ ### Strictness weakened
129
+
130
+ - **Seen:** A project whose resolved compiler options leave a strict flag off.
131
+ - **May indicate:** Sets how strictly the checker works → The type checker proves it.
132
+ - **Breach usually sits:** The base config or the project that overrides it.
133
+ - **Seen by:** files.
134
+ - **Check today:** reuse.
135
+
136
+ ### Default on a closed union
137
+
138
+ - **Seen:** `default:` in a `switch` over a closed union.
139
+ - **May indicate:** A value is one of several kinds → Kinds are named.
140
+ - **Breach usually sits:** The switch.
141
+ - **Seen by:** types.
142
+ - **Check today:** reuse.
143
+
144
+ ### Boolean in a signature
145
+
146
+ - **Seen:** A `boolean` parameter, field, or return that stands for a mode or state.
147
+ - **May indicate:** A value is one of several kinds → Kinds are named; Does one job → Doer or orchestrator ("boolean inputs are a smell, disallowed").
148
+ - **Breach usually sits:** A missing named kind, or a unit with two modes.
149
+ - **Seen by:** syntax; types to tell a predicate.
150
+ - **Check today:** reuse.
151
+
152
+ ### Absence standing for a state
153
+
154
+ - **Seen:** A field typed `T | null` or `T | undefined`, or optional, whose absence means a state rather than "not given".
155
+ - **May indicate:** A value is one of several kinds → Kinds are named; Keeps state across calls → No hidden effects. "this is a bunch of nullable and state management mess".
156
+ - **Breach usually sits:** The type, which needs named kinds.
157
+ - **Seen by:** person; types to find candidates.
158
+ - **Check today:** only review.
159
+
160
+ ### Default for a required value
161
+
162
+ - **Seen:** `??`, `||` or a parameter default that supplies a required config, context or environment value.
163
+ - **May indicate:** Reads data from outside → No leak ("no default, must be provided as env var"); An operation can fail → Failures are values; Gives a value its type → Declared, not asserted.
164
+ - **Breach usually sits:** The declaration or the adapter: a missing value is a failure.
165
+ - **Seen by:** types.
166
+ - **Check today:** review.
167
+
168
+ ## Failures
169
+
170
+ ### Throw between our units
171
+
172
+ - **Seen:** `throw` outside an adapter whose caller's contract is exceptions.
173
+ - **May indicate:** An operation can fail → Failures are values; Sends data out → No leak.
174
+ - **Breach usually sits:** The unit, or a missing mapping at the adapter. Correct use: authorised location. "Throwing in specific places allowed is just authorised locations as prose."
175
+ - **Seen by:** syntax; graph for adapters.
176
+ - **Check today:** review.
177
+
178
+ ### Thrown non-error
179
+
180
+ - **Seen:** `throw` of a literal, an object or a template.
181
+ - **May indicate:** Sends data out → No leak, since a thrown value speaks the caller's language.
182
+ - **Breach usually sits:** The throw site.
183
+ - **Seen by:** syntax.
184
+ - **Check today:** reuse.
185
+
186
+ ### Failure shaped as success
187
+
188
+ - **Seen:** A failed path that returns `null`, `false`, `[]`, `undefined` or a default, or a `catch` that returns one.
189
+ - **May indicate:** An operation can fail → Failures are values.
190
+ - **Breach usually sits:** The unit's return type.
191
+ - **Seen by:** person; syntax for a `catch` that returns.
192
+ - **Check today:** only review.
193
+
194
+ ### Catch-all failure kind
195
+
196
+ - **Seen:** A failure variant such as `unknown`, `other` or a bare message string, carrying no named cause.
197
+ - **May indicate:** An operation can fail → Failures are values; A value is one of several kinds → Kinds are named.
198
+ - **Breach usually sits:** The adapter, which did not name the outside failure.
199
+ - **Seen by:** types; person.
200
+ - **Check today:** new.
201
+
202
+ ## Effects and state
203
+
204
+ ### Loop keyword
205
+
206
+ - **Seen:** `for`, `for…of`, `for…in`, `for await`, `while` or `do`.
207
+ - **May indicate:** Makes a new value → No hidden effects; Causes an effect → Ports declared inside; Coordinates other units → Doer or orchestrator. "For of mutates by its nature."
208
+ - **Breach usually sits:** The unit. Correct use: draining a stream in its source's adapter, as an authorised location.
209
+ - **Seen by:** syntax.
210
+ - **Check today:** reuse.
211
+
212
+ ### Write into a parameter
213
+
214
+ - **Seen:** Assigning to or deleting a parameter's field, or calling an in-place method (`push`, `sort`, `splice`) on a parameter.
215
+ - **May indicate:** Makes a new value → No hidden effects.
216
+ - **Breach usually sits:** The unit.
217
+ - **Seen by:** syntax; types for in-place methods.
218
+ - **Check today:** reuse.
219
+
220
+ ### Rebinding
221
+
222
+ - **Seen:** A `let` assigned again, or a parameter reassigned, incremented or destructured into.
223
+ - **May indicate:** Makes a new value → No hidden effects; Does one job → Doer or orchestrator (work done inline in steps).
224
+ - **Breach usually sits:** The unit. No caller sees it, so on its own it shows no hidden effect; it is suspect for inline work.
225
+ - **Seen by:** syntax.
226
+ - **Check today:** reuse.
227
+
228
+ ### Authored class or this
229
+
230
+ - **Seen:** The `class` keyword in our code, `static`-only classes included, or `this` read outside a class.
231
+ - **May indicate:** Keeps state or settings across calls → No hidden effects; Reuses behaviour → One reason per module; Gives a value its type → Declared, not asserted.
232
+ - **Breach usually sits:** The unit.
233
+ - **Seen by:** syntax.
234
+ - **Check today:** reuse.
235
+
236
+ ### Module-level state
237
+
238
+ - **Seen:** A module-scope `let`, or a module-scope collection that functions change.
239
+ - **May indicate:** Keeps state across calls → No hidden effects; External behaviour sits at a boundary.
240
+ - **Breach usually sits:** A missing adapter for the state.
241
+ - **Seen by:** syntax.
242
+ - **Check today:** new.
243
+
244
+ ## Unit shape
245
+
246
+ ### Long function
247
+
248
+ - **Seen:** A function body over the line limit.
249
+ - **May indicate:** Coordinates other units, Does one job → Doer or orchestrator; Gives a value its type → Handed what it uses; Checks conditions → Guard first; Puts code in a file, Names something → One reason per module, One word everywhere. "Line and complexity are symptoms that flag many things. Functions doing too many things. Minimal interfaces issues. Nested logic indicating complexity density instead of isolated rules and responsibilities named for what they are."
250
+ - **Breach usually sits:** The unit: several jobs, an input wider than its use, nested questions, or a responsibility not isolated and named.
251
+ - **Seen by:** syntax.
252
+ - **Check today:** reuse.
253
+
254
+ ### Tangled function
255
+
256
+ - **Seen:** A function over the cognitive-complexity limit.
257
+ - **May indicate:** The same cases and rules as Long function.
258
+ - **Breach usually sits:** As Long function.
259
+ - **Seen by:** syntax.
260
+ - **Check today:** reuse.
261
+
262
+ ### Work inside a condition
263
+
264
+ - **Seen:** An `if` inside another `if`, or an `else` after a branch that always exits.
265
+ - **May indicate:** Checks conditions → Guard first; Does one job → Doer or orchestrator. "If nested it's a poorly modelled set of questions for a single job."
266
+ - **Breach usually sits:** The unit's questions.
267
+ - **Seen by:** syntax.
268
+ - **Check today:** partial.
269
+
270
+ ### Orchestrator that computes
271
+
272
+ - **Seen:** A function that calls two or more units of ours and also branches, computes or reshapes between the calls.
273
+ - **May indicate:** Coordinates other units → Doer or orchestrator.
274
+ - **Breach usually sits:** The orchestrator.
275
+ - **Seen by:** graph.
276
+ - **Check today:** review.
277
+
278
+ ### Doer calling our own unit
279
+
280
+ - **Seen:** A function with logic that imports and calls a business-logic unit of ours that is not a port.
281
+ - **May indicate:** Does one job → Doer or orchestrator; Uses what a collaborator gives back → Written-out answers.
282
+ - **Breach usually sits:** The unit, mixing two roles.
283
+ - **Seen by:** graph.
284
+ - **Check today:** new.
285
+
286
+ ### Positional parameters
287
+
288
+ - **Seen:** A function of ours, whose shape no outside API fixes, that has two or more parameters. "Functions with no outside influence should take 1. 2 is debatable. But for agents the goal is always 1."
289
+ - **May indicate:** Names something → One word everywhere; Does one job → Handed what it uses.
290
+ - **Breach usually sits:** The signature.
291
+ - **Seen by:** syntax.
292
+ - **Check today:** partial.
293
+
294
+ ### Tuple as data
295
+
296
+ - **Seen:** An array literal or type of fixed mixed positions used as a value, such as `[key, value]` pairs or `pair[1]`.
297
+ - **May indicate:** Names something → One word everywhere ("nope, you will not use tupple like arrays for data").
298
+ - **Breach usually sits:** The data's type.
299
+ - **Seen by:** syntax; types.
300
+ - **Check today:** new.
301
+
302
+ ### Wide input
303
+
304
+ - **Seen:** A parameter type holding fields the unit never reads.
305
+ - **May indicate:** Does one job, Gives a value its type → Handed what it uses.
306
+ - **Breach usually sits:** The unit's declared input.
307
+ - **Seen by:** types.
308
+ - **Check today:** new.
309
+
310
+ ### Wide port
311
+
312
+ - **Seen:** A port with methods its consumer never calls.
313
+ - **May indicate:** Uses a system or service outside the program → Handed what it uses; Ports declared inside.
314
+ - **Breach usually sits:** The port.
315
+ - **Seen by:** graph; types.
316
+ - **Check today:** new.
317
+
318
+ ## Layers and wiring
319
+
320
+ ### Inner layer imports outer
321
+
322
+ - **Seen:** A domain or business-logic file that imports an adapter or infrastructure file.
323
+ - **May indicate:** Uses a system or service outside the program → Ports declared inside; Outside dependencies stay at boundaries; External behaviour sits at a boundary.
324
+ - **Breach usually sits:** The import, or a port declared on the wrong side.
325
+ - **Seen by:** app.
326
+ - **Check today:** review.
327
+
328
+ ### Port outside the domain
329
+
330
+ - **Seen:** A port interface declared in an adapter's module, or beside its default adapter.
331
+ - **May indicate:** Uses a system or service outside the program → Ports declared inside ("the port is domain and to be kept separate to the concrete implementation or use").
332
+ - **Breach usually sits:** The port's file.
333
+ - **Seen by:** graph.
334
+ - **Check today:** review.
335
+
336
+ ### Adapter built outside the root
337
+
338
+ - **Seen:** A call to an adapter's factory anywhere but the entry point.
339
+ - **May indicate:** Builds the real implementations → Ports declared inside; Doer or orchestrator.
340
+ - **Breach usually sits:** The calling unit, which builds what it should be passed.
341
+ - **Seen by:** graph.
342
+ - **Check today:** review.
343
+
344
+ ### Port named for a mechanism
345
+
346
+ - **Seen:** A port named for a technology (`HttpClient`, `Fs`, `Sqlite`) rather than a capability.
347
+ - **May indicate:** Uses a system or service outside the program → Ports declared inside; Names something → One word everywhere.
348
+ - **Breach usually sits:** The port.
349
+ - **Seen by:** person.
350
+ - **Check today:** only review.
351
+
352
+ ## Tests
353
+
354
+ ### Double with a body
355
+
356
+ - **Seen:** A double that has a function body at all: `vi.fn(impl)`, `mockImplementation`, or a hand-written function or object double. A body that only returns a value is included. "Exact returns can use mockreturn or mockresolve".
357
+ - **May indicate:** Uses what a collaborator gives back → Written-out answers; Handed what it uses; Doer or orchestrator. "The stub form not expressing has to be tied to something very strong to justify. Or it implies a different root cause around coupling to external behaviour".
358
+ - **Breach usually sits:** A port too wide, or a collaborator holding two decisions. Correct use: deviation from [Stub with vi.fn](recipes.md#stub-with-vifn).
359
+ - **Seen by:** syntax.
360
+ - **Check today:** reuse.
361
+
362
+ ### Module or global patched
363
+
364
+ - **Seen:** `vi.mock`, `vi.stubGlobal`, a spy on a global, or `process.env` set in a test.
365
+ - **May indicate:** Uses what a collaborator gives back → Written-out answers; Ports declared inside. "if you are doing this you have severely messed up your dependency management".
366
+ - **Breach usually sits:** The unit, which imports what it should be passed.
367
+ - **Seen by:** syntax.
368
+ - **Check today:** partial.
369
+
370
+ ### Branch in a test
371
+
372
+ - **Seen:** `if`, a ternary, `&&`, `||`, `??`, `?.` or `switch` in a test file.
373
+ - **May indicate:** Checks a value that may be one of several outcomes → Straight-through tests; Kinds are named; Failures are values.
374
+ - **Breach usually sits:** Often the unit's output type: optional or loose shapes force the test to branch.
375
+ - **Seen by:** syntax.
376
+ - **Check today:** reuse.
377
+
378
+ ### Computed value in a test
379
+
380
+ - **Seen:** A test that builds or picks a value: array methods, `find`, `Math.*`, `Object.assign`, `Object.fromEntries`, `Array.from` or a spread over a list. Calls on the unit's own API are not included.
381
+ - **May indicate:** States what the unit gives back → Straight-through tests; Written-out answers. "Math and map are deterministic logic. Banned in tests."
382
+ - **Breach usually sits:** The test, or logic no unit owns.
383
+ - **Seen by:** syntax.
384
+ - **Check today:** reuse.
385
+
386
+ ### Throw or catch in a test
387
+
388
+ - **Seen:** `throw`, `try` or `catch` in a test file.
389
+ - **May indicate:** States what the unit gives back → Straight-through tests; An operation can fail → Failures are values.
390
+ - **Breach usually sits:** Often the unit, which throws.
391
+ - **Seen by:** syntax.
392
+ - **Check today:** reuse.
393
+
394
+ ### Unasserted call
395
+
396
+ - **Seen:** A stub or spy passed to the unit whose calls the test never asserts.
397
+ - **May indicate:** Uses what a collaborator gives back → Written-out answers ("If the unit calls something we check it calls it.").
398
+ - **Breach usually sits:** The test.
399
+ - **Seen by:** syntax; types.
400
+ - **Check today:** new.
401
+
402
+ ### Answer set in a hook
403
+
404
+ - **Seen:** A test hook that gives a stub its answer (`mockReturnValue`, `mockResolvedValue`, `mockImplementation`) or reassigns a value the tests read. A plain reset in `afterEach` is not this symptom. "Nothing wrong with a reset in after each. But something wrong with a remock in after each. Implies the suite knows the input needed for each test." Sharing alone is not the breach: "I have no issue with shared boilerplate or even mock builders when it doesn't hide minimal interfaces issues and doesn't hide assumptions or coupling between tests. But it often does when not done with care."
405
+ - **May indicate:** States what the unit gives back → Straight-through tests (each test is one complete, distinct case); Uses what a collaborator gives back → Written-out answers; Keeps state across calls → No hidden effects.
406
+ - **Breach usually sits:** A double or a value shared across tests at file or suite scope; or state held in the unit's module.
407
+ - **Seen by:** syntax.
408
+ - **Check today:** partial (the `let` form only).
409
+
410
+ ### Test switched off
411
+
412
+ - **Seen:** `.only`, `.skip`, `fit` or `xit`.
413
+ - **May indicate:** Gives each unit its test → Tested where it's owned.
414
+ - **Breach usually sits:** The test file.
415
+ - **Seen by:** syntax.
416
+ - **Check today:** reuse.
417
+
418
+ ### Unit without a running test
419
+
420
+ - **Seen:** A file with a runtime export and no `name.test.ts` beside it that imports and runs it.
421
+ - **May indicate:** Gives each unit its test → Tested where it's owned.
422
+ - **Breach usually sits:** The missing test. Correct use: debt.
423
+ - **Seen by:** files; graph.
424
+ - **Check today:** reuse.
425
+
426
+ ### Machine touched in a unit test
427
+
428
+ - **Seen:** A unit test that reads or writes files, spawns a process, opens a socket or makes a temp directory.
429
+ - **May indicate:** Tests across units or against a real system → Tested where it's owned; Uses what a collaborator gives back → Written-out answers. "even TMP directory style ones should not need to exercise real operations of any kind".
430
+ - **Breach usually sits:** The unit, which has no port; or a test that is an integration test misnamed.
431
+ - **Seen by:** syntax; files.
432
+ - **Check today:** new.
433
+
434
+ ### Inherited environment in a subprocess
435
+
436
+ - **Seen:** A process spawned in a test with no explicit environment, or one built from `process.env`.
437
+ - **May indicate:** Tests across units or against a real system → Tested where it's owned (Tests are ours).
438
+ - **Breach usually sits:** The spawn site.
439
+ - **Seen by:** syntax; types.
440
+ - **Check today:** partial.
441
+
442
+ ### Behaviour tested away from its owner
443
+
444
+ - **Seen:** A unit test that asserts what a collaborator does, or an integration test that pins a rule a unit owns.
445
+ - **May indicate:** Tests across units, Gives each unit its test → Tested where it's owned; Written-out answers.
446
+ - **Breach usually sits:** The test level.
447
+ - **Seen by:** person; graph.
448
+ - **Check today:** only review.
449
+
450
+ ### Integration-heavy suite
451
+
452
+ - **Seen:** More integration tests, or more integration test cases, than the bindings to the outside they cover.
453
+ - **May indicate:** Tests across units → Tested where it's owned. "We had excessive integration tests and "fixtures" for what we're unit level business rules."
454
+ - **Breach usually sits:** Missing unit tests and ports.
455
+ - **Seen by:** files (by the integration test suffix).
456
+ - **Check today:** review.
457
+
458
+ ### Coverage gate
459
+
460
+ - **Seen:** A coverage percentage threshold in test config.
461
+ - **May indicate:** Gives each unit its test → Tested where it's owned.
462
+ - **Breach usually sits:** The config.
463
+ - **Seen by:** files.
464
+ - **Check today:** review.
465
+
466
+ ### Large input for a few fields
467
+
468
+ - **Seen:** A test that writes a large object, or casts, to give the unit the few fields it reads.
469
+ - **May indicate:** Gives a value its type, Does one job → Handed what it uses. "Shows up in tests where to avoid writing a large object for 2 fields that impact th test they double cast."
470
+ - **Breach usually sits:** The unit's declared input.
471
+ - **Seen by:** person; syntax for the cast.
472
+ - **Check today:** only review.
473
+
474
+ ### Test of the type checker
475
+
476
+ - **Seen:** A test that asserts only what the types already prove, such as exhaustiveness.
477
+ - **May indicate:** Gives each unit its test → Tested where it's owned; The type checker proves it. "it simply checks the type system itself. Instead of adding value."
478
+ - **Breach usually sits:** The test.
479
+ - **Seen by:** person.
480
+ - **Check today:** only review.
481
+
482
+ ## Names, prose and files
483
+
484
+ ### Shorthand name
485
+
486
+ - **Seen:** A name of single letters, an abbreviation or a filler word (`data`, `result`, `options`, `tx`), at any scope.
487
+ - **May indicate:** Names something → One word everywhere.
488
+ - **Breach usually sits:** The name. Correct use: authorised location for a name an outside contract fixes.
489
+ - **Seen by:** syntax.
490
+ - **Check today:** reuse.
491
+
492
+ ### Name off its casing
493
+
494
+ - **Seen:** An identifier or file name outside the adopter's casing convention.
495
+ - **May indicate:** Names something → One word everywhere.
496
+ - **Breach usually sits:** The name. Correct use: authorised location for an outside contract's names (`PATH`, ESLint listener keys).
497
+ - **Seen by:** syntax; files.
498
+ - **Check today:** reuse.
499
+
500
+ ### Drawer path
501
+
502
+ - **Seen:** A file or folder named utils, helpers, types, common, shared or the like.
503
+ - **May indicate:** Puts code in a file or folder → One reason per module. "this folder is a junk drawer".
504
+ - **Breach usually sits:** The module's contents.
505
+ - **Seen by:** files.
506
+ - **Check today:** reuse.
507
+
508
+ ### Types-only file
509
+
510
+ - **Seen:** A file that declares only types and is not a port declaration.
511
+ - **May indicate:** Puts code in a file, Reuses behaviour → One reason per module ("There shouldn't be type only files. They should be entities.").
512
+ - **Breach usually sits:** The entity's module.
513
+ - **Seen by:** syntax.
514
+ - **Check today:** new.
515
+
516
+ ### Prose in code
517
+
518
+ - **Seen:** Any comment or JSDoc other than a tracked pointer or a covered tool directive.
519
+ - **May indicate:** Explains something in prose → One word everywhere.
520
+ - **Breach usually sits:** A name or type that does not carry the meaning.
521
+ - **Seen by:** syntax.
522
+ - **Check today:** new.
523
+
524
+ ### Untracked escape
525
+
526
+ - **Seen:** A TODO, linter directive or `@ts-*` directive with no tracked reference and no record.
527
+ - **May indicate:** Explains something in prose → One word everywhere; whatever rule the directive switches off.
528
+ - **Breach usually sits:** The record that is missing.
529
+ - **Seen by:** syntax.
530
+ - **Check today:** reuse.
531
+
532
+ ### Many spellings of one concept
533
+
534
+ - **Seen:** One domain concept named two or more ways across the code or the wire.
535
+ - **May indicate:** Names something → One word everywhere ("I don't want to propogate 3 duplicates").
536
+ - **Breach usually sits:** The vocabulary.
537
+ - **Seen by:** person; the vocabulary list makes it checkable.
538
+ - **Check today:** new.
539
+
540
+ ### Outside dependency vocabulary for basic logic
541
+
542
+ - **Seen:** An import of a utility or functional outside dependency (lodash, fp-ts) for branching, matching, transforming or results.
543
+ - **May indicate:** Writes basic logic → Our code reads in the common language; Takes an outside dependency → Outside dependencies justified.
544
+ - **Breach usually sits:** The dependency.
545
+ - **Seen by:** graph.
546
+ - **Check today:** new.
547
+
548
+ ### Duplicate decision
549
+
550
+ - **Seen:** The same decision written in two or more places.
551
+ - **May indicate:** Reuses behaviour, Puts code in a file → One reason per module. "dry is true but it must be held with reasons to change not "same functional code right now"".
552
+ - **Breach usually sits:** Where the decision's home should be. A clone only surfaces a candidate.
553
+ - **Seen by:** person; clone tools surface candidates.
554
+ - **Check today:** only review.
555
+
556
+ ### Change spread across modules
557
+
558
+ - **Seen:** One change for one reason touches many modules, or two modules always change together.
559
+ - **May indicate:** Puts code in a file → One reason per module. "Cause 2 things that change together is potentially a sign of reasons to change boundaries are incorrect."
560
+ - **Breach usually sits:** The module boundaries.
561
+ - **Seen by:** history.
562
+ - **Check today:** new.
563
+
564
+ ## Dependencies and versions
565
+
566
+ ### Floating version
567
+
568
+ - **Seen:** A range (`^`, `~`, `*`, `x`) or a tag (`latest`, `lts`) for an outside dependency, a runtime or a CI action.
569
+ - **May indicate:** Takes an outside dependency → Fixed versions.
570
+ - **Breach usually sits:** The manifest or workflow.
571
+ - **Seen by:** files.
572
+ - **Check today:** new.
573
+
574
+ ### No lock file
575
+
576
+ - **Seen:** A repository with dependencies and no committed lock file.
577
+ - **May indicate:** Takes an outside dependency → Fixed versions.
578
+ - **Breach usually sits:** The repository.
579
+ - **Seen by:** files.
580
+ - **Check today:** new.
581
+
582
+ ### Dependency without a record
583
+
584
+ - **Seen:** A direct dependency, tools included, with no record of the native way weighed.
585
+ - **May indicate:** Takes an outside dependency → Outside dependencies justified.
586
+ - **Breach usually sits:** The record.
587
+ - **Seen by:** files.
588
+ - **Check today:** new.
589
+
590
+ ### Tool fetched at run time
591
+
592
+ - **Seen:** `npx`, `dlx`, `bunx` or a download-and-run in a script, CI step or doc.
593
+ - **May indicate:** Takes an outside dependency → Tools live in the repo.
594
+ - **Breach usually sits:** The script.
595
+ - **Seen by:** files.
596
+ - **Check today:** new.
597
+
598
+ ### Edit inside vendored code
599
+
600
+ - **Seen:** A change to a file inside a vendored folder.
601
+ - **May indicate:** Takes an outside dependency → Upstream stays untouched.
602
+ - **Breach usually sits:** The change. Correct use: an authorised location (drift).
603
+ - **Seen by:** history.
604
+ - **Check today:** new.
605
+
606
+ ### Bundled dependency
607
+
608
+ - **Seen:** Published build output that holds a dependency's code that the package manifest does not declare.
609
+ - **May indicate:** Ships code for others (proposed) → Shipped risk declared (proposed, not accepted). "Do we still bundle Zod which means a Zod cve won't show up accurately?"
610
+ - **Breach usually sits:** The build config.
611
+ - **Seen by:** files (build output).
612
+ - **Check today:** new.
File without changes