@hailstails/hone 0.1.0-pre.3 → 0.1.0-pre.5

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 (51) hide show
  1. package/ADOPTING.md +44 -19
  2. package/MIGRATING.md +5 -5
  3. package/README.md +89 -24
  4. package/api/audit.d.ts +11 -0
  5. package/api/audit.mjs +1 -0
  6. package/api/rule-set.d.ts +4 -0
  7. package/api/rule-set.mjs +1 -0
  8. package/chunks/chunk-3HFJHJDO.js +53 -0
  9. package/chunks/chunk-7OVV6NEU.js +22 -0
  10. package/chunks/chunk-7PVPPH4C.js +13 -0
  11. package/chunks/chunk-HVABJ7T4.js +361 -0
  12. package/chunks/{chunk-TRCB27ET.js → chunk-IIMK5BCL.js} +55 -14
  13. package/chunks/{chunk-7ZJZZBSS.js → chunk-SWPCKTJV.js} +87 -380
  14. package/chunks/{chunk-HBY4ZWSP.js → chunk-VUG3DJHN.js} +7 -13
  15. package/chunks/{chunk-233U4FBA.js → chunk-YBWVUDIG.js} +1 -1
  16. package/core/check/tool-command.js +422 -115
  17. package/core/mechanism-port/piece-failure-types.d.ts +14 -0
  18. package/core/mechanism-port/runner-module-types.d.ts +13 -0
  19. package/core/mechanism-port/runner-result-types.d.ts +9 -0
  20. package/core/rule-set-reader/authored-rule-set-types.d.ts +48 -0
  21. package/core/values/anchor.d.ts +10 -0
  22. package/core/values/branded.d.ts +5 -0
  23. package/core/values/clause-address-types.d.ts +9 -0
  24. package/core/values/identifier-types.d.ts +5 -0
  25. package/core/values/json-value.d.ts +6 -0
  26. package/core/values/repo-path-types.d.ts +2 -0
  27. package/core/values/result.d.ts +7 -0
  28. package/docs/adding-a-discipline-or-mechanism.md +8 -5
  29. package/docs/extending.md +357 -0
  30. package/mechanisms/audit/CD-1/any-cast.js +9 -37
  31. package/mechanisms/audit/CD-19/import-boundaries.js +82 -63
  32. package/mechanisms/audit/CD-19/piece.json +5 -0
  33. package/mechanisms/audit/CD-2/cast-expressions.js +14 -37
  34. package/mechanisms/audit/CD-5/comments-directives.js +137 -55
  35. package/mechanisms/audit/CD-5/piece.json +7 -0
  36. package/mechanisms/audit/runner/README.md +1 -0
  37. package/mechanisms/audit/runner/runner.js +39 -33
  38. package/mechanisms/audit/runner/typescript-parse.d.ts +26 -0
  39. package/mechanisms/audit/runner/walker-piece.d.ts +60 -0
  40. package/mechanisms/eslint/runner/README.md +1 -1
  41. package/mechanisms/eslint/runner/eslint-piece-settings-types.d.ts +8 -0
  42. package/mechanisms/eslint/runner/runner.js +137 -71
  43. package/package.json +20 -3
  44. package/rules/CD-1/README.md +5 -5
  45. package/rules/CD-1/discipline.json +16 -6
  46. package/rules/CD-19/README.md +13 -3
  47. package/rules/CD-19/discipline.json +6 -8
  48. package/rules/CD-2/README.md +8 -4
  49. package/rules/CD-2/discipline.json +25 -7
  50. package/rules/CD-5/README.md +17 -5
  51. package/rules/CD-5/discipline.json +66 -0
package/ADOPTING.md CHANGED
@@ -10,15 +10,15 @@ Hone reads `disciplines.json` in `<repo>`, runs the selected disciplines' checks
10
10
  node --version
11
11
  ```
12
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.
13
+ It must print `v22.18.0` or a later 22.x, or `v24.0.0` or later. A rule set of your own may write its piece modules as `.ts` files, which Hone runs with Node's built-in type stripping, so they are limited to what [Node's TypeScript support](https://nodejs.org/docs/latest-v22.x/api/typescript.html) allows: only syntax that can be erased, so no enums, no namespaces that hold values and no parameter properties; relative imports that spell the `.ts` extension; and `import type` (or `type` on each name) for anything that is only a type. Node does not strip types from files under `node_modules`, so a rule set installed as a package must ship `.js`. 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
14
 
15
15
  ## 2. Install the Hone package
16
16
 
17
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
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.
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. Its first pre-release was released under the old name `honed`; [MIGRATING.md](MIGRATING.md#11-moving-from-honed-to-hailstailshone) says how to move from it.
20
20
 
21
- The current version, `0.1.0-pre.3`, is a pre-release: its commands, flags and files may still change before `0.1.0`.
21
+ Releases are pre-releases until a stable release is published: until then, commands, flags and files may still change between releases.
22
22
 
23
23
  The main route is the npm registry. Pre-releases are published under the dist-tag `next`, so name it:
24
24
 
@@ -28,17 +28,17 @@ npm install --save-dev @hailstails/hone@next
28
28
 
29
29
  npm records it in `package.json`, and the exact version it installed in the lockfile. Check the name before you run it: `@hailstails/hone`, never the unscoped `hone`. With pnpm or Yarn, add `@hailstails/hone@next` with their own `add -D` command at the workspace root. `next` names the newest pre-release approved on npm, so it can trail the newest GitHub release for a while; [README.md](README.md#developing-hone) says how a version reaches npm.
30
30
 
31
- The alternative is a tarball, copied into the repository so every teammate and CI runner installs the same bytes without the registry. This page writes its location as `<hone-tarball>`: a path such as `vendor/hailstails-hone/hailstails-hone-0.1.0-pre.3.tgz`, or an `https://` URL your team serves it from. Download `hailstails-hone-0.1.0-pre.3.tgz` from the [`v0.1.0-pre.3` GitHub release](https://github.com/HailsTails/hone/releases/tag/v0.1.0-pre.3), which the release workflow creates, marked as a pre-release, when the tag `v0.1.0-pre.3` is pushed. Until that tag exists, use the [`v0.1.0-pre.2` release](https://github.com/HailsTails/hone/releases/tag/v0.1.0-pre.2), or 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 first pre-release under the old name `honed`.
31
+ The alternative is a tarball, copied into the repository so every teammate and CI runner installs the same bytes without the registry. This page writes its location as `<hone-tarball>`: a path such as `vendor/hailstails-hone/hailstails-hone-<version>.tgz`, or an `https://` URL your team serves it from. Download the tarball attached to the latest [GitHub release](https://github.com/HailsTails/hone/releases), or build it from a pinned commit as below.
32
32
 
33
- To build the tarball yourself, 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>`:
33
+ To build the tarball yourself, use Node.js 22.18 or later with [corepack](https://nodejs.org/api/corepack.html) available, which provides the pnpm version `package.json` pins, 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>`:
34
34
 
35
35
  ```bash
36
36
  git clone -c core.longpaths=true https://github.com/HailsTails/hone.git /tmp/hone-source
37
37
  git -C /tmp/hone-source checkout <pinned-sha>
38
- cd /tmp/hone-source && bun install --frozen-lockfile && bun run pack-package && cd -
38
+ cd /tmp/hone-source && corepack pnpm install --frozen-lockfile && corepack pnpm run pack-package && cd -
39
39
  ```
40
40
 
41
- The last command prints `pack package: wrote <path>/artefacts/hailstails-hone-0.1.0-pre.3.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. The commands in this guide are POSIX shell; on Windows run them in Git Bash.
41
+ The last command prints `pack package: wrote <path>/artefacts/hailstails-hone-<version>.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. The commands in this guide are POSIX shell; on Windows run them in Git Bash.
42
42
 
43
43
  Install it as a development dependency of the repository root, beside the toolchain:
44
44
 
@@ -64,7 +64,7 @@ Hone runs on the toolchain the repository already uses, which the package declar
64
64
  | Package | Needed for | Range |
65
65
  | --- | --- | --- |
66
66
  | `typescript` | any `audit` clause | `>=4.8.4 <7.0.0` |
67
- | `eslint` | any `eslint` clause | `^9.12.0 \|\| ^10.0.0` |
67
+ | `eslint` | any `eslint` clause | `^9.28.0 \|\| ^10.0.0` |
68
68
  | `@typescript-eslint/parser` | any `eslint` clause | `^8.56.0` |
69
69
  | `@typescript-eslint/eslint-plugin` | any `eslint` clause | `^8.56.0` |
70
70
 
@@ -98,11 +98,14 @@ Create `<repo>/disciplines.json`. Map every clause you adopt to the mechanism th
98
98
  }
99
99
  ```
100
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`.
101
+ - `clauses` keys are clause addresses from the rules pages; the value is a mechanism the clause's rules page lists, `audit` or `eslint`, or `"not-adopted"`.
102
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).
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 leave such a clause out, list it as `"not-adopted"`; to defer it as tracked debt, list it with its mechanism and record a `clause-wide-carve-out` for it (step 7).
104
+ - To adopt a discipline through one mechanism only, for example CD-6's `identifier-names` through `audit` without its ESLint-only `naming-convention`, list the clause you do not adopt as `"not-adopted"`: `"CD-6#identifier-names": "audit", "CD-6#naming-convention": "not-adopted"`. That clause is never run and never projected, not even as `"off"`, so this adopter needs no ESLint installed; the report lists it under `notAdopted` and the run stays a whole assessment. No exception record is needed, and one on that clause is invalid as `clause-not-adopted`.
105
+ - To keep a clause adopted but defer it as tracked debt with an owner, select it, record a `clause-wide-carve-out` with its why-chain, and set `"assessment": { "waivedClauses": "not-run" }` in `disciplines.json`. The waived clause is then never run, and a mechanism left with nothing to run is not loaded, so this adopter needs no ESLint installed. `hone project` still writes the waived clause's `"off"` block to the projection, and whenever ESLint runs for another clause the projection is still checked against every selected clause. The trade: in those runs the waiver is not judged `stale`, so it stays in force until you remove it, and every report says so in its `assessment` section.
104
106
  - `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).
107
+ - `clauseSettings` gives a clause the settings its rules page lists under Settings, keyed by clause address. CD-19, for example, flags only imports of the packages you list in its `confinedPackages`; CD-5's `trackerPatterns` narrows tracked references to your tracker's format. See [README.md](README.md#disciplinesjson).
108
+ - `ruleSets` stays `{}` unless you write disciplines of your own; see [docs/extending.md](docs/extending.md).
106
109
 
107
110
  Every clause address Hone ships:
108
111
 
@@ -156,7 +159,7 @@ In a monorepo, every `eslint.config.*` that applies to checked files spreads the
156
159
  { "eslintConfigLookup": "nearest-to-file" }
157
160
  ```
158
161
 
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.
162
+ 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.28 and 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
163
 
161
164
  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
165
 
@@ -180,7 +183,27 @@ In CI, pass the branch's base so that debt recorded per file is forfeited once t
180
183
  npm run --silent hone:check -- --base-revision origin/main
181
184
  ```
182
185
 
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.
186
+ Add the command to the repository's existing validation script, and run that script in CI and in any pre-push hook the repository already has, so the check runs wherever the other checks run.
187
+
188
+ To assess decay at push only, for example so that a hotfix in a carved file is not blocked in CI, set `"assessment": { "forfeiture": "elsewhere" }` in `disciplines.json`. CI and the pre-push hook then run different commands. The pre-push hook assesses decay for its run:
189
+
190
+ ```bash
191
+ npm run --silent hone:check -- --forfeiture this-run --base-revision origin/main
192
+ ```
193
+
194
+ CI leaves decay to the hook. A repository with no imported records and no legacy-chain records runs the check with no base revision:
195
+
196
+ ```bash
197
+ npm run --silent hone:check
198
+ ```
199
+
200
+ A repository with imported records (`provenance`) or legacy-chain records still needs a base revision in CI, because those records are checked against it; without one the report lists `import-unmeasured` or `legacy-chain-unmeasured` and the run fails. Pass the pull request's base commit with `elsewhere` in effect: the base is then used for those records only, and nothing is forfeited. CI needs that one commit fetched, for example `git fetch --depth=1 origin <base-commit>`, not the full history:
201
+
202
+ ```bash
203
+ npm run --silent hone:check -- --base-revision <base-commit>
204
+ ```
205
+
206
+ The trade: a push that bypasses the hook, for example with `git push --no-verify`, leaves no later gate, so carve-out debt can stop decaying unnoticed. Every run that leaves decay to another run says so in its report (step 6). With `eslint` clauses, the repository's own `eslint` run also reports them in the editor, from the projection.
184
207
 
185
208
  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
209
 
@@ -193,21 +216,23 @@ The report prints only the sections that have entries, each with its count, then
193
216
  CD-15#loops audit src/basket.ts:15:0 for (const line of this.lines) {
194
217
  ```
195
218
 
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:
219
+ Lines are 1-based and columns 0-based. The run passes only when every section except `excluded`, `notAdopted`, `exempted` and `assessment` is empty. The sections are:
197
220
 
198
221
  | Section | Meaning and what to do |
199
222
  | --- | --- |
200
223
  | `excluded` | the `exclude` entries from `disciplines.json` that were left out of the run; informational, check it is what you meant |
224
+ | `notAdopted` | the clauses `disciplines.json` lists as `"not-adopted"`; informational, they were neither run nor projected |
201
225
  | `findings` | violations: fix the code, or record an exception (step 7) |
202
226
  | `exempted` | findings an exception covers; informational |
203
- | `uncovered` | a mechanical clause of an adopted discipline is not selected: add it to `disciplines.json` |
227
+ | `uncovered` | a mechanical clause of an adopted discipline is not listed: add it to `disciplines.json` with a mechanism, or as `"not-adopted"` |
204
228
  | `stale` | an exception that no longer exempts anything: delete it |
205
229
  | `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 |
230
+ | `invalidRecords` | an exception entry that cannot be accepted, with the reason, for example `clause-not-adopted` for an entry on a clause listed as `"not-adopted"`: correct or delete it |
207
231
  | `doublyHeld` | a file both authorised and carved out for one clause: keep one |
208
232
  | `unmeasured` | something could not be measured, for example `forfeiture-unmeasured` when file carve-outs exist and no `--base-revision` was given |
233
+ | `assessment` | a concern this run left to another run or did not run, for example `forfeiture elsewhere: 37 file carve-outs not checked for decay in this run` or `waived-clauses not-run: 1 clause not run, 1 record not judged stale: CD-6#naming-convention eslint`; informational, and the verdict line then reads `verdict: pass (partial assessment)` or `verdict: fail (partial assessment)` |
209
234
 
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.
235
+ 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`, `notAdopted`, `exempted` and `assessment`; `counts` prints only each section's heading and count, adding `informational` after `excluded`, `notAdopted`, `exempted` and `assessment` 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
236
 
212
237
  ## 7. Record exceptions
213
238
 
@@ -215,7 +240,7 @@ Fix findings where you can. Where a file legitimately needs what a clause forbid
215
240
 
216
241
  - `authorised-location`: the clause does not apply to this one file, for example the single adapter that reads the real clock.
217
242
  - `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.
243
+ - `clause-wide-carve-out`: the clause is waived everywhere. Leaving the clause out of `clauses` is not an alternative: it leaves the clause `uncovered`. To not adopt the clause at all, list it as `"not-adopted"` (step 4) instead of recording a waiver. A clause-wide carve-out that exempts no finding is `stale`, so record one only while the clause still has findings, unless the repository sets `waivedClauses` to `not-run` (step 4), which skips the clause and does not judge the carve-out stale.
219
244
 
220
245
  Every entry needs a `reason`. By default every entry also needs a `whyChain` shaped like this, with exactly five steps in `whys`:
221
246
 
@@ -311,4 +336,4 @@ verdict: pass
311
336
  - The worked example uses only the audit mechanism. The ESLint consumer in `tests/test-fixtures/consumer-proof/eslint/` is the tested ESLint setup.
312
337
  - 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
338
  - 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.
339
+ - 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, following [docs/extending.md](docs/extending.md).
package/MIGRATING.md CHANGED
@@ -31,7 +31,7 @@ Old code often holds CD-1 `any` the old route never checked. Hone flags it in st
31
31
 
32
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
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`.
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`. To adopt a discipline through one mechanism only, list the other clauses as `"not-adopted"`, as [ADOPTING.md](ADOPTING.md#4-write-disciplinesjson) step 4 shows. A repository that did this with a `clause-wide-carve-out` and `"waivedClauses": "not-run"` can switch: list the clause as `"not-adopted"`, delete its carve-out, which would otherwise be `clause-not-adopted`, and re-run `hone project` so the projection no longer carries that rule.
35
35
 
36
36
  | Old CD | Clauses to select in `disciplines.json` |
37
37
  | --- | --- |
@@ -149,7 +149,7 @@ Only after step 5 passes:
149
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
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
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.
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, unless it leaves forfeiture to another run as [ADOPTING.md](ADOPTING.md#5-run-the-check) step 5 shows, and a run with imported records needs it in any case: 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
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
154
  6. Run the check and the repository's own validation command again, then commit everything in one change.
155
155
 
@@ -164,7 +164,7 @@ Stop and ask the human if anything outside the old trial uses the copied tools o
164
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
165
  | CD-1 | no exemptions | exempted like every other discipline, so existing `any` debt can be recorded |
166
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` |
167
+ | Running with debt | the decay check needed a base ref | every run with a file carve-out needs `--base-revision`, unless it sets forfeiture `elsewhere`; every run with imported or legacy-chain records needs it either way |
168
168
  | Debt decay (CD-46) | optional `rin-harness-carve-out-decay.ts` run | built into every check run with `--base-revision` |
169
169
  | Stale and unrecorded exceptions | not checked | fail the run, including linter ignores or disables with no record |
170
170
  | Path matching | old tools matched records by path suffix | exact repository paths |
@@ -185,7 +185,7 @@ An install from before the [why-chain contract](docs/why-chain-contract.md) hold
185
185
 
186
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
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.
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.28.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
189
  2. **Install the package** as [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 says, including the two `hone:` scripts.
190
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
191
  4. **Remove the copy.** Delete `tools/discipline-core/`, its line in `.gitignore`, and its entry in `disciplines.json`'s `exclude`.
@@ -231,7 +231,7 @@ Version `0.1.0-pre.1` was published as the GitHub release tarball `honed-0.1.0-p
231
231
  | governance rule `honed/inline-config` | `hone-core/inline-config` |
232
232
  | rule pages under `node_modules/honed/rules/` | `node_modules/@hailstails/hone/rules/` |
233
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: `npm install --save-dev @hailstails/hone@next`, or the tarball `hailstails-hone-0.1.0-pre.3.tgz` from the `v0.1.0-pre.3` release. Remove the vendored `honed-0.1.0-pre.1.tgz` if the repository keeps one, or replace it with the new tarball. `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.
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: `npm install --save-dev @hailstails/hone@next`, or the tarball attached to the latest [GitHub release](https://github.com/HailsTails/hone/releases). Remove the vendored `honed-0.1.0-pre.1.tgz` if the repository keeps one, or replace it with the new tarball. `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
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
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
237
  4. **Repoint agent instructions** from `node_modules/honed/rules/` to `node_modules/@hailstails/hone/rules/`.
package/README.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Hone
2
2
 
3
+ [![npm version on the next dist-tag](https://img.shields.io/npm/v/%40hailstails%2Fhone/next)](https://www.npmjs.com/package/@hailstails/hone)
4
+ [![CI on main](https://github.com/HailsTails/hone/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/HailsTails/hone/actions/workflows/ci.yml?query=branch%3Amain)
5
+ [![Unpacked size on the next dist-tag](https://img.shields.io/npm/unpacked-size/%40hailstails%2Fhone/next)](https://www.npmjs.com/package/@hailstails/hone)
6
+ [![Supported Node versions on the next dist-tag](https://img.shields.io/node/v/%40hailstails%2Fhone/next)](https://www.npmjs.com/package/@hailstails/hone)
7
+ [![Licence](https://img.shields.io/npm/l/%40hailstails%2Fhone)](LICENSE)
8
+
3
9
  Hone checks a repository against the disciplines it has chosen to adopt. It is a tool, not a framework: it reads what the repository selected, hands each selected clause to the mechanism that checks it, applies the repository's recorded exceptions, and prints one verdict. Its core enforces nothing and names no discipline and no mechanism. A discipline (for example CD-14, no authored classes) is data under `rules/`, and a mechanism is a runner under `mechanisms/`; the core reaches both only through files and one module contract.
4
10
 
5
11
  **Install the npm package `@hailstails/hone`.** The unscoped name `hone` on npm belongs to an unrelated package: never run `npm install hone`. `@hailstails/hone` installs one command, `hone`:
@@ -8,20 +14,20 @@ Hone checks a repository against the disciplines it has chosen to adopt. It is a
8
14
  npm install --save-dev @hailstails/hone@next
9
15
  ```
10
16
 
11
- Version `0.1.0-pre.3` is a pre-release, and pre-releases are published to npm under the dist-tag `next`. The alternative is the tarball `hailstails-hone-0.1.0-pre.3.tgz`, downloaded from the [`v0.1.0-pre.3` GitHub release](https://github.com/HailsTails/hone/releases/tag/v0.1.0-pre.3) once that tag is pushed and installed with `npm install --save-dev <path-to-tarball>`. The earlier [`v0.1.0-pre.1` release](https://github.com/HailsTails/hone/releases/tag/v0.1.0-pre.1) holds the first pre-release under the package's old name, `honed`; [MIGRATING.md](MIGRATING.md#11-moving-from-honed-to-hailstailshone) says how to move from it. [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 has the steps, and the alternative of building the tarball from a pinned commit.
17
+ Releases are pre-releases, published to npm under the dist-tag `next`, until a stable release is published under `latest`; the badge above shows the version `next` installs. The alternative is the tarball attached to each [GitHub release](https://github.com/HailsTails/hone/releases), installed with `npm install --save-dev <path-to-tarball>`. A repository on the package's old name, `honed`, moves with [MIGRATING.md](MIGRATING.md#11-moving-from-honed-to-hailstailshone). [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 has the steps, and the alternative of building the tarball from a pinned commit.
12
18
 
13
19
  Two mechanisms ship: `audit`, a standalone TypeScript syntax walker, and `eslint`, which runs the clause as an ESLint rule inside the team's own ESLint setup. [rules/README.md](rules/README.md) lists every shared discipline with its clauses: the audit mechanism checks 20 disciplines, and ESLint pieces check clauses of CD-1, CD-6, CD-7, CD-10, CD-14, CD-27, CD-40, CD-41, CD-42 and CD-44. The rest are judgement rules, applied in review with the review methods in [methods/](methods/README.md).
14
20
 
15
21
  To adopt Hone in another repository, follow [ADOPTING.md](ADOPTING.md) step by step. A repository already using the older standalone route, or a copy of Hone's source, follows [MIGRATING.md](MIGRATING.md) instead.
16
22
 
17
- Adding a discipline or a mechanism, and the full list of ESLint native channels, are covered in [docs/adding-a-discipline-or-mechanism.md](docs/adding-a-discipline-or-mechanism.md).
23
+ A team adds its own disciplines as a rule set in its own repository, with ESLint and audit pieces, following [docs/extending.md](docs/extending.md). Adding a discipline or a mechanism to Hone itself, and the full list of ESLint native channels, are covered in [docs/adding-a-discipline-or-mechanism.md](docs/adding-a-discipline-or-mechanism.md).
18
24
 
19
25
  ## Commands
20
26
 
21
27
  The package ships one command, `hone`, with two subcommands, run through a `package.json` script as [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) shows:
22
28
 
23
29
  ```text
24
- hone check --repo <dir> [--base-revision <rev>] [--report-output <output>]
30
+ hone check --repo <dir> [--base-revision <rev>] [--report-output <output>] [--forfeiture <this-run|elsewhere>] [--waived-clauses <run|not-run>]
25
31
  hone project --repo <dir>
26
32
  ```
27
33
 
@@ -37,26 +43,42 @@ hone project --repo <dir>
37
43
 
38
44
  A load failure prints one line, `load failure: <kind> <fields>`.
39
45
 
40
- The report lists the excluded paths, findings, exempted findings, uncovered clauses, stale, forfeited, unrecorded and doubly-held exceptions, invalid exception records, unmeasured checks and projection problems, each with its count. The verdict is `pass` only when every list except the excluded paths and exempted findings is empty.
46
+ The report lists the excluded paths, the clauses not adopted, findings, exempted findings, uncovered clauses, stale, forfeited, unrecorded and doubly-held exceptions, invalid exception records, unmeasured checks, projection problems and any part of the assessment left to another run, each with its count. The verdict is `pass` only when every list except the excluded paths, clauses not adopted, exempted findings and assessment is empty.
41
47
 
42
48
  `--report-output` sets how much of the report is printed for one run, overriding `reportOutput` in `disciplines.json`; with neither, the output is `full`.
43
49
 
44
50
  | Output | Prints |
45
51
  | --- | --- |
46
52
  | `full` | every non-empty section with its entries, then the verdict |
47
- | `failures-only` | the same without the `excluded` and `exempted` sections |
48
- | `counts` | one `<section> (<count>)` line per non-empty section, with ` informational` after `excluded` and `exempted`, then the verdict |
53
+ | `failures-only` | the same without the `excluded`, `exempted` and `assessment` sections |
54
+ | `counts` | one `<section> (<count>)` line per non-empty section, with ` informational` after `excluded`, `exempted` and `assessment`, then the verdict |
49
55
  | `verdict-only` | only the verdict line |
50
56
 
51
57
  The output changes only what is printed: the verdict and exit code always come from the whole report. An unknown `--report-output` value is a load failure `arguments-invalid`; an unknown `reportOutput` value makes `disciplines.json` `file-malformed`, even when `--report-output` is given. Load failures print the same in every output.
52
58
 
53
59
  Without `--base-revision`, Hone cannot tell which files were touched, so a file carve-out cannot be forfeited; if any file carve-out exists the report lists `forfeiture-unmeasured` and the run fails. For the same reason it cannot tell whether an entry with an earlier-contract why-chain is unchanged; if one exists the report lists `legacy-chain-unmeasured` and the run fails.
54
60
 
61
+ `--forfeiture elsewhere` makes a run leave carve-out decay to another run, such as a pre-push hook given a base revision, overriding `assessment.forfeiture` in `disciplines.json`; `--forfeiture this-run`, the default, assesses it in this run. A run with forfeiture elsewhere asks git for no change set, forfeits no file carve-out and never reports `forfeiture-unmeasured`, with or without `--base-revision`. It ends its report with an `assessment` section, printed whenever the run assesses less than the default, and marks its verdict line in every output:
62
+
63
+ ```text
64
+ assessment (1)
65
+ forfeiture elsewhere: 37 file carve-outs not checked for decay in this run
66
+ verdict: pass (partial assessment)
67
+ ```
68
+
69
+ The `assessment` section is informational and the marker does not change the exit code. Forfeiture elsewhere changes nothing else: `--base-revision` given with it is used only to check imported entries and legacy chains, and a run without a base revision still reports `import-unmeasured` and `legacy-chain-unmeasured` as above.
70
+
71
+ `--waived-clauses not-run` makes a run skip every selected clause a valid `clause-wide-carve-out` covers, overriding `assessment.waivedClauses` in `disciplines.json`; `--waived-clauses run`, the default, runs them as before. A mechanism left with nothing to run is not loaded at all, so a repository that waives every `eslint` clause needs no ESLint installed. A mechanism that still has another clause to run skips just the waived ones: ESLint never switches a waived rule on, while its projection is still judged against every selected clause, the waived clause and its `"off"` block included. When every ESLint clause is waived, ESLint is not loaded, so the projection's freshness is not checked in that run. Only the waived clauses' execution and the staleness of the records on them are skipped: `stale` is not judged for those records, while invalid records, forfeiture, doubly-held records and `uncovered` are reported as before, and `hone project` still writes the waived rules and their `"off"` blocks. The `assessment` section names each clause not run:
72
+
73
+ ```text
74
+ waived-clauses not-run: 1 clause not run, 1 record not judged stale: CD-6#naming-convention eslint
75
+ ```
76
+
55
77
  `hone project` writes the native configuration each embedded mechanism needs, and prints `<path> <effect>` per file (`written` or `unchanged`). The audit mechanism is standalone and writes nothing, so with only the walker selected the command prints nothing and exits `0`.
56
78
 
57
79
  ## Adopting the ESLint mechanism
58
80
 
59
- With any clause selected for `eslint`, run `hone project`. It writes `disciplines.eslint.mjs` at the repository root: one block per piece enabling its selected rules at `"error"` on `**/*.{ts,tsx,mts,cts}`, then one block per exception record turning the rule `"off"` for that record's file, or everywhere for a clause-wide carve-out. Commit it, and spread its default export last in the repository's flat config:
81
+ With any clause selected for `eslint`, run `hone project`. It writes `disciplines.eslint.mjs` at the repository root: one block per piece enabling its selected rules at `"error"` on `**/*.{ts,tsx,mts,cts}`, then one block per set of clauses that files are excepted from, listing those files and turning the rules `"off"` for them, and one block per clause-wide carve-out turning its rules `"off"` everywhere. Commit it, and spread its default export last in the repository's flat config:
60
82
 
61
83
  ```js
62
84
  import disciplines from "./disciplines.eslint.mjs";
@@ -90,13 +112,16 @@ At the repository root. It selects clauses and the mechanism that checks each on
90
112
  }
91
113
  ```
92
114
 
93
- - `ruleSets` names the repository's own rule sets, each a directory relative to the repository root. The name `shared` is reserved for the rule set shipped with core.
94
- - `clauses` maps a clause address to a mechanism id. An address is `[<ruleSet>/]<DisciplineId>#<clauseId>`; no prefix means the shared rule set. The mechanism must be one the clause lists.
95
- - Selecting a clause adopts its discipline. Mechanical clauses of an adopted discipline that are not selected are reported as uncovered, and fail the run.
115
+ - `ruleSets` names the repository's own rule sets, each a directory relative to the repository root. The name `hone` is reserved for the rule set shipped with the tool; `hone/CD-15#loops` and `CD-15#loops` are the same address. A rule-set name may not start with `hone-`, and no declared name may be another declared name plus `-<suffix>`.
116
+ - `clauses` maps a clause address to a mechanism id, or to `"not-adopted"`. An address is `[<ruleSet>/]<DisciplineId>#<clauseId>`; no prefix means the `hone` rule set. The mechanism must be one the clause lists.
117
+ - Listing a clause adopts its discipline. Mechanical clauses of an adopted discipline that are not listed are reported as uncovered, and fail the run.
118
+ - `"not-adopted"` states that the repository does not adopt that clause. It is never run and never projected, and its mechanism is not loaded unless another clause uses it. The report lists it under `notAdopted`, which is informational: the run is still a whole assessment. An exception record on it is invalid as `clause-not-adopted`, and `clauseSettings` for it make `disciplines.json` `file-malformed`. The clause must still exist and be mechanical, in any rule set.
96
119
  - A judgement clause cannot be selected; it is enforced by review.
97
120
  - `eslintConfigLookup`, optional, is `"nearest-to-file"` or `"repository-root"` and says which `eslint.config.*` the team's own ESLint run applies to a file; see [Runtime](#runtime). Leave it out to let Hone detect it.
98
121
  - `fileExceptionWhyChains`, optional, is `"required"` (the default) or `"optional"`. `"optional"` lets an `authorised-location` or `file-carve-out` entry give only its `reason`; see [discipline-exceptions.json](#discipline-exceptionsjson).
99
122
  - `reportOutput`, optional, is `"full"` (the default), `"failures-only"`, `"counts"` or `"verdict-only"`: the repository's default for how much of the report the check prints. `--report-output` overrides it for one run; see [Commands](#commands).
123
+ - `clauseSettings`, optional, maps a selected clause address to an object of that clause's settings, for a clause whose rules page lists settings. Each key must be one the clause's piece declares, and its value must be the same JSON kind as the declared default and, where the piece lists choices, one of them; the value replaces the default. Anything else makes `disciplines.json` malformed, naming the clause, the key and what is accepted: settings for a clause the file does not select or names twice, for a clause that takes none, under an undeclared key, or of the wrong kind or choice.
124
+ - `assessment`, optional, says which run assesses each concern. `forfeiture` is `"this-run"` (the default) or `"elsewhere"`, and `--forfeiture` overrides it for one run. `waivedClauses` is `"run"` (the default) or `"not-run"`, and `--waived-clauses` overrides it for one run. See [Commands](#commands). Any other key makes `disciplines.json` `file-malformed`, naming the key as not available in this version.
100
125
  - `exclude`, optional, lists repository folders or exact files that no mechanism checks. A folder entry covers everything under it. Globs are refused: an entry containing `*` makes `disciplines.json` malformed. The report lists the active entries under `excluded`. Exclude Hone's own install when it is vendored inside the repository.
101
126
 
102
127
  ## discipline-exceptions.json
@@ -143,24 +168,48 @@ At the repository root; absent means no exceptions. Each entry names a selected
143
168
 
144
169
  ## Installing
145
170
 
146
- Hone installs as one npm package, `@hailstails/hone`, installed as `@hailstails/hone@next` from npm, downloaded as `hailstails-hone-0.1.0-pre.3.tgz` from the `v0.1.0-pre.3` GitHub release once that tag is pushed, or built by `bun run pack-package` into `artefacts/hailstails-hone-0.1.0-pre.3.tgz`, the file name `npm pack` gives the scoped package, and added to the repository root as a development dependency; [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 has the steps. The package is plain JavaScript with `zod`, `jsonc-parser` and `@eslint/plugin-kit` bundled in, so it has no `dependencies`; its licences are reproduced in `THIRD-PARTY-NOTICES.md` inside it. It declares the toolchain as `peerDependencies`, `typescript` required and the ESLint packages optional, and exposes one command, `hone`, whose subcommands `hone check` and `hone project` are described under Commands. It ships the rule data and pages, both mechanisms, the review methods and the why-chain contract, and no TypeScript source. Version `0.1.0-pre.3` is a pre-release.
171
+ Hone installs as one npm package, `@hailstails/hone`, installed as `@hailstails/hone@next` from npm, downloaded as the tarball `hailstails-hone-<version>.tgz` attached to a GitHub release, or built by `pnpm run pack-package` into `artefacts/hailstails-hone-<version>.tgz`, the file name `npm pack` gives the scoped package, and added to the repository root as a development dependency; [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 has the steps. The package is plain JavaScript with `zod`, `jsonc-parser` and `@eslint/plugin-kit` bundled in, so it has no `dependencies`; its licences are reproduced in `THIRD-PARTY-NOTICES.md` inside it. It declares the toolchain as `peerDependencies`, `typescript` required and the ESLint packages optional, and exposes one command, `hone`, whose subcommands `hone check` and `hone project` are described under Commands. It ships the rule data and pages, both mechanisms, the review methods and the why-chain contract, and no TypeScript source, only the declaration files of the public type entries below.
147
172
 
148
173
  With the ESLint mechanism selected, a packaged install's projection imports each piece by package name, `@hailstails/hone/mechanisms/eslint/<DisciplineId>/...`, so the repository's ESLint must resolve the package from the repository root. Hone compares the committed projection `disciplines.eslint.mjs` byte for byte with what `hone project` would write now.
149
174
 
175
+ ## Public type entries
176
+
177
+ The package has two public entries for TypeScript. Each holds types only, so importing one adds no code to a build; import them with `import type`.
178
+
179
+ | Entry | Status | What it is for |
180
+ | --- | --- | --- |
181
+ | `@hailstails/hone/rule-set` | Stable | The shapes of `discipline.json`, `piece.json` and an ESLint piece's `settings`, for a team writing its own rule set. Identifiers and paths are plain strings: Hone checks them when it reads the files. |
182
+ | `@hailstails/hone/audit` | Experimental | The types for writing an audit walker piece, `WalkerPiece` and what it needs, including `PieceFailure`, the failures a piece may return. Clause addresses and file paths reach a piece from Hone, already checked, and a piece passes them back unchanged. It may change in a minor release. |
183
+
184
+ Both resolve with `moduleResolution` `"nodenext"` or `"bundler"`. `install-proof` type-checks a team piece and rule set against them, and checks that a wrongly typed field fails: on TypeScript 4.8.4 from an ES module with `"nodenext"` (4.8 has no `"bundler"`), and on 6.0.3 from an ES module with both and from a CommonJS file. A CommonJS file (`.cts`, or `.ts` in a package that is not `"type": "module"`) can import these types on TypeScript 5.8 or later with `module` `"nodenext"`. With `module` `"node16"`, and on TypeScript 5.3 to 5.7, the import needs `with { "resolution-mode": "import" }`, and older versions reject it. These CommonJS figures were checked once by hand, on 5.8.2, 5.3.3 and 6.0.3 with `"node16"`; `install-proof` checks only the 6.0.3 CommonJS case with `"nodenext"`. `@hailstails/hone/audit` names TypeScript's own syntax types, so it needs the `typescript` the repository already installs as a peer. No other path in the package is a public TypeScript entry.
185
+
150
186
  ## Runtime
151
187
 
152
188
  - Windows, Linux, macOS or WSL. Hone keeps absolute paths in the platform's own form and repository paths in POSIX form, as git reports them.
153
- - The package: Node `^22.13.0 || >=24` (its `engines.node`). It is plain JavaScript, so Node never strips types from it.
189
+ - The package: Node `^22.18.0 || >=24` (its `engines.node`). It is plain JavaScript, so Node never strips types from it, and from 22.18.0 Node strips types from a rule set's `.ts` piece modules, within the limits [ADOPTING.md](ADOPTING.md#1-check-the-prerequisites) lists.
154
190
  - git 2.24 or later. Older git rejects `--end-of-options`, so the changed-file query fails and forfeiture is reported unmeasured.
155
- - Hone's own packages, `zod`, `jsonc-parser` and `@eslint/plugin-kit`, exact-pinned in `dependencies` and locked by `bun.lock`: bundled into the package. They are implementation details: nothing of theirs crosses into the repository's code or configuration.
156
- - The repository's own toolchain, declared as `peerDependencies`: `typescript` `>=4.8.4 <7.0.0`, a required peer because every audit clause needs it, and for the ESLint mechanism the optional peers `eslint` `^9.12.0 || ^10.0.0`, `@typescript-eslint/parser` `^8.56.0` and `@typescript-eslint/eslint-plugin` `^8.56.0`. npm 7 and later install a missing required peer on their own, so declare `typescript` at the root at the version the repository uses. Each floor is the oldest release Hone is tested on: TypeScript 4.8 is the oldest whose syntax API the audit uses (`getModifiers`), ESLint 9.12.0 the first 9.x that can look up the configuration nearest each file, and typescript-eslint 8.56.0 the first whose peer range accepts ESLint 10. TypeScript stops below 7 because TypeScript 7's compiler API is a different one. Yarn Plug'n'Play is not supported.
191
+ - Hone's own packages, `zod`, `jsonc-parser` and `@eslint/plugin-kit`, exact-pinned in `dependencies` and locked by `pnpm-lock.yaml`: bundled into the package. They are implementation details: nothing of theirs crosses into the repository's code or configuration.
192
+ - The repository's own toolchain, declared as `peerDependencies`: `typescript` `>=4.8.4 <7.0.0`, a required peer because every audit clause needs it, and for the ESLint mechanism the optional peers `eslint` `^9.28.0 || ^10.0.0`, `@typescript-eslint/parser` `^8.56.0` and `@typescript-eslint/eslint-plugin` `^8.56.0`. npm 7 and later install a missing required peer on their own, so declare `typescript` at the root at the version the repository uses. Each floor is the oldest release Hone is tested on: TypeScript 4.8 is the oldest whose syntax API the audit uses (`getModifiers`), ESLint 9.28.0 the first 9.x with every bulk-suppressions option a carve-out kept in `eslint-suppressions.json` relies on (`--pass-on-unpruned-suppressions` came last), and typescript-eslint 8.56.0 the first whose peer range accepts ESLint 10. TypeScript stops below 7 because TypeScript 7's compiler API is a different one. Yarn Plug'n'Play is not supported.
157
193
 
158
- Hone loads the toolchain by Node's own resolution, upward from the install directory, which is the same resolution the pieces' plugin modules get when the team's ESLint loads the projection. Hone's query of the team's configuration, its governance run and the pieces therefore all use one copy, the repository's. Keep the toolchain resolvable from the repository root: declare it in the root `package.json` (in a pnpm workspace, `pnpm add -Dw`). A package may install a different ESLint for its own lint script; Hone's verdict still comes from the root's, its governance behaviour is the same on either supported line, and the pieces that wrap native rules wrap the root's copies there too. Hone's tests run the governance path and every piece's shared cases on four ESLint lines, 9.12.0 and 10.0.0 with typescript-eslint 8.56.0 and 9.39.5 and 10.11.0 with 8.71.2, and the audit pieces' shared cases on TypeScript 4.8.4 and 6.0.3; the in-process consumer fixtures run on ESLint 10.11.0, and `install-proof` runs real consumers on each floor.
194
+ Hone loads the toolchain by Node's own resolution, upward from the install directory, which is the same resolution the pieces' plugin modules get when the team's ESLint loads the projection. Hone's query of the team's configuration, its governance run and the pieces therefore all use one copy, the repository's. Keep the toolchain resolvable from the repository root: declare it in the root `package.json` (in a pnpm workspace, `pnpm add -Dw`). A package may install a different ESLint for its own lint script; Hone's verdict still comes from the root's, its governance behaviour is the same on either supported line, and the pieces that wrap native rules wrap the root's copies there too. Hone's tests run the governance path and every piece's shared cases on four ESLint lines, 9.28.0 and 10.0.0 with typescript-eslint 8.56.0 and 9.39.5 and 10.11.0 with 8.71.2, and the audit pieces' shared cases on TypeScript 4.8.4 and 6.0.3; the in-process consumer fixtures run on ESLint 10.11.0, and `install-proof` runs real consumers on each floor.
159
195
 
160
- A peer that is missing, cannot load, or is outside its range stops the mechanism before any piece loads, with one line such as `load failure: runner-failed eslint toolchain-unavailable eslint found not installed, supported ^9.12.0 || ^10.0.0: add a supported version to the devDependencies of the repository root`. A `typescript` that is not installed at all is reported the same way, with the line saying that `typescript` is a required peer of `@hailstails/hone` and the install is incomplete, since a supported install always has it; one that is installed but out of range or unloadable gets the plain line. A peer that resolves from inside the installed package, such as an `eslint` left in `node_modules/@hailstails/hone/node_modules`, stops it as `toolchain-shadowed`, naming where it resolved and the folder to delete before reinstalling core. A source checkout of Hone is its own development install, so its development toolchain in its own `node_modules` is not a shadow.
196
+ A peer that is missing, cannot load, or is outside its range stops the mechanism before any piece loads, with one line such as `load failure: runner-failed eslint toolchain-unavailable eslint found not installed, supported ^9.28.0 || ^10.0.0: add a supported version to the devDependencies of the repository root`. A `typescript` that is not installed at all is reported the same way, with the line saying that `typescript` is a required peer of `@hailstails/hone` and the install is incomplete, since a supported install always has it; one that is installed but out of range or unloadable gets the plain line. A peer that resolves from inside the installed package, such as an `eslint` left in `node_modules/@hailstails/hone/node_modules`, stops it as `toolchain-shadowed`, naming where it resolved and the folder to delete before reinstalling core. A source checkout of Hone is its own development install, so its development toolchain in its own `node_modules` is not a shadow.
161
197
 
162
198
  A repository can hold one `eslint.config.*` at its root or one per package. Hone resolves the team's configuration the way the team's own ESLint run does. ESLint 10, and ESLint 9 started with `--flag v10_config_lookup_from_file` (or `unstable_config_lookup_from_file`), use the `eslint.config.*` nearest each checked file. Plain ESLint 9 uses only the one in the directory it runs from, so for a repository whose `eslint` resolves to 9.x at `node_modules/eslint` and whose lint scripts carry no such flag, Hone reads the root `eslint.config.*` for every file, and fails the run as `team-config-unloadable` if there is none. When Hone cannot read an installed `eslint` at the repository root it assumes the nearest-to-file lookup. Each config that applies to a file must spread the projection. Detection cannot see how a task runner starts ESLint, so `disciplines.json` can state the lookup: `"eslintConfigLookup": "nearest-to-file"` or `"repository-root"`, which overrides detection. Both lookups are tested against monorepo fixtures with a config per package.
163
199
 
200
+ ## Compatibility
201
+
202
+ Hone's version numbers follow semantic versioning under these rules:
203
+
204
+ - A new or tightened check ships off by default in a minor release and becomes a default only in a major release.
205
+ - A change to the ESLint config that `hone project` generates, which an adopter must regenerate, is a minor release, with a clear message telling the adopter to regenerate: its changelog entry says to run `hone project` and commit the result, and until then the check reports the projection `out-of-date`.
206
+ - A change to a clause address, a config key in `disciplines.json` or `discipline-exceptions.json`, or a CLI flag is a major release.
207
+ - A breaking change to a type in `@hailstails/hone/rule-set` is a major release. `@hailstails/hone/audit` is experimental: its types may change in a minor release until it is marked stable.
208
+ - Before the first stable release, a change that would need a major release ships in a minor release instead.
209
+ - A pre-release previews the release it is numbered towards and is published under the `next` dist-tag. A change of any size can land between two pre-releases of the same release, and the changelog lists it.
210
+
211
+ Each release's changes are listed in [the changelog](https://github.com/HailsTails/hone/blob/main/CHANGELOG.md) in the repository.
212
+
164
213
  ## Known limits
165
214
 
166
215
  The ESLint pieces use the plugin namespace `hone` for CD-14 and `hone-cd<N>` for the others, so a rule id reads `hone/no-class-authoring`. The namespace `hone-core` is reserved for Hone's own machinery, never a discipline's rule: it names the projection's block names, such as `hone-core/piece/hone`, and the governance rule `hone-core/inline-config`, which reports inline configuration comments. No piece may use it.
@@ -184,7 +233,7 @@ This is the first release. Its tests cover each supported platform's ordinary pa
184
233
 
185
234
  ## Developing Hone
186
235
 
187
- This repository is self-contained: it holds its own configuration and its own lock. `package.json` declares the packages the code imports and the development tools, `bun.lock` locks both, `tsconfig.json` typechecks the code under `strict`, `lint.biome.json` configures the linter, and `vitest.config.ts` runs its tests. Install with `bun install --frozen-lockfile` in this directory, then run a script from it:
236
+ This repository is self-contained: it holds its own configuration and its own lock. `package.json` declares the packages the code imports and the development tools, `pnpm-lock.yaml` locks both, `tsconfig.json` typechecks the code under `strict`, `lint.biome.json` configures the linter, and `vitest.config.ts` runs its tests. `package.json` pins the pnpm version that locks and installs them, `pnpm-workspace.yaml` holds its settings, and pnpm resolves a dependency only to a release that is at least three days old when a dependency is added or updated; installing from the lock does not re-check it. Run `corepack enable` once so that Node provides that pnpm, install with `pnpm install --frozen-lockfile` in this directory, then run a script from it with `pnpm run <script>`:
188
237
 
189
238
  | Script | Runs |
190
239
  | --- | --- |
@@ -192,21 +241,37 @@ This repository is self-contained: it holds its own configuration and its own lo
192
241
  | `lint` | Biome with `lint.biome.json` |
193
242
  | `test` | Vitest with `vitest.config.ts` |
194
243
  | `check` | all three in that order |
195
- | `build-package` | `node scripts/build-package.ts`: bundles Hone with esbuild from its own installed packages into `dist/`, and adds the published `package.json`, the shipped documents and data, and `THIRD-PARTY-NOTICES.md`. It fails if an output imports anything but a `node:` builtin or a declared peer, if a command or runner is not emitted at its own path with its own code, if a bundled package's version is not the one the lock holds, or if a shipped page links to a file the package does not ship. The tool's name, package name, command name, reserved ESLint namespace, description, GitHub repository and the unrelated npm name to warn against live in `core/values/tool-identity.ts`, which the build, the install proof, the release text, the command's usage line and the ESLint runner all read. The reserved namespace is its own field, independent of the package name |
244
+ | `build-package` | `node scripts/build-package.ts`: bundles Hone with esbuild from its own installed packages into `dist/`, and adds the published `package.json`, the shipped documents and data, and `THIRD-PARTY-NOTICES.md`. It fails if an output imports anything but a `node:` builtin or a declared peer, if a command or runner is not emitted at its own path with its own code, if a bundled package's version is not the one the lock holds, or if a shipped page links to a file the package does not ship. The tool's name, package name, command name, shipped rule-set name, reserved ESLint namespace, description, GitHub repository and the unrelated npm name to warn against live in `core/values/tool-identity.ts`, which the build, the install proof, the release text, the command's usage line and the ESLint runner all read. The reserved namespace is its own field, independent of the package name |
196
245
  | `pack-package` | `node scripts/pack-package.ts`: builds `dist/` and packs it with `npm pack` into `artefacts/hailstails-hone-<version>.tgz`, named by the `version` in `package.json` |
197
246
  | `package-determinism` | `node scripts/check-package-determinism.ts`: builds and packs twice into separate temporary roots and fails naming any file that differs, or when the two packed tarballs differ |
198
- | `self-check` | `node scripts/self-check.ts check --repo .`: runs Hone's own check on this repository with `disciplines.json` and `discipline-exceptions.json`; pass `-- --base-revision <rev>`. See [Core's check on itself](#hones-check-on-itself) |
199
- | `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball and installs it offline into four CommonJS consumers in an OS temporary directory outside the working tree: the audit on TypeScript 4.8.4, ESLint 9.12.0, ESLint 10.0.0, and one without `eslint`. It installs each toolchain once, at the peers' floors, in a folder the consumers sharing it sit inside: TypeScript 4.8.4 alone for the audit consumer and the consumer without `eslint`, and ESLint 9.12.0 or 10.0.0 with typescript-eslint 8.56.0 and TypeScript 4.8.4 for the two ESLint consumers. Each consumer declares the required peer `typescript` at its floor in its own `devDependencies`, as an adopter does, and the proof checks that `typescript` resolves there at 4.8.4, since npm would otherwise install the newest supported release beside it. Each consumer runs both commands through the installed bins with type stripping off, expecting a fail on a class, a pass once it is removed, a projection importing each piece by package name, and `toolchain-unavailable` for the consumer without `eslint`; the temporary directory is removed afterwards |
247
+ | `self-check` | `node scripts/self-check.ts check --repo .`: runs Hone's own check on this repository with `disciplines.json` and `discipline-exceptions.json`; pass `--base-revision <rev>` after the script name. See [Core's check on itself](#hones-check-on-itself) |
248
+ | `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball and installs it offline into six CommonJS consumers in an OS temporary directory outside the working tree, each copied from its folder under `tests/test-fixtures/consumer-proof/`, which holds only what that consumer's action needs. Each consumer exists for one thing only an installed package shows. The audit consumer, on TypeScript 4.8.4, runs `check` through the installed bin and expects its finding. The ESLint 9.28.0 and 10.0.0 consumers run `project`, expect a projection importing the piece by package name, and expect its finding from `check`. The consumer without `eslint` expects `toolchain-unavailable`. These four run with type stripping off. The team consumer is the example [docs/extending.md](docs/extending.md) follows. On TypeScript 4.8.4 it type-checks a wrong team piece, rule set and ESLint piece settings with its own `tsc`, as described under Public type entries, and expects the three errors. On the development versions, TypeScript 6.0.3, ESLint 10.11.0 and typescript-eslint 8.71.2, it also type-checks its rule set under `nodenext` and `bundler` and a CommonJS file, then runs both commands with type stripping on: its `.ts` pieces load through the installed package and give one finding from each mechanism under the team's `acme/` prefix. Its root says `"type": "commonjs"`, the hard case, so its rule set carries its own `"type": "module"` `package.json`. It installs each toolchain once, in a folder the consumers sharing it sit inside: TypeScript 4.8.4 alone for the audit consumer, the consumer without `eslint` and the team consumer on 4.8.4; ESLint 9.28.0 or 10.0.0 with typescript-eslint 8.56.0 and TypeScript 4.8.4 for the two ESLint consumers; and the development versions for the team consumer. Each consumer declares the required peer `typescript` at its pin in its own `devDependencies`, as an adopter does, and the proof checks that `typescript` resolves there at that version, since npm would otherwise install the newest supported release beside it. A pass once a violation is removed, rule-set naming, plugin namespaces, settings overrides and per-package ESLint configs are proven by unit and in-process tests instead. The temporary directory is removed afterwards |
249
+ | `pull-request-title` | `node scripts/pull-request-title-command.ts <title>`: passes a title shaped as a Conventional Commits subject, `type(scope)!: description`, and fails any other with the expected form. See [Versions and releases](#versions-and-releases) |
250
+ | `release-pull-request` | `node scripts/release-pull-request-command.ts [pre-release\|stable]`: writes the next release's section into `CHANGELOG.md` and its version into `package.json`, in the working tree only. See [Versions and releases](#versions-and-releases) |
200
251
 
201
252
  ### Hone's check on itself
202
253
 
203
- `disciplines.json` selects every mechanical clause Hone ships, through the mechanism it names, and `eslint.config.mjs` spreads the committed `disciplines.eslint.mjs` projection, which `node scripts/self-check.ts project --repo .` regenerates. `discipline-exceptions.json` holds seven `authorised-location` records for `CD-19#import-boundaries`, each the single file that binds a runtime or third-party surface; they are imported, with `existing-authorisation` provenance, from the earlier records kept in `.constitution-authorised-locations/cd-19.json`. Strictness lives in `tsconfig.base.json`, which `tsconfig.json` extends.
254
+ `disciplines.json` selects every mechanical clause Hone ships, through the mechanism it names, confines the `eslint` package under CD-19's `confinedPackages`, and excludes `tests/test-fixtures/consumer-proof`: those folders are package-test content, the files of other repositories that `install-proof` copies out and checks with their own Hone run. `eslint.config.mjs` spreads the committed `disciplines.eslint.mjs` projection, which `node scripts/self-check.ts project --repo .` regenerates. `discipline-exceptions.json` holds eight `authorised-location` records for `CD-19#import-boundaries`, each the single file that binds a runtime or third-party surface; seven are imported, with `existing-authorisation` provenance, from the earlier records kept in `.constitution-authorised-locations/cd-19.json`, and the eighth, for `mechanisms/eslint/runner/native-rules.ts`, carries its own why-chain. Strictness lives in `tsconfig.base.json`, which `tsconfig.json` extends; `tsconfig.json` leaves the same consumer folders out, since their files compile against the installed package.
204
255
 
205
256
  `self-check` prints Hone's full report on itself, then one `self-check:` line. It fails when the run cannot load, or when any of `uncovered`, `stale`, `forfeited`, `doublyHeld`, `invalidRecords`, `unmeasured` or `projectionProblems` holds an entry: that is, when the selection, the exception records or the projection are not sound. It does not fail on `findings` or `unrecorded`. Those are printed in full and counted in the `self-check:` line, but they do not gate a change yet: the test fixtures hold deliberate violations, and some of Hone's own code does not meet every selected clause. CI runs `self-check` on every change with the pull request's base, or the previous `main`, as the base revision.
206
257
 
207
- Continuous integration runs `check`, `build-package`, `package-determinism` and `install-proof` on every pull request, drafts included, and on every push to `main`, from `bun.lock` alone. It runs the same steps on Windows and on Linux, and both pass.
258
+ Continuous integration runs `check`, `build-package`, `package-determinism` and `install-proof` on every pull request, drafts included, and on every push to `main`, from `pnpm-lock.yaml` alone. It runs the same steps on Windows and on Linux, and both pass. Two further jobs, `Package on Node <version> on <platform>`, are not required checks. One builds the package and runs `install-proof` on macOS with the oldest Node the package claims; the other does the same on Node 24 on Linux and also runs the test suite. The required jobs already prove the oldest claimed Node on Windows and Linux. The extra jobs show that the package installs and runs on the other platform and Node line, against the toolchain floors `install-proof` uses. A separate workflow, `pull-request-title.yml`, runs `pull-request-title` on each pull request's title whenever the pull request is opened, edited, reopened, marked ready or pushed to.
259
+
260
+ ### Versions and releases
261
+
262
+ Pull requests are squash-merged, and the pull request's title becomes the commit's subject on `main`. The `pull-request-title` check requires that title to be a Conventional Commits subject: `type(scope)!: description`, where the scope is optional and lowercase, `!` marks a breaking change as [Compatibility](#compatibility) defines it, and the type is one of `feat`, `fix`, `perf`, `revert`, `docs`, `refactor`, `test`, `build`, `ci`, `chore` or `style`. Reverting behaviour that has been released is breaking, so its title is `revert!:`; `revert:` without `!` is for undoing a change that has not been released, and counts as a patch. A title that changes the ESLint projection says that adopters must run `hone project`, since the title becomes the changelog entry. `.github/dependabot.yml` leaves Dependabot's routine version updates off and gives its security pull requests a conventional title with the type `build` and a scope, such as `build(deps):`. It covers the GitHub Actions the workflows use and, through the `npm` ecosystem, which is how Dependabot names pnpm, the JavaScript dependencies in `pnpm-lock.yaml`. A security release published in the last three days can be held back by the minimum release age when pnpm resolves it.
263
+
264
+ To prepare a release, create a new branch at the tip of `main` and run `pnpm run release-pull-request` on it before anything is committed to it. It finds the highest release tag `v<version>` merged into `HEAD`, reads the full message of every commit after it, and works out the next version. It needs that history to be the straight line of squash-merged commits that `main` holds, so it refuses, changing nothing and naming the commits, when any of them is a merge commit, since a merge brings in changes whose subjects it cannot size. It works out the version like this:
265
+
266
+ - A subject with `!`, or a message with a `BREAKING CHANGE:` or `BREAKING-CHANGE:` footer line, is a major change, `feat` a minor change, and every other subject a patch. While the major version is 0, a major change counts as a minor one, so the script never picks the first stable release: the owner prepares that release by hand, setting the version in `package.json` and writing its changelog section, and only on her word.
267
+ - On a pre-release, a change no larger than the one the pre-release is numbered towards moves to the next pre-release number; a larger one starts the next version's first pre-release. On a stable release, the change increments the version.
268
+ - The release stays on the latest tag's channel. Pass `stable` to finish a pre-release as its stable version, or `pre-release` to start a pre-release line from a stable one.
269
+
270
+ It then writes a section for that version at the top of `CHANGELOG.md`, grouping the subjects under Breaking changes, Features, Fixes and Other changes, and sets `version` in `package.json`. It refuses, changing nothing, when no subject follows the tag, when a merge commit does, when `package.json` is not at the tag's version, or when the changelog already has the new version. A subject that is not a Conventional Commits subject is named on standard error and counted as a patch under Other changes, or as a major under Breaking changes when its message has a breaking footer, so check its place before opening the pull request. If writing the second file fails, it restores the first. The script only edits those two files: it never commits, tags, pushes or publishes. Open the release pull request with the title `chore(release): <version>`.
271
+
272
+ `CHANGELOG.md` names versions, so it stays in the repository and out of the package; the shipped pages link to it on GitHub.
208
273
 
209
- A release starts from a pushed tag `v<version>` that matches the `version` in `package.json`. The release workflow runs `check`, `package-determinism` and `install-proof`, packs the tarball with `pack-package`, records the tarball's name and SHA-256 as outputs of the release job, and attaches it to a GitHub release for that tag. `gh release create` creates that release as a draft, uploads the tarball and only then publishes it, so with immutable releases on, the tarball is attached before the release's assets and tag become immutable. `scripts/release-text-command.ts` prints the release's title and notes from the identity, and its dist-tag: `next` when the version has a pre-release part such as `-pre.1` before any `+` build metadata, otherwise `latest`. The release is marked as a pre-release exactly when its dist-tag is `next`, and the step stops if any of the three cannot be printed. The release does not wait on npm.
274
+ Once the release pull request is on `main`, a release starts from a pushed tag `v<version>` that matches the `version` in `package.json`, pushed only on the owner's word. The release workflow runs `check`, `package-determinism` and `install-proof`, packs the tarball with `pack-package`, records the tarball's name and SHA-256 as outputs of the release job, and attaches it to a GitHub release for that tag. `gh release create` creates that release as a draft, uploads the tarball and only then publishes it, so with immutable releases on, the tarball is attached before the release's assets and tag become immutable. `scripts/release-text-command.ts` prints the release's title from the identity and the tag, its notes, which name the npm install command under its dist-tag and the attached tarball but no version, and its dist-tag: `next` when the version has a pre-release part such as `-pre.1` before any `+` build metadata, otherwise `latest`. The release is marked as a pre-release exactly when its dist-tag is `next`, and the step stops if any of the three cannot be printed. The release does not wait on npm.
210
275
 
211
276
  A version reaches npm in four steps:
212
277
 
@@ -215,6 +280,6 @@ A version reaches npm in four steps:
215
280
  3. The npm owner approves it, on npmjs.com under `@hailstails/hone`, Staged Packages, or with `npm stage approve <stage-id>`. Approval needs the owner's two-factor sign-in, so CI cannot approve.
216
281
  4. The version is published under its dist-tag and installable.
217
282
 
218
- The second job runs in the GitHub environment `npm`, which accepts only `v*` tags, and only when the repository variable `NPM_PUBLISH` is `enabled`; with any other value, or none, it is skipped and the release is unaffected. It authenticates by npm trusted publishing, so no npm token is stored. The trusted publisher is saved on npmjs.com under `@hailstails/hone`, Settings, Trusted publishing, GitHub Actions, as: user `HailsTails`, repository `hone`, workflow filename `release.yml`, environment `npm`, with both allowed actions, "npm publish" and "npm dist-tag", unticked, so CI can only stage. The published `package.json` carries `repository`, `homepage` and `bugs` from the identity's repository, which trusted publishing matches against this repository, and `publishConfig.access` `public`, because npm otherwise publishes a scoped package as restricted. `build-package` fails if a shipped page names the tarball at a version other than the one in `package.json`.
283
+ The second job runs in the GitHub environment `npm`, which accepts only `v*` tags, and only when the repository variable `NPM_PUBLISH` is `enabled`; with any other value, or none, it is skipped and the release is unaffected. It authenticates by npm trusted publishing, so no npm token is stored. The trusted publisher is saved on npmjs.com under `@hailstails/hone`, Settings, Trusted publishing, GitHub Actions, as: user `HailsTails`, repository `hone`, workflow filename `release.yml`, environment `npm`, with both allowed actions, "npm publish" and "npm dist-tag", unticked, so CI can only stage. The published `package.json` carries `repository`, `homepage` and `bugs` from the identity's repository, which trusted publishing matches against this repository, and `publishConfig.access` `public`, because npm otherwise publishes a scoped package as restricted. `build-package` fails if a shipped page names a versioned tarball of the package, at any version, or the version in `package.json`, with or without a leading `v`, so a page cannot name the current version and go stale on the next release.
219
284
 
220
285
  npm does not check a trusted publisher when it is saved, and one that has not completed a successful publish within 2 days of being added expires and can no longer be used or edited. npm's documentation does not say whether a staged publish counts as that first publish, so save the trusted publisher only just before pushing a tag, and approve the staged version within the same 2 days. A re-run of an older release run stages a version npm already has, so it cannot complete that first publish.
package/api/audit.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ export type { PieceFailure } from "../core/mechanism-port/piece-failure-types.js";
2
+ export type { ClauseSettingValues, RunnerClause } from "../core/mechanism-port/runner-module-types.js";
3
+ export type { ReadonlyJsonValue } from "../core/values/json-value.js";
4
+ export type { Hit } from "../core/mechanism-port/runner-result-types.js";
5
+ export type { Anchor, AnchorKind } from "../core/values/anchor.js";
6
+ export type { ClauseAddress, ToolRuleSet } from "../core/values/clause-address-types.js";
7
+ export type { ClauseId, DisciplineId, RuleSetName } from "../core/values/identifier-types.js";
8
+ export type { RepoPath } from "../core/values/repo-path-types.js";
9
+ export type { Result } from "../core/values/result.js";
10
+ export type { CommentRange, SyntaxApi, SyntaxNode, SyntaxTree } from "../mechanisms/audit/runner/typescript-parse.js";
11
+ export type { PieceHit, PreparedFileCheck, PreparedWalkerCheck, SourceObservers, WalkerFile, WalkerPiece, WalkerRepository } from "../mechanisms/audit/runner/walker-piece.js";
package/api/audit.mjs ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export type { AuthoredClauseDefinition as ClauseDefinition, AuthoredDisciplineFile as DisciplineFile, AuthoredPieceFile as PieceFile, AuthoredSourceCase as SourceCase, ClauseExceptions, ClauseSettingDeclaration, ClauseSettingDeclarations, } from "../core/rule-set-reader/authored-rule-set-types.js";
2
+ export type { AnchorKind } from "../core/values/anchor.js";
3
+ export type { JsonValue, ReadonlyJsonValue } from "../core/values/json-value.js";
4
+ export type { EslintPieceSettings, RuleOptions } from "../mechanisms/eslint/runner/eslint-piece-settings-types.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,53 @@
1
+ // mechanisms/audit/runner/cast-shape.ts
2
+ var SNIPPET_MAX_LENGTH = 80;
3
+ var castSnippetAt = (request) => {
4
+ const snippet = request.sourceFile.text.slice(request.position, request.position + SNIPPET_MAX_LENGTH).replace(/\n/g, " ");
5
+ return snippet.length === SNIPPET_MAX_LENGTH ? `${snippet}\u2026` : snippet;
6
+ };
7
+ var assertionOf = (request) => {
8
+ const { node, syntaxApi } = request;
9
+ if (syntaxApi.isAsExpression(node)) return { node, expression: node.expression, type: node.type, form: "as" };
10
+ if (syntaxApi.isTypeAssertionExpression(node)) return { node, expression: node.expression, type: node.type, form: "angle-bracket" };
11
+ return void 0;
12
+ };
13
+ var anyBearingFound = (request) => anyBearingOf(request) === "any-bearing" ? "any-bearing" : void 0;
14
+ var anyBearingOf = (request) => {
15
+ const { typeNode, syntaxApi } = request;
16
+ if (typeNode.kind === syntaxApi.SyntaxKind.AnyKeyword) return "any-bearing";
17
+ return syntaxApi.forEachChild(typeNode, (child) => anyBearingFound({ typeNode: child, syntaxApi })) ?? "any-free";
18
+ };
19
+ var satisfiesOperand = (request) => {
20
+ const { node, syntaxApi } = request;
21
+ if (node.kind !== syntaxApi.SyntaxKind.SatisfiesExpression) return void 0;
22
+ return syntaxApi.isSatisfiesExpression(node) ? node.expression : void 0;
23
+ };
24
+ var wrappedOperand = (request) => {
25
+ const { node, syntaxApi } = request;
26
+ if (syntaxApi.isParenthesizedExpression(node) || syntaxApi.isNonNullExpression(node)) return node.expression;
27
+ return satisfiesOperand({ node, syntaxApi });
28
+ };
29
+ var unwrappedExpression = (request) => {
30
+ const operand = wrappedOperand(request);
31
+ return operand === void 0 ? request.node : unwrappedExpression({ node: operand, syntaxApi: request.syntaxApi });
32
+ };
33
+ var unknownTypeOf = (request) => request.typeNode.kind === request.syntaxApi.SyntaxKind.UnknownKeyword ? "unknown" : "other";
34
+ var constTypeOf = (request) => {
35
+ const { typeNode, syntaxApi } = request;
36
+ if (!syntaxApi.isTypeReferenceNode(typeNode) || !syntaxApi.isIdentifier(typeNode.typeName)) return "other";
37
+ return typeNode.typeName.text === "const" ? "const" : "other";
38
+ };
39
+ var castShapeOf = (request) => {
40
+ const { assertion, syntaxApi } = request;
41
+ const operand = assertionOf({ node: unwrappedExpression({ node: assertion.expression, syntaxApi }), syntaxApi });
42
+ if (operand !== void 0 && unknownTypeOf({ typeNode: operand.type, syntaxApi }) === "unknown") return "through-unknown";
43
+ if (unknownTypeOf({ typeNode: assertion.type, syntaxApi }) === "unknown") return "unknown-widening";
44
+ if (constTypeOf({ typeNode: assertion.type, syntaxApi }) === "const") return "const-assertion";
45
+ return "type-assertion";
46
+ };
47
+
48
+ export {
49
+ castSnippetAt,
50
+ assertionOf,
51
+ anyBearingOf,
52
+ castShapeOf
53
+ };