@hailstails/hone 1.3.0 → 1.4.0

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 (47) hide show
  1. package/ADOPTING.md +2 -2
  2. package/CHANGELOG.md +22 -0
  3. package/MIGRATING.md +23 -0
  4. package/README.md +27 -6
  5. package/api/audit.d.ts +1 -1
  6. package/api/testing.js +3 -3
  7. package/chunks/chunk-335ITLPO.js +7 -0
  8. package/chunks/{chunk-YSN46EB3.js → chunk-6SM3HKWO.js} +270 -624
  9. package/chunks/{chunk-PL2PNPAR.js → chunk-E6VR3VRV.js} +1 -6
  10. package/chunks/{chunk-H4V72FCW.js → chunk-FEWCJU7H.js} +9 -1
  11. package/chunks/chunk-WF3PPYRR.js +27 -0
  12. package/core/check/tool-command.js +756 -64
  13. package/core/mechanism-port/runner-result-types.d.ts +6 -0
  14. package/docs/adding-a-discipline-or-mechanism.md +3 -3
  15. package/docs/extending.md +1 -0
  16. package/docs/output-contract.md +52 -10
  17. package/mechanisms/audit/CD-27/test-body-logic.js +394 -46
  18. package/mechanisms/audit/runner/runner.js +1 -1
  19. package/mechanisms/audit/runner/typescript-parse.d.ts +2 -0
  20. package/mechanisms/audit/runner/walker-piece.d.ts +2 -1
  21. package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +7 -4
  22. package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +21 -11
  23. package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +15 -5
  24. package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +7 -3
  25. package/mechanisms/eslint/CD-41/README.md +1 -1
  26. package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +100 -28
  27. package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +8 -4
  28. package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +8 -4
  29. package/mechanisms/eslint/runner/README.md +9 -2
  30. package/mechanisms/eslint/runner/runner.js +1404 -1382
  31. package/methods/lenses/di-discipline.md +4 -5
  32. package/methods/lenses/test-discipline.md +1 -1
  33. package/package.json +1 -1
  34. package/rules/CD-1/CHECKS.md +2 -0
  35. package/rules/CD-12/README.md +1 -1
  36. package/rules/CD-15/CHECKS.md +2 -0
  37. package/rules/CD-17/README.md +3 -3
  38. package/rules/CD-2/CHECKS.md +2 -0
  39. package/rules/CD-25/CHECKS.md +2 -2
  40. package/rules/CD-25/README.md +3 -3
  41. package/rules/CD-27/CHECKS.md +382 -6
  42. package/rules/CD-27/README.md +1 -1
  43. package/rules/CD-27/discipline.json +130 -0
  44. package/rules/CD-41/CHECKS.md +10 -0
  45. package/rules/CD-41/README.md +2 -0
  46. package/rules/CD-41/discipline.json +14 -0
  47. package/chunks/chunk-YLZ73C7O.js +0 -0
@@ -1,9 +1,15 @@
1
1
  import type { Anchor } from "../values/anchor.js";
2
2
  import type { ClauseAddress } from "../values/clause-address-types.js";
3
3
  import type { RepoPath } from "../values/repo-path-types.js";
4
+ export type Remedy = {
5
+ readonly fix: string;
6
+ readonly page: string;
7
+ readonly section: string;
8
+ };
4
9
  export type Hit = {
5
10
  readonly clause: ClauseAddress;
6
11
  readonly file: RepoPath;
7
12
  readonly anchor: Anchor;
8
13
  readonly snippet: string;
14
+ readonly remedy?: Remedy;
9
15
  };
@@ -67,7 +67,7 @@ For each mechanism in a clause's `mechanisms` list, add a piece folder `mechanis
67
67
  `discipline` and `mechanism` must match the folder names, every `clause` must exist in the discipline, and no clause may appear twice. Core reads only this envelope. `settings` belongs to the runner, which parses it with its own schema:
68
68
 
69
69
  - **audit:** `{ "module": "<file>.ts" }`, a path inside the piece folder; a `.js` module is accepted too, which is what the built package's pieces name. The module exports `check`, typed with `import type { WalkerPiece }` from `mechanisms/audit/runner/walker-piece.ts`. See `mechanisms/audit/runner/README.md`.
70
- - **eslint:** `{ "pluginNamespace", "pluginModule", "rule" }`. `pluginModule` is a `.ts` or `.js` path inside the piece folder whose default export is an ESLint plugin; `rule` must be a key of its `rules`. The rule id is `<pluginNamespace>/<rule>`. The namespace `hone-core` is reserved for Hone's own machinery. The namespaces `hone` and `hone-*` belong to Hone's own rule set. A team rule set's pieces must use its rule-set name or `<ruleSet>-<name>`. Two selected clauses may not share a rule id, or a namespace with different plugin modules. CD-14's piece is `mechanisms/eslint/CD-14/piece.json`, pointing at the rule `no-class-authoring` in `cd14/cd14.eslint-plugin.ts` under the namespace `hone`.
70
+ - **eslint:** `{ "pluginNamespace", "pluginModule", "rule" }`. `pluginModule` is a `.ts` or `.js` path inside the piece folder whose default export is an ESLint plugin; `rule` must be a key of its `rules`. The rule id is `<pluginNamespace>/<rule>`. The namespace `hone-core` is reserved for Hone's own machinery. The namespaces `hone` and `hone-*` belong to Hone's own rule set. A team rule set's pieces must use its rule-set name or `<ruleSet>-<name>`. Two selected clauses may not share a rule id, or a namespace with different plugin modules. CD-14's piece is `mechanisms/eslint/CD-14/piece.json`, pointing at the rule `no-class-authoring` in `cd14/cd14.eslint-plugin.ts` under the namespace `hone`. A shipped piece writes each of its own rules with `siteRule` from `mechanisms/eslint/runner/rule-sites.ts`, which holds the mapping onto ESLint's listener keys (see the runner's README). A team rule set's piece stays a plain ESLint plugin.
71
71
 
72
72
  A clause entry may also declare the settings a repository may tune, beside `settings`: `"clauseSettings": { "<key>": { "default": <JSON>, "choices": [<JSON>, ...] } }`. `choices` is optional; when given, every choice is the default's JSON kind and the default is one of them. Core reads these declarations itself, checks a repository's values from its `disciplines.json` against them when the check loads, and hands the piece the settled values, defaults included, as `clauseSettings` on each clause, typed `ClauseSettingValues`, apart from the mechanism's own `settings`. The `audit` and `rule-set` type entries carry no code, so a team's piece checks the shape of its `clauseSettings` itself, for example with its own schema, and returns `piece-invalid` when they do not match. No eslint piece declares `clauseSettings` yet, so a repository's settings for an eslint clause are refused when the check loads.
73
73
 
@@ -181,13 +181,13 @@ The ESLint runner's map. "Checked file" means a tracked `.ts`, `.tsx`, `.mts` or
181
181
  | ESLint native channel | Exception kind | Can a record cover it? |
182
182
  | --- | --- | --- |
183
183
  | a checked file the team's configuration ignores (for example a global `ignores` block); reported for every selected clause | `ignore` | no |
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 |
184
+ | a checked file on which the team's resolved configuration leaves a selected rule below `"error"` (`"warn"`, `"off"` or not set), unless a record projects that rule off for that file | `config-override` | yes |
185
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 |
186
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 |
187
187
  | an `/* eslint ... */` comment configuring a selected rule, or one that cannot be parsed | `inline-rule-config` | no |
188
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 |
189
189
 
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.
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. The runner does not report a `config-override` on a clause and file that a record projects off, forfeited or not: while the projection is in effect it is spread last and enables every selected rule at `"error"`, so a rule below `"error"` there is the projection's own off-switch. That off-switch never counts as a native exception the record holds, so a record whose file no longer breaks its clause is `stale`.
191
191
 
192
192
  How the runner finds each channel (`mechanisms/eslint/runner/`):
193
193
 
package/docs/extending.md CHANGED
@@ -225,6 +225,7 @@ export const check: WalkerPiece = {
225
225
  - `module` is a path inside the piece folder, and the module exports `check`.
226
226
  - `prepare` runs once with the selected clauses, the repository's file list and TypeScript's syntax API. The repository also carries a `disk`, a required field: its `root`, the kind of entry at an absolute path (`kindAt`) and a file's text (`textAt`), for a piece that must read files beyond the one it is given, untracked ones included. In a conformance case the disk holds only the case's file. A piece's own tests that build a `WalkerRepository` by hand must now give it a `disk` (the type is `WalkerDisk` from `@hailstails/hone/audit`), as the example's proof does. Such tests written before the field was added no longer type-check until they give it one. `prepareFile` runs once per tracked file and returns `skipped`, `complete` with its hits, or `syntax` with observers that walk the file's syntax tree. `finish` returns hits that need the whole repository.
227
227
  - A hit passes back the clause's `address` unchanged, a 1-based line and 0-based column, and a short snippet.
228
+ - A hit may also give a `remedy` (the type is `Remedy` from `@hailstails/hone/audit`): a `fix` naming what to write instead of the form it flagged, the `page` that shows it as a path inside the rule's folder (`rules/<ID>/`), such as `CHECKS.md` or `README.md`, and the `section` of that page, as lowercase letters, digits and hyphens. Core resolves the page to the path a reader opens, as it does for the rule page under `readFirst`, and the finding then ends with ` fix: <fix> (<fix page>#<section>)`; see [the output contract](output-contract.md#report-lines).
228
229
  - When the piece cannot run, for example on settings it does not accept, return a failed result whose error is a `PieceFailure`: `kind` `piece-invalid`, the clause's `pieceRoot` and a `detail`. `hone check` then stops with a load failure naming the piece folder.
229
230
  - When the piece cannot parse a file, return a failed result whose error is `kind` `file-unparseable`, the `file` and a `detail`. `hone check` then stops with `load failure: runner-failed audit file-unparseable <file> <detail>`.
230
231
  - To read JSON with comments, such as a `tsconfig.json`, call TypeScript's own parser on the syntax API: `syntaxApi.parseConfigFileTextToJson(file, text)` returns the parsed value as `config` and sets `error` when it cannot parse the text. A piece does not import a JSON parser of its own; see [What is stable](#what-is-stable).
@@ -1,18 +1,18 @@
1
1
  # Output contract
2
2
 
3
- This page lists everything the `hone` command prints, exactly as it prints it: the help, the version, the report, the load failures, the `hone project` lines, the `hone record-debt` lines and the `hone split-records` 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.
3
+ This page lists everything the `hone` command prints, exactly as it prints it: the help, the version, the report, the load failures, the `hone project` lines, the `hone record-debt` lines, the `hone prune-debt` lines and the `hone split-records` 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
4
 
5
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
6
 
7
7
  ## Streams and exit codes
8
8
 
9
- Hone prints everything to standard output: the report, the help, the version, `hone project`, `hone record-debt` and `hone split-records` 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.
9
+ Hone prints everything to standard output: the report, the help, the version, `hone project`, `hone record-debt`, `hone prune-debt` and `hone split-records` 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
10
 
11
11
  The exit code is the signal a hook should act on:
12
12
 
13
- - `0`: `hone check` printed `verdict: pass` or `verdict: pass (partial assessment)`, `hone project` wrote or confirmed every projection, `hone record-debt` wrote every record it needed or needed none, `hone split-records` split the records or found nothing to split, or help or the version was printed;
13
+ - `0`: `hone check` printed `verdict: pass` or `verdict: pass (partial assessment)`, `hone project` wrote or confirmed every projection, `hone record-debt` wrote every record it needed or needed none, `hone prune-debt` removed every paid record or found none, `hone split-records` split the records or found nothing to split, or help or the version was printed;
14
14
  - `1`: `hone check` printed `verdict: fail` or `verdict: fail (partial assessment)` as its last line. Exit `1` always comes with one of those lines, 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, records `hone record-debt` or `hone split-records` could not write or place, and an error Hone did not expect, which prints as `unexpected-error`.
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, records `hone record-debt`, `hone prune-debt` or `hone split-records` could not write or place, and an error Hone did not expect, which prints as `unexpected-error`.
16
16
 
17
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
18
 
@@ -35,6 +35,7 @@ These are not stable, so a minor release may change them:
35
35
  - the wording after `load failure: arguments-invalid`, written for the person who typed the command;
36
36
  - the text after a load failure's values, which says what to do next: the repair text of `selection-absent`, `judgement-clause-listed`, `config-root-untracked` and `why-chains-required`, and everything after the kind in `toolchain-unavailable` and `toolchain-shadowed`;
37
37
  - the `readFirst` lines and their leading note, written for a person;
38
+ - the words of a finding's `<fix>`, and which `<fix page>` and `<section>` it names;
38
39
  - 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
  - the words of a `hone record-debt` line after the `:` that follows its file, which say why no record was written and what to do instead.
40
41
 
@@ -57,14 +58,18 @@ In the tables below, a word in angle brackets, such as `<clause>`, stands for a
57
58
  | `<folders>` | paths separated by `, ` | may hold a space |
58
59
  | `<folder>` | the folder that holds a `<slice>` | may hold a space |
59
60
  | `<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 |
61
+ | `<prune command>` | the command that runs `hone prune-debt` for this repository: like `<project command>` with `prune-debt` in place of `project`, followed by `--base-revision` and `--forfeiture` with their values when the check was given them, each value written as a path is | may hold a space |
60
62
  | `<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 |
61
63
  | `<dir>` | the `--repo` value as typed | may hold a space |
62
64
  | `<url>` | the module URL Hone could not resolve, as given | may hold a space |
63
65
  | `<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 |
66
+ | `<fix>` | what to write instead of the form a finding flags, as the clause's piece words it | may hold a space |
67
+ | `<fix page>` | the page in the clause's rule folder that its piece names for a fix, such as that rule's `CHECKS.md`, as a path described below | may hold a space |
68
+ | `<section>` | the section of `<fix page>` that shows that form and what to write instead: lowercase letters, digits and hyphens | never |
64
69
  | `<comment>`, `<script>`, `<option>`, `<source>` | the native exception's comment, the `package.json` script name and the option in it (or the whole script, when a quote in it has no partner), or where an imported record came from | may hold a space |
65
70
  | `<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 |
66
71
 
67
- 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 path into Hone's own package, such as a `<rule page>`, the `<adoption guide>`, a `<piece folder>` or the `<install folder>`, is printed through the repository's `node_modules/@hailstails/hone` when that folder holds the same `package.json` as the package that is running, as it does under pnpm, which runs the package from its store under `node_modules/.pnpm`. When the repository root has no such folder, as when the package is installed only in a workspace package, installed globally or run from a source checkout, the path is printed where the running package is, by the rules above. 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.
72
+ 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 path into Hone's own package, such as a `<rule page>`, a `<fix page>`, the `<adoption guide>`, a `<piece folder>` or the `<install folder>`, is printed through the repository's `node_modules/@hailstails/hone` when that folder holds the same `package.json` as the package that is running, as it does under pnpm, which runs the package from its store under `node_modules/.pnpm`. When the repository root has no such folder, as when the package is installed only in a workspace package, installed globally or run from a source checkout, the path is printed where the running package is, by the rules above. 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.
68
73
 
69
74
  ## Commands
70
75
 
@@ -72,6 +77,7 @@ Paths are printed with forward slashes. A path inside the `--repo` folder is pri
72
77
  hone check --repo <dir> [--base-revision <revision>] [--report-output <full|failures-only|counts|verdict-only>] [--forfeiture <this-run|elsewhere>]
73
78
  hone project --repo <dir>
74
79
  hone record-debt --repo <dir> --base-revision <revision> [--leave <path>]...
80
+ hone prune-debt --repo <dir> [--base-revision <revision>] [--forfeiture <this-run|elsewhere>]
75
81
  hone split-records --repo <dir>
76
82
  hone --help
77
83
  hone --version
@@ -90,6 +96,7 @@ commands:
90
96
  check check the repository against the disciplines it selects and print the report, ending in its verdict
91
97
  project write the native configuration each selected embedded mechanism needs, printing each file as written or unchanged
92
98
  record-debt add a file carve-out naming only its clause and file to the exception records for each clause and file the check finds broken, as inherited debt, printing each pair and what was done
99
+ prune-debt remove from the exception records each stale or forfeited file carve-out whose file no longer exists, printing each pair removed
93
100
  split-records move the exception records from discipline-exceptions.json into the discipline-exceptions folder, one file for each record kind and discipline, printing each file as written or removed
94
101
 
95
102
  options:
@@ -164,6 +171,28 @@ exit codes:
164
171
  2 a load failure: an input could not be loaded, a mechanism failed, the records could not be written, or Hone failed unexpectedly
165
172
  ```
166
173
 
174
+ `hone prune-debt --help` prints:
175
+
176
+ ```text
177
+ usage: hone prune-debt --repo <dir> [--base-revision <revision>] [--forfeiture <this-run|elsewhere>]
178
+
179
+ remove from the exception records each stale or forfeited file carve-out whose file no longer exists, printing each pair removed
180
+
181
+ options:
182
+ --repo <dir>
183
+ the folder that holds disciplines.json, usually the repository root
184
+ --base-revision <revision>
185
+ the revision the change is measured from; without it no file carve-out can be forfeited
186
+ --forfeiture <this-run|elsewhere>
187
+ 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
188
+ --help, -h
189
+ print this help
190
+
191
+ exit codes:
192
+ 0 every paid record was removed, or none was paid
193
+ 2 a load failure: an input could not be loaded, a mechanism failed, the records could not be written, or Hone failed unexpectedly
194
+ ```
195
+
167
196
  `hone split-records --help` prints:
168
197
 
169
198
  ```text
@@ -209,7 +238,7 @@ exit codes:
209
238
  | `unmeasured` | failing | what this run could not measure |
210
239
  | `projectionProblems` | failing | ESLint projections that are out of date |
211
240
  | `assessment` | informational | concerns this run left to another run |
212
- | `readFirst` | guidance | where to read before changing code, for each clause with findings |
241
+ | `readFirst` | guidance | where to read before changing code, for each clause with findings, and the command that removes recorded debt that is paid |
213
242
 
214
243
  `--report-output`, or `reportOutput` in `disciplines.json`, sets how much is printed. The verdict and the exit code are the same in every output.
215
244
 
@@ -236,7 +265,7 @@ The verdict line reads `(partial assessment)` whenever the report has an `assess
236
265
 
237
266
  ## Report lines
238
267
 
239
- 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.*`.
268
+ Each section's entries take one of these shapes. A finding ends with ` fix: <fix> (<fix page>#<section>)` when its clause's piece names what to write instead of the form it flagged and the page that shows it, as `CD-27#test-body-logic` does; an exempted finding never carries it. 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.*`.
240
269
 
241
270
  | Section | Line |
242
271
  | --- | --- |
@@ -245,6 +274,7 @@ Each section's entries take one of these shapes. An exempted finding repeats ` e
245
274
  | `notRun` | `<clause> adopted, mechanism not run: enforced by review` |
246
275
  | `editions` | `<clause> <mechanism> edition <edition> of <latest>` |
247
276
  | `findings` | `<clause> <mechanism> <file>:<line>:<column> <snippet>` |
277
+ | `findings` | `<clause> <mechanism> <file>:<line>:<column> <snippet> fix: <fix> (<fix page>#<section>)` |
248
278
  | `exempted` | `<clause> <mechanism> <file>:<line>:<column> <snippet> exempted by <record kind>` |
249
279
  | `exempted` | `<clause> <mechanism> <file>:<line>:<column> <snippet> exempted by <record kind> imported from <source>` |
250
280
  | `uncovered` | `<clause>` |
@@ -311,8 +341,12 @@ Each section's entries take one of these shapes. An exempted finding repeats ` e
311
341
  | `readFirst` | `<clause>: read the "## <clause>" section of disciplines.assessment.md; its rule set has no rule page at <rule page>` |
312
342
  | `readFirst` | `<clause>: its rule set has no rule page at <rule page>; disciplines.assessment.md does not assess this clause` |
313
343
  | `readFirst` | `<clause>: its rule set has no rule page at <rule page>` |
344
+ | `readFirst` | `prune-debt: 1 file carve-out under stale or forfeited still records debt that is paid; run <prune command> to remove what is paid, and commit the exception records it changes` |
345
+ | `readFirst` | `prune-debt: <count> file carve-outs under stale or forfeited still record debt that is paid; run <prune command> to remove what is paid, and commit the exception records it changes` |
346
+ | `readFirst` | `prune-debt: 1 file carve-out under stale or forfeited still records debt that is paid; run <prune command> to remove what is paid, then run <project command> and commit the exception records with every disciplines.<mechanism>.mjs it writes` |
347
+ | `readFirst` | `prune-debt: <count> file carve-outs under stale or forfeited still record debt that is paid; run <prune command> to remove what is paid, then run <project command> and commit the exception records with every disciplines.<mechanism>.mjs it writes` |
314
348
 
315
- `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.
349
+ `readFirst` has one clause line per clause with findings, in the order the findings first name them, then, last, one `prune-debt` line when any `file-carve-out` under `stale` or `forfeited` names a file that no longer exists: one `hone prune-debt` would remove. It names `hone project` too when any of those records is for a clause whose mechanism, such as `eslint`, puts records into effect through a projection, and then names each such mechanism's projection file, joined by ` and every `. 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.
316
350
 
317
351
  ## Load failures
318
352
 
@@ -366,8 +400,8 @@ An `arguments-invalid` line says what was wrong with the command as typed. Its w
366
400
 
367
401
  | Problem | Line |
368
402
  | --- | --- |
369
- | `command-missing` | `load failure: arguments-invalid hone needs a command, check, project, record-debt or split-records; run hone --help for usage` |
370
- | `command-unknown` | `load failure: arguments-invalid hone has no command "<given>"; its commands are check, project, record-debt and split-records; run hone --help for usage` |
403
+ | `command-missing` | `load failure: arguments-invalid hone needs a command, check, project, record-debt, prune-debt or split-records; run hone --help for usage` |
404
+ | `command-unknown` | `load failure: arguments-invalid hone has no command "<given>"; its commands are check, project, record-debt, prune-debt and split-records; run hone --help for usage` |
371
405
  | `flag-extra` | `load failure: arguments-invalid hone <flag> takes nothing after it, not "<given>"; run hone --help for usage` |
372
406
  | `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` |
373
407
  | `option-unknown` | `load failure: arguments-invalid hone <command> has no option "<given>"; run hone <command> --help for its options` |
@@ -404,6 +438,14 @@ An `arguments-invalid` line says what was wrong with the command as typed. Its w
404
438
  | `record-debt` | `<clause> refused <file>: the clause's discipline refuses exceptions; fix it` |
405
439
  | `record-debt` | `<clause> nested-configuration <file>: the file loads the <mechanism> configuration in <config folder>, and <folder> holds its own disciplines.json; nested Hone configurations are not supported yet (https://github.com/HailsTails/hone/issues/72), so the <mechanism> projection cannot put a record on this file into effect; fix it, or govern <folder> from this repository by removing <folder>/disciplines.json, then run record-debt again` |
406
440
 
441
+ ## hone prune-debt
442
+
443
+ `hone prune-debt` runs the check with the `--base-revision` and `--forfeiture` it is given, then removes from the exception records each `file-carve-out` the check lists under `stale` or `forfeited` whose file no longer exists, unless a finding, exempted finding or native exception is still listed on its clause and file. It works in whichever [layout](../README.md#the-split-layout) the repository keeps the records in, and prints one line for each clause and file it removed, ordered by file and then by clause. It leaves every other record for a person: a `file-carve-out` on a file that still exists, stale or forfeited, and an `authorised-location` or `clause-wide-carve-out` under `stale`. It prints nothing when it removed none. It does not write the projection: with an `eslint` clause, run `hone project` after it, as the `readFirst` line says. The text of every other record in a file it changes is kept byte for byte. In the split layout, a rule's file left with no records is deleted; a single `discipline-exceptions.json` left with none holds an empty list.
444
+
445
+ | Output | Line |
446
+ | --- | --- |
447
+ | `prune-debt` | `<clause> removed <file>` |
448
+
407
449
  ## hone split-records
408
450
 
409
451
  `hone split-records` moves a repository's exception records from `discipline-exceptions.json` into the `discipline-exceptions` folder. It prints a `written` line for each file it writes, in path order, then a `removed` line for `discipline-exceptions.json`. When the records are already split, or `discipline-exceptions.json` is absent or holds no records, it prints one line, changes nothing and exits `0`. A records file that holds a record whose clause names no discipline, or keys other than `version` and `exceptions`, is `records-unsplittable`, and nothing is written.