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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/ADOPTING.md +314 -0
  2. package/LICENSE +17 -0
  3. package/MIGRATING.md +238 -0
  4. package/README.md +219 -2
  5. package/THIRD-PARTY-NOTICES.md +354 -0
  6. package/chunks/chunk-233U4FBA.js +42 -0
  7. package/chunks/chunk-7ZJZZBSS.js +14909 -0
  8. package/chunks/chunk-HBY4ZWSP.js +79 -0
  9. package/chunks/chunk-HJA4CX7C.js +24 -0
  10. package/chunks/chunk-NZLE2WMY.js +35 -0
  11. package/chunks/chunk-QWA6OVLC.js +11 -0
  12. package/chunks/chunk-TRCB27ET.js +202 -0
  13. package/core/check/tool-command.js +2305 -0
  14. package/docs/adding-a-discipline-or-mechanism.md +195 -0
  15. package/docs/why-chain-contract.md +78 -0
  16. package/mechanisms/audit/CD-1/any-cast.js +81 -0
  17. package/mechanisms/audit/CD-1/piece.json +13 -0
  18. package/mechanisms/audit/CD-10/piece.json +13 -0
  19. package/mechanisms/audit/CD-10/throws-in-tests.js +49 -0
  20. package/mechanisms/audit/CD-14/class-syntax.js +70 -0
  21. package/mechanisms/audit/CD-14/piece.json +13 -0
  22. package/mechanisms/audit/CD-15/loops.js +40 -0
  23. package/mechanisms/audit/CD-15/piece.json +13 -0
  24. package/mechanisms/audit/CD-17/clock-sources.js +29 -0
  25. package/mechanisms/audit/CD-17/piece.json +13 -0
  26. package/mechanisms/audit/CD-19/import-boundaries.js +80 -0
  27. package/mechanisms/audit/CD-19/piece.json +13 -0
  28. package/mechanisms/audit/CD-2/cast-expressions.js +81 -0
  29. package/mechanisms/audit/CD-2/piece.json +13 -0
  30. package/mechanisms/audit/CD-23/export-test-sibling.js +56 -0
  31. package/mechanisms/audit/CD-23/piece.json +13 -0
  32. package/mechanisms/audit/CD-25/dependency-isolation.js +53 -0
  33. package/mechanisms/audit/CD-25/piece.json +13 -0
  34. package/mechanisms/audit/CD-26/module-mocking.js +51 -0
  35. package/mechanisms/audit/CD-26/piece.json +13 -0
  36. package/mechanisms/audit/CD-27/piece.json +13 -0
  37. package/mechanisms/audit/CD-27/test-body-logic.js +107 -0
  38. package/mechanisms/audit/CD-3/compiler-overrides.js +955 -0
  39. package/mechanisms/audit/CD-3/piece.json +49 -0
  40. package/mechanisms/audit/CD-43/boolean-signatures.js +55 -0
  41. package/mechanisms/audit/CD-43/piece.json +13 -0
  42. package/mechanisms/audit/CD-44/parameter-mutation.js +92 -0
  43. package/mechanisms/audit/CD-44/piece.json +13 -0
  44. package/mechanisms/audit/CD-47/hermetic-git-spawns.js +44 -0
  45. package/mechanisms/audit/CD-47/piece.json +13 -0
  46. package/mechanisms/audit/CD-5/comments-directives.js +73 -0
  47. package/mechanisms/audit/CD-5/piece.json +13 -0
  48. package/mechanisms/audit/CD-6/identifier-names.js +132 -0
  49. package/mechanisms/audit/CD-6/piece.json +13 -0
  50. package/mechanisms/audit/CD-7/categorical-paths.js +55 -0
  51. package/mechanisms/audit/CD-7/piece.json +13 -0
  52. package/mechanisms/audit/CD-7a/factory-return-types.js +42 -0
  53. package/mechanisms/audit/CD-7a/piece.json +13 -0
  54. package/mechanisms/audit/CD-8/piece.json +13 -0
  55. package/mechanisms/audit/CD-8/switch-defaults.js +43 -0
  56. package/mechanisms/audit/runner/README.md +38 -0
  57. package/mechanisms/audit/runner/runner.js +546 -0
  58. package/mechanisms/eslint/CD-1/README.md +12 -0
  59. package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +50 -0
  60. package/mechanisms/eslint/CD-1/piece.json +23 -0
  61. package/mechanisms/eslint/CD-10/README.md +9 -0
  62. package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +55 -0
  63. package/mechanisms/eslint/CD-10/piece.json +15 -0
  64. package/mechanisms/eslint/CD-14/README.md +11 -0
  65. package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +88 -0
  66. package/mechanisms/eslint/CD-14/piece.json +31 -0
  67. package/mechanisms/eslint/CD-27/README.md +12 -0
  68. package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +83 -0
  69. package/mechanisms/eslint/CD-27/piece.json +23 -0
  70. package/mechanisms/eslint/CD-40/README.md +7 -0
  71. package/mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js +16 -0
  72. package/mechanisms/eslint/CD-40/piece.json +21 -0
  73. package/mechanisms/eslint/CD-41/README.md +12 -0
  74. package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +228 -0
  75. package/mechanisms/eslint/CD-41/piece.json +23 -0
  76. package/mechanisms/eslint/CD-42/README.md +9 -0
  77. package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +75 -0
  78. package/mechanisms/eslint/CD-42/piece.json +15 -0
  79. package/mechanisms/eslint/CD-44/README.md +7 -0
  80. package/mechanisms/eslint/CD-44/cd44/cd44.eslint-plugin.js +16 -0
  81. package/mechanisms/eslint/CD-44/piece.json +20 -0
  82. package/mechanisms/eslint/CD-6/README.md +9 -0
  83. package/mechanisms/eslint/CD-6/cd6/cd6.eslint-plugin.js +16 -0
  84. package/mechanisms/eslint/CD-6/piece.json +217 -0
  85. package/mechanisms/eslint/CD-7/README.md +9 -0
  86. package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +52 -0
  87. package/mechanisms/eslint/CD-7/piece.json +15 -0
  88. package/mechanisms/eslint/runner/README.md +43 -0
  89. package/mechanisms/eslint/runner/runner.js +4248 -0
  90. package/methods/README.md +18 -0
  91. package/methods/lenses/clean-architecture.md +167 -0
  92. package/methods/lenses/decomposition.md +159 -0
  93. package/methods/lenses/defended-on-intent.md +178 -0
  94. package/methods/lenses/di-discipline.md +156 -0
  95. package/methods/lenses/errors-as-data.md +88 -0
  96. package/methods/lenses/function-first.md +193 -0
  97. package/methods/lenses/naming.md +127 -0
  98. package/methods/lenses/test-discipline.md +166 -0
  99. package/methods/lenses/type-soundness.md +135 -0
  100. package/methods/lenses/zod-boundary.md +158 -0
  101. package/package.json +65 -4
  102. package/rules/CD-1/README.md +43 -0
  103. package/rules/CD-1/discipline.json +185 -0
  104. package/rules/CD-10/README.md +55 -0
  105. package/rules/CD-10/discipline.json +133 -0
  106. package/rules/CD-11/README.md +19 -0
  107. package/rules/CD-11/discipline.json +12 -0
  108. package/rules/CD-12/README.md +19 -0
  109. package/rules/CD-12/discipline.json +12 -0
  110. package/rules/CD-13/README.md +19 -0
  111. package/rules/CD-13/discipline.json +12 -0
  112. package/rules/CD-14/README.md +54 -0
  113. package/rules/CD-14/discipline.json +173 -0
  114. package/rules/CD-15/README.md +48 -0
  115. package/rules/CD-15/discipline.json +73 -0
  116. package/rules/CD-16/README.md +17 -0
  117. package/rules/CD-17/README.md +42 -0
  118. package/rules/CD-17/discipline.json +51 -0
  119. package/rules/CD-18/README.md +19 -0
  120. package/rules/CD-18/discipline.json +12 -0
  121. package/rules/CD-19/README.md +45 -0
  122. package/rules/CD-19/discipline.json +65 -0
  123. package/rules/CD-2/README.md +43 -0
  124. package/rules/CD-2/discipline.json +65 -0
  125. package/rules/CD-20/README.md +17 -0
  126. package/rules/CD-21/README.md +19 -0
  127. package/rules/CD-21/discipline.json +12 -0
  128. package/rules/CD-22/README.md +19 -0
  129. package/rules/CD-22/discipline.json +12 -0
  130. package/rules/CD-23/README.md +41 -0
  131. package/rules/CD-23/discipline.json +57 -0
  132. package/rules/CD-24/README.md +17 -0
  133. package/rules/CD-25/README.md +43 -0
  134. package/rules/CD-25/discipline.json +57 -0
  135. package/rules/CD-26/README.md +42 -0
  136. package/rules/CD-26/discipline.json +57 -0
  137. package/rules/CD-27/README.md +51 -0
  138. package/rules/CD-27/discipline.json +233 -0
  139. package/rules/CD-28/README.md +19 -0
  140. package/rules/CD-28/discipline.json +12 -0
  141. package/rules/CD-29/README.md +19 -0
  142. package/rules/CD-29/discipline.json +12 -0
  143. package/rules/CD-3/README.md +48 -0
  144. package/rules/CD-3/discipline.json +363 -0
  145. package/rules/CD-30/README.md +19 -0
  146. package/rules/CD-30/discipline.json +12 -0
  147. package/rules/CD-31/README.md +19 -0
  148. package/rules/CD-31/discipline.json +12 -0
  149. package/rules/CD-32/README.md +19 -0
  150. package/rules/CD-32/discipline.json +12 -0
  151. package/rules/CD-33/README.md +19 -0
  152. package/rules/CD-33/discipline.json +12 -0
  153. package/rules/CD-34/README.md +19 -0
  154. package/rules/CD-34/discipline.json +12 -0
  155. package/rules/CD-39/README.md +19 -0
  156. package/rules/CD-39/discipline.json +12 -0
  157. package/rules/CD-4/README.md +19 -0
  158. package/rules/CD-4/discipline.json +12 -0
  159. package/rules/CD-40/README.md +45 -0
  160. package/rules/CD-40/discipline.json +58 -0
  161. package/rules/CD-41/README.md +60 -0
  162. package/rules/CD-41/discipline.json +124 -0
  163. package/rules/CD-42/README.md +53 -0
  164. package/rules/CD-42/discipline.json +61 -0
  165. package/rules/CD-43/README.md +43 -0
  166. package/rules/CD-43/discipline.json +65 -0
  167. package/rules/CD-44/README.md +54 -0
  168. package/rules/CD-44/discipline.json +111 -0
  169. package/rules/CD-45/README.md +19 -0
  170. package/rules/CD-45/discipline.json +12 -0
  171. package/rules/CD-46/README.md +13 -0
  172. package/rules/CD-47/README.md +47 -0
  173. package/rules/CD-47/discipline.json +57 -0
  174. package/rules/CD-5/README.md +46 -0
  175. package/rules/CD-5/discipline.json +65 -0
  176. package/rules/CD-6/README.md +57 -0
  177. package/rules/CD-6/discipline.json +165 -0
  178. package/rules/CD-7/README.md +52 -0
  179. package/rules/CD-7/discipline.json +142 -0
  180. package/rules/CD-7a/README.md +44 -0
  181. package/rules/CD-7a/discipline.json +57 -0
  182. package/rules/CD-8/README.md +48 -0
  183. package/rules/CD-8/discipline.json +57 -0
  184. package/rules/CD-9/README.md +19 -0
  185. package/rules/CD-9/discipline.json +12 -0
  186. package/rules/README.md +52 -0
@@ -0,0 +1,18 @@
1
+ # Review methods
2
+
3
+ These are review methods for applying the rule pages' judgement clauses, and for reviewing the mechanical ones beyond what their checks see.
4
+
5
+ | Lens | Concern |
6
+ | --- | --- |
7
+ | [type-soundness](lenses/type-soundness.md) | This lens defends **the integrity of the type system as a source of truth**: the type the compiler sees must be the type the value actually has, and the type must declare state rather than make the reader evaluate it. |
8
+ | [zod-boundary](lenses/zod-boundary.md) | This lens defends **boundary validation discipline**: external, typeless input is validated exactly once, at the seam where it enters the system, then mapped to a plain internal shape that the rest of the code trusts by construction. |
9
+ | [naming](lenses/naming.md) | This lens defends **names as the documentation**: identifiers, file names, and folder names must carry the meaning, so the codebase needs no prose to explain itself. |
10
+ | [errors-as-data](lenses/errors-as-data.md) | This lens defends **error totality and throw discipline**: the idea that a fallible operation declares its failure modes in its return type rather than escaping through exceptions, and that exceptions are confined to a closed, named set of contexts. |
11
+ | [clean-architecture](lenses/clean-architecture.md) | This lens defends **structural-semantic boundaries**: the directions data and dependencies are allowed to flow, and the classification of the data that crosses the outermost edge. |
12
+ | [function-first](lenses/function-first.md) | This lens defends **function-first composition**: the idea that behaviour is expressed as functions and closures rather than authored classes, that iteration is functional transformation rather than imperative loop shape, that third-party libraries are reached only through a confined wrapping boundary, and that every authored function takes a single named-field argument rather than a positional list. |
13
+ | [di-discipline](lenses/di-discipline.md) | This lens defends **dependency injection through composition** on both faces of the code: every technical binding a unit needs — wall-clock time, process and signal lifecycle, standard-library capabilities (filesystem, crypto, path, net), and third-party services — arrives through a named port the unit receives as a constructor parameter or function argument, never reached for through a global, an ambient import, or the module system. |
14
+ | [test-discipline](lenses/test-discipline.md) | This lens defends **structural test discipline** as a load-bearing floor — the shape of the test suite, not the truth of any domain assertion. |
15
+ | [decomposition](lenses/decomposition.md) | This lens audits **shape, not content** — it asks whether a unit is doing more than its altitude warrants. |
16
+ | [defended-on-intent](lenses/defended-on-intent.md) | This lens defends **intent over letter**: a PASS is only a PASS when the artefact satisfies both the literal text of the cited rule *and* the principle that rule exists to encode. |
17
+
18
+ The defended-on-intent lens runs last, over the other lenses' findings.
@@ -0,0 +1,167 @@
1
+ # Clean-architecture lens
2
+
3
+ A reusable audit method, not a ruleset. The rules it enforces are **data**: load
4
+ every rule page whose `Review lens` line names `clean-architecture`
5
+ from the codebase under review and treat their text as authoritative. This file
6
+ describes only *how* the lens reads code — the concept, the inspection procedure,
7
+ and the output shape. It names no specific rule numbers, file paths, type names,
8
+ or library names; those live in the loaded rules and differ per codebase.
9
+
10
+ ## Concept
11
+
12
+ This lens defends **structural-semantic boundaries**: the directions data and
13
+ dependencies are allowed to flow, and the classification of the data that crosses
14
+ the outermost edge. It is one concept with four faces:
15
+
16
+ - **Dependency direction.** The import graph points inward. An inner layer
17
+ (domain) depends on nothing; each outer layer may depend only on layers more
18
+ inner than itself; the outermost layer (transports) is a leaf nothing imports.
19
+ An import that points outward — a domain module reaching into a transport, an
20
+ application orchestrator reaching into an adapter — is the violation, even when
21
+ every symbol it touches is locally well-typed.
22
+ - **Storage behind a port.** Storage is a capability named by a repository port;
23
+ the adapter behind the port composes the raw driver primitives. Inner code talks
24
+ to the port and never knows whether the backing is a database, a filesystem, an
25
+ in-memory map, or a remote service. Inner code importing a storage driver
26
+ directly is the violation.
27
+ - **Data classification at the edge.** Data leaving the system into a log, a URL,
28
+ or the repository carries a classification. The default for free-form strings
29
+ is "sensitive/PII unless proven otherwise"; the opt-out to log-safe is explicit
30
+ and auditable; secrets are pinned to the type system so the redaction layer can
31
+ enforce them wherever they flow. An unannotated secret or PII string reaching an
32
+ edge is the violation.
33
+ - **Minimal surface.** The system's externally-reachable surface — public network
34
+ bindings, per-service resource budgets — has hard caps. Exceeding a cap is not a
35
+ code smell to weigh; it is a violation that requires an explicit, tracked
36
+ decision to override.
37
+
38
+ Across codebases the concept recurs under different names (hexagonal / ports-and-
39
+ adapters, onion layering, the dependency-inversion principle, data-classification
40
+ or taint rules, attack-surface budgets). The loaded rules tell you this codebase's
41
+ exact shape: the names of its rings, which driver primitives are forbidden inward,
42
+ the brand/annotation idiom for classifying data, and the specific surface caps.
43
+ Read them first; they override any default intuition.
44
+
45
+ ## Loading the ruleset
46
+
47
+ 1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
48
+ 2. Keep the pages whose `Review lens` line names `clean-architecture`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved** — an unloadable ruleset is never a codebase without discipline, and reviewing zero rules would emit a PASS that means nothing.
49
+ 3. Read each kept page in full, including its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a rule names exact permitted sites (a single adapter file, a single redaction layer, a closed list of binding counts), those are the only permitted sites.
50
+ 4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no clean-architecture discipline and produce an empty finding set — do not invent rules.
51
+
52
+ ## Inspection procedure
53
+
54
+ This lens reads one direction and one classification per artefact. For each
55
+ changed file, identify its layer (the rules name the rings and how a path or
56
+ package maps to one), then walk its imports and its edge-crossing call sites.
57
+
58
+ ### The inward-arrow read (dependency direction + storage-behind-port)
59
+
60
+ For every import in a changed file, ask the single question the layering rules
61
+ encode: *does this import point inward toward the system's own abstractions, or
62
+ outward toward a raw library, a raw stdlib module, an ambient global, or a more
63
+ outer layer?*
64
+
65
+ - **Cross-layer outward import.** Map the importing file's layer and the imported
66
+ module's layer. An import that points outward (inner depending on outer) is a
67
+ finding against the layering rule. The permitted shapes are inner-on-inner,
68
+ outer-on-inner, and a boundary file importing the raw outer-world library it
69
+ exists to wrap — everything else is the forbidden outward arrow.
70
+ - **Inner code importing a storage/driver primitive.** Inner layers (domain,
71
+ application) importing a database driver, a filesystem module, or any raw
72
+ storage primitive is a finding against the repository-port rule: the inner code
73
+ reached around the port. The correct shape is a port type declared with the
74
+ domain, a default factory wired at boot, and an adapter file that composes the
75
+ driver behind the port.
76
+ - **Type-only does not escape.** A type-only import still couples the consumer to
77
+ the outer world's type shape; if the rules say type-only follows the same rule,
78
+ read it the same way as a runtime import.
79
+ - **Re-exports and dynamic imports do not escape.** A re-export still imports the
80
+ outer module to re-export it; a dynamic `import(...)` / `require(...)` is still
81
+ an import. Read the import line, not the consumption pattern.
82
+ - **Borderline heuristic.** "Could this file be reasoned about without knowing
83
+ which platform/library it runs on?" If yes, its import direction is likely
84
+ correct; if no, find the port it should depend on and let the boundary file
85
+ shoulder the platform-specificity. The whole point of the abstraction layer is
86
+ that *most* files should pass this test and only a small contained set fail it.
87
+
88
+ ### The classification read (PII / secrets / data at the edge)
89
+
90
+ For every call site that emits data into a log, a URL, a response body, or the
91
+ repository, ask what classification the emitted fields carry:
92
+
93
+ - **Unannotated PII in a log.** A logged field whose value is a free-form string
94
+ sourced from user input, an external response, a parsed external message, or a
95
+ stored row, and which lacks the explicit log-safe annotation the rules define,
96
+ is a finding. The remediation is to confirm the field's classification and
97
+ either annotate it (if genuinely safe) or remove it from the payload (if not) —
98
+ never to rubber-stamp it safe to clear the check.
99
+ - **Unbranded secret.** A schema or type whose identifier or shape reads as a
100
+ credential (token, secret, key, password, session key, bearer, authorization,
101
+ refresh/access token, OAuth material) but which is held as a plain string
102
+ without the sensitive brand the rules mandate is a finding: the value is
103
+ indistinguishable from a normal string and can slip past the redaction layer.
104
+ The remediation is to brand it at the declaration site and propagate the branded
105
+ type to every consumer.
106
+ - **Secret at a forbidden surface.** A hard-coded credential literal in committed
107
+ source, a secret placed in a URL query parameter, or a sensitive-branded value
108
+ reaching a log without passing the redaction layer is a finding. (Operational
109
+ backstops — secret-manager wiring, env discipline, deploy-side rotation,
110
+ external scanners — are upstream of this lens; it flags only the source-level
111
+ artefact that would arm them, and clearly-fake test fixtures on an audited
112
+ allowlist are out of scope, deferring to test-discipline.)
113
+
114
+ ### The minimal-surface read
115
+
116
+ For every change that adds or widens an externally-reachable surface — a new
117
+ public network binding, a service whose steady-state resource footprint may exceed
118
+ the per-service cap — check it against the rule's hard cap. Exceeding a cap is a
119
+ finding unless the change carries the explicit tracked decision the rule requires
120
+ to override. The cap is a number, not a judgement call; "it's only slightly over"
121
+ is not an exception.
122
+
123
+ For each candidate, decide finding vs non-finding strictly against the loaded
124
+ rules and their carve-outs — never against this file's prose or a remembered
125
+ version of some other codebase's rule.
126
+
127
+ ## Letter-vs-intent
128
+
129
+ The lens's catch-rate lives where each symbol is locally fine yet a boundary is
130
+ defeated. An outward import compiles cleanly and every name it touches is valid —
131
+ the defect is the *direction*, not any one symbol. A logged field is a legal
132
+ string — the defect is its missing classification. A surface addition is valid
133
+ config — the defect is that it crosses a capped budget. A finding must explain
134
+ *how the local code reads correct yet the boundary rule is defeated*, grounded in
135
+ the specific loaded rule.
136
+
137
+ Two cross-lens notes worth holding while reading, expressed as method (never by
138
+ re-tagging the rule another lens owns):
139
+
140
+ - **Ambient globals and raw-library wrapping.** Some codebases enforce the same
141
+ inward-arrow shape on raw third-party libraries and stdlib modules through a
142
+ *separate* set of rules (often owned by a dependency-injection / wrapping-factory
143
+ lens, sometimes keyed to capabilities that have a dedicated port). When you see
144
+ inner code call an ambient global or import a raw library outside its wrapping
145
+ site, the *layering* defect is yours to name, but the rule citation may belong to
146
+ that sibling lens — cite the rule the loaded ruleset actually declares, and flag
147
+ the boundary observation rather than inventing a layering rule that doesn't carry
148
+ this lens tag. The wrapping-factory file *is* the permitted seam; the boundary
149
+ violation is only the import that skips it.
150
+ - **Default-factory siblings.** A permitted wrapping/adapter site should also ship
151
+ the default factory its DI rules require; the *internal shape* of the port
152
+ (capability naming, factory presence, generic binding) is the DI lens's lane.
153
+ Note a missing default-factory export as a sibling observation, not as a
154
+ clean-architecture finding of its own.
155
+
156
+ Vague phrasings ("this coupling feels wrong", "might leak data") are the lens's own
157
+ failure mode — every finding names the specific boundary and the rule that draws it.
158
+
159
+ ## Output shape
160
+
161
+ Produce the counts the review asks for (e.g. imports inspected,
162
+ outward-arrow / cross-layer violations, inner-code-importing-driver violations,
163
+ ambient-global call sites, unannotated-PII log emissions, unbranded-secret
164
+ declarations, secret-at-forbidden-surface hits, minimal-surface cap breaches).
165
+ Every finding is `file:line | quoted code | <rule-id> | defect-named`, citing the
166
+ loaded rule by the discipline id and clause address on the rule page (for example `CD-9#result-failures`). State the code-discipline path you
167
+ resolved and which rule ids you loaded under this lens.
@@ -0,0 +1,159 @@
1
+ # Decomposition lens
2
+
3
+ A reusable audit method, not a ruleset. The rules it enforces are **data**: load
4
+ every rule page whose `Review lens` line names `decomposition`
5
+ from the codebase under review and treat their text as authoritative. This file
6
+ describes only *how* the lens reads code — the concept, the inspection
7
+ procedure, and the output shape. It names no specific rule numbers, file paths,
8
+ type names, threshold numbers, or tool rule names; those live in the loaded
9
+ rules and differ per codebase.
10
+
11
+ ## Concept
12
+
13
+ This lens audits **shape, not content** — it asks whether a unit is doing more
14
+ than its altitude warrants. It defends three related ideas:
15
+
16
+ - **Orchestrator purity.** A module classified as an orchestrator composes
17
+ helper calls in dependency order and assembles a return value, and nothing
18
+ else. Inline branching beyond what a helper's return value already
19
+ discriminates, loops, anonymous transformations, local helper definitions, and
20
+ inline computation that carries meaning beyond plumbing are all work that
21
+ belongs in a named helper — not in the orchestrator body.
22
+ - **Unhappy-path early return.** When a branch distinguishes a normal
23
+ continue-path from an exceptional abort-path, the abort case returns early and
24
+ the happy path is the function's final expression. The inverse shape
25
+ (happy-first, failure-last) inverts the natural "compute X unless something
26
+ went wrong" reading.
27
+ - **No parameter-field mutation.** A function inspects the parameters it
28
+ receives and returns outputs; it never mutates the fields of those parameters
29
+ — not by assignment, not by `delete`, not by a mutating method call. Locals
30
+ constructed inside the body are not parameters and may be mutated freely before
31
+ return; the contract is enforced at the input/output boundary.
32
+
33
+ Across codebases the concept recurs under different names (a complexity ceiling,
34
+ a "small functions" rule, a guard-clause / early-exit convention, an
35
+ immutability or no-side-effect-on-args rule). The loaded rules tell you this
36
+ codebase's exact shape: which module class counts as an orchestrator, the
37
+ closed carve-outs to the early-return rule, and what mutation forms are
38
+ forbidden. Read them first; they override any default intuition.
39
+
40
+ ## Loading the ruleset
41
+
42
+ 1. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`.
43
+ 2. Keep the pages whose `Review lens` line names `decomposition`. **If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved** — an unloadable ruleset is never a codebase without discipline, and reviewing zero rules would emit a PASS that means nothing.
44
+ 3. Read each kept page in full, including its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline: those recorded exceptions (authorised locations and carve-outs) are the closed exception list — anything outside them is a finding. Where a clause on a rule page lists a deterministic check (a lint rule, an audit script) in its `## Clauses` table, treat that as a partial mechanical floor: the enforcer catches the obvious cases, but the structural read on diff-touched functions is the lens's job and is not mechanically covered.
45
+ 4. If zero rule pages name this lens in their `Review lens` line, report that the codebase declares no decomposition discipline and produce an empty finding set — do not invent rules or thresholds.
46
+
47
+ ## Inspection procedure
48
+
49
+ Walk every diff-touched function and the module it sits in. The lens reads the
50
+ *shape* of each body against what its altitude permits.
51
+
52
+ ### Orchestrator purity
53
+
54
+ First decide whether the module is an orchestrator per the loaded rule's
55
+ definition (a composition root that wires helpers). If it is, the only permitted
56
+ body content is helper-call bindings, helper invocations in dependency order, and
57
+ a single return-value assembly. The tells, in order of frequency:
58
+
59
+ 1. An `if` inside an orchestrator body whose then-branch is more than a few
60
+ lines — the branch is doing work, and that work should be a helper named for
61
+ the work.
62
+ 2. A loop or a collection-transform callback containing anything beyond a
63
+ one-line projection — the collection processing belongs in a helper named for
64
+ the transformation.
65
+ 3. A binding whose right-hand side is computation rather than a helper call.
66
+ Plumbing literals (assembling a config/info object out of already-computed
67
+ values) are fine; a derived value (an arithmetic or transform with standalone
68
+ meaning) is extraction-worthy.
69
+ 4. A local helper function declared inside the orchestrator body — extract to a
70
+ sibling file with its own co-located test.
71
+
72
+ ### Complexity and length signals
73
+
74
+ A long body or a deeply-branched body is the signal that an orchestrator (or any
75
+ function) is doing non-orchestration work. Where the loaded rules name a
76
+ mechanical complexity/length enforcer, a diff function over that ceiling is the
77
+ first place to look — but the **finding is the structural one** (this body
78
+ conflates abstractions / hides a helper), not the raw number. Conversely, some
79
+ files carry a recorded exemption from the mechanical ceiling (a composition root,
80
+ library-wrapping factories, tooling, test bodies). For an exempt file the lens
81
+ does **not** raise the raw length/complexity finding, but it MUST check whether
82
+ the recorded justification still holds — an exemption whose stated reason no
83
+ longer applies (the helper was extracted, the code migrated) is itself a finding.
84
+ Any inline suppression of the mechanical enforcer must carry the codebase's
85
+ required tracker reference; a bare suppression is a finding in its own count.
86
+
87
+ ### Unhappy-path early return
88
+
89
+ For each diff function whose body contains an `if`/`else` over a success/failure
90
+ discriminator, apply the loaded rule's test: does this branch mean "everything
91
+ is fine, proceed" versus "abort — something is wrong"? If yes, the abort branch
92
+ must come first and the happy path must be the final expression. The fix is
93
+ almost always "invert the branch" — surface the corrected shape inline; do not
94
+ propose helper extraction for an early-return finding alone (that is an
95
+ orchestrator-purity concern that may co-occur, raised separately).
96
+
97
+ ### Parameter-field mutation
98
+
99
+ For each diff function, check whether any field of a *parameter* is mutated:
100
+ direct assignment (`param.x = y`, `param[key] = z`), `delete param.field`, or a
101
+ mutating method call on the parameter (`param.push(...)`, `param.sort()`, and the
102
+ other in-place array/object mutators the loaded rule enumerates). Reassigning the
103
+ parameter binding itself is usually covered by a separate mechanical enforcer;
104
+ this lens closes the field-mutation loophole that enforcer leaves open. Locals
105
+ built inside the body are exempt. Where the loaded rule names an audit script as
106
+ the source-of-truth for direct assignment, seed findings from that report scoped
107
+ to diff files, and mark method-call mutations found by structural read as a
108
+ distinct category (the audit may not yet cover them) so synthesis does not
109
+ conflate script-confirmed with code-review findings. The fix is "copy-then-
110
+ mutate" (return `{ ...param, x: next }`) or the non-mutating method equivalent.
111
+
112
+ ### When a finding recommends extraction
113
+
114
+ A suggested split must answer, in one sentence each: (1) what abstraction the
115
+ extracted helper contains — a noun phrase the file is named for, never a
116
+ categorical name; if you cannot name the abstraction, the body conflates more
117
+ than one and *that* is the finding, with no split proposed; (2) where the helper
118
+ file sits — same directory as the caller, named for the abstraction, not under a
119
+ categorical folder; (3) the helper's input/output shape in one line, honouring
120
+ the codebase's argument and failure-envelope conventions — you draft only the
121
+ boundary, never the body, test, or implementation; (4) what the caller becomes
122
+ after extraction (a single helper-call binding / an early return whose helper
123
+ returns the happy value / a caller that binds a copy instead of mutating). If the
124
+ post-extraction caller is still over the ceiling, the finding is "multiple
125
+ extractions required" and you enumerate them. Do **not** propose: an extraction
126
+ purely for line count with no abstraction; a single arithmetic expression with no
127
+ standalone meaning; a closure capturing more than a couple of caller locals (that
128
+ is a closure-state-injection problem — surface it as an upstream signal); an
129
+ extraction that crosses a layer boundary or requires a new injected port (those
130
+ are other lenses' lanes). When any anti-case applies, raise the upstream-problem
131
+ signal instead of filing a half-designed split.
132
+
133
+ For each candidate, decide finding vs non-finding strictly against the loaded
134
+ rules and their carve-outs — never against this file's prose or a remembered
135
+ version of some other codebase's thresholds.
136
+
137
+ ## Letter-vs-intent
138
+
139
+ The lens's catch-rate lives where the mechanical floor passes but the shape is
140
+ wrong: a body under the complexity ceiling that still conflates two abstractions;
141
+ an early-return inversion that lints clean; a parameter mutation the audit
142
+ script's v1 cut does not yet detect; an exemption whose recorded justification
143
+ has silently expired. A finding here must explain *how the shape reads acceptable
144
+ yet the rule is defeated*, grounded in the specific loaded rule. Distinguish a
145
+ genuine carve-out (closed-discriminator peer dispatch, retry-loop exit condition)
146
+ from a real inversion — the carve-out branches are peer cases with no
147
+ happy/unhappy asymmetry, not findings. Vague phrasings ("function is too long",
148
+ "this looks complex") are the lens's own failure mode.
149
+
150
+ ## Output shape
151
+
152
+ Produce the counts the review asks for: files inspected, functions
153
+ inspected, complexity/length ceilings crossed by type, orchestrator-purity
154
+ violations, early-return inversions, parameter-mutation findings (split by
155
+ script-confirmed vs code-review category), and untracked suppressions. Every
156
+ finding is `file:line | quoted code | <rule-id> | defect-named`, citing the
157
+ loaded rule by the discipline id and clause address on the rule page (for example `CD-9#result-failures`), and — where extraction is
158
+ recommended — the suggested split per the four questions above. State the
159
+ rule-page paths you resolved and which rule ids you loaded under this lens.
@@ -0,0 +1,178 @@
1
+ # Defended-on-intent lens
2
+
3
+ A reusable audit method, not a ruleset. Unlike the other lenses, this one owns
4
+ **no numbered rules of its own** — it applies no lens filter to the
5
+ rule pages. Its denominator is the *bundle*: the PASS claims every other lens
6
+ already asserted, re-tested against the *intent* of the clause each one cited. This file describes only *how* the lens reads those
7
+ claims — the concept, the inspection procedure, the letter-vs-intent test, and
8
+ the output shape. It names no specific rule numbers, file paths, type names, or
9
+ library names; those live in the rule pages and the claims under review, and
10
+ differ per codebase.
11
+
12
+ ## Concept
13
+
14
+ This lens defends **intent over letter**: a PASS is only a PASS when the
15
+ artefact satisfies both the literal text of the cited rule *and* the principle
16
+ that rule exists to encode. The failure shape it hunts is
17
+ **letter-pass-intent-fail** — the rule's letter names mechanism X, the artefact
18
+ uses mechanism Y, so the author concludes "the rule does not apply", while
19
+ mechanism Y subverts the very principle the rule operationalises. The letter
20
+ test and the intent test have *different denominators*; an author who runs only
21
+ the letter test passes a class of artefacts the principle forbids.
22
+
23
+ No script catches this gap — if one could, the gap would not have reached a
24
+ review bundle in the first place. The structural anti-laziness mechanism is the
25
+ mechanical application of the three-step test below to *every* PASS claim in the
26
+ bundle. Skipping a step is not a shortcut; skipping a step IS the failure mode
27
+ this lens exists to detect in others, so the lens cannot tolerate skipping it in
28
+ itself.
29
+
30
+ Across codebases the concept recurs under different names (spirit-vs-letter,
31
+ substance-over-form, "the rule means what it's for, not what it literally
32
+ enumerates"). The mechanism is always the same: derive the rule's intent from
33
+ the principle it sits under, then re-test the defended artefact against that
34
+ intent rather than against the enumerated letter.
35
+
36
+ ## Loading the ruleset
37
+
38
+ This lens applies **no lens filter to the rule pages**. Instead:
39
+
40
+ 1. The **denominator** is fixed by the bundle: the set of PASS claims the other
41
+ lenses' collated reports make. The lens neither discovers new clauses
42
+ nor enumerates the rule pages — both are out of scope. VIOLATION rows are
43
+ another lane; this lens reads PASS claims only.
44
+ 2. For each PASS, the rule pages are consulted **solely to
45
+ look up the literal text of the cited clause** — never to find new clauses to
46
+ test. Resolve the rule pages: `rules/*/README.md` in the Hone install (the folder holding `core/` and `rules/`), and in each rule set the repository's `disciplines.json` names under `ruleSets`. Every rule page in scope is loaded, not filtered by lens. If no rule pages can be read at all, STOP and return CANNOT-REVIEW naming the rule-page paths you resolved — an unloadable ruleset is never a codebase without discipline. Each PASS
47
+ cites a rule by the discipline id and clause address on the rule page (for example `CD-9#result-failures`), and that rule page is where the literal
48
+ text and its governing principle live, together with its `## Exceptions` section and the repository's `discipline-exceptions.json` entries for that discipline.
49
+ 3. If the bundle carries zero PASS claims with cited artefacts, produce an empty
50
+ gap set — do not invent claims to test.
51
+
52
+ ## Inspection procedure
53
+
54
+ For each PASS claim in the bundle, apply three steps mechanically. Skipping a
55
+ step is the laziness this lens detects in others.
56
+
57
+ ### Step 1 — Cite the clause text
58
+
59
+ Open the cited rule page at the resolved path. Locate the cited rule. Quote ≤2
60
+ lines of its **literal text** — no paraphrase, no "in essence", no summary. The
61
+ literal text is the letter: the test the PASS author already ran. Quoting it
62
+ forces an honest comparison at step 3.
63
+
64
+ If the cited rule does not exist at the resolved path, the PASS is malformed:
65
+ surface it as a separate-shape finding ("PASS cites a clause that does not exist
66
+ at the resolved path") and continue to the next claim. Do not invent a clause to
67
+ test against. If the PASS cites no artefact text / file:line / interface
68
+ fragment, step 3 has nothing to run against: surface it as **excluded** with
69
+ reason "no artefact citation — PASS unfalsifiable as written", and do not invent
70
+ an artefact.
71
+
72
+ ### Step 2 — Write the rule's intent in one sentence
73
+
74
+ Your own synthesis. No citation. One sentence. No hedging. Derive the intent
75
+ from **the principle the clause sits under**, not from the clause's letter. A
76
+ rule set clusters rules under principles, each of which carries a standing
77
+ charge the rules under it operationalise. A rule's intent is *that principle's
78
+ standing charge applied to the specific surface the rule names*.
79
+
80
+ The discipline:
81
+
82
+ - **One sentence.** If it needs two, you have not yet boiled it down.
83
+ - **No citation.** If you write "per Principle V…" you are paraphrasing; rewrite
84
+ it as a positive claim.
85
+ - **No hedging.** No "roughly", "essentially", "in spirit". The intent sentence
86
+ must be specific enough that step 3 can *fail*.
87
+
88
+ Two opposite traps bound the intent sentence:
89
+
90
+ - **Tautological intent.** If your sentence rewrites cleanly back to the letter,
91
+ the test is a re-run of the letter test and will catch nothing. The intent
92
+ sentence is correct only when it and the letter have *different denominators*
93
+ — i.e. there exist artefacts that pass the letter and fail the intent.
94
+ - **Manufactured intent.** If your sentence reaches *past* the principle's
95
+ standing charge to manufacture a test the author could not reasonably have
96
+ intended, you have become a generic reviewer inventing findings. The intent
97
+ must be *derivable from the principle*, never invented to manufacture a gap.
98
+ When in doubt, discard the intent sentence and exclude the PASS.
99
+
100
+ ### Step 3 — Re-test the artefact against the intent
101
+
102
+ Read the same artefact text the PASS author defended — the file:line, the
103
+ interface fragment, the test code, whatever the PASS pointed at. Apply the
104
+ intent sentence as a test. Three outcomes:
105
+
106
+ - **a. PASS survives.** The artefact satisfies both letter and intent. Log the
107
+ intent sentence to the audit trail and move on. This is the common case and IS
108
+ work — the logged intent sentence is the proof you did not skip the test.
109
+ - **b. Intent-test fails in a way the letter-test did not.** This is the gap.
110
+ Capture four fields: (1) the artefact text/behaviour (quote / file:line); (2)
111
+ why it satisfies the letter (one sentence); (3) why it fails the intent (one
112
+ sentence); (4) the **structural reframing** the author would need to retract
113
+ the PASS. The reframing field is load-bearing — a gap without a named
114
+ reframing is a complaint, not a finding. The reframing names the concrete
115
+ change (a new constructor parameter, a port, a wrapping-factory move) that
116
+ makes *both* letter and intent pass, and names which lens the retracted PASS
117
+ becomes a VIOLATION on.
118
+ - **c. Intent-test fails identically to the letter-test.** This is not a
119
+ defended-on-intent gap; it is a letter-level VIOLATION another lens missed. Do
120
+ not raise it here (that double-counts and dilutes this lens's signal). Note it
121
+ as "letter-test-also-fails: defer to <source-lens>" and let it be routed back.
122
+
123
+ ## Letter-vs-intent
124
+
125
+ This lens *is* the letter-vs-intent test, so its own catch-rate is the test's
126
+ fidelity. The canonical pattern: a rule's letter enumerates a specific mechanism
127
+ ("module mocks are forbidden — these named mechanisms"), an artefact uses a
128
+ *different* mechanism not enumerated (a global stub, a monkey-patch, a
129
+ module-system reach-around) and the PASS reads "that mechanism is not on the
130
+ list, so the rule does not apply". The intent of the rule — derived from its
131
+ principle (e.g. "every dependency outside the unit boundary is faked through
132
+ dependency injection, never reached around") — is "no faking outside DI". The
133
+ unlisted mechanism *is* faking outside DI; it passes the letter and fails the
134
+ intent. The structural reframing: the unit consumes the dependency as an
135
+ injected port through its argument seam, production wires the real
136
+ implementation in the wrapping-factory file, the test injects a fake directly;
137
+ the PASS retracts and becomes a DI/testing VIOLATION on the owning lens.
138
+
139
+ The three properties that make a finding sound — and that an author can
140
+ reproduce from this procedure alone:
141
+
142
+ 1. **The PASS was defensible at the letter.** The author was not careless; they
143
+ ran the letter test correctly. The catch is not "you missed the letter" — it
144
+ is "the letter and the intent had different denominators and you tested only
145
+ one".
146
+ 2. **The intent sentence is short, specific, principled.** One sentence; not a
147
+ paraphrase of the letter; derivable from the governing principle without
148
+ adversarial extension.
149
+ 3. **The reframing is concrete.** It names the structural change that makes both
150
+ tests pass, not just "this is wrong".
151
+
152
+ When in doubt, ask: **would the PASS author
153
+ retract on reading my intent sentence and re-examining their artefact?** Yes →
154
+ gap. No → they'd defend it at the principle level too, and it is not a
155
+ letter-vs-intent gap.
156
+
157
+ ## Output shape
158
+
159
+ Produce the counts the review asks for:
160
+
161
+ - `pass-claims-tested=N` — every PASS claim in the bundle is either tested or
162
+ explicitly excluded. A verdict without N means sampling, which is the exact
163
+ laziness this lens exists to catch.
164
+ - `pass-claims-excluded=E` — each with a one-line reason (no artefact citation;
165
+ cited clause does not exist; letter-test-also-fails deferred).
166
+ - `letter-vs-intent-gaps=K`.
167
+
168
+ Log the **full intent audit trail**: all N intent sentences, one line each
169
+ (`<rule-id> | intent sentence — my synthesis, no citation`), as the proof the
170
+ test was run on every claim, not sampled.
171
+
172
+ Each gap is reported with: the source lens it came from,
173
+ the cited rule id, the clause letter (quoted, ≤2 lines), the intent sentence,
174
+ the artefact text defending on letter (`file:line | quoted code`), the
175
+ intent-test failure (one sentence), and the structural reframing the author
176
+ needs (naming which lens the retracted PASS becomes a VIOLATION on). State that
177
+ this lens loaded no numbered ruleset of its own and which rule-page paths you
178
+ resolved to look up cited clause text.