@hailstails/hone 1.2.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.
- package/ADOPTING.md +6 -6
- package/CHANGELOG.md +38 -0
- package/MIGRATING.md +28 -5
- package/README.md +41 -14
- package/api/audit.d.ts +1 -1
- package/api/testing.js +3 -3
- package/chunks/chunk-335ITLPO.js +7 -0
- package/chunks/{chunk-5VXHQC4A.js → chunk-6SM3HKWO.js} +302 -637
- package/chunks/{chunk-PL2PNPAR.js → chunk-E6VR3VRV.js} +1 -6
- package/chunks/{chunk-H4V72FCW.js → chunk-FEWCJU7H.js} +9 -1
- package/chunks/chunk-WF3PPYRR.js +27 -0
- package/core/check/tool-command.js +797 -88
- package/core/mechanism-port/runner-result-types.d.ts +6 -0
- package/docs/adding-a-discipline-or-mechanism.md +4 -4
- package/docs/extending.md +5 -5
- package/docs/output-contract.md +60 -14
- package/mechanisms/audit/CD-27/test-body-logic.js +394 -46
- package/mechanisms/audit/runner/runner.js +1 -1
- package/mechanisms/audit/runner/typescript-parse.d.ts +2 -0
- package/mechanisms/audit/runner/walker-piece.d.ts +2 -1
- package/mechanisms/eslint/CD-1/cd1/cd1.eslint-plugin.js +7 -4
- package/mechanisms/eslint/CD-10/cd10/cd10.eslint-plugin.js +21 -11
- package/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js +15 -5
- package/mechanisms/eslint/CD-27/cd27/cd27.eslint-plugin.js +7 -3
- package/mechanisms/eslint/CD-41/README.md +1 -1
- package/mechanisms/eslint/CD-41/cd41/cd41.eslint-plugin.js +100 -28
- package/mechanisms/eslint/CD-42/cd42/cd42.eslint-plugin.js +8 -4
- package/mechanisms/eslint/CD-7/cd7/cd7.eslint-plugin.js +8 -4
- package/mechanisms/eslint/runner/README.md +10 -3
- package/mechanisms/eslint/runner/runner.js +1410 -1351
- package/methods/lenses/di-discipline.md +4 -5
- package/methods/lenses/test-discipline.md +1 -1
- package/package.json +1 -1
- package/rules/CD-1/CHECKS.md +2 -0
- package/rules/CD-10/CHECKS.md +2 -2
- package/rules/CD-12/README.md +1 -1
- package/rules/CD-14/CHECKS.md +2 -2
- package/rules/CD-15/CHECKS.md +4 -2
- package/rules/CD-17/CHECKS.md +2 -2
- package/rules/CD-17/README.md +3 -3
- package/rules/CD-19/CHECKS.md +2 -2
- package/rules/CD-2/CHECKS.md +4 -2
- package/rules/CD-23/CHECKS.md +2 -2
- package/rules/CD-25/CHECKS.md +3 -3
- package/rules/CD-25/README.md +3 -3
- package/rules/CD-26/CHECKS.md +2 -2
- package/rules/CD-27/CHECKS.md +384 -8
- package/rules/CD-27/README.md +1 -1
- package/rules/CD-27/discipline.json +130 -0
- package/rules/CD-3/CHECKS.md +2 -2
- package/rules/CD-40/CHECKS.md +2 -2
- package/rules/CD-41/CHECKS.md +12 -2
- package/rules/CD-41/README.md +2 -0
- package/rules/CD-41/discipline.json +14 -0
- package/rules/CD-42/CHECKS.md +2 -2
- package/rules/CD-43/CHECKS.md +2 -2
- package/rules/CD-44/CHECKS.md +2 -2
- package/rules/CD-47/CHECKS.md +2 -2
- package/rules/CD-5/CHECKS.md +2 -2
- package/rules/CD-6/CHECKS.md +2 -2
- package/rules/CD-7/CHECKS.md +2 -2
- package/rules/CD-7a/CHECKS.md +2 -2
- package/rules/CD-8/CHECKS.md +2 -2
- package/chunks/chunk-YLZ73C7O.js +0 -0
package/ADOPTING.md
CHANGED
|
@@ -337,7 +337,7 @@ CD-15#loops audit src/basket.ts:15:0 for (const line of this.lines) {
|
|
|
337
337
|
| `exempted` | findings an exception covers; informational |
|
|
338
338
|
| `unrecorded` | a native exception no record holds, as `<clause> <mechanism> <kind> <detail>`: remove it, or record it where step 7 allows. An inline disable, `<clause> eslint inline-disable <file>:<line> <comment>`, and a TypeScript directive, `CD-2#cast-expressions audit inline-disable <file>:<line> <comment>`, are held only by an `authorised-location` or `file-carve-out` on that clause and file. An `eslint-disable` naming no rule escapes every selected clause, needs a record for each, and its lines end ` names no rule and escapes every selected clause: naming the rule is the cheap fix`. A lint-script option, `<clause> eslint command-line-option <package.json> <script> <option> weakens the script's whole run, so no record can cover it: remove it from the script`, cannot be recorded. Where another command comes before `eslint` in its script, as in `tsc && eslint -c eslint.config.mjs .`, the line instead reads `<clause> eslint command-line-option <package.json> <script> <option>: <command> is not the first command of its script, so Hone cannot tell what the option does to the files under check; give <command> a script of its own, such as "<invocation>"`: move that command to a script of its own. Where something before `eslint` in its own command is neither a package runner nor a `NAME=value` setting, as `env` in `env --chdir=src eslint --ignore-pattern dist .` or `-y` in `npx -y eslint --ignore-pattern dist .`, it reads `<clause> eslint command-line-option <package.json> <script> <option>: "<wrapper>" comes before <command> and is neither a package runner nor a NAME=value setting, so Hone cannot tell what the option does to the files under check; put only package runners and NAME=value settings before <command>`. `cross-env` followed only by `NAME=value` settings counts as a setting |
|
|
339
339
|
| `uncovered` | a mechanical clause of an adopted discipline is not listed: add it to `disciplines.json` with a mechanism, `"not-run"` or `"not-adopted"` |
|
|
340
|
-
| `stale` | an exception that no longer exempts anything:
|
|
340
|
+
| `stale` | an exception that no longer exempts anything. A `file-carve-out` whose file no longer exists is removed by the `hone prune-debt` command the last `readFirst` line names; run it, then `npm run --silent hone:project`. Delete every other stale record by hand, including a `file-carve-out` on a file that still exists, then run `hone:project` again ([README.md](README.md#pruning-paid-debt)). Right after a move from an older route, first check that its settings were carried over ([MIGRATING.md](MIGRATING.md#2a-carry-over-the-old-routes-settings) step 2a) |
|
|
341
341
|
| `forfeited` | a file carve-out whose file changed since `--base-revision`: fix the file and delete the carve-out |
|
|
342
342
|
| `invalidRecords` | an exception entry that cannot be accepted, with the reason, for example `clause-not-run` or `clause-not-adopted` for an entry on a clause listed as `"not-run"` or `"not-adopted"`: correct or delete it |
|
|
343
343
|
| `doublyHeld` | a file both authorised and carved out for one clause: keep one |
|
|
@@ -356,7 +356,7 @@ Before recording anything, take the chain in [the spirit of the rules](rules/SPI
|
|
|
356
356
|
- `file-carve-out`: known debt in one file. It is forfeited, and fails the run, as soon as that file changes since `--base-revision`. An `eslint-disable` comment or a `@ts-expect-error`, `@ts-ignore` or `@ts-nocheck` directive already in a file is debt of this kind on the clause it escapes; a new one in a file with no record is `unrecorded`.
|
|
357
357
|
- `clause-wide-carve-out`: debt across the whole clause. The rule binds and its check is sound, and the codebase cannot address the debt right now. Its why-chain records why, and the debt has an owner who will pay it down. The check still runs, and a clause-wide carve-out that exempts no finding is `stale`, so record one only while the clause still has findings. Leaving the clause out of `clauses` is not an alternative: it leaves the clause `uncovered`. If the check is not a true measure of the rule here, or cannot work here, list the clause as `"not-run"` instead; if the rule does not apply, list it as `"not-adopted"` (step 4).
|
|
358
358
|
|
|
359
|
-
Every entry needs a `reason
|
|
359
|
+
A `file-carve-out` is debt and needs only its `kind`, `clause` and `file`; its `reason` is an optional note to future developers. Every other entry needs a `reason`, and an `authorised-location` or `clause-wide-carve-out` also needs a `whyChain` shaped like this, with exactly five steps in `whys`:
|
|
360
360
|
|
|
361
361
|
```json
|
|
362
362
|
"whyChain": {
|
|
@@ -380,14 +380,14 @@ Debt or authorisations already recorded by an earlier system, for example the ol
|
|
|
380
380
|
|
|
381
381
|
The records live in `discipline-exceptions.json` by default. To keep one file for each rule and kind instead, so the name of a changed file says which rule and which kind a change touches, move to the split layout with `hone split-records`, as [MIGRATING.md](MIGRATING.md#16-moving-to-the-split-layout) section 16 shows; [README.md](README.md#the-split-layout) describes the layout. Everything that reads or writes records works the same in either.
|
|
382
382
|
|
|
383
|
-
|
|
383
|
+
Existing debt needs no chain and no reason: a `file-carve-out` names only its clause and file, and step 7a writes those records for you. Add a `reason` if you want to leave future developers a note on what the debt signals. A run with any file carve-out still needs `--base-revision`, or it reports `forfeiture-unmeasured` and fails. `"fileExceptionWhyChains": "optional"` in `disciplines.json` lets an `authorised-location` give only its `reason` too, but a reason-only `authorised-location` will be refused in the next major release. A `clause-wide-carve-out` still needs its `whyChain`, and a `whyChain` or `provenance` you give anyway is still checked. [README.md](README.md#discipline-exceptionsjson) has the details.
|
|
384
384
|
|
|
385
385
|
### 7a. Record the debt you inherit
|
|
386
386
|
|
|
387
387
|
A repository with existing code usually has more findings than the change that adopts Hone can fix. `hone record-debt` writes a `file-carve-out` for each clause and file the check finds broken, so the first passing run does not wait on hundreds of records written by hand. Do this after the assessment (step 5a), and after fixing what you are going to fix in this change.
|
|
388
388
|
|
|
389
389
|
1. **Decide the permanent exceptions first.** List each file or folder that breaks a clause on purpose and always will, such as the one adapter that reads the real clock. Those are not debt. They get an `authorised-location` with their own reason, written by a person, so keep them out of the generated records with `--leave`.
|
|
390
|
-
2. **
|
|
390
|
+
2. **Leave `disciplines.json` as it is, and put every check on this release.** The records the command writes are file carve-outs, which are debt and need no `whyChain` and no `reason`, so it needs no setting. The same command records debt a later change uncovers, such as a newly selected clause or a newer edition: run it again against the branch's base. A Hone from before file carve-outs could leave out `reason` refuses such a record: the whole check stops with `load failure: file-malformed <records file> … at exceptions[<index>].reason` and exits `2`. So before the command writes any record, update the Hone that every pre-push hook, CI job and other machine runs to this release or later, as [ADOPTING.md](#10-update-and-remove) step 10 says, or that check stops.
|
|
391
391
|
3. **Finish every source file this change edits.** Decay is assessed against the branch's base, the revision your pre-push hook and CI pass to the check (step 5), such as `origin/main`, not against the commit you run from. A file the adopting change edits has changed since that base, so a record for it is forfeited there, even after you commit the edit. In each file this change edits, fix every finding of each clause, or take the edit out of this change and make it later in a change that fixes the file. A file this change adds has no record to lose: point 4 reports it `new-file`.
|
|
392
392
|
4. **Run it once, with the branch's base as `--base-revision`**, one `--leave` for each path from point 1. Fetch the base first, so the revision is current:
|
|
393
393
|
|
|
@@ -396,13 +396,13 @@ A repository with existing code usually has more findings than the change that a
|
|
|
396
396
|
node_modules/.bin/hone record-debt --repo . --base-revision origin/main --leave src/clock.ts --leave src/adapters
|
|
397
397
|
```
|
|
398
398
|
|
|
399
|
-
It prints one line per clause and file. `recorded` lines are records it added to the exception records. `left` lines are files under a `--leave` path: write their `authorised-location` records now, each with its own reason. `new-file` lines are files the base revision does not hold, so nothing in them was inherited: fix them, or record them yourself with a reason of your own. `already-recorded` and `
|
|
399
|
+
It prints one line per clause and file. `recorded` lines are records it added to the exception records. `left` lines are files under a `--leave` path: write their `authorised-location` records now, each with its own reason. `new-file` lines are files the base revision does not hold, so nothing in them was inherited: fix them, or record them yourself with a reason of your own. `already-recorded`, `refused` and `nested-configuration` lines say why nothing was written; [README.md](README.md#recording-inherited-debt) has the details.
|
|
400
400
|
5. **Re-project and check against the same base.** With any `eslint` clause, run `npm run --silent hone:project`. Then run `npm run --silent hone:check -- --forfeiture this-run --base-revision origin/main` (with pnpm, `pnpm run --silent hone:check --forfeiture this-run --base-revision origin/main`). `--forfeiture this-run` makes this run assess decay whatever `assessment.forfeiture` says, as the run that assesses it for your repository does: the pre-push hook with `"forfeiture": "elsewhere"` (step 5), or CI without it. A `forfeited` line names a file this change edits: go back to point 3 for it. A check against `HEAD` hides those lines, because nothing has changed since `HEAD`, and the hook or CI then fails where this run passed. The generated records leave only what point 4 did not record, such as `config-override` or lint-script options under `unrecorded`, which step 6 says how to clear.
|
|
401
401
|
6. **Review the diff.** Nothing takes effect until you commit it. Each generated record says it is inherited debt that nobody has reviewed, and the reviewer of the adopting change reads them as that. Note them in each clause's Debt line in `disciplines.assessment.md`.
|
|
402
402
|
|
|
403
403
|
The records are the same as any other `file-carve-out`: each is forfeited once its file changes, which is how the debt is paid down. A file with no earlier revision gets no record, because it has no debt to inherit. The command is for adoption, but it does not refuse to run again: forfeiture already stops it turning new findings into carve-outs, since a record written for a file just changed is forfeited by the next check that assesses decay. That holds only where decay is assessed. With `"assessment": { "forfeiture": "elsewhere" }` (step 5), it is assessed only by the run that the repository leaves it to, such as the pre-push hook, so a push that bypasses that run lets such a record through until a later run assesses it.
|
|
404
404
|
|
|
405
|
-
Running it again only adds records for pairs that have none; it never removes or rewrites one. A record whose
|
|
405
|
+
Running it again only adds records for pairs that have none; it never removes or rewrites one. A record whose debt is paid is reported `stale`, or `forfeited` with no finding left on its file. `hone prune-debt` removes it when its file no longer exists; otherwise delete it by hand ([README.md](README.md#pruning-paid-debt)).
|
|
406
406
|
|
|
407
407
|
## 8. Prove one failure and correction
|
|
408
408
|
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,44 @@
|
|
|
2
2
|
|
|
3
3
|
Every release of Hone, newest first. `pnpm run release-pull-request` writes each new section from the commits merged to `main` since the previous release tag, whose subjects are the squash-merged pull request titles; README.md's Compatibility section says what each kind of release may change. The sections below were written by hand from the merged pull requests when the changelog started.
|
|
4
4
|
|
|
5
|
+
## 1.4.0
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- a CD-27 test-body-logic finding names the allowed form for what it flagged, and CHECKS.md shows each one, proven against every audit and ESLint clause Hone ships (#171)
|
|
10
|
+
- list paid ESLint debt as stale, and add hone prune-debt to remove the records of deleted files (#191)
|
|
11
|
+
|
|
12
|
+
### Fixes
|
|
13
|
+
|
|
14
|
+
- CD-41 function-length does not measure a test suite's describe body (#170)
|
|
15
|
+
- a CD-27 test-body-logic finding on JSON.stringify or JSON.parse points at CD-19 (#186)
|
|
16
|
+
|
|
17
|
+
### Other changes
|
|
18
|
+
|
|
19
|
+
- Hone's ESLint pieces observe sites through one boundary over ESLint's rule contract (#166)
|
|
20
|
+
- the ESLint runner reads lint messages and source lines through two units of their own (#177)
|
|
21
|
+
- CD-25 names stubs and spies with written-out answers as a unit test's doubles, and reads a double that needs behaviour as a finding (#180)
|
|
22
|
+
- hone check's measurement rules move from run-check into a unit of their own (#179)
|
|
23
|
+
- the ESLint runner reads its repository through readers named for what it asks, and its tests stub them (#181)
|
|
24
|
+
- CD-17, CD-27, CD-12 and the review lenses name a stub where they offered a fake clock or an in-memory fake (#188)
|
|
25
|
+
- hone check takes its selection through a repository, and its orchestration tests pass written-out objects (#183)
|
|
26
|
+
|
|
27
|
+
## 1.3.0
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
- debt records need no reason or why-chain (#147)
|
|
32
|
+
- record-debt skips files the ESLint projection cannot reach (#153)
|
|
33
|
+
|
|
34
|
+
### Fixes
|
|
35
|
+
|
|
36
|
+
- pass over a package.json script whose quotes do not pair, and list one naming eslint as an unreadable command-line-option (#139)
|
|
37
|
+
|
|
38
|
+
### Other changes
|
|
39
|
+
|
|
40
|
+
- keep Hone's own exception records in the split layout (#140)
|
|
41
|
+
- run CD-27 test-body-logic and the CD-3 clauses at edition 2, and record Hone's backlog as debt (#157)
|
|
42
|
+
|
|
5
43
|
## 1.2.0
|
|
6
44
|
|
|
7
45
|
### Features
|
package/MIGRATING.md
CHANGED
|
@@ -103,17 +103,17 @@ Each converted record is imported: give it `provenance` naming the old record in
|
|
|
103
103
|
}
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
`source` is the old file and the entry's position in its array, counting from `0`, so both files in the example above use `.constitution-carve-outs/cd-15.json#0`. An authorised location uses `{ "kind": "existing-authorisation", "source": ".constitution-authorised-locations/cd-<id>.json#<index>" }`. Hone accepts an imported record only while the `--base-revision` holds it unchanged or its `source` entry lists the record's file at that revision, so keep the old record files committed until step 6, and run every check in this migration with `--base-revision HEAD`.
|
|
106
|
+
`source` is the old file and the entry's position in its array, counting from `0`, so both files in the example above use `.constitution-carve-outs/cd-15.json#0`. An authorised location uses `{ "kind": "existing-authorisation", "source": ".constitution-authorised-locations/cd-<id>.json#<index>" }`. Hone accepts an imported record only while the `--base-revision` holds it unchanged or its `source` entry lists the record's file at that revision, so keep the old record files committed until step 6, and run every check in this migration with `--base-revision HEAD`. An imported record you later change needs a full `whyChain` that follows the [why-chain contract](docs/why-chain-contract.md), or, for a `file-carve-out`, no `provenance` at all: Hone refuses it as `import-unverified` otherwise. A `file-carve-out` is debt, so a record you write for new debt needs only its clause and file, with no `whyChain` and no `provenance`; a `reason` is an optional note. An `authorised-location` you write needs a `whyChain`; a repository whose `disciplines.json` sets `"fileExceptionWhyChains": "optional"` may give one only its `reason`, which will be refused in the next major release.
|
|
107
107
|
|
|
108
108
|
An imported `file-carve-out` needs a `decision`: copy the old entry's. If the old entry has none, stop and ask the human who accepted the debt. An imported `authorised-location` needs no `decision`: copy the old entry's if it has one, otherwise give `kind` and `source` only. Never write a placeholder or a root cause that only says the check was failing: Hone refuses those as `invalidRecords`.
|
|
109
109
|
|
|
110
|
-
Once the old records are converted, what is left is debt no old record covers: findings in a folder whose relaxed rule set was not carried over (step 2a), clauses the old route never checked, and inline disables or `@ts-expect-error` directives the old tool accepted ([section 14](#14-moving-to-recorded-inline-exceptions)). When the human approves recording it,
|
|
110
|
+
Once the old records are converted, what is left is debt no old record covers: findings in a folder whose relaxed rule set was not carried over (step 2a), clauses the old route never checked, and inline disables or `@ts-expect-error` directives the old tool accepted ([section 14](#14-moving-to-recorded-inline-exceptions)). When the human approves recording it, run, with one `--leave` for each file the human decided is a permanent exception:
|
|
111
111
|
|
|
112
112
|
```bash
|
|
113
113
|
node_modules/.bin/hone record-debt --repo . --base-revision origin/main --leave <path>
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
Give it the branch's base, `origin/main`, not `HEAD` as this migration's other checks do: after step 6 the pre-push hook and CI assess decay against that base, so a record for a file this branch edits passes a check against `HEAD` and is forfeited there. Finish each file the migration edits, as [ADOPTING.md](ADOPTING.md#7a-record-the-debt-you-inherit) step 7a point 3 says, and confirm with `npm run --silent hone:check -- --forfeiture this-run --base-revision origin/main`, which assesses decay in that run whatever `assessment.forfeiture` says.
|
|
116
|
+
Give it the branch's base, `origin/main`, not `HEAD` as this migration's other checks do: after step 6 the pre-push hook and CI assess decay against that base, so a record for a file this branch edits passes a check against `HEAD` and is forfeited there. Finish each file the migration edits, as [ADOPTING.md](ADOPTING.md#7a-record-the-debt-you-inherit) step 7a point 3 says, and confirm with `npm run --silent hone:check -- --forfeiture this-run --base-revision origin/main`, which assesses decay in that run whatever `assessment.forfeiture` says. Before you run it, put every pre-push hook, CI job and other machine that runs the check on this release or later: the records it writes give no `reason`, and a Hone from before file carve-outs could leave out `reason` stops with `load failure: file-malformed` on them. It adds a `file-carve-out` naming only its clause and file for each clause and file that no converted record holds, and leaves the converted records as they are. A converted record still holds its pair, so the command reports it `already-recorded` only if the check does not accept it; fix that record rather than adding another. [ADOPTING.md](ADOPTING.md#7a-record-the-debt-you-inherit) step 7a says how to read its output and review the result.
|
|
117
117
|
|
|
118
118
|
## 4. Replace the hand-written linter rules
|
|
119
119
|
|
|
@@ -192,7 +192,7 @@ Stop and ask the human if anything outside the old trial uses the copied tools o
|
|
|
192
192
|
| --- | --- | --- |
|
|
193
193
|
| What is installed | rule text only; checks were the repository's own linters, plus an optional copied tools tree | one package that runs every selected check |
|
|
194
194
|
| Selection | whole CD files, read by an agent; a check ran only if wired by hand | clauses in `disciplines.json`; every mechanical clause of an adopted discipline must be selected |
|
|
195
|
-
| First-adoption debt | inherited debt could be recorded without a why-chain | imported with `provenance` and no `whyChain`, accepted only while unchanged since `--base-revision`; new or edited
|
|
195
|
+
| First-adoption debt | inherited debt could be recorded without a why-chain | imported with `provenance` and no `whyChain`, accepted only while unchanged since `--base-revision`; a `file-carve-out` is debt and needs only its clause and file; a new or edited `authorised-location` or `clause-wide-carve-out` needs a causal five-step `whyChain` ([contract](docs/why-chain-contract.md)) |
|
|
196
196
|
| CD-1 | no exemptions | exempted like every other discipline, so existing `any` debt can be recorded |
|
|
197
197
|
| CD-3 flags | merged into the shared `compilerOptions`, wherever they were | set only in a base file not named `tsconfig.json`; any of the seven in a `tsconfig.json` is a finding |
|
|
198
198
|
| Running with debt | the decay check needed a base ref | every run with a file carve-out needs `--base-revision`, unless it sets forfeiture `elsewhere`; every run with imported or legacy-chain records needs it either way |
|
|
@@ -313,7 +313,7 @@ Earlier releases reported an `eslint-disable` comment naming a selected rule as
|
|
|
313
313
|
|
|
314
314
|
1. **Refresh Hone** as [ADOPTING.md](ADOPTING.md#10-update-and-remove) step 10 says, and run the check. Each `@ts-expect-error`, `@ts-ignore` and `@ts-nocheck` in a `.ts` or `.tsx` file is listed under `unrecorded` as `CD-2#cast-expressions audit inline-disable <file>:<line> <comment>`, test files included, and each `eslint-disable` as before.
|
|
315
315
|
2. **Remove what you can.** A directive or disable that hides nothing is cheaper to delete than to record.
|
|
316
|
-
3. **Record the rest per clause and file.** Add a `file-carve-out` for debt, or an `authorised-location` where the clause truly does not apply to that file, on the clause the line names and that file.
|
|
316
|
+
3. **Record the rest per clause and file.** Add a `file-carve-out` for debt, or an `authorised-location` where the clause truly does not apply to that file, on the clause the line names and that file. `hone record-debt` writes the debt records ([ADOPTING.md](ADOPTING.md#7a-record-the-debt-you-inherit) step 7a). One record holds every inline exception of that clause in the file. A `clause-wide-carve-out` does not hold them, and a tracked reference on the comment (CD-5) does not stand in for the record. Editing a carved file forfeits the carve-out, and each inline exception it held is listed again.
|
|
317
317
|
4. **Name the rule in a bare disable.** An `eslint-disable` naming no rule escapes every selected ESLint clause and needs a record for each. Its lines end `names no rule and escapes every selected clause: naming the rule is the cheap fix`.
|
|
318
318
|
5. **Fix lint-script options.** A `command-line-option` line that ends `weakens the script's whole run, so no record can cover it: remove it from the script` names an option to remove. One that ends `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>"` names a script such as `tsc && eslint -c eslint.config.mjs .`: move the quoted command to a script of its own, then run the check again. One that ends `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>` quotes the first token Hone does not read, such as `env` or a runner flag like `-y`: rewrite the command so only package runners and `NAME=value` settings, including `cross-env NAME=value`, come before `eslint`. `-c` naming the config ESLint already finds, and `--ignore-pattern` that ignores no checked file, are not reported once `eslint` runs plainly.
|
|
319
319
|
6. **Stale records may clear.** A record that holds a native exception it can cover now counts as used. An `authorised-location` or `file-carve-out` that held only a `config-override`, and was listed `stale` while dropping it left the override unrecorded, is no longer stale.
|
|
@@ -351,3 +351,26 @@ Neither `"not-run"` nor `"not-adopted"` takes an exception record. Stop and ask
|
|
|
351
351
|
4. **Commit the removal and the new files in one change.** A tree that holds both `discipline-exceptions.json` and the folder fails every run with `records-in-both-layouts`. Point any code owners or review rules at the new files, such as `discipline-exceptions/file-carve-outs/cd-19.json`.
|
|
352
352
|
|
|
353
353
|
From then on, `hone record-debt` adds each record to its discipline's file, and a record a person writes goes in the file of its kind and discipline: one in any other file fails the load as `file-malformed`, naming the file it belongs in.
|
|
354
|
+
|
|
355
|
+
## 17. Pruning paid ESLint debt
|
|
356
|
+
|
|
357
|
+
Earlier releases never listed an `eslint` file record as `stale`. The off-switch `hone project` writes for a record counted as a `config-override` that the record held, so a record kept its rule off after its file stopped breaking the clause, and a new violation there went unreported. A forfeited `eslint` record's off-switch was also listed under `unrecorded` as a `config-override`. The check no longer counts the projection's own off-switches as native exceptions, and the new `hone prune-debt` removes the records of files that no longer exist.
|
|
358
|
+
|
|
359
|
+
1. **Refresh Hone** as [ADOPTING.md](ADOPTING.md#10-update-and-remove) step 10 says, and run the check against the branch's base. If none of your `eslint` debt is paid, nothing changes.
|
|
360
|
+
2. **If some is, the run fails.** Each paid record is listed under `stale` as `<clause> eslint file-carve-out <file>`.
|
|
361
|
+
3. **Delete each of those records by hand** when its file still exists, then run `npm run --silent hone:project`, which prints `disciplines.eslint.mjs written`. A stale `authorised-location` or `clause-wide-carve-out` is left for a person in the same way.
|
|
362
|
+
4. **Run `hone prune-debt` for records whose file is gone.** When a stale or forfeited record names a file that no longer exists, the report ends with one `readFirst` line naming the command to run, such as:
|
|
363
|
+
|
|
364
|
+
```text
|
|
365
|
+
prune-debt: 3 file carve-outs under stale or forfeited still record debt that is paid; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js prune-debt --repo /work/shop --base-revision origin/main to remove what is paid, then run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit the exception records with every disciplines.eslint.mjs it writes
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
From the repository root that is:
|
|
369
|
+
|
|
370
|
+
```bash
|
|
371
|
+
node_modules/.bin/hone prune-debt --repo . --base-revision origin/main
|
|
372
|
+
npm run --silent hone:project
|
|
373
|
+
```
|
|
374
|
+
|
|
375
|
+
`hone prune-debt` prints `<clause> removed <file>` for each record it removed. Commit the exception records and `disciplines.eslint.mjs`, and each package slice `hone project` writes. The check passes.
|
|
376
|
+
5. **Look for a team override that surfaces.** An off-switch your own config places after the projection, for a rule and file a removed record held, was hidden behind the record. It is now listed under `unrecorded` as a `config-override`; [ADOPTING.md](ADOPTING.md#6-read-the-report) step 6 says what to do with it.
|
package/README.md
CHANGED
|
@@ -25,24 +25,25 @@ A team adds its own disciplines as a rule set in its own repository, with ESLint
|
|
|
25
25
|
|
|
26
26
|
## Commands
|
|
27
27
|
|
|
28
|
-
The package ships one command, `hone`, with
|
|
28
|
+
The package ships one command, `hone`, with five subcommands. `check` and `project` run through a `package.json` script as [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) shows; `record-debt` runs once, when a repository adopts Hone; `prune-debt` runs when the check names it, to remove the records of files that no longer exist; `split-records` runs once, when a repository moves its records to [the split layout](#the-split-layout):
|
|
29
29
|
|
|
30
30
|
```text
|
|
31
31
|
hone check --repo <dir> [--base-revision <revision>] [--report-output <full|failures-only|counts|verdict-only>] [--forfeiture <this-run|elsewhere>]
|
|
32
32
|
hone project --repo <dir>
|
|
33
33
|
hone record-debt --repo <dir> --base-revision <revision> [--leave <path>]...
|
|
34
|
+
hone prune-debt --repo <dir> [--base-revision <revision>] [--forfeiture <this-run|elsewhere>]
|
|
34
35
|
hone split-records --repo <dir>
|
|
35
36
|
hone --help
|
|
36
37
|
hone --version
|
|
37
38
|
```
|
|
38
39
|
|
|
39
|
-
`--repo` is the folder that holds `disciplines.json`, usually the repository root. `hone --help` lists the commands, `hone check --help`, `hone project --help`, `hone record-debt --help` and `hone split-records --help` list each one's options and exit codes, and `hone --version` prints the installed version. A command typed wrongly is a load failure `arguments-invalid` that says what was wrong, a `--repo` folder with no `disciplines.json` is the load failure `selection-absent`, and an error Hone did not expect is the load failure `unexpected-error`; each exits `2`. Everything Hone prints goes to standard output, so exit `1` always comes with `verdict: fail`. From a source checkout the same command is `node core/check/tool-command.ts check --repo <dir>`.
|
|
40
|
+
`--repo` is the folder that holds `disciplines.json`, usually the repository root. `hone --help` lists the commands, `hone check --help`, `hone project --help`, `hone record-debt --help`, `hone prune-debt --help` and `hone split-records --help` list each one's options and exit codes, and `hone --version` prints the installed version. A command typed wrongly is a load failure `arguments-invalid` that says what was wrong, a `--repo` folder with no `disciplines.json` is the load failure `selection-absent`, and an error Hone did not expect is the load failure `unexpected-error`; each exits `2`. Everything Hone prints goes to standard output, so exit `1` always comes with `verdict: fail`. From a source checkout the same command is `node core/check/tool-command.ts check --repo <dir>`.
|
|
40
41
|
|
|
41
42
|
[docs/output-contract.md](docs/output-contract.md) lists every line `hone` prints, exactly as it prints it, with the exit codes and which parts are stable for hooks, CI and agents to rely on. A test renders every kind of line and checks it against that page, both ways.
|
|
42
43
|
|
|
43
|
-
`hone check` loads the repository's selection, exceptions, rule sets and pieces; works out which files changed since `--base-revision`; runs each selected mechanism once over the repository's tracked `.ts`, `.tsx`, `.mts` and `.cts` files; applies the exceptions; and prints a plain-text report ending in `verdict: pass` or `verdict: fail`, followed by ` (partial assessment)` when the run left part of the assessment to another run. It exits `0` when the verdict is `pass`, `1` when it is `fail`, and `2` on a load failure, which prints one line, `load failure: <kind> <fields>`. `hone project`, `hone record-debt` and `hone split-records` exit `0` or `2`.
|
|
44
|
+
`hone check` loads the repository's selection, exceptions, rule sets and pieces; works out which files changed since `--base-revision`; runs each selected mechanism once over the repository's tracked `.ts`, `.tsx`, `.mts` and `.cts` files; applies the exceptions; and prints a plain-text report ending in `verdict: pass` or `verdict: fail`, followed by ` (partial assessment)` when the run left part of the assessment to another run. It exits `0` when the verdict is `pass`, `1` when it is `fail`, and `2` on a load failure, which prints one line, `load failure: <kind> <fields>`. `hone project`, `hone record-debt`, `hone prune-debt` and `hone split-records` exit `0` or `2`.
|
|
44
45
|
|
|
45
|
-
The report lists the excluded paths, the clauses not adopted, the clauses adopted with their mechanism not run, the edition each clause with more than one edition ran, findings, exempted findings, uncovered clauses, stale, forfeited, unrecorded and doubly-held exceptions, invalid exception records, unmeasured checks, projection problems, any part of the assessment left to another run and, last, where to read first for each clause with findings, each with its count. The verdict is `pass` only when every list except the excluded paths, clauses not adopted, clauses not run, editions, exempted findings, assessment and where to read first is empty.
|
|
46
|
+
The report lists the excluded paths, the clauses not adopted, the clauses adopted with their mechanism not run, the edition each clause with more than one edition ran, findings, exempted findings, uncovered clauses, stale, forfeited, unrecorded and doubly-held exceptions, invalid exception records, unmeasured checks, projection problems, any part of the assessment left to another run and, last, where to read first for each clause with findings and the command that removes the records of files that no longer exist, each with its count. The verdict is `pass` only when every list except the excluded paths, clauses not adopted, clauses not run, editions, exempted findings, assessment and where to read first is empty.
|
|
46
47
|
|
|
47
48
|
An `unrecorded` line is `<clause> <mechanism> <kind> <detail>`. Two kinds end with a note:
|
|
48
49
|
|
|
@@ -52,12 +53,13 @@ An `unrecorded` line is `<clause> <mechanism> <kind> <detail>`. Two kinds end wi
|
|
|
52
53
|
| `command-line-option` that weakens the run | `<clause> eslint command-line-option <package.json> <script> <option> weakens the script's whole run, so no record can cover it: remove it from the script` |
|
|
53
54
|
| `command-line-option` Hone cannot judge, because another command comes before `eslint` in its script | `<clause> eslint command-line-option <package.json> <script> <option>: <command> is not the first command of its script, so Hone cannot tell what the option does to the files under check; give <command> a script of its own, such as "<invocation>"` |
|
|
54
55
|
| `command-line-option` Hone cannot judge, because something before `eslint` in its own command is not a package runner or a `NAME=value` setting | `<clause> eslint command-line-option <package.json> <script> <option>: "<wrapper>" comes before <command> and is neither a package runner nor a NAME=value setting, so Hone cannot tell what the option does to the files under check; put only package runners and NAME=value settings before <command>` |
|
|
56
|
+
| `command-line-option` Hone cannot judge, because a quote in a script naming `eslint` has no partner; the whole script stands in for the option | `<clause> eslint command-line-option <package.json> <script> <script text>: a quote in the script has no partner, so Hone cannot read what the script passes to <command> or tell what that does to the files under check; pair every quote in the script` |
|
|
55
57
|
|
|
56
58
|
`<command>` is the `eslint` call as the script writes it, `<invocation>` is its whole command with its settings and options, from the same script, and `<wrapper>` is the first token before it that Hone does not read, such as `env` or a runner flag like `-y` or `-C`. `cross-env` followed only by `NAME=value` settings counts as a setting. Once only package runners and settings come first, Hone judges the option: `-c` naming the config ESLint already finds, and `--ignore-pattern` that ignores no checked file, are then not reported.
|
|
57
59
|
|
|
58
60
|
`readFirst` comes last, just before the verdict, so a reader who looks only at the end of a failing report lands on it. It has one line per clause with findings, not one per finding, in the order the findings first name the clauses. Each line points at the Spirit section of the clause's rule page, `rules/<ID>/README.md` in the clause's rule set, and, where the repository has written one, at the clause's own section in `disciplines.assessment.md` at the repository root first. That file is where a repository records its own causes, forward goal and steps for a clause; [ADOPTING step 5a](ADOPTING.md#5a-write-the-assessment) says how to write it. Paths are printed with forward slashes, relative to the `--repo` folder; a page on another drive is printed as its absolute path.
|
|
59
61
|
|
|
60
|
-
When `disciplines.assessment.md` is not written yet, or cannot be read, one note line comes first and says so, naming ADOPTING step 5a; each clause line then names its rule page only. The note counts as an entry, so a report with two failing clauses and no assessment file prints `readFirst (3)`. A clause line names the clause's section when the file has one, and says `disciplines.assessment.md does not assess this clause` when the file is there without it. [The output contract](docs/output-contract.md#report-lines) lists every `readFirst` line exactly.
|
|
62
|
+
When `disciplines.assessment.md` is not written yet, or cannot be read, one note line comes first and says so, naming ADOPTING step 5a; each clause line then names its rule page only. The note counts as an entry, so a report with two failing clauses and no assessment file prints `readFirst (3)`. A clause line names the clause's section when the file has one, and says `disciplines.assessment.md does not assess this clause` when the file is there without it. When the check finds a `stale` or `forfeited` `file-carve-out` on a file that no longer exists, one more line comes last and names the exact `hone prune-debt` command for this repository, as [Pruning paid debt](#pruning-paid-debt) shows. [The output contract](docs/output-contract.md#report-lines) lists every `readFirst` line exactly.
|
|
61
63
|
|
|
62
64
|
A file that does not assess a clause is normal: the assessment covers the clauses the repository chose to describe, and the rule page's Spirit is the read for the rest.
|
|
63
65
|
|
|
@@ -99,23 +101,46 @@ The `assessment` section is informational and the marker does not change the exi
|
|
|
99
101
|
|
|
100
102
|
### Recording inherited debt
|
|
101
103
|
|
|
102
|
-
`hone record-debt` gives a repository that adopts Hone with existing code a file record for each debt it cannot fix on day one. [ADOPTING.md](ADOPTING.md#7a-record-the-debt-you-inherit) step 7a is the procedure. The command runs the check with the `--base-revision` it is given, then adds one `file-carve-out` to the exception records, `discipline-exceptions.json` or the discipline's file in [the split layout](#the-split-layout), for each clause and file that has a finding, or an inline disable or TypeScript directive under `unrecorded`. Each is the record a person would write, so nothing downstream treats it differently
|
|
104
|
+
`hone record-debt` gives a repository that adopts Hone with existing code a file record for each debt it cannot fix on day one. [ADOPTING.md](ADOPTING.md#7a-record-the-debt-you-inherit) step 7a is the procedure. The command runs the check with the `--base-revision` it is given, then adds one `file-carve-out` to the exception records, `discipline-exceptions.json` or the discipline's file in [the split layout](#the-split-layout), for each clause and file that has a finding, or an inline disable or TypeScript directive under `unrecorded`. Each is the record a person would write, so nothing downstream treats it differently: it names only its `kind`, `clause` and `file`. A file carve-out is debt and needs no `reason` and no `whyChain`, so the command needs no setting in `disciplines.json` and never sets one. Add a `reason` by hand afterwards if you want to leave a note for future developers on what the debt signals.
|
|
103
105
|
|
|
104
106
|
Give it the base that the run assessing decay is given, such as `origin/main` for a branch: a record for a file changed since that base is forfeited by that run, and a check against a later revision, such as `HEAD`, does not show it.
|
|
105
107
|
|
|
108
|
+
The records it writes give no `reason`. A Hone from before file carve-outs could leave out `reason` refuses such a record: the whole check stops with `load failure: file-malformed <records file> … at exceptions[<index>].reason` and exits `2`. So before the command writes any record, update the Hone that every pre-push hook, CI job and other machine runs to this release or later, as [ADOPTING.md](ADOPTING.md#10-update-and-remove) step 10 says, or that check stops.
|
|
109
|
+
|
|
106
110
|
It never writes anything wider than one clause in one file: no `authorised-location`, no `clause-wide-carve-out`, no `exclude` entry and no setting. It prints one line per clause and file, `recorded` for each record it added, and writes nothing for:
|
|
107
111
|
|
|
108
112
|
- a pair that already has an `authorised-location` or `file-carve-out`, such as one the check forfeits (`already-recorded`);
|
|
109
113
|
- a file under a `--leave` path (`left`). `--leave` takes an exact file or folder, as `exclude` does, and may be given once for each path. It names the deliberate, permanent exceptions, which a person records as an `authorised-location` with its own reason;
|
|
110
114
|
- a file the base revision does not hold, since nothing in it was inherited (`new-file`);
|
|
111
|
-
- a clause whose discipline refuses exceptions (`refused`)
|
|
115
|
+
- a clause whose discipline refuses exceptions (`refused`);
|
|
116
|
+
- a file that loads its own ESLint config inside a folder holding its own `disciplines.json` (`nested-configuration`). The projection never reaches that config, so the record could not take effect and the next check would fail on it. Nested Hone configurations are not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)).
|
|
112
117
|
|
|
113
118
|
Other native exceptions under `unrecorded`, such as a `config-override` or a lint-script option, are not recorded: [ADOPTING.md](ADOPTING.md#6-read-the-report) step 6 says what to do with each.
|
|
114
119
|
|
|
115
|
-
It adds the new entries after the last one and leaves every entry already in the file as written. It stages and commits nothing: the diff of the exception records is the review, and nothing takes effect until a person commits it. It never removes or rewrites a record, so running it again adds records only for pairs that still have none. A record
|
|
120
|
+
It adds the new entries after the last one and leaves every entry already in the file as written. It stages and commits nothing: the diff of the exception records is the review, and nothing takes effect until a person commits it. It never removes or rewrites a record, so running it again adds records only for pairs that still have none. A record on a file that no longer exists is removed by `hone prune-debt`, below. Run `hone project` after it when any clause is `eslint`, so the projection carries the new records.
|
|
116
121
|
|
|
117
122
|
The command does not refuse to run again later, and has no flag for it. Forfeiture is what stops it turning new findings into carve-outs: a file carve-out is forfeited once its file changes since `--base-revision`, so a record written for a file someone has just changed fails the next check that assesses forfeiture, and a file that is new since the base gets no record at all. That holds only where forfeiture is assessed. In an arrangement that leaves it elsewhere, such as `"assessment": { "forfeiture": "elsewhere" }` with the pre-push hook that assesses it bypassed, such a record is not caught until a run that does assess it.
|
|
118
123
|
|
|
124
|
+
### Pruning paid debt
|
|
125
|
+
|
|
126
|
+
A `file-carve-out` is debt, and once the debt is paid the record should go. `hone prune-debt` removes the records whose file no longer exists: each `file-carve-out` under `stale` or `forfeited` whose file is gone from the repository, unless the report still lists a finding or a native exception on its clause and file.
|
|
127
|
+
|
|
128
|
+
Every other record stays for a person:
|
|
129
|
+
|
|
130
|
+
- **A `stale` `file-carve-out` on a file that still exists:** the command does not remove it. Delete it by hand, then run `hone project` when its clause is `eslint`.
|
|
131
|
+
- **A `forfeited` record on a file that still exists:** fix the file and delete the record, as for any forfeited record. While the file still breaks its clause, the record keeps failing the run.
|
|
132
|
+
- **An `authorised-location` or `clause-wide-carve-out` under `stale`:** it carries a person's judgement, so delete it by hand.
|
|
133
|
+
|
|
134
|
+
The command runs the check with the `--base-revision` and `--forfeiture` it is given, so give it what the check was given. A check that finds a `file-carve-out` on a file that no longer exists names the command exactly in its last `readFirst` line, just above the verdict, with `hone project` after it when any of the records is for an `eslint` clause:
|
|
135
|
+
|
|
136
|
+
```text
|
|
137
|
+
prune-debt: 3 file carve-outs under stale or forfeited still record debt that is paid; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js prune-debt --repo /work/shop --base-revision origin/main to remove what is paid, then run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit the exception records with every disciplines.eslint.mjs it writes
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
It prints `<clause> removed <file>` for each record it removed, ordered by file and then by clause, and nothing when it removed none. Like `hone record-debt`, it writes the exception records in whichever layout the repository keeps them, keeps every other record's text byte for byte, stages and commits nothing, and does not write the projection: run `hone project` after it when any clause is `eslint`, so the projection drops the records' off-switches. When it removes the last record from a file, it follows the layout: in [the split layout](#the-split-layout) it deletes that rule's file, as `hone split-records` writes a file only for a rule that holds records; a single `discipline-exceptions.json` is left holding an empty list. It has no dry run, as no other Hone command has: the `stale` and `forfeited` lines naming a file that no longer exists name what it removes, and the diff of the records is the review.
|
|
141
|
+
|
|
142
|
+
For an `eslint` clause, the off-switch the projection writes for a record is Hone's own. The check does not list it as a `config-override`, so it never counts as a native exception the record holds, and a record whose file no longer breaks its clause is `stale` like any other. A `config-override` on a clause and file no record holds is reported as before. While a record holds a file, the team's own off-switch for that rule and file cannot be told from the projection's, and the record holds the file either way. Once the record is removed, a team off-switch placed after the projection is listed under `unrecorded` as a `config-override`, and one placed before it never takes effect, since the projection turns the rule on after it, so ESLint and the check both flag the file. A team block placed after the projection that sets a recorded file's rule to `"warn"` or `"error"` leaves the projection out of effect, and the check says `not-included`, as before.
|
|
143
|
+
|
|
119
144
|
## Adopting the ESLint mechanism
|
|
120
145
|
|
|
121
146
|
With any clause selected for `eslint`, run `hone project`. It writes `disciplines.eslint.mjs` at the repository root: one block per piece enabling its selected rules at `"error"` on `**/*.{ts,tsx,mts,cts}`, then one block per set of clauses that files are excepted from, listing those files and turning the rules `"off"` for them, and one block per clause-wide carve-out turning its rules `"off"` everywhere. Commit it, and spread its default export last in the repository's flat config:
|
|
@@ -197,7 +222,7 @@ At the repository root. It selects clauses and the mechanism that checks each on
|
|
|
197
222
|
- A judgement clause cannot be selected; it is enforced by review.
|
|
198
223
|
- `eslintConfigLookup`, optional, is `"nearest-to-file"` or `"repository-root"` and says which `eslint.config.*` the team's own ESLint run applies to a file; see [Runtime](#runtime). Leave it out to let Hone detect it.
|
|
199
224
|
- `eslintConfigRoots`, optional, lists repository folders that get their own projection slice under either lookup although they track no `eslint.config.*`, such as a package whose config a tool generates and ignores; see [Package slices](#package-slices). Globs are refused. Each entry must be a folder git tracks files under outside every `exclude` path, spelled exactly as git spells it; any other entry stops the run before anything is checked or written, as `load failure: config-root-untracked <folder>:` with what to fix.
|
|
200
|
-
- `fileExceptionWhyChains`, optional, is `"required"` (the default) or `"optional"`. `"optional"` lets an `authorised-location`
|
|
225
|
+
- `fileExceptionWhyChains`, optional, is `"required"` (the default) or `"optional"`. It governs authorised locations only: `"optional"` lets an `authorised-location` entry give only its `reason`, which will be refused in the next major release; see [discipline-exceptions.json](#discipline-exceptionsjson). A `file-carve-out` needs no `whyChain` under either value.
|
|
201
226
|
- `reportOutput`, optional, is `"full"` (the default), `"failures-only"`, `"counts"` or `"verdict-only"`: the repository's default for how much of the report the check prints. `--report-output` overrides it for one run; see [Commands](#commands).
|
|
202
227
|
- `checkEditions`, optional, is `"pinned"` (the default) or `"latest"`. A clause whose check has been tightened has more than one edition, listed on its CHECKS.md. `"pinned"` runs each clause's default edition, which changes only in a major release; `"latest"` runs the newest edition the installed Hone has for every selected clause, so a minor release can add findings. `"edition"` in a clause's `clauseSettings` holds that one clause to the edition it names over either. The report lists the edition each such clause ran under `editions`.
|
|
203
228
|
- `clauseSettings`, optional, maps a selected clause address to an object of that clause's settings, for a clause whose CHECKS.md lists settings. Each key must be one the clause's piece declares, and its value must be the same JSON kind as the declared default and, where the piece lists choices, one of them; the value replaces the default. Anything else makes `disciplines.json` malformed, naming the clause, the key and what is accepted: settings for a clause the file does not select or names twice, for a clause that takes none, under an undeclared key, or of the wrong kind or choice.
|
|
@@ -213,7 +238,7 @@ At the repository root, or split by rule into the `discipline-exceptions` folder
|
|
|
213
238
|
"version": 1,
|
|
214
239
|
"exceptions": [
|
|
215
240
|
{ "kind": "authorised-location", "clause": "CD-14#class-syntax", "file": "src/adapter.ts", "reason": "..." },
|
|
216
|
-
{ "kind": "file-carve-out", "clause": "CD-14#class-syntax", "file": "src/legacy.ts", "reason": "..."
|
|
241
|
+
{ "kind": "file-carve-out", "clause": "CD-14#class-syntax", "file": "src/legacy.ts", "reason": "..." },
|
|
217
242
|
{ "kind": "clause-wide-carve-out", "clause": "CD-14#class-syntax", "reason": "...", "whyChain": { } }
|
|
218
243
|
]
|
|
219
244
|
}
|
|
@@ -223,7 +248,7 @@ At the repository root, or split by rule into the `discipline-exceptions` folder
|
|
|
223
248
|
- A `file-carve-out` is debt in one file. It is forfeited once the file is touched.
|
|
224
249
|
- A `clause-wide-carve-out` exempts the clause's findings everywhere. It does not hold an inline exception.
|
|
225
250
|
- An inline exception, an `eslint-disable` comment naming a selected rule or no rule, or a `@ts-expect-error`, `@ts-ignore` or `@ts-nocheck` directive under `CD-2#cast-expressions`, is held only by an `authorised-location` or `file-carve-out` on its clause and file. A comment naming no rule escapes every selected ESLint clause and needs one per clause. Without a record it is listed under `unrecorded` and fails the run. A lint-script option that weakens the whole run, such as `--rule`, `--suppress-all` or `-c` naming another config, cannot be recorded.
|
|
226
|
-
- Every entry needs a `whyChain` (an `authorised-location`
|
|
251
|
+
- A `file-carve-out` is debt: it needs only its `kind`, `clause` and `file`, never a `whyChain`, under either `fileExceptionWhyChains` value. Its `reason` is optional, a note to future developers on what the debt signals, and nothing reads it. Forfeiture is what holds it: it is forfeited once its file is touched. Every other entry needs a `whyChain` (an `authorised-location` may leave it out while `fileExceptionWhyChains` is `"optional"`; see below) that follows the [why-chain contract](docs/why-chain-contract.md): exactly five `{ "why", "because", "evidence" }` steps chained cause to cause, then `rootCause`, `rootCheck`, `readback` and `owner`. The contract lists what Hone refuses and what review still judges:
|
|
227
252
|
|
|
228
253
|
```json
|
|
229
254
|
"whyChain": {
|
|
@@ -242,7 +267,8 @@ At the repository root, or split by rule into the `discipline-exceptions` folder
|
|
|
242
267
|
```
|
|
243
268
|
- A chain with neither `rootCheck` nor `readback` was written to the earlier contract. It is accepted only while the `--base-revision` holds its entry unchanged; a new or edited one is refused as `why-chain-refused`, and a run with such a chain and no `--base-revision` is `legacy-chain-unmeasured`.
|
|
244
269
|
- An entry carried over from an earlier system may give `provenance` instead of a `whyChain`: `{ "kind": "inherited-debt", "source", "decision" }` on a file carve-out, `{ "kind": "existing-authorisation", "source" }` on an authorised location, where `decision` is optional. `source` names the old record entry as `<directory>/cd-<id>.json#<index>`: `.constitution-carve-outs` for inherited debt, `.constitution-authorised-locations` for an existing authorisation, the old file for the record's discipline, and the entry's position in its array. Such an entry is imported, and is accepted only while the `--base-revision` already holds it unchanged, or, when the base holds no record for that kind, clause and file, while the `source` entry at that revision lists the file in its `files`. A new or edited entry without a `whyChain` is refused as `import-unverified`, and a run with imported entries and no `--base-revision` is `import-unmeasured`. The report names each imported entry it exempts by.
|
|
245
|
-
-
|
|
270
|
+
- A `file-carve-out` without a `whyChain` or `provenance` is not checked against `--base-revision`, but a run with any file carve-out still needs `--base-revision`: without it the report lists `forfeiture-unmeasured` and the run fails, and with it a file carve-out is forfeited once its file is touched. A `whyChain` or `provenance` a file carve-out gives anyway is still judged as above.
|
|
271
|
+
- With `"fileExceptionWhyChains": "optional"` in `disciplines.json`, an `authorised-location` entry may give only its `reason`, which then carries why the exception exists and must not be blank. This is deprecated: a reason-only `authorised-location` will be refused in the next major release, so give it a `whyChain`. A `whyChain` or `provenance` the entry gives anyway is still judged as above. A `clause-wide-carve-out` still needs its `whyChain`.
|
|
246
272
|
- A clause whose `discipline.json` declares `"exceptions": "refused"` cannot be exempted. No shipped discipline declares it, so every shipped clause can be.
|
|
247
273
|
- Files are exact repository paths, never globs.
|
|
248
274
|
- An entry that exempts nothing is stale, a file both authorised and carved for one clause is doubly held, and an entry that cannot be parsed is invalid. Each fails the run.
|
|
@@ -338,6 +364,7 @@ This is the first release. Its tests cover each supported platform's ordinary pa
|
|
|
338
364
|
- `.d.mts` and `.d.cts` declaration files are not handled separately from other sources.
|
|
339
365
|
- Columns reported on lines holding non-ASCII text.
|
|
340
366
|
- Lint scripts are read with a simple shell tokenizer, so unusual quoting or a `cd` before `eslint` is not interpreted.
|
|
367
|
+
- A script whose quotes do not pair as `sh` reads them, such as `echo don't stop`, is passed over when nothing in it names `eslint`. One that names `eslint` is listed as an unreadable `command-line-option` on every selected ESLint clause, since Hone cannot tell what it passes to ESLint.
|
|
341
368
|
- Detection reads an ESLint 9 run started from inside a package, or given the lookup flag through the environment or a task runner, as a root-only run; set `eslintConfigLookup` in `disciplines.json` for those repositories.
|
|
342
369
|
- Team ESLint configs that imitate projection block names, register a second copy of the plugin, or use processors are not exercised.
|
|
343
370
|
- A byte-order mark at the start of `disciplines.json`, `discipline-exceptions.json` or a file of the split layout; save them without one.
|
|
@@ -355,14 +382,14 @@ This repository is self-contained: it holds its own configuration and its own lo
|
|
|
355
382
|
| `build-package` | `node scripts/build-package.ts`: compiles Hone's own code with esbuild into `dist/`, leaving each declared peer and dependency to be imported by name, and adds the published `package.json`, which declares the dependencies at the ranges `package.json` declares, and the shipped documents and data. It fails if a dependency is not declared as a caret range of one release, if that range's floor is not the version the lock's root importer holds, or if the lock does not hold it, if an output imports anything but a `node:` builtin, a declared peer or a declared dependency, if an output carries an installed package's code, if a command or runner is not emitted at its own path with its own code, or if a shipped page links to a file the package does not ship. The tool's name, package name, command name, shipped rule-set name, reserved ESLint namespace, description, GitHub repository and the unrelated npm name to warn against live in `core/values/tool-identity.ts`, which the build, the install proof, the release text, the command's usage line and the ESLint runner all read. The reserved namespace is its own field, independent of the package name |
|
|
356
383
|
| `pack-package` | `node scripts/pack-package.ts`: builds `dist/` and packs it with `npm pack` into `artefacts/hailstails-hone-<version>.tgz`, named by the `version` in `package.json` |
|
|
357
384
|
| `package-determinism` | `node scripts/check-package-determinism.ts`: builds and packs twice into separate temporary roots and fails naming any file that differs, or when the two packed tarballs differ |
|
|
358
|
-
| `self-check` | `node scripts/self-check.ts check --repo .`: runs Hone's own check on this repository with `disciplines.json` and `discipline-exceptions
|
|
385
|
+
| `self-check` | `node scripts/self-check.ts check --repo .`: runs Hone's own check on this repository with `disciplines.json` and the exception records in its `discipline-exceptions` folder; pass `--base-revision <rev>` after the script name. See [Core's check on itself](#hones-check-on-itself) |
|
|
359
386
|
| `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball, or, given `--tarball <path>` after the script name, copies that already packed tarball there instead, and installs it with pnpm into six CommonJS consumers in an OS temporary directory outside the working tree, each copied from its folder under `tests/test-fixtures/consumer-proof/`, which holds only what that consumer's action needs. Each consumer exists for one thing only an installed package shows. The audit consumer, on TypeScript 4.8.4, runs `check` through the installed bin and expects its finding. The ESLint 9.28.0 and 10.0.0 consumers run `project`, expect a projection importing the piece by package name, and expect its finding from `check`. The consumer without `eslint` expects `toolchain-unavailable`. These four run with type stripping off. The team consumer is the example [docs/extending.md](docs/extending.md) follows. On TypeScript 4.8.4 it type-checks a wrong team piece, rule set and ESLint piece settings with its own `tsc`, as described under Public type entries, and expects the three errors. On the development versions, TypeScript 6.0.3, ESLint 10.11.0 and typescript-eslint 8.71.2, it also type-checks its rule set under `nodenext` and `bundler` and a CommonJS file, then runs both commands with type stripping on: its `.ts` pieces load through the installed package and give one finding from each mechanism under the team's `acme/` prefix. Its root says `"type": "commonjs"`, the hard case, so its rule set carries its own `"type": "module"` `package.json`. Each consumer declares its toolchain at exact pins in its own `devDependencies`, as an adopter does: TypeScript 4.8.4 alone for the audit consumer, the consumer without `eslint` and the team consumer on 4.8.4; ESLint 9.28.0 or 10.0.0 with typescript-eslint 8.56.0 and TypeScript 4.8.4 for the two ESLint consumers; and the development versions for the team consumer. It declares the tarball beside them, pins the pnpm version this repository's `package.json` pins, and waits this repository's `minimumReleaseAge`. pnpm's store shares each toolchain package between consumers. The proof prints where pnpm put the installed package, checks that each of Hone's dependencies is installed beside it at a release inside its published range, and expects the report to name its pages through the consumer's `node_modules/@hailstails/hone` instead, and it runs `check` through the package script with its options after `--`, as an adopter's pre-push hook does. A pass once a violation is removed, rule-set naming, plugin namespaces, settings overrides and per-package ESLint configs are proven by unit and in-process tests instead. The temporary directory is removed afterwards |
|
|
360
387
|
| `pull-request-title` | `node scripts/pull-request-title-command.ts <title>`: passes a title shaped as a Conventional Commits subject, `type(scope)!: description`, and fails any other with the expected form. See [Versions and releases](#versions-and-releases) |
|
|
361
388
|
| `release-pull-request` | `node scripts/release-pull-request-command.ts [pre-release\|stable]`: writes the next release's section into `CHANGELOG.md` and its version into `package.json`, in the working tree only. See [Versions and releases](#versions-and-releases) |
|
|
362
389
|
|
|
363
390
|
### Hone's check on itself
|
|
364
391
|
|
|
365
|
-
`disciplines.json` selects every mechanical clause Hone ships, through the mechanism it names, confines the `eslint` package under CD-19's `confinedPackages`, and excludes `tests/test-fixtures/consumer-proof`: those folders are package-test content, the files of other repositories that `install-proof` copies out and checks with their own Hone run. `eslint.config.mjs` spreads the committed `disciplines.eslint.mjs` projection, which `node scripts/self-check.ts project --repo .` regenerates. `discipline-exceptions.json` holds eight `authorised-location` records for `CD-19#import-boundaries`, each the single file that binds a runtime or third-party surface; seven are imported, with `existing-authorisation` provenance, from the earlier records kept in `.constitution-authorised-locations/cd-19.json`, and the eighth, for `mechanisms/eslint/runner/native-rules.ts`, carries its own why-chain. Strictness lives in `tsconfig.base.json`, which `tsconfig.json` extends; `tsconfig.json` leaves the same consumer folders out, since their files compile against the installed package.
|
|
392
|
+
`disciplines.json` selects every mechanical clause Hone ships, through the mechanism it names, confines the `eslint` package under CD-19's `confinedPackages`, and excludes `tests/test-fixtures/consumer-proof`: those folders are package-test content, the files of other repositories that `install-proof` copies out and checks with their own Hone run. `eslint.config.mjs` spreads the committed `disciplines.eslint.mjs` projection, which `node scripts/self-check.ts project --repo .` regenerates. Hone keeps its exception records in [the split layout](#the-split-layout): `discipline-exceptions/authorised-locations/cd-19.json` holds eight `authorised-location` records for `CD-19#import-boundaries`, each the single file that binds a runtime or third-party surface; seven are imported, with `existing-authorisation` provenance, from the earlier records kept in `.constitution-authorised-locations/cd-19.json`, and the eighth, for `mechanisms/eslint/runner/native-rules.ts`, carries its own why-chain. Strictness lives in `tsconfig.base.json`, which `tsconfig.json` extends; `tsconfig.json` leaves the same consumer folders out, since their files compile against the installed package.
|
|
366
393
|
|
|
367
394
|
`self-check` prints Hone's full report on itself, then one `self-check:` line. It fails when the run cannot load, or when any of `uncovered`, `stale`, `forfeited`, `doublyHeld`, `invalidRecords`, `unmeasured` or `projectionProblems` holds an entry: that is, when the selection, the exception records or the projection are not sound. It does not fail on `findings` or `unrecorded`. Those are printed in full and counted in the `self-check:` line, but they do not gate a change yet: the test fixtures hold deliberate violations, and some of Hone's own code does not meet every selected clause. CI runs `self-check` on every change with the pull request's base, or the previous `main`, as the base revision.
|
|
368
395
|
|
package/api/audit.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export type { PieceFailure } from "../core/mechanism-port/piece-failure-types.js
|
|
|
2
2
|
export type { ClauseSettingValues, RunnerClause } from "../core/mechanism-port/runner-module-types.js";
|
|
3
3
|
export type { ReadonlyJsonValue } from "../core/values/json-value.js";
|
|
4
4
|
export type { Edition, EditionReach } from "../core/values/edition-types.js";
|
|
5
|
-
export type { Hit } from "../core/mechanism-port/runner-result-types.js";
|
|
5
|
+
export type { Hit, Remedy } from "../core/mechanism-port/runner-result-types.js";
|
|
6
6
|
export type { Anchor, AnchorKind } from "../core/values/anchor.js";
|
|
7
7
|
export type { ClauseAddress, ToolRuleSet } from "../core/values/clause-address-types.js";
|
|
8
8
|
export type { ClauseId, DisciplineId, RuleSetName } from "../core/values/identifier-types.js";
|
package/api/testing.js
CHANGED
|
@@ -5,15 +5,15 @@ import {
|
|
|
5
5
|
loadRunner,
|
|
6
6
|
rejectedCall,
|
|
7
7
|
runnerInvalidOutput
|
|
8
|
-
} from "../chunks/chunk-
|
|
8
|
+
} from "../chunks/chunk-6SM3HKWO.js";
|
|
9
9
|
import {
|
|
10
10
|
caseVerdictSchema,
|
|
11
11
|
runnerResultSchema
|
|
12
|
-
} from "../chunks/chunk-
|
|
12
|
+
} from "../chunks/chunk-FEWCJU7H.js";
|
|
13
13
|
import {
|
|
14
14
|
readDisciplineFile,
|
|
15
15
|
readPieceFile
|
|
16
|
-
} from "../chunks/chunk-
|
|
16
|
+
} from "../chunks/chunk-E6VR3VRV.js";
|
|
17
17
|
import "../chunks/chunk-RWQ4UNKY.js";
|
|
18
18
|
import "../chunks/chunk-NA5L6PUE.js";
|
|
19
19
|
import {
|