@hailstails/hone 0.1.0-pre.5 → 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 (130) hide show
  1. package/ADOPTING.md +151 -42
  2. package/MIGRATING.md +55 -4
  3. package/README.md +98 -35
  4. package/THIRD-PARTY-NOTICES.md +1 -1
  5. package/chunks/chunk-5LCLBXP7.js +76 -0
  6. package/chunks/{chunk-IIMK5BCL.js → chunk-ET5EBSJX.js} +15 -13
  7. package/chunks/{chunk-7PVPPH4C.js → chunk-LDQUT742.js} +3 -1
  8. package/chunks/{chunk-VUG3DJHN.js → chunk-LOYT2AGY.js} +8 -9
  9. package/chunks/{chunk-HVABJ7T4.js → chunk-MVK5KFJI.js} +72 -12
  10. package/chunks/{chunk-SWPCKTJV.js → chunk-NCDYOPHG.js} +7340 -2124
  11. package/chunks/{chunk-7OVV6NEU.js → chunk-WPRR2MPJ.js} +1 -1
  12. package/chunks/{chunk-YBWVUDIG.js → chunk-XB4PCY3Q.js} +1 -1
  13. package/core/check/tool-command.js +938 -313
  14. package/docs/adding-a-discipline-or-mechanism.md +27 -14
  15. package/docs/extending.md +4 -3
  16. package/docs/output-contract.md +326 -0
  17. package/mechanisms/audit/CD-19/import-boundaries.js +3 -3
  18. package/mechanisms/audit/CD-2/piece.json +6 -1
  19. package/mechanisms/audit/CD-5/comments-directives.js +10 -26
  20. package/mechanisms/audit/runner/README.md +3 -2
  21. package/mechanisms/audit/runner/runner.js +97 -35
  22. package/mechanisms/eslint/CD-2/README.md +12 -0
  23. package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +16 -0
  24. package/mechanisms/eslint/CD-2/piece.json +25 -0
  25. package/mechanisms/eslint/runner/README.md +12 -5
  26. package/mechanisms/eslint/runner/runner.js +900 -242
  27. package/methods/README.md +2 -0
  28. package/methods/assessment-template.md +35 -0
  29. package/methods/lenses/clean-architecture.md +2 -2
  30. package/methods/lenses/decomposition.md +2 -2
  31. package/methods/lenses/defended-on-intent.md +7 -7
  32. package/methods/lenses/di-discipline.md +38 -26
  33. package/methods/lenses/errors-as-data.md +2 -2
  34. package/methods/lenses/function-first.md +2 -2
  35. package/methods/lenses/naming.md +2 -2
  36. package/methods/lenses/test-discipline.md +15 -13
  37. package/methods/lenses/type-soundness.md +2 -2
  38. package/methods/lenses/zod-boundary.md +2 -2
  39. package/package.json +2 -1
  40. package/rules/CD-1/CHECKS.md +37 -0
  41. package/rules/CD-1/README.md +17 -32
  42. package/rules/CD-10/CHECKS.md +49 -0
  43. package/rules/CD-10/README.md +21 -49
  44. package/rules/CD-11/CHECKS.md +13 -0
  45. package/rules/CD-11/README.md +14 -8
  46. package/rules/CD-12/CHECKS.md +13 -0
  47. package/rules/CD-12/README.md +14 -8
  48. package/rules/CD-13/CHECKS.md +13 -0
  49. package/rules/CD-13/README.md +14 -8
  50. package/rules/CD-14/CHECKS.md +49 -0
  51. package/rules/CD-14/README.md +22 -48
  52. package/rules/CD-15/CHECKS.md +40 -0
  53. package/rules/CD-15/README.md +22 -40
  54. package/rules/CD-16/CHECKS.md +7 -0
  55. package/rules/CD-16/README.md +3 -5
  56. package/rules/CD-17/CHECKS.md +37 -0
  57. package/rules/CD-17/README.md +17 -31
  58. package/rules/CD-18/CHECKS.md +13 -0
  59. package/rules/CD-18/README.md +15 -9
  60. package/rules/CD-19/CHECKS.md +49 -0
  61. package/rules/CD-19/README.md +18 -44
  62. package/rules/CD-2/CHECKS.md +56 -0
  63. package/rules/CD-2/README.md +18 -35
  64. package/rules/CD-2/discipline.json +68 -0
  65. package/rules/CD-20/CHECKS.md +7 -0
  66. package/rules/CD-20/README.md +3 -5
  67. package/rules/CD-21/CHECKS.md +13 -0
  68. package/rules/CD-21/README.md +14 -9
  69. package/rules/CD-22/CHECKS.md +13 -0
  70. package/rules/CD-22/README.md +13 -8
  71. package/rules/CD-23/CHECKS.md +35 -0
  72. package/rules/CD-23/README.md +14 -29
  73. package/rules/CD-24/CHECKS.md +7 -0
  74. package/rules/CD-24/README.md +3 -5
  75. package/rules/CD-25/CHECKS.md +38 -0
  76. package/rules/CD-25/README.md +20 -32
  77. package/rules/CD-26/CHECKS.md +36 -0
  78. package/rules/CD-26/README.md +18 -31
  79. package/rules/CD-27/CHECKS.md +45 -0
  80. package/rules/CD-27/README.md +18 -40
  81. package/rules/CD-28/CHECKS.md +13 -0
  82. package/rules/CD-28/README.md +14 -8
  83. package/rules/CD-29/CHECKS.md +13 -0
  84. package/rules/CD-29/README.md +12 -8
  85. package/rules/CD-3/CHECKS.md +42 -0
  86. package/rules/CD-3/README.md +20 -42
  87. package/rules/CD-30/CHECKS.md +13 -0
  88. package/rules/CD-30/README.md +13 -8
  89. package/rules/CD-31/CHECKS.md +13 -0
  90. package/rules/CD-31/README.md +12 -8
  91. package/rules/CD-32/CHECKS.md +13 -0
  92. package/rules/CD-32/README.md +13 -8
  93. package/rules/CD-33/CHECKS.md +13 -0
  94. package/rules/CD-33/README.md +13 -8
  95. package/rules/CD-34/CHECKS.md +13 -0
  96. package/rules/CD-34/README.md +12 -8
  97. package/rules/CD-39/CHECKS.md +13 -0
  98. package/rules/CD-39/README.md +13 -8
  99. package/rules/CD-4/CHECKS.md +13 -0
  100. package/rules/CD-4/README.md +15 -8
  101. package/rules/CD-40/CHECKS.md +39 -0
  102. package/rules/CD-40/README.md +17 -33
  103. package/rules/CD-41/CHECKS.md +54 -0
  104. package/rules/CD-41/README.md +23 -54
  105. package/rules/CD-42/CHECKS.md +47 -0
  106. package/rules/CD-42/README.md +19 -47
  107. package/rules/CD-43/CHECKS.md +37 -0
  108. package/rules/CD-43/README.md +15 -31
  109. package/rules/CD-44/CHECKS.md +48 -0
  110. package/rules/CD-44/README.md +20 -48
  111. package/rules/CD-45/CHECKS.md +13 -0
  112. package/rules/CD-45/README.md +14 -8
  113. package/rules/CD-46/CHECKS.md +7 -0
  114. package/rules/CD-46/README.md +16 -4
  115. package/rules/CD-47/CHECKS.md +37 -0
  116. package/rules/CD-47/README.md +16 -32
  117. package/rules/CD-5/CHECKS.md +52 -0
  118. package/rules/CD-5/README.md +22 -52
  119. package/rules/CD-6/CHECKS.md +51 -0
  120. package/rules/CD-6/README.md +22 -51
  121. package/rules/CD-7/CHECKS.md +46 -0
  122. package/rules/CD-7/README.md +23 -46
  123. package/rules/CD-7a/CHECKS.md +38 -0
  124. package/rules/CD-7a/README.md +14 -32
  125. package/rules/CD-8/CHECKS.md +42 -0
  126. package/rules/CD-8/README.md +20 -42
  127. package/rules/CD-9/CHECKS.md +13 -0
  128. package/rules/CD-9/README.md +15 -8
  129. package/rules/README.md +5 -3
  130. package/rules/SPIRIT.md +50 -0
@@ -31,6 +31,20 @@ Each clause is either mechanical or judgement:
31
31
 
32
32
  Clause ids are lower-case words joined by hyphens, and are unique within the discipline.
33
33
 
34
+ ### 1a. The rule pages
35
+
36
+ Each discipline has two pages beside its `discipline.json`, so a reader meets the rule's intent before any detail of how it is checked.
37
+
38
+ `rules/<DisciplineId>/README.md` holds the rule and its spirit, and ends on the spirit:
39
+
40
+ - `# <ID>: <title>`, then `## Rule` with the rule text.
41
+ - One line that starts `Review lens:` and links the lens (the lenses find their pages by this line), then links `CHECKS.md` and [the spirit of the rules](../rules/SPIRIT.md).
42
+ - `## Spirit`, in five fixed parts, each a bold lead: **What the friction is for**; **What a finding points at**, a short list of usual causes, each with the direction it points; **Where to go**, the forward goal; **Reactions to distrust**, each common reaction with what it usually hides; **Principles behind it**, established principles named with one line each on how they apply, attributed only where the attribution is certain.
43
+
44
+ The Spirit section does not talk about syntax, detectors or linting. [rules/SPIRIT.md](../rules/SPIRIT.md) gives the approach for the whole set.
45
+
46
+ `rules/<DisciplineId>/CHECKS.md` holds the mechanics. It opens by pointing back to the rule page, then gives the Clauses table, what each check flags and misses, any settings, a violation and its fix, and how to record an exception.
47
+
34
48
  ### 2. The shared cases
35
49
 
36
50
  A mechanical clause's `cases` hold `flag` and `allow` lists. Each case is `{ "name", "fileName", "source", "expectedLines" }`: a flag case lists the lines that must be flagged (at least one), and an allow case lists none. `fileName` is a repository path and may be a declaration file such as `x.d.ts`. There must be at least one of each.
@@ -94,7 +108,7 @@ A repository selects it by naming the rule set and the clause:
94
108
 
95
109
  ### 1. The runner
96
110
 
97
- Create `mechanisms/<MechanismId>/runner/runner.ts`. The id is lower-case words joined by hyphens. The module has one named export, `runner`, built by a factory in its own file so the runner's tests can call the factory with fakes. The ESLint runner's `runner.ts`:
111
+ Create `mechanisms/<MechanismId>/runner/runner.ts`. The id is lower-case words joined by hyphens, and never `not-run` or `not-adopted`, which `disciplines.json` reserves for a clause adopted with its mechanism not run and a clause a repository does not adopt. The module has one named export, `runner`, built by a factory in its own file so the runner's tests can call the factory with test doubles. The ESLint runner's `runner.ts`:
98
112
 
99
113
  ```ts
100
114
  export const runner = toolchainBoundEmbeddedRunner({
@@ -120,7 +134,7 @@ Use core's ports (`core/platform-ports/`) for files, module loading and paths, a
120
134
 
121
135
  A runner declares `exceptionPath`, which tells core how the tool's own exception formats are handled.
122
136
 
123
- - **Standalone** (`"standalone"`): the tool has no exception format of its own, or none the repository can write to. The runner implements `run`, which returns raw hits for the selected clauses with no exception applied, and `conform`, which runs a clause over its shared cases without reading any repository file. Core applies `discipline-exceptions.json` itself. The audit mechanism is standalone. The author's contract is `StandaloneRunner` in `core/mechanism-port/runner-module-schema.ts`.
137
+ - **Standalone** (`"standalone"`): the tool has no exception format of its own, or none the repository can write to. The runner implements `run`, which returns raw hits for the selected clauses with no exception applied, and the `inline-disable` native exceptions it found, and `conform`, which runs a clause over its shared cases without reading any repository file. Core applies `discipline-exceptions.json` itself. The audit mechanism is standalone. The author's contract is `StandaloneRunner` in `core/mechanism-port/runner-module-schema.ts`.
124
138
  - **Embedded** (`"embedded"`): the tool has its own ignore, override, suppression or inline formats, which the team's own run of the tool honours. The runner reports every native channel that touches a selected clause, and writes a projection so the team's run honours the recorded exceptions. ESLint is embedded. The author's contract is `EmbeddedRunner` in `core/mechanism-port/embedded-runner-module-schema.ts`; see "Embedded mechanisms" below.
125
139
 
126
140
  Core knows only these two paths. A mechanism that fits neither would need a change to core.
@@ -153,15 +167,14 @@ These hold for every discipline and mechanism. Tests under `core/check/` check t
153
167
  An embedded runner has the same `run` and `conform` as a standalone one, plus:
154
168
 
155
169
  - `projectedKinds`: the native exception kinds its own projection writes. Only these kinds can be matched by a record.
156
- - `run` also receives the repository's exception records for that mechanism, so it can regenerate the projection and compare it. It returns hits, the native exceptions it found, and the projection's state: `current`, `out-of-date`, `missing` or `not-included`. A projection that is missing or not included means the mechanism did not run: core lists `mechanism-not-run` and the check fails. An out-of-date one is a projection problem and also fails.
157
- - `run` also receives `projectedClauses`: every selected clause of the mechanism, while `clauses` holds only the clauses to run. The two differ only when `waivedClauses` is `not-run` and a waived clause shares its mechanism with a clause still to run. Judge the projection, its effect and every native exception against `projectedClauses`; run, and report hits for, `clauses` only. Core refuses a hit on a clause outside `clauses`, and a native exception on a clause outside `projectedClauses`, as `runner-invalid-output`. The ESLint runner registers every projected plugin and watches every projected rule for inline comments, but switches on only the rules in `clauses`, so ESLint never creates a waived rule.
158
- - `project`: writes the projection file and returns its path with `written` or `unchanged`. `hone project` calls it.
170
+ - `run` also receives the repository's exception records for that mechanism, so it can regenerate the projection and compare it. It returns hits, the native exceptions it found, and the projection's state: `current`, `out-of-date`, `missing` or `not-included`. A projection that is missing or not included means the mechanism did not run: core lists `mechanism-not-run` and the check fails. An out-of-date one is a projection problem and also fails. It may also return `slices`, each a projection file other than the root one with its state, `missing`, `out-of-date`, `not-applied`, `unconfigured` or `nested-configuration`; a runner reports `nested-configuration` only beside a `not-included` projection, for a folder holding its own `disciplines.json` whose own config left the projection out of effect, and core names that folder on the `mechanism-not-run` entry; core lists each other state as a projection problem naming the file. A runner that returns none has none.
171
+ - `project`: writes the projection files and returns each path with `written`, `unchanged`, `removed` or `left-in-place`. `hone project` calls it.
159
172
 
160
- Core passes every record for the mechanism to both calls, forfeited or not, and never passes the touched set. A forfeited file carve-out therefore stays in the projection and still matches its native exception; core's check reports it as `forfeited` and fails the run. Keep it that way: a runner must not compute forfeiture or read the touched set itself, so that whether a forfeited carve-out stays pushed down remains core's decision. No test checks this; it is a rule for review.
173
+ Core passes every record for the mechanism to both calls, forfeited or not, and never passes the touched set. A forfeited file carve-out therefore stays in the projection; core's check reports it as `forfeited`, no longer counts it as holding any native exception, so each one it held is listed under `unrecorded`, and fails the run. Keep it that way: a runner must not compute forfeiture or read the touched set itself, so that whether a forfeited carve-out stays pushed down remains core's decision. No test checks this; it is a rule for review.
161
174
 
162
175
  ### Native channels
163
176
 
164
- Writing an embedded mechanism means listing every native channel the tool has and mapping each one to an exception kind core understands (`nativeExceptionSchema` in `core/mechanism-port/embedded-run-report-schema.ts`). A native exception is accepted only when its kind is in the runner's `projectedKinds` and a record in `discipline-exceptions.json` covers it; every other native exception is reported as unrecorded and fails the run, whether or not it currently hides a finding.
177
+ Writing an embedded mechanism means listing every native channel the tool has and mapping each one to an exception kind core understands (`nativeExceptionSchema` in `core/mechanism-port/embedded-run-report-schema.ts`). A native exception is accepted only when its kind is in the runner's `projectedKinds` and a record in `discipline-exceptions.json` covers it; every other native exception is reported as unrecorded and fails the run, whether or not it currently hides a finding. A standalone run can always have its `inline-disable` exceptions covered. An `inline-disable` is debt on its clause in its file, so only an `authorised-location` or `file-carve-out` on that clause and file covers it, never a `clause-wide-carve-out`; editing a carved file forfeits the carve-out as for any other file carve-out. A `command-line-option` is never covered: it changes the whole run of its script, so no record can hold it.
165
178
 
166
179
  The ESLint runner's map. "Checked file" means a tracked `.ts`, `.tsx`, `.mts` or `.cts` file; "selected rule" means the rule id of a selected clause's ESLint piece.
167
180
 
@@ -170,26 +183,26 @@ The ESLint runner's map. "Checked file" means a tracked `.ts`, `.tsx`, `.mts` or
170
183
  | a checked file the team's configuration ignores (for example a global `ignores` block); reported for every selected clause | `ignore` | no |
171
184
  | a checked file on which the team's resolved configuration leaves a selected rule below `"error"` (`"warn"`, `"off"` or not set) | `config-override` | yes |
172
185
  | an entry for a selected rule in any tracked file named `eslint-suppressions.json`, or in a file named by `--suppressions-location` in a tracked `package.json` script | `suppression-entry` | no |
173
- | an `eslint-disable`, `eslint-disable-line` or `eslint-disable-next-line` comment naming a selected rule, or naming no rule | `inline-disable` | no |
186
+ | an `eslint-disable`, `eslint-disable-line` or `eslint-disable-next-line` comment naming a selected rule, or naming no rule, which escapes every selected clause and is reported once for each | `inline-disable` | yes, by a file record on its clause and file |
174
187
  | an `/* eslint ... */` comment configuring a selected rule, or one that cannot be parsed | `inline-rule-config` | no |
175
- | an option in an ESLint invocation in a tracked `package.json` script that weakens or replaces a selected rule's configuration: `--rule` or `--suppress-rule` naming it, or `--suppress-all`, `--ignore-pattern`, `-c`/`--config`, `--no-config-lookup`, `--parser`, `--parser-options` or `--plugin` | `command-line-option` | no |
188
+ | an option in an ESLint invocation in a tracked `package.json` script that weakens or replaces a selected rule's configuration: `--rule` or `--suppress-rule` naming it, or `--suppress-all`, `--no-config-lookup`, `--parser`, `--parser-options` or `--plugin`; `-c`/`--config` or `--ignore-pattern`, unless the script's own folder settles that it changes nothing | `command-line-option` | no |
176
189
 
177
- The ESLint runner declares `projectedKinds: ["config-override"]`. A record covers a `config-override` on its own file (authorised location or file carve-out) or on every file (clause-wide carve-out).
190
+ The ESLint runner declares `projectedKinds: ["config-override", "inline-disable"]`, because a file record's projection block turns the rule off for that file whatever its comments say. A record covers a `config-override` on its own file (authorised location or file carve-out) or on every file (clause-wide carve-out), and an `inline-disable` on its own file only.
178
191
 
179
192
  How the runner finds each channel (`mechanisms/eslint/runner/`):
180
193
 
181
- - `ignore` and `config-override` come from a query instance of ESLint on the team's own configuration (`eslint-instance.ts`): `isPathIgnored` and `calculateConfigForFile` per checked file. A configuration that fails to load is `team-config-unloadable`; one that registers a different module under a selected piece's namespace is `plugin-conflict`.
194
+ - `ignore` and `config-override` come from a query instance of ESLint on the team's own configuration (`eslint-instance.ts`): `isPathIgnored` and `calculateConfigForFile` per checked file. A configuration that fails to load is `team-config-unloadable`, whose detail names the config through ESLint's `findConfigFile` and the checked file it applies to. Before failing, `governing-config.ts` asks the config governing the broken config's folder, and each one above it up to the repository root, whether it ignores that folder and then the file. Each question is `governingConfigIgnores`: ESLint built on that one config from its folder, with a files-only override block matching the asked path, so `isPathIgnored` answers true only for a real ignore and never for a path no `files` block matches; a folder is asked through a probe file directly inside it. A yes for both makes the file `ignore`, because the team's ESLint never enters that folder. A configuration that registers a different module under a selected piece's namespace is `plugin-conflict`.
182
195
  - `inline-disable` and `inline-rule-config` come from a reserved rule, `<reservedNamespace>/inline-config` (currently `hone-core/inline-config`), that runs in core's governance lint and reads each file's inline configuration comments with `@eslint/plugin-kit` (`inline-config-parser.ts`). `eslint-enable` and other directives such as `/* global */` are not reported.
183
196
  - `suppression-entry` comes from `suppressions-scanner.ts`. Keys in a tracked `eslint-suppressions.json` are read relative to its folder; keys in a file named by `--suppressions-location` are read relative to the `package.json` that names it.
184
- - `command-line-option` comes from `package-script-scanner.ts`, which parses every tracked `package.json` and splits each script into commands. A command is an ESLint invocation when a token is `eslint`, starts `eslint@`, or ends `/eslint` or `/eslint.js`. A script with an unterminated quote is `tool-failed`.
197
+ - `command-line-option` comes from `package-script-scanner.ts`, which parses every tracked `package.json` and splits each script into commands. A command is an ESLint invocation when a token is `eslint`, starts `eslint@`, or ends `/eslint` or `/eslint.js`. A script with an unterminated quote is `tool-failed`. `script-option-effect.ts` clears only two cases, judged on the checked files under the `package.json` folder: `-c` or `--config` naming, from that folder, the config the query instance finds for each of those files, and `--ignore-pattern` that ESLint, built from that folder on that pattern alone with a files block matching each asked file, ignores none of them with. Anything it cannot settle weakens the run: no checked file under the folder, or any token after `eslint` that the shell expands (an unquoted `*`, `?`, `[`, `]`, `{`, `}`, `~`, `$` or backtick, or a `$` or backtick in double quotes) or that holds `..`, `$` or a backtick or starts with `/`, `~` or a drive letter. An invocation that is not plain is reported with its reason instead, as the cause `wrapped` naming the first token before `eslint` that is neither a package runner (`npx`, `pnpm`, `yarn`, `npm`, `bunx`, `exec`, `--`), a literal `NAME=value` assignment, nor `cross-env` followed only by `NAME=value` assignments; or, failing that, as the cause `after-another-command` when another command comes before it in the script, carrying its whole command as the suggested script. Every other option weakens the run.
185
198
 
186
- Hits come from a separate governance instance that uses only the runner's configuration: the rules of the clauses to run and the inline-config rule at `"error"` on `**/*.{ts,tsx,mts,cts}`, with every selected plugin registered and every selected rule watched by the inline-config rule, parsed with `@typescript-eslint/parser`, with the team's configuration file, ignores, suppressions and inline configuration all off. No native channel can change core's findings.
199
+ Hits come from a separate governance instance that uses only the runner's configuration: the selected rules and the inline-config rule at `"error"` on `**/*.{ts,tsx,mts,cts}`, parsed with `@typescript-eslint/parser`, with the team's configuration file, ignores, suppressions and inline configuration all off. No native channel can change core's findings.
187
200
 
188
201
  Options passed outside a `package.json` script (a CI step, an editor setting, a wrapper script) are not found. They cannot change core's verdict, but core cannot check whether such a run honours the records.
189
202
 
190
203
  ### The ESLint projection
191
204
 
192
- `projection.ts` writes `disciplines.eslint.mjs` at the repository root. It imports each piece's plugin module by a path relative to the repository root, then exports, in order: one block per plugin namespace enabling its selected rules at `"error"` on `**/*.{ts,tsx,mts,cts}`; one block per distinct set of clauses that authorised locations and file carve-outs except files from, listing those files (each path escaped as a glob) and turning the set's rules `"off"` for them, so the block count follows the clause combinations in use rather than the number of records; and one block per clause-wide carve-out turning them `"off"` everywhere. Block names start with `reservedNamespace` (currently `hone-core/`). The output is sorted, so the same selection and records always produce the same text.
205
+ `projection.ts` writes `disciplines.eslint.mjs` at the repository root, and one slice of it beside each package config the team's ESLint loads (see the runner's README). It imports each piece's plugin module by a path relative to the slice's folder, then exports, in order: one block per plugin namespace enabling its selected rules at `"error"` on `**/*.{ts,tsx,mts,cts}`; one block per distinct set of clauses that authorised locations and file carve-outs except files from, listing those files (each path escaped as a glob) and turning the set's rules `"off"` for them, so the block count follows the clause combinations in use rather than the number of records; and one block per clause-wide carve-out turning them `"off"` everywhere. Block names start with `reservedNamespace` (currently `hone-core/`). The output is sorted, so the same selection and records always produce the same text.
193
206
 
194
207
  The team spreads its default export last in its flat config; the projection is the only supported way to adopt the rules. On each check the runner first compares the file with what it would write now (`missing`, or `out-of-date` if it differs). It then checks the projection's effect through the query instance, in two directions. Every selected rule must be set, at any severity, on at least one checked file that is not ignored, when there is one. Every record whose file is checked must leave its rules at severity `0` on that file, or on every checked file for a clause-wide carve-out. If either fails, the result is `not-included` with no hits. The second direction catches a team that enables a rule another way, for example through a piece's own fragment such as `mechanisms/eslint/CD-14/cd14.eslint.ts`, without importing the projection.
195
208
 
package/docs/extending.md CHANGED
@@ -97,7 +97,7 @@ verdict: fail
97
97
  - A clause with `"kind": "judgement"`, a `summary` and `"enforcedBy": "review"` is applied in review and cannot be selected.
98
98
  - `"exceptions": "refused"` on a clause stops any exception record from exempting it.
99
99
 
100
- `rules/ACME-1/README.md` is the rule's page: why the rule exists, one example that honours it and one that breaks it. Write it for the people and agents who apply the rule, not about how the check matches. It is optional today and will be required.
100
+ `rules/ACME-1/README.md` is the rule's page: why the rule exists, one example that honours it and one that breaks it. Write it for the people and agents who apply the rule, not about how the check matches. It is optional today and will be required. Hone's own rule pages follow a fixed shape, a Rule and its Spirit on `README.md` with the mechanics in a sibling `CHECKS.md`; [adding a discipline](adding-a-discipline-or-mechanism.md#1a-the-rule-pages) describes it.
101
101
 
102
102
  ## An ESLint piece
103
103
 
@@ -159,13 +159,14 @@ export default [
159
159
  ];
160
160
  ```
161
161
 
162
- Every `eslint.config.*` that applies to checked files spreads the projection last. The example's `eslint.config.mjs`:
162
+ Every `eslint.config.*` that applies to checked files spreads the projection last. The projection sets rules only, so the config also sets the typescript-eslint parser, as [ADOPTING.md](../ADOPTING.md#4a-set-up-eslint-for-eslint-clauses) step 4a explains. The example's `eslint.config.mjs`:
163
163
 
164
164
  ```js
165
+ import typescriptParser from "@typescript-eslint/parser";
165
166
  import projection from "./disciplines.eslint.mjs";
166
167
 
167
168
  export default [
168
- { files: ["**/*.{ts,tsx,mts,cts}"] },
169
+ { files: ["**/*.{ts,tsx,mts,cts}"], languageOptions: { parser: typescriptParser } },
169
170
  ...projection,
170
171
  ];
171
172
  ```
@@ -0,0 +1,326 @@
1
+ # Output contract
2
+
3
+ This page lists everything the `hone` command prints, exactly as it prints it: the help, the version, the report, the load failures and the `hone project` lines. It says which parts a hook, CI job or agent can parse and rely on. [Compatibility](../README.md#compatibility) says which releases may change them.
4
+
5
+ A test renders every kind of line the command can print, fills each template below with that line's own sample values, and requires the result to equal the printed line exactly: a line Hone can print that is not listed here fails the build, and so does a line listed here that Hone cannot print. The synopsis and help blocks below are compared with what the command prints, character for character.
6
+
7
+ ## Streams and exit codes
8
+
9
+ Hone prints everything to standard output: the report, the help, the version, `hone project` lines and every load failure, including an error Hone did not expect. Hone writes nothing to standard error itself; Node can write its own warnings there, so a hook should not read output on standard error as a failure.
10
+
11
+ The exit code is the signal a hook should act on:
12
+
13
+ - `0`: `hone check` printed `verdict: pass`, `hone project` wrote or confirmed every projection, or help or the version was printed;
14
+ - `1`: `hone check` printed `verdict: fail` as its last line. Exit `1` always comes with that line, and with nothing else;
15
+ - `2`: Hone could not decide. It printed exactly one line, starting with `load failure: `, and no verdict. That covers a command typed wrongly, an input that could not be loaded, a mechanism that failed, and an error Hone did not expect, which prints as `unexpected-error`.
16
+
17
+ A 1.0 hook can rely on this: run `hone check`, block on any non-zero exit, and show standard output as it came.
18
+
19
+ ## What a tool can parse
20
+
21
+ A tool can rely on these, and a change to any of them is a major release:
22
+
23
+ - the command names, option names, option values, exit codes and streams above;
24
+ - the verdict line, which is always the last line of a `hone check` report and is one of the four lines under [The report](#the-report);
25
+ - the section names, their order and roles, the heading and count lines, and the output modes;
26
+ - the first word of a load failure after `load failure: `, its kind;
27
+ - in each line below, the fixed words and values up to the first value that may hold a space, and the single spaces between them.
28
+
29
+ The values in the [table of values](#values) marked "may hold a space" can contain spaces, and Hone does not quote or escape them. Everything from the first such value to the end of the line is one piece of text: a tool cannot split it into fields, and should not try. For a finding, a tool can read the clause and the mechanism; the file, position and snippet that follow are for a person. Hone has no machine-readable report yet, so a tool that needs each finding's file and position has nothing stable to read them from.
30
+
31
+ These are not stable, so a minor release may change them:
32
+
33
+ - the help text, though the synopsis and the exit codes it lists are stable;
34
+ - the text of a `<detail>`, which comes from Node, git, ESLint or a schema check;
35
+ - the wording after `load failure: arguments-invalid`, written for the person who typed the command;
36
+ - the text after a load failure's values, which says what to do next: the repair text of `selection-absent`, `judgement-clause-listed` and `config-root-untracked`, and everything after the kind in `toolchain-unavailable` and `toolchain-shadowed`;
37
+ - the `readFirst` lines and their leading note, written for a person;
38
+ - the words of an `unmeasured` or `projectionProblems` line after the `:` that ends its leading fields (its kind and reason, or its mechanism, state and slice), which say why and what to do next.
39
+
40
+ A minor release may add a section, a kind of line in a section, a load failure kind, an option or a command. A tool reading the report should pass over a section heading or a line kind it does not know.
41
+
42
+ ## Values
43
+
44
+ In the tables below, a word in angle brackets, such as `<clause>`, stands for a value; everything else is printed as shown. Every line ends with a line feed. A value that holds a line break prints it as `\n` or `\r`, so each entry and each load failure stays on one line.
45
+
46
+ | Value | Printed as | Space |
47
+ | --- | --- | --- |
48
+ | `<clause>` | in the report, a clause address: `CD-15#loops` for Hone's own rule set, `<rule set>/<ID>#<clause>` for a team's; in a load failure, the address as written in `disciplines.json` | never in the report; may hold a space in a load failure |
49
+ | `<mechanism>` | a mechanism id, such as `audit` or `eslint` | never |
50
+ | `<record kind>`, `<section>`, `<package>` | a word from the lines below, a section name, or an npm package name | never |
51
+ | `<line>`, `<column>` | a 1-based line and a 0-based column | never |
52
+ | `<count>`, `<index>`, `<earlier index>` | a whole number; an index counts from 0 | never |
53
+ | `<version>` | the installed package's version | never |
54
+ | `<file>`, `<path>`, `<slice>`, `<suppressions file>`, `<package file>`, `<config root>`, `<piece folder>`, `<location>`, `<install folder>`, `<rule page>`, `<adoption guide>` | a path, as described below | may hold a space |
55
+ | `<folders>` | paths separated by `, ` | may hold a space |
56
+ | `<folder>` | the folder that holds a `<slice>` | may hold a space |
57
+ | `<project command>` | the command that runs `hone project` for this repository: `node`, the installed command's absolute path, `project --repo` and the repository's absolute path, each path with forward slashes and in double quotes when it holds a character other than a letter, digit or one of `_ . / @ : + -` | may hold a space |
58
+ | `<revision>`, `<git message>` | the `--base-revision` value as given and what git said, each as a JSON string in double quotes | may hold a space |
59
+ | `<dir>` | the `--repo` value as typed | may hold a space |
60
+ | `<url>` | the module URL Hone could not resolve, as given | may hold a space |
61
+ | `<snippet>` | the source text at a finding: at most 200 characters, or the first 200 followed by `…` when it is longer | may hold a space |
62
+ | `<comment>`, `<script>`, `<option>`, `<source>` | the native exception's comment, the `package.json` script name and the option in it, or where an imported record came from | may hold a space |
63
+ | `<detail>`, `<given>`, `<values>`, `<rule set>`, `<other rule set>`, `<clause with its rule set>`, `<version found>`, `<other package>`, `<range>` | text from the input, a tool or the command as typed | may hold a space |
64
+
65
+ Paths are printed with forward slashes. A path inside the `--repo` folder is printed relative to it, in the report and in load failures alike. A path outside it is printed absolute, such as `C:/Users/me/shared/rule.json` on Windows. A load failure from before `--repo` is resolved names the folder as typed (`<dir>`). A load failure reading the installed package's own `package.json`, which only `hone --version` reads, prints its absolute path. A path inside a `<detail>` is printed however the tool that wrote the detail printed it.
66
+
67
+ ## Commands
68
+
69
+ ```text
70
+ hone check --repo <dir> [--base-revision <revision>] [--report-output <full|failures-only|counts|verdict-only>] [--forfeiture <this-run|elsewhere>]
71
+ hone project --repo <dir>
72
+ hone --help
73
+ hone --version
74
+ ```
75
+
76
+ Each option is followed by its value as the next argument; a value that starts with `-` is read as a missing value. `--help` or `-h` after a command prints that command's help instead of running it, and `hone --help <command>` prints the same. `hone --help` and `hone --version` take nothing else after them.
77
+
78
+ `hone --help` prints:
79
+
80
+ ```text
81
+ usage: hone <command> [options]
82
+
83
+ Checks a repository against the disciplines it selects, applies its recorded exceptions and prints one verdict.
84
+
85
+ commands:
86
+ check check the repository against the disciplines it selects and print the report, ending in its verdict
87
+ project write the native configuration each selected embedded mechanism needs, printing each file as written or unchanged
88
+
89
+ options:
90
+ --help, -h print this help; after a command, print that command's help
91
+ --version print the installed version of @hailstails/hone
92
+
93
+ run hone <command> --help for a command's options and exit codes
94
+ ```
95
+
96
+ `hone check --help` prints:
97
+
98
+ ```text
99
+ usage: hone check --repo <dir> [--base-revision <revision>] [--report-output <full|failures-only|counts|verdict-only>] [--forfeiture <this-run|elsewhere>]
100
+
101
+ check the repository against the disciplines it selects and print the report, ending in its verdict
102
+
103
+ options:
104
+ --repo <dir>
105
+ the folder that holds disciplines.json, usually the repository root
106
+ --base-revision <revision>
107
+ the revision the change is measured from; without it no file carve-out can be forfeited
108
+ --report-output <full|failures-only|counts|verdict-only>
109
+ how much of the report to print, over reportOutput in disciplines.json; full when neither is set
110
+ --forfeiture <this-run|elsewhere>
111
+ assess file carve-out decay in this run or leave it to another, over assessment.forfeiture in disciplines.json; this-run when neither is set
112
+ --help, -h
113
+ print this help
114
+
115
+ exit codes:
116
+ 0 the verdict is pass
117
+ 1 the verdict is fail
118
+ 2 a load failure: an input could not be loaded, a mechanism failed, or Hone failed unexpectedly
119
+ ```
120
+
121
+ `hone project --help` prints:
122
+
123
+ ```text
124
+ usage: hone project --repo <dir>
125
+
126
+ write the native configuration each selected embedded mechanism needs, printing each file as written or unchanged
127
+
128
+ options:
129
+ --repo <dir>
130
+ the folder that holds disciplines.json, usually the repository root
131
+ --help, -h
132
+ print this help
133
+
134
+ exit codes:
135
+ 0 every projection was written or already current
136
+ 2 any failure
137
+ ```
138
+
139
+ `hone --version` prints the version of the installed package, read from its `package.json`, and exits `0`:
140
+
141
+ | Output | Line |
142
+ | --- | --- |
143
+ | `version` | `<version>` |
144
+
145
+ ## The report
146
+
147
+ `hone check` prints the report's non-empty sections in this order, then the verdict line. A failing section makes the verdict `fail`; an informational or guidance section never does.
148
+
149
+ | Section | Role | What it lists |
150
+ | --- | --- | --- |
151
+ | `excluded` | informational | paths that `exclude` in `disciplines.json` leaves out |
152
+ | `notAdopted` | informational | clauses marked `not-adopted` |
153
+ | `notRun` | informational | clauses marked `not-run` |
154
+ | `findings` | failing | each place a clause is broken |
155
+ | `exempted` | informational | findings an exception covers, with the exceptions that cover them |
156
+ | `uncovered` | failing | clauses of a selected discipline that are neither selected nor marked |
157
+ | `stale` | failing | exceptions that cover no finding |
158
+ | `forfeited` | failing | file carve-outs on files this change touched |
159
+ | `unrecorded` | failing | native exceptions with no record in `discipline-exceptions.json` |
160
+ | `doublyHeld` | failing | files both authorised and carved out for one clause |
161
+ | `invalidRecords` | failing | entries in `discipline-exceptions.json` that cannot be applied |
162
+ | `unmeasured` | failing | what this run could not measure |
163
+ | `projectionProblems` | failing | ESLint projections that are out of date |
164
+ | `assessment` | informational | concerns this run left to another run |
165
+ | `readFirst` | guidance | where to read before changing code, for each clause with findings |
166
+
167
+ `--report-output`, or `reportOutput` in `disciplines.json`, sets how much is printed. The verdict and the exit code are the same in every output.
168
+
169
+ | Output | Prints |
170
+ | --- | --- |
171
+ | `full` | each non-empty section's heading and entries, then the verdict line |
172
+ | `failures-only` | the same without the informational sections |
173
+ | `counts` | each non-empty section's heading only, with its role after an informational or guidance section, then the verdict line |
174
+ | `verdict-only` | the verdict line |
175
+
176
+ A section heading counts its entries. In `counts`, an informational or guidance section's heading names its role. The `readFirst` count includes its leading note line when there is one.
177
+
178
+ | Line | Template |
179
+ | --- | --- |
180
+ | `heading` | `<section> (<count>)` |
181
+ | `heading` | `<section> (<count>) informational` |
182
+ | `heading` | `<section> (<count>) guidance` |
183
+ | `verdict` | `verdict: pass` |
184
+ | `verdict` | `verdict: fail` |
185
+ | `verdict` | `verdict: pass (partial assessment)` |
186
+ | `verdict` | `verdict: fail (partial assessment)` |
187
+
188
+ The verdict line reads `(partial assessment)` whenever the report has an `assessment` section.
189
+
190
+ ## Report lines
191
+
192
+ Each section's entries take one of these shapes. An exempted finding repeats ` exempted by <record kind>` once for each exception that covers it. In `projectionProblems`, a `<slice>` is the `disciplines.eslint.mjs` projection file of one config root, the repository root or a folder in `eslintConfigRoots`; `unconfigured` means that root has no `eslint.config.*`.
193
+
194
+ | Section | Line |
195
+ | --- | --- |
196
+ | `excluded` | `<path>` |
197
+ | `notAdopted` | `<clause>` |
198
+ | `notRun` | `<clause> adopted, mechanism not run: enforced by review` |
199
+ | `findings` | `<clause> <mechanism> <file>:<line>:<column> <snippet>` |
200
+ | `exempted` | `<clause> <mechanism> <file>:<line>:<column> <snippet> exempted by <record kind>` |
201
+ | `exempted` | `<clause> <mechanism> <file>:<line>:<column> <snippet> exempted by <record kind> imported from <source>` |
202
+ | `uncovered` | `<clause>` |
203
+ | `stale` | `<clause> <mechanism> authorised-location <file>` |
204
+ | `stale` | `<clause> <mechanism> file-carve-out <file>` |
205
+ | `stale` | `<clause> <mechanism> clause-wide-carve-out *` |
206
+ | `forfeited` | `<clause> <mechanism> file-carve-out <file>` |
207
+ | `unrecorded` | `<clause> <mechanism> ignore <file>` |
208
+ | `unrecorded` | `<clause> <mechanism> config-override <file>` |
209
+ | `unrecorded` | `<clause> <mechanism> suppression-entry <file> <suppressions file>` |
210
+ | `unrecorded` | `<clause> <mechanism> inline-disable <file>:<line> <comment>` |
211
+ | `unrecorded` | `<clause> <mechanism> inline-disable <file>:<line> <comment> names no rule and escapes every selected clause: naming the rule is the cheap fix` |
212
+ | `unrecorded` | `<clause> <mechanism> inline-rule-config <file>:<line> <comment>` |
213
+ | `unrecorded` | `<clause> <mechanism> command-line-option <package file> <script> <option> weakens the script's whole run, so no record can cover it: remove it from the script` |
214
+ | `unrecorded` | `<clause> <mechanism> command-line-option <package file> <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>` |
215
+ | `unrecorded` | `<clause> <mechanism> command-line-option <package file> <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>` |
216
+ | `doublyHeld` | `<clause> <mechanism> doubly-held <file>` |
217
+ | `invalidRecords` | `exceptions[<index>] clause-unparseable <detail>` |
218
+ | `invalidRecords` | `exceptions[<index>] clause-not-selected <clause>` |
219
+ | `invalidRecords` | `exceptions[<index>] clause-not-adopted <clause>` |
220
+ | `invalidRecords` | `exceptions[<index>] clause-not-run <clause>` |
221
+ | `invalidRecords` | `exceptions[<index>] file-not-repo-path <file>` |
222
+ | `invalidRecords` | `exceptions[<index>] why-chain-refused <detail>` |
223
+ | `invalidRecords` | `exceptions[<index>] evidence-refused <detail>` |
224
+ | `invalidRecords` | `exceptions[<index>] import-unverified <detail>` |
225
+ | `invalidRecords` | `exceptions[<index>] non-exemptible-clause <clause>` |
226
+ | `invalidRecords` | `exceptions[<index>] duplicate of <earlier index>` |
227
+ | `unmeasured` | `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` |
228
+ | `unmeasured` | `forfeiture-unmeasured base-git-failed <revision>: git could not list the files changed since that revision and said <git message>; 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` |
229
+ | `unmeasured` | `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` |
230
+ | `unmeasured` | `import-unmeasured base-git-failed <revision>: git could not read the exception records at that revision and said <git message>; Hone needs the exception records as they were at that revision` |
231
+ | `unmeasured` | `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` |
232
+ | `unmeasured` | `legacy-chain-unmeasured base-git-failed <revision>: git could not read the exception records at that revision and said <git message>; Hone needs the exception records as they were at that revision` |
233
+ | `unmeasured` | `mechanism-not-run <mechanism> missing: disciplines.<mechanism>.mjs is not written; run <project command> and commit every disciplines.<mechanism>.mjs it writes` |
234
+ | `unmeasured` | `mechanism-not-run <mechanism> not-included: the <mechanism> configuration leaves the projection out of effect for a file under check; spread the default export of disciplines.<mechanism>.mjs, or of a package's own disciplines.<mechanism>.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` |
235
+ | `unmeasured` | `mechanism-not-run <mechanism> not-included: the <mechanism> configuration leaves the projection out of effect for a file under check; spread the default export of disciplines.<mechanism>.mjs, or of a package's own disciplines.<mechanism>.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 <mechanism> lines under projectionProblems name the package slices involved` |
236
+ | `unmeasured` | `mechanism-not-run <mechanism> not-included: the <mechanism> configuration leaves the projection out of effect for a file under check; spread the default export of disciplines.<mechanism>.mjs, or of a package's own disciplines.<mechanism>.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; <folders> 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 <project command>, which writes its slice` |
237
+ | `unmeasured` | `mechanism-not-run <mechanism> not-included: the <mechanism> configuration leaves the projection out of effect for a file under check; spread the default export of disciplines.<mechanism>.mjs, or of a package's own disciplines.<mechanism>.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 <mechanism> lines under projectionProblems name the package slices involved; <folders> 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 <project command>, which writes its slice` |
238
+ | `projectionProblems` | `<mechanism> out-of-date: disciplines.<mechanism>.mjs differs from what hone project writes now; run <project command> and commit every disciplines.<mechanism>.mjs it writes` |
239
+ | `projectionProblems` | `<mechanism> out-of-date <slice>: that slice differs from what hone project writes now; run <project command> and commit every disciplines.<mechanism>.mjs it writes` |
240
+ | `projectionProblems` | `<mechanism> missing <slice>: that slice is not written; run <project command> and commit every disciplines.<mechanism>.mjs it writes` |
241
+ | `projectionProblems` | `<mechanism> not-applied <slice>: the <mechanism> configuration for <folder> leaves records of that slice out of effect; spread the default export of <slice> 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` |
242
+ | `projectionProblems` | `<mechanism> unconfigured <slice>: <folder> has no <mechanism> configuration file on disk, so nothing loads that slice; run the tool that generates it (for sku, sku configure) before the check` |
243
+ | `assessment` | `forfeiture elsewhere: 1 file carve-out not checked for decay in this run` |
244
+ | `assessment` | `forfeiture elsewhere: <count> file carve-outs not checked for decay in this run` |
245
+ | `readFirst` | `Start from each rule's Spirit below. disciplines.assessment.md, where this repository records its own causes, forward goal and steps for a clause, is not written yet; <adoption guide>#5a-write-the-assessment says how to write it.` |
246
+ | `readFirst` | `disciplines.assessment.md, where this repository records its own causes, forward goal and steps for a clause, is not written yet; <adoption guide>#5a-write-the-assessment says how to write it.` |
247
+ | `readFirst` | `Start from each rule's Spirit below. disciplines.assessment.md could not be read.` |
248
+ | `readFirst` | `disciplines.assessment.md could not be read.` |
249
+ | `readFirst` | `<clause>: read the "## <clause>" section of disciplines.assessment.md, then <rule page>#spirit` |
250
+ | `readFirst` | `<clause>: read <rule page>#spirit; disciplines.assessment.md does not assess this clause` |
251
+ | `readFirst` | `<clause>: read <rule page>#spirit` |
252
+ | `readFirst` | `<clause>: read the "## <clause>" section of disciplines.assessment.md; its rule set has no rule page at <rule page>` |
253
+ | `readFirst` | `<clause>: its rule set has no rule page at <rule page>; disciplines.assessment.md does not assess this clause` |
254
+ | `readFirst` | `<clause>: its rule set has no rule page at <rule page>` |
255
+
256
+ `readFirst` has one clause line per clause with findings, in the order the findings first name them. When `disciplines.assessment.md` is not written yet, or cannot be read, one note line comes first; it starts with `Start from each rule's Spirit below.` only when at least one clause line names a rule page. A clause line's first word is a clause address, which holds a `#`, followed by `:`; a note line's first word holds no `#`, which is how a tool tells them apart. The `<adoption guide>` is `ADOPTING.md` in the installed package, such as `node_modules/@hailstails/hone/ADOPTING.md`. A clause line names the clause's section in `disciplines.assessment.md` when the file has one, says `does not assess this clause` when the file is there without that section, and says neither when the file is not read. [The README](../README.md#commands) says how a section is matched.
257
+
258
+ ## Load failures
259
+
260
+ A run that cannot decide prints one line and exits `2`. It prints the same line in every output. The line starts with `load failure: ` and its kind; the values follow in the order shown, and any text after the values is not stable.
261
+
262
+ | Kind | Line |
263
+ | --- | --- |
264
+ | `arguments-invalid` | `load failure: arguments-invalid <detail>` |
265
+ | `selection-absent` | `load failure: selection-absent <dir> holds no disciplines.json; give the folder that holds it, usually the repository root` |
266
+ | `install-root-unresolvable` | `load failure: install-root-unresolvable <url> <detail>` |
267
+ | `file-unreadable` | `load failure: file-unreadable <path> <detail>` |
268
+ | `file-malformed` | `load failure: file-malformed <path> <detail>` |
269
+ | `unsupported-version` | `load failure: unsupported-version <path> <version found>` |
270
+ | `reserved-rule-set-name` | `load failure: reserved-rule-set-name <rule set>` |
271
+ | `rule-set-name-collision` | `load failure: rule-set-name-collision <rule set> <other rule set>` |
272
+ | `duplicate-clause` | `load failure: duplicate-clause <clause> <clause with its rule set>` |
273
+ | `unknown-rule-set` | `load failure: unknown-rule-set <rule set>` |
274
+ | `unknown-discipline` | `load failure: unknown-discipline <clause>` |
275
+ | `unknown-clause` | `load failure: unknown-clause <clause>` |
276
+ | `judgement-clause-selected` | `load failure: judgement-clause-selected <clause>` |
277
+ | `judgement-clause-listed` | `load failure: judgement-clause-listed <clause>: a judgement clause is enforced by review and is left out of clauses, adopted or not; remove it` |
278
+ | `mechanism-not-allowed` | `load failure: mechanism-not-allowed <clause> <mechanism>` |
279
+ | `runner-missing` | `load failure: runner-missing <mechanism>` |
280
+ | `runner-invalid` | `load failure: runner-invalid <mechanism> <detail>` |
281
+ | `piece-missing` | `load failure: piece-missing <clause> <mechanism>` |
282
+ | `rule-set-invalid` | `load failure: rule-set-invalid <path> <detail>` |
283
+ | `git-failed` | `load failure: git-failed <detail>` |
284
+ | `config-root-untracked` | `load failure: config-root-untracked <config root>: an eslintConfigRoots entry is a folder git tracks files under outside every excluded path, spelled exactly as git spells it; fix or remove it in disciplines.json` |
285
+ | `unexpected-error` | `load failure: unexpected-error <detail>` |
286
+ | `runner-failed` | `load failure: runner-failed <mechanism> piece-invalid <piece folder> <detail>` |
287
+ | `runner-failed` | `load failure: runner-failed <mechanism> file-unreadable <file> <detail>` |
288
+ | `runner-failed` | `load failure: runner-failed <mechanism> file-unparseable <file> <detail>` |
289
+ | `runner-failed` | `load failure: runner-failed <mechanism> tool-failed <detail>` |
290
+ | `runner-failed` | `load failure: runner-failed <mechanism> plugin-conflict <detail>` |
291
+ | `runner-failed` | `load failure: runner-failed <mechanism> team-config-unloadable <detail>` |
292
+ | `runner-failed` | `load failure: runner-failed <mechanism> runner-invalid-output <detail>` |
293
+ | `runner-failed` | `load failure: runner-failed <mechanism> toolchain-unavailable <package> found <version found>, supported <range>: add a supported version to the devDependencies of the repository root` |
294
+ | `runner-failed` | `load failure: runner-failed <mechanism> toolchain-unavailable <package> found not installed, supported <range>: <package> is a required peer of @hailstails/hone, so this install is incomplete; add a supported version to the devDependencies of the repository root and reinstall` |
295
+ | `runner-failed` | `load failure: runner-failed <mechanism> toolchain-unavailable <package> found <version found>, supported <range>; <other package> found <version found>, supported <range>: add a supported version of each to the devDependencies of the repository root` |
296
+ | `runner-failed` | `load failure: runner-failed <mechanism> toolchain-shadowed <package> resolved from <location> inside the core install <install folder>: delete <install folder>/node_modules, then reinstall the package with the repository's package manager, so the repository's own copy is used` |
297
+
298
+ The last `toolchain-unavailable` line lists every unavailable package, separated by `; `. An `unexpected-error` is a fault in Hone, not in the repository; its `<detail>` is the error's message.
299
+
300
+ An `arguments-invalid` line says what was wrong with the command as typed. Its wording is not stable.
301
+
302
+ | Problem | Line |
303
+ | --- | --- |
304
+ | `command-missing` | `load failure: arguments-invalid hone needs a command, check or project; run hone --help for usage` |
305
+ | `command-unknown` | `load failure: arguments-invalid hone has no command "<given>"; its commands are check and project; run hone --help for usage` |
306
+ | `flag-extra` | `load failure: arguments-invalid hone <flag> takes nothing after it, not "<given>"; run hone --help for usage` |
307
+ | `argument-unexpected` | `load failure: arguments-invalid hone <command> takes options, not "<given>" on its own; give each option and its value as two arguments, as in <option> <value>; run hone <command> --help for its options` |
308
+ | `option-unknown` | `load failure: arguments-invalid hone <command> has no option "<given>"; run hone <command> --help for its options` |
309
+ | `option-joined` | `load failure: arguments-invalid give <option> and its value as two arguments, as in <option> <value>, not "<given>"` |
310
+ | `value-missing` | `load failure: arguments-invalid <option> needs a value, as in <option> <value>` |
311
+ | `option-repeated` | `load failure: arguments-invalid <option> is given more than once; give it once` |
312
+ | `option-required` | `load failure: arguments-invalid hone <command> needs --repo <dir>: the folder that holds disciplines.json, usually the repository root` |
313
+ | `choice-invalid` | `load failure: arguments-invalid <option> takes <values>, not "<given>"` |
314
+ | `option-removed` | `load failure: arguments-invalid removed: "--waived-clauses"; in clauses, mark a clause "not-run" when its mechanism does not run, or "not-adopted" when its rule does not apply; see MIGRATING.md section 12` |
315
+ | `repo-unresolvable` | `load failure: arguments-invalid --repo <dir> resolves to no absolute path` |
316
+
317
+ ## hone project
318
+
319
+ `hone project` prints one line per projection file it manages, and nothing when no selected mechanism needs one.
320
+
321
+ | Output | Line |
322
+ | --- | --- |
323
+ | `project` | `<path> written` |
324
+ | `project` | `<path> unchanged` |
325
+ | `project` | `<path> removed` |
326
+ | `project` | `<path> left-in-place` |
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  stringListClauseSettings
3
- } from "../../../chunks/chunk-7OVV6NEU.js";
3
+ } from "../../../chunks/chunk-WPRR2MPJ.js";
4
4
  import {
5
5
  gatheredOutcomes
6
- } from "../../../chunks/chunk-7PVPPH4C.js";
7
- import "../../../chunks/chunk-SWPCKTJV.js";
6
+ } from "../../../chunks/chunk-LDQUT742.js";
7
+ import "../../../chunks/chunk-NCDYOPHG.js";
8
8
  import {
9
9
  folderScope
10
10
  } from "../../../chunks/chunk-QWA6OVLC.js";
@@ -6,7 +6,12 @@
6
6
  {
7
7
  "clause": "cast-expressions",
8
8
  "settings": {
9
- "module": "cast-expressions.js"
9
+ "module": "cast-expressions.js",
10
+ "escapingDirectives": [
11
+ "@ts-expect-error",
12
+ "@ts-ignore",
13
+ "@ts-nocheck"
14
+ ]
10
15
  }
11
16
  }
12
17
  ]
@@ -1,12 +1,15 @@
1
1
  import {
2
2
  stringListClauseSettings
3
- } from "../../../chunks/chunk-7OVV6NEU.js";
3
+ } from "../../../chunks/chunk-WPRR2MPJ.js";
4
+ import {
5
+ typeDirectiveReaderFor
6
+ } from "../../../chunks/chunk-5LCLBXP7.js";
4
7
  import {
5
8
  gatheredOutcomes
6
- } from "../../../chunks/chunk-7PVPPH4C.js";
9
+ } from "../../../chunks/chunk-LDQUT742.js";
7
10
  import {
8
11
  clauseAddressText
9
- } from "../../../chunks/chunk-SWPCKTJV.js";
12
+ } from "../../../chunks/chunk-NCDYOPHG.js";
10
13
  import {
11
14
  folderScope
12
15
  } from "../../../chunks/chunk-QWA6OVLC.js";
@@ -19,9 +22,6 @@ var sourceEligibility = (request) => {
19
22
  return "eligible";
20
23
  };
21
24
  var TODO_PATTERN = /\/\/\s*TODO\b/;
22
- var LINE_SUPPRESSION_PATTERN = /^\/\/\/?\s*@ts-(?:expect-error|ignore)/;
23
- var BLOCK_SUPPRESSION_PATTERN = /^\s*[/*]*\s*@ts-(?:expect-error|ignore)/;
24
- var FILE_SUPPRESSION_PATTERN = /^\/\/\/?\s*@ts-nocheck(?=[\s:]|$)/i;
25
25
  var LINTER_DIRECTIVE_PATTERN = /^(?:\/\/|\/\*)\s*((?:biome-ignore(?:-all|-start|-end)?|(?:eslint|oxlint)-(?:disable(?:-line|-next-line)?|enable)|eslint(?=\s)))\b/;
26
26
  var TRACKED_REFERENCE_PATTERN = /\([^()\s]*\d[^()\s]*\)/g;
27
27
  var LEADING_TRACKED_REFERENCE_PATTERN = /^\s*(\([^()\s]*\d[^()\s]*\))/;
@@ -62,15 +62,6 @@ var textAfter = (request) => {
62
62
  const marker = request.pattern.exec(request.text);
63
63
  return marker === null ? void 0 : request.text.slice(marker.index + marker[0].length);
64
64
  };
65
- var typeDirectiveTail = (request) => {
66
- const { comment, placement } = request;
67
- if (placement.form === "block") {
68
- return textAfter({ pattern: BLOCK_SUPPRESSION_PATTERN, text: comment.slice(comment.lastIndexOf("\n") + 1) });
69
- }
70
- const suppression = textAfter({ pattern: LINE_SUPPRESSION_PATTERN, text: comment });
71
- if (suppression !== void 0 || placement.region === "body") return suppression;
72
- return textAfter({ pattern: FILE_SUPPRESSION_PATTERN, text: comment });
73
- };
74
65
  var untrackedClauses = (request) => request.trackedClauses.filter((tracked) => request.tracking({ text: request.text, tracked }) === "untracked");
75
66
  var hitsFor = (request) => {
76
67
  if (request.untracked.length === 0) return [];
@@ -92,15 +83,9 @@ var taskHits = (request) => {
92
83
  });
93
84
  });
94
85
  };
95
- var commentPlacementOf = (request) => ({
96
- form: request.range.kind === request.syntaxApi.SyntaxKind.MultiLineCommentTrivia ? "block" : "line",
97
- region: request.fileHeaderPositions.has(request.range.pos) ? "file-header" : "body"
98
- });
99
86
  var sourceObserversFor = (request) => {
100
87
  const { sourceFile, anchorAt, trackedClauses, syntaxApi } = request;
101
- const fileHeaderPositions = new Set(
102
- (syntaxApi.getLeadingCommentRanges(sourceFile.text, 0) ?? []).map((headerRange) => headerRange.pos)
103
- );
88
+ const typeDirectiveOf = typeDirectiveReaderFor({ sourceFile, syntaxApi });
104
89
  const todoHits = taskHits(request);
105
90
  const directiveHits = [];
106
91
  const typeDirectiveHits = [];
@@ -113,10 +98,9 @@ var sourceObserversFor = (request) => {
113
98
  return {
114
99
  comment: ({ range }) => {
115
100
  const whole = sourceFile.text.slice(range.pos, range.end);
116
- const placement = commentPlacementOf({ range, fileHeaderPositions, syntaxApi });
117
- const afterTypeDirective = typeDirectiveTail({ comment: whole, placement });
118
- if (afterTypeDirective !== void 0) {
119
- typeDirectiveHits.push(...commentHits({ text: afterTypeDirective, whole, position: range.pos }));
101
+ const typeDirective = typeDirectiveOf({ range });
102
+ if (typeDirective !== void 0) {
103
+ typeDirectiveHits.push(...commentHits({ text: typeDirective.tail, whole, position: range.pos }));
120
104
  return;
121
105
  }
122
106
  if (LINTER_DIRECTIVE_PATTERN.exec(whole)?.[1] === void 0) return;
@@ -1,6 +1,6 @@
1
1
  # Audit runner
2
2
 
3
- The audit runner is Hone's standalone mechanism for checks that read a project's TypeScript source directly. Core hands it the selected clauses and the files to check; it loads each clause's piece module, parses each file once, visits every node of the syntax tree, and reports a hit wherever a piece's check finds one. It reports no native exceptions: the audit mechanism has no suppression format of its own, so its `exceptionPath` is `standalone`.
3
+ The audit runner is Hone's standalone mechanism for checks that read a project's TypeScript source directly. Core hands it the selected clauses and the files to check; it loads each clause's piece module, parses each file once, visits every node of the syntax tree, and reports a hit wherever a piece's check finds one. Its `exceptionPath` is `standalone`: the audit mechanism has no suppression format of its own. The one native channel it reports is a TypeScript directive, `@ts-expect-error`, `@ts-ignore` or `@ts-nocheck`, in a file the clause's piece reads, for each clause whose `piece.json` settings list that directive in `escapingDirectives`; each is an `inline-disable` of that clause, which only a file record on that clause and file covers.
4
4
 
5
5
  ## Runtime
6
6
 
@@ -12,7 +12,8 @@ The audit runner is Hone's standalone mechanism for checks that read a project's
12
12
 
13
13
  - `walker-piece.ts` declares the contract a piece implements, `WalkerPiece`: a `prepare` call that receives the piece's selected clauses, the repository's tracked paths and TypeScript's API, and returns a prepared check with per-file `prepareFile` and a repository-wide `finish`.
14
14
  - `source-scope.ts` classifies a repository path as `generated` (under `node_modules`, `dist`, `build`, `coverage`, `.git`, or a root `vendor`) or `authored`, so every piece skips generated folders the same way.
15
- - `walker-check-schema.ts` holds the schema for a clause's settings: `module`, a path inside the piece folder ending `.ts`.
15
+ - `walker-check-schema.ts` holds the schema for a clause's settings: `module`, a path inside the piece folder ending `.ts`, and optionally `escapingDirectives`, the TypeScript directives that escape the clause.
16
+ - `type-directives.ts` reads a comment as a TypeScript directive only where the compiler honours it, and turns each directive a clause lists into an `inline-disable` of that clause. A piece that judges directives reads them through it too.
16
17
  - `piece-clause-settings.ts` reads the string lists a Hone piece declares under `clauseSettings` from the settled values core hands it on each clause, and reports a malformed value as `piece-invalid`.
17
18
  - `prepare-walker-pieces.ts` loads each selected module once and prepares it with every selected clause that names it.
18
19
  - `observe-walker-file.ts` offers one file to every prepared piece, parses it once if any piece asks for syntax, walks it, and collects the hits.