@hailstails/hone 1.4.0 → 1.5.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 (121) hide show
  1. package/ADOPTING.md +8 -8
  2. package/CHANGELOG.md +14 -0
  3. package/MIGRATING.md +17 -0
  4. package/README.md +10 -10
  5. package/api/testing.js +2 -2
  6. package/chunks/{chunk-FEWCJU7H.js → chunk-2O46EB4E.js} +6 -0
  7. package/chunks/{chunk-6SM3HKWO.js → chunk-5U4VTFD5.js} +88 -51
  8. package/core/check/tool-command.js +379 -56
  9. package/core/mechanism-port/runner-result-types.d.ts +4 -0
  10. package/docs/adding-a-discipline-or-mechanism.md +2 -0
  11. package/docs/extending.md +1 -0
  12. package/docs/output-contract.md +17 -6
  13. package/mechanisms/audit/CD-27/test-body-logic.js +5 -2
  14. package/mechanisms/audit/runner/runner.js +5 -3
  15. package/mechanisms/eslint/runner/runner.js +7 -3
  16. package/methods/assessment-template.md +2 -2
  17. package/methods/lenses/clean-architecture.md +7 -8
  18. package/methods/lenses/defended-on-intent.md +2 -2
  19. package/methods/lenses/di-discipline.md +10 -13
  20. package/methods/lenses/function-first.md +16 -18
  21. package/package.json +1 -1
  22. package/rules/CD-1/CHECKS.md +4 -2
  23. package/rules/CD-1/README.md +6 -19
  24. package/rules/CD-10/CHECKS.md +5 -3
  25. package/rules/CD-10/README.md +6 -18
  26. package/rules/CD-11/CHECKS.md +4 -2
  27. package/rules/CD-11/README.md +6 -16
  28. package/rules/CD-12/CHECKS.md +4 -2
  29. package/rules/CD-12/README.md +6 -16
  30. package/rules/CD-13/CHECKS.md +4 -2
  31. package/rules/CD-13/README.md +6 -16
  32. package/rules/CD-14/CHECKS.md +3 -1
  33. package/rules/CD-14/README.md +6 -19
  34. package/rules/CD-15/CHECKS.md +3 -1
  35. package/rules/CD-15/README.md +5 -20
  36. package/rules/CD-16/CHECKS.md +3 -1
  37. package/rules/CD-16/README.md +6 -6
  38. package/rules/CD-17/CHECKS.md +3 -1
  39. package/rules/CD-17/README.md +6 -19
  40. package/rules/CD-18/CHECKS.md +4 -2
  41. package/rules/CD-18/README.md +6 -16
  42. package/rules/CD-19/CHECKS.md +8 -6
  43. package/rules/CD-19/README.md +6 -20
  44. package/rules/CD-2/CHECKS.md +5 -3
  45. package/rules/CD-2/README.md +6 -21
  46. package/rules/CD-20/CHECKS.md +3 -1
  47. package/rules/CD-20/README.md +6 -6
  48. package/rules/CD-21/CHECKS.md +4 -2
  49. package/rules/CD-21/README.md +6 -15
  50. package/rules/CD-22/CHECKS.md +4 -2
  51. package/rules/CD-22/README.md +6 -15
  52. package/rules/CD-23/CHECKS.md +5 -3
  53. package/rules/CD-23/README.md +6 -17
  54. package/rules/CD-24/CHECKS.md +3 -1
  55. package/rules/CD-24/README.md +6 -6
  56. package/rules/CD-25/CHECKS.md +3 -1
  57. package/rules/CD-25/README.md +5 -21
  58. package/rules/CD-26/CHECKS.md +5 -3
  59. package/rules/CD-26/README.md +6 -20
  60. package/rules/CD-27/CHECKS.md +16 -7
  61. package/rules/CD-27/README.md +6 -20
  62. package/rules/CD-28/CHECKS.md +4 -2
  63. package/rules/CD-28/README.md +6 -16
  64. package/rules/CD-29/CHECKS.md +4 -2
  65. package/rules/CD-29/README.md +6 -14
  66. package/rules/CD-3/CHECKS.md +3 -1
  67. package/rules/CD-3/README.md +6 -17
  68. package/rules/CD-30/CHECKS.md +4 -2
  69. package/rules/CD-30/README.md +6 -15
  70. package/rules/CD-31/CHECKS.md +4 -2
  71. package/rules/CD-31/README.md +6 -14
  72. package/rules/CD-32/CHECKS.md +3 -1
  73. package/rules/CD-32/README.md +2 -0
  74. package/rules/CD-33/CHECKS.md +3 -1
  75. package/rules/CD-33/README.md +2 -0
  76. package/rules/CD-34/CHECKS.md +3 -1
  77. package/rules/CD-34/README.md +2 -0
  78. package/rules/CD-39/CHECKS.md +3 -1
  79. package/rules/CD-39/README.md +2 -0
  80. package/rules/CD-4/CHECKS.md +4 -2
  81. package/rules/CD-4/README.md +6 -17
  82. package/rules/CD-40/CHECKS.md +3 -1
  83. package/rules/CD-40/README.md +6 -20
  84. package/rules/CD-41/CHECKS.md +4 -2
  85. package/rules/CD-41/README.md +6 -22
  86. package/rules/CD-42/CHECKS.md +3 -1
  87. package/rules/CD-42/README.md +6 -16
  88. package/rules/CD-43/CHECKS.md +3 -1
  89. package/rules/CD-43/README.md +6 -18
  90. package/rules/CD-44/CHECKS.md +3 -1
  91. package/rules/CD-44/README.md +6 -17
  92. package/rules/CD-45/CHECKS.md +4 -2
  93. package/rules/CD-45/README.md +6 -16
  94. package/rules/CD-46/CHECKS.md +3 -1
  95. package/rules/CD-46/README.md +2 -0
  96. package/rules/CD-47/CHECKS.md +4 -2
  97. package/rules/CD-47/README.md +4 -20
  98. package/rules/CD-5/CHECKS.md +4 -2
  99. package/rules/CD-5/README.md +6 -19
  100. package/rules/CD-6/CHECKS.md +3 -1
  101. package/rules/CD-6/README.md +6 -19
  102. package/rules/CD-7/CHECKS.md +3 -1
  103. package/rules/CD-7/README.md +6 -20
  104. package/rules/CD-7a/CHECKS.md +3 -1
  105. package/rules/CD-7a/README.md +6 -17
  106. package/rules/CD-8/CHECKS.md +3 -1
  107. package/rules/CD-8/README.md +6 -17
  108. package/rules/CD-9/CHECKS.md +4 -2
  109. package/rules/CD-9/README.md +6 -17
  110. package/rules/README.md +71 -54
  111. package/rules/SPIRIT.md +3 -3
  112. package/rules/cases.md +94 -0
  113. package/rules/numbers.md +155 -0
  114. package/rules/principles.md +89 -0
  115. package/rules/records.md +150 -0
  116. package/rules/rules.md +149 -0
  117. package/rules/sources.md +142 -0
  118. package/rules/typescript/checks.md +219 -0
  119. package/rules/typescript/recipes.md +361 -0
  120. package/rules/typescript/symptoms.json +1005 -0
  121. package/rules/typescript/symptoms.md +612 -0
@@ -54,7 +54,7 @@ In the tables below, a word in angle brackets, such as `<clause>`, stands for a
54
54
  | `<count>`, `<index>`, `<earlier index>` | a whole number; an index counts from 0, within the file that holds the record | never |
55
55
  | `<version>` | the installed package's version | never |
56
56
  | `<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 |
57
- | `<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 |
57
+ | `<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>`, `<symptom page>` | a path, as described below | may hold a space |
58
58
  | `<folders>` | paths separated by `, ` | may hold a space |
59
59
  | `<folder>` | the folder that holds a `<slice>` | may hold a space |
60
60
  | `<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 |
@@ -64,6 +64,9 @@ In the tables below, a word in angle brackets, such as `<clause>`, stands for a
64
64
  | `<url>` | the module URL Hone could not resolve, as given | may hold a space |
65
65
  | `<snippet>` | the source text at a finding: at most 200 characters, or the first 200 followed by `…` when it is longer | may hold a space |
66
66
  | `<fix>` | what to write instead of the form a finding flags, as the clause's piece words it | may hold a space |
67
+ | `<symptom>` | a symptom's name in the installed symptom catalogue, which is also its heading's anchor on `<symptom page>`: lowercase letters, digits and hyphens | never |
68
+ | `<indicated>` | the names of the rules and principles the symptom may indicate, in the catalogue's order, each once, separated by `, ` | may hold a space |
69
+ | `<title>`, `<indications>`, `<breach>`, `<recipe>`, `<recipes>`, `<answers>` | the symptom's title; each case it may indicate, lowercased at its start, with ` → ` and the titles it points at separated by `, `, the cases separated by `; `; where its breach usually sits; its recipe's title, or its recipes' titles separated by `; `; and one sentence for each correct use the symptom has, then one for known debt, which every symptom takes: the situation, capitalised, then `: `, the record kind that expresses it, where it sits when the catalogue says, and in brackets that kind's format today or `no record format yet`, the sentences separated by `. ` | may hold a space |
67
70
  | `<fix page>` | the page in the clause's rule folder that its piece names for a fix, such as that rule's `CHECKS.md`, as a path described below | may hold a space |
68
71
  | `<section>` | the section of `<fix page>` that shows that form and what to write instead: lowercase letters, digits and hyphens | never |
69
72
  | `<comment>`, `<script>`, `<option>`, `<source>` | the native exception's comment, the `package.json` script name and the option in it (or the whole script, when a quote in it has no partner), or where an imported record came from | may hold a space |
@@ -96,7 +99,7 @@ commands:
96
99
  check check the repository against the disciplines it selects and print the report, ending in its verdict
97
100
  project write the native configuration each selected embedded mechanism needs, printing each file as written or unchanged
98
101
  record-debt add a file carve-out naming only its clause and file to the exception records for each clause and file the check finds broken, as inherited debt, printing each pair and what was done
99
- prune-debt remove from the exception records each stale or forfeited file carve-out whose file no longer exists, printing each pair removed
102
+ prune-debt remove from the exception records each stale or forfeited file carve-out whose file no longer exists or whose clause its mechanism measured on that file with nothing left to hold it, printing each pair removed
100
103
  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
101
104
 
102
105
  options:
@@ -176,7 +179,7 @@ exit codes:
176
179
  ```text
177
180
  usage: hone prune-debt --repo <dir> [--base-revision <revision>] [--forfeiture <this-run|elsewhere>]
178
181
 
179
- remove from the exception records each stale or forfeited file carve-out whose file no longer exists, printing each pair removed
182
+ remove from the exception records each stale or forfeited file carve-out whose file no longer exists or whose clause its mechanism measured on that file with nothing left to hold it, printing each pair removed
180
183
 
181
184
  options:
182
185
  --repo <dir>
@@ -265,7 +268,7 @@ The verdict line reads `(partial assessment)` whenever the report has an `assess
265
268
 
266
269
  ## Report lines
267
270
 
268
- Each section's entries take one of these shapes. A finding ends with ` fix: <fix> (<fix page>#<section>)` when its clause's piece names what to write instead of the form it flagged and the page that shows it, as `CD-27#test-body-logic` does; an exempted finding never carries it. An exempted finding repeats ` exempted by <record kind>` once for each exception that covers it. In `projectionProblems`, a `<slice>` is the `disciplines.eslint.mjs` projection file of one config root, the repository root or a folder in `eslintConfigRoots`; `unconfigured` means that root has no `eslint.config.*`.
271
+ Each section's entries take one of these shapes. A finding names its symptom with ` symptom: <symptom>, may indicate: <indicated>` after the snippet when the installed symptom catalogue reads one for its clause, and for `CD-27#test-body-logic` for the form it flagged; a finding the catalogue reads no symptom for prints without it. A finding ends with ` fix: <fix> (<fix page>#<section>)` when its clause's piece names what to write instead of the form it flagged and the page that shows it, as `CD-27#test-body-logic` does; an exempted finding never carries either. An exempted finding repeats ` exempted by <record kind>` once for each exception that covers it. In `projectionProblems`, a `<slice>` is the `disciplines.eslint.mjs` projection file of one config root, the repository root or a folder in `eslintConfigRoots`; `unconfigured` means that root has no `eslint.config.*`.
269
272
 
270
273
  | Section | Line |
271
274
  | --- | --- |
@@ -275,6 +278,8 @@ Each section's entries take one of these shapes. A finding ends with ` fix: <fix
275
278
  | `editions` | `<clause> <mechanism> edition <edition> of <latest>` |
276
279
  | `findings` | `<clause> <mechanism> <file>:<line>:<column> <snippet>` |
277
280
  | `findings` | `<clause> <mechanism> <file>:<line>:<column> <snippet> fix: <fix> (<fix page>#<section>)` |
281
+ | `findings` | `<clause> <mechanism> <file>:<line>:<column> <snippet> symptom: <symptom>, may indicate: <indicated>` |
282
+ | `findings` | `<clause> <mechanism> <file>:<line>:<column> <snippet> symptom: <symptom>, may indicate: <indicated> fix: <fix> (<fix page>#<section>)` |
278
283
  | `exempted` | `<clause> <mechanism> <file>:<line>:<column> <snippet> exempted by <record kind>` |
279
284
  | `exempted` | `<clause> <mechanism> <file>:<line>:<column> <snippet> exempted by <record kind> imported from <source>` |
280
285
  | `uncovered` | `<clause>` |
@@ -331,6 +336,12 @@ Each section's entries take one of these shapes. A finding ends with ` fix: <fix
331
336
  | `projectionProblems` | `<mechanism> unconfigured <slice>: <folder> has no <mechanism> configuration file on disk, so nothing loads that slice; run the tool that generates it (for sku, sku configure) before the check` |
332
337
  | `assessment` | `forfeiture elsewhere: 1 file carve-out not checked for decay in this run` |
333
338
  | `assessment` | `forfeiture elsewhere: <count> file carve-outs not checked for decay in this run` |
339
+ | `readFirst` | `<symptom>: <title>. May indicate: <indications>. The breach usually sits <breach>. Recipe: <recipe>. <answers>. Read <symptom page>#<symptom>` |
340
+ | `readFirst` | `<symptom>: <title>. May indicate: <indications>. The breach usually sits <breach>. Recipes: <recipes>. <answers>. Read <symptom page>#<symptom>` |
341
+ | `readFirst` | `<symptom>: <title>. May indicate: <indications>. The breach usually sits <breach>. <answers>. Read <symptom page>#<symptom>` |
342
+ | `readFirst` | `symptom catalogue not read, so no finding names its symptom: file-unreadable <path> <detail>` |
343
+ | `readFirst` | `symptom catalogue not read, so no finding names its symptom: file-malformed <path> <detail>` |
344
+ | `readFirst` | `symptom catalogue not read, so no finding names its symptom: unsupported-version <path> <version found>` |
334
345
  | `readFirst` | `Start from each rule's Spirit below. disciplines.assessment.md, where this repository records its own causes, forward goal and steps for a clause, is not written yet; <adoption guide>#5a-write-the-assessment says how to write it.` |
335
346
  | `readFirst` | `disciplines.assessment.md, where this repository records its own causes, forward goal and steps for a clause, is not written yet; <adoption guide>#5a-write-the-assessment says how to write it.` |
336
347
  | `readFirst` | `Start from each rule's Spirit below. disciplines.assessment.md could not be read.` |
@@ -346,7 +357,7 @@ Each section's entries take one of these shapes. A finding ends with ` fix: <fix
346
357
  | `readFirst` | `prune-debt: 1 file carve-out under stale or forfeited still records debt that is paid; run <prune command> to remove what is paid, then run <project command> and commit the exception records with every disciplines.<mechanism>.mjs it writes` |
347
358
  | `readFirst` | `prune-debt: <count> file carve-outs under stale or forfeited still record debt that is paid; run <prune command> to remove what is paid, then run <project command> and commit the exception records with every disciplines.<mechanism>.mjs it writes` |
348
359
 
349
- `readFirst` has one clause line per clause with findings, in the order the findings first name them, then, last, one `prune-debt` line when any `file-carve-out` under `stale` or `forfeited` names a file that no longer exists: one `hone prune-debt` would remove. It names `hone project` too when any of those records is for a clause whose mechanism, such as `eslint`, puts records into effect through a projection, and then names each such mechanism's projection file, joined by ` and every `. When `disciplines.assessment.md` is not written yet, or cannot be read, one note line comes first; it starts with `Start from each rule's Spirit below.` only when at least one clause line names a rule page. A clause line's first word is a clause address, which holds a `#`, followed by `:`; a note line's first word holds no `#`, which is how a tool tells them apart. The `<adoption guide>` is `ADOPTING.md` in the installed package, such as `node_modules/@hailstails/hone/ADOPTING.md`. A clause line names the clause's section in `disciplines.assessment.md` when the file has one, says `does not assess this clause` when the file is there without that section, and says neither when the file is not read. [The README](../README.md#commands) says how a section is matched.
360
+ `readFirst` opens with one symptom line per symptom a finding names, in the order the findings first name them, each printed once however many findings name it. It names the symptom's cases with the rules and principles each may indicate, where the breach usually sits, its recipe or recipes when it has any, each correct use it has and the kind of record that expresses it, then known debt, which debt answers for every symptom, each with that kind's record format today. When the symptom catalogue cannot be read, `readFirst` opens instead with one line that says so and why; the findings then print as they would with no catalogue, and the verdict and exit code are those the findings decide. `readFirst` then has one clause line per clause with findings, in the order the findings first name them, then, last, one `prune-debt` line when any `file-carve-out` under `stale` or `forfeited` is one `hone prune-debt` would remove. It names `hone project` too when any of those records is for a clause whose mechanism, such as `eslint`, puts records into effect through a projection, and then names each such mechanism's projection file, joined by ` and every `. When `disciplines.assessment.md` is not written yet, or cannot be read, one note line comes after the symptom lines and before the clause lines; it starts with `Start from each rule's Spirit below.` only when at least one clause line names a rule page. A clause line's first word is a clause address, which holds a `#`, followed by `:`; a note line's first word holds no `#`, which is how a tool tells them apart. A symptom line is a note line whose first word is its symptom's name followed by `:`. The `<adoption guide>` is `ADOPTING.md` in the installed package, such as `node_modules/@hailstails/hone/ADOPTING.md`. A clause line names the clause's section in `disciplines.assessment.md` when the file has one, says `does not assess this clause` when the file is there without that section, and says neither when the file is not read. [The README](../README.md#commands) says how a section is matched.
350
361
 
351
362
  ## Load failures
352
363
 
@@ -440,7 +451,7 @@ An `arguments-invalid` line says what was wrong with the command as typed. Its w
440
451
 
441
452
  ## hone prune-debt
442
453
 
443
- `hone prune-debt` runs the check with the `--base-revision` and `--forfeiture` it is given, then removes from the exception records each `file-carve-out` the check lists under `stale` or `forfeited` whose file no longer exists, unless a finding, exempted finding or native exception is still listed on its clause and file. It works in whichever [layout](../README.md#the-split-layout) the repository keeps the records in, and prints one line for each clause and file it removed, ordered by file and then by clause. It leaves every other record for a person: a `file-carve-out` on a file that still exists, stale or forfeited, and an `authorised-location` or `clause-wide-carve-out` under `stale`. It prints nothing when it removed none. It does not write the projection: with an `eslint` clause, run `hone project` after it, as the `readFirst` line says. The text of every other record in a file it changes is kept byte for byte. In the split layout, a rule's file left with no records is deleted; a single `discipline-exceptions.json` left with none holds an empty list.
454
+ `hone prune-debt` runs the check with the `--base-revision` and `--forfeiture` it is given, then removes from the exception records each `file-carve-out` the check lists under `stale` or `forfeited` whose file no longer exists or whose clause and file its mechanism reported as `measured`, unless its clause and file still hold a finding that no record answers, a finding that only debt exempts, or any native exception, recorded or not. A finding an `authorised-location` in force exempts is answered and does not keep the record; a `clause-wide-carve-out` is not an answer. An imported `authorised-location` or one with a legacy why-chain answers nothing on a run whose exception baseline is unmeasured, since that run accepted it without judging it at the base revision, so an unmeasured baseline removes nothing on such an answer. A `file-carve-out` in force beside an `authorised-location` on the same clause and file is listed under `doublyHeld`, not `stale` or `forfeited`, so the command removes neither. It works in whichever [layout](../README.md#the-split-layout) the repository keeps the records in, and prints one line for each clause and file it removed, ordered by file and then by clause. It leaves every other record for a person: a stale or forfeited `file-carve-out` on a file that still exists and that its mechanism did not measure, such as a file the mechanism skips, and an `authorised-location` or `clause-wide-carve-out` under `stale`. It prints nothing when it removed none. It does not write the projection: with an `eslint` clause, run `hone project` after it, as the `readFirst` line says. The text of every other record in a file it changes is kept byte for byte. In the split layout, a rule's file left with no records is deleted; a single `discipline-exceptions.json` left with none holds an empty list.
444
455
 
445
456
  | Output | Line |
446
457
  | --- | --- |
@@ -61,13 +61,16 @@ var PROPERTY_OPTIONAL_CHAIN = secondEdition({
61
61
  });
62
62
  var OPTIONAL_CALL = secondEdition({ fix: "assert.isDefined the function, then call it", section: "an-optional-call" });
63
63
  var SWITCH = secondEdition({ fix: "write one test per case, or one it.each table", section: "a-switch" });
64
- var JSON_CALL = secondEdition({ fix: "CD-19 is the rule for the runtime's standard library", section: "serialising-or-parsing-json" });
64
+ var JSON_CALL = secondEdition({
65
+ fix: "assert the object the unit gives back, written out; a unit that gives back only text should hand over an object, leaving the text to the adapter at its edge",
66
+ section: "serialising-or-parsing-json"
67
+ });
65
68
  var OBJECT_ASSIGN = secondEdition({ fix: "write the object out, spreading what it copies; to give an Error a property, assign it", section: "merging-objects" });
66
69
  var OBJECT_FROM_ENTRIES = secondEdition({ fix: "write the object out as a literal", section: "building-an-object-from-entries" });
67
70
  var ARRAY_FROM = secondEdition({ fix: "write a short array out as a literal; the page shows no form for a long one", section: "building-an-array-from-a-length" });
68
71
  var MATH_CALL = secondEdition({ fix: "write the number out", section: "a-math-call" });
69
72
  var PASSED_ON_FUNCTION = onAllowedFormsPage({
70
- fix: "make it a vi.fn spy with a written-out mockReturnValue, and assert what it was asked with toHaveBeenCalledExactlyOnceWith; CD-25 is the rule for test doubles",
73
+ fix: "make it a vi.fn spy with a written-out mockReturnValue, and assert what it was asked with toHaveBeenCalledExactlyOnceWith; the recipe is Stub with vi.fn",
71
74
  section: "logic-inside-a-function-the-test-passes-on"
72
75
  });
73
76
  var FORMS_IN_PAGE_ORDER = [
@@ -6,7 +6,7 @@ import {
6
6
  import {
7
7
  hitSchema,
8
8
  runnerResultSchema
9
- } from "../../../chunks/chunk-FEWCJU7H.js";
9
+ } from "../../../chunks/chunk-2O46EB4E.js";
10
10
  import {
11
11
  createDefaultPackageLocationPort,
12
12
  installRootOfRunnerEntry,
@@ -490,7 +490,8 @@ var observedReport = (request) => {
490
490
  value: [
491
491
  {
492
492
  hits: inSourceOrder({ clauses: request.clauses, hits: observed.value.hits }),
493
- nativeExceptions: observed.value.nativeExceptions
493
+ nativeExceptions: observed.value.nativeExceptions,
494
+ measured: observed.value.applicable.map((clause) => ({ clause, file: request.file.file }))
494
495
  }
495
496
  ]
496
497
  };
@@ -520,7 +521,8 @@ var walkedReport = (request) => {
520
521
  outcome: "ok",
521
522
  value: {
522
523
  hits: [...fromFiles.value.flatMap((report) => report.hits), ...finished.value],
523
- nativeExceptions: fromFiles.value.flatMap((report) => report.nativeExceptions)
524
+ nativeExceptions: fromFiles.value.flatMap((report) => report.nativeExceptions),
525
+ measured: fromFiles.value.flatMap((report) => report.measured)
524
526
  }
525
527
  };
526
528
  };
@@ -2041,6 +2041,8 @@ var parseableFile = (request) => {
2041
2041
  }
2042
2042
  return file;
2043
2043
  };
2044
+ var ruleCoverageOf = (request) => request.linted.messages.some((message) => message.ruleId === null) ? "rule-less-message" : "every-rule-ran";
2045
+ var measuredOn = (request) => ruleCoverageOf({ linted: request.linted }) === "rule-less-message" ? [] : request.selected.map((entry) => ({ clause: entry.clause.address, file: request.file }));
2044
2046
  var lintedFindings = (request) => {
2045
2047
  const file = parseableFile({ linted: request.linted, path: request.path, repoRoot: request.repoRoot });
2046
2048
  if (file.outcome === "failed") {
@@ -2059,7 +2061,8 @@ var lintedFindings = (request) => {
2059
2061
  outcome: lines,
2060
2062
  map: (sourceLines) => ({
2061
2063
  hits: hitsCutFrom({ file: file.value, ruleHits: reading.value.ruleHits, lines: sourceLines }),
2062
- nativeExceptions: reading.value.nativeExceptions
2064
+ nativeExceptions: reading.value.nativeExceptions,
2065
+ measured: measuredOn({ file: file.value, linted: request.linted, selected: request.selected })
2063
2066
  })
2064
2067
  });
2065
2068
  };
@@ -2145,7 +2148,7 @@ var trackedExceptions = (request) => Promise.all([
2145
2148
  ]).then((outcomes) => gatheredOutcomes({ outcomes }));
2146
2149
  var reportWith = (request) => ({
2147
2150
  outcome: "ok",
2148
- value: { hits: [], nativeExceptions: [], projection: request.projection, slices: request.slices }
2151
+ value: { hits: [], nativeExceptions: [], projection: request.projection, slices: request.slices, measured: [] }
2149
2152
  });
2150
2153
  var ruleIdsOf = (request) => request.selected.map((entry) => entry.ruleId);
2151
2154
  var governedRulesOf = (request) => request.selected.map((entry) => ({ ruleId: entry.ruleId, options: ruleOptionsOf({ settings: entry.settings }) }));
@@ -2209,7 +2212,8 @@ var governedReport = (request) => {
2209
2212
  ...tracked.value
2210
2213
  ],
2211
2214
  projection: request.status.projection,
2212
- slices: request.status.slices
2215
+ slices: request.status.slices,
2216
+ measured: findings.value.flatMap((found) => found.measured)
2213
2217
  }
2214
2218
  };
2215
2219
  });
@@ -1,6 +1,6 @@
1
1
  # Disciplines assessment
2
2
 
3
- What this repository's checks are telling us, and where the code is going. Each clause section sharpens that rule's Spirit section for this codebase; it does not repeat the rule. Read a clause's section before changing code to make its check pass.
3
+ What this repository's checks are telling us, and where the code is going. Each clause section sharpens what the symptoms page says for this codebase; it does not repeat the rule. Read a clause's section before changing code to make its check pass.
4
4
 
5
5
  ## Rules adopted
6
6
 
@@ -26,7 +26,7 @@ Applied in review with the lens each rule page names.
26
26
 
27
27
  ## <clause address>
28
28
 
29
- - **Cause here:** <a cause from the rule's Spirit list, named as the rule names it>. <How it shows in this codebase.>
29
+ - **Cause here:** <a case or breach site from the symptom's "May indicate" or "Breach usually sits", named as the symptoms page names it>. <How it shows in this codebase.>
30
30
  - **Sites:** <count> at <commit>, in <folders or files>. For example <file:line>, <file:line>.
31
31
  - **Forward goal:** <the cleaner design, in this codebase's terms>.
32
32
  - **Steps:** 1. <the step that unlocks the rest> 2. <the next step>
@@ -70,9 +70,9 @@ outer layer?*
70
70
  - **Inner code importing a storage/driver primitive.** Inner layers (domain,
71
71
  application) importing a database driver, a filesystem module, or any raw
72
72
  storage primitive is a finding against the repository-port rule: the inner code
73
- reached around the port. The correct shape is a port type declared with the
74
- domain, a default factory wired at boot, and an adapter file that composes the
75
- driver behind the port.
73
+ reached around the port. The correct shape is a port declared in the domain,
74
+ in a module of its own, an adapter that fulfils it, and one entry-point module
75
+ that builds the adapter and passes it in.
76
76
  - **Type-only does not escape.** A type-only import still couples the consumer to
77
77
  the outer world's type shape; if the rules say type-only follows the same rule,
78
78
  read it the same way as a runtime import.
@@ -147,11 +147,10 @@ re-tagging the rule another lens owns):
147
147
  the boundary observation rather than inventing a layering rule that doesn't carry
148
148
  this lens tag. The wrapping-factory file *is* the permitted seam; the boundary
149
149
  violation is only the import that skips it.
150
- - **Default-factory siblings.** A permitted wrapping/adapter site should also ship
151
- the default factory its DI rules require; the *internal shape* of the port
152
- (capability naming, factory presence, generic binding) is the DI lens's lane.
153
- Note a missing default-factory export as a sibling observation, not as a
154
- clean-architecture finding of its own.
150
+ - **Adapter built outside the root.** One entry-point module builds every
151
+ adapter and passes each one in; the *internal shape* of the port (capability
152
+ naming, generic binding) is the DI lens's lane. Note an adapter built anywhere
153
+ else as a sibling observation, not as a clean-architecture finding of its own.
155
154
 
156
155
  Vague phrasings ("this coupling feels wrong", "might leak data") are the lens's own
157
156
  failure mode — every finding names the specific boundary and the rule that draws it.
@@ -132,8 +132,8 @@ principle (e.g. "every dependency outside the unit boundary is replaced by a tes
132
132
  dependency injection, never reached around") — is "no substitution outside DI". The
133
133
  unlisted mechanism *is* substitution outside DI; it passes the letter and fails the
134
134
  intent. The structural reframing: the unit consumes the dependency as an
135
- injected port through its argument seam, production wires the real
136
- implementation in the wrapping-factory file, the test injects a test double directly;
135
+ injected port through its argument seam, production builds the real
136
+ implementation at the entry point and passes it in, the test injects a test double directly;
137
137
  the PASS retracts and becomes a DI/testing VIOLATION on the owning lens.
138
138
 
139
139
  The three properties that make a finding sound — and that an author can
@@ -15,9 +15,9 @@ the code: every technical binding a unit needs — wall-clock time, process and
15
15
  signal lifecycle, standard-library capabilities (filesystem, crypto, path, net),
16
16
  and third-party services — arrives through a named port the unit receives as a
17
17
  constructor parameter or function argument, never reached for through a global,
18
- an ambient import, or the module system. Each port ships a default factory in
19
- its own module so production wires the real implementation once at the
20
- composition root and tests inject a test double of the same shape. The test face is the
18
+ an ambient import, or the module system. The port's interface is declared in
19
+ the domain, in a module of its own; one entry-point module builds every
20
+ adapter and passes each one in, and tests inject a test double of the same shape. The test face is the
21
21
  mirror image: a unit test replaces *everything* outside the unit's boundary with a
22
22
  test double, and it delivers those doubles the same way production delivers the
23
23
  real ones — through the
@@ -72,18 +72,15 @@ reached for through the module system). Walk the diff for both.
72
72
  violation-in-waiting even if it currently delegates to a helper that itself
73
73
  holds the raw call. The composition pathway must terminate at an injected port,
74
74
  not at a buried global.
75
- - **Missing default factory.** For every port type added or changed in the diff,
76
- confirm a sibling default-factory function exists in the same module (the
77
- production implementation). A port shipped without its default forces every
78
- consumer to hand-roll the wiring and predicts test-side module-mocking
79
- downstream — flag the absence preemptively. Conversely, consumers that
80
- construct an ad-hoc object literal matching the port shape outside test code,
81
- instead of importing the default factory, are reaching around the port.
75
+ - **Adapter built outside the root.** One entry-point module builds every
76
+ adapter and passes each one in. A call to an adapter's factory anywhere but
77
+ the entry point is a finding: the calling unit builds what it should be
78
+ passed. No port is declared in an adapter's module or in its consumer's.
82
79
  - **Composition-root threading.** The boot path (the service-run entrypoint, the
83
- app start module, the kernel composition) must call each default factory and
80
+ app start module, the kernel composition) must build each adapter and
84
81
  pass the port into the unit that declared it. A unit that *declares* a port
85
82
  parameter but is never wired to one in the boot path is a threading violation;
86
- a boot path that constructs a port inline instead of importing its factory is
83
+ a unit outside the boot path that builds an adapter itself is
87
84
  the same gap from the other end.
88
85
  - **Type-level context constraint.** Where the rules require context-consuming
89
86
  middleware (or any generic that reads kernel-shipped context fields) to bind
@@ -157,7 +154,7 @@ lens's own failure mode.
157
154
  ## Output shape
158
155
 
159
156
  Report **two-sided** counts the review asks for: a production-side
160
- block (ambient-binding violations by capability, missing default factories,
157
+ block (ambient-binding violations by capability, adapters built outside the root,
161
158
  threading gaps, unbound context generics) and a test-side block
162
159
  (module-interception violations by mechanism, spy classifications, structural
163
160
  boundary gaps). Every finding is
@@ -31,13 +31,11 @@ Four facets of the same stance:
31
31
  the transformation as data. Counted loops name a counter where the operation
32
32
  is what matters. Side-effect-only iteration is the one place an imperative
33
33
  shape survives, and even then under a `void`-returning callback.
34
- - **Third-party imports confined to wrapping factories.** A library is an
35
- external dependency the domain should not see directly. Each library is
36
- imported in exactly one wrapping-factory file (runtime *and* type-only); every
37
- other module consumes the kernel-supplied factory output. The wrapping factory
38
- *is* the function-first boundary for the library — it is where the unavoidable
39
- `new X(...)` and the raw import are quarantined behind a function-shaped
40
- surface.
34
+ - **Outside dependencies confined to their adapter.** An outside dependency or
35
+ runtime module is imported only in the adapter file for the party it reaches
36
+ (runtime *and* type-only). That adapter fulfils a port and returns our types.
37
+ Nothing re-exports the outside dependency. A library's class is built only in
38
+ its adapter.
41
39
  - **Single-object-argument functions.** Every authored function takes exactly
42
40
  one parameter; multiple values pass as named fields on an object. Positional
43
41
  multi-argument signatures are forbidden except for callbacks whose signature is
@@ -73,9 +71,9 @@ per-declaration not per-export — is suspect until classified. For each, decide
73
71
  one of three buckets:
74
72
 
75
73
  - **justified.** The declaration is the single permitted authored class at its
76
- named site, OR it is a `new X(...)` for an external-library class whose
77
- wrapping-factory file the rules name AND the instance is held inside the
78
- closure and never re-exported as a class. Cite the carve-out; no replacement.
74
+ named site, OR it is a `new X(...)` for an external-library class in
75
+ the adapter for the party it reaches, with a boundary record, AND the instance
76
+ is held inside the closure and never re-exported as a class. Cite the carve-out; no replacement.
79
77
  - **closure-candidate.** The class carries genuine instance state that is
80
78
  *mutated* across method calls (counters, caches, accumulating buffers,
81
79
  subscription registries, in-flight tracking). Replacement: a factory closing
@@ -135,15 +133,15 @@ counter-shaped `for`, not a direction. An async-iterator loop has no source-side
135
133
  carve-out unless the rules grant one — lift it into a Promise-reduce pipeline or
136
134
  an event `forEach` handler by shape.
137
135
 
138
- ### Wrapping-factory pass
136
+ ### Adapter pass
139
137
 
140
- Every raw third-party import (runtime *or* type-only) and every `new X(...)` for
141
- an external-library class is a candidate. For each: is the importing/instantiating
142
- file on the rules' closed list of wrapping-factory files for that library? If
143
- yes → justified. If the library is on the list but the file is not, the import is
144
- in the wrong place — a function-first finding with a DI/port cross-reference (the
145
- raw import escaping its wrapping factory is both a structural and a
146
- boundary-discipline defect; name the boundary lens as the cross-reference). A
138
+ Every raw outside-dependency import (runtime *or* type-only) and every `new X(...)`
139
+ for an external-library class is a candidate. For each: is the importing or
140
+ instantiating file the adapter for the party it reaches, with a boundary record?
141
+ If yes → justified. If not, the import is in the wrong place — a function-first
142
+ finding with a DI/port cross-reference (the raw import escaping its adapter is
143
+ both a structural and a boundary-discipline defect; name the boundary lens as the
144
+ cross-reference). A
147
145
  `new X(...)` for a class the codebase itself authored is a finding twice over —
148
146
  the class should not have been authored, and the instantiation is the symptom.
149
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hailstails/hone",
3
- "version": "1.4.0",
3
+ "version": "1.5.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",
@@ -1,6 +1,8 @@
1
1
  # CD-1 checks
2
2
 
3
- Read [the rule and its spirit](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
3
+ Symptoms: [Claimed type](../typescript/symptoms.md#claimed-type) and [Untyped value](../typescript/symptoms.md#untyped-value).
4
+
5
+ Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: what each check flags and misses, how to fix a flagged site, and how to record an exception.
4
6
 
5
7
  ## Clauses
6
8
 
@@ -31,7 +33,7 @@ const parsed = JSON.parse(text) as any;
31
33
  ```ts
32
34
  const order = orderSchema.parse(JSON.parse(text));
33
35
  ```
34
- Give it a concrete type where it enters: parse it with a schema or a type guard at the boundary, checked at runtime.
36
+ Give it a concrete type where it enters: parse it once with a schema in the adapter for whoever produced it, checked at runtime.
35
37
 
36
38
  In a test file, edition 2 of `CD-27#test-body-logic` flags `JSON.parse`; edition 1, the default, does not.
37
39
 
@@ -2,27 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- `any` is the absence of a type: it tells the compiler to stop checking, and that hole propagates silently through every call site that consumes the value. The whole reason a type system exists — catching shape errors before runtime — is forfeited at each `any`. Give the value a concrete type where it enters, checked at runtime, or a precise union. Every `any` is a violation regardless of stated reason: no code form or setting permits one. Debt a repository carries while adopting the rule is held only in exception records.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [type-soundness](../../methods/lenses/type-soundness.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
8
-
9
- ## Spirit
7
+ **Verdict.** Symptom of [Declared, not asserted](../rules.md#declared-not-asserted).
10
8
 
11
- **What the friction is for.** A value with no type switches off checking for everything it touches. The friction makes "this value has a known shape" the cheapest thing to write, so the compiler keeps doing the work at every use instead of a reader doing it in their head.
9
+ **Read.** [Declared, not asserted](../rules.md#declared-not-asserted).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *Input never typed where it entered.* A request, file, parse or database row crossed in and nobody said what it is. Give it a concrete type at that boundary, checked at runtime.
15
- - *A shape nobody named.* The value has a shape that was never declared. Declare it as a type or a union.
16
- - *A library kept at arm's length.* The vendor's types were awkward, so they were dropped. Wrap the library once and hand the rest of the code your own type.
17
- - *One function serving many shapes.* It takes anything because its callers differ. Split it, or make the variants an explicit union.
18
-
19
- **Where to go.** Every value inside the codebase has a known type. Unknown data becomes concrete where it arrives, not somewhere further in. A high count is usually one or two boundaries that were never built; build those first and most sites go with them.
11
+ Review lens: [type-soundness](../../methods/lenses/type-soundness.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
20
12
 
21
- **Reactions to distrust.**
22
- - "It's just tests." A test that needs an untyped value builds its input the wrong way. Build the real type.
23
- - "The library forces it." It forces it at one call. One wrapping file holds that.
24
- - "Swap it for unknown." Unknown carried inward is the same debt, deferred. Very few values should stay unknown past the boundary.
13
+ ## Spirit
25
14
 
26
- **Principles behind it.**
27
- - *Parse, don't validate* (Alexis King). Turn untyped input into a typed value once, where it arrives, so everything after it can rely on the type.
28
- - *Make illegal states unrepresentable* (Yaron Minsky). A precise type or union rules out shapes the code cannot handle; an untyped value rules out nothing.
15
+ Start from the symptom a finding names: [Claimed type](../typescript/symptoms.md#claimed-type) and [Untyped value](../typescript/symptoms.md#untyped-value). Each symptom names the cases it may indicate and the rules they point at. The why is on [The type checker proves it](../principles.md#the-type-checker-proves-it).
@@ -1,6 +1,8 @@
1
1
  # CD-10 checks
2
2
 
3
- Read [the rule and its spirit](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
3
+ Symptoms: [Throw or catch in a test](../typescript/symptoms.md#throw-or-catch-in-a-test) and [Thrown non-error](../typescript/symptoms.md#thrown-non-error).
4
+
5
+ Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
4
6
 
5
7
  ## Clauses
6
8
 
@@ -38,11 +40,11 @@ it("loads the account", () => {
38
40
  Assert on the whole result. Branching in tests is also reported by CD-27.
39
41
 
40
42
  ## Exceptions
41
- Add an entry to `discipline-exceptions.json` at the repository root. Use `authorised-location` when a test file legitimately needs a throw, such as a shared test harness. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
43
+ Add an entry to `discipline-exceptions.json` at the repository root. Use `file-carve-out` for debt in one file: it is forfeited once the file is touched, and needs no `whyChain`. The form accepts an `authorised-location` for this clause, as for any; in spirit [Throw or catch in a test](../typescript/symptoms.md#throw-or-catch-in-a-test) has no correct use, and a reviewer refuses one. See [discipline-exceptions.json](../../README.md#discipline-exceptionsjson).
42
44
 
43
45
  ```json
44
46
  { "version": 1, "exceptions": [
45
- { "kind": "authorised-location", "clause": "CD-10#throws-in-tests", "file": "src/legacy/harness.test.ts", "reason": "..." }
47
+ { "kind": "file-carve-out", "clause": "CD-10#throws-in-tests", "file": "src/legacy/charge.test.ts" }
46
48
  ] }
47
49
  ```
48
50
 
@@ -2,26 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- Throwing is confined to a closed, named set of contexts: a startup-invariant check that fails at boot, and a branch made unreachable by exhaustive type narrowing. Defensive throws — "this should never happen", "guard against impossible state" — are forbidden: if you can name the state, you can model it as a result variant. A library that throws is caught at the boundary and converted to a result. Tests carry no exemption; they surface failures through assertions, not by throwing.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [errors-as-data](../../methods/lenses/errors-as-data.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
8
-
9
- ## Spirit
7
+ **Verdict.** Splits: Failures are values; Straight-through tests; throw-only-error a check.
10
8
 
11
- **What the friction is for.** A throw is a failure the type does not mention. The friction makes returning the failure as a value the easy path, so every caller sees what can go wrong and must decide what to do.
9
+ **Read.** [Failures are values](../rules.md#failures-are-values), [Straight-through tests](../rules.md#straight-through-tests), [Failure asserted as a value](../typescript/recipes.md#failure-asserted-as-a-value) and [Failure mapping at the adapter](../typescript/recipes.md#failure-mapping-at-the-adapter).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *A defensive "can't happen".* A throw guards a state the code believes impossible. If you can name the state, model it as a result variant or rule it out with a type.
15
- - *A library that throws, caught too late.* Exceptions escape into the core. Catch at the wrapping boundary and return a result.
16
- - *Tests that throw to fail.* A test throws instead of asserting. Assert on the result; the assertion is the failure.
17
- - *Failure modes nobody listed.* Errors are thrown because no error type exists yet. List the ways the operation fails.
18
-
19
- **Where to go.** Throws exist only for a failed startup invariant and a branch the types prove unreachable. Everything else returns its failure.
11
+ Review lens: [errors-as-data](../../methods/lenses/errors-as-data.md). The lens reviews the whole rule, including what no check flags. What each check flags, how to fix a flagged site, and how to record an exception: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
20
12
 
21
- **Reactions to distrust.**
22
- - "It really can't happen." Then the type can say so, and the throw is unnecessary.
23
- - "Results are verbose." They are the failure paths written down. A throw hides the same paths.
13
+ ## Spirit
24
14
 
25
- **Principles behind it.**
26
- - *Railway oriented programming* (Scott Wlaschin). Success and failure travel as two tracks of one value, so failure is handled, not escaped.
27
- - *Fail fast.* A broken startup invariant stops the program at once; that is the one place a throw is the clearest signal.
15
+ Start from the symptom a finding names: [Throw or catch in a test](../typescript/symptoms.md#throw-or-catch-in-a-test) and [Thrown non-error](../typescript/symptoms.md#thrown-non-error). Each symptom names the cases it may indicate and the rules they point at. The why is on [The type checker proves it](../principles.md#the-type-checker-proves-it) and [Tests are ours](../principles.md#tests-are-ours).
@@ -1,6 +1,8 @@
1
1
  # CD-11 checks
2
2
 
3
- Read [the rule and its spirit](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
3
+ Recipe: [Result union](../typescript/recipes.md#result-union). The outcome it protects is seen by [Failure shaped as success](../typescript/symptoms.md#failure-shaped-as-success).
4
+
5
+ Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
4
6
 
5
7
  ## Clauses
6
8
 
@@ -10,4 +12,4 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: how
10
12
 
11
13
  ## How it is checked
12
14
 
13
- Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the rule](README.md) with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
15
+ Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the named rules](README.md) with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
@@ -2,24 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- Operational error envelopes are plain, tagged data — constructed by a factory, inspected by a type guard, dispatched by an exhaustive switch on the tag — never authored classes extending the runtime's error type. Data-shaped errors compose, narrow, and serialise; class hierarchies for operational failure do not. The only authored error class is the single startup-invariant one the throw rule permits.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [errors-as-data](../../methods/lenses/errors-as-data.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
8
-
9
- ## Spirit
7
+ **Verdict.** Recipe for [Failures are values](../rules.md#failures-are-values).
10
8
 
11
- **What the friction is for.** Errors are values the code passes, narrows and serialises. The friction makes plain tagged data the easy shape, so errors compose like any other data.
9
+ **Read.** [Failures are values](../rules.md#failures-are-values) and [Result union](../typescript/recipes.md#result-union).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *Error hierarchies built by inheritance.* Error kinds are subclasses. Make them variants of one tagged union.
15
- - *Errors carrying behaviour.* Error objects have methods. Move the behaviour into functions that take the error.
16
- - *Errors that cannot cross a boundary.* Class instances lose their type when serialised. Plain data survives.
17
-
18
- **Where to go.** Each error is plain data with a tag, built by a factory and dispatched by an exhaustive switch.
11
+ Review lens: [errors-as-data](../../methods/lenses/errors-as-data.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
19
12
 
20
- **Reactions to distrust.**
21
- - "Stack traces need the error class." Operational failures are expected outcomes, not bugs; they need context, not a trace.
13
+ ## Spirit
22
14
 
23
- **Principles behind it.**
24
- - *Make illegal states unrepresentable* (Yaron Minsky). A closed union lists exactly the failures that exist; an open class hierarchy admits any subclass.
25
- - *Algebraic data types.* A tagged union of error variants is checked for exhaustiveness wherever it is handled.
15
+ Start from the symptom a finding names: [Failure shaped as success](../typescript/symptoms.md#failure-shaped-as-success) and [Catch-all failure kind](../typescript/symptoms.md#catch-all-failure-kind). Each symptom names the cases it may indicate and the rules they point at. The why is on [The type checker proves it](../principles.md#the-type-checker-proves-it).
@@ -1,6 +1,8 @@
1
1
  # CD-12 checks
2
2
 
3
- Read [the rule and its spirit](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
3
+ Recipe: [Port in the domain](../typescript/recipes.md#port-in-the-domain). The outcome it protects is seen by [Port outside the domain](../typescript/symptoms.md#port-outside-the-domain).
4
+
5
+ Read [the verdict and the named pages it points at](README.md) first. This page is the mechanics: how the rule is checked, and how to record an exception where the rule allows one.
4
6
 
5
7
  ## Clauses
6
8
 
@@ -10,4 +12,4 @@ Read [the rule and its spirit](README.md) first. This page is the mechanics: how
10
12
 
11
13
  ## How it is checked
12
14
 
13
- Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the rule](README.md) with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
15
+ Every clause of this discipline is a judgement clause. It cannot be selected in `disciplines.json` and no mechanism checks it; a reviewer applies [the named rules](README.md) with its review lens, as [ADOPTING.md](../../ADOPTING.md#9-apply-the-judgement-rules) describes. Selecting no clause of this discipline leaves nothing uncovered.
@@ -2,24 +2,14 @@
2
2
 
3
3
  ## Rule
4
4
 
5
- Storage sits behind a repository port. Domain code talks to the port; an adapter composes the raw storage-driver primitives behind it. The domain never imports the storage driver or a filesystem primitive directly — so the storage technology can change without the domain knowing.
5
+ This numbered page is the earlier form of this rule. The [named pages](../README.md) govern where they differ, and [Every CD](../numbers.md) maps each number to its names.
6
6
 
7
- Review lens: [clean-architecture](../../methods/lenses/clean-architecture.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
8
-
9
- ## Spirit
7
+ **Verdict.** Recipe for [Ports declared inside](../rules.md#ports-declared-inside).
10
8
 
11
- **What the friction is for.** Storage technology changes more often than the domain. The friction keeps the domain talking to a repository port, so storage can change without the domain knowing.
9
+ **Read.** [Ports declared inside](../rules.md#ports-declared-inside) and [Port in the domain](../typescript/recipes.md#port-in-the-domain).
12
10
 
13
- **What a finding points at.** Match the sites against these causes.
14
- - *Queries written in domain code.* Domain functions call the driver directly. Move the query behind a repository method named for what the domain needs.
15
- - *A repository that leaks its driver.* The port returns driver rows or types. Return domain shapes.
16
- - *Files used as storage directly.* Filesystem calls sit in domain logic. Put them behind a repository too.
17
-
18
- **Where to go.** The domain depends on repository ports. Adapters compose the driver behind them.
11
+ Review lens: [clean-architecture](../../methods/lenses/clean-architecture.md). The lens reviews the whole rule, including what no check flags. How it is checked: [CHECKS.md](CHECKS.md). The thinking behind every rule: [the spirit of the rules](../SPIRIT.md).
19
12
 
20
- **Reactions to distrust.**
21
- - "We'll never change the database." The port is also what lets tests stub storage.
13
+ ## Spirit
22
14
 
23
- **Principles behind it.**
24
- - *Repository* (Martin Fowler, *Patterns of Enterprise Application Architecture*). A collection-like interface between the domain and data mapping.
25
- - *Dependency Inversion Principle* (Robert C. Martin, SOLID). The domain defines what it needs; storage implements it.
15
+ Start from the symptom a finding names: [Port outside the domain](../typescript/symptoms.md#port-outside-the-domain). Each symptom names the cases it may indicate and the rules they point at. The why is on [External behaviour sits at a boundary](../principles.md#external-behaviour-sits-at-a-boundary).