@hailstails/hone 0.1.0-pre.4 → 0.1.0-pre.5
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 +37 -12
- package/MIGRATING.md +4 -4
- package/README.md +35 -16
- package/api/audit.d.ts +3 -2
- package/api/rule-set.d.ts +2 -4
- package/chunks/chunk-3HFJHJDO.js +53 -0
- package/chunks/chunk-7OVV6NEU.js +22 -0
- package/chunks/chunk-7PVPPH4C.js +13 -0
- package/chunks/chunk-HVABJ7T4.js +361 -0
- package/chunks/{chunk-BX6QHLSZ.js → chunk-IIMK5BCL.js} +57 -4
- package/chunks/{chunk-FOAGAYXM.js → chunk-SWPCKTJV.js} +44 -397
- package/chunks/{chunk-RZA3OVOO.js → chunk-VUG3DJHN.js} +5 -3
- package/chunks/{chunk-EYCRDEXX.js → chunk-YBWVUDIG.js} +2 -13
- package/core/check/tool-command.js +356 -81
- package/core/mechanism-port/piece-failure-types.d.ts +14 -0
- package/core/mechanism-port/runner-module-types.d.ts +5 -0
- package/core/rule-set-reader/authored-rule-set-types.d.ts +48 -0
- package/core/values/json-value.d.ts +3 -0
- package/docs/adding-a-discipline-or-mechanism.md +6 -3
- package/docs/extending.md +357 -0
- package/mechanisms/audit/CD-1/any-cast.js +9 -37
- package/mechanisms/audit/CD-19/import-boundaries.js +79 -68
- package/mechanisms/audit/CD-19/piece.json +5 -0
- package/mechanisms/audit/CD-2/cast-expressions.js +14 -37
- package/mechanisms/audit/CD-5/comments-directives.js +137 -55
- package/mechanisms/audit/CD-5/piece.json +7 -0
- package/mechanisms/audit/runner/README.md +1 -0
- package/mechanisms/audit/runner/runner.js +10 -6
- package/mechanisms/audit/runner/typescript-parse.d.ts +6 -0
- package/mechanisms/audit/runner/walker-piece.d.ts +5 -5
- package/mechanisms/eslint/runner/README.md +1 -1
- package/mechanisms/eslint/runner/runner.js +85 -35
- package/package.json +4 -4
- package/rules/CD-1/README.md +5 -5
- package/rules/CD-1/discipline.json +16 -6
- package/rules/CD-19/README.md +13 -3
- package/rules/CD-19/discipline.json +6 -8
- package/rules/CD-2/README.md +8 -4
- package/rules/CD-2/discipline.json +25 -7
- package/rules/CD-5/README.md +17 -5
- package/rules/CD-5/discipline.json +66 -0
- package/core/mechanism-port/runner-failure-types.d.ts +0 -38
- package/core/rule-set-reader/rule-set-types.d.ts +0 -41
- /package/api/{audit.js → audit.mjs} +0 -0
- /package/api/{rule-set.js → rule-set.mjs} +0 -0
package/ADOPTING.md
CHANGED
|
@@ -64,7 +64,7 @@ Hone runs on the toolchain the repository already uses, which the package declar
|
|
|
64
64
|
| Package | Needed for | Range |
|
|
65
65
|
| --- | --- | --- |
|
|
66
66
|
| `typescript` | any `audit` clause | `>=4.8.4 <7.0.0` |
|
|
67
|
-
| `eslint` | any `eslint` clause | `^9.
|
|
67
|
+
| `eslint` | any `eslint` clause | `^9.28.0 \|\| ^10.0.0` |
|
|
68
68
|
| `@typescript-eslint/parser` | any `eslint` clause | `^8.56.0` |
|
|
69
69
|
| `@typescript-eslint/eslint-plugin` | any `eslint` clause | `^8.56.0` |
|
|
70
70
|
|
|
@@ -98,11 +98,14 @@ Create `<repo>/disciplines.json`. Map every clause you adopt to the mechanism th
|
|
|
98
98
|
}
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
- `clauses` keys are clause addresses from the rules pages; the value is a mechanism the clause's rules page lists, `audit` or `eslint`.
|
|
101
|
+
- `clauses` keys are clause addresses from the rules pages; the value is a mechanism the clause's rules page lists, `audit` or `eslint`, or `"not-adopted"`.
|
|
102
102
|
- Selecting one clause of a discipline adopts the whole discipline: any of its other mechanical clauses you leave out are reported as `uncovered` and fail the run. CD-3 has seven clauses; select all seven or none.
|
|
103
|
-
- A discipline may span mechanisms; adopt every mechanical clause through the mechanism that has it, or the discipline reports the rest uncovered. CD-14, for example, checks `class-syntax` through `audit` or `eslint` but `static-only-class` only through `eslint`, so adopting CD-14 means adopting the ESLint mechanism for at least that clause; see [README.md](README.md#adopting-the-eslint-mechanism). To
|
|
103
|
+
- A discipline may span mechanisms; adopt every mechanical clause through the mechanism that has it, or the discipline reports the rest uncovered. CD-14, for example, checks `class-syntax` through `audit` or `eslint` but `static-only-class` only through `eslint`, so adopting CD-14 means adopting the ESLint mechanism for at least that clause; see [README.md](README.md#adopting-the-eslint-mechanism). To leave such a clause out, list it as `"not-adopted"`; to defer it as tracked debt, list it with its mechanism and record a `clause-wide-carve-out` for it (step 7).
|
|
104
|
+
- To adopt a discipline through one mechanism only, for example CD-6's `identifier-names` through `audit` without its ESLint-only `naming-convention`, list the clause you do not adopt as `"not-adopted"`: `"CD-6#identifier-names": "audit", "CD-6#naming-convention": "not-adopted"`. That clause is never run and never projected, not even as `"off"`, so this adopter needs no ESLint installed; the report lists it under `notAdopted` and the run stays a whole assessment. No exception record is needed, and one on that clause is invalid as `clause-not-adopted`.
|
|
105
|
+
- To keep a clause adopted but defer it as tracked debt with an owner, select it, record a `clause-wide-carve-out` with its why-chain, and set `"assessment": { "waivedClauses": "not-run" }` in `disciplines.json`. The waived clause is then never run, and a mechanism left with nothing to run is not loaded, so this adopter needs no ESLint installed. `hone project` still writes the waived clause's `"off"` block to the projection, and whenever ESLint runs for another clause the projection is still checked against every selected clause. The trade: in those runs the waiver is not judged `stale`, so it stays in force until you remove it, and every report says so in its `assessment` section.
|
|
104
106
|
- `exclude` lists folders or exact files, as repository paths with forward slashes; an entry containing `*` is refused, because globs are not supported. A folder entry excludes everything under it. Use it for generated or third-party code. `node_modules`, `dist`, `build`, `coverage`, `.git` and a top-level `vendor` folder are skipped already.
|
|
105
|
-
- `
|
|
107
|
+
- `clauseSettings` gives a clause the settings its rules page lists under Settings, keyed by clause address. CD-19, for example, flags only imports of the packages you list in its `confinedPackages`; CD-5's `trackerPatterns` narrows tracked references to your tracker's format. See [README.md](README.md#disciplinesjson).
|
|
108
|
+
- `ruleSets` stays `{}` unless you write disciplines of your own; see [docs/extending.md](docs/extending.md).
|
|
106
109
|
|
|
107
110
|
Every clause address Hone ships:
|
|
108
111
|
|
|
@@ -156,7 +159,7 @@ In a monorepo, every `eslint.config.*` that applies to checked files spreads the
|
|
|
156
159
|
{ "eslintConfigLookup": "nearest-to-file" }
|
|
157
160
|
```
|
|
158
161
|
|
|
159
|
-
Use `"nearest-to-file"` when ESLint runs per package, with ESLint 10, or with ESLint 9 and `--flag v10_config_lookup_from_file` (on 9.
|
|
162
|
+
Use `"nearest-to-file"` when ESLint runs per package, with ESLint 10, or with ESLint 9 and `--flag v10_config_lookup_from_file` (on 9.28 and 9.29, `--flag unstable_config_lookup_from_file`). Use `"repository-root"` for one ESLint 9 run from the repository root, whose root `eslint.config.*` then applies to every file. To confirm the setting, lint a package file the way the team does (for example `pnpm exec eslint packages/a/src/x.ts` from where the lint script runs) and check that it reports the same finding the Hone check lists for that file.
|
|
160
163
|
|
|
161
164
|
Commit both files. Hone's check reads this configuration and fails if the projection is missing, not in effect, or out of date, so re-run `hone:project` whenever `disciplines.json` or `discipline-exceptions.json` changes or Hone is updated. The projection imports each piece from the package by name, for example `@hailstails/hone/mechanisms/eslint/CD-14/cd14/cd14.eslint-plugin.js`, so the repository's ESLint must resolve `@hailstails/hone` from the repository root. Hone's own ESLint run uses the repository's root `eslint` from step 2, the same copy the projection's pieces load; its verdict is the same on 9.x and 10.x. [README.md](README.md#adopting-the-eslint-mechanism) has the details.
|
|
162
165
|
|
|
@@ -180,7 +183,27 @@ In CI, pass the branch's base so that debt recorded per file is forfeited once t
|
|
|
180
183
|
npm run --silent hone:check -- --base-revision origin/main
|
|
181
184
|
```
|
|
182
185
|
|
|
183
|
-
Add the command to the repository's existing validation script, and run that
|
|
186
|
+
Add the command to the repository's existing validation script, and run that script in CI and in any pre-push hook the repository already has, so the check runs wherever the other checks run.
|
|
187
|
+
|
|
188
|
+
To assess decay at push only, for example so that a hotfix in a carved file is not blocked in CI, set `"assessment": { "forfeiture": "elsewhere" }` in `disciplines.json`. CI and the pre-push hook then run different commands. The pre-push hook assesses decay for its run:
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
npm run --silent hone:check -- --forfeiture this-run --base-revision origin/main
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
CI leaves decay to the hook. A repository with no imported records and no legacy-chain records runs the check with no base revision:
|
|
195
|
+
|
|
196
|
+
```bash
|
|
197
|
+
npm run --silent hone:check
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
A repository with imported records (`provenance`) or legacy-chain records still needs a base revision in CI, because those records are checked against it; without one the report lists `import-unmeasured` or `legacy-chain-unmeasured` and the run fails. Pass the pull request's base commit with `elsewhere` in effect: the base is then used for those records only, and nothing is forfeited. CI needs that one commit fetched, for example `git fetch --depth=1 origin <base-commit>`, not the full history:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
npm run --silent hone:check -- --base-revision <base-commit>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
The trade: a push that bypasses the hook, for example with `git push --no-verify`, leaves no later gate, so carve-out debt can stop decaying unnoticed. Every run that leaves decay to another run says so in its report (step 6). With `eslint` clauses, the repository's own `eslint` run also reports them in the editor, from the projection.
|
|
184
207
|
|
|
185
208
|
Tell any coding agent working in the repository, in its project instructions: "Read the rule pages under `node_modules/@hailstails/hone/rules/` for the disciplines in `disciplines.json` before editing. Before handing off, run the repository's validation command, report its exit code and findings, and apply the judgement rules listed in this file with their review lenses." Copying the rule pages does not make an agent read them; the instruction does.
|
|
186
209
|
|
|
@@ -193,21 +216,23 @@ The report prints only the sections that have entries, each with its count, then
|
|
|
193
216
|
CD-15#loops audit src/basket.ts:15:0 for (const line of this.lines) {
|
|
194
217
|
```
|
|
195
218
|
|
|
196
|
-
Lines are 1-based and columns 0-based. The run passes only when every section except `excluded` and `
|
|
219
|
+
Lines are 1-based and columns 0-based. The run passes only when every section except `excluded`, `notAdopted`, `exempted` and `assessment` is empty. The sections are:
|
|
197
220
|
|
|
198
221
|
| Section | Meaning and what to do |
|
|
199
222
|
| --- | --- |
|
|
200
223
|
| `excluded` | the `exclude` entries from `disciplines.json` that were left out of the run; informational, check it is what you meant |
|
|
224
|
+
| `notAdopted` | the clauses `disciplines.json` lists as `"not-adopted"`; informational, they were neither run nor projected |
|
|
201
225
|
| `findings` | violations: fix the code, or record an exception (step 7) |
|
|
202
226
|
| `exempted` | findings an exception covers; informational |
|
|
203
|
-
| `uncovered` | a mechanical clause of an adopted discipline is not
|
|
227
|
+
| `uncovered` | a mechanical clause of an adopted discipline is not listed: add it to `disciplines.json` with a mechanism, or as `"not-adopted"` |
|
|
204
228
|
| `stale` | an exception that no longer exempts anything: delete it |
|
|
205
229
|
| `forfeited` | a file carve-out whose file changed since `--base-revision`: fix the file and delete the carve-out |
|
|
206
|
-
| `invalidRecords` | an exception entry that cannot be accepted, with the reason
|
|
230
|
+
| `invalidRecords` | an exception entry that cannot be accepted, with the reason, for example `clause-not-adopted` for an entry on a clause listed as `"not-adopted"`: correct or delete it |
|
|
207
231
|
| `doublyHeld` | a file both authorised and carved out for one clause: keep one |
|
|
208
232
|
| `unmeasured` | something could not be measured, for example `forfeiture-unmeasured` when file carve-outs exist and no `--base-revision` was given |
|
|
233
|
+
| `assessment` | a concern this run left to another run or did not run, for example `forfeiture elsewhere: 37 file carve-outs not checked for decay in this run` or `waived-clauses not-run: 1 clause not run, 1 record not judged stale: CD-6#naming-convention eslint`; informational, and the verdict line then reads `verdict: pass (partial assessment)` or `verdict: fail (partial assessment)` |
|
|
209
234
|
|
|
210
|
-
To print less, set `"reportOutput"` in `disciplines.json` for the repository, or pass `--report-output <output>` for one run, which wins over the file. `full` is the default and prints the report above; `failures-only` leaves out `excluded` and `
|
|
235
|
+
To print less, set `"reportOutput"` in `disciplines.json` for the repository, or pass `--report-output <output>` for one run, which wins over the file. `full` is the default and prints the report above; `failures-only` leaves out `excluded`, `notAdopted`, `exempted` and `assessment`; `counts` prints only each section's heading and count, adding `informational` after `excluded`, `notAdopted`, `exempted` and `assessment` so every other line names a section that failed the run; `verdict-only` prints only the verdict line. Every output ends in the verdict line, and the exit code is the same whichever output you choose. An unknown value fails the run with exit `2`, as `arguments-invalid` for the option or `file-malformed` for the file.
|
|
211
236
|
|
|
212
237
|
## 7. Record exceptions
|
|
213
238
|
|
|
@@ -215,7 +240,7 @@ Fix findings where you can. Where a file legitimately needs what a clause forbid
|
|
|
215
240
|
|
|
216
241
|
- `authorised-location`: the clause does not apply to this one file, for example the single adapter that reads the real clock.
|
|
217
242
|
- `file-carve-out`: known debt in one file. It is forfeited, and fails the run, as soon as that file changes since `--base-revision`.
|
|
218
|
-
- `clause-wide-carve-out`: the clause is waived everywhere.
|
|
243
|
+
- `clause-wide-carve-out`: the clause is waived everywhere. Leaving the clause out of `clauses` is not an alternative: it leaves the clause `uncovered`. To not adopt the clause at all, list it as `"not-adopted"` (step 4) instead of recording a waiver. A clause-wide carve-out that exempts no finding is `stale`, so record one only while the clause still has findings, unless the repository sets `waivedClauses` to `not-run` (step 4), which skips the clause and does not judge the carve-out stale.
|
|
219
244
|
|
|
220
245
|
Every entry needs a `reason`. By default every entry also needs a `whyChain` shaped like this, with exactly five steps in `whys`:
|
|
221
246
|
|
|
@@ -311,4 +336,4 @@ verdict: pass
|
|
|
311
336
|
- The worked example uses only the audit mechanism. The ESLint consumer in `tests/test-fixtures/consumer-proof/eslint/` is the tested ESLint setup.
|
|
312
337
|
- Each check flags exactly what its rules page says and no more. Where a rule asks for more than its check can see, the page says which part is left to review.
|
|
313
338
|
- A snippet is the text the check reports; some checks report a fixed-width window that runs across lines, as CD-2 does above.
|
|
314
|
-
- The disciplines' IDs and rule text come from one team's code-discipline set. Selecting a subset is supported; editing a shipped rule is not. Write your own rule set for different rules.
|
|
339
|
+
- The disciplines' IDs and rule text come from one team's code-discipline set. Selecting a subset is supported; editing a shipped rule is not. Write your own rule set for different rules, following [docs/extending.md](docs/extending.md).
|
package/MIGRATING.md
CHANGED
|
@@ -31,7 +31,7 @@ Old code often holds CD-1 `any` the old route never checked. Hone flags it in st
|
|
|
31
31
|
|
|
32
32
|
Do [ADOPTING.md](ADOPTING.md) steps 1, 2 and 4 (and 4a for any `eslint` clause). A repository that used only Biome has no `eslint.config.*`: create `eslint.config.mjs` as step 4a shows before the first check, or the check stops with `runner-failed eslint team-config-unloadable`. Leave the old files in place until step 6.
|
|
33
33
|
|
|
34
|
-
Map each chosen discipline to its clauses with this table. A discipline is adopted whole: select every mechanical clause it lists, or the check reports the rest as `uncovered`.
|
|
34
|
+
Map each chosen discipline to its clauses with this table. A discipline is adopted whole: select every mechanical clause it lists, or the check reports the rest as `uncovered`. To adopt a discipline through one mechanism only, list the other clauses as `"not-adopted"`, as [ADOPTING.md](ADOPTING.md#4-write-disciplinesjson) step 4 shows. A repository that did this with a `clause-wide-carve-out` and `"waivedClauses": "not-run"` can switch: list the clause as `"not-adopted"`, delete its carve-out, which would otherwise be `clause-not-adopted`, and re-run `hone project` so the projection no longer carries that rule.
|
|
35
35
|
|
|
36
36
|
| Old CD | Clauses to select in `disciplines.json` |
|
|
37
37
|
| --- | --- |
|
|
@@ -149,7 +149,7 @@ Only after step 5 passes:
|
|
|
149
149
|
1. Delete the copied rule files and guides from step 1's harness folder (`.cursor/knowledge/aidlc-shared/code-discipline/` or its `.claude`/`.codex` equivalent).
|
|
150
150
|
2. Delete the copied tools tree and `harness.config.json`, unless anything else in the repository uses them. A repository that also runs the rin AIDLC plugin keeps `harness.config.json`, and in this same change sets `"constitution": { "engine": "discipline-core", "baseRevision": "origin/main" }` in it. Otherwise rin's stage gate, sensors and review lenses keep running the old walker over the old records, and they refuse what this check passes. Set `baseRevision` whenever a file carve-out or an imported entry exists.
|
|
151
151
|
3. Delete `.constitution-carve-outs/` and `.constitution-authorised-locations/`: their content now lives in `discipline-exceptions.json`.
|
|
152
|
-
4. In `package.json` scripts, CI and the pre-push hook, replace the old tool commands with the Hone check, as [ADOPTING.md](ADOPTING.md#5-run-the-check) step 5 shows. Every run needs `--base-revision` while a file carve-out exists: in local scripts and the pre-push hook use the branch's base (`origin/main`, or `HEAD` to measure only uncommitted changes); in CI use the pull request's base commit.
|
|
152
|
+
4. In `package.json` scripts, CI and the pre-push hook, replace the old tool commands with the Hone check, as [ADOPTING.md](ADOPTING.md#5-run-the-check) step 5 shows. Every run needs `--base-revision` while a file carve-out exists, unless it leaves forfeiture to another run as [ADOPTING.md](ADOPTING.md#5-run-the-check) step 5 shows, and a run with imported records needs it in any case: in local scripts and the pre-push hook use the branch's base (`origin/main`, or `HEAD` to measure only uncommitted changes); in CI use the pull request's base commit.
|
|
153
153
|
5. Rewrite the agent instructions to point at `node_modules/@hailstails/hone/rules/` and the judgement rules, as ADOPTING step 5 and step 9 say, and remove any instruction to read the old copied files.
|
|
154
154
|
6. Run the check and the repository's own validation command again, then commit everything in one change.
|
|
155
155
|
|
|
@@ -164,7 +164,7 @@ Stop and ask the human if anything outside the old trial uses the copied tools o
|
|
|
164
164
|
| 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 exceptions need a causal five-step `whyChain` ([contract](docs/why-chain-contract.md)), unless `disciplines.json` sets `"fileExceptionWhyChains": "optional"`, which lets file-level exceptions give only a `reason` |
|
|
165
165
|
| CD-1 | no exemptions | exempted like every other discipline, so existing `any` debt can be recorded |
|
|
166
166
|
| 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 |
|
|
167
|
-
| Running with debt | the decay check needed a base ref | every run with a file carve-out needs `--base-revision` |
|
|
167
|
+
| 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 |
|
|
168
168
|
| Debt decay (CD-46) | optional `rin-harness-carve-out-decay.ts` run | built into every check run with `--base-revision` |
|
|
169
169
|
| Stale and unrecorded exceptions | not checked | fail the run, including linter ignores or disables with no record |
|
|
170
170
|
| Path matching | old tools matched records by path suffix | exact repository paths |
|
|
@@ -185,7 +185,7 @@ An install from before the [why-chain contract](docs/why-chain-contract.md) hold
|
|
|
185
185
|
|
|
186
186
|
Hone is no longer installed by copying its source into the repository: this version ships no install files for that route. A copy of the source in `tools/discipline-core/` moves to the package, which gives the same reports from the same `disciplines.json` and `discipline-exceptions.json`, and runs on the repository's own toolchain. To move:
|
|
187
187
|
|
|
188
|
-
1. **Make sure the toolchain resolves from the repository root**, in the ranges [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 lists: TypeScript 4.8.4 up to 6.x, ESLint 9.
|
|
188
|
+
1. **Make sure the toolchain resolves from the repository root**, in the ranges [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 lists: TypeScript 4.8.4 up to 6.x, ESLint 9.28.0 or later on 9 or any 10, and typescript-eslint 8.56.0 or later on 8. Keep the versions the repository already uses.
|
|
189
189
|
2. **Install the package** as [ADOPTING.md](ADOPTING.md#2-install-the-hone-package) step 2 says, including the two `hone:` scripts.
|
|
190
190
|
3. **Repoint every command.** In scripts, CI and the pre-push hook, replace `node tools/discipline-core/core/check/check-command.ts --repo .` with `npm run --silent hone:check` (pass flags after `--`, as in `npm run --silent hone:check -- --base-revision origin/main`), and `project-command.ts` with `npm run --silent hone:project`. Point agent instructions at `node_modules/@hailstails/hone/rules/`.
|
|
191
191
|
4. **Remove the copy.** Delete `tools/discipline-core/`, its line in `.gitignore`, and its entry in `disciplines.json`'s `exclude`.
|
package/README.md
CHANGED
|
@@ -20,14 +20,14 @@ Two mechanisms ship: `audit`, a standalone TypeScript syntax walker, and `eslint
|
|
|
20
20
|
|
|
21
21
|
To adopt Hone in another repository, follow [ADOPTING.md](ADOPTING.md) step by step. A repository already using the older standalone route, or a copy of Hone's source, follows [MIGRATING.md](MIGRATING.md) instead.
|
|
22
22
|
|
|
23
|
-
Adding a discipline or a mechanism, and the full list of ESLint native channels, are covered in [docs/adding-a-discipline-or-mechanism.md](docs/adding-a-discipline-or-mechanism.md).
|
|
23
|
+
A team adds its own disciplines as a rule set in its own repository, with ESLint and audit pieces, following [docs/extending.md](docs/extending.md). Adding a discipline or a mechanism to Hone itself, and the full list of ESLint native channels, are covered in [docs/adding-a-discipline-or-mechanism.md](docs/adding-a-discipline-or-mechanism.md).
|
|
24
24
|
|
|
25
25
|
## Commands
|
|
26
26
|
|
|
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 <rev>] [--report-output <output>]
|
|
30
|
+
hone check --repo <dir> [--base-revision <rev>] [--report-output <output>] [--forfeiture <this-run|elsewhere>] [--waived-clauses <run|not-run>]
|
|
31
31
|
hone project --repo <dir>
|
|
32
32
|
```
|
|
33
33
|
|
|
@@ -43,26 +43,42 @@ hone project --repo <dir>
|
|
|
43
43
|
|
|
44
44
|
A load failure prints one line, `load failure: <kind> <fields>`.
|
|
45
45
|
|
|
46
|
-
The report lists the excluded paths, findings, exempted findings, uncovered clauses, stale, forfeited, unrecorded and doubly-held exceptions, invalid exception records, unmeasured checks and
|
|
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 and any part of the assessment left to another run, each with its count. The verdict is `pass` only when every list except the excluded paths, clauses not adopted, exempted findings and assessment is empty.
|
|
47
47
|
|
|
48
48
|
`--report-output` sets how much of the report is printed for one run, overriding `reportOutput` in `disciplines.json`; with neither, the output is `full`.
|
|
49
49
|
|
|
50
50
|
| Output | Prints |
|
|
51
51
|
| --- | --- |
|
|
52
52
|
| `full` | every non-empty section with its entries, then the verdict |
|
|
53
|
-
| `failures-only` | the same without the `excluded` and `
|
|
54
|
-
| `counts` | one `<section> (<count>)` line per non-empty section, with ` informational` after `excluded` and `
|
|
53
|
+
| `failures-only` | the same without the `excluded`, `exempted` and `assessment` sections |
|
|
54
|
+
| `counts` | one `<section> (<count>)` line per non-empty section, with ` informational` after `excluded`, `exempted` and `assessment`, then the verdict |
|
|
55
55
|
| `verdict-only` | only the verdict line |
|
|
56
56
|
|
|
57
57
|
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
58
|
|
|
59
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.
|
|
60
60
|
|
|
61
|
+
`--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
|
+
|
|
63
|
+
```text
|
|
64
|
+
assessment (1)
|
|
65
|
+
forfeiture elsewhere: 37 file carve-outs not checked for decay in this run
|
|
66
|
+
verdict: pass (partial assessment)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
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
|
+
|
|
71
|
+
`--waived-clauses not-run` makes a run skip every selected clause a valid `clause-wide-carve-out` covers, overriding `assessment.waivedClauses` in `disciplines.json`; `--waived-clauses run`, the default, runs them as before. A mechanism left with nothing to run is not loaded at all, so a repository that waives every `eslint` clause needs no ESLint installed. A mechanism that still has another clause to run skips just the waived ones: ESLint never switches a waived rule on, while its projection is still judged against every selected clause, the waived clause and its `"off"` block included. When every ESLint clause is waived, ESLint is not loaded, so the projection's freshness is not checked in that run. Only the waived clauses' execution and the staleness of the records on them are skipped: `stale` is not judged for those records, while invalid records, forfeiture, doubly-held records and `uncovered` are reported as before, and `hone project` still writes the waived rules and their `"off"` blocks. The `assessment` section names each clause not run:
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
waived-clauses not-run: 1 clause not run, 1 record not judged stale: CD-6#naming-convention eslint
|
|
75
|
+
```
|
|
76
|
+
|
|
61
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`.
|
|
62
78
|
|
|
63
79
|
## Adopting the ESLint mechanism
|
|
64
80
|
|
|
65
|
-
With any clause selected for `eslint`, run `hone project`. It writes `disciplines.eslint.mjs` at the repository root: one block per piece enabling its selected rules at `"error"` on `**/*.{ts,tsx,mts,cts}`, then one block per
|
|
81
|
+
With any clause selected for `eslint`, run `hone project`. It writes `disciplines.eslint.mjs` at the repository root: one block per piece enabling its selected rules at `"error"` on `**/*.{ts,tsx,mts,cts}`, then one block per set of clauses that files are excepted from, listing those files and turning the rules `"off"` for them, and one block per clause-wide carve-out turning its rules `"off"` everywhere. Commit it, and spread its default export last in the repository's flat config:
|
|
66
82
|
|
|
67
83
|
```js
|
|
68
84
|
import disciplines from "./disciplines.eslint.mjs";
|
|
@@ -97,12 +113,15 @@ At the repository root. It selects clauses and the mechanism that checks each on
|
|
|
97
113
|
```
|
|
98
114
|
|
|
99
115
|
- `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>`.
|
|
100
|
-
- `clauses` maps a clause address to a mechanism id
|
|
101
|
-
-
|
|
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.
|
|
117
|
+
- 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-adopted"` states that the repository does not adopt that clause. It is never run and never projected, and its mechanism is not loaded unless another clause uses it. The report lists it under `notAdopted`, which is informational: the run is still a whole assessment. An exception record on it is invalid as `clause-not-adopted`, and `clauseSettings` for it make `disciplines.json` `file-malformed`. The clause must still exist and be mechanical, in any rule set.
|
|
102
119
|
- A judgement clause cannot be selected; it is enforced by review.
|
|
103
120
|
- `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.
|
|
104
121
|
- `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).
|
|
105
122
|
- `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 rules page 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.
|
|
124
|
+
- `assessment`, optional, says which run assesses each concern. `forfeiture` is `"this-run"` (the default) or `"elsewhere"`, and `--forfeiture` overrides it for one run. `waivedClauses` is `"run"` (the default) or `"not-run"`, and `--waived-clauses` overrides it for one run. See [Commands](#commands). Any other key makes `disciplines.json` `file-malformed`, naming the key as not available in this version.
|
|
106
125
|
- `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.
|
|
107
126
|
|
|
108
127
|
## discipline-exceptions.json
|
|
@@ -159,10 +178,10 @@ The package has two public entries for TypeScript. Each holds types only, so imp
|
|
|
159
178
|
|
|
160
179
|
| Entry | Status | What it is for |
|
|
161
180
|
| --- | --- | --- |
|
|
162
|
-
| `@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. |
|
|
163
|
-
| `@hailstails/hone/audit` | Experimental | The types for writing an audit walker piece, `WalkerPiece` and what it needs. It may change in a minor release. |
|
|
181
|
+
| `@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. |
|
|
164
183
|
|
|
165
|
-
Both resolve with `moduleResolution` `"nodenext"` or `"bundler"
|
|
184
|
+
Both resolve 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.
|
|
166
185
|
|
|
167
186
|
## Runtime
|
|
168
187
|
|
|
@@ -170,11 +189,11 @@ Both resolve with `moduleResolution` `"nodenext"` or `"bundler"`, and `install-p
|
|
|
170
189
|
- The package: Node `^22.18.0 || >=24` (its `engines.node`). It is plain JavaScript, so Node never strips types from it, and from 22.18.0 Node strips types from a rule set's `.ts` piece modules, within the limits [ADOPTING.md](ADOPTING.md#1-check-the-prerequisites) lists.
|
|
171
190
|
- git 2.24 or later. Older git rejects `--end-of-options`, so the changed-file query fails and forfeiture is reported unmeasured.
|
|
172
191
|
- Hone's own packages, `zod`, `jsonc-parser` and `@eslint/plugin-kit`, exact-pinned in `dependencies` and locked by `pnpm-lock.yaml`: bundled into the package. They are implementation details: nothing of theirs crosses into the repository's code or configuration.
|
|
173
|
-
- The repository's own toolchain, declared as `peerDependencies`: `typescript` `>=4.8.4 <7.0.0`, a required peer because every audit clause needs it, and for the ESLint mechanism the optional peers `eslint` `^9.
|
|
192
|
+
- The repository's own toolchain, declared as `peerDependencies`: `typescript` `>=4.8.4 <7.0.0`, a required peer because every audit clause needs it, and for the ESLint mechanism the optional peers `eslint` `^9.28.0 || ^10.0.0`, `@typescript-eslint/parser` `^8.56.0` and `@typescript-eslint/eslint-plugin` `^8.56.0`. npm 7 and later install a missing required peer on their own, so declare `typescript` at the root at the version the repository uses. Each floor is the oldest release Hone is tested on: TypeScript 4.8 is the oldest whose syntax API the audit uses (`getModifiers`), ESLint 9.28.0 the first 9.x with every bulk-suppressions option a carve-out kept in `eslint-suppressions.json` relies on (`--pass-on-unpruned-suppressions` came last), and typescript-eslint 8.56.0 the first whose peer range accepts ESLint 10. TypeScript stops below 7 because TypeScript 7's compiler API is a different one. Yarn Plug'n'Play is not supported.
|
|
174
193
|
|
|
175
|
-
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.
|
|
194
|
+
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.
|
|
176
195
|
|
|
177
|
-
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.
|
|
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.
|
|
178
197
|
|
|
179
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.
|
|
180
199
|
|
|
@@ -226,13 +245,13 @@ This repository is self-contained: it holds its own configuration and its own lo
|
|
|
226
245
|
| `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` |
|
|
227
246
|
| `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 |
|
|
228
247
|
| `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) |
|
|
229
|
-
| `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball and installs it offline into
|
|
248
|
+
| `install-proof` | `node scripts/install-proof.ts`: packs the package once into a temporary tarball and installs it offline 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`. It installs each toolchain once, in a folder the consumers sharing it sit inside: 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. Each consumer declares the required peer `typescript` at its pin in its own `devDependencies`, as an adopter does, and the proof checks that `typescript` resolves there at that version, since npm would otherwise install the newest supported release beside it. 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 |
|
|
230
249
|
| `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) |
|
|
231
250
|
| `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) |
|
|
232
251
|
|
|
233
252
|
### Hone's check on itself
|
|
234
253
|
|
|
235
|
-
`disciplines.json` selects every mechanical clause Hone ships, through the mechanism it names, and `eslint.config.mjs` spreads the committed `disciplines.eslint.mjs` projection, which `node scripts/self-check.ts project --repo .` regenerates. `discipline-exceptions.json` holds
|
|
254
|
+
`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.
|
|
236
255
|
|
|
237
256
|
`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.
|
|
238
257
|
|
package/api/audit.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
export type { RunnerClause } from "../core/mechanism-port/runner-module-types.js";
|
|
1
|
+
export type { PieceFailure } from "../core/mechanism-port/piece-failure-types.js";
|
|
2
|
+
export type { ClauseSettingValues, RunnerClause } from "../core/mechanism-port/runner-module-types.js";
|
|
3
|
+
export type { ReadonlyJsonValue } from "../core/values/json-value.js";
|
|
3
4
|
export type { Hit } from "../core/mechanism-port/runner-result-types.js";
|
|
4
5
|
export type { Anchor, AnchorKind } from "../core/values/anchor.js";
|
|
5
6
|
export type { ClauseAddress, ToolRuleSet } from "../core/values/clause-address-types.js";
|
package/api/rule-set.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export type { ClauseDefinition,
|
|
1
|
+
export type { AuthoredClauseDefinition as ClauseDefinition, AuthoredDisciplineFile as DisciplineFile, AuthoredPieceFile as PieceFile, AuthoredSourceCase as SourceCase, ClauseExceptions, ClauseSettingDeclaration, ClauseSettingDeclarations, } from "../core/rule-set-reader/authored-rule-set-types.js";
|
|
2
2
|
export type { AnchorKind } from "../core/values/anchor.js";
|
|
3
|
-
export type {
|
|
4
|
-
export type { JsonValue } from "../core/values/json-value.js";
|
|
5
|
-
export type { RepoPath } from "../core/values/repo-path-types.js";
|
|
3
|
+
export type { JsonValue, ReadonlyJsonValue } from "../core/values/json-value.js";
|
|
6
4
|
export type { EslintPieceSettings, RuleOptions } from "../mechanisms/eslint/runner/eslint-piece-settings-types.js";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// mechanisms/audit/runner/cast-shape.ts
|
|
2
|
+
var SNIPPET_MAX_LENGTH = 80;
|
|
3
|
+
var castSnippetAt = (request) => {
|
|
4
|
+
const snippet = request.sourceFile.text.slice(request.position, request.position + SNIPPET_MAX_LENGTH).replace(/\n/g, " ");
|
|
5
|
+
return snippet.length === SNIPPET_MAX_LENGTH ? `${snippet}\u2026` : snippet;
|
|
6
|
+
};
|
|
7
|
+
var assertionOf = (request) => {
|
|
8
|
+
const { node, syntaxApi } = request;
|
|
9
|
+
if (syntaxApi.isAsExpression(node)) return { node, expression: node.expression, type: node.type, form: "as" };
|
|
10
|
+
if (syntaxApi.isTypeAssertionExpression(node)) return { node, expression: node.expression, type: node.type, form: "angle-bracket" };
|
|
11
|
+
return void 0;
|
|
12
|
+
};
|
|
13
|
+
var anyBearingFound = (request) => anyBearingOf(request) === "any-bearing" ? "any-bearing" : void 0;
|
|
14
|
+
var anyBearingOf = (request) => {
|
|
15
|
+
const { typeNode, syntaxApi } = request;
|
|
16
|
+
if (typeNode.kind === syntaxApi.SyntaxKind.AnyKeyword) return "any-bearing";
|
|
17
|
+
return syntaxApi.forEachChild(typeNode, (child) => anyBearingFound({ typeNode: child, syntaxApi })) ?? "any-free";
|
|
18
|
+
};
|
|
19
|
+
var satisfiesOperand = (request) => {
|
|
20
|
+
const { node, syntaxApi } = request;
|
|
21
|
+
if (node.kind !== syntaxApi.SyntaxKind.SatisfiesExpression) return void 0;
|
|
22
|
+
return syntaxApi.isSatisfiesExpression(node) ? node.expression : void 0;
|
|
23
|
+
};
|
|
24
|
+
var wrappedOperand = (request) => {
|
|
25
|
+
const { node, syntaxApi } = request;
|
|
26
|
+
if (syntaxApi.isParenthesizedExpression(node) || syntaxApi.isNonNullExpression(node)) return node.expression;
|
|
27
|
+
return satisfiesOperand({ node, syntaxApi });
|
|
28
|
+
};
|
|
29
|
+
var unwrappedExpression = (request) => {
|
|
30
|
+
const operand = wrappedOperand(request);
|
|
31
|
+
return operand === void 0 ? request.node : unwrappedExpression({ node: operand, syntaxApi: request.syntaxApi });
|
|
32
|
+
};
|
|
33
|
+
var unknownTypeOf = (request) => request.typeNode.kind === request.syntaxApi.SyntaxKind.UnknownKeyword ? "unknown" : "other";
|
|
34
|
+
var constTypeOf = (request) => {
|
|
35
|
+
const { typeNode, syntaxApi } = request;
|
|
36
|
+
if (!syntaxApi.isTypeReferenceNode(typeNode) || !syntaxApi.isIdentifier(typeNode.typeName)) return "other";
|
|
37
|
+
return typeNode.typeName.text === "const" ? "const" : "other";
|
|
38
|
+
};
|
|
39
|
+
var castShapeOf = (request) => {
|
|
40
|
+
const { assertion, syntaxApi } = request;
|
|
41
|
+
const operand = assertionOf({ node: unwrappedExpression({ node: assertion.expression, syntaxApi }), syntaxApi });
|
|
42
|
+
if (operand !== void 0 && unknownTypeOf({ typeNode: operand.type, syntaxApi }) === "unknown") return "through-unknown";
|
|
43
|
+
if (unknownTypeOf({ typeNode: assertion.type, syntaxApi }) === "unknown") return "unknown-widening";
|
|
44
|
+
if (constTypeOf({ typeNode: assertion.type, syntaxApi }) === "const") return "const-assertion";
|
|
45
|
+
return "type-assertion";
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
castSnippetAt,
|
|
50
|
+
assertionOf,
|
|
51
|
+
anyBearingOf,
|
|
52
|
+
castShapeOf
|
|
53
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
clauseAddressText,
|
|
3
|
+
external_exports
|
|
4
|
+
} from "./chunk-SWPCKTJV.js";
|
|
5
|
+
|
|
6
|
+
// mechanisms/audit/runner/piece-clause-settings.ts
|
|
7
|
+
var stringListClauseSettings = (request) => {
|
|
8
|
+
const parsed = external_exports.record(external_exports.enum(request.keys), external_exports.array(external_exports.string().min(1)).readonly()).safeParse(request.clause.clauseSettings);
|
|
9
|
+
if (parsed.success) return { outcome: "ok", value: parsed.data };
|
|
10
|
+
return {
|
|
11
|
+
outcome: "failed",
|
|
12
|
+
error: {
|
|
13
|
+
kind: "piece-invalid",
|
|
14
|
+
pieceRoot: request.clause.pieceRoot,
|
|
15
|
+
detail: `the clauseSettings of ${clauseAddressText({ address: request.clause.address })} are malformed: ${external_exports.prettifyError(parsed.error)}`
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export {
|
|
21
|
+
stringListClauseSettings
|
|
22
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// core/values/gathered-outcomes.ts
|
|
2
|
+
var gatheredOutcomes = (request) => {
|
|
3
|
+
const failed = request.outcomes.find((outcome) => outcome.outcome === "failed");
|
|
4
|
+
if (failed !== void 0) return failed;
|
|
5
|
+
return {
|
|
6
|
+
outcome: "ok",
|
|
7
|
+
value: request.outcomes.flatMap((outcome) => outcome.outcome === "ok" ? outcome.value : [])
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
gatheredOutcomes
|
|
13
|
+
};
|