@hailstails/hone 1.2.0 → 1.3.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 +4 -4
- package/CHANGELOG.md +16 -0
- package/MIGRATING.md +5 -5
- package/README.md +14 -8
- package/api/testing.js +1 -1
- package/chunks/{chunk-5VXHQC4A.js → chunk-YSN46EB3.js} +38 -19
- package/core/check/tool-command.js +44 -27
- package/docs/adding-a-discipline-or-mechanism.md +1 -1
- package/docs/extending.md +4 -5
- package/docs/output-contract.md +8 -4
- package/mechanisms/eslint/runner/README.md +1 -1
- package/mechanisms/eslint/runner/runner.js +57 -20
- package/package.json +1 -1
- package/rules/CD-10/CHECKS.md +2 -2
- package/rules/CD-14/CHECKS.md +2 -2
- package/rules/CD-15/CHECKS.md +2 -2
- package/rules/CD-17/CHECKS.md +2 -2
- package/rules/CD-19/CHECKS.md +2 -2
- package/rules/CD-2/CHECKS.md +2 -2
- package/rules/CD-23/CHECKS.md +2 -2
- package/rules/CD-25/CHECKS.md +2 -2
- package/rules/CD-26/CHECKS.md +2 -2
- package/rules/CD-27/CHECKS.md +2 -2
- package/rules/CD-3/CHECKS.md +2 -2
- package/rules/CD-40/CHECKS.md +2 -2
- package/rules/CD-41/CHECKS.md +2 -2
- 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/ADOPTING.md
CHANGED
|
@@ -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,7 +396,7 @@ 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
|
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
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.3.0
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- debt records need no reason or why-chain (#147)
|
|
10
|
+
- record-debt skips files the ESLint projection cannot reach (#153)
|
|
11
|
+
|
|
12
|
+
### Fixes
|
|
13
|
+
|
|
14
|
+
- pass over a package.json script whose quotes do not pair, and list one naming eslint as an unreadable command-line-option (#139)
|
|
15
|
+
|
|
16
|
+
### Other changes
|
|
17
|
+
|
|
18
|
+
- keep Hone's own exception records in the split layout (#140)
|
|
19
|
+
- run CD-27 test-body-logic and the CD-3 clauses at edition 2, and record Hone's backlog as debt (#157)
|
|
20
|
+
|
|
5
21
|
## 1.2.0
|
|
6
22
|
|
|
7
23
|
### 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.
|
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ An `unrecorded` line is `<clause> <mechanism> <kind> <detail>`. Two kinds end wi
|
|
|
52
52
|
| `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
53
|
| `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
54
|
| `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>` |
|
|
55
|
+
| `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
56
|
|
|
56
57
|
`<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
58
|
|
|
@@ -99,16 +100,19 @@ The `assessment` section is informational and the marker does not change the exi
|
|
|
99
100
|
|
|
100
101
|
### Recording inherited debt
|
|
101
102
|
|
|
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
|
|
103
|
+
`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
104
|
|
|
104
105
|
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
106
|
|
|
107
|
+
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.
|
|
108
|
+
|
|
106
109
|
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
110
|
|
|
108
111
|
- a pair that already has an `authorised-location` or `file-carve-out`, such as one the check forfeits (`already-recorded`);
|
|
109
112
|
- 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
113
|
- a file the base revision does not hold, since nothing in it was inherited (`new-file`);
|
|
111
|
-
- a clause whose discipline refuses exceptions (`refused`)
|
|
114
|
+
- a clause whose discipline refuses exceptions (`refused`);
|
|
115
|
+
- 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
116
|
|
|
113
117
|
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
118
|
|
|
@@ -197,7 +201,7 @@ At the repository root. It selects clauses and the mechanism that checks each on
|
|
|
197
201
|
- A judgement clause cannot be selected; it is enforced by review.
|
|
198
202
|
- `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
203
|
- `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`
|
|
204
|
+
- `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
205
|
- `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
206
|
- `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
207
|
- `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 +217,7 @@ At the repository root, or split by rule into the `discipline-exceptions` folder
|
|
|
213
217
|
"version": 1,
|
|
214
218
|
"exceptions": [
|
|
215
219
|
{ "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": "..."
|
|
220
|
+
{ "kind": "file-carve-out", "clause": "CD-14#class-syntax", "file": "src/legacy.ts", "reason": "..." },
|
|
217
221
|
{ "kind": "clause-wide-carve-out", "clause": "CD-14#class-syntax", "reason": "...", "whyChain": { } }
|
|
218
222
|
]
|
|
219
223
|
}
|
|
@@ -223,7 +227,7 @@ At the repository root, or split by rule into the `discipline-exceptions` folder
|
|
|
223
227
|
- A `file-carve-out` is debt in one file. It is forfeited once the file is touched.
|
|
224
228
|
- A `clause-wide-carve-out` exempts the clause's findings everywhere. It does not hold an inline exception.
|
|
225
229
|
- 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`
|
|
230
|
+
- 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
231
|
|
|
228
232
|
```json
|
|
229
233
|
"whyChain": {
|
|
@@ -242,7 +246,8 @@ At the repository root, or split by rule into the `discipline-exceptions` folder
|
|
|
242
246
|
```
|
|
243
247
|
- 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
248
|
- 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
|
-
-
|
|
249
|
+
- 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.
|
|
250
|
+
- 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
251
|
- A clause whose `discipline.json` declares `"exceptions": "refused"` cannot be exempted. No shipped discipline declares it, so every shipped clause can be.
|
|
247
252
|
- Files are exact repository paths, never globs.
|
|
248
253
|
- 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 +343,7 @@ This is the first release. Its tests cover each supported platform's ordinary pa
|
|
|
338
343
|
- `.d.mts` and `.d.cts` declaration files are not handled separately from other sources.
|
|
339
344
|
- Columns reported on lines holding non-ASCII text.
|
|
340
345
|
- Lint scripts are read with a simple shell tokenizer, so unusual quoting or a `cd` before `eslint` is not interpreted.
|
|
346
|
+
- 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
347
|
- 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
348
|
- Team ESLint configs that imitate projection block names, register a second copy of the plugin, or use processors are not exercised.
|
|
343
349
|
- 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 +361,14 @@ This repository is self-contained: it holds its own configuration and its own lo
|
|
|
355
361
|
| `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
362
|
| `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
363
|
| `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
|
|
364
|
+
| `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
365
|
| `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
366
|
| `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
367
|
| `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
368
|
|
|
363
369
|
### Hone's check on itself
|
|
364
370
|
|
|
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.
|
|
371
|
+
`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
372
|
|
|
367
373
|
`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
374
|
|
package/api/testing.js
CHANGED
|
@@ -450,7 +450,7 @@ var exceptionsFileSchema = z2.object({
|
|
|
450
450
|
kind: z2.literal("file-carve-out"),
|
|
451
451
|
clause: z2.string(),
|
|
452
452
|
file: z2.string(),
|
|
453
|
-
reason: z2.string(),
|
|
453
|
+
reason: z2.string().optional(),
|
|
454
454
|
whyChain: z2.unknown().optional(),
|
|
455
455
|
provenance: z2.unknown().optional()
|
|
456
456
|
}),
|
|
@@ -511,19 +511,19 @@ var fileCarveOutFields = {
|
|
|
511
511
|
kind: z2.literal("file-carve-out"),
|
|
512
512
|
clause: z2.string(),
|
|
513
513
|
file: z2.string(),
|
|
514
|
-
reason: z2.string()
|
|
514
|
+
reason: z2.string().optional()
|
|
515
515
|
};
|
|
516
516
|
var chainedFileCarveOutSchema = z2.strictObject({ ...fileCarveOutFields, whyChain: unjudgedWhyChainSchema, provenance: inheritedDebtProvenanceSchema.optional() });
|
|
517
517
|
var importedFileCarveOutSchema = z2.strictObject({ ...fileCarveOutFields, whyChain: z2.never().optional(), provenance: inheritedDebtProvenanceSchema });
|
|
518
|
-
var
|
|
518
|
+
var plainFileCarveOutSchema = z2.strictObject({ ...fileCarveOutFields, whyChain: z2.never().optional(), provenance: z2.never().optional() });
|
|
519
519
|
var FILE_EVIDENCE_SCHEMAS_OF = {
|
|
520
520
|
required: {
|
|
521
521
|
"authorised-location": z2.union([chainedAuthorisedLocationSchema, importedAuthorisedLocationSchema]),
|
|
522
|
-
"file-carve-out": z2.union([chainedFileCarveOutSchema, importedFileCarveOutSchema])
|
|
522
|
+
"file-carve-out": z2.union([chainedFileCarveOutSchema, importedFileCarveOutSchema, plainFileCarveOutSchema])
|
|
523
523
|
},
|
|
524
524
|
optional: {
|
|
525
525
|
"authorised-location": z2.union([chainedAuthorisedLocationSchema, importedAuthorisedLocationSchema, reasonedAuthorisedLocationSchema]),
|
|
526
|
-
"file-carve-out": z2.union([chainedFileCarveOutSchema, importedFileCarveOutSchema,
|
|
526
|
+
"file-carve-out": z2.union([chainedFileCarveOutSchema, importedFileCarveOutSchema, plainFileCarveOutSchema])
|
|
527
527
|
}
|
|
528
528
|
};
|
|
529
529
|
var legacySourceOf = (request) => {
|
|
@@ -545,9 +545,13 @@ var legacyListing = (request) => {
|
|
|
545
545
|
const records = legacyRecordsSchema.safeParse(document.value);
|
|
546
546
|
return records.success && records.data[request.source.index]?.files.includes(request.file) === true ? "listed" : "not-listed";
|
|
547
547
|
};
|
|
548
|
+
var IMPORT_WAY_OUT = {
|
|
549
|
+
"authorised-location": "give it a whyChain",
|
|
550
|
+
"file-carve-out": "give it a whyChain, or remove its provenance to keep it as debt"
|
|
551
|
+
};
|
|
548
552
|
var importRefused = (request) => ({
|
|
549
553
|
outcome: "failed",
|
|
550
|
-
error: { kind: "import-unverified", detail: `${request.detail}:
|
|
554
|
+
error: { kind: "import-unverified", detail: `${request.detail}: ${IMPORT_WAY_OUT[request.kind]}` }
|
|
551
555
|
});
|
|
552
556
|
var verifiedImport = (request) => {
|
|
553
557
|
const { baseline } = request;
|
|
@@ -558,11 +562,12 @@ var verifiedImport = (request) => {
|
|
|
558
562
|
return { outcome: "ok", value: request.record };
|
|
559
563
|
}
|
|
560
564
|
if (baseline.entriesAtBase.some((baseEntry) => sameIdentity({ entry: baseEntry, identity: request.identity }) === "same")) {
|
|
561
|
-
return importRefused({ detail: "the imported record was edited since the base revision" });
|
|
565
|
+
return importRefused({ detail: "the imported record was edited since the base revision", kind: request.identity.kind });
|
|
562
566
|
}
|
|
563
567
|
const source = legacySourceOf({ source: request.provenance.source });
|
|
564
568
|
const listed2 = source !== "not-legacy-source" && source.directory === LEGACY_DIRECTORY_OF[request.provenance.kind] && source.discipline === request.discipline.toUpperCase() && legacyListing({ sourceTextsAtBase: baseline.sourceTextsAtBase, source, file: request.identity.file }) === "listed";
|
|
565
569
|
return listed2 ? { outcome: "ok", value: request.record } : importRefused({
|
|
570
|
+
kind: request.identity.kind,
|
|
566
571
|
detail: `the record is new since the base revision, and its provenance source ${request.provenance.source} is not an entry at the base revision listing ${request.identity.file} under ${LEGACY_DIRECTORY_OF[request.provenance.kind]}/${request.discipline.toLowerCase()}.json`
|
|
567
572
|
});
|
|
568
573
|
};
|
|
@@ -1724,7 +1729,8 @@ var inlineDisableSchema = z10.object({
|
|
|
1724
1729
|
var scriptOptionCauseSchema = z10.discriminatedUnion("kind", [
|
|
1725
1730
|
z10.object({ kind: z10.literal("weakens-run") }).readonly(),
|
|
1726
1731
|
z10.object({ kind: z10.literal("after-another-command"), command: z10.string(), invocation: z10.string() }).readonly(),
|
|
1727
|
-
z10.object({ kind: z10.literal("wrapped"), command: z10.string(), wrapper: z10.string() }).readonly()
|
|
1732
|
+
z10.object({ kind: z10.literal("wrapped"), command: z10.string(), wrapper: z10.string() }).readonly(),
|
|
1733
|
+
z10.object({ kind: z10.literal("unreadable"), command: z10.string() }).readonly()
|
|
1728
1734
|
]);
|
|
1729
1735
|
var nativeExceptionSchema = z10.discriminatedUnion("kind", [
|
|
1730
1736
|
z10.object({ kind: z10.literal("ignore"), clause: clauseAddressObjectSchema, file: repoPathSchema }).readonly(),
|
|
@@ -1760,11 +1766,16 @@ var sliceProblemSchema = z10.object({
|
|
|
1760
1766
|
slice: repoPathSchema,
|
|
1761
1767
|
state: z10.enum(["out-of-date", "missing", "not-applied", "unconfigured", "nested-configuration"])
|
|
1762
1768
|
}).readonly();
|
|
1769
|
+
var unprojectedFolderSchema = z10.object({
|
|
1770
|
+
folder: repoPathSchema,
|
|
1771
|
+
selectionFolder: repoPathSchema
|
|
1772
|
+
}).readonly();
|
|
1763
1773
|
var embeddedRunReportSchema = z10.object({
|
|
1764
1774
|
hits: z10.array(hitSchema).readonly(),
|
|
1765
1775
|
nativeExceptions: z10.array(nativeExceptionSchema).readonly(),
|
|
1766
1776
|
projection: z10.enum(["current", "out-of-date", "missing", "not-included"]),
|
|
1767
|
-
slices: z10.array(sliceProblemSchema).readonly().default([])
|
|
1777
|
+
slices: z10.array(sliceProblemSchema).readonly().default([]),
|
|
1778
|
+
unprojectedFolders: z10.array(unprojectedFolderSchema).readonly().default([])
|
|
1768
1779
|
}).readonly();
|
|
1769
1780
|
|
|
1770
1781
|
// core/mechanism-port/runner-failure.ts
|
|
@@ -1832,7 +1843,8 @@ var standaloneRun = (request) => {
|
|
|
1832
1843
|
nativeExceptions: report.nativeExceptions,
|
|
1833
1844
|
coverableKinds: STANDALONE_COVERABLE_KINDS,
|
|
1834
1845
|
projection: "none",
|
|
1835
|
-
slices: []
|
|
1846
|
+
slices: [],
|
|
1847
|
+
unprojectedFolders: []
|
|
1836
1848
|
}
|
|
1837
1849
|
};
|
|
1838
1850
|
};
|
|
@@ -1875,7 +1887,8 @@ var embeddedRun = (request) => {
|
|
|
1875
1887
|
nativeExceptions: report.nativeExceptions,
|
|
1876
1888
|
coverableKinds: request.projectedKinds,
|
|
1877
1889
|
projection: report.projection,
|
|
1878
|
-
slices: report.slices
|
|
1890
|
+
slices: report.slices,
|
|
1891
|
+
unprojectedFolders: report.unprojectedFolders
|
|
1879
1892
|
}
|
|
1880
1893
|
};
|
|
1881
1894
|
};
|
|
@@ -2182,7 +2195,8 @@ var checkReportOf = (request) => {
|
|
|
2182
2195
|
readFirst: clauseReadingsOf({ ...request.check, findings: governed.findings, clauseRoots: request.inputs.clauseRoots })
|
|
2183
2196
|
};
|
|
2184
2197
|
};
|
|
2185
|
-
var
|
|
2198
|
+
var unprojectedOf = (request) => request.runs.flatMap((run) => run.unprojectedFolders.map((unprojected) => ({ mechanism: run.mechanism, ...unprojected })));
|
|
2199
|
+
var runReachedCheck = async (request) => {
|
|
2186
2200
|
const inputs = await loadInputs({
|
|
2187
2201
|
...request,
|
|
2188
2202
|
exceptionBaselineOf: ({ entries }) => exceptionBaselineOf({ check: request, entries })
|
|
@@ -2200,15 +2214,19 @@ var runCheck = async (request) => {
|
|
|
2200
2214
|
}
|
|
2201
2215
|
return {
|
|
2202
2216
|
outcome: "ok",
|
|
2203
|
-
value:
|
|
2204
|
-
|
|
2205
|
-
|
|
2206
|
-
|
|
2207
|
-
|
|
2208
|
-
|
|
2209
|
-
|
|
2217
|
+
value: {
|
|
2218
|
+
report: checkReportOf({
|
|
2219
|
+
check: request,
|
|
2220
|
+
assessment: request.assessment,
|
|
2221
|
+
inputs: inputs.value,
|
|
2222
|
+
runs: runs.value,
|
|
2223
|
+
touched: touchedSetFor({ check: request, records: inputs.value.records })
|
|
2224
|
+
}),
|
|
2225
|
+
unprojected: unprojectedOf({ runs: runs.value })
|
|
2226
|
+
}
|
|
2210
2227
|
};
|
|
2211
2228
|
};
|
|
2229
|
+
var runCheck = (request) => runReachedCheck(request).then((reached) => reached.outcome === "failed" ? reached : { outcome: "ok", value: reached.value.report });
|
|
2212
2230
|
|
|
2213
2231
|
export {
|
|
2214
2232
|
exceptionEntriesOfDocument,
|
|
@@ -2243,5 +2261,6 @@ export {
|
|
|
2243
2261
|
loadInputs,
|
|
2244
2262
|
recordsOf,
|
|
2245
2263
|
checkedTreeOf,
|
|
2264
|
+
runReachedCheck,
|
|
2246
2265
|
runCheck
|
|
2247
2266
|
};
|
|
@@ -25,9 +25,10 @@ import {
|
|
|
25
25
|
reportOutputInEffect,
|
|
26
26
|
reportOutputSchema,
|
|
27
27
|
runCheck,
|
|
28
|
+
runReachedCheck,
|
|
28
29
|
runnerFailed,
|
|
29
30
|
shownFailureOf
|
|
30
|
-
} from "../../chunks/chunk-
|
|
31
|
+
} from "../../chunks/chunk-YSN46EB3.js";
|
|
31
32
|
import "../../chunks/chunk-H4V72FCW.js";
|
|
32
33
|
import "../../chunks/chunk-YLZ73C7O.js";
|
|
33
34
|
import {
|
|
@@ -774,7 +775,6 @@ var createDefaultProcessPort = (_options) => createProcessPort({ processSurface:
|
|
|
774
775
|
|
|
775
776
|
// core/exception-records/inherited-debt.ts
|
|
776
777
|
var RECORD_DEBT_SUBCOMMAND = "record-debt";
|
|
777
|
-
var INHERITED_DEBT_REASON = `Inherited debt: this file existed at the base revision ${TOOL_IDENTITY.command} ${RECORD_DEBT_SUBCOMMAND} was given, and broke this clause when it wrote this record. Nobody has reviewed it or decided it should stay. The record is forfeited when the file next changes.`;
|
|
778
778
|
var pairKey = (request) => `${clauseAddressText({ address: request.clause })} ${request.file}`;
|
|
779
779
|
var inlinePairs = (request) => request.unrecorded.flatMap(
|
|
780
780
|
(exception) => exception.kind === "inline-disable" ? [{ clause: exception.clause, file: exception.file }] : []
|
|
@@ -823,8 +823,27 @@ var inheritedDebtOf = (request) => {
|
|
|
823
823
|
);
|
|
824
824
|
};
|
|
825
825
|
var inheritedDebtEntriesOf = (request) => request.outcomes.flatMap(
|
|
826
|
-
(outcome) => outcome.effect === "recorded" ? [{ kind: "file-carve-out", clause: clauseAddressText({ address: outcome.clause }), file: outcome.file
|
|
826
|
+
(outcome) => outcome.effect === "recorded" ? [{ kind: "file-carve-out", clause: clauseAddressText({ address: outcome.clause }), file: outcome.file }] : []
|
|
827
827
|
);
|
|
828
|
+
var reachedOutcomeOf = (request) => {
|
|
829
|
+
const { outcome } = request;
|
|
830
|
+
if (outcome.effect !== "recorded") {
|
|
831
|
+
return outcome;
|
|
832
|
+
}
|
|
833
|
+
const mechanism = request.mechanisms.get(clauseAddressText({ address: outcome.clause }));
|
|
834
|
+
const unprojected = request.unprojected.find(
|
|
835
|
+
(candidate) => candidate.mechanism === mechanism && outcome.file.startsWith(`${candidate.folder}/`)
|
|
836
|
+
);
|
|
837
|
+
return unprojected === void 0 ? outcome : {
|
|
838
|
+
clause: outcome.clause,
|
|
839
|
+
file: outcome.file,
|
|
840
|
+
effect: "nested-configuration",
|
|
841
|
+
under: unprojected.folder,
|
|
842
|
+
selectionFolder: unprojected.selectionFolder,
|
|
843
|
+
mechanism: unprojected.mechanism
|
|
844
|
+
};
|
|
845
|
+
};
|
|
846
|
+
var reachedDebtOf = (request) => request.outcomes.map((outcome) => reachedOutcomeOf({ ...request, outcome }));
|
|
828
847
|
|
|
829
848
|
// core/check/command-line.ts
|
|
830
849
|
var SPLIT_RECORDS_SUBCOMMAND = "split-records";
|
|
@@ -893,7 +912,7 @@ var COMMANDS = {
|
|
|
893
912
|
]
|
|
894
913
|
},
|
|
895
914
|
[RECORD_DEBT_SUBCOMMAND]: {
|
|
896
|
-
summary: "add a
|
|
915
|
+
summary: "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",
|
|
897
916
|
options: [REPO_OPTION, ADOPTION_BASE_REVISION_OPTION, LEAVE_OPTION],
|
|
898
917
|
exits: [
|
|
899
918
|
{ code: 0, meaning: "every record needed was written, or none was needed" },
|
|
@@ -1274,6 +1293,8 @@ var scriptOptionNote = (request) => {
|
|
|
1274
1293
|
return `: ${request.cause.command} is not the first command of its script, ${UNJUDGED_OPTION}; give ${request.cause.command} a script of its own, such as ${quoted({ text: request.cause.invocation })}`;
|
|
1275
1294
|
case "wrapped":
|
|
1276
1295
|
return `: ${quoted({ text: request.cause.wrapper })} comes before ${request.cause.command} and is neither a package runner nor a NAME=value setting, ${UNJUDGED_OPTION}; put only package runners and NAME=value settings before ${request.cause.command}`;
|
|
1296
|
+
case "unreadable":
|
|
1297
|
+
return `: a quote in the script has no partner, so Hone cannot read what the script passes to ${request.cause.command} or tell what that does to the files under check; pair every quote in the script`;
|
|
1277
1298
|
}
|
|
1278
1299
|
};
|
|
1279
1300
|
var inlineDetail = (request) => `${request.exception.file}:${request.exception.line} ${escapedLineBreaks({ text: request.exception.text })}`;
|
|
@@ -1513,6 +1534,8 @@ var inheritedDebtNote = (request) => {
|
|
|
1513
1534
|
return ": the base revision does not hold this file, so its debt was not inherited; fix it, or record it with its own reason";
|
|
1514
1535
|
case "refused":
|
|
1515
1536
|
return ": the clause's discipline refuses exceptions; fix it";
|
|
1537
|
+
case "nested-configuration":
|
|
1538
|
+
return `: the file loads the ${outcome.mechanism} configuration in ${outcome.under}, and ${outcome.selectionFolder} holds its own disciplines.json; nested Hone configurations are not supported yet (${NESTED_CONFIGURATION_ISSUE}), so the ${outcome.mechanism} projection cannot put a record on this file into effect; fix it, or govern ${outcome.selectionFolder} from this repository by removing ${outcome.selectionFolder}/disciplines.json, then run ${RECORD_DEBT_SUBCOMMAND} again`;
|
|
1516
1539
|
}
|
|
1517
1540
|
};
|
|
1518
1541
|
var inheritedDebtLine = (request) => `${clauseAddressText({ address: request.outcome.clause })} ${request.outcome.effect} ${request.outcome.file}${inheritedDebtNote(request)}
|
|
@@ -1729,45 +1752,39 @@ var runProjectCommand = (request) => projectResult(request).then(
|
|
|
1729
1752
|
);
|
|
1730
1753
|
|
|
1731
1754
|
// core/check/run-record-debt-command.ts
|
|
1732
|
-
var SELECTION_FILE_NAME2 = "disciplines.json";
|
|
1733
1755
|
var ASSESSED_IN_THIS_RUN = { forfeiture: "this-run" };
|
|
1734
|
-
var reasonOnlySelection = (request) => {
|
|
1735
|
-
const reading = readSelection({ ...request, moduleExtension: moduleExtensionOf({ moduleUrl: request.moduleUrl }) });
|
|
1736
|
-
if (reading.outcome === "failed" || reading.value.fileExceptionWhyChains === "optional") {
|
|
1737
|
-
return reading;
|
|
1738
|
-
}
|
|
1739
|
-
return {
|
|
1740
|
-
outcome: "failed",
|
|
1741
|
-
error: { kind: "why-chains-required", path: request.path.join({ segments: [request.repoRoot, SELECTION_FILE_NAME2] }) }
|
|
1742
|
-
};
|
|
1743
|
-
};
|
|
1744
1756
|
var pathsInBase = (request) => {
|
|
1745
1757
|
const listed2 = request.gitTree.pathsAt({ repoRoot: request.repoRoot, revision: request.arguments.baseRevision });
|
|
1746
1758
|
return listed2.outcome === "failed" ? { outcome: "failed", error: { kind: "git-failed", detail: `${listed2.error.command}: ${listed2.error.detail}` } } : { outcome: "ok", value: new Set(listed2.value) };
|
|
1747
1759
|
};
|
|
1760
|
+
var clauseMechanismsOf = (request) => new Map(request.selection.selection.selected.map((clause) => [clauseAddressText({ address: clause.address }), clause.mechanism]));
|
|
1748
1761
|
var debtOutcomesOf = async (request) => {
|
|
1749
|
-
const
|
|
1762
|
+
const reached = await runReachedCheck({
|
|
1750
1763
|
...request,
|
|
1751
1764
|
moduleExtension: moduleExtensionOf({ moduleUrl: request.moduleUrl }),
|
|
1752
1765
|
baseRevision: request.arguments.baseRevision,
|
|
1753
1766
|
assessment: ASSESSED_IN_THIS_RUN
|
|
1754
1767
|
});
|
|
1755
|
-
if (
|
|
1756
|
-
return
|
|
1757
|
-
}
|
|
1758
|
-
const outcomes =
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1768
|
+
if (reached.outcome === "failed") {
|
|
1769
|
+
return reached;
|
|
1770
|
+
}
|
|
1771
|
+
const outcomes = reachedDebtOf({
|
|
1772
|
+
outcomes: inheritedDebtOf({
|
|
1773
|
+
findings: reached.value.report.findings,
|
|
1774
|
+
unrecorded: reached.value.report.unrecorded,
|
|
1775
|
+
existing: request.existing,
|
|
1776
|
+
leave: request.arguments.leave,
|
|
1777
|
+
inBase: request.inBase,
|
|
1778
|
+
refusing: request.selection.selection.selected.flatMap((clause) => clause.exceptions === "refused" ? [clause.address] : [])
|
|
1779
|
+
}),
|
|
1780
|
+
unprojected: reached.value.unprojected,
|
|
1781
|
+
mechanisms: clauseMechanismsOf(request)
|
|
1765
1782
|
});
|
|
1766
1783
|
const written = request.exceptionRepository.add({ entries: inheritedDebtEntriesOf({ outcomes }) });
|
|
1767
1784
|
return written.outcome === "failed" ? written : { outcome: "ok", value: outcomes };
|
|
1768
1785
|
};
|
|
1769
1786
|
var adoptionDebt = (request) => {
|
|
1770
|
-
const selection =
|
|
1787
|
+
const selection = readSelection({ ...request, moduleExtension: moduleExtensionOf({ moduleUrl: request.moduleUrl }) });
|
|
1771
1788
|
if (selection.outcome === "failed") {
|
|
1772
1789
|
return Promise.resolve(selection);
|
|
1773
1790
|
}
|
|
@@ -167,7 +167,7 @@ These hold for every discipline and mechanism. Tests under `core/check/` check t
|
|
|
167
167
|
An embedded runner has the same `run` and `conform` as a standalone one, plus:
|
|
168
168
|
|
|
169
169
|
- `projectedKinds`: the native exception kinds its own projection writes. Only these kinds can be matched by a record.
|
|
170
|
-
- `run` also receives the repository's exception records for that mechanism, so it can regenerate the projection and compare it. It returns hits, the native exceptions it found, and the projection's state: `current`, `out-of-date`, `missing` or `not-included`. A projection that is missing or not included means the mechanism did not run: core lists `mechanism-not-run` and the check fails. An out-of-date one is a projection problem and also fails. It may also return `slices`, each a projection file other than the root one with its state, `missing`, `out-of-date`, `not-applied`, `unconfigured` or `nested-configuration`; a runner reports `nested-configuration` only beside a `not-included` projection, for a folder holding its own `disciplines.json` whose own config left the projection out of effect, and core names that folder on the `mechanism-not-run` entry; core lists each other state as a projection problem naming the file. A runner that returns none has none.
|
|
170
|
+
- `run` also receives the repository's exception records for that mechanism, so it can regenerate the projection and compare it. It returns hits, the native exceptions it found, and the projection's state: `current`, `out-of-date`, `missing` or `not-included`. A projection that is missing or not included means the mechanism did not run: core lists `mechanism-not-run` and the check fails. An out-of-date one is a projection problem and also fails. It may also return `slices`, each a projection file other than the root one with its state, `missing`, `out-of-date`, `not-applied`, `unconfigured` or `nested-configuration`; a runner reports `nested-configuration` only beside a `not-included` projection, for a folder holding its own `disciplines.json` whose own config left the projection out of effect, and core names that folder on the `mechanism-not-run` entry; core lists each other state as a projection problem naming the file. A runner that returns none has none. It may also return `unprojectedFolders`: each `folder` whose files load a configuration the projection never reaches, such as one inside a folder holding its own `disciplines.json`, with the outermost such `selectionFolder` that holds it. The check prints nothing for them; `hone record-debt` writes no record for a file under one and prints a `nested-configuration` line instead, since that record could not take effect. A runner that returns none has none, and its type, `ReturnedEmbeddedRunReport`, leaves the field optional.
|
|
171
171
|
- `project`: writes the projection files and returns each path with `written`, `unchanged`, `removed` or `left-in-place`. `hone project` calls it.
|
|
172
172
|
|
|
173
173
|
Core passes every record for the mechanism to both calls, forfeited or not, and never passes the touched set. A forfeited file carve-out therefore stays in the projection; core's check reports it as `forfeited`, no longer counts it as holding any native exception, so each one it held is listed under `unrecorded`, and fails the run. Keep it that way: a runner must not compute forfeiture or read the touched set itself, so that whether a forfeited carve-out stays pushed down remains core's decision. No test checks this; it is a rule for review.
|
package/docs/extending.md
CHANGED
|
@@ -344,18 +344,17 @@ Checks of your own call the piece directly. `clauseUnderTestOf` returns the same
|
|
|
344
344
|
|
|
345
345
|
## Exceptions
|
|
346
346
|
|
|
347
|
-
Exception records in `discipline-exceptions.json` name team clauses by their full address and work exactly as for Hone's own clauses. This entry
|
|
347
|
+
Exception records in `discipline-exceptions.json` name team clauses by their full address and work exactly as for Hone's own clauses. This entry records the console calls already in `src/start-banner.ts` as debt: it moves the finding to `exempted` and, after `hone project`, turns the rule off for that file in the team's own ESLint run, until the file is next touched and the record is forfeited:
|
|
348
348
|
|
|
349
349
|
```json
|
|
350
350
|
{
|
|
351
|
-
"kind": "
|
|
351
|
+
"kind": "file-carve-out",
|
|
352
352
|
"clause": "acme/ACME-1#console-calls",
|
|
353
|
-
"file": "src/start-banner.ts"
|
|
354
|
-
"reason": "The start banner is the one place that writes to the terminal."
|
|
353
|
+
"file": "src/start-banner.ts"
|
|
355
354
|
}
|
|
356
355
|
```
|
|
357
356
|
|
|
358
|
-
|
|
357
|
+
A `file-carve-out` is debt and needs no `whyChain` and no `reason`. Where the clause does not apply to a file at all, record an `authorised-location` instead: it is never forfeited, so it needs a `reason` and a `whyChain` that follows the [why-chain contract](why-chain-contract.md), and without the chain it is refused as `evidence-refused`. [README.md](../README.md#discipline-exceptionsjson) describes the record kinds and what each needs.
|
|
359
358
|
|
|
360
359
|
## What is stable
|
|
361
360
|
|