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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/ADOPTING.md +314 -0
  2. package/LICENSE +17 -0
  3. package/MIGRATING.md +238 -0
  4. package/README.md +216 -2
  5. package/THIRD-PARTY-NOTICES.md +354 -0
  6. package/chunks/chunk-233U4FBA.js +42 -0
  7. package/chunks/chunk-7ZJZZBSS.js +14909 -0
  8. package/chunks/chunk-HBY4ZWSP.js +79 -0
  9. package/chunks/chunk-HJA4CX7C.js +24 -0
  10. package/chunks/chunk-NZLE2WMY.js +35 -0
  11. package/chunks/chunk-QWA6OVLC.js +11 -0
  12. package/chunks/chunk-TRCB27ET.js +202 -0
  13. package/core/check/tool-command.js +2305 -0
  14. package/docs/adding-a-discipline-or-mechanism.md +195 -0
  15. package/docs/why-chain-contract.md +78 -0
  16. package/mechanisms/audit/CD-1/any-cast.js +81 -0
  17. package/mechanisms/audit/CD-1/piece.json +13 -0
  18. package/mechanisms/audit/CD-10/piece.json +13 -0
  19. package/mechanisms/audit/CD-10/throws-in-tests.js +49 -0
  20. package/mechanisms/audit/CD-14/class-syntax.js +70 -0
  21. package/mechanisms/audit/CD-14/piece.json +13 -0
  22. package/mechanisms/audit/CD-15/loops.js +40 -0
  23. package/mechanisms/audit/CD-15/piece.json +13 -0
  24. package/mechanisms/audit/CD-17/clock-sources.js +29 -0
  25. package/mechanisms/audit/CD-17/piece.json +13 -0
  26. package/mechanisms/audit/CD-19/import-boundaries.js +80 -0
  27. package/mechanisms/audit/CD-19/piece.json +13 -0
  28. package/mechanisms/audit/CD-2/cast-expressions.js +81 -0
  29. package/mechanisms/audit/CD-2/piece.json +13 -0
  30. package/mechanisms/audit/CD-23/export-test-sibling.js +56 -0
  31. package/mechanisms/audit/CD-23/piece.json +13 -0
  32. package/mechanisms/audit/CD-25/dependency-isolation.js +53 -0
  33. package/mechanisms/audit/CD-25/piece.json +13 -0
  34. package/mechanisms/audit/CD-26/module-mocking.js +51 -0
  35. package/mechanisms/audit/CD-26/piece.json +13 -0
  36. package/mechanisms/audit/CD-27/piece.json +13 -0
  37. package/mechanisms/audit/CD-27/test-body-logic.js +107 -0
  38. package/mechanisms/audit/CD-3/compiler-overrides.js +955 -0
  39. package/mechanisms/audit/CD-3/piece.json +49 -0
  40. package/mechanisms/audit/CD-43/boolean-signatures.js +55 -0
  41. package/mechanisms/audit/CD-43/piece.json +13 -0
  42. package/mechanisms/audit/CD-44/parameter-mutation.js +92 -0
  43. package/mechanisms/audit/CD-44/piece.json +13 -0
  44. package/mechanisms/audit/CD-47/hermetic-git-spawns.js +44 -0
  45. package/mechanisms/audit/CD-47/piece.json +13 -0
  46. package/mechanisms/audit/CD-5/comments-directives.js +73 -0
  47. package/mechanisms/audit/CD-5/piece.json +13 -0
  48. package/mechanisms/audit/CD-6/identifier-names.js +132 -0
  49. package/mechanisms/audit/CD-6/piece.json +13 -0
  50. package/mechanisms/audit/CD-7/categorical-paths.js +55 -0
  51. package/mechanisms/audit/CD-7/piece.json +13 -0
  52. package/mechanisms/audit/CD-7a/factory-return-types.js +42 -0
  53. package/mechanisms/audit/CD-7a/piece.json +13 -0
  54. package/mechanisms/audit/CD-8/piece.json +13 -0
  55. package/mechanisms/audit/CD-8/switch-defaults.js +43 -0
  56. package/mechanisms/audit/runner/README.md +38 -0
  57. package/mechanisms/audit/runner/runner.js +546 -0
  58. package/mechanisms/eslint/CD-1/README.md +12 -0
  59. package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +50 -0
  60. package/mechanisms/eslint/CD-1/piece.json +23 -0
  61. package/mechanisms/eslint/CD-10/README.md +9 -0
  62. package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +55 -0
  63. package/mechanisms/eslint/CD-10/piece.json +15 -0
  64. package/mechanisms/eslint/CD-14/README.md +11 -0
  65. package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +88 -0
  66. package/mechanisms/eslint/CD-14/piece.json +31 -0
  67. package/mechanisms/eslint/CD-27/README.md +12 -0
  68. package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +83 -0
  69. package/mechanisms/eslint/CD-27/piece.json +23 -0
  70. package/mechanisms/eslint/CD-40/README.md +7 -0
  71. package/mechanisms/eslint/CD-40/cd40/cd40.eslint-plugin.js +16 -0
  72. package/mechanisms/eslint/CD-40/piece.json +21 -0
  73. package/mechanisms/eslint/CD-41/README.md +12 -0
  74. package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +228 -0
  75. package/mechanisms/eslint/CD-41/piece.json +23 -0
  76. package/mechanisms/eslint/CD-42/README.md +9 -0
  77. package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +75 -0
  78. package/mechanisms/eslint/CD-42/piece.json +15 -0
  79. package/mechanisms/eslint/CD-44/README.md +7 -0
  80. package/mechanisms/eslint/CD-44/cd44/cd44.eslint-plugin.js +16 -0
  81. package/mechanisms/eslint/CD-44/piece.json +20 -0
  82. package/mechanisms/eslint/CD-6/README.md +9 -0
  83. package/mechanisms/eslint/CD-6/cd6/cd6.eslint-plugin.js +16 -0
  84. package/mechanisms/eslint/CD-6/piece.json +217 -0
  85. package/mechanisms/eslint/CD-7/README.md +9 -0
  86. package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +52 -0
  87. package/mechanisms/eslint/CD-7/piece.json +15 -0
  88. package/mechanisms/eslint/runner/README.md +43 -0
  89. package/mechanisms/eslint/runner/runner.js +4248 -0
  90. package/methods/README.md +18 -0
  91. package/methods/lenses/clean-architecture.md +167 -0
  92. package/methods/lenses/decomposition.md +159 -0
  93. package/methods/lenses/defended-on-intent.md +178 -0
  94. package/methods/lenses/di-discipline.md +156 -0
  95. package/methods/lenses/errors-as-data.md +88 -0
  96. package/methods/lenses/function-first.md +193 -0
  97. package/methods/lenses/naming.md +127 -0
  98. package/methods/lenses/test-discipline.md +166 -0
  99. package/methods/lenses/type-soundness.md +135 -0
  100. package/methods/lenses/zod-boundary.md +158 -0
  101. package/package.json +65 -4
  102. package/rules/CD-1/README.md +43 -0
  103. package/rules/CD-1/discipline.json +185 -0
  104. package/rules/CD-10/README.md +55 -0
  105. package/rules/CD-10/discipline.json +133 -0
  106. package/rules/CD-11/README.md +19 -0
  107. package/rules/CD-11/discipline.json +12 -0
  108. package/rules/CD-12/README.md +19 -0
  109. package/rules/CD-12/discipline.json +12 -0
  110. package/rules/CD-13/README.md +19 -0
  111. package/rules/CD-13/discipline.json +12 -0
  112. package/rules/CD-14/README.md +54 -0
  113. package/rules/CD-14/discipline.json +173 -0
  114. package/rules/CD-15/README.md +48 -0
  115. package/rules/CD-15/discipline.json +73 -0
  116. package/rules/CD-16/README.md +17 -0
  117. package/rules/CD-17/README.md +42 -0
  118. package/rules/CD-17/discipline.json +51 -0
  119. package/rules/CD-18/README.md +19 -0
  120. package/rules/CD-18/discipline.json +12 -0
  121. package/rules/CD-19/README.md +45 -0
  122. package/rules/CD-19/discipline.json +65 -0
  123. package/rules/CD-2/README.md +43 -0
  124. package/rules/CD-2/discipline.json +65 -0
  125. package/rules/CD-20/README.md +17 -0
  126. package/rules/CD-21/README.md +19 -0
  127. package/rules/CD-21/discipline.json +12 -0
  128. package/rules/CD-22/README.md +19 -0
  129. package/rules/CD-22/discipline.json +12 -0
  130. package/rules/CD-23/README.md +41 -0
  131. package/rules/CD-23/discipline.json +57 -0
  132. package/rules/CD-24/README.md +17 -0
  133. package/rules/CD-25/README.md +43 -0
  134. package/rules/CD-25/discipline.json +57 -0
  135. package/rules/CD-26/README.md +42 -0
  136. package/rules/CD-26/discipline.json +57 -0
  137. package/rules/CD-27/README.md +51 -0
  138. package/rules/CD-27/discipline.json +233 -0
  139. package/rules/CD-28/README.md +19 -0
  140. package/rules/CD-28/discipline.json +12 -0
  141. package/rules/CD-29/README.md +19 -0
  142. package/rules/CD-29/discipline.json +12 -0
  143. package/rules/CD-3/README.md +48 -0
  144. package/rules/CD-3/discipline.json +363 -0
  145. package/rules/CD-30/README.md +19 -0
  146. package/rules/CD-30/discipline.json +12 -0
  147. package/rules/CD-31/README.md +19 -0
  148. package/rules/CD-31/discipline.json +12 -0
  149. package/rules/CD-32/README.md +19 -0
  150. package/rules/CD-32/discipline.json +12 -0
  151. package/rules/CD-33/README.md +19 -0
  152. package/rules/CD-33/discipline.json +12 -0
  153. package/rules/CD-34/README.md +19 -0
  154. package/rules/CD-34/discipline.json +12 -0
  155. package/rules/CD-39/README.md +19 -0
  156. package/rules/CD-39/discipline.json +12 -0
  157. package/rules/CD-4/README.md +19 -0
  158. package/rules/CD-4/discipline.json +12 -0
  159. package/rules/CD-40/README.md +45 -0
  160. package/rules/CD-40/discipline.json +58 -0
  161. package/rules/CD-41/README.md +60 -0
  162. package/rules/CD-41/discipline.json +124 -0
  163. package/rules/CD-42/README.md +53 -0
  164. package/rules/CD-42/discipline.json +61 -0
  165. package/rules/CD-43/README.md +43 -0
  166. package/rules/CD-43/discipline.json +65 -0
  167. package/rules/CD-44/README.md +54 -0
  168. package/rules/CD-44/discipline.json +111 -0
  169. package/rules/CD-45/README.md +19 -0
  170. package/rules/CD-45/discipline.json +12 -0
  171. package/rules/CD-46/README.md +13 -0
  172. package/rules/CD-47/README.md +47 -0
  173. package/rules/CD-47/discipline.json +57 -0
  174. package/rules/CD-5/README.md +46 -0
  175. package/rules/CD-5/discipline.json +65 -0
  176. package/rules/CD-6/README.md +57 -0
  177. package/rules/CD-6/discipline.json +165 -0
  178. package/rules/CD-7/README.md +52 -0
  179. package/rules/CD-7/discipline.json +142 -0
  180. package/rules/CD-7a/README.md +44 -0
  181. package/rules/CD-7a/discipline.json +57 -0
  182. package/rules/CD-8/README.md +48 -0
  183. package/rules/CD-8/discipline.json +57 -0
  184. package/rules/CD-9/README.md +19 -0
  185. package/rules/CD-9/discipline.json +12 -0
  186. package/rules/README.md +52 -0
package/ADOPTING.md ADDED
@@ -0,0 +1,314 @@
1
+ # Adopting Hone
2
+
3
+ This page takes a TypeScript repository from nothing to a checked, passing run. Do the steps in order. Every command is run from the root of the repository being checked, which this page calls `<repo>`. Nothing here needs AIDLC or any agent harness. A repository that adopted the disciplines through the older standalone copy route follows [MIGRATING.md](MIGRATING.md), which uses these steps.
4
+
5
+ Hone reads `disciplines.json` in `<repo>`, runs the selected disciplines' checks over every git-tracked file, applies the exceptions in `discipline-exceptions.json`, and prints one report ending in `verdict: pass` or `verdict: fail`.
6
+
7
+ ## 1. Check the prerequisites
8
+
9
+ ```bash
10
+ node --version
11
+ ```
12
+
13
+ It must print `v22.13.0` or a later 22.x, or `v24.0.0` or later. A rule set of your own whose piece modules are `.ts` files needs Node 22.18.0 or later, because Hone loads those modules as they are. Also needed: git 2.24 or later and npm. `<repo>` must be a git repository, and the files to check must be committed or staged: untracked files are not checked.
14
+
15
+ ## 2. Install the Hone package
16
+
17
+ Hone ships as one npm package tarball: built JavaScript with its own packages bundled in, so it has no dependencies of its own and needs no TypeScript support from Node.
18
+
19
+ **The npm package is named `@hailstails/hone`.** The unscoped name `hone` on npm belongs to an unrelated package: never run `npm install hone`. The package `@hailstails/hone` installs one command, `hone`. Its tarball is named `hailstails-hone-<version>.tgz`, the file name `npm pack` gives a scoped package. Version `0.1.0-pre.1` was released under the old name `honed`; [MIGRATING.md](MIGRATING.md#11-moving-from-honed-to-hailstailshone) says how to move from it.
20
+
21
+ The current version, `0.1.0-pre.2`, is a pre-release: its commands, flags and files may still change before `0.1.0`. This page writes the tarball's location as `<hone-tarball>`: a path such as `vendor/hailstails-hone/hailstails-hone-0.1.0-pre.2.tgz`, or an `https://` URL your team serves it from.
22
+
23
+ The main route is to download `hailstails-hone-0.1.0-pre.2.tgz` from the [`v0.1.0-pre.2` GitHub release](https://github.com/HailsTails/hone/releases/tag/v0.1.0-pre.2), which the release workflow creates, marked as a pre-release, when the tag `v0.1.0-pre.2` is pushed. Until that tag exists, build the tarball from a pinned commit as below; the earlier [`v0.1.0-pre.1` release](https://github.com/HailsTails/hone/releases/tag/v0.1.0-pre.1) holds the previous pre-release under the old name `honed`.
24
+
25
+ The alternative is to build the tarball yourself from a pinned commit. Install [bun](https://bun.sh) and pick the commit to pin, such as the latest on [`main`](https://github.com/HailsTails/hone/commits/main). Then run, with that commit's SHA in place of `<pinned-sha>`:
26
+
27
+ ```bash
28
+ git clone -c core.longpaths=true https://github.com/HailsTails/hone.git /tmp/hone-source
29
+ git -C /tmp/hone-source checkout <pinned-sha>
30
+ cd /tmp/hone-source && bun install --frozen-lockfile && bun run pack-package && cd -
31
+ ```
32
+
33
+ The last command prints `pack package: wrote <path>/artefacts/hailstails-hone-0.1.0-pre.2.tgz`. Copy the downloaded or built tarball into `<repo>/vendor/hailstails-hone/` and commit it with a message naming the release tag or the pinned SHA, so every teammate and CI runner installs the same bytes. The commands in this guide are POSIX shell; on Windows run them in Git Bash.
34
+
35
+ Install it as a development dependency of the repository root, beside the toolchain:
36
+
37
+ ```bash
38
+ npm install --save-dev <hone-tarball>
39
+ ```
40
+
41
+ npm records it in `package.json` and the lockfile. With pnpm or Yarn, add the same tarball with their own `add -D` command at the workspace root.
42
+
43
+ After the first registry publish of `@hailstails/hone`, the registry is a third route, with no tarball to copy or commit. Pre-releases are published under the dist-tag `next`, so name it:
44
+
45
+ ```bash
46
+ npm install --save-dev @hailstails/hone@next
47
+ ```
48
+
49
+ npm records the exact version it installed in the lockfile. Check the name before you run it: `@hailstails/hone`, never the unscoped `hone`. Until that first publish, npm answers this command with `404 Not Found`; use one of the tarball routes above.
50
+
51
+ Add the two commands to the root `package.json` scripts:
52
+
53
+ ```json
54
+ "scripts": {
55
+ "hone:check": "hone check --repo .",
56
+ "hone:project": "hone project --repo ."
57
+ }
58
+ ```
59
+
60
+ `hone` is the package's one command, with two subcommands: `hone check` runs the check and `hone project` writes the ESLint projection. `hone` with no subcommand, or with any other, exits `2` with a `load failure: arguments-invalid` line that prints the usage.
61
+
62
+ Hone runs on the toolchain the repository already uses, which the package declares as peer dependencies: `typescript` is a required peer, because every `audit` clause needs it, and the ESLint packages are optional peers, needed only for `eslint` clauses. npm 7 and later install a missing required peer on their own, and some other package managers only warn about one, so declare `typescript` yourself at the repository root, at the version the repository already uses, rather than let the package manager choose or skip it. Keep the versions you have; Hone supports these ranges:
63
+
64
+ | Package | Needed for | Range |
65
+ | --- | --- | --- |
66
+ | `typescript` | any `audit` clause | `>=4.8.4 <7.0.0` |
67
+ | `eslint` | any `eslint` clause | `^9.12.0 \|\| ^10.0.0` |
68
+ | `@typescript-eslint/parser` | any `eslint` clause | `^8.56.0` |
69
+ | `@typescript-eslint/eslint-plugin` | any `eslint` clause | `^8.56.0` |
70
+
71
+ A repository that already has them in range needs nothing more. A package that is missing or out of range is named when the check runs; add it at a version inside its range and inside the range your other tooling accepts, without moving ESLint or TypeScript to another major for Hone's sake.
72
+
73
+ Hone finds these by Node's resolution upward from where the package is installed, so in a monorepo they must resolve from the repository root: declare them in the root `package.json` (with pnpm, `pnpm add -Dw` at the versions the packages already use), even where packages also declare their own. Yarn Plug'n'Play is not supported, because Hone resolves the toolchain through `node_modules`.
74
+
75
+ Commit `package.json`, the lockfile and the tarball if it is a file in the repository. To update later, repeat this step with a newer tarball.
76
+
77
+ ## 3. Read what each discipline means
78
+
79
+ [rules/README.md](rules/README.md) lists every discipline. Each `rules/<ID>/README.md` quotes the rule, says exactly what its check flags, shows a violation and its fix, and says how to record an exception. A discipline's clause addresses are in its README's Clauses table, for example `CD-14#class-syntax`, with the mechanism that checks each clause. A clause whose mechanism is `review` is a judgement clause: it is applied in review, not by a check, with the review lens the page names (step 9).
80
+
81
+ A check covers only what its page says it flags. Read the whole rule, not only the Clauses table: where a rule asks for more than its check can see, the page says which part is left to review, and the page's review lens covers that part.
82
+
83
+ Where to start: for an API, boundary validation (CD-4, CD-45), result-shaped failures (CD-9, CD-10, CD-11) and inward dependency direction (CD-12, CD-13) are useful next selections, most of them judgement rules. For React, first select the type and test disciplines that apply to component code; do not apply server ports or process-lifecycle rules to browser code.
84
+
85
+ ## 4. Write disciplines.json
86
+
87
+ Create `<repo>/disciplines.json`. Map every clause you adopt to the mechanism that checks it:
88
+
89
+ ```json
90
+ {
91
+ "version": 1,
92
+ "ruleSets": {},
93
+ "clauses": {
94
+ "CD-15#loops": "audit",
95
+ "CD-17#clock-sources": "audit",
96
+ "CD-23#export-test-sibling": "audit"
97
+ }
98
+ }
99
+ ```
100
+
101
+ - `clauses` keys are clause addresses from the rules pages; the value is a mechanism the clause's rules page lists, `audit` or `eslint`.
102
+ - Selecting one clause of a discipline adopts the whole discipline: any of its other mechanical clauses you leave out are reported as `uncovered` and fail the run. CD-3 has seven clauses; select all seven or none.
103
+ - A discipline may span mechanisms; adopt every mechanical clause through the mechanism that has it, or the discipline reports the rest uncovered. CD-14, for example, checks `class-syntax` through `audit` or `eslint` but `static-only-class` only through `eslint`, so adopting CD-14 means adopting the ESLint mechanism for at least that clause; see [README.md](README.md#adopting-the-eslint-mechanism). To defer such a clause, still list it with its mechanism and record a `clause-wide-carve-out` for it (step 7).
104
+ - `exclude` lists folders or exact files, as repository paths with forward slashes; an entry containing `*` is refused, because globs are not supported. A folder entry excludes everything under it. Use it for generated or third-party code. `node_modules`, `dist`, `build`, `coverage`, `.git` and a top-level `vendor` folder are skipped already.
105
+ - `ruleSets` stays `{}` unless you write disciplines of your own; see [docs/adding-a-discipline-or-mechanism.md](docs/adding-a-discipline-or-mechanism.md).
106
+
107
+ Every clause address Hone ships:
108
+
109
+ ```text
110
+ audit:
111
+ CD-1#any-cast CD-2#cast-expressions CD-5#comments-directives
112
+ CD-6#identifier-names CD-7#categorical-paths CD-7a#factory-return-types
113
+ CD-8#switch-defaults CD-10#throws-in-tests CD-14#class-syntax
114
+ CD-15#loops CD-17#clock-sources CD-19#import-boundaries
115
+ CD-23#export-test-sibling CD-25#dependency-isolation
116
+ CD-26#module-mocking CD-27#test-body-logic CD-43#boolean-signatures
117
+ CD-44#parameter-mutation CD-47#hermetic-git-spawns
118
+ CD-3#strict CD-3#no-unchecked-indexed-access CD-3#exact-optional-property-types
119
+ CD-3#no-implicit-override CD-3#no-fallthrough-cases-in-switch
120
+ CD-3#no-property-access-from-index-signature CD-3#use-unknown-in-catch-variables
121
+
122
+ eslint:
123
+ CD-1#explicit-any CD-1#implicit-any-let CD-6#naming-convention
124
+ CD-7#filename-case CD-10#throw-only-error CD-14#class-syntax
125
+ CD-14#static-only-class CD-27#focused-tests CD-27#skipped-tests
126
+ CD-40#parameter-count CD-41#cognitive-complexity CD-41#function-length
127
+ CD-42#useless-else CD-44#parameter-reassignment
128
+ ```
129
+
130
+ CD-1, CD-6, CD-7, CD-10, CD-14, CD-27 and CD-44 have clauses under both mechanisms, and CD-40, CD-41 and CD-42 only under `eslint`, so adopting any of them needs the ESLint mechanism.
131
+
132
+ Starting with a few disciplines and adding more once the run passes is easier than fixing everything at once.
133
+
134
+ ### 4a. Set up ESLint for `eslint` clauses
135
+
136
+ Skip this if every selected clause is `audit`. Otherwise, after writing `disciplines.json`, write the ESLint projection:
137
+
138
+ ```bash
139
+ npm run --silent hone:project
140
+ ```
141
+
142
+ It prints `disciplines.eslint.mjs written`. Spread its default export last in the repository's flat config. A repository with no ESLint config yet can start from this `eslint.config.mjs`:
143
+
144
+ ```js
145
+ import projection from "./disciplines.eslint.mjs";
146
+
147
+ export default [
148
+ { files: ["**/*.{ts,tsx,mts,cts}"] },
149
+ ...projection,
150
+ ];
151
+ ```
152
+
153
+ In a monorepo, every `eslint.config.*` that applies to checked files spreads the projection last. Hone detects which config the team's ESLint run applies from the installed `eslint` version and the lint scripts; see [README.md](README.md#runtime). Detection is wrong when a task runner (turbo, nx, `pnpm -r`) starts ESLint 9 inside each package, because each package then uses its own config, and when ESLint 9 gets the lookup flag outside the scripts. In those repositories set the lookup in `disciplines.json`:
154
+
155
+ ```json
156
+ { "eslintConfigLookup": "nearest-to-file" }
157
+ ```
158
+
159
+ Use `"nearest-to-file"` when ESLint runs per package, with ESLint 10, or with ESLint 9 and `--flag v10_config_lookup_from_file` (on 9.12 to 9.29, `--flag unstable_config_lookup_from_file`). Use `"repository-root"` for one ESLint 9 run from the repository root, whose root `eslint.config.*` then applies to every file. To confirm the setting, lint a package file the way the team does (for example `pnpm exec eslint packages/a/src/x.ts` from where the lint script runs) and check that it reports the same finding the Hone check lists for that file.
160
+
161
+ Commit both files. Hone's check reads this configuration and fails if the projection is missing, not in effect, or out of date, so re-run `hone:project` whenever `disciplines.json` or `discipline-exceptions.json` changes or Hone is updated. The projection imports each piece from the package by name, for example `@hailstails/hone/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js`, so the repository's ESLint must resolve `@hailstails/hone` from the repository root. Hone's own ESLint run uses the repository's root `eslint` from step 2, the same copy the projection's pieces load; its verdict is the same on 9.x and 10.x. [README.md](README.md#adopting-the-eslint-mechanism) has the details.
162
+
163
+ ## 5. Run the check
164
+
165
+ ```bash
166
+ npm run --silent hone:check
167
+ ```
168
+
169
+ | Exit code | Meaning |
170
+ | --- | --- |
171
+ | `0` | `verdict: pass` |
172
+ | `1` | `verdict: fail`: the report says why |
173
+ | `2` | an input could not be loaded or a check crashed; the output is one line starting `load failure:` or names the failing piece |
174
+
175
+ `npm run` passes the exit code through. `sh: hone: not found` or `'hone' is not recognized` means step 2's install is missing; run `npm install`. A `load failure: runner-failed <mechanism> toolchain-unavailable <package> ...` line names a toolchain package that is missing from the repository root or outside its range; install a version in the range it prints. For a `typescript` that is not installed, the line says the install is incomplete, since a supported install always has its required peer: add `typescript` to the root's `devDependencies` and reinstall. A `toolchain-shadowed <package> resolved from ...` line means a copy of that package sits inside Hone's own install folder, which the line names: delete that `node_modules` folder and reinstall.
176
+
177
+ In CI, pass the branch's base so that debt recorded per file is forfeited once that file changes:
178
+
179
+ ```bash
180
+ npm run --silent hone:check -- --base-revision origin/main
181
+ ```
182
+
183
+ Add the command to the repository's existing validation script, and run that same script in CI and in any pre-push hook the repository already has, so the check runs wherever the other checks run. With `eslint` clauses, the repository's own `eslint` run also reports them in the editor, from the projection.
184
+
185
+ Tell any coding agent working in the repository, in its project instructions: "Read the rule pages under `node_modules/@hailstails/hone/rules/` for the disciplines in `disciplines.json` before editing. Before handing off, run the repository's validation command, report its exit code and findings, and apply the judgement rules listed in this file with their review lenses." Copying the rule pages does not make an agent read them; the instruction does.
186
+
187
+ ## 6. Read the report
188
+
189
+ The report prints only the sections that have entries, each with its count, then the verdict. A finding line is:
190
+
191
+ ```text
192
+ <clause> <mechanism> <file>:<line>:<column> <snippet>
193
+ CD-15#loops audit src/basket.ts:15:0 for (const line of this.lines) {
194
+ ```
195
+
196
+ Lines are 1-based and columns 0-based. The run passes only when every section except `excluded` and `exempted` is empty. The sections are:
197
+
198
+ | Section | Meaning and what to do |
199
+ | --- | --- |
200
+ | `excluded` | the `exclude` entries from `disciplines.json` that were left out of the run; informational, check it is what you meant |
201
+ | `findings` | violations: fix the code, or record an exception (step 7) |
202
+ | `exempted` | findings an exception covers; informational |
203
+ | `uncovered` | a mechanical clause of an adopted discipline is not selected: add it to `disciplines.json` |
204
+ | `stale` | an exception that no longer exempts anything: delete it |
205
+ | `forfeited` | a file carve-out whose file changed since `--base-revision`: fix the file and delete the carve-out |
206
+ | `invalidRecords` | an exception entry that cannot be accepted, with the reason: correct it |
207
+ | `doublyHeld` | a file both authorised and carved out for one clause: keep one |
208
+ | `unmeasured` | something could not be measured, for example `forfeiture-unmeasured` when file carve-outs exist and no `--base-revision` was given |
209
+
210
+ To print less, set `"reportOutput"` in `disciplines.json` for the repository, or pass `--report-output <output>` for one run, which wins over the file. `full` is the default and prints the report above; `failures-only` leaves out `excluded` and `exempted`; `counts` prints only each section's heading and count, adding `informational` after `excluded` and `exempted` so every other line names a section that failed the run; `verdict-only` prints only the verdict line. Every output ends in the verdict line, and the exit code is the same whichever output you choose. An unknown value fails the run with exit `2`, as `arguments-invalid` for the option or `file-malformed` for the file.
211
+
212
+ ## 7. Record exceptions
213
+
214
+ Fix findings where you can. Where a file legitimately needs what a clause forbids, record it in `<repo>/discipline-exceptions.json`:
215
+
216
+ - `authorised-location`: the clause does not apply to this one file, for example the single adapter that reads the real clock.
217
+ - `file-carve-out`: known debt in one file. It is forfeited, and fails the run, as soon as that file changes since `--base-revision`.
218
+ - `clause-wide-carve-out`: the clause is waived everywhere. Not selecting the clause is not an alternative: it leaves the clause `uncovered`. A clause-wide carve-out that exempts no finding is `stale`, so record one only while the clause still has findings.
219
+
220
+ Every entry needs a `reason`. By default every entry also needs a `whyChain` shaped like this, with exactly five steps in `whys`:
221
+
222
+ ```json
223
+ "whyChain": {
224
+ "whys": [
225
+ { "why": "...", "because": "...", "evidence": "..." },
226
+ { "why": "...", "because": "...", "evidence": "..." },
227
+ { "why": "...", "because": "...", "evidence": "..." },
228
+ { "why": "...", "because": "...", "evidence": "..." },
229
+ { "why": "...", "because": "...", "evidence": "..." }
230
+ ],
231
+ "rootCause": "...",
232
+ "rootCheck": "...",
233
+ "readback": "...",
234
+ "owner": "..."
235
+ }
236
+ ```
237
+
238
+ The chain runs cause to cause: each why asks why the answer before it is true, each answer cites evidence that can be checked again, the root names the fifth answer's cause and is checked against today, and the readback runs back from the root to the symptom with "therefore". [The why-chain contract](docs/why-chain-contract.md) has a worked example, the checks Hone runs, and what review still judges. A chain that breaks a check is refused as an `invalidRecords` entry. `file` is an exact repository path.
239
+
240
+ Debt or authorisations already recorded by an earlier system, for example the old standalone route's `.constitution-carve-outs/`, can be imported with `provenance` instead of a `whyChain`, as [MIGRATING.md](MIGRATING.md#3-convert-the-old-records-into-exceptions) step 3 shows. Imported entries are checked against `--base-revision`: by default, any entry you write or change yourself needs the full `whyChain`.
241
+
242
+ To record existing debt without a chain on every entry, set `"fileExceptionWhyChains": "optional"` in `disciplines.json`. An `authorised-location` or `file-carve-out` entry may then give only its `reason`, so write the reason as why the exception exists; a blank reason is refused. A run with any file carve-out still needs `--base-revision`, or it reports `forfeiture-unmeasured` and fails. A `clause-wide-carve-out` still needs its `whyChain`, and a `whyChain` or `provenance` you give anyway is still checked. [README.md](README.md#discipline-exceptionsjson) has the details.
243
+
244
+ ## 8. Prove one failure and correction
245
+
246
+ Before relying on the check, prove that it fails on a real violation in your repository and passes once it is fixed. With CD-17 selected, create `src/discipline-probe.ts` (any path the check covers) containing exactly:
247
+
248
+ ```ts
249
+ const probeStartedAt = Date.now();
250
+ ```
251
+
252
+ Stage it, since only tracked files are checked, and run the check:
253
+
254
+ ```bash
255
+ git add src/discipline-probe.ts
256
+ npm run --silent hone:check
257
+ ```
258
+
259
+ It must exit `1` with the line `CD-17#clock-sources audit src/discipline-probe.ts:1:0 const probeStartedAt = Date.now();` among its findings. Change the same file to `const probeStartedAt = 0;`, stage it, and run the check again: that finding must be gone. Then remove the probe with `git rm -f src/discipline-probe.ts`. A run that never showed the finding proves nothing: check that the file was staged and is not under an `exclude` entry. For another discipline, take a flag case from its `rules/<ID>/discipline.json`.
260
+
261
+ ## 9. Apply the judgement rules
262
+
263
+ A judgement clause cannot be selected in `disciplines.json`, and no check reports it. Write down which judgement rules the repository adopts, in the project instructions beside `disciplines.json`, so reviewers and agents know to apply them.
264
+
265
+ Each rule page names its review lens, a method under [methods/lenses/](methods/README.md) for reading code against that kind of rule. To review a change, by a human reviewer or a coding agent:
266
+
267
+ 1. The reviewer is not the change's author. An agent reviewing a change reads files only; it does not edit them.
268
+ 2. Pin the tree under review to a commit and review that.
269
+ 3. Run each lens on its own, one concern at a time, without seeing the other lenses' findings. Follow the lens file: load the rule pages that name it, inspect the change as it says, and report findings in its output shape, citing the clause address. A lens covers mechanical rules too, beyond what their checks flag.
270
+ 4. Run [defended-on-intent](methods/lenses/defended-on-intent.md) last, over the rule text and the other lenses' findings, to catch changes that meet a rule's letter but defeat its intent.
271
+ 5. Fix each finding. A deliberate departure from a judgement rule is recorded where the review decision is kept, with a `whyChain` in the same shape as step 7.
272
+
273
+ To use an agent, give it the lens file, the rule pages it names, the change and the pinned commit, and ask it to follow the lens exactly. A single reviewer covering every concern at once misses what separate lenses catch.
274
+
275
+ ## 10. Update and remove
276
+
277
+ To update, repeat step 2 on a branch with a tarball built from a newer pinned SHA, compare the installed rule pages under `node_modules/@hailstails/hone/rules/` with the old ones, re-run `hone:project` if any clause is `eslint`, run the check, and commit with a message naming the new SHA. Rule text can change between pins, so read the changed pages. Before updating to a pin that has the causal why-chain contract, follow [MIGRATING.md section 8](MIGRATING.md#8-moving-to-causal-why-chains): pass `--base-revision` first, or the update's check reports `legacy-chain-unmeasured`.
278
+
279
+ To remove, run `npm uninstall @hailstails/hone`, delete the two `hone:` scripts, the tarball, `disciplines.json`, `discipline-exceptions.json` and, with `eslint` clauses, `disciplines.eslint.mjs` and its spread in the flat config, and take the check out of the validation script.
280
+
281
+ ## Worked example
282
+
283
+ In the Hone source repository, `tests/test-fixtures/walkthrough/` is a small repository before and after its fix, selecting CD-2, CD-15, CD-17 and CD-23 through the audit, with a `generated/` folder excluded. `tests/walkthrough.integration.test.ts` pins both reports exactly.
284
+
285
+ Before, `npm run --silent hone:check` prints, and exits `1`:
286
+
287
+ ```text
288
+ excluded (1)
289
+ generated
290
+ findings (5)
291
+ CD-17#clock-sources audit src/basket.ts:7:0 private openedAt = Date.now();
292
+ CD-2#cast-expressions audit src/basket.ts:10:20 entry as Line); } total(): string { let pence = 0; for (const line …
293
+ CD-15#loops audit src/basket.ts:15:0 for (const line of this.lines) {
294
+ CD-17#clock-sources audit src/basket.ts:22:0 return Date.now() - this.openedAt;
295
+ CD-23#export-test-sibling audit src/utils/format.ts:1:0 missing co-located *.test.ts(x) sibling
296
+ verdict: fail
297
+ ```
298
+
299
+ The fix replaces the `Basket` class with functions over a readonly `Basket` value, sums with `reduce`, takes the time from an injected `Clock`, types the input instead of casting it, moves `src/utils/format.ts` to `src/format.ts` with a `src/format.test.ts` sibling, and records `src/clock.ts`, the one adapter that reads `Date.now()`, as an authorised location. After, the same command prints, and exits `0`:
300
+
301
+ ```text
302
+ excluded (1)
303
+ generated
304
+ exempted (1)
305
+ CD-17#clock-sources audit src/clock.ts:3:0 export const createSystemClock = (): Clock => ({ now: () => Date.now() }); exempted by authorised-location
306
+ verdict: pass
307
+ ```
308
+
309
+ ## Known gaps
310
+
311
+ - The worked example uses only the audit mechanism. The ESLint consumer in `tests/test-fixtures/consumer-proof/eslint/` is the tested ESLint setup.
312
+ - Each check flags exactly what its rules page says and no more. Where a rule asks for more than its check can see, the page says which part is left to review.
313
+ - A snippet is the text the check reports; some checks report a fixed-width window that runs across lines, as CD-2 does above.
314
+ - The disciplines' IDs and rule text come from one team's code-discipline set. Selecting a subset is supported; editing a shipped rule is not. Write your own rule set for different rules.
package/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ MIT No Attribution
2
+
3
+ Copyright 2026 Helen G
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so.
10
+
11
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
13
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
14
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
15
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
16
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
+
package/MIGRATING.md ADDED
@@ -0,0 +1,238 @@
1
+ # Migrating from the standalone copy route
2
+
3
+ This page moves a repository from the older standalone route, which copied rule files into a harness folder and wired selected linter rules by hand, to Hone. Follow the steps in order. Every command is run from the repository root. Stop at any "stop and ask" line and hand the question to the human; do not guess past it.
4
+
5
+ A repository already on Hone, or on discipline Hone before the rename, whose exceptions predate causal why-chains needs only [section 8](#8-moving-to-causal-why-chains).
6
+
7
+ ## 1. Detect the old install
8
+
9
+ Look for each of these and write down what you find:
10
+
11
+ | What | Where | Example |
12
+ | --- | --- | --- |
13
+ | Copied rule files | `.claude/`, `.codex/` or `.cursor/` under `knowledge/aidlc-shared/code-discipline/` | `.cursor/knowledge/aidlc-shared/code-discipline/cd-001-no-any.md` |
14
+ | Copied guides | the same folder | `standalone-adoption.md`, `standalone-cd-inventory.md`, `standalone-linter-options.md` |
15
+ | Copied tools tree | `.claude/tools/`, `.codex/tools/` or `.cursor/tools/` | `.cursor/tools/rin-harness-constitution-audit.ts` |
16
+ | Tool config | repository root | `harness.config.json` |
17
+ | Debt records | repository root | `.constitution-carve-outs/cd-<id>.json` |
18
+ | Structural records | repository root | `.constitution-authorised-locations/cd-<id>.json` |
19
+ | Hand-written linter rules | `biome.json`, `eslint.config.*`, `.oxlintrc.json` | `noExplicitAny`, `@typescript-eslint/no-explicit-any`, `typescript/no-explicit-any` |
20
+ | Compiler flags | every `tsconfig*.json` | the seven CD-3 flags |
21
+ | Scripts and hooks | `package.json` scripts, CI workflow, pre-push hook | `bun .cursor/tools/rin-harness-constitution-audit.ts`, `rin-harness-carve-out-decay.ts`, `rin-harness-hermetic-git-guard.ts` |
22
+ | Agent instructions | `AGENTS.md`, `CLAUDE.md`, `.cursor/rules/`, an adoption record | "read the selected discipline files before editing" |
23
+
24
+ The chosen disciplines are the `cd-NNN-*.md` files that were copied (CD-1, CD-3 and CD-46 in the old quick start), plus any CD named in a record file.
25
+
26
+ A CD that a record file names but whose rule file was not copied (for example CD-15, when only CD-1, CD-3 and CD-46 were copied) is expected: select it in step 2 like the others. Stop and ask the human only if a named CD is one of CD-35 to CD-38.
27
+
28
+ Old code often holds CD-1 `any` the old route never checked. Hone flags it in step 3; it is new debt, so fix it or record it only after the human approves (step 3), and any further `any` still fails.
29
+
30
+ ## 2. Install Hone and select the clauses
31
+
32
+ Do [ADOPTING.md](ADOPTING.md) steps 1, 2 and 4 (and 4a for any `eslint` clause). A repository that used only Biome has no `eslint.config.*`: create `eslint.config.mjs` as step 4a shows before the first check, or the check stops with `runner-failed eslint team-config-unloadable`. Leave the old files in place until step 6.
33
+
34
+ Map each chosen discipline to its clauses with this table. A discipline is adopted whole: select every mechanical clause it lists, or the check reports the rest as `uncovered`.
35
+
36
+ | Old CD | Clauses to select in `disciplines.json` |
37
+ | --- | --- |
38
+ | CD-1 | `CD-1#any-cast` audit, `CD-1#explicit-any` eslint, `CD-1#implicit-any-let` eslint |
39
+ | CD-3 | all seven `CD-3#...` clauses, audit; then move the flags out of `tsconfig.json` (step 4) |
40
+ | CD-46 | nothing to select: it applies to every file carve-out once the check runs with `--base-revision` |
41
+ | CD-16, CD-20, CD-24 | select their owners, CD-15, CD-19 and CD-23 |
42
+ | CD-35, CD-36, CD-37, CD-38 | not in Hone; keep their current handling |
43
+ | any other CD | every mechanical clause in `node_modules/@hailstails/hone/rules/<ID>/README.md`'s Clauses table, with a mechanism that table lists |
44
+
45
+ Clauses whose mechanism is `review` are judgement clauses: do not put them in `disciplines.json`; list them in the agent instructions instead (step 6).
46
+
47
+ Stop and ask the human if a chosen CD is one of CD-35 to CD-38, or if selecting a whole discipline adds clauses the old route never checked and the first run shows findings for them: they decide whether to fix those findings, carve them out (step 3), or not adopt that discipline yet.
48
+
49
+ ## 3. Convert the old records into exceptions
50
+
51
+ Run the check once with no exceptions file, to see what Hone finds:
52
+
53
+ ```bash
54
+ npm run --silent hone:check
55
+ ```
56
+
57
+ CD-3 findings on `tsconfig.json` are fixed in step 4, not recorded. Then write `discipline-exceptions.json` from the old records, using the format in [README.md](README.md#discipline-exceptionsjson):
58
+
59
+ An old record file is a JSON array of entries, each listing one or more files:
60
+
61
+ ```json
62
+ [
63
+ {
64
+ "files": ["src/legacy.ts", "src/legacy-report.ts"],
65
+ "reason": "Inherited for...of totals loop from the 2025 pricing import",
66
+ "decision": "Initial adoption inventory accepted by pricing owner Sam on 2026-09-02; retire on touch"
67
+ }
68
+ ]
69
+ ```
70
+
71
+ - Each file in a `.constitution-carve-outs/cd-<id>.json` entry that Hone now flags becomes one `file-carve-out`: `clause` is the clause the finding names (for example `CD-15#loops`), `file` is the exact path. Two flagged files in one entry become two records with the same `source`.
72
+ - Each file in a `.constitution-authorised-locations/cd-<id>.json` entry that Hone now flags becomes one `authorised-location`.
73
+ - A listed file Hone does not flag gets no record: a record that exempts nothing is reported `stale` and fails the run.
74
+ - A finding in a file no old record lists is new debt: fix it, or record it only after the human approves.
75
+
76
+ Each converted record is imported: give it `provenance` naming the old record instead of a `whyChain`, and keep the old `reason`:
77
+
78
+ ```json
79
+ {
80
+ "kind": "file-carve-out",
81
+ "clause": "CD-15#loops",
82
+ "file": "src/legacy.ts",
83
+ "reason": "Inherited for...of totals loop from the 2025 pricing import",
84
+ "provenance": {
85
+ "kind": "inherited-debt",
86
+ "source": ".constitution-carve-outs/cd-15.json#0",
87
+ "decision": "Initial adoption inventory accepted by pricing owner Sam on 2026-09-02; retire on touch"
88
+ }
89
+ }
90
+ ```
91
+
92
+ `source` is the old file and the entry's position in its array, counting from `0`, so both files in the example above use `.constitution-carve-outs/cd-15.json#0`. An authorised location uses `{ "kind": "existing-authorisation", "source": ".constitution-authorised-locations/cd-<id>.json#<index>" }`. Hone accepts an imported record only while the `--base-revision` holds it unchanged or its `source` entry lists the record's file at that revision, so keep the old record files committed until step 6, and run every check in this migration with `--base-revision HEAD`. A record you write for new debt, or an imported record you later change, needs a full `whyChain` that follows the [why-chain contract](docs/why-chain-contract.md): Hone refuses it as `import-unverified` otherwise. A repository whose `disciplines.json` sets `"fileExceptionWhyChains": "optional"` may instead give such an `authorised-location` or `file-carve-out` only its `reason`, with no `whyChain` and no `provenance`.
93
+
94
+ Stop and ask the human if an old record has no `decision`. Never write a placeholder or a root cause that only says the check was failing: Hone refuses those as `invalidRecords`.
95
+
96
+ ## 4. Replace the hand-written linter rules
97
+
98
+ The ESLint projection from step 2 now carries every `eslint` clause. Remove only the rules the old route added for the disciplines; keep every other rule the repository uses:
99
+
100
+ - `biome.json`: remove `suspicious.noExplicitAny` and `suspicious.noImplicitAnyLet`. If nothing else in the file was added for the trial, remove the file, the `@biomejs/biome` dev dependency the old quick start installed and the `package.json` script that ran `biome lint` (step 6 replaces it); otherwise keep it for its other rules.
101
+ - `eslint.config.*`: remove `@typescript-eslint/no-explicit-any` (and any other rule the old route added for a CD), and spread the projection last as [ADOPTING.md](ADOPTING.md#4a-set-up-eslint-for-eslint-clauses) shows.
102
+ - `.oxlintrc.json`: remove `typescript/no-explicit-any`; remove the file if it held nothing else.
103
+ - CD-3: Hone flags any of the seven strict flags written in a file named `tsconfig.json`, even when it is `true`, because the flags must be inherited, never set per project. Move them from every `tsconfig.json` into one shared base file with another name, for example `tsconfig.base.json`, and make each `tsconfig.json` extend it (`"extends": "./tsconfig.base.json"`). Keep every other compiler option where it is. Then run the repository's own typecheck, which must still pass.
104
+
105
+ Then re-run `hone:project` and the check. With any `file-carve-out` recorded, pass `--base-revision`: without it Hone cannot tell whether a carved file was touched, reports `forfeiture-unmeasured` and fails. Locally, `HEAD` measures what is already committed:
106
+
107
+ ```bash
108
+ npm run --silent hone:project
109
+ npm run --silent hone:check -- --base-revision HEAD
110
+ ```
111
+
112
+ Stop and ask the human if a rule you are about to remove was there before the trial, or if you cannot tell which rules the trial added (the adoption record or `git log -p -- biome.json` usually says).
113
+
114
+ ## 5. Prove the migration
115
+
116
+ Prove one failure per mechanism, then the correction. Create these two files, stage them (only tracked files are checked), and run the check with `--base-revision HEAD`:
117
+
118
+ ```ts
119
+ // src/discipline-probe-loop.ts
120
+ export const probeTotal = (prices: readonly number[]): number => {
121
+ let sum = 0;
122
+ for (const price of prices) {
123
+ sum += price;
124
+ }
125
+ return sum;
126
+ };
127
+ ```
128
+
129
+ ```ts
130
+ // src/discipline-probe-any.ts
131
+ export const probeValue: any = 1;
132
+ ```
133
+
134
+ ```bash
135
+ git add src/discipline-probe-loop.ts src/discipline-probe-any.ts
136
+ npm run --silent hone:check -- --base-revision HEAD
137
+ ```
138
+
139
+ It must print a `CD-15#loops audit` finding and a `CD-1#explicit-any eslint` finding, then `verdict: fail`, and exit `1`. Use a selected clause in place of either if the repository did not adopt CD-15 or CD-1. Then remove both files (`git rm -f src/discipline-probe-loop.ts src/discipline-probe-any.ts`) and run the check again: it must print `verdict: pass` and exit `0`.
140
+
141
+ To see debt decay, change one line in a carved file, stage it and run the check: the record moves to `forfeited` and the run fails. Restore the file afterwards (`git restore --staged --worktree <file>`).
142
+
143
+ Stop here, do not remove anything, and ask the human if the check does not pass.
144
+
145
+ ## 6. Remove the old route and repoint everything
146
+
147
+ Only after step 5 passes:
148
+
149
+ 1. Delete the copied rule files and guides from step 1's harness folder (`.cursor/knowledge/aidlc-shared/code-discipline/` or its `.claude`/`.codex` equivalent).
150
+ 2. Delete the copied tools tree and `harness.config.json`, unless anything else in the repository uses them. A repository that also runs the rin AIDLC plugin keeps `harness.config.json`, and in this same change sets `"constitution": { "engine": "discipline-core", "baseRevision": "origin/main" }` in it. Otherwise rin's stage gate, sensors and review lenses keep running the old walker over the old records, and they refuse what this check passes. Set `baseRevision` whenever a file carve-out or an imported entry exists.
151
+ 3. Delete `.constitution-carve-outs/` and `.constitution-authorised-locations/`: their content now lives in `discipline-exceptions.json`.
152
+ 4. In `package.json` scripts, CI and the pre-push hook, replace the old tool commands with the Hone check, as [ADOPTING.md](ADOPTING.md#5-run-the-check) step 5 shows. Every run needs `--base-revision` while a file carve-out exists: in local scripts and the pre-push hook use the branch's base (`origin/main`, or `HEAD` to measure only uncommitted changes); in CI use the pull request's base commit.
153
+ 5. Rewrite the agent instructions to point at `node_modules/@hailstails/hone/rules/` and the judgement rules, as ADOPTING step 5 and step 9 say, and remove any instruction to read the old copied files.
154
+ 6. Run the check and the repository's own validation command again, then commit everything in one change.
155
+
156
+ Stop and ask the human if anything outside the old trial uses the copied tools or `harness.config.json`.
157
+
158
+ ## 7. Known differences
159
+
160
+ | | Old route | Hone |
161
+ | --- | --- | --- |
162
+ | What is installed | rule text only; checks were the repository's own linters, plus an optional copied tools tree | one package that runs every selected check |
163
+ | Selection | whole CD files, read by an agent; a check ran only if wired by hand | clauses in `disciplines.json`; every mechanical clause of an adopted discipline must be selected |
164
+ | First-adoption debt | inherited debt could be recorded without a why-chain | imported with `provenance` and no `whyChain`, accepted only while unchanged since `--base-revision`; new or edited exceptions need a causal five-step `whyChain` ([contract](docs/why-chain-contract.md)), unless `disciplines.json` sets `"fileExceptionWhyChains": "optional"`, which lets file-level exceptions give only a `reason` |
165
+ | CD-1 | no exemptions | exempted like every other discipline, so existing `any` debt can be recorded |
166
+ | CD-3 flags | merged into the shared `compilerOptions`, wherever they were | set only in a base file not named `tsconfig.json`; any of the seven in a `tsconfig.json` is a finding |
167
+ | Running with debt | the decay check needed a base ref | every run with a file carve-out needs `--base-revision` |
168
+ | Debt decay (CD-46) | optional `rin-harness-carve-out-decay.ts` run | built into every check run with `--base-revision` |
169
+ | Stale and unrecorded exceptions | not checked | fail the run, including linter ignores or disables with no record |
170
+ | Path matching | old tools matched records by path suffix | exact repository paths |
171
+ | Linter | Biome, ESLint or oxlint for explicit `any` only | ESLint through the generated projection; Biome and oxlint are not Hone mechanisms |
172
+ | CD-8 exhaustive switch | typed ESLint `switch-exhaustiveness-check` suggested | the audit's `switch-defaults` clause only; type-aware linting is not supported |
173
+ | Judgement rules | read by an agent on request | each rule page names a review lens in `methods/lenses/`; ADOPTING step 9 is the procedure |
174
+
175
+ ## 8. Moving to causal why-chains
176
+
177
+ An install from before the [why-chain contract](docs/why-chain-contract.md) holds chains with `whys`, `rootCause` and `owner` only. Hone still accepts such a chain while `--base-revision` holds its entry unchanged, but the first run without a base revision reports `legacy-chain-unmeasured` and fails. Do these steps in order:
178
+
179
+ 1. **Give every check a base revision, before you refresh Hone.** Add `--base-revision` to the check command in `package.json` scripts, CI and the pre-push hook: `origin/main` locally, the pull request's base commit in CI. On a push to the main branch, the base is the commit before the push. Make sure CI fetches enough history to reach the base: `actions/checkout` defaults to one commit, so set `fetch-depth: 0` or fetch the base explicitly. A rin consumer on the `discipline-core` engine sets `constitution.baseRevision` in `harness.config.json`. Rin's stage gate and `disciplines` sensor pass it on.
180
+ 2. **Refresh Hone** as [ADOPTING.md](ADOPTING.md#10-update-and-remove) step 10 says, and run the check. Every chain that is unchanged since the base passes. If the run lists `legacy-chain-unmeasured`, step 1 is missing somewhere. Any `why-chain-refused` entry is a legacy chain that is new or edited since the base.
181
+ 3. **Rewrite each chain when you next touch its entry.** An edited entry with a legacy chain is refused until the chain follows the contract. Write the chain from the symptom down: ask why the exception exists, then ask why that answer is true, four more times. Add the `rootCheck` you ran today and the `readback`.
182
+ 4. **Queue a rewrite of the rest.** Nothing ends the grace period: a legacy chain whose entry is never touched stays accepted. To make every chain causal, rewrite the remaining ones as tracked work. Rewriting a chain is an edit, so each rewritten chain must pass the contract in that change.
183
+
184
+ ## 9. Moving from a copied source tree to the package
185
+
186
+ Hone is no longer installed by copying its source into the repository: this version ships no install files for that route. A copy of the source in `tools/discipline-core/` moves to the package, which gives the same reports from the same `disciplines.json` and `discipline-exceptions.json`, and runs on the repository's own toolchain. To move:
187
+
188
+ 1. **Make sure the toolchain resolves from the repository root**, in the ranges [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 lists: TypeScript 4.8.4 up to 6.x, ESLint 9.12.0 or later on 9 or any 10, and typescript-eslint 8.56.0 or later on 8. Keep the versions the repository already uses.
189
+ 2. **Install the package** as [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 says, including the two `hone:` scripts.
190
+ 3. **Repoint every command.** In scripts, CI and the pre-push hook, replace `node tools/discipline-core/core/check/check-command.ts --repo .` with `npm run --silent hone:check` (pass flags after `--`, as in `npm run --silent hone:check -- --base-revision origin/main`), and `project-command.ts` with `npm run --silent hone:project`. Point agent instructions at `node_modules/@hailstails/hone/rules/`.
191
+ 4. **Remove the copy.** Delete `tools/discipline-core/`, its line in `.gitignore`, and its entry in `disciplines.json`'s `exclude`.
192
+ 5. **Re-project** if any clause is `eslint`: run `npm run --silent hone:project`. The projection now imports each piece by package name instead of by a path into `tools/discipline-core/`, so it changes once; commit it.
193
+ 6. **Run the check.** It must give the same report as the last run on the copy. A `toolchain-unavailable` load failure names a package to install at the repository root.
194
+
195
+ ## 10. Moving from the discipline-core names to Hone
196
+
197
+ Before `0.1.0-pre.1` the tool was called discipline core, with provisional names. Its npm package was then named `honed` until `0.1.0-pre.2` renamed it `@hailstails/hone`, as section 11 describes; a repository still on discipline core moves straight to the current names below. Only the names changed: the checks, the reports, the flags and the exit codes are the same, and `disciplines.json`, `discipline-exceptions.json`, `disciplines.eslint.mjs` and every `CD-*` clause address keep their names. To move:
198
+
199
+ | Old name | New name |
200
+ | --- | --- |
201
+ | npm package `discipline-core` | npm package `@hailstails/hone` (not the unscoped `hone`, an unrelated npm package) |
202
+ | tarball `discipline-core-<version>.tgz` | tarball `hailstails-hone-<version>.tgz` |
203
+ | command `discipline-core-check --repo .` | `hone check --repo .` |
204
+ | command `discipline-core-project --repo .` | `hone project --repo .` |
205
+ | scripts `discipline:check`, `discipline:project` | scripts `hone:check`, `hone:project` |
206
+ | source entries `core/check/check-command.ts`, `core/check/project-command.ts` | `core/check/tool-command.ts check`, `core/check/tool-command.ts project` |
207
+ | ESLint rule ids `discipline/<rule>` (CD-14) | `hone/<rule>` |
208
+ | ESLint rule ids `discipline-cd<N>/<rule>` | `hone-cd<N>/<rule>` |
209
+ | reserved ESLint namespace `discipline-core` (projection block names, `discipline-core/inline-config`) | `hone-core` (`hone-core/piece/...`, `hone-core/inline-config`) |
210
+ | rule pages under `node_modules/discipline-core/rules/` | `node_modules/@hailstails/hone/rules/` |
211
+
212
+ 1. **Swap the package.** Run `npm uninstall discipline-core`, then install `@hailstails/hone` as [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 says. Replace the vendored tarball file if the repository keeps one.
213
+ 2. **Rename the scripts and repoint their callers.** In `package.json`, replace the two scripts with `"hone:check": "hone check --repo ."` and `"hone:project": "hone project --repo ."`, then change every caller of the old scripts or commands: CI, the pre-push hook and the validation script. Flags are unchanged and still go after `--`.
214
+ 3. **Re-project** if any clause is `eslint`: run `npm run --silent hone:project`. The projection's imports, block names and rule ids change once; commit it.
215
+ 4. **Rename old rule ids written by hand.** Any `eslint-disable` comment, team config rule entry or suppression that names `discipline/...` or `discipline-cd<N>/...` now names a rule that no longer exists. The check does not list it: it names no selected rule, so it drops out of `unrecorded` instead of appearing there. What appears is the finding it no longer suppresses, in the repository's own ESLint run. Search the repository for `discipline/` and `discipline-cd` and rename each to `hone/...` or `hone-cd<N>/...`, so the check governs it again.
216
+ 5. **Repoint agent instructions** from `node_modules/discipline-core/rules/` to `node_modules/@hailstails/hone/rules/`.
217
+ 6. **Run the check.** It must give the same report as the last run under the old names.
218
+
219
+ A repository whose own tooling calls the commands, such as the rin harness on the `discipline-core` engine, changes those calls on its own side. The engine name in `harness.config.json` belongs to that tooling and is not renamed here.
220
+
221
+ ## 11. Moving from `honed` to `@hailstails/hone`
222
+
223
+ Version `0.1.0-pre.1` was published as the GitHub release tarball `honed-0.1.0-pre.1.tgz`, under the npm package name `honed`. npm refuses that name as too similar to existing packages, so from `0.1.0-pre.2` the package is the scoped `@hailstails/hone`, and `honed` will never be on the registry. The package name and what derives from it changed, and so did Hone's reserved ESLint namespace, from `honed` to `hone-core`, so that no name is left from the old package. The command is still `hone`, the scripts `hone:check` and `hone:project`, and the disciplines' ESLint rule ids `hone/...` and `hone-cd<N>/...`, as are `disciplines.json`, `discipline-exceptions.json` and every `CD-*` clause address.
224
+
225
+ | `honed` 0.1.0-pre.1 | `@hailstails/hone` |
226
+ | --- | --- |
227
+ | npm package `honed` | npm package `@hailstails/hone` |
228
+ | tarball `honed-<version>.tgz` | tarball `hailstails-hone-<version>.tgz` |
229
+ | projection imports `honed/mechanisms/eslint/...` | `@hailstails/hone/mechanisms/eslint/...` |
230
+ | projection block names `honed/piece/...` and the other `honed/...` blocks | `hone-core/piece/...` and `hone-core/...` |
231
+ | governance rule `honed/inline-config` | `hone-core/inline-config` |
232
+ | rule pages under `node_modules/honed/rules/` | `node_modules/@hailstails/hone/rules/` |
233
+
234
+ 1. **Swap the package.** Run `npm uninstall honed`, then install `@hailstails/hone` as [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 says: the tarball `hailstails-hone-0.1.0-pre.2.tgz` from the `v0.1.0-pre.2` release, or, after the first registry publish, `npm install --save-dev @hailstails/hone@next`. Replace the vendored `honed-0.1.0-pre.1.tgz` if the repository keeps one. `typescript` is now a required peer, where `honed` declared it optional: if the repository root does not already declare it, npm 7 and later install the newest supported release on their own, so add it to `devDependencies` at the version the repository uses.
235
+ 2. **Re-project straight away** if any clause is `eslint`, before the check, the linter or anything else runs: `npm run --silent hone:project`, then commit `disciplines.eslint.mjs`. Until then the committed projection still imports `honed/...`, which is no longer installed, so the repository's own ESLint cannot load its configuration and the check stops with `load failure: runner-failed eslint team-config-unloadable Cannot find package 'honed' imported from ...disciplines.eslint.mjs` and exit 2. `hone project` does not load the old projection, so it runs and repairs it. Its import specifiers change from `honed/...` to `@hailstails/hone/...`, and its block names from `honed/...` to `hone-core/...`, in that same re-projection. The disciplines' rule ids `hone/...` and `hone-cd<N>/...` stay, so an `eslint-disable` comment, team config entry or suppression needs renaming only if it names `honed/inline-config`, which is now `hone-core/inline-config`.
236
+ 3. **Keep the scripts.** `"hone:check": "hone check --repo ."` and `"hone:project": "hone project --repo ."` work unchanged, because the command is still `hone`.
237
+ 4. **Repoint agent instructions** from `node_modules/honed/rules/` to `node_modules/@hailstails/hone/rules/`.
238
+ 5. **Run the check.** It must give the same report as the last run under `honed`.