@hailstails/hone 0.1.0-pre.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/ADOPTING.md +33 -7
  2. package/CHANGELOG.md +19 -0
  3. package/MIGRATING.md +31 -6
  4. package/README.md +73 -24
  5. package/api/audit.d.ts +6 -0
  6. package/api/audit.js +9 -1
  7. package/api/testing.js +36 -8
  8. package/chunks/{chunk-XE6RNNZB.js → chunk-63SJV5ZY.js} +1395 -1339
  9. package/chunks/{chunk-RNXPEK2U.js → chunk-BLGGM7AV.js} +2 -2
  10. package/chunks/{chunk-OKQHVZLO.js → chunk-CBWWAKQY.js} +1 -1
  11. package/chunks/{chunk-5X2BR42Y.js → chunk-FR4FASVM.js} +15 -24
  12. package/chunks/chunk-MXSIQPCV.js +13 -0
  13. package/chunks/{chunk-LHVFZMXD.js → chunk-MZTLH4EU.js} +60 -20
  14. package/chunks/chunk-NA5L6PUE.js +15 -0
  15. package/chunks/{chunk-OVEQ37JQ.js → chunk-PVCA3ISA.js} +42 -17
  16. package/chunks/chunk-RWQ4UNKY.js +24 -0
  17. package/chunks/{chunk-YL6WR3QW.js → chunk-Y4SMWOD2.js} +1 -1
  18. package/chunks/chunk-YLZ73C7O.js +0 -0
  19. package/chunks/{chunk-NILRE23T.js → chunk-Z4UBS7WI.js} +1 -1
  20. package/core/check/tool-command.js +702 -22
  21. package/core/conformance/conformance-testing-types.d.ts +2 -0
  22. package/core/mechanism-port/runner-module-types.d.ts +2 -0
  23. package/core/rule-set-reader/authored-rule-set-types.d.ts +2 -0
  24. package/core/values/edition-types.d.ts +16 -0
  25. package/docs/extending.md +31 -9
  26. package/docs/output-contract.md +101 -15
  27. package/mechanisms/audit/CD-19/import-boundaries.js +3 -2
  28. package/mechanisms/audit/CD-27/piece.json +5 -1
  29. package/mechanisms/audit/CD-27/test-body-logic.js +55 -4
  30. package/mechanisms/audit/CD-5/comments-directives.js +4 -3
  31. package/mechanisms/audit/runner/runner.js +6 -5
  32. package/mechanisms/eslint/runner/runner.js +8 -4
  33. package/package.json +1 -1
  34. package/rules/CD-27/CHECKS.md +31 -1
  35. package/rules/CD-27/discipline.json +74 -0
@@ -1,4 +1,5 @@
1
1
  import type { RunnerClause } from "../mechanism-port/runner-module-types.js";
2
+ import type { Edition } from "../values/edition-types.js";
2
3
  import type { RepoPath } from "../values/repo-path-types.js";
3
4
  import type { Result } from "../values/result.js";
4
5
  import type { ConformanceFailure } from "./conformance-types.js";
@@ -16,6 +17,7 @@ export type CaseUnderTest = {
16
17
  readonly name: string;
17
18
  readonly file: RepoPath;
18
19
  readonly source: string;
20
+ readonly edition: Edition;
19
21
  };
20
22
  export type ClauseUnderTest = {
21
23
  readonly clause: RunnerClause;
@@ -1,5 +1,6 @@
1
1
  import type { AnchorKind } from "../values/anchor.js";
2
2
  import type { ClauseAddress } from "../values/clause-address-types.js";
3
+ import type { Edition } from "../values/edition-types.js";
3
4
  import type { ReadonlyJsonValue } from "../values/json-value.js";
4
5
  export type ClauseSettingValues = {
5
6
  readonly [key: string]: ReadonlyJsonValue;
@@ -10,4 +11,5 @@ export type RunnerClause = {
10
11
  readonly pieceRoot: string;
11
12
  readonly settings: unknown;
12
13
  readonly clauseSettings: ClauseSettingValues;
14
+ readonly edition: Edition;
13
15
  };
@@ -6,6 +6,7 @@ export type AuthoredSourceCase = {
6
6
  readonly fileName: string;
7
7
  readonly source: string;
8
8
  readonly expectedLines: readonly number[];
9
+ readonly edition?: string | undefined;
9
10
  };
10
11
  export type AuthoredClauseDefinition = {
11
12
  readonly kind: "mechanical";
@@ -44,5 +45,6 @@ export type AuthoredPieceFile = {
44
45
  readonly clause: string;
45
46
  readonly settings: unknown;
46
47
  readonly clauseSettings?: ClauseSettingDeclarations;
48
+ readonly editions?: readonly string[] | undefined;
47
49
  }[];
48
50
  };
@@ -0,0 +1,16 @@
1
+ import type { Branded } from "./branded.js";
2
+ import type { ClauseAddress } from "./clause-address-types.js";
3
+ import type { MechanismId } from "./identifier-types.js";
4
+ export type Edition = Branded<string, "Edition">;
5
+ export type ClauseEditions = {
6
+ readonly declared: readonly Edition[];
7
+ readonly default: Edition;
8
+ readonly latest: Edition;
9
+ };
10
+ export type EditionReach = "reached" | "not-reached";
11
+ export type ClauseEditionReading = {
12
+ readonly address: ClauseAddress;
13
+ readonly mechanism: MechanismId;
14
+ readonly edition: Edition;
15
+ readonly latest: Edition;
16
+ };
package/docs/extending.md CHANGED
@@ -185,7 +185,8 @@ In a monorepo each package's own config does the same, importing the projection
185
185
  "clauses": [
186
186
  {
187
187
  "clause": "scratch-files",
188
- "settings": { "module": "scratch-files.ts" }
188
+ "settings": { "module": "scratch-files.ts" },
189
+ "editions": ["1", "2"]
189
190
  }
190
191
  ]
191
192
  }
@@ -194,14 +195,21 @@ In a monorepo each package's own config does the same, importing the projection
194
195
  `mechanisms/audit/ACME-2/scratch-files.ts`:
195
196
 
196
197
  ```ts
197
- import type { PieceHit, RunnerClause, WalkerPiece } from "@hailstails/hone/audit";
198
+ import { editionReaches, isEdition, type PieceHit, type RunnerClause, type WalkerPiece } from "@hailstails/hone/audit";
198
199
 
199
200
  const SCRATCH_MARKER = ".scratch.";
201
+ const DRAFT_MARKER = ".draft.";
202
+ const DRAFT_EDITION = "2";
203
+
204
+ const markersOf = (request: { readonly clause: RunnerClause }): readonly string[] =>
205
+ isEdition(DRAFT_EDITION) && editionReaches({ edition: request.clause.edition, introducedIn: DRAFT_EDITION }) === "reached"
206
+ ? [SCRATCH_MARKER, DRAFT_MARKER]
207
+ : [SCRATCH_MARKER];
200
208
 
201
209
  const scratchHits = (request: { readonly clauses: readonly RunnerClause[]; readonly file: string }): readonly PieceHit[] =>
202
- request.file.includes(SCRATCH_MARKER)
203
- ? request.clauses.map((clause) => ({ clause: clause.address, anchor: { line: 1, column: 0 }, snippet: request.file }))
204
- : [];
210
+ request.clauses
211
+ .filter((clause) => markersOf({ clause }).some((marker) => request.file.includes(marker)))
212
+ .map((clause) => ({ clause: clause.address, anchor: { line: 1, column: 0 }, snippet: request.file }));
205
213
 
206
214
  export const check: WalkerPiece = {
207
215
  prepare: ({ clauses }) => ({
@@ -243,6 +251,20 @@ A repository that selects the clause can then override it in `disciplines.json`,
243
251
 
244
252
  Hone refuses a value under an undeclared key, of another JSON kind than the default, or outside the `choices`, before any piece runs. The piece reads the value, the override or else the default, from `clause.clauseSettings` on each `RunnerClause`, in place of the fixed `SCRATCH_MARKER`. The value is typed as any JSON value, so the piece narrows it, for example with `typeof marker === "string"`, and returns a `piece-invalid` failure when it is not what it accepts. Name the settings on the discipline's page under a Settings heading. This section is described, not run by the example: Hone's unit tests cover reading, refusing and overriding settings.
245
253
 
254
+ ### Editions of a check
255
+
256
+ When a clause's check becomes stricter, ship the stricter check as a new edition instead of changing what the clause flags. A clause entry in `piece.json` lists its `editions` in ascending order: the first is the default, and the last is the latest. The example's piece lists `["1", "2"]`: edition 2 also flags files named with `.draft.`. An entry without `editions` has the single edition `"1"`. The setting key `edition` is reserved for the edition a repository pins, so a piece cannot declare it under `clauseSettings`.
257
+
258
+ The piece reads the edition that runs from `clause.edition` on each `RunnerClause`. `@hailstails/hone/audit` exports two helpers. `isEdition` narrows a text such as `"2"` to an `Edition` without a cast. `editionReaches({ edition: clause.edition, introducedIn })` says whether the running edition covers something introduced in a given edition. The example piece uses both, and a piece's tests use `isEdition` the same way to build a `RunnerClause` for each edition.
259
+
260
+ A case in `discipline.json` names the edition it runs under with `"edition": "2"`. A case without one runs under the piece's default edition. A case naming an edition the piece does not declare makes the rule set invalid. Conformance runs each edition's cases under that edition, and `clauseUnderTestOf` gives each case its `edition`. The example's `rules/ACME-2/discipline.json` flags `src/notes.draft.ts` under edition 2 and allows it under edition 1:
261
+
262
+ ```json
263
+ { "name": "draft file", "fileName": "src/notes.draft.ts", "source": "export const notes = 1;\n", "expectedLines": [1], "edition": "2" }
264
+ ```
265
+
266
+ A repository that selects the clause runs edition 1 until it sets `"checkEditions": "latest"` or pins the clause with `"edition": "2"` in its `clauseSettings`. Its report lists the edition that ran under `editions`, such as `acme/ACME-2#scratch-files audit edition 1 of 2`.
267
+
246
268
  ## TypeScript pieces under Node
247
269
 
248
270
  Hone loads piece modules with Node, which strips the types from a `.ts` file as it loads it. Node 22.18 or later does this without flags.
@@ -268,7 +290,7 @@ Hone loads piece modules with Node, which strips the types from a `.ts` file as
268
290
 
269
291
  ## Type-check the rule set
270
292
 
271
- `@hailstails/hone/rule-set` holds types only. `@hailstails/hone/audit` holds the walker piece types and one value, `folderScope`. Import types with `import type`. A `tsconfig` for the rule set that matches how Node runs it, `tools/disciplines/acme/tsconfig.pieces.json`:
293
+ `@hailstails/hone/rule-set` holds types only. `@hailstails/hone/audit` holds the walker piece types and three values: `folderScope`, `isEdition` and `editionReaches`. Import types with `import type`. A `tsconfig` for the rule set that matches how Node runs it, `tools/disciplines/acme/tsconfig.pieces.json`:
272
294
 
273
295
  ```json
274
296
  {
@@ -318,7 +340,7 @@ const conformance = await clauseConformanceOf({ ruleSetRoot: "tools/disciplines/
318
340
 
319
341
  A relative `ruleSetRoot` is read from the working directory. `{ outcome: "ok", value: [] }` means the piece met every case. Each entry in a longer list names a case, the lines it expects and the lines the piece flagged. `{ outcome: "failed", error: { kind, detail } }` means the cases could not run, for example `rule-set-unloadable` for a clause the audit mechanism may not check.
320
342
 
321
- Checks of your own call the piece directly. `clauseUnderTestOf` returns the same bound clause and each case's `name`, `file` and `source`, ready for `check.prepare` and `prepareFile`; `repoPathOf` makes the `RepoPath` for any other file, such as one whose `readText` fails with `file-unreadable`. `folderScope` from `@hailstails/hone/audit` tells a piece whether a file sits in a generated folder. Hone does not run these tests; the team runs them with its own test runner.
343
+ Checks of your own call the piece directly. `clauseUnderTestOf` returns the same bound clause and each case's `name`, `file`, `source` and `edition`, ready for `check.prepare` and `prepareFile`; `repoPathOf` makes the `RepoPath` for any other file, such as one whose `readText` fails with `file-unreadable`. `folderScope` from `@hailstails/hone/audit` tells a piece whether a file sits in a generated folder. Hone does not run these tests; the team runs them with its own test runner.
322
344
 
323
345
  ## Exceptions
324
346
 
@@ -340,9 +362,9 @@ Without that setting the entry also needs a `whyChain`, and without one it is re
340
362
  Two requirements are decided and not yet built. Each will make some rule sets that pass today fail:
341
363
 
342
364
  - **A rule page is required.** A selected team discipline without `rules/<ID>/README.md` will fail to load.
343
- - **Pieces keep to import boundaries.** A team piece will be refused if it imports from anywhere but its own piece folder, its discipline's `rules/<ID>` folder, `@hailstails/hone/rule-set`, `@hailstails/hone/audit` and its mechanism's toolchain package (`eslint` or `typescript`), with values only from its own piece folder and `folderScope` from `@hailstails/hone/audit`. The rule is about a piece's run-time code: a piece's own tests may also import `@hailstails/hone/testing`.
365
+ - **Pieces keep to import boundaries.** A team piece will be refused if it imports from anywhere but its own piece folder, its discipline's `rules/<ID>` folder, `@hailstails/hone/rule-set`, `@hailstails/hone/audit` and its mechanism's toolchain package (`eslint` or `typescript`), with values only from its own piece folder and `folderScope`, `isEdition` and `editionReaches` from `@hailstails/hone/audit`. The rule is about a piece's run-time code: a piece's own tests may also import `@hailstails/hone/testing`.
344
366
 
345
- To be ready now: write each discipline's `README.md`, and import nothing from Hone in a piece but types from `@hailstails/hone/rule-set` and `@hailstails/hone/audit` and `folderScope`.
367
+ To be ready now: write each discipline's `README.md`, and import nothing from Hone in a piece but types from `@hailstails/hone/rule-set` and `@hailstails/hone/audit`, and `folderScope`, `isEdition` and `editionReaches`.
346
368
 
347
369
  | Part | Status |
348
370
  | --- | --- |
@@ -1,18 +1,18 @@
1
1
  # Output contract
2
2
 
3
- This page lists everything the `hone` command prints, exactly as it prints it: the help, the version, the report, the load failures and the `hone project` lines. It says which parts a hook, CI job or agent can parse and rely on. [Compatibility](../README.md#compatibility) says which releases may change them.
3
+ This page lists everything the `hone` command prints, exactly as it prints it: the help, the version, the report, the load failures, the `hone project` lines, the `hone record-debt` lines and the `hone split-records` lines. It says which parts a hook, CI job or agent can parse and rely on. [Compatibility](../README.md#compatibility) says which releases may change them.
4
4
 
5
5
  A test renders every kind of line the command can print, fills each template below with that line's own sample values, and requires the result to equal the printed line exactly: a line Hone can print that is not listed here fails the build, and so does a line listed here that Hone cannot print. The synopsis and help blocks below are compared with what the command prints, character for character.
6
6
 
7
7
  ## Streams and exit codes
8
8
 
9
- Hone prints everything to standard output: the report, the help, the version, `hone project` lines and every load failure, including an error Hone did not expect. Hone writes nothing to standard error itself; Node can write its own warnings there, so a hook should not read output on standard error as a failure.
9
+ Hone prints everything to standard output: the report, the help, the version, `hone project`, `hone record-debt` and `hone split-records` lines and every load failure, including an error Hone did not expect. Hone writes nothing to standard error itself; Node can write its own warnings there, so a hook should not read output on standard error as a failure.
10
10
 
11
11
  The exit code is the signal a hook should act on:
12
12
 
13
- - `0`: `hone check` printed `verdict: pass` or `verdict: pass (partial assessment)`, `hone project` wrote or confirmed every projection, or help or the version was printed;
13
+ - `0`: `hone check` printed `verdict: pass` or `verdict: pass (partial assessment)`, `hone project` wrote or confirmed every projection, `hone record-debt` wrote every record it needed or needed none, `hone split-records` split the records or found nothing to split, or help or the version was printed;
14
14
  - `1`: `hone check` printed `verdict: fail` or `verdict: fail (partial assessment)` as its last line. Exit `1` always comes with one of those lines, and with nothing else;
15
- - `2`: Hone could not decide. It printed exactly one line, starting with `load failure: `, and no verdict. That covers a command typed wrongly, an input that could not be loaded, a mechanism that failed, and an error Hone did not expect, which prints as `unexpected-error`.
15
+ - `2`: Hone could not decide. It printed exactly one line, starting with `load failure: `, and no verdict. That covers a command typed wrongly, an input that could not be loaded, a mechanism that failed, records `hone record-debt` or `hone split-records` could not write or place, and an error Hone did not expect, which prints as `unexpected-error`.
16
16
 
17
17
  A 1.0 hook can rely on this: run `hone check`, block on any non-zero exit, and show standard output as it came.
18
18
 
@@ -33,9 +33,10 @@ These are not stable, so a minor release may change them:
33
33
  - the help text, though the synopsis and the exit codes it lists are stable;
34
34
  - the text of a `<detail>`, which comes from Node, git, ESLint or a schema check;
35
35
  - the wording after `load failure: arguments-invalid`, written for the person who typed the command;
36
- - the text after a load failure's values, which says what to do next: the repair text of `selection-absent`, `judgement-clause-listed` and `config-root-untracked`, and everything after the kind in `toolchain-unavailable` and `toolchain-shadowed`;
36
+ - the text after a load failure's values, which says what to do next: the repair text of `selection-absent`, `judgement-clause-listed`, `config-root-untracked` and `why-chains-required`, and everything after the kind in `toolchain-unavailable` and `toolchain-shadowed`;
37
37
  - the `readFirst` lines and their leading note, written for a person;
38
- - the words of an `unmeasured` or `projectionProblems` line after the `:` that ends its leading fields (its kind and reason, or its mechanism, state and slice), which say why and what to do next.
38
+ - the words of an `unmeasured` or `projectionProblems` line after the `:` that ends its leading fields (its kind and reason, or its mechanism, state and slice), which say why and what to do next;
39
+ - the words of a `hone record-debt` line after the `:` that follows its file, which say why no record was written and what to do instead.
39
40
 
40
41
  A minor release may add a section, a kind of line in a section, a load failure kind, an option or a command. A tool reading the report should pass over a section heading or a line kind it does not know.
41
42
 
@@ -49,9 +50,10 @@ In the tables below, a word in angle brackets, such as `<clause>`, stands for a
49
50
  | `<mechanism>` | a mechanism id, such as `audit` or `eslint` | never |
50
51
  | `<record kind>`, `<section>`, `<package>` | a word from the lines below, a section name, or an npm package name | never |
51
52
  | `<line>`, `<column>` | a 1-based line and a 0-based column | never |
52
- | `<count>`, `<index>`, `<earlier index>` | a whole number; an index counts from 0 | never |
53
+ | `<count>`, `<index>`, `<earlier index>` | a whole number; an index counts from 0, within the file that holds the record | never |
53
54
  | `<version>` | the installed package's version | never |
54
- | `<file>`, `<path>`, `<slice>`, `<suppressions file>`, `<package file>`, `<config root>`, `<piece folder>`, `<location>`, `<install folder>`, `<rule page>`, `<adoption guide>` | a path, as described below | may hold a space |
55
+ | `<edition>`, `<latest>` | the edition of a clause's check that ran and the latest edition its piece declares, each a whole number from 1 | never |
56
+ | `<file>`, `<path>`, `<records file>`, `<earlier records file>`, `<records folder>`, `<slice>`, `<suppressions file>`, `<package file>`, `<config root>`, `<piece folder>`, `<location>`, `<install folder>`, `<rule page>`, `<adoption guide>` | a path, as described below | may hold a space |
55
57
  | `<folders>` | paths separated by `, ` | may hold a space |
56
58
  | `<folder>` | the folder that holds a `<slice>` | may hold a space |
57
59
  | `<project command>` | the command that runs `hone project` for this repository: `node`, the installed command's absolute path, `project --repo` and the repository's absolute path, each path with forward slashes and in double quotes when it holds a character other than a letter, digit or one of `_ . / @ : + -` | may hold a space |
@@ -69,11 +71,13 @@ Paths are printed with forward slashes. A path inside the `--repo` folder is pri
69
71
  ```text
70
72
  hone check --repo <dir> [--base-revision <revision>] [--report-output <full|failures-only|counts|verdict-only>] [--forfeiture <this-run|elsewhere>]
71
73
  hone project --repo <dir>
74
+ hone record-debt --repo <dir> --base-revision <revision> [--leave <path>]...
75
+ hone split-records --repo <dir>
72
76
  hone --help
73
77
  hone --version
74
78
  ```
75
79
 
76
- Each option is followed by its value as the next argument; a value that starts with `-` is read as a missing value. A bare `--` where an option is expected is skipped and the options after it are still read, so `pnpm run <script> -- <options>` works whether or not the package manager passes the `--` on; a `--` where a value is expected is a missing value, like any value that starts with `-`. `--help` or `-h` after a command prints that command's help instead of running it, and `hone --help <command>` prints the same. `hone --help` and `hone --version` take nothing else after them.
80
+ Each option is followed by its value as the next argument; a value that starts with `-` is read as a missing value. An option followed by `...` may be given more than once, one value each time; any other option given twice is `arguments-invalid`. A bare `--` where an option is expected is skipped and the options after it are still read, so `pnpm run <script> -- <options>` works whether or not the package manager passes the `--` on; a `--` where a value is expected is a missing value, like any value that starts with `-`. `--help` or `-h` after a command prints that command's help instead of running it, and `hone --help <command>` prints the same. `hone --help` and `hone --version` take nothing else after them.
77
81
 
78
82
  `hone --help` prints:
79
83
 
@@ -83,8 +87,10 @@ usage: hone <command> [options]
83
87
  Checks a repository against the disciplines it selects, applies its recorded exceptions and prints one verdict.
84
88
 
85
89
  commands:
86
- check check the repository against the disciplines it selects and print the report, ending in its verdict
87
- project write the native configuration each selected embedded mechanism needs, printing each file as written or unchanged
90
+ check check the repository against the disciplines it selects and print the report, ending in its verdict
91
+ project write the native configuration each selected embedded mechanism needs, printing each file as written or unchanged
92
+ record-debt add a reason-only file carve-out to the exception records for each clause and file the check finds broken, as inherited debt, printing each pair and what was done
93
+ split-records move the exception records from discipline-exceptions.json into the discipline-exceptions folder, one file for each record kind and discipline, printing each file as written or removed
88
94
 
89
95
  options:
90
96
  --help, -h print this help; after a command, print that command's help
@@ -136,6 +142,46 @@ exit codes:
136
142
  2 any failure
137
143
  ```
138
144
 
145
+ `hone record-debt --help` prints:
146
+
147
+ ```text
148
+ usage: hone record-debt --repo <dir> --base-revision <revision> [--leave <path>]...
149
+
150
+ add a reason-only file carve-out to the exception records for each clause and file the check finds broken, as inherited debt, printing each pair and what was done
151
+
152
+ options:
153
+ --repo <dir>
154
+ the folder that holds disciplines.json, usually the repository root
155
+ --base-revision <revision>
156
+ the branch's base, the revision the run that assesses decay is given, such as origin/main; a file it does not hold gets no record
157
+ --leave <path>
158
+ a file or folder, relative to --repo, that gets no record because a person records it as an authorised location; give it once for each path
159
+ --help, -h
160
+ print this help
161
+
162
+ exit codes:
163
+ 0 every record needed was written, or none was needed
164
+ 2 a load failure: an input could not be loaded, a mechanism failed, the records could not be written, or Hone failed unexpectedly
165
+ ```
166
+
167
+ `hone split-records --help` prints:
168
+
169
+ ```text
170
+ usage: hone split-records --repo <dir>
171
+
172
+ move the exception records from discipline-exceptions.json into the discipline-exceptions folder, one file for each record kind and discipline, printing each file as written or removed
173
+
174
+ options:
175
+ --repo <dir>
176
+ the folder that holds disciplines.json, usually the repository root
177
+ --help, -h
178
+ print this help
179
+
180
+ exit codes:
181
+ 0 the records were split, or there was nothing to split
182
+ 2 a load failure: the records could not be read, placed or written, or Hone failed unexpectedly
183
+ ```
184
+
139
185
  `hone --version` prints the version of the installed package, read from its `package.json`, and exits `0`:
140
186
 
141
187
  | Output | Line |
@@ -151,14 +197,15 @@ exit codes:
151
197
  | `excluded` | informational | paths that `exclude` in `disciplines.json` leaves out |
152
198
  | `notAdopted` | informational | clauses marked `not-adopted` |
153
199
  | `notRun` | informational | clauses marked `not-run` |
200
+ | `editions` | informational | the edition each clause ran, for clauses whose check has more than one edition |
154
201
  | `findings` | failing | each place a clause is broken |
155
202
  | `exempted` | informational | findings an exception covers, with the exceptions that cover them |
156
203
  | `uncovered` | failing | clauses of a selected discipline that are neither selected nor marked |
157
204
  | `stale` | failing | exceptions that cover no finding |
158
205
  | `forfeited` | failing | file carve-outs on files this change touched |
159
- | `unrecorded` | failing | native exceptions with no record in `discipline-exceptions.json` |
206
+ | `unrecorded` | failing | native exceptions with no exception record |
160
207
  | `doublyHeld` | failing | files both authorised and carved out for one clause |
161
- | `invalidRecords` | failing | entries in `discipline-exceptions.json` that cannot be applied |
208
+ | `invalidRecords` | failing | exception records that cannot be applied |
162
209
  | `unmeasured` | failing | what this run could not measure |
163
210
  | `projectionProblems` | failing | ESLint projections that are out of date |
164
211
  | `assessment` | informational | concerns this run left to another run |
@@ -196,6 +243,7 @@ Each section's entries take one of these shapes. An exempted finding repeats ` e
196
243
  | `excluded` | `<path>` |
197
244
  | `notAdopted` | `<clause>` |
198
245
  | `notRun` | `<clause> adopted, mechanism not run: enforced by review` |
246
+ | `editions` | `<clause> <mechanism> edition <edition> of <latest>` |
199
247
  | `findings` | `<clause> <mechanism> <file>:<line>:<column> <snippet>` |
200
248
  | `exempted` | `<clause> <mechanism> <file>:<line>:<column> <snippet> exempted by <record kind>` |
201
249
  | `exempted` | `<clause> <mechanism> <file>:<line>:<column> <snippet> exempted by <record kind> imported from <source>` |
@@ -224,6 +272,16 @@ Each section's entries take one of these shapes. An exempted finding repeats ` e
224
272
  | `invalidRecords` | `exceptions[<index>] import-unverified <detail>` |
225
273
  | `invalidRecords` | `exceptions[<index>] non-exemptible-clause <clause>` |
226
274
  | `invalidRecords` | `exceptions[<index>] duplicate of <earlier index>` |
275
+ | `invalidRecords` | `<records file> exceptions[<index>] clause-unparseable <detail>` |
276
+ | `invalidRecords` | `<records file> exceptions[<index>] clause-not-selected <clause>` |
277
+ | `invalidRecords` | `<records file> exceptions[<index>] clause-not-adopted <clause>` |
278
+ | `invalidRecords` | `<records file> exceptions[<index>] clause-not-run <clause>` |
279
+ | `invalidRecords` | `<records file> exceptions[<index>] file-not-repo-path <file>` |
280
+ | `invalidRecords` | `<records file> exceptions[<index>] why-chain-refused <detail>` |
281
+ | `invalidRecords` | `<records file> exceptions[<index>] evidence-refused <detail>` |
282
+ | `invalidRecords` | `<records file> exceptions[<index>] import-unverified <detail>` |
283
+ | `invalidRecords` | `<records file> exceptions[<index>] non-exemptible-clause <clause>` |
284
+ | `invalidRecords` | `<records file> exceptions[<index>] duplicate of <earlier records file> exceptions[<earlier index>]` |
227
285
  | `unmeasured` | `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` |
228
286
  | `unmeasured` | `forfeiture-unmeasured base-git-failed <revision>: git could not list the files changed since that revision and said <git message>; 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` |
229
287
  | `unmeasured` | `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` |
@@ -266,6 +324,10 @@ A run that cannot decide prints one line and exits `2`. It prints the same line
266
324
  | `install-root-unresolvable` | `load failure: install-root-unresolvable <url> <detail>` |
267
325
  | `file-unreadable` | `load failure: file-unreadable <path> <detail>` |
268
326
  | `file-malformed` | `load failure: file-malformed <path> <detail>` |
327
+ | `file-unwritable` | `load failure: file-unwritable <path> <detail>` |
328
+ | `records-in-both-layouts` | `load failure: records-in-both-layouts <path> <records folder>: Hone reads exception records from one layout; keep each record in one of them and remove the other` |
329
+ | `records-unsplittable` | `load failure: records-unsplittable <path> <detail>` |
330
+ | `why-chains-required` | `load failure: why-chains-required <path>: hone record-debt writes records that give only a reason, and this file requires a whyChain on every record; set "fileExceptionWhyChains": "optional" in it to accept them` |
269
331
  | `unsupported-version` | `load failure: unsupported-version <path> <version found>` |
270
332
  | `reserved-rule-set-name` | `load failure: reserved-rule-set-name <rule set>` |
271
333
  | `rule-set-name-collision` | `load failure: rule-set-name-collision <rule set> <other rule set>` |
@@ -301,8 +363,8 @@ An `arguments-invalid` line says what was wrong with the command as typed. Its w
301
363
 
302
364
  | Problem | Line |
303
365
  | --- | --- |
304
- | `command-missing` | `load failure: arguments-invalid hone needs a command, check or project; run hone --help for usage` |
305
- | `command-unknown` | `load failure: arguments-invalid hone has no command "<given>"; its commands are check and project; run hone --help for usage` |
366
+ | `command-missing` | `load failure: arguments-invalid hone needs a command, check, project, record-debt or split-records; run hone --help for usage` |
367
+ | `command-unknown` | `load failure: arguments-invalid hone has no command "<given>"; its commands are check, project, record-debt and split-records; run hone --help for usage` |
306
368
  | `flag-extra` | `load failure: arguments-invalid hone <flag> takes nothing after it, not "<given>"; run hone --help for usage` |
307
369
  | `argument-unexpected` | `load failure: arguments-invalid hone <command> takes options, not "<given>" on its own; give each option and its value as two arguments, as in <option> <value>; run hone <command> --help for its options` |
308
370
  | `option-unknown` | `load failure: arguments-invalid hone <command> has no option "<given>"; run hone <command> --help for its options` |
@@ -313,6 +375,7 @@ An `arguments-invalid` line says what was wrong with the command as typed. Its w
313
375
  | `choice-invalid` | `load failure: arguments-invalid <option> takes <values>, not "<given>"` |
314
376
  | `option-removed` | `load failure: arguments-invalid removed: "--waived-clauses"; in clauses, mark a clause "not-run" when its mechanism does not run, or "not-adopted" when its rule does not apply; see MIGRATING.md section 12` |
315
377
  | `repo-unresolvable` | `load failure: arguments-invalid --repo <dir> resolves to no absolute path` |
378
+ | `path-invalid` | `load failure: arguments-invalid <option> takes one exact file or folder inside --repo, relative to it, with forward slashes and no *, not "<given>"` |
316
379
 
317
380
  ## hone project
318
381
 
@@ -324,3 +387,26 @@ An `arguments-invalid` line says what was wrong with the command as typed. Its w
324
387
  | `project` | `<path> unchanged` |
325
388
  | `project` | `<path> removed` |
326
389
  | `project` | `<path> left-in-place` |
390
+
391
+ ## hone record-debt
392
+
393
+ `hone record-debt` runs the check, then prints one line for each clause and file that has a finding, or an inline disable or TypeScript directive under `unrecorded`, ordered by file and then by clause. A `recorded` line is a `file-carve-out` it added to the exception records, in whichever [layout](../README.md#the-split-layout) the repository keeps them; every other line names a pair it wrote nothing for. It prints nothing when the check finds nothing to record. The `<path>` on a `left` line is the `--leave` value that covers the file.
394
+
395
+ | Output | Line |
396
+ | --- | --- |
397
+ | `record-debt` | `<clause> recorded <file>` |
398
+ | `record-debt` | `<clause> already-recorded <file>: <records file> already holds a record on this clause and file; the check says why it does not hold` |
399
+ | `record-debt` | `<clause> left <file>: under --leave <path>; record it as an authorised-location with its own reason, or fix it` |
400
+ | `record-debt` | `<clause> new-file <file>: the base revision does not hold this file, so its debt was not inherited; fix it, or record it with its own reason` |
401
+ | `record-debt` | `<clause> refused <file>: the clause's discipline refuses exceptions; fix it` |
402
+
403
+ ## hone split-records
404
+
405
+ `hone split-records` moves a repository's exception records from `discipline-exceptions.json` into the `discipline-exceptions` folder. It prints a `written` line for each file it writes, in path order, then a `removed` line for `discipline-exceptions.json`. When the records are already split, or `discipline-exceptions.json` is absent or holds no records, it prints one line, changes nothing and exits `0`. A records file that holds a record whose clause names no discipline, or keys other than `version` and `exceptions`, is `records-unsplittable`, and nothing is written.
406
+
407
+ | Output | Line |
408
+ | --- | --- |
409
+ | `split-records` | `<path> written` |
410
+ | `split-records` | `<path> removed` |
411
+ | `split-records` | `<path> already holds the records split: nothing to split` |
412
+ | `split-records` | `<path> holds no records: nothing to split` |
@@ -1,10 +1,11 @@
1
1
  import {
2
2
  stringListClauseSettings
3
- } from "../../../chunks/chunk-YL6WR3QW.js";
3
+ } from "../../../chunks/chunk-Y4SMWOD2.js";
4
4
  import {
5
5
  gatheredOutcomes
6
6
  } from "../../../chunks/chunk-LDQUT742.js";
7
- import "../../../chunks/chunk-5X2BR42Y.js";
7
+ import "../../../chunks/chunk-FR4FASVM.js";
8
+ import "../../../chunks/chunk-MXSIQPCV.js";
8
9
  import {
9
10
  folderScope
10
11
  } from "../../../chunks/chunk-QWA6OVLC.js";
@@ -7,7 +7,11 @@
7
7
  "clause": "test-body-logic",
8
8
  "settings": {
9
9
  "module": "test-body-logic.js"
10
- }
10
+ },
11
+ "editions": [
12
+ "1",
13
+ "2"
14
+ ]
11
15
  }
12
16
  ]
13
17
  }
@@ -1,3 +1,11 @@
1
+ import {
2
+ FIRST_EDITION,
3
+ editionSchema
4
+ } from "../../../chunks/chunk-RWQ4UNKY.js";
5
+ import {
6
+ editionReaches
7
+ } from "../../../chunks/chunk-NA5L6PUE.js";
8
+ import "../../../chunks/chunk-MXSIQPCV.js";
1
9
  import {
2
10
  folderScope
3
11
  } from "../../../chunks/chunk-QWA6OVLC.js";
@@ -7,6 +15,7 @@ var testFileEligibility = (request) => {
7
15
  if (folderScope({ file: request.file }) === "generated") return "skipped";
8
16
  return request.file.endsWith(".test.ts") || request.file.endsWith(".test.tsx") ? "eligible" : "skipped";
9
17
  };
18
+ var SECOND_EDITION = editionSchema.parse("2");
10
19
  var BANNED_DYNAMIC_METHODS = [
11
20
  "at",
12
21
  "charAt",
@@ -63,6 +72,47 @@ var BANNED_DYNAMIC_METHODS = [
63
72
  "with"
64
73
  ];
65
74
  var BANNED_MUTATION_METHODS = ["copyWithin", "fill", "pop", "push", "reverse", "shift", "splice", "unshift"];
75
+ var EVERY_METHOD = "every-method";
76
+ var COMPUTING_NAMESPACES = /* @__PURE__ */ new Map([
77
+ ["JSON", ["stringify", "parse"]],
78
+ ["Object", ["assign", "fromEntries"]],
79
+ ["Array", ["from"]],
80
+ ["Math", EVERY_METHOD]
81
+ ]);
82
+ var firstEditionLogic = (request) => {
83
+ const { syntaxApi, node } = request;
84
+ const isStructural = syntaxApi.isIfStatement(node) || syntaxApi.isTryStatement(node) || syntaxApi.isConditionalExpression(node) || syntaxApi.isVariableStatement(node) && (node.declarationList.flags & syntaxApi.NodeFlags.Let) === syntaxApi.NodeFlags.Let;
85
+ const methodName = syntaxApi.isCallExpression(node) && syntaxApi.isPropertyAccessExpression(node.expression) ? node.expression.name.text : void 0;
86
+ return isStructural || methodName !== void 0 && (BANNED_DYNAMIC_METHODS.includes(methodName) || BANNED_MUTATION_METHODS.includes(methodName)) ? "logic" : "plain";
87
+ };
88
+ var shortCircuitOperators = (request) => [
89
+ request.syntaxApi.SyntaxKind.QuestionQuestionToken,
90
+ request.syntaxApi.SyntaxKind.BarBarToken,
91
+ request.syntaxApi.SyntaxKind.AmpersandAmpersandToken,
92
+ request.syntaxApi.SyntaxKind.QuestionQuestionEqualsToken,
93
+ request.syntaxApi.SyntaxKind.BarBarEqualsToken,
94
+ request.syntaxApi.SyntaxKind.AmpersandAmpersandEqualsToken
95
+ ];
96
+ var namespaceComputation = (request) => {
97
+ const { syntaxApi, node } = request;
98
+ if (!syntaxApi.isCallExpression(node) || !syntaxApi.isPropertyAccessExpression(node.expression)) return "plain";
99
+ const receiver = node.expression.expression;
100
+ if (!syntaxApi.isIdentifier(receiver)) return "plain";
101
+ const methods = COMPUTING_NAMESPACES.get(receiver.text);
102
+ if (methods === void 0) return "plain";
103
+ return methods === EVERY_METHOD || methods.includes(node.expression.name.text) ? "logic" : "plain";
104
+ };
105
+ var secondEditionLogic = (request) => {
106
+ const { syntaxApi, node } = request;
107
+ const isShortCircuit = syntaxApi.isBinaryExpression(node) && shortCircuitOperators({ syntaxApi }).includes(node.operatorToken.kind);
108
+ const isOptionalChain = (syntaxApi.isPropertyAccessExpression(node) || syntaxApi.isElementAccessExpression(node) || syntaxApi.isCallExpression(node)) && node.questionDotToken !== void 0;
109
+ return isShortCircuit || isOptionalChain || syntaxApi.isSwitchStatement(node) || namespaceComputation(request) === "logic" ? "logic" : "plain";
110
+ };
111
+ var editionIntroducing = (request) => {
112
+ if (firstEditionLogic(request) === "logic") return FIRST_EDITION;
113
+ if (secondEditionLogic(request) === "logic") return SECOND_EDITION;
114
+ return void 0;
115
+ };
66
116
  var snippetAt = (request) => {
67
117
  const snippet = request.source.slice(request.position, request.position + 80).replace(/\n/g, " ");
68
118
  return snippet.length === 80 ? `${snippet}\u2026` : snippet;
@@ -83,13 +133,14 @@ var check = {
83
133
  const hits = [];
84
134
  return {
85
135
  enter: ({ node }) => {
86
- const isStructural = syntaxApi.isIfStatement(node) || syntaxApi.isTryStatement(node) || syntaxApi.isConditionalExpression(node) || syntaxApi.isVariableStatement(node) && (node.declarationList.flags & syntaxApi.NodeFlags.Let) === syntaxApi.NodeFlags.Let;
87
- const methodName = syntaxApi.isCallExpression(node) && syntaxApi.isPropertyAccessExpression(node.expression) ? node.expression.name.text : void 0;
88
- if (!isStructural && (methodName === void 0 || !BANNED_DYNAMIC_METHODS.includes(methodName) && !BANNED_MUTATION_METHODS.includes(methodName))) return;
136
+ const introducedIn = editionIntroducing({ syntaxApi, node });
137
+ if (introducedIn === void 0) return;
138
+ const reaching = clauses.filter((clause) => editionReaches({ edition: clause.edition, introducedIn }) === "reached");
139
+ if (reaching.length === 0) return;
89
140
  const position = node.getStart(sourceFile);
90
141
  const anchor = anchorAt({ position });
91
142
  const snippet = snippetAt({ source: sourceFile.text, position });
92
- hits.push(...clauses.map((clause) => ({ clause: clause.address, anchor, snippet })));
143
+ hits.push(...reaching.map((clause) => ({ clause: clause.address, anchor, snippet })));
93
144
  },
94
145
  finish: () => hits
95
146
  };
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  stringListClauseSettings
3
- } from "../../../chunks/chunk-YL6WR3QW.js";
3
+ } from "../../../chunks/chunk-Y4SMWOD2.js";
4
4
  import {
5
5
  typeDirectiveReaderFor
6
- } from "../../../chunks/chunk-NILRE23T.js";
6
+ } from "../../../chunks/chunk-Z4UBS7WI.js";
7
7
  import {
8
8
  gatheredOutcomes
9
9
  } from "../../../chunks/chunk-LDQUT742.js";
10
10
  import {
11
11
  clauseAddressText
12
- } from "../../../chunks/chunk-5X2BR42Y.js";
12
+ } from "../../../chunks/chunk-FR4FASVM.js";
13
+ import "../../../chunks/chunk-MXSIQPCV.js";
13
14
  import {
14
15
  folderScope
15
16
  } from "../../../chunks/chunk-QWA6OVLC.js";
@@ -2,16 +2,16 @@ import {
2
2
  TYPE_DIRECTIVES,
3
3
  directiveEscapesIn,
4
4
  escapesOf
5
- } from "../../../chunks/chunk-NILRE23T.js";
5
+ } from "../../../chunks/chunk-Z4UBS7WI.js";
6
6
  import {
7
7
  hitSchema,
8
8
  runnerResultSchema
9
- } from "../../../chunks/chunk-RNXPEK2U.js";
9
+ } from "../../../chunks/chunk-BLGGM7AV.js";
10
10
  import {
11
11
  createDefaultPackageLocationPort,
12
12
  installRootOfRunnerEntry,
13
13
  toolchainBoundStandaloneRunner
14
- } from "../../../chunks/chunk-OKQHVZLO.js";
14
+ } from "../../../chunks/chunk-CBWWAKQY.js";
15
15
  import {
16
16
  gatheredOutcomes
17
17
  } from "../../../chunks/chunk-LDQUT742.js";
@@ -24,10 +24,11 @@ import {
24
24
  loadedPeer,
25
25
  moduleExtensionOf,
26
26
  moduleFileForm
27
- } from "../../../chunks/chunk-LHVFZMXD.js";
27
+ } from "../../../chunks/chunk-MZTLH4EU.js";
28
28
  import {
29
29
  sameClauseAddress
30
- } from "../../../chunks/chunk-5X2BR42Y.js";
30
+ } from "../../../chunks/chunk-FR4FASVM.js";
31
+ import "../../../chunks/chunk-MXSIQPCV.js";
31
32
 
32
33
  // mechanisms/audit/runner/create-walker-runner.ts
33
34
  import { z as z4 } from "zod";
@@ -1,12 +1,15 @@
1
+ import "../../../chunks/chunk-YLZ73C7O.js";
1
2
  import {
2
3
  eslintConfigLookupSchema,
3
4
  parsedJson
4
- } from "../../../chunks/chunk-OVEQ37JQ.js";
5
+ } from "../../../chunks/chunk-PVCA3ISA.js";
6
+ import "../../../chunks/chunk-RWQ4UNKY.js";
7
+ import "../../../chunks/chunk-NA5L6PUE.js";
5
8
  import {
6
9
  createDefaultPackageLocationPort,
7
10
  installRootOfRunnerEntry,
8
11
  toolchainBoundEmbeddedRunner
9
- } from "../../../chunks/chunk-OKQHVZLO.js";
12
+ } from "../../../chunks/chunk-CBWWAKQY.js";
10
13
  import {
11
14
  gatheredOutcomes,
12
15
  listedOutcome
@@ -28,12 +31,13 @@ import {
28
31
  moduleFileForm,
29
32
  repoPathSchema,
30
33
  versionSupport
31
- } from "../../../chunks/chunk-LHVFZMXD.js";
34
+ } from "../../../chunks/chunk-MZTLH4EU.js";
32
35
  import {
33
36
  TOOL_IDENTITY,
34
37
  clauseAddressText,
35
38
  sameClauseAddress
36
- } from "../../../chunks/chunk-5X2BR42Y.js";
39
+ } from "../../../chunks/chunk-FR4FASVM.js";
40
+ import "../../../chunks/chunk-MXSIQPCV.js";
37
41
 
38
42
  // mechanisms/eslint/runner/create-eslint-runner.ts
39
43
  import { z as z9 } from "zod";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hailstails/hone",
3
- "version": "0.1.0-pre.9",
3
+ "version": "1.1.0",
4
4
  "description": "Checks a repository against the disciplines it selects, applies its recorded exceptions and prints one verdict.",
5
5
  "keywords": [
6
6
  "disciplines",