@hailstails/hone 0.1.0-pre.4 → 0.1.0-pre.6

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 (150) hide show
  1. package/ADOPTING.md +172 -38
  2. package/MIGRATING.md +58 -7
  3. package/README.md +117 -35
  4. package/THIRD-PARTY-NOTICES.md +1 -1
  5. package/api/audit.d.ts +3 -2
  6. package/api/rule-set.d.ts +2 -4
  7. package/chunks/chunk-3HFJHJDO.js +53 -0
  8. package/chunks/chunk-5LCLBXP7.js +76 -0
  9. package/chunks/{chunk-BX6QHLSZ.js → chunk-ET5EBSJX.js} +61 -6
  10. package/chunks/chunk-LDQUT742.js +15 -0
  11. package/chunks/{chunk-RZA3OVOO.js → chunk-LOYT2AGY.js} +10 -9
  12. package/chunks/chunk-MVK5KFJI.js +421 -0
  13. package/chunks/{chunk-FOAGAYXM.js → chunk-NCDYOPHG.js} +7224 -2361
  14. package/chunks/chunk-WPRR2MPJ.js +22 -0
  15. package/chunks/{chunk-EYCRDEXX.js → chunk-XB4PCY3Q.js} +2 -13
  16. package/core/check/tool-command.js +1130 -230
  17. package/core/mechanism-port/piece-failure-types.d.ts +14 -0
  18. package/core/mechanism-port/runner-module-types.d.ts +5 -0
  19. package/core/rule-set-reader/authored-rule-set-types.d.ts +48 -0
  20. package/core/values/json-value.d.ts +3 -0
  21. package/docs/adding-a-discipline-or-mechanism.md +29 -13
  22. package/docs/extending.md +358 -0
  23. package/docs/output-contract.md +326 -0
  24. package/mechanisms/audit/CD-1/any-cast.js +9 -37
  25. package/mechanisms/audit/CD-19/import-boundaries.js +79 -68
  26. package/mechanisms/audit/CD-19/piece.json +5 -0
  27. package/mechanisms/audit/CD-2/cast-expressions.js +14 -37
  28. package/mechanisms/audit/CD-2/piece.json +6 -1
  29. package/mechanisms/audit/CD-5/comments-directives.js +121 -55
  30. package/mechanisms/audit/CD-5/piece.json +7 -0
  31. package/mechanisms/audit/runner/README.md +4 -2
  32. package/mechanisms/audit/runner/runner.js +102 -36
  33. package/mechanisms/audit/runner/typescript-parse.d.ts +6 -0
  34. package/mechanisms/audit/runner/walker-piece.d.ts +5 -5
  35. package/mechanisms/eslint/CD-2/README.md +12 -0
  36. package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +16 -0
  37. package/mechanisms/eslint/CD-2/piece.json +25 -0
  38. package/mechanisms/eslint/runner/README.md +12 -5
  39. package/mechanisms/eslint/runner/runner.js +940 -232
  40. package/methods/README.md +2 -0
  41. package/methods/assessment-template.md +35 -0
  42. package/methods/lenses/clean-architecture.md +2 -2
  43. package/methods/lenses/decomposition.md +2 -2
  44. package/methods/lenses/defended-on-intent.md +7 -7
  45. package/methods/lenses/di-discipline.md +38 -26
  46. package/methods/lenses/errors-as-data.md +2 -2
  47. package/methods/lenses/function-first.md +2 -2
  48. package/methods/lenses/naming.md +2 -2
  49. package/methods/lenses/test-discipline.md +15 -13
  50. package/methods/lenses/type-soundness.md +2 -2
  51. package/methods/lenses/zod-boundary.md +2 -2
  52. package/package.json +5 -4
  53. package/rules/CD-1/CHECKS.md +37 -0
  54. package/rules/CD-1/README.md +17 -32
  55. package/rules/CD-1/discipline.json +16 -6
  56. package/rules/CD-10/CHECKS.md +49 -0
  57. package/rules/CD-10/README.md +21 -49
  58. package/rules/CD-11/CHECKS.md +13 -0
  59. package/rules/CD-11/README.md +14 -8
  60. package/rules/CD-12/CHECKS.md +13 -0
  61. package/rules/CD-12/README.md +14 -8
  62. package/rules/CD-13/CHECKS.md +13 -0
  63. package/rules/CD-13/README.md +14 -8
  64. package/rules/CD-14/CHECKS.md +49 -0
  65. package/rules/CD-14/README.md +22 -48
  66. package/rules/CD-15/CHECKS.md +40 -0
  67. package/rules/CD-15/README.md +22 -40
  68. package/rules/CD-16/CHECKS.md +7 -0
  69. package/rules/CD-16/README.md +3 -5
  70. package/rules/CD-17/CHECKS.md +37 -0
  71. package/rules/CD-17/README.md +17 -31
  72. package/rules/CD-18/CHECKS.md +13 -0
  73. package/rules/CD-18/README.md +15 -9
  74. package/rules/CD-19/CHECKS.md +49 -0
  75. package/rules/CD-19/README.md +18 -34
  76. package/rules/CD-19/discipline.json +6 -8
  77. package/rules/CD-2/CHECKS.md +56 -0
  78. package/rules/CD-2/README.md +19 -32
  79. package/rules/CD-2/discipline.json +93 -7
  80. package/rules/CD-20/CHECKS.md +7 -0
  81. package/rules/CD-20/README.md +3 -5
  82. package/rules/CD-21/CHECKS.md +13 -0
  83. package/rules/CD-21/README.md +14 -9
  84. package/rules/CD-22/CHECKS.md +13 -0
  85. package/rules/CD-22/README.md +13 -8
  86. package/rules/CD-23/CHECKS.md +35 -0
  87. package/rules/CD-23/README.md +14 -29
  88. package/rules/CD-24/CHECKS.md +7 -0
  89. package/rules/CD-24/README.md +3 -5
  90. package/rules/CD-25/CHECKS.md +38 -0
  91. package/rules/CD-25/README.md +20 -32
  92. package/rules/CD-26/CHECKS.md +36 -0
  93. package/rules/CD-26/README.md +18 -31
  94. package/rules/CD-27/CHECKS.md +45 -0
  95. package/rules/CD-27/README.md +18 -40
  96. package/rules/CD-28/CHECKS.md +13 -0
  97. package/rules/CD-28/README.md +14 -8
  98. package/rules/CD-29/CHECKS.md +13 -0
  99. package/rules/CD-29/README.md +12 -8
  100. package/rules/CD-3/CHECKS.md +42 -0
  101. package/rules/CD-3/README.md +20 -42
  102. package/rules/CD-30/CHECKS.md +13 -0
  103. package/rules/CD-30/README.md +13 -8
  104. package/rules/CD-31/CHECKS.md +13 -0
  105. package/rules/CD-31/README.md +12 -8
  106. package/rules/CD-32/CHECKS.md +13 -0
  107. package/rules/CD-32/README.md +13 -8
  108. package/rules/CD-33/CHECKS.md +13 -0
  109. package/rules/CD-33/README.md +13 -8
  110. package/rules/CD-34/CHECKS.md +13 -0
  111. package/rules/CD-34/README.md +12 -8
  112. package/rules/CD-39/CHECKS.md +13 -0
  113. package/rules/CD-39/README.md +13 -8
  114. package/rules/CD-4/CHECKS.md +13 -0
  115. package/rules/CD-4/README.md +15 -8
  116. package/rules/CD-40/CHECKS.md +39 -0
  117. package/rules/CD-40/README.md +17 -33
  118. package/rules/CD-41/CHECKS.md +54 -0
  119. package/rules/CD-41/README.md +23 -54
  120. package/rules/CD-42/CHECKS.md +47 -0
  121. package/rules/CD-42/README.md +19 -47
  122. package/rules/CD-43/CHECKS.md +37 -0
  123. package/rules/CD-43/README.md +15 -31
  124. package/rules/CD-44/CHECKS.md +48 -0
  125. package/rules/CD-44/README.md +20 -48
  126. package/rules/CD-45/CHECKS.md +13 -0
  127. package/rules/CD-45/README.md +14 -8
  128. package/rules/CD-46/CHECKS.md +7 -0
  129. package/rules/CD-46/README.md +16 -4
  130. package/rules/CD-47/CHECKS.md +37 -0
  131. package/rules/CD-47/README.md +16 -32
  132. package/rules/CD-5/CHECKS.md +52 -0
  133. package/rules/CD-5/README.md +22 -40
  134. package/rules/CD-5/discipline.json +66 -0
  135. package/rules/CD-6/CHECKS.md +51 -0
  136. package/rules/CD-6/README.md +22 -51
  137. package/rules/CD-7/CHECKS.md +46 -0
  138. package/rules/CD-7/README.md +23 -46
  139. package/rules/CD-7a/CHECKS.md +38 -0
  140. package/rules/CD-7a/README.md +14 -32
  141. package/rules/CD-8/CHECKS.md +42 -0
  142. package/rules/CD-8/README.md +20 -42
  143. package/rules/CD-9/CHECKS.md +13 -0
  144. package/rules/CD-9/README.md +15 -8
  145. package/rules/README.md +5 -3
  146. package/rules/SPIRIT.md +50 -0
  147. package/core/mechanism-port/runner-failure-types.d.ts +0 -38
  148. package/core/rule-set-reader/rule-set-types.d.ts +0 -41
  149. /package/api/{audit.js → audit.mjs} +0 -0
  150. /package/api/{rule-set.js → rule-set.mjs} +0 -0
package/README.md CHANGED
@@ -20,49 +20,83 @@ Two mechanisms ship: `audit`, a standalone TypeScript syntax walker, and `eslint
20
20
 
21
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.
22
22
 
23
- 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).
24
24
 
25
25
  ## Commands
26
26
 
27
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:
28
28
 
29
29
  ```text
30
- hone check --repo <dir> [--base-revision <rev>] [--report-output <output>]
30
+ hone check --repo <dir> [--base-revision <revision>] [--report-output <full|failures-only|counts|verdict-only>] [--forfeiture <this-run|elsewhere>]
31
31
  hone project --repo <dir>
32
+ hone --help
33
+ hone --version
32
34
  ```
33
35
 
34
- `hone` with no subcommand, or with one it does not know, is a load failure `arguments-invalid` whose line ends with the usage, and exits `2`. From a source checkout the same command is `node core/check/tool-command.ts check --repo <dir>`.
36
+ `--repo` is the folder that holds `disciplines.json`, usually the repository root. `hone --help` lists the commands, `hone check --help` and `hone project --help` list each one's options and exit codes, and `hone --version` prints the installed version. A command typed wrongly is a load failure `arguments-invalid` that says what was wrong, a `--repo` folder with no `disciplines.json` is the load failure `selection-absent`, and an error Hone did not expect is the load failure `unexpected-error`; each exits `2`. Everything Hone prints goes to standard output, so exit `1` always comes with `verdict: fail`. From a source checkout the same command is `node core/check/tool-command.ts check --repo <dir>`.
35
37
 
36
- `hone check` loads the repository's selection, exceptions, rule sets and pieces; works out which files changed since `--base-revision`; runs each selected mechanism once over the repository's tracked `.ts`, `.tsx`, `.mts` and `.cts` files; applies the exceptions; and prints a plain-text report ending in `verdict: pass` or `verdict: fail`.
38
+ [docs/output-contract.md](docs/output-contract.md) lists every line `hone` prints, exactly as it prints it, with the exit codes and which parts are stable for hooks, CI and agents to rely on. A test renders every kind of line and checks it against that page, both ways.
37
39
 
38
- | Exit | `hone check` | `hone project` |
39
- | --- | --- | --- |
40
- | `0` | the verdict is `pass` | every projection was written or already current |
41
- | `1` | the verdict is `fail` | not used |
42
- | `2` | an input could not be loaded, or a mechanism failed or returned invalid output | any failure |
43
-
44
- A load failure prints one line, `load failure: <kind> <fields>`.
40
+ `hone check` loads the repository's selection, exceptions, rule sets and pieces; works out which files changed since `--base-revision`; runs each selected mechanism once over the repository's tracked `.ts`, `.tsx`, `.mts` and `.cts` files; applies the exceptions; and prints a plain-text report ending in `verdict: pass` or `verdict: fail`. It exits `0` when the verdict is `pass`, `1` when it is `fail`, and `2` on a load failure, which prints one line, `load failure: <kind> <fields>`. `hone project` exits `0` or `2`.
45
41
 
46
- 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.
42
+ The report lists the excluded paths, the clauses not adopted, the clauses adopted with their mechanism not run, findings, exempted findings, uncovered clauses, stale, forfeited, unrecorded and doubly-held exceptions, invalid exception records, unmeasured checks, projection problems, any part of the assessment left to another run and, last, where to read first for each clause with findings, each with its count. The verdict is `pass` only when every list except the excluded paths, clauses not adopted, clauses not run, exempted findings, assessment and where to read first is empty.
47
43
 
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`.
44
+ An `unrecorded` line is `<clause> <mechanism> <kind> <detail>`. Two kinds end with a note:
49
45
 
50
- | Output | Prints |
46
+ | Kind | Line |
51
47
  | --- | --- |
52
- | `full` | every non-empty section with its entries, then the verdict |
53
- | `failures-only` | the same without the `excluded` and `exempted` sections |
54
- | `counts` | one `<section> (<count>)` line per non-empty section, with ` informational` after `excluded` and `exempted`, then the verdict |
55
- | `verdict-only` | only the verdict line |
48
+ | `inline-disable` naming no rule | `<clause> eslint inline-disable <file>:<line> <comment> names no rule and escapes every selected clause: naming the rule is the cheap fix` |
49
+ | `command-line-option` that weakens the run | `<clause> eslint command-line-option <package.json> <script> <option> weakens the script's whole run, so no record can cover it: remove it from the script` |
50
+ | `command-line-option` Hone cannot judge, because another command comes before `eslint` in its script | `<clause> eslint command-line-option <package.json> <script> <option>: <command> is not the first command of its script, so Hone cannot tell what the option does to the files under check; give <command> a script of its own, such as "<invocation>"` |
51
+ | `command-line-option` Hone cannot judge, because something before `eslint` in its own command is not a package runner or a `NAME=value` setting | `<clause> eslint command-line-option <package.json> <script> <option>: "<wrapper>" comes before <command> and is neither a package runner nor a NAME=value setting, so Hone cannot tell what the option does to the files under check; put only package runners and NAME=value settings before <command>` |
52
+
53
+ `<command>` is the `eslint` call as the script writes it, `<invocation>` is its whole command with its settings and options, from the same script, and `<wrapper>` is the first token before it that Hone does not read, such as `env` or a runner flag like `-y` or `-C`. `cross-env` followed only by `NAME=value` settings counts as a setting. Once only package runners and settings come first, Hone judges the option: `-c` naming the config ESLint already finds, and `--ignore-pattern` that ignores no checked file, are then not reported.
54
+
55
+ `readFirst` comes last, just before the verdict, so a reader who looks only at the end of a failing report lands on it. It has one line per clause with findings, not one per finding, in the order the findings first name the clauses. Each line points at the Spirit section of the clause's rule page, `rules/<ID>/README.md` in the clause's rule set, and, where the repository has written one, at the clause's own section in `disciplines.assessment.md` at the repository root first. That file is where a repository records its own causes, forward goal and steps for a clause; [ADOPTING step 5a](ADOPTING.md#5a-write-the-assessment) says how to write it. Paths are printed with forward slashes, relative to the `--repo` folder; a page on another drive is printed as its absolute path.
56
+
57
+ When `disciplines.assessment.md` is not written yet, or cannot be read, one note line comes first and says so, naming ADOPTING step 5a; each clause line then names its rule page only. The note counts as an entry, so a report with two failing clauses and no assessment file prints `readFirst (3)`. A clause line names the clause's section when the file has one, and says `disciplines.assessment.md does not assess this clause` when the file is there without it. [The output contract](docs/output-contract.md#report-lines) lists every `readFirst` line exactly.
58
+
59
+ A file that does not assess a clause is normal: the assessment covers the clauses the repository chose to describe, and the rule page's Spirit is the read for the rest.
60
+
61
+ A clause's section is a level-2 heading whose text is exactly the clause address as the report prints it (`## CD-15#loops`, `## team/TM-1#no-tmp-files`). Trailing spaces, a carriage return and a byte order mark at the start of the file are ignored. Nothing else is normalised: `## CD-15#loops ##`, `## CD-15#loops`, `### CD-15#loops` and `## hone/CD-15#loops` are not that clause's section, and a heading inside a fenced code block (opened by three or more backticks or tildes, closed by at least as many of the same character) is not counted.
62
+
63
+ Hone matches the heading only; it never reads the section's text. A missing file or section never fails the run. A run with no findings prints no `readFirst` section and reads neither file, so its report is unchanged; a run with findings reads `disciplines.assessment.md` once and checks that each failing clause's rule page exists.
64
+
65
+ `--report-output` sets how much of the report is printed for one run, overriding `reportOutput` in `disciplines.json`; with neither, the output is `full`. `full` prints every non-empty section, `failures-only` leaves out the informational sections and keeps `readFirst`, `counts` prints each section's heading line only, with `informational` or `guidance` after the sections that never fail the run, and `verdict-only` prints the verdict line alone; [the output contract](docs/output-contract.md#the-report) shows each.
56
66
 
57
67
  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.
58
68
 
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.
69
+ 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. Each line says what Hone needs:
70
+
71
+ ```text
72
+ forfeiture-unmeasured no-base-revision: no --base-revision was given, so file carve-outs cannot be checked for decay; pass --base-revision with the branch's base, such as origin/main, or leave decay to another run with "assessment": { "forfeiture": "elsewhere" } in disciplines.json or --forfeiture elsewhere
73
+ import-unmeasured no-base-revision: no --base-revision was given, so imported records cannot be checked against it; pass --base-revision with the branch's base, such as origin/main
74
+ legacy-chain-unmeasured no-base-revision: no --base-revision was given, so legacy-chain records cannot be checked against it; pass --base-revision with the branch's base, such as origin/main
75
+ ```
76
+
77
+ A `--base-revision` that git cannot use gives the same kinds as `base-git-failed`, naming the revision in double quotes, escaped as in JSON, with git's own first line:
78
+
79
+ ```text
80
+ forfeiture-unmeasured base-git-failed "origin/main": git could not list the files changed since that revision and said "<git's first line>"; Hone needs that revision and the history back to where this branch left it, or leave decay to another run with "assessment": { "forfeiture": "elsewhere" } in disciplines.json or --forfeiture elsewhere
81
+ import-unmeasured base-git-failed "origin/main": git could not read the exception records at that revision and said "<git's first line>"; Hone needs the exception records as they were at that revision
82
+ legacy-chain-unmeasured base-git-failed "origin/main": git could not read the exception records at that revision and said "<git's first line>"; Hone needs the exception records as they were at that revision
83
+ ```
60
84
 
61
- `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`.
85
+ `--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:
86
+
87
+ ```text
88
+ assessment (1)
89
+ forfeiture elsewhere: 37 file carve-outs not checked for decay in this run
90
+ verdict: pass (partial assessment)
91
+ ```
92
+
93
+ 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.
94
+
95
+ `hone project` writes the native configuration each embedded mechanism needs, and prints `<path> <effect>` per file: `written`, `unchanged`, `removed` for a package slice Hone wrote whose folder is no longer a config root, or `left-in-place` for such a file whose bytes are not what Hone would write there. The audit mechanism is standalone and writes nothing, so with only the walker selected the command prints nothing and exits `0`.
62
96
 
63
97
  ## Adopting the ESLint mechanism
64
98
 
65
- 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:
99
+ 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:
66
100
 
67
101
  ```js
68
102
  import disciplines from "./disciplines.eslint.mjs";
@@ -73,8 +107,46 @@ export default [
73
107
  ];
74
108
  ```
75
109
 
76
- This is the only supported way to adopt the rules. On every check, Hone reads the team's resolved configuration for each checked file and fails the run if the projection is missing (`mechanism-not-run eslint missing`), not in effect (`mechanism-not-run eslint not-included`), or differs from what `hone project` would write now (`eslint out-of-date`). Re-run `hone project` after changing the selection or the exceptions.
110
+ This is the only supported way to adopt the rules. On every check, Hone reads the team's resolved configuration for each checked file and fails the run if the projection is missing, not in effect, or differs from what `hone project` would write now, with the line that says what to do:
111
+
112
+ ```text
113
+ mechanism-not-run eslint missing: disciplines.eslint.mjs is not written; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
114
+ mechanism-not-run eslint not-included: the eslint configuration leaves the projection out of effect for a file under check; spread the default export of disciplines.eslint.mjs, or of a package's own disciplines.eslint.mjs in that package, last in the configuration that file loads, after every other block (an import placed last without the spread applies nothing), or, where a tool such as sku generates the configuration, last in the configuration the tool takes
115
+ eslint out-of-date: disciplines.eslint.mjs differs from what hone project writes now; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
116
+ ```
117
+
118
+ The command on these lines runs the entry file of the Hone that ran the check with `node`, with the repository the check measured, both as absolute paths with forward slashes, so it runs as printed from any directory; the lines above show an install at `/work/shop`. Re-run `hone project` after changing the selection or the exceptions.
119
+
120
+ ### Package slices
121
+
122
+ A package that runs ESLint from its own folder resolves the `files` of its config against that folder, so spreading the root projection there loses every carve-out written with a root-relative path. `hone project` therefore writes one projection per config root. The repository root gets `disciplines.eslint.mjs` as above. Under the nearest-to-file lookup, each package folder with a tracked `eslint.config.*` is a config root; under the repository-root lookup a package's own config is never loaded, so it gets no slice. Each folder `disciplines.json` lists under `eslintConfigRoots` is a config root under either lookup. Each package config root gets its own `disciplines.eslint.mjs` beside it: the same pieces, imported by a path relative to that folder, and only the records for files under it, with paths relative to it; clause-wide carve-outs go in every slice. Each package config spreads its own slice:
123
+
124
+ ```js
125
+ import disciplines from "./disciplines.eslint.mjs";
126
+
127
+ export default [{ files: ["**/*.{ts,tsx,mts,cts}"] }, ...disciplines];
128
+ ```
129
+
130
+ A package with no `eslint.config.*` of its own is linted by the nearest config above it, so its records stay in that config's slice. A file is governed by the deepest config root that contains it. A folder holding its own `disciplines.json` gets no slice, and nor does anything under it: its ESLint configuration is not managed from this repository, and nested Hone configurations are not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)). When that folder's own config leaves a carve-out recorded there out of effect, the `mechanism-not-run` line it explains adds the folder, which `--report-output failures-only` prints too. Governing the folder from this repository works today: remove its `disciplines.json`, keep its records here, and `hone project` writes its slice. With package slices also reported, the line points at them:
77
131
 
132
+ ```text
133
+ mechanism-not-run eslint not-included: the eslint configuration leaves the projection out of effect for a file under check; spread the default export of disciplines.eslint.mjs, or of a package's own disciplines.eslint.mjs in that package, last in the configuration that file loads, after every other block (an import placed last without the spread applies nothing), or, where a tool such as sku generates the configuration, last in the configuration the tool takes; the eslint lines under projectionProblems name the package slices involved; fixtures/a hold their own disciplines.json, and nested Hone configurations are not supported yet (https://github.com/HailsTails/hone/issues/72): to govern such a folder from this repository, remove its disciplines.json and keep its records here, then run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop, which writes its slice
134
+ ```
135
+
136
+ A config root keeps its slice even where a config above it ignores its folder: a lint run from that folder loads its own config and never reads the ignores above it, so `hone project` writes the same slices from the same inputs every time. `not-applied` for such a package judges each recorded file by its nearest config, the one that lint loads. A repository with only a root config gets exactly the projection it had before.
137
+
138
+ The check reports each package slice under the mechanism, naming the slice: out of date, missing, or, when ESLint resolves each file from its nearest config and a package's carve-outs are not in effect, for example because its config spreads the root projection or nothing instead of its slice, not applied, beside `mechanism-not-run eslint not-included`. A folder listed under `eslintConfigRoots` with no `eslint.config.*` on disk is unconfigured: nothing there can load its slice, so Hone would otherwise say nothing about that package; generate its config before the check runs, as a tool such as sku does on any of its commands:
139
+
140
+ ```text
141
+ eslint out-of-date packages/a/disciplines.eslint.mjs: that slice differs from what hone project writes now; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
142
+ eslint missing packages/a/disciplines.eslint.mjs: that slice is not written; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
143
+ eslint not-applied packages/a/disciplines.eslint.mjs: the eslint configuration for packages/a leaves records of that slice out of effect; spread the default export of packages/a/disciplines.eslint.mjs last in that package's configuration, in place of any other projection it spreads, or, where a tool such as sku generates the configuration, last in the configuration the tool takes
144
+ eslint unconfigured packages/a/disciplines.eslint.mjs: packages/a has no eslint configuration file on disk, so nothing loads that slice; run the tool that generates it (for sku, sku configure) before the check
145
+ ```
146
+
147
+ A slice is not-applied only when a recorded file under check in that package is not excepted; a package with no file exceptions gets the same rules from either projection, so the check is silent there until the package has one.
148
+
149
+ `hone project` removes a tracked `disciplines.eslint.mjs` whose folder is no longer a config root only when its bytes are exactly what Hone would write for that folder now, so a file Hone did not write is never deleted; any other such file is reported `left-in-place`. Under the repository-root lookup no package folder is a config root, so `hone project` removes each package slice it wrote; a package config that still imports its slice then fails to load when someone lints from that package. List such a package under `eslintConfigRoots` to keep its slice, or stop importing it.
78
150
  A file carve-out stays in the projection after it is forfeited, so the team's own ESLint run keeps ignoring that file; Hone's check is what fails it, as `forfeited`.
79
151
 
80
152
  Hone's own ESLint run uses only the runner's configuration, with ignores, suppressions and inline configuration off, so nothing in the team's setup can change a finding. Every way the team's setup can weaken a selected rule (a native channel) is reported instead, and only an override that matches an exception record is accepted. The guide has the table.
@@ -97,12 +169,16 @@ At the repository root. It selects clauses and the mechanism that checks each on
97
169
  ```
98
170
 
99
171
  - `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>`.
100
- - `clauses` maps a clause address to a mechanism id. An address is `[<ruleSet>/]<DisciplineId>#<clauseId>`; no prefix means the `hone` rule set. The mechanism must be one the clause lists.
101
- - Selecting a clause adopts its discipline. Mechanical clauses of an adopted discipline that are not selected are reported as uncovered, and fail the run.
172
+ - `clauses` maps a clause address to a mechanism id, to `"not-run"` 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.
173
+ - Listing a clause adopts its discipline. Mechanical clauses of an adopted discipline that are not listed are reported as uncovered, and fail the run.
174
+ - `"not-run"` states that the clause is adopted and binds the repository, but its mechanism is not run: the check is not a true measure of the rule's intent here, or cannot work here. The rule is enforced by review. `"not-adopted"` states that the clause does not apply to the repository. Either way the clause is never run and never projected, and its mechanism is not loaded unless another clause uses it. The report lists it under `notRun`, as `<clause> adopted, mechanism not run: enforced by review`, or under `notAdopted`; both are informational, and the run is still a whole assessment. An exception record on it is invalid as `clause-not-run` or `clause-not-adopted`, and `clauseSettings` for it make `disciplines.json` `file-malformed`: remove them. The clause must still exist and be mechanical, in any rule set; a judgement clause is never listed in either state and fails the run as `judgement-clause-listed`. No mechanism may be named `not-run` or `not-adopted`.
102
175
  - A judgement clause cannot be selected; it is enforced by review.
103
176
  - `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.
177
+ - `eslintConfigRoots`, optional, lists repository folders that get their own projection slice under either lookup although they track no `eslint.config.*`, such as a package whose config a tool generates and ignores; see [Package slices](#package-slices). Globs are refused. Each entry must be a folder git tracks files under outside every `exclude` path, spelled exactly as git spells it; any other entry stops the run before anything is checked or written, as `load failure: config-root-untracked <folder>:` with what to fix.
104
178
  - `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).
105
179
  - `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).
180
+ - `clauseSettings`, optional, maps a selected clause address to an object of that clause's settings, for a clause whose CHECKS.md 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.
181
+ - `assessment`, optional, says which run assesses each concern. Its one key, `forfeiture`, is `"this-run"` (the default) or `"elsewhere"`; `--forfeiture` overrides it for one run; see [Commands](#commands). `waivedClauses`, which earlier releases accepted, is removed: it makes `disciplines.json` `file-malformed`, naming the clause states that replace it; see [MIGRATING.md](MIGRATING.md#12-moving-off-waivedclauses). Any other key makes it `file-malformed`, naming the key as not available in this version.
106
182
  - `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.
107
183
 
108
184
  ## discipline-exceptions.json
@@ -122,7 +198,8 @@ At the repository root; absent means no exceptions. Each entry names a selected
122
198
 
123
199
  - An `authorised-location` says the clause does not apply to that file.
124
200
  - A `file-carve-out` is debt in one file. It is forfeited once the file is touched.
125
- - A `clause-wide-carve-out` exempts the clause everywhere.
201
+ - A `clause-wide-carve-out` exempts the clause's findings everywhere. It does not hold an inline exception.
202
+ - An inline exception, an `eslint-disable` comment naming a selected rule or no rule, or a `@ts-expect-error`, `@ts-ignore` or `@ts-nocheck` directive under `CD-2#cast-expressions`, is held only by an `authorised-location` or `file-carve-out` on its clause and file. A comment naming no rule escapes every selected ESLint clause and needs one per clause. Without a record it is listed under `unrecorded` and fails the run. A lint-script option that weakens the whole run, such as `--rule`, `--suppress-all` or `-c` naming another config, cannot be recorded.
126
203
  - Every entry needs a `whyChain` (an `authorised-location` or `file-carve-out` may leave it out when `fileExceptionWhyChains` is `"optional"`; see below) that follows the [why-chain contract](docs/why-chain-contract.md): exactly five `{ "why", "because", "evidence" }` steps chained cause to cause, then `rootCause`, `rootCheck`, `readback` and `owner`. The contract lists what Hone refuses and what review still judges:
127
204
 
128
205
  ```json
@@ -159,10 +236,10 @@ The package has two public entries for TypeScript. Each holds types only, so imp
159
236
 
160
237
  | Entry | Status | What it is for |
161
238
  | --- | --- | --- |
162
- | `@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. |
163
- | `@hailstails/hone/audit` | Experimental | The types for writing an audit walker piece, `WalkerPiece` and what it needs. It may change in a minor release. |
239
+ | `@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. |
240
+ | `@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. |
164
241
 
165
- Both resolve with `moduleResolution` `"nodenext"` or `"bundler"`, and `install-proof` type-checks a team piece against them on TypeScript 4.8.4 (`"nodenext"`, since 4.8 has no `"bundler"`) and 6.0.3 (both). `@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.
242
+ 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.
166
243
 
167
244
  ## Runtime
168
245
 
@@ -170,13 +247,13 @@ Both resolve with `moduleResolution` `"nodenext"` or `"bundler"`, and `install-p
170
247
  - 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.
171
248
  - git 2.24 or later. Older git rejects `--end-of-options`, so the changed-file query fails and forfeiture is reported unmeasured.
172
249
  - 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.
173
- - 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.
250
+ - 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.
174
251
 
175
- 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.
252
+ 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.
176
253
 
177
- 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.
254
+ 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`. The line names every peer of that mechanism that is unavailable, separated by `; `, and then asks for a supported version of each, so one install fixes them all. 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.
178
255
 
179
- 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.
256
+ 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 its projection: the root config the root projection, each package config its own slice; see [Package slices](#package-slices). A config that fails to load stops the run as `team-config-unloadable`, naming the config, the checked file it applies to and ESLint's message, then the next step: fix that config. Only if its folder holds nothing Hone should check, add it to `exclude` in `disciplines.json` instead. A broken config in a folder that the repository's own ESLint never enters does not stop the run. Before failing, Hone asks the config that governs that folder, and each config above it up to the root, whether it really ignores both that folder and the file; a file that no `files` block matches is not taken for an ignored one. If one does, the file is treated like any other file the team's ESLint ignores and reported as an `ignore` native exception. Hone asks about a folder through a file inside it, so one gap remains: an ignore that matches every entry directly inside the folder but not the folder itself, such as `gen/*`, counts as ignoring `gen`, and Hone reports its files as ignored where the team's `eslint .` still loads the broken `gen/eslint.config.*` and fails. A file that no `eslint.config.*` applies to stops the run the same way, and the next step is to create one at the repository root that spreads the projection, as [ADOPTING.md](ADOPTING.md) step 4a shows. 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.
180
257
 
181
258
  ## Compatibility
182
259
 
@@ -184,11 +261,16 @@ Hone's version numbers follow semantic versioning under these rules:
184
261
 
185
262
  - A new or tightened check ships off by default in a minor release and becomes a default only in a major release.
186
263
  - 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`.
187
- - A change to a clause address, a config key in `disciplines.json` or `discipline-exceptions.json`, or a CLI flag is a major release.
264
+ - Renaming or removing a clause address, a config key in `disciplines.json` or `discipline-exceptions.json`, or a CLI flag, or changing what one means, is a major release. Adding one with a safe default is not.
265
+ - A change to what [the output contract](docs/output-contract.md) says a tool can parse is a major release: the command and option names, the exit codes and streams, the report's sections, outputs and verdict lines, the load failure kinds, and each line's leading fields up to its first value that may hold a space. What it marks not stable, such as the help text, the wording of `arguments-invalid` and `readFirst` lines and the repair text after a load failure's values, may change in a minor release, and a minor release may add a section, a kind of line or an option.
188
266
  - 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.
189
267
  - Before the first stable release, a change that would need a major release ships in a minor release instead.
190
268
  - 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.
191
269
 
270
+ `disciplines.json` and `discipline-exceptions.json` follow the same rules. A new key with a safe default, where nothing changes for an adopter who does not set it, is not breaking and can arrive in a minor release. A new required key with no safe default is breaking, and so is a change that makes a file that loads today stop loading or mean something else; both wait for a major release.
271
+
272
+ A clause that accepts `audit` keeps accepting it: `audit` is never removed from the mechanisms such a clause lists, so a selection that names `audit` for it keeps loading. A clause can only gain mechanisms.
273
+
192
274
  Each release's changes are listed in [the changelog](https://github.com/HailsTails/hone/blob/main/CHANGELOG.md) in the repository.
193
275
 
194
276
  ## Known limits
@@ -226,13 +308,13 @@ This repository is self-contained: it holds its own configuration and its own lo
226
308
  | `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` |
227
309
  | `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 |
228
310
  | `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) |
229
- | `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 |
311
+ | `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball and installs it with pnpm 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`. Each consumer declares its toolchain at exact pins in its own `devDependencies`, as an adopter does: 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. It declares the tarball beside them, pins the pnpm version this repository's `package.json` pins, and waits this repository's `minimumReleaseAge`. pnpm's store shares each toolchain package between consumers, and the proof prints where pnpm put the installed package and expects the report to name its pages there. 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 |
230
312
  | `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) |
231
313
  | `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) |
232
314
 
233
315
  ### Hone's check on itself
234
316
 
235
- `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.
317
+ `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.
236
318
 
237
319
  `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.
238
320
 
@@ -325,7 +325,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
325
325
  OTHER DEALINGS IN THE SOFTWARE.
326
326
  ```
327
327
 
328
- ## zod 4.4.3
328
+ ## zod 4.6.6
329
329
 
330
330
  License: MIT
331
331
 
package/api/audit.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export type { RunnerFailure, PeerKind } from "../core/mechanism-port/runner-failure-types.js";
2
- export type { RunnerClause } from "../core/mechanism-port/runner-module-types.js";
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";
3
4
  export type { Hit } from "../core/mechanism-port/runner-result-types.js";
4
5
  export type { Anchor, AnchorKind } from "../core/values/anchor.js";
5
6
  export type { ClauseAddress, ToolRuleSet } from "../core/values/clause-address-types.js";
package/api/rule-set.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- export type { ClauseDefinition, ClauseExceptions, DisciplineFile, PieceFile, SourceCase } from "../core/rule-set-reader/rule-set-types.js";
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
2
  export type { AnchorKind } from "../core/values/anchor.js";
3
- export type { ClauseId, DisciplineId, MechanismId } from "../core/values/identifier-types.js";
4
- export type { JsonValue } from "../core/values/json-value.js";
5
- export type { RepoPath } from "../core/values/repo-path-types.js";
3
+ export type { JsonValue, ReadonlyJsonValue } from "../core/values/json-value.js";
6
4
  export type { EslintPieceSettings, RuleOptions } from "../mechanisms/eslint/runner/eslint-piece-settings-types.js";
@@ -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
+ };
@@ -0,0 +1,76 @@
1
+ import {
2
+ sameClauseAddress
3
+ } from "./chunk-NCDYOPHG.js";
4
+
5
+ // mechanisms/audit/runner/type-directives.ts
6
+ var TYPE_DIRECTIVES = ["@ts-expect-error", "@ts-ignore", "@ts-nocheck"];
7
+ var LINE_SUPPRESSIONS = [
8
+ { directive: "@ts-expect-error", pattern: /^\/\/\/?\s*@ts-expect-error/ },
9
+ { directive: "@ts-ignore", pattern: /^\/\/\/?\s*@ts-ignore/ }
10
+ ];
11
+ var BLOCK_SUPPRESSIONS = [
12
+ { directive: "@ts-expect-error", pattern: /^\s*[/*]*\s*@ts-expect-error/ },
13
+ { directive: "@ts-ignore", pattern: /^\s*[/*]*\s*@ts-ignore/ }
14
+ ];
15
+ var FILE_SUPPRESSIONS = [
16
+ { directive: "@ts-nocheck", pattern: /^\/\/\/?\s*@ts-nocheck(?=[\s:]|$)/i }
17
+ ];
18
+ var readingAgainst = (request) => request.patterns.flatMap(({ directive, pattern }) => {
19
+ const marker = pattern.exec(request.text);
20
+ return marker === null ? [] : [{ directive, tail: request.text.slice(marker.index + marker[0].length) }];
21
+ })[0];
22
+ var commentPlacementOf = (request) => ({
23
+ form: request.range.kind === request.syntaxApi.SyntaxKind.MultiLineCommentTrivia ? "block" : "line",
24
+ region: request.fileHeaderPositions.has(request.range.pos) ? "file-header" : "body"
25
+ });
26
+ var readingByPlacement = (request) => {
27
+ const { comment, placement } = request;
28
+ if (placement.form === "block") {
29
+ return readingAgainst({ patterns: BLOCK_SUPPRESSIONS, text: comment.slice(comment.lastIndexOf("\n") + 1) });
30
+ }
31
+ const suppression = readingAgainst({ patterns: LINE_SUPPRESSIONS, text: comment });
32
+ if (suppression !== void 0 || placement.region === "body") return suppression;
33
+ return readingAgainst({ patterns: FILE_SUPPRESSIONS, text: comment });
34
+ };
35
+ var jsxTextSpansUnder = (request) => {
36
+ const own = request.syntaxApi.isJsxText(request.node) ? [{ pos: request.node.pos, end: request.node.end }] : [];
37
+ const children = [];
38
+ request.syntaxApi.forEachChild(request.node, (child) => {
39
+ children.push(child);
40
+ });
41
+ return [...own, ...children.flatMap((child) => jsxTextSpansUnder({ node: child, syntaxApi: request.syntaxApi }))];
42
+ };
43
+ var jsxTextSpansOf = (request) => request.sourceFile.languageVariant === request.syntaxApi.LanguageVariant.JSX ? jsxTextSpansUnder({ node: request.sourceFile, syntaxApi: request.syntaxApi }) : [];
44
+ var rangePlacementOf = (request) => request.spans.some((span) => span.pos <= request.range.pos && request.range.end <= span.end) ? "jsx-text" : "trivia";
45
+ var typeDirectiveReaderFor = (request) => {
46
+ const { sourceFile, syntaxApi } = request;
47
+ const fileHeaderPositions = new Set(
48
+ (syntaxApi.getLeadingCommentRanges(sourceFile.text, 0) ?? []).map((headerRange) => headerRange.pos)
49
+ );
50
+ const jsxTextSpans = jsxTextSpansOf({ sourceFile, syntaxApi });
51
+ return ({ range }) => rangePlacementOf({ range, spans: jsxTextSpans }) === "jsx-text" ? void 0 : readingByPlacement({
52
+ comment: sourceFile.text.slice(range.pos, range.end),
53
+ placement: commentPlacementOf({ range, fileHeaderPositions, syntaxApi })
54
+ });
55
+ };
56
+ var escapesOf = (request) => request.escapes.filter(
57
+ (directiveEscape) => request.clauses.some((clause) => sameClauseAddress({ left: clause, right: directiveEscape.clause }) === "same")
58
+ );
59
+ var directiveEscapesIn = (request) => {
60
+ if (request.escapes.length === 0) return [];
61
+ const readDirective = typeDirectiveReaderFor(request);
62
+ return [...request.comments].sort((left, right) => left.pos - right.pos).flatMap((range) => {
63
+ const reading = readDirective({ range });
64
+ if (reading === void 0) return [];
65
+ const line = request.anchorAt({ position: range.pos }).line;
66
+ const text = request.sourceFile.text.slice(range.pos, range.end).trim();
67
+ return request.escapes.filter((directiveEscape) => directiveEscape.directives.includes(reading.directive)).map((directiveEscape) => ({ kind: "inline-disable", clause: directiveEscape.clause, file: request.file, line, text, reach: "one-clause" }));
68
+ });
69
+ };
70
+
71
+ export {
72
+ TYPE_DIRECTIVES,
73
+ typeDirectiveReaderFor,
74
+ escapesOf,
75
+ directiveEscapesIn
76
+ };
@@ -1,13 +1,14 @@
1
+ import {
2
+ repoPathSchema
3
+ } from "./chunk-MVK5KFJI.js";
1
4
  import {
2
5
  clauseIdSchema,
3
6
  disciplineIdSchema,
4
7
  external_exports,
5
- mechanismIdSchema,
6
- repoPathSchema
7
- } from "./chunk-FOAGAYXM.js";
8
+ mechanismIdSchema
9
+ } from "./chunk-NCDYOPHG.js";
8
10
 
9
- // core/rule-set-reader/rule-set-reader.ts
10
- var SUPPORTED_VERSION = 1;
11
+ // core/values/parsed-json.ts
11
12
  var parsedJson = (request) => {
12
13
  try {
13
14
  const parsed = JSON.parse(request.text);
@@ -19,6 +20,38 @@ var parsedJson = (request) => {
19
20
  };
20
21
  }
21
22
  };
23
+
24
+ // core/values/json-kind.ts
25
+ var JSON_KIND_NAMES = {
26
+ string: "a string",
27
+ number: "a number",
28
+ boolean: "a boolean",
29
+ null: "null",
30
+ array: "an array",
31
+ object: "an object"
32
+ };
33
+ var jsonKindOf = (request) => {
34
+ if (request.value === null) return "null";
35
+ if (Array.isArray(request.value)) return "array";
36
+ const kind = typeof request.value;
37
+ if (kind === "string" || kind === "number" || kind === "boolean") return kind;
38
+ return "object";
39
+ };
40
+ var isJsonObject = (candidate) => jsonKindOf({ value: candidate }) === "object";
41
+ var sameItems = (request) => request.left.length === request.right.length && request.left.every((leftItem, position) => sameJsonValue({ left: leftItem, right: request.right[position] }) === "same") ? "same" : "different";
42
+ var sameObjects = (request) => Object.keys(request.left).length === Object.keys(request.right).length && Object.entries(request.left).every(
43
+ ([key, leftEntry]) => Object.hasOwn(request.right, key) && sameJsonValue({ left: leftEntry, right: request.right[key] }) === "same"
44
+ ) ? "same" : "different";
45
+ var sameJsonValue = (request) => {
46
+ const { left, right } = request;
47
+ if (right === void 0 || jsonKindOf({ value: left }) !== jsonKindOf({ value: right })) return "different";
48
+ if (Array.isArray(left) && Array.isArray(right)) return sameItems({ left, right });
49
+ if (isJsonObject(left) && isJsonObject(right)) return sameObjects({ left, right });
50
+ return left === right ? "same" : "different";
51
+ };
52
+
53
+ // core/rule-set-reader/rule-set-reader.ts
54
+ var SUPPORTED_VERSION = 1;
22
55
  var readVersionOneJson = (request) => {
23
56
  const text = request.fileText.read({ path: request.path });
24
57
  if (text.outcome === "failed") {
@@ -90,11 +123,30 @@ var disciplineFileSchema = external_exports.object({
90
123
  error: "two clauses share an id"
91
124
  })
92
125
  });
126
+ var clauseSettingDeclarationSchema = external_exports.strictObject({
127
+ default: external_exports.json(),
128
+ choices: external_exports.array(external_exports.json()).min(1).optional()
129
+ }).superRefine((declaration, context) => {
130
+ if (declaration.choices === void 0) return;
131
+ const defaultKind = jsonKindOf({ value: declaration.default });
132
+ if (declaration.choices.some((choice) => jsonKindOf({ value: choice }) !== defaultKind)) {
133
+ context.addIssue({ code: "custom", path: ["choices"], message: `every choice must be ${JSON_KIND_NAMES[defaultKind]}, as the default is` });
134
+ }
135
+ if (!declaration.choices.some((choice) => sameJsonValue({ left: choice, right: declaration.default }) === "same")) {
136
+ context.addIssue({ code: "custom", path: ["default"], message: "the default must be one of the choices" });
137
+ }
138
+ });
93
139
  var pieceFileSchema = external_exports.object({
94
140
  version: external_exports.literal(SUPPORTED_VERSION),
95
141
  discipline: disciplineIdSchema,
96
142
  mechanism: mechanismIdSchema,
97
- clauses: external_exports.array(external_exports.object({ clause: clauseIdSchema, settings: external_exports.unknown() })).refine((entries) => textDistinctness(entries.map((entry) => entry.clause)) === "distinct", {
143
+ clauses: external_exports.array(
144
+ external_exports.object({
145
+ clause: clauseIdSchema,
146
+ settings: external_exports.unknown(),
147
+ clauseSettings: external_exports.record(external_exports.string().min(1), clauseSettingDeclarationSchema).default({})
148
+ })
149
+ ).refine((entries) => textDistinctness(entries.map((entry) => entry.clause)) === "distinct", {
98
150
  error: "two entries name the same clause"
99
151
  })
100
152
  });
@@ -180,6 +232,9 @@ var readPieceFile = (request) => {
180
232
  var eslintConfigLookupSchema = external_exports.enum(["nearest-to-file", "repository-root"]);
181
233
 
182
234
  export {
235
+ JSON_KIND_NAMES,
236
+ jsonKindOf,
237
+ sameJsonValue,
183
238
  parsedJson,
184
239
  readVersionOneJson,
185
240
  disciplineFilePath,
@@ -0,0 +1,15 @@
1
+ // core/values/gathered-outcomes.ts
2
+ var gatheredOutcomes = (request) => {
3
+ const failed = request.outcomes.find((outcome) => outcome.outcome === "failed");
4
+ if (failed !== void 0) return failed;
5
+ return {
6
+ outcome: "ok",
7
+ value: request.outcomes.flatMap((outcome) => outcome.outcome === "ok" ? outcome.value : [])
8
+ };
9
+ };
10
+ var listedOutcome = (request) => request.outcome.outcome === "failed" ? request.outcome : { outcome: "ok", value: [request.outcome.value] };
11
+
12
+ export {
13
+ gatheredOutcomes,
14
+ listedOutcome
15
+ };