@hailstails/hone 0.1.0-pre.5 → 0.1.0-pre.7
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 +151 -42
- package/MIGRATING.md +55 -4
- package/README.md +120 -43
- package/THIRD-PARTY-NOTICES.md +1 -1
- package/api/audit.d.ts +3 -0
- package/api/audit.js +10 -0
- package/api/rule-set.js +0 -0
- package/api/testing.d.ts +5 -0
- package/api/testing.js +211 -0
- package/chunks/chunk-3LCKBX5T.js +2134 -0
- package/chunks/chunk-5LCLBXP7.js +76 -0
- package/chunks/{chunk-7PVPPH4C.js → chunk-LDQUT742.js} +3 -1
- package/chunks/{chunk-VUG3DJHN.js → chunk-MYX7GAVM.js} +9 -9
- package/chunks/{chunk-SWPCKTJV.js → chunk-NCDYOPHG.js} +7340 -2124
- package/chunks/{chunk-HVABJ7T4.js → chunk-NRXSM7BY.js} +73 -12
- package/chunks/{chunk-YBWVUDIG.js → chunk-P3NLETF5.js} +1 -1
- package/chunks/{chunk-IIMK5BCL.js → chunk-POZL7G62.js} +15 -13
- package/chunks/{chunk-7OVV6NEU.js → chunk-WPRR2MPJ.js} +1 -1
- package/core/check/tool-command.js +531 -1967
- package/core/conformance/conformance-testing-types.d.ts +28 -0
- package/core/conformance/conformance-types.d.ts +7 -0
- package/docs/adding-a-discipline-or-mechanism.md +27 -14
- package/docs/extending.md +22 -11
- package/docs/output-contract.md +326 -0
- package/mechanisms/audit/CD-19/import-boundaries.js +3 -3
- package/mechanisms/audit/CD-2/piece.json +6 -1
- package/mechanisms/audit/CD-5/comments-directives.js +10 -26
- package/mechanisms/audit/runner/README.md +3 -2
- package/mechanisms/audit/runner/runner.js +97 -35
- package/mechanisms/eslint/CD-2/README.md +12 -0
- package/mechanisms/eslint/CD-2/cd2/cd2.eslint-plugin.js +16 -0
- package/mechanisms/eslint/CD-2/piece.json +25 -0
- package/mechanisms/eslint/runner/README.md +12 -5
- package/mechanisms/eslint/runner/runner.js +900 -242
- package/methods/README.md +2 -0
- package/methods/assessment-template.md +35 -0
- package/methods/lenses/clean-architecture.md +2 -2
- package/methods/lenses/decomposition.md +2 -2
- package/methods/lenses/defended-on-intent.md +7 -7
- package/methods/lenses/di-discipline.md +38 -26
- package/methods/lenses/errors-as-data.md +2 -2
- package/methods/lenses/function-first.md +2 -2
- package/methods/lenses/naming.md +2 -2
- package/methods/lenses/test-discipline.md +15 -13
- package/methods/lenses/type-soundness.md +2 -2
- package/methods/lenses/zod-boundary.md +2 -2
- package/package.json +8 -3
- package/rules/CD-1/CHECKS.md +37 -0
- package/rules/CD-1/README.md +17 -32
- package/rules/CD-10/CHECKS.md +49 -0
- package/rules/CD-10/README.md +21 -49
- package/rules/CD-11/CHECKS.md +13 -0
- package/rules/CD-11/README.md +14 -8
- package/rules/CD-12/CHECKS.md +13 -0
- package/rules/CD-12/README.md +14 -8
- package/rules/CD-13/CHECKS.md +13 -0
- package/rules/CD-13/README.md +14 -8
- package/rules/CD-14/CHECKS.md +49 -0
- package/rules/CD-14/README.md +22 -48
- package/rules/CD-15/CHECKS.md +40 -0
- package/rules/CD-15/README.md +22 -40
- package/rules/CD-16/CHECKS.md +7 -0
- package/rules/CD-16/README.md +3 -5
- package/rules/CD-17/CHECKS.md +37 -0
- package/rules/CD-17/README.md +17 -31
- package/rules/CD-18/CHECKS.md +13 -0
- package/rules/CD-18/README.md +15 -9
- package/rules/CD-19/CHECKS.md +49 -0
- package/rules/CD-19/README.md +18 -44
- package/rules/CD-2/CHECKS.md +56 -0
- package/rules/CD-2/README.md +18 -35
- package/rules/CD-2/discipline.json +68 -0
- package/rules/CD-20/CHECKS.md +7 -0
- package/rules/CD-20/README.md +3 -5
- package/rules/CD-21/CHECKS.md +13 -0
- package/rules/CD-21/README.md +14 -9
- package/rules/CD-22/CHECKS.md +13 -0
- package/rules/CD-22/README.md +13 -8
- package/rules/CD-23/CHECKS.md +35 -0
- package/rules/CD-23/README.md +14 -29
- package/rules/CD-24/CHECKS.md +7 -0
- package/rules/CD-24/README.md +3 -5
- package/rules/CD-25/CHECKS.md +38 -0
- package/rules/CD-25/README.md +20 -32
- package/rules/CD-26/CHECKS.md +36 -0
- package/rules/CD-26/README.md +18 -31
- package/rules/CD-27/CHECKS.md +45 -0
- package/rules/CD-27/README.md +18 -40
- package/rules/CD-28/CHECKS.md +13 -0
- package/rules/CD-28/README.md +14 -8
- package/rules/CD-29/CHECKS.md +13 -0
- package/rules/CD-29/README.md +12 -8
- package/rules/CD-3/CHECKS.md +42 -0
- package/rules/CD-3/README.md +20 -42
- package/rules/CD-30/CHECKS.md +13 -0
- package/rules/CD-30/README.md +13 -8
- package/rules/CD-31/CHECKS.md +13 -0
- package/rules/CD-31/README.md +12 -8
- package/rules/CD-32/CHECKS.md +13 -0
- package/rules/CD-32/README.md +13 -8
- package/rules/CD-33/CHECKS.md +13 -0
- package/rules/CD-33/README.md +13 -8
- package/rules/CD-34/CHECKS.md +13 -0
- package/rules/CD-34/README.md +12 -8
- package/rules/CD-39/CHECKS.md +13 -0
- package/rules/CD-39/README.md +13 -8
- package/rules/CD-4/CHECKS.md +13 -0
- package/rules/CD-4/README.md +15 -8
- package/rules/CD-40/CHECKS.md +39 -0
- package/rules/CD-40/README.md +17 -33
- package/rules/CD-41/CHECKS.md +54 -0
- package/rules/CD-41/README.md +23 -54
- package/rules/CD-42/CHECKS.md +47 -0
- package/rules/CD-42/README.md +19 -47
- package/rules/CD-43/CHECKS.md +37 -0
- package/rules/CD-43/README.md +15 -31
- package/rules/CD-44/CHECKS.md +48 -0
- package/rules/CD-44/README.md +20 -48
- package/rules/CD-45/CHECKS.md +13 -0
- package/rules/CD-45/README.md +14 -8
- package/rules/CD-46/CHECKS.md +7 -0
- package/rules/CD-46/README.md +16 -4
- package/rules/CD-47/CHECKS.md +37 -0
- package/rules/CD-47/README.md +16 -32
- package/rules/CD-5/CHECKS.md +52 -0
- package/rules/CD-5/README.md +22 -52
- package/rules/CD-6/CHECKS.md +51 -0
- package/rules/CD-6/README.md +22 -51
- package/rules/CD-7/CHECKS.md +46 -0
- package/rules/CD-7/README.md +23 -46
- package/rules/CD-7a/CHECKS.md +38 -0
- package/rules/CD-7a/README.md +14 -32
- package/rules/CD-8/CHECKS.md +42 -0
- package/rules/CD-8/README.md +20 -42
- package/rules/CD-9/CHECKS.md +13 -0
- package/rules/CD-9/README.md +15 -8
- package/rules/README.md +5 -3
- package/rules/SPIRIT.md +50 -0
- package/api/audit.mjs +0 -1
- package/api/rule-set.mjs +0 -1
package/README.md
CHANGED
|
@@ -27,36 +27,60 @@ A team adds its own disciplines as a rule set in its own repository, with ESLint
|
|
|
27
27
|
The package ships one command, `hone`, with two subcommands, run through a `package.json` script as [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) shows:
|
|
28
28
|
|
|
29
29
|
```text
|
|
30
|
-
hone check --repo <dir> [--base-revision <
|
|
30
|
+
hone check --repo <dir> [--base-revision <revision>] [--report-output <full|failures-only|counts|verdict-only>] [--forfeiture <this-run|elsewhere>]
|
|
31
31
|
hone project --repo <dir>
|
|
32
|
+
hone --help
|
|
33
|
+
hone --version
|
|
32
34
|
```
|
|
33
35
|
|
|
34
|
-
`hone`
|
|
36
|
+
`--repo` is the folder that holds `disciplines.json`, usually the repository root. `hone --help` lists the commands, `hone check --help` and `hone project --help` list each one's options and exit codes, and `hone --version` prints the installed version. A command typed wrongly is a load failure `arguments-invalid` that says what was wrong, a `--repo` folder with no `disciplines.json` is the load failure `selection-absent`, and an error Hone did not expect is the load failure `unexpected-error`; each exits `2`. Everything Hone prints goes to standard output, so exit `1` always comes with `verdict: fail`. From a source checkout the same command is `node core/check/tool-command.ts check --repo <dir>`.
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
[docs/output-contract.md](docs/output-contract.md) lists every line `hone` prints, exactly as it prints it, with the exit codes and which parts are stable for hooks, CI and agents to rely on. A test renders every kind of line and checks it against that page, both ways.
|
|
37
39
|
|
|
38
|
-
|
|
39
|
-
| --- | --- | --- |
|
|
40
|
-
| `0` | the verdict is `pass` | every projection was written or already current |
|
|
41
|
-
| `1` | the verdict is `fail` | not used |
|
|
42
|
-
| `2` | an input could not be loaded, or a mechanism failed or returned invalid output | any failure |
|
|
43
|
-
|
|
44
|
-
A load failure prints one line, `load failure: <kind> <fields>`.
|
|
40
|
+
`hone check` loads the repository's selection, exceptions, rule sets and pieces; works out which files changed since `--base-revision`; runs each selected mechanism once over the repository's tracked `.ts`, `.tsx`, `.mts` and `.cts` files; applies the exceptions; and prints a plain-text report ending in `verdict: pass` or `verdict: fail`. It exits `0` when the verdict is `pass`, `1` when it is `fail`, and `2` on a load failure, which prints one line, `load failure: <kind> <fields>`. `hone project` exits `0` or `2`.
|
|
45
41
|
|
|
46
|
-
The report lists the excluded paths, the clauses not adopted, findings, exempted findings, uncovered clauses, stale, forfeited, unrecorded and doubly-held exceptions, invalid exception records, unmeasured checks, projection problems
|
|
42
|
+
The report lists the excluded paths, the clauses not adopted, the clauses adopted with their mechanism not run, findings, exempted findings, uncovered clauses, stale, forfeited, unrecorded and doubly-held exceptions, invalid exception records, unmeasured checks, projection problems, any part of the assessment left to another run and, last, where to read first for each clause with findings, each with its count. The verdict is `pass` only when every list except the excluded paths, clauses not adopted, clauses not run, exempted findings, assessment and where to read first is empty.
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
An `unrecorded` line is `<clause> <mechanism> <kind> <detail>`. Two kinds end with a note:
|
|
49
45
|
|
|
50
|
-
|
|
|
46
|
+
| Kind | Line |
|
|
51
47
|
| --- | --- |
|
|
52
|
-
| `
|
|
53
|
-
| `
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
48
|
+
| `inline-disable` naming no rule | `<clause> eslint inline-disable <file>:<line> <comment> names no rule and escapes every selected clause: naming the rule is the cheap fix` |
|
|
49
|
+
| `command-line-option` that weakens the run | `<clause> eslint command-line-option <package.json> <script> <option> weakens the script's whole run, so no record can cover it: remove it from the script` |
|
|
50
|
+
| `command-line-option` Hone cannot judge, because another command comes before `eslint` in its script | `<clause> eslint command-line-option <package.json> <script> <option>: <command> is not the first command of its script, so Hone cannot tell what the option does to the files under check; give <command> a script of its own, such as "<invocation>"` |
|
|
51
|
+
| `command-line-option` Hone cannot judge, because something before `eslint` in its own command is not a package runner or a `NAME=value` setting | `<clause> eslint command-line-option <package.json> <script> <option>: "<wrapper>" comes before <command> and is neither a package runner nor a NAME=value setting, so Hone cannot tell what the option does to the files under check; put only package runners and NAME=value settings before <command>` |
|
|
52
|
+
|
|
53
|
+
`<command>` is the `eslint` call as the script writes it, `<invocation>` is its whole command with its settings and options, from the same script, and `<wrapper>` is the first token before it that Hone does not read, such as `env` or a runner flag like `-y` or `-C`. `cross-env` followed only by `NAME=value` settings counts as a setting. Once only package runners and settings come first, Hone judges the option: `-c` naming the config ESLint already finds, and `--ignore-pattern` that ignores no checked file, are then not reported.
|
|
54
|
+
|
|
55
|
+
`readFirst` comes last, just before the verdict, so a reader who looks only at the end of a failing report lands on it. It has one line per clause with findings, not one per finding, in the order the findings first name the clauses. Each line points at the Spirit section of the clause's rule page, `rules/<ID>/README.md` in the clause's rule set, and, where the repository has written one, at the clause's own section in `disciplines.assessment.md` at the repository root first. That file is where a repository records its own causes, forward goal and steps for a clause; [ADOPTING step 5a](ADOPTING.md#5a-write-the-assessment) says how to write it. Paths are printed with forward slashes, relative to the `--repo` folder; a page on another drive is printed as its absolute path.
|
|
56
|
+
|
|
57
|
+
When `disciplines.assessment.md` is not written yet, or cannot be read, one note line comes first and says so, naming ADOPTING step 5a; each clause line then names its rule page only. The note counts as an entry, so a report with two failing clauses and no assessment file prints `readFirst (3)`. A clause line names the clause's section when the file has one, and says `disciplines.assessment.md does not assess this clause` when the file is there without it. [The output contract](docs/output-contract.md#report-lines) lists every `readFirst` line exactly.
|
|
58
|
+
|
|
59
|
+
A file that does not assess a clause is normal: the assessment covers the clauses the repository chose to describe, and the rule page's Spirit is the read for the rest.
|
|
60
|
+
|
|
61
|
+
A clause's section is a level-2 heading whose text is exactly the clause address as the report prints it (`## CD-15#loops`, `## team/TM-1#no-tmp-files`). Trailing spaces, a carriage return and a byte order mark at the start of the file are ignored. Nothing else is normalised: `## CD-15#loops ##`, `## CD-15#loops`, `### CD-15#loops` and `## hone/CD-15#loops` are not that clause's section, and a heading inside a fenced code block (opened by three or more backticks or tildes, closed by at least as many of the same character) is not counted.
|
|
62
|
+
|
|
63
|
+
Hone matches the heading only; it never reads the section's text. A missing file or section never fails the run. A run with no findings prints no `readFirst` section and reads neither file, so its report is unchanged; a run with findings reads `disciplines.assessment.md` once and checks that each failing clause's rule page exists.
|
|
64
|
+
|
|
65
|
+
`--report-output` sets how much of the report is printed for one run, overriding `reportOutput` in `disciplines.json`; with neither, the output is `full`. `full` prints every non-empty section, `failures-only` leaves out the informational sections and keeps `readFirst`, `counts` prints each section's heading line only, with `informational` or `guidance` after the sections that never fail the run, and `verdict-only` prints the verdict line alone; [the output contract](docs/output-contract.md#the-report) shows each.
|
|
56
66
|
|
|
57
67
|
The output changes only what is printed: the verdict and exit code always come from the whole report. An unknown `--report-output` value is a load failure `arguments-invalid`; an unknown `reportOutput` value makes `disciplines.json` `file-malformed`, even when `--report-output` is given. Load failures print the same in every output.
|
|
58
68
|
|
|
59
|
-
Without `--base-revision`, Hone cannot tell which files were touched, so a file carve-out cannot be forfeited; if any file carve-out exists the report lists `forfeiture-unmeasured` and the run fails. For the same reason it cannot tell whether an entry with an earlier-contract why-chain is unchanged; if one exists the report lists `legacy-chain-unmeasured` and the run fails.
|
|
69
|
+
Without `--base-revision`, Hone cannot tell which files were touched, so a file carve-out cannot be forfeited; if any file carve-out exists the report lists `forfeiture-unmeasured` and the run fails. For the same reason it cannot tell whether an entry with an earlier-contract why-chain is unchanged; if one exists the report lists `legacy-chain-unmeasured` and the run fails. Each line says what Hone needs:
|
|
70
|
+
|
|
71
|
+
```text
|
|
72
|
+
forfeiture-unmeasured no-base-revision: no --base-revision was given, so file carve-outs cannot be checked for decay; pass --base-revision with the branch's base, such as origin/main, or leave decay to another run with "assessment": { "forfeiture": "elsewhere" } in disciplines.json or --forfeiture elsewhere
|
|
73
|
+
import-unmeasured no-base-revision: no --base-revision was given, so imported records cannot be checked against it; pass --base-revision with the branch's base, such as origin/main
|
|
74
|
+
legacy-chain-unmeasured no-base-revision: no --base-revision was given, so legacy-chain records cannot be checked against it; pass --base-revision with the branch's base, such as origin/main
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
A `--base-revision` that git cannot use gives the same kinds as `base-git-failed`, naming the revision in double quotes, escaped as in JSON, with git's own first line:
|
|
78
|
+
|
|
79
|
+
```text
|
|
80
|
+
forfeiture-unmeasured base-git-failed "origin/main": git could not list the files changed since that revision and said "<git's first line>"; Hone needs that revision and the history back to where this branch left it, or leave decay to another run with "assessment": { "forfeiture": "elsewhere" } in disciplines.json or --forfeiture elsewhere
|
|
81
|
+
import-unmeasured base-git-failed "origin/main": git could not read the exception records at that revision and said "<git's first line>"; Hone needs the exception records as they were at that revision
|
|
82
|
+
legacy-chain-unmeasured base-git-failed "origin/main": git could not read the exception records at that revision and said "<git's first line>"; Hone needs the exception records as they were at that revision
|
|
83
|
+
```
|
|
60
84
|
|
|
61
85
|
`--forfeiture elsewhere` makes a run leave carve-out decay to another run, such as a pre-push hook given a base revision, overriding `assessment.forfeiture` in `disciplines.json`; `--forfeiture this-run`, the default, assesses it in this run. A run with forfeiture elsewhere asks git for no change set, forfeits no file carve-out and never reports `forfeiture-unmeasured`, with or without `--base-revision`. It ends its report with an `assessment` section, printed whenever the run assesses less than the default, and marks its verdict line in every output:
|
|
62
86
|
|
|
@@ -68,13 +92,7 @@ verdict: pass (partial assessment)
|
|
|
68
92
|
|
|
69
93
|
The `assessment` section is informational and the marker does not change the exit code. Forfeiture elsewhere changes nothing else: `--base-revision` given with it is used only to check imported entries and legacy chains, and a run without a base revision still reports `import-unmeasured` and `legacy-chain-unmeasured` as above.
|
|
70
94
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```text
|
|
74
|
-
waived-clauses not-run: 1 clause not run, 1 record not judged stale: CD-6#naming-convention eslint
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
`hone project` writes the native configuration each embedded mechanism needs, and prints `<path> <effect>` per file (`written` or `unchanged`). The audit mechanism is standalone and writes nothing, so with only the walker selected the command prints nothing and exits `0`.
|
|
95
|
+
`hone project` writes the native configuration each embedded mechanism needs, and prints `<path> <effect>` per file: `written`, `unchanged`, `removed` for a package slice Hone wrote whose folder is no longer a config root, or `left-in-place` for such a file whose bytes are not what Hone would write there. The audit mechanism is standalone and writes nothing, so with only the walker selected the command prints nothing and exits `0`.
|
|
78
96
|
|
|
79
97
|
## Adopting the ESLint mechanism
|
|
80
98
|
|
|
@@ -89,8 +107,46 @@ export default [
|
|
|
89
107
|
];
|
|
90
108
|
```
|
|
91
109
|
|
|
92
|
-
This is the only supported way to adopt the rules. On every check, Hone reads the team's resolved configuration for each checked file and fails the run if the projection is missing
|
|
110
|
+
This is the only supported way to adopt the rules. On every check, Hone reads the team's resolved configuration for each checked file and fails the run if the projection is missing, not in effect, or differs from what `hone project` would write now, with the line that says what to do:
|
|
111
|
+
|
|
112
|
+
```text
|
|
113
|
+
mechanism-not-run eslint missing: disciplines.eslint.mjs is not written; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
|
|
114
|
+
mechanism-not-run eslint not-included: the eslint configuration leaves the projection out of effect for a file under check; spread the default export of disciplines.eslint.mjs, or of a package's own disciplines.eslint.mjs in that package, last in the configuration that file loads, after every other block (an import placed last without the spread applies nothing), or, where a tool such as sku generates the configuration, last in the configuration the tool takes
|
|
115
|
+
eslint out-of-date: disciplines.eslint.mjs differs from what hone project writes now; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The command on these lines runs the entry file of the Hone that ran the check with `node`, with the repository the check measured, both as absolute paths with forward slashes, so it runs as printed from any directory; the lines above show an install at `/work/shop`. Re-run `hone project` after changing the selection or the exceptions.
|
|
93
119
|
|
|
120
|
+
### Package slices
|
|
121
|
+
|
|
122
|
+
A package that runs ESLint from its own folder resolves the `files` of its config against that folder, so spreading the root projection there loses every carve-out written with a root-relative path. `hone project` therefore writes one projection per config root. The repository root gets `disciplines.eslint.mjs` as above. Under the nearest-to-file lookup, each package folder with a tracked `eslint.config.*` is a config root; under the repository-root lookup a package's own config is never loaded, so it gets no slice. Each folder `disciplines.json` lists under `eslintConfigRoots` is a config root under either lookup. Each package config root gets its own `disciplines.eslint.mjs` beside it: the same pieces, imported by a path relative to that folder, and only the records for files under it, with paths relative to it; clause-wide carve-outs go in every slice. Each package config spreads its own slice:
|
|
123
|
+
|
|
124
|
+
```js
|
|
125
|
+
import disciplines from "./disciplines.eslint.mjs";
|
|
126
|
+
|
|
127
|
+
export default [{ files: ["**/*.{ts,tsx,mts,cts}"] }, ...disciplines];
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
A package with no `eslint.config.*` of its own is linted by the nearest config above it, so its records stay in that config's slice. A file is governed by the deepest config root that contains it. A folder holding its own `disciplines.json` gets no slice, and nor does anything under it: its ESLint configuration is not managed from this repository, and nested Hone configurations are not supported yet ([#72](https://github.com/HailsTails/hone/issues/72)). When that folder's own config leaves a carve-out recorded there out of effect, the `mechanism-not-run` line it explains adds the folder, which `--report-output failures-only` prints too. Governing the folder from this repository works today: remove its `disciplines.json`, keep its records here, and `hone project` writes its slice. With package slices also reported, the line points at them:
|
|
131
|
+
|
|
132
|
+
```text
|
|
133
|
+
mechanism-not-run eslint not-included: the eslint configuration leaves the projection out of effect for a file under check; spread the default export of disciplines.eslint.mjs, or of a package's own disciplines.eslint.mjs in that package, last in the configuration that file loads, after every other block (an import placed last without the spread applies nothing), or, where a tool such as sku generates the configuration, last in the configuration the tool takes; the eslint lines under projectionProblems name the package slices involved; fixtures/a hold their own disciplines.json, and nested Hone configurations are not supported yet (https://github.com/HailsTails/hone/issues/72): to govern such a folder from this repository, remove its disciplines.json and keep its records here, then run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop, which writes its slice
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
A config root keeps its slice even where a config above it ignores its folder: a lint run from that folder loads its own config and never reads the ignores above it, so `hone project` writes the same slices from the same inputs every time. `not-applied` for such a package judges each recorded file by its nearest config, the one that lint loads. A repository with only a root config gets exactly the projection it had before.
|
|
137
|
+
|
|
138
|
+
The check reports each package slice under the mechanism, naming the slice: out of date, missing, or, when ESLint resolves each file from its nearest config and a package's carve-outs are not in effect, for example because its config spreads the root projection or nothing instead of its slice, not applied, beside `mechanism-not-run eslint not-included`. A folder listed under `eslintConfigRoots` with no `eslint.config.*` on disk is unconfigured: nothing there can load its slice, so Hone would otherwise say nothing about that package; generate its config before the check runs, as a tool such as sku does on any of its commands:
|
|
139
|
+
|
|
140
|
+
```text
|
|
141
|
+
eslint out-of-date packages/a/disciplines.eslint.mjs: that slice differs from what hone project writes now; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
|
|
142
|
+
eslint missing packages/a/disciplines.eslint.mjs: that slice is not written; run node /work/shop/node_modules/@hailstails/hone/core/check/tool-command.js project --repo /work/shop and commit every disciplines.eslint.mjs it writes
|
|
143
|
+
eslint not-applied packages/a/disciplines.eslint.mjs: the eslint configuration for packages/a leaves records of that slice out of effect; spread the default export of packages/a/disciplines.eslint.mjs last in that package's configuration, in place of any other projection it spreads, or, where a tool such as sku generates the configuration, last in the configuration the tool takes
|
|
144
|
+
eslint unconfigured packages/a/disciplines.eslint.mjs: packages/a has no eslint configuration file on disk, so nothing loads that slice; run the tool that generates it (for sku, sku configure) before the check
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
A slice is not-applied only when a recorded file under check in that package is not excepted; a package with no file exceptions gets the same rules from either projection, so the check is silent there until the package has one.
|
|
148
|
+
|
|
149
|
+
`hone project` removes a tracked `disciplines.eslint.mjs` whose folder is no longer a config root only when its bytes are exactly what Hone would write for that folder now, so a file Hone did not write is never deleted; any other such file is reported `left-in-place`. Under the repository-root lookup no package folder is a config root, so `hone project` removes each package slice it wrote; a package config that still imports its slice then fails to load when someone lints from that package. List such a package under `eslintConfigRoots` to keep its slice, or stop importing it.
|
|
94
150
|
A file carve-out stays in the projection after it is forfeited, so the team's own ESLint run keeps ignoring that file; Hone's check is what fails it, as `forfeited`.
|
|
95
151
|
|
|
96
152
|
Hone's own ESLint run uses only the runner's configuration, with ignores, suppressions and inline configuration off, so nothing in the team's setup can change a finding. Every way the team's setup can weaken a selected rule (a native channel) is reported instead, and only an override that matches an exception record is accepted. The guide has the table.
|
|
@@ -113,15 +169,16 @@ At the repository root. It selects clauses and the mechanism that checks each on
|
|
|
113
169
|
```
|
|
114
170
|
|
|
115
171
|
- `ruleSets` names the repository's own rule sets, each a directory relative to the repository root. The name `hone` is reserved for the rule set shipped with the tool; `hone/CD-15#loops` and `CD-15#loops` are the same address. A rule-set name may not start with `hone-`, and no declared name may be another declared name plus `-<suffix>`.
|
|
116
|
-
- `clauses` maps a clause address to a mechanism id, or to `"not-adopted"`. An address is `[<ruleSet>/]<DisciplineId>#<clauseId>`; no prefix means the `hone` rule set. The mechanism must be one the clause lists.
|
|
172
|
+
- `clauses` maps a clause address to a mechanism id, to `"not-run"` or to `"not-adopted"`. An address is `[<ruleSet>/]<DisciplineId>#<clauseId>`; no prefix means the `hone` rule set. The mechanism must be one the clause lists.
|
|
117
173
|
- Listing a clause adopts its discipline. Mechanical clauses of an adopted discipline that are not listed are reported as uncovered, and fail the run.
|
|
118
|
-
- `"not-
|
|
174
|
+
- `"not-run"` states that the clause is adopted and binds the repository, but its mechanism is not run: the check is not a true measure of the rule's intent here, or cannot work here. The rule is enforced by review. `"not-adopted"` states that the clause does not apply to the repository. Either way the clause is never run and never projected, and its mechanism is not loaded unless another clause uses it. The report lists it under `notRun`, as `<clause> adopted, mechanism not run: enforced by review`, or under `notAdopted`; both are informational, and the run is still a whole assessment. An exception record on it is invalid as `clause-not-run` or `clause-not-adopted`, and `clauseSettings` for it make `disciplines.json` `file-malformed`: remove them. The clause must still exist and be mechanical, in any rule set; a judgement clause is never listed in either state and fails the run as `judgement-clause-listed`. No mechanism may be named `not-run` or `not-adopted`.
|
|
119
175
|
- A judgement clause cannot be selected; it is enforced by review.
|
|
120
176
|
- `eslintConfigLookup`, optional, is `"nearest-to-file"` or `"repository-root"` and says which `eslint.config.*` the team's own ESLint run applies to a file; see [Runtime](#runtime). Leave it out to let Hone detect it.
|
|
177
|
+
- `eslintConfigRoots`, optional, lists repository folders that get their own projection slice under either lookup although they track no `eslint.config.*`, such as a package whose config a tool generates and ignores; see [Package slices](#package-slices). Globs are refused. Each entry must be a folder git tracks files under outside every `exclude` path, spelled exactly as git spells it; any other entry stops the run before anything is checked or written, as `load failure: config-root-untracked <folder>:` with what to fix.
|
|
121
178
|
- `fileExceptionWhyChains`, optional, is `"required"` (the default) or `"optional"`. `"optional"` lets an `authorised-location` or `file-carve-out` entry give only its `reason`; see [discipline-exceptions.json](#discipline-exceptionsjson).
|
|
122
179
|
- `reportOutput`, optional, is `"full"` (the default), `"failures-only"`, `"counts"` or `"verdict-only"`: the repository's default for how much of the report the check prints. `--report-output` overrides it for one run; see [Commands](#commands).
|
|
123
|
-
- `clauseSettings`, optional, maps a selected clause address to an object of that clause's settings, for a clause whose
|
|
124
|
-
- `assessment`, optional, says which run assesses each concern. `forfeiture
|
|
180
|
+
- `clauseSettings`, optional, maps a selected clause address to an object of that clause's settings, for a clause whose CHECKS.md lists settings. Each key must be one the clause's piece declares, and its value must be the same JSON kind as the declared default and, where the piece lists choices, one of them; the value replaces the default. Anything else makes `disciplines.json` malformed, naming the clause, the key and what is accepted: settings for a clause the file does not select or names twice, for a clause that takes none, under an undeclared key, or of the wrong kind or choice.
|
|
181
|
+
- `assessment`, optional, says which run assesses each concern. Its one key, `forfeiture`, is `"this-run"` (the default) or `"elsewhere"`; `--forfeiture` overrides it for one run; see [Commands](#commands). `waivedClauses`, which earlier releases accepted, is removed: it makes `disciplines.json` `file-malformed`, naming the clause states that replace it; see [MIGRATING.md](MIGRATING.md#12-moving-off-waivedclauses). Any other key makes it `file-malformed`, naming the key as not available in this version.
|
|
125
182
|
- `exclude`, optional, lists repository folders or exact files that no mechanism checks. A folder entry covers everything under it. Globs are refused: an entry containing `*` makes `disciplines.json` malformed. The report lists the active entries under `excluded`. Exclude Hone's own install when it is vendored inside the repository.
|
|
126
183
|
|
|
127
184
|
## discipline-exceptions.json
|
|
@@ -141,7 +198,8 @@ At the repository root; absent means no exceptions. Each entry names a selected
|
|
|
141
198
|
|
|
142
199
|
- An `authorised-location` says the clause does not apply to that file.
|
|
143
200
|
- A `file-carve-out` is debt in one file. It is forfeited once the file is touched.
|
|
144
|
-
- A `clause-wide-carve-out` exempts the clause everywhere.
|
|
201
|
+
- A `clause-wide-carve-out` exempts the clause's findings everywhere. It does not hold an inline exception.
|
|
202
|
+
- An inline exception, an `eslint-disable` comment naming a selected rule or no rule, or a `@ts-expect-error`, `@ts-ignore` or `@ts-nocheck` directive under `CD-2#cast-expressions`, is held only by an `authorised-location` or `file-carve-out` on its clause and file. A comment naming no rule escapes every selected ESLint clause and needs one per clause. Without a record it is listed under `unrecorded` and fails the run. A lint-script option that weakens the whole run, such as `--rule`, `--suppress-all` or `-c` naming another config, cannot be recorded.
|
|
145
203
|
- Every entry needs a `whyChain` (an `authorised-location` or `file-carve-out` may leave it out when `fileExceptionWhyChains` is `"optional"`; see below) that follows the [why-chain contract](docs/why-chain-contract.md): exactly five `{ "why", "because", "evidence" }` steps chained cause to cause, then `rootCause`, `rootCheck`, `readback` and `owner`. The contract lists what Hone refuses and what review still judges:
|
|
146
204
|
|
|
147
205
|
```json
|
|
@@ -174,14 +232,15 @@ With the ESLint mechanism selected, a packaged install's projection imports each
|
|
|
174
232
|
|
|
175
233
|
## Public type entries
|
|
176
234
|
|
|
177
|
-
The package has
|
|
235
|
+
The package has three public entries for TypeScript. `@hailstails/hone/rule-set` holds types only, so importing it adds no code to a build; import it with `import type`. `@hailstails/hone/audit` adds one value to its types, and `@hailstails/hone/testing` is for a team's own tests.
|
|
178
236
|
|
|
179
237
|
| Entry | Status | What it is for |
|
|
180
238
|
| --- | --- | --- |
|
|
181
239
|
| `@hailstails/hone/rule-set` | Stable | The shapes of `discipline.json`, `piece.json` and an ESLint piece's `settings`, for a team writing its own rule set. Identifiers and paths are plain strings: Hone checks them when it reads the files. |
|
|
182
|
-
| `@hailstails/hone/audit` | Experimental | The types for writing an audit walker piece, `WalkerPiece` and what it needs, including `PieceFailure`, the failures a piece may return. Clause addresses and file paths reach a piece from Hone, already checked, and a piece passes them back unchanged. It may change in a minor release. |
|
|
240
|
+
| `@hailstails/hone/audit` | Experimental | The types for writing an audit walker piece, `WalkerPiece` and what it needs, including `PieceFailure`, the failures a piece may return. Clause addresses and file paths reach a piece from Hone, already checked, and a piece passes them back unchanged. Its one value, `folderScope`, tells a piece whether a file sits in a generated folder. It may change in a minor release. |
|
|
241
|
+
| `@hailstails/hone/testing` | Experimental | Runs a team audit clause's `cases` through its piece with the installed audit runner (`clauseConformanceOf`), and hands a test the clause bound as `hone check` binds it (`clauseUnderTestOf`) and a checked file path (`repoPathOf`). Hone does not run these tests itself. It may change in a minor release. |
|
|
183
242
|
|
|
184
|
-
|
|
243
|
+
Each resolves with `moduleResolution` `"nodenext"` or `"bundler"`. `install-proof` type-checks a team piece and rule set against them, and checks that a wrongly typed field fails: on TypeScript 4.8.4 from an ES module with `"nodenext"` (4.8 has no `"bundler"`), and on 6.0.3 from an ES module with both and from a CommonJS file. A CommonJS file (`.cts`, or `.ts` in a package that is not `"type": "module"`) can import these types on TypeScript 5.8 or later with `module` `"nodenext"`. With `module` `"node16"`, and on TypeScript 5.3 to 5.7, the import needs `with { "resolution-mode": "import" }`, and older versions reject it. These CommonJS figures were checked once by hand, on 5.8.2, 5.3.3 and 6.0.3 with `"node16"`; `install-proof` checks only the 6.0.3 CommonJS case with `"nodenext"`. `@hailstails/hone/audit` names TypeScript's own syntax types, so it needs the `typescript` the repository already installs as a peer. No other path in the package is a public TypeScript entry.
|
|
185
244
|
|
|
186
245
|
## Runtime
|
|
187
246
|
|
|
@@ -193,9 +252,9 @@ Both resolve with `moduleResolution` `"nodenext"` or `"bundler"`. `install-proof
|
|
|
193
252
|
|
|
194
253
|
Hone loads the toolchain by Node's own resolution, upward from the install directory, which is the same resolution the pieces' plugin modules get when the team's ESLint loads the projection. Hone's query of the team's configuration, its governance run and the pieces therefore all use one copy, the repository's. Keep the toolchain resolvable from the repository root: declare it in the root `package.json` (in a pnpm workspace, `pnpm add -Dw`). A package may install a different ESLint for its own lint script; Hone's verdict still comes from the root's, its governance behaviour is the same on either supported line, and the pieces that wrap native rules wrap the root's copies there too. Hone's tests run the governance path and every piece's shared cases on four ESLint lines, 9.28.0 and 10.0.0 with typescript-eslint 8.56.0 and 9.39.5 and 10.11.0 with 8.71.2, and the audit pieces' shared cases on TypeScript 4.8.4 and 6.0.3; the in-process consumer fixtures run on ESLint 10.11.0, and `install-proof` runs real consumers on each floor.
|
|
195
254
|
|
|
196
|
-
A peer that is missing, cannot load, or is outside its range stops the mechanism before any piece loads, with one line such as `load failure: runner-failed eslint toolchain-unavailable eslint found not installed, supported ^9.28.0 || ^10.0.0: add a supported version to the devDependencies of the repository root`. A `typescript` that is not installed at all is reported the same way, with the line saying that `typescript` is a required peer of `@hailstails/hone` and the install is incomplete, since a supported install always has it; one that is installed but out of range or unloadable gets the plain line. A peer that resolves from inside the installed package, such as an `eslint` left in `node_modules/@hailstails/hone/node_modules`, stops it as `toolchain-shadowed`, naming where it resolved and the folder to delete before reinstalling core. A source checkout of Hone is its own development install, so its development toolchain in its own `node_modules` is not a shadow.
|
|
255
|
+
A peer that is missing, cannot load, or is outside its range stops the mechanism before any piece loads, with one line such as `load failure: runner-failed eslint toolchain-unavailable eslint found not installed, supported ^9.28.0 || ^10.0.0: add a supported version to the devDependencies of the repository root`. The line names every peer of that mechanism that is unavailable, separated by `; `, and then asks for a supported version of each, so one install fixes them all. A `typescript` that is not installed at all is reported the same way, with the line saying that `typescript` is a required peer of `@hailstails/hone` and the install is incomplete, since a supported install always has it; one that is installed but out of range or unloadable gets the plain line. A peer that resolves from inside the installed package, such as an `eslint` left in `node_modules/@hailstails/hone/node_modules`, stops it as `toolchain-shadowed`, naming where it resolved and the folder to delete before reinstalling core. A source checkout of Hone is its own development install, so its development toolchain in its own `node_modules` is not a shadow.
|
|
197
256
|
|
|
198
|
-
A repository can hold one `eslint.config.*` at its root or one per package. Hone resolves the team's configuration the way the team's own ESLint run does. ESLint 10, and ESLint 9 started with `--flag v10_config_lookup_from_file` (or `unstable_config_lookup_from_file`), use the `eslint.config.*` nearest each checked file. Plain ESLint 9 uses only the one in the directory it runs from, so for a repository whose `eslint` resolves to 9.x at `node_modules/eslint` and whose lint scripts carry no such flag, Hone reads the root `eslint.config.*` for every file, and fails the run as `team-config-unloadable` if there is none. When Hone cannot read an installed `eslint` at the repository root it assumes the nearest-to-file lookup. Each config that applies to a file must spread the projection. Detection cannot see how a task runner starts ESLint, so `disciplines.json` can state the lookup: `"eslintConfigLookup": "nearest-to-file"` or `"repository-root"`, which overrides detection. Both lookups are tested against monorepo fixtures with a config per package.
|
|
257
|
+
A repository can hold one `eslint.config.*` at its root or one per package. Hone resolves the team's configuration the way the team's own ESLint run does. ESLint 10, and ESLint 9 started with `--flag v10_config_lookup_from_file` (or `unstable_config_lookup_from_file`), use the `eslint.config.*` nearest each checked file. Plain ESLint 9 uses only the one in the directory it runs from, so for a repository whose `eslint` resolves to 9.x at `node_modules/eslint` and whose lint scripts carry no such flag, Hone reads the root `eslint.config.*` for every file, and fails the run as `team-config-unloadable` if there is none. When Hone cannot read an installed `eslint` at the repository root it assumes the nearest-to-file lookup. Each config that applies to a file must spread its projection: the root config the root projection, each package config its own slice; see [Package slices](#package-slices). A config that fails to load stops the run as `team-config-unloadable`, naming the config, the checked file it applies to and ESLint's message, then the next step: fix that config. Only if its folder holds nothing Hone should check, add it to `exclude` in `disciplines.json` instead. A broken config in a folder that the repository's own ESLint never enters does not stop the run. Before failing, Hone asks the config that governs that folder, and each config above it up to the root, whether it really ignores both that folder and the file; a file that no `files` block matches is not taken for an ignored one. If one does, the file is treated like any other file the team's ESLint ignores and reported as an `ignore` native exception. Hone asks about a folder through a file inside it, so one gap remains: an ignore that matches every entry directly inside the folder but not the folder itself, such as `gen/*`, counts as ignoring `gen`, and Hone reports its files as ignored where the team's `eslint .` still loads the broken `gen/eslint.config.*` and fails. A file that no `eslint.config.*` applies to stops the run the same way, and the next step is to create one at the repository root that spreads the projection, as [ADOPTING.md](ADOPTING.md) step 4a shows. Detection cannot see how a task runner starts ESLint, so `disciplines.json` can state the lookup: `"eslintConfigLookup": "nearest-to-file"` or `"repository-root"`, which overrides detection. Both lookups are tested against monorepo fixtures with a config per package.
|
|
199
258
|
|
|
200
259
|
## Compatibility
|
|
201
260
|
|
|
@@ -203,11 +262,16 @@ Hone's version numbers follow semantic versioning under these rules:
|
|
|
203
262
|
|
|
204
263
|
- A new or tightened check ships off by default in a minor release and becomes a default only in a major release.
|
|
205
264
|
- A change to the ESLint config that `hone project` generates, which an adopter must regenerate, is a minor release, with a clear message telling the adopter to regenerate: its changelog entry says to run `hone project` and commit the result, and until then the check reports the projection `out-of-date`.
|
|
206
|
-
-
|
|
265
|
+
- Renaming or removing a clause address, a config key in `disciplines.json` or `discipline-exceptions.json`, or a CLI flag, or changing what one means, is a major release. Adding one with a safe default is not.
|
|
266
|
+
- A change to what [the output contract](docs/output-contract.md) says a tool can parse is a major release: the command and option names, the exit codes and streams, the report's sections, outputs and verdict lines, the load failure kinds, and each line's leading fields up to its first value that may hold a space. What it marks not stable, such as the help text, the wording of `arguments-invalid` and `readFirst` lines and the repair text after a load failure's values, may change in a minor release, and a minor release may add a section, a kind of line or an option.
|
|
207
267
|
- A breaking change to a type in `@hailstails/hone/rule-set` is a major release. `@hailstails/hone/audit` is experimental: its types may change in a minor release until it is marked stable.
|
|
208
268
|
- Before the first stable release, a change that would need a major release ships in a minor release instead.
|
|
209
269
|
- A pre-release previews the release it is numbered towards and is published under the `next` dist-tag. A change of any size can land between two pre-releases of the same release, and the changelog lists it.
|
|
210
270
|
|
|
271
|
+
`disciplines.json` and `discipline-exceptions.json` follow the same rules. A new key with a safe default, where nothing changes for an adopter who does not set it, is not breaking and can arrive in a minor release. A new required key with no safe default is breaking, and so is a change that makes a file that loads today stop loading or mean something else; both wait for a major release.
|
|
272
|
+
|
|
273
|
+
A clause that accepts `audit` keeps accepting it: `audit` is never removed from the mechanisms such a clause lists, so a selection that names `audit` for it keeps loading. A clause can only gain mechanisms.
|
|
274
|
+
|
|
211
275
|
Each release's changes are listed in [the changelog](https://github.com/HailsTails/hone/blob/main/CHANGELOG.md) in the repository.
|
|
212
276
|
|
|
213
277
|
## Known limits
|
|
@@ -245,7 +309,7 @@ This repository is self-contained: it holds its own configuration and its own lo
|
|
|
245
309
|
| `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` |
|
|
246
310
|
| `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 |
|
|
247
311
|
| `self-check` | `node scripts/self-check.ts check --repo .`: runs Hone's own check on this repository with `disciplines.json` and `discipline-exceptions.json`; pass `--base-revision <rev>` after the script name. See [Core's check on itself](#hones-check-on-itself) |
|
|
248
|
-
| `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball and installs it
|
|
312
|
+
| `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball and installs it with pnpm into six CommonJS consumers in an OS temporary directory outside the working tree, each copied from its folder under `tests/test-fixtures/consumer-proof/`, which holds only what that consumer's action needs. Each consumer exists for one thing only an installed package shows. The audit consumer, on TypeScript 4.8.4, runs `check` through the installed bin and expects its finding. The ESLint 9.28.0 and 10.0.0 consumers run `project`, expect a projection importing the piece by package name, and expect its finding from `check`. The consumer without `eslint` expects `toolchain-unavailable`. These four run with type stripping off. The team consumer is the example [docs/extending.md](docs/extending.md) follows. On TypeScript 4.8.4 it type-checks a wrong team piece, rule set and ESLint piece settings with its own `tsc`, as described under Public type entries, and expects the three errors. On the development versions, TypeScript 6.0.3, ESLint 10.11.0 and typescript-eslint 8.71.2, it also type-checks its rule set under `nodenext` and `bundler` and a CommonJS file, then runs both commands with type stripping on: its `.ts` pieces load through the installed package and give one finding from each mechanism under the team's `acme/` prefix. Its root says `"type": "commonjs"`, the hard case, so its rule set carries its own `"type": "module"` `package.json`. Each consumer declares its toolchain at exact pins in its own `devDependencies`, as an adopter does: TypeScript 4.8.4 alone for the audit consumer, the consumer without `eslint` and the team consumer on 4.8.4; ESLint 9.28.0 or 10.0.0 with typescript-eslint 8.56.0 and TypeScript 4.8.4 for the two ESLint consumers; and the development versions for the team consumer. It declares the tarball beside them, pins the pnpm version this repository's `package.json` pins, and waits this repository's `minimumReleaseAge`. pnpm's store shares each toolchain package between consumers, and the proof prints where pnpm put the installed package and expects the report to name its pages there. A pass once a violation is removed, rule-set naming, plugin namespaces, settings overrides and per-package ESLint configs are proven by unit and in-process tests instead. The temporary directory is removed afterwards |
|
|
249
313
|
| `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) |
|
|
250
314
|
| `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) |
|
|
251
315
|
|
|
@@ -267,19 +331,32 @@ To prepare a release, create a new branch at the tip of `main` and run `pnpm run
|
|
|
267
331
|
- On a pre-release, a change no larger than the one the pre-release is numbered towards moves to the next pre-release number; a larger one starts the next version's first pre-release. On a stable release, the change increments the version.
|
|
268
332
|
- The release stays on the latest tag's channel. Pass `stable` to finish a pre-release as its stable version, or `pre-release` to start a pre-release line from a stable one.
|
|
269
333
|
|
|
270
|
-
It then writes a section for that version at the top of `CHANGELOG.md`, grouping the subjects under Breaking changes, Features, Fixes and Other changes, and sets `version` in `package.json`. It refuses, changing nothing, when no subject follows the tag, when a merge commit does, when `package.json` is not at the tag's version, or when the changelog already has the new version. A subject that is not a Conventional Commits subject is named on standard error and counted as a patch under Other changes, or as a major under Breaking changes when its message has a breaking footer, so check its place before opening the pull request. If writing the second file fails, it restores the first. The script only edits those two files: it never commits, tags, pushes or publishes. Open the release pull request with the title `chore(release): <version>`.
|
|
334
|
+
It then writes a section for that version at the top of `CHANGELOG.md`, grouping the subjects under Breaking changes, Features, Fixes and Other changes, and sets `version` in `package.json`. It refuses, changing nothing, when no subject follows the tag, when a merge commit does, when `package.json` is not at the tag's version, or when the changelog already has the new version. A subject that is not a Conventional Commits subject is named on standard error and counted as a patch under Other changes, or as a major under Breaking changes when its message has a breaking footer, so check its place before opening the pull request. If writing the second file fails, it restores the first. The script only edits those two files: it never commits, tags, pushes or publishes. Open the release pull request with the title `chore(release): <version>`. Merging it is the release: no tag is pushed by hand and nothing is run after the merge. `.github/CODEOWNERS` makes the owner, `@HailsTails`, the code owner of `package.json`, `CHANGELOG.md`, `.github/workflows/`, `.github/CODEOWNERS` itself, the `scripts/release-*` scripts, `scripts/published-manifest.ts`, which writes the published `package.json`, `core/values/tool-identity.ts`, which names the package and its repository, and `pnpm-workspace.yaml`, which holds the `minimumReleaseAge` the release job installs under, so a release pull request, or any change to how a release is made, needs her code-owner approval before it can merge. That also covers every change to `package.json`, dependency updates included, since the version a release is triggered by lives there.
|
|
271
335
|
|
|
272
336
|
`CHANGELOG.md` names versions, so it stays in the repository and out of the package; the shipped pages link to it on GitHub.
|
|
273
337
|
|
|
274
|
-
|
|
338
|
+
The release workflow, `release.yml`, starts on a push to `main` that changes `package.json`. Its first job runs `scripts/release-state-command.ts` with the pushed commit, `package.json` as pushed, `package.json` as it was before the push, and the `v*` tags `git ls-remote` lists on the repository. It prints the tag `v<version>` for the pushed version and one of three states. `version-unchanged`: the push leaves the version as it was. `already-released`: the tag already names the pushed commit, as when a finished release run is run again. `unreleased`: the push changes the version and no tag has its name. It refuses, failing the run and printing no state, when either `package.json` has no readable version, when the pushed version is not `major.minor.patch` with an optional `-<identifier>.<number>`, when it cannot read the listed tags, or when the version's tag already names a different commit. That last refusal is how a `v<version>` tag made by hand, or a version set back to one released earlier, shows up instead of silently passing for a release; delete the tag if the workflow did not make it, or prepare a new version. Only `unreleased` runs the rest of the workflow; the other two end the run there, successfully, with the release and staging jobs skipped. A push that leaves `package.json` alone does not start the workflow at all.
|
|
339
|
+
|
|
340
|
+
For an unreleased version, the release job runs `check`, `package-determinism` and `install-proof` on the pushed commit, packs the tarball with `pack-package`, records the tarball's name and SHA-256 as outputs of the release job, and creates a GitHub release for `v<version>` at that commit with the tarball attached. Creating the release creates the tag: the tag is the record that the version is released. `gh release create` creates that release as a draft, uploads the tarball and only then publishes it, which is when the tag is made, so with immutable releases on, the tarball is attached before the release's assets and tag become immutable, and a run that fails before then leaves no tag. When a tag of that name already exists, GitHub attaches the release to it and ignores the commit asked for, so the release job then reads the tag back from the repository with `scripts/release-tag-command.ts` and fails unless it names the pushed commit. A tag made by hand on another commit while the job ran therefore stops the run before anything is staged on npm; the failure says to delete that GitHub release and release a new version with a new release pull request, since re-running would find the tag on the wrong commit and refuse. The `release tags` ruleset leaves creating `v*` tags open, so the workflow's own token can make the tag, and restricts updating and deleting them. A tag or release made with the workflow's own token starts no other workflow, and no workflow here starts on a tag. `scripts/release-text-command.ts` prints the release's title from the identity and the tag, its notes, which name the npm install command under its dist-tag and the attached tarball but no version, and its dist-tag: `next` when the version has a pre-release part such as `-pre.1` before any `+` build metadata, otherwise `latest`. The release is marked as a pre-release exactly when its dist-tag is `next`, and the step stops if any of the three cannot be printed. The release does not wait on npm.
|
|
275
341
|
|
|
276
342
|
A version reaches npm in four steps:
|
|
277
343
|
|
|
278
|
-
1. The
|
|
344
|
+
1. The merged release pull request creates the GitHub release and its tag, as above.
|
|
279
345
|
2. A second job downloads that release's tarball, refuses it unless its SHA-256 equals the one the release job recorded in the same run, and stages it with `npm stage publish` under the release job's dist-tag. A staged version is held by npm and cannot be installed. Its dist-tag is fixed when it is staged.
|
|
280
346
|
3. The npm owner approves it, on npmjs.com under `@hailstails/hone`, Staged Packages, or with `npm stage approve <stage-id>`. Approval needs the owner's two-factor sign-in, so CI cannot approve.
|
|
281
347
|
4. The version is published under its dist-tag and installable.
|
|
282
348
|
|
|
283
|
-
The second job runs in the GitHub environment `npm`, which accepts only `
|
|
349
|
+
The second job runs in the GitHub environment `npm`, which accepts only the `main` branch, and only when the repository variable `NPM_PUBLISH` is `enabled`; with any other value, or none, it is skipped and the release is unaffected. It authenticates by npm trusted publishing, so no npm token is stored. The trusted publisher is saved on npmjs.com under `@hailstails/hone`, Settings, Trusted publishing, GitHub Actions, as: user `HailsTails`, repository `hone`, workflow filename `release.yml`, environment `npm`, with both allowed actions, "npm publish" and "npm dist-tag", unticked, so CI can only stage. The published `package.json` carries `repository`, `homepage` and `bugs` from the identity's repository, which trusted publishing matches against this repository, and `publishConfig.access` `public`, because npm otherwise publishes a scoped package as restricted. `build-package` fails if a shipped page names a versioned tarball of the package, at any version, or the version in `package.json`, with or without a leading `v`, so a page cannot name the current version and go stale on the next release.
|
|
350
|
+
|
|
351
|
+
npm does not check a trusted publisher when it is saved, and one that has not completed a successful publish within 2 days of being added expires and can no longer be used or edited. npm's documentation does not say whether a staged publish counts as that first publish, so save the trusted publisher only just before merging a release pull request, and approve the staged version within the same 2 days. A re-run of an older release run stages a version npm already has, so it cannot complete that first publish.
|
|
352
|
+
|
|
353
|
+
Re-running a release run never releases a version twice. Re-running all its jobs runs the first job again, which finds the tag and ends the run. When the release job failed before publishing the release, there is no tag, so re-running the run releases that same commit. When only the staging job failed, re-run the failed jobs: the staging job runs again with the outputs of the release job it followed, and npm refuses a version it already holds.
|
|
354
|
+
|
|
355
|
+
The release relies on these repository settings, which only the owner changes:
|
|
356
|
+
|
|
357
|
+
- The `main` ruleset requires a pull request with one approval, squash merging only, and "Require review from Code Owners" on, so `.github/CODEOWNERS` holds.
|
|
358
|
+
- The `release tags` ruleset restricts updating and deleting `v*` tags but not creating them, so the release job's own token can create the tag. A tag publishes nothing: no workflow starts on a tag, and the environment `npm` does not accept one.
|
|
359
|
+
- The environment `npm` accepts only the `main` branch.
|
|
360
|
+
- The repository variable `NPM_PUBLISH` is `enabled` for the staging job to run.
|
|
284
361
|
|
|
285
|
-
|
|
362
|
+
Merging the release pull request does not make the version installable: staging on npm still waits for the owner's approval there, as step 3 above says.
|
package/THIRD-PARTY-NOTICES.md
CHANGED
package/api/audit.d.ts
CHANGED
|
@@ -9,3 +9,6 @@ export type { RepoPath } from "../core/values/repo-path-types.js";
|
|
|
9
9
|
export type { Result } from "../core/values/result.js";
|
|
10
10
|
export type { CommentRange, SyntaxApi, SyntaxNode, SyntaxTree } from "../mechanisms/audit/runner/typescript-parse.js";
|
|
11
11
|
export type { PieceHit, PreparedFileCheck, PreparedWalkerCheck, SourceObservers, WalkerFile, WalkerPiece, WalkerRepository } from "../mechanisms/audit/runner/walker-piece.js";
|
|
12
|
+
export declare const folderScope: (request: {
|
|
13
|
+
readonly file: string;
|
|
14
|
+
}) => "generated" | "authored";
|
package/api/audit.js
ADDED
package/api/rule-set.js
ADDED
|
File without changes
|
package/api/testing.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ClauseConformanceOf, ClauseUnderTestOf, RepoPathOf } from "../core/conformance/conformance-testing-types.js";
|
|
2
|
+
export type { CaseUnderTest, ClauseRequest, ClauseUnderTest, ConformanceFailure, ConformanceSetupFailure, ConformanceSetupFailureKind, } from "../core/conformance/conformance-testing-types.js";
|
|
3
|
+
export declare const clauseConformanceOf: ClauseConformanceOf;
|
|
4
|
+
export declare const clauseUnderTestOf: ClauseUnderTestOf;
|
|
5
|
+
export declare const repoPathOf: RepoPathOf;
|