@hailstails/hone 2.0.0-pre.3 → 2.0.0-pre.4

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 (201) hide show
  1. package/ADOPTING.md +7 -7
  2. package/CHANGELOG.md +70 -0
  3. package/MIGRATING.md +15 -6
  4. package/README.md +12 -13
  5. package/chunks/chunk-3CWFUD5B.js +38 -0
  6. package/chunks/chunk-5AKHEW6V.js +15 -0
  7. package/chunks/chunk-75XWZYNN.js +64 -0
  8. package/chunks/chunk-7FVSZ2VL.js +1304 -0
  9. package/chunks/chunk-A3RL4O5V.js +146 -0
  10. package/chunks/chunk-BIDD2YWP.js +398 -0
  11. package/chunks/{chunk-GNOMK7CR.js → chunk-BKQ3K766.js} +489 -52
  12. package/chunks/{chunk-NRIQD3PI.js → chunk-BRANVR7K.js} +3 -5
  13. package/chunks/chunk-COQMPHWZ.js +37 -0
  14. package/chunks/{chunk-L7BGRC6D.js → chunk-CXM5KBZX.js} +1 -1
  15. package/chunks/chunk-D6645WPB.js +6 -0
  16. package/chunks/chunk-DJMF6JIM.js +42 -0
  17. package/chunks/{chunk-OKLYWD2Z.js → chunk-E4D5WDRX.js} +27 -20
  18. package/chunks/chunk-EBX57Z3V.js +8 -0
  19. package/chunks/chunk-FHVNKG5Q.js +19 -0
  20. package/chunks/chunk-FPIP7JEC.js +191 -0
  21. package/chunks/{chunk-QP5TLOBY.js → chunk-HVZVKZPW.js} +12 -9
  22. package/chunks/chunk-LD766VWU.js +57 -0
  23. package/chunks/chunk-LEFM7OPS.js +41 -0
  24. package/chunks/chunk-LNMDMRGQ.js +51 -0
  25. package/chunks/{chunk-RGSHTPLA.js → chunk-MBEDAFVC.js} +3 -11
  26. package/chunks/chunk-OO5KV7KN.js +17 -0
  27. package/chunks/{chunk-ASUN4AVC.js → chunk-PVSC4SE3.js} +71 -5
  28. package/chunks/chunk-SKDQ3QJD.js +75 -0
  29. package/chunks/chunk-W5OIAUDW.js +18 -0
  30. package/chunks/chunk-X73RZUPO.js +63 -0
  31. package/chunks/chunk-XE2KKWYH.js +45 -0
  32. package/chunks/chunk-YGMO5Z6U.js +432 -0
  33. package/chunks/chunk-YONPKP3C.js +15 -0
  34. package/docs/adding-a-discipline-or-mechanism.md +1 -1
  35. package/docs/extending.md +7 -388
  36. package/package.json +7 -6
  37. package/rules/README.md +2 -2
  38. package/rules/typescript/checks.md +236 -18
  39. package/rules/typescript/symptoms/ambient-randomness/random-call.md +10 -0
  40. package/rules/typescript/symptoms/answer-set-in-a-hook/hook-answer.md +10 -0
  41. package/rules/typescript/symptoms/assertion-outside-a-test/assertion-site.md +10 -0
  42. package/rules/typescript/symptoms/assertion-outside-a-test.md +25 -0
  43. package/rules/typescript/symptoms/built-unit-called-in-place/call-of-a-call.md +10 -0
  44. package/rules/typescript/symptoms/built-unit-called-in-place.md +25 -0
  45. package/rules/typescript/symptoms/code-or-prose-read-as-text/raw-read.md +10 -0
  46. package/rules/typescript/symptoms/code-or-prose-read-as-text.md +31 -0
  47. package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +1 -1
  48. package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +1 -1
  49. package/rules/typescript/symptoms/double-with-a-body/stub-implementation.md +2 -2
  50. package/rules/typescript/symptoms/export-from-a-test-file/test-file-export.md +10 -0
  51. package/rules/typescript/symptoms/export-from-a-test-file.md +33 -0
  52. package/rules/typescript/symptoms/failure-shaped-as-success/empty-catch.md +10 -0
  53. package/rules/typescript/symptoms/floating-version/version-selector.md +10 -0
  54. package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +1 -1
  55. package/rules/typescript/symptoms/many-spellings-of-one-concept/test-call-aliases.md +10 -0
  56. package/rules/typescript/symptoms/many-spellings-of-one-concept.md +3 -2
  57. package/rules/typescript/symptoms/module-or-global-patched/module-mock-call.md +4 -4
  58. package/rules/typescript/symptoms/no-lock-file/committed-lock-file.md +12 -0
  59. package/rules/typescript/symptoms/process-global-used-in-place/debugger-statement.md +10 -0
  60. package/rules/typescript/symptoms/process-global-used-in-place/direct-global-use.md +14 -0
  61. package/rules/typescript/symptoms/process-global-used-in-place.md +1 -1
  62. package/rules/typescript/symptoms/prose-in-code/comment-prose.md +12 -0
  63. package/rules/typescript/symptoms/test-switched-off/skipped-tests.md +3 -6
  64. package/rules/typescript/symptoms/test-switched-off.md +1 -1
  65. package/rules/typescript/symptoms/throw-between-our-units/throw-statement.md +10 -0
  66. package/rules/typescript/symptoms/throw-or-catch-in-a-test/throw-statement.md +1 -1
  67. package/rules/typescript/symptoms/tool-fetched-at-run-time/fetch-command.md +10 -0
  68. package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +10 -0
  69. package/rules/typescript/symptoms/type-declared-in-a-test.md +33 -0
  70. package/rules/typescript/symptoms/unit-without-a-running-test/companion-test-file.md +2 -2
  71. package/rules/typescript/symptoms/wide-input/unread-parameter.md +10 -0
  72. package/rules/typescript/symptoms/wide-input.md +3 -2
  73. package/rules/typescript/symptoms.md +183 -121
  74. package/src/application/conformance/conformance-testing-types.d.ts +13 -16
  75. package/src/domain/language-layer/authored-item-types.d.ts +50 -0
  76. package/src/domain/language-layer/catalogue-name.d.ts +5 -0
  77. package/src/domain/language-layer/check-address-text.d.ts +12 -0
  78. package/src/domain/rule-set/authored-rule-set-types.d.ts +31 -32
  79. package/src/domain/rule-set/clause-address-types.d.ts +4 -3
  80. package/src/domain/rule-set/rule-set-name-of.d.ts +10 -0
  81. package/src/domain/runner/check-binding.d.ts +18 -0
  82. package/src/domain/runner/check-observations.d.ts +39 -0
  83. package/src/domain/runner/conformance-types.d.ts +8 -2
  84. package/src/domain/settings/test-files.d.ts +7 -0
  85. package/src/eslint-plugin.js +16 -12
  86. package/src/hone.js +10677 -10754
  87. package/src/infrastructure/engines/eslint/authored-class-or-this/static-members-only/piece.json +0 -6
  88. package/src/infrastructure/engines/eslint/long-function/function-length/piece.json +0 -6
  89. package/src/infrastructure/engines/eslint/runner/pieces/eslint-piece-settings-types.d.ts +2 -0
  90. package/src/infrastructure/engines/eslint/runner/runner.js +945 -1188
  91. package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/README.md +0 -3
  92. package/src/infrastructure/engines/eslint/test-switched-off/focused-tests/eslint-plugin.js +33 -21
  93. package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/piece.json +11 -4
  94. package/src/infrastructure/engines/eslint/test-switched-off/skipped-tests/skipped-tests.examples.json +28 -0
  95. package/src/infrastructure/engines/eslint/untyped-value/implicit-any-let/piece.json +0 -2
  96. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/eslint-plugin.js +94 -0
  97. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/piece.json +11 -0
  98. package/src/infrastructure/engines/eslint/wide-input/unread-parameter/unread-parameter.examples.json +48 -0
  99. package/src/infrastructure/engines/walker/ambient-randomness/random-call/ambient-randomness.js +109 -0
  100. package/src/infrastructure/engines/walker/ambient-randomness/random-call/piece.json +9 -0
  101. package/src/infrastructure/engines/walker/ambient-randomness/random-call/random-call.examples.json +48 -0
  102. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answer.examples.json +42 -0
  103. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/hook-answers.js +72 -0
  104. package/src/infrastructure/engines/walker/answer-set-in-a-hook/hook-answer/piece.json +9 -0
  105. package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/assertion-site.examples.json +30 -0
  106. package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/assertion-site.js +123 -0
  107. package/src/infrastructure/engines/walker/assertion-outside-a-test/assertion-site/piece.json +9 -0
  108. package/src/infrastructure/engines/walker/authored-class-or-this/class-keyword/class-syntax.js +3 -3
  109. package/src/infrastructure/engines/walker/boolean-in-a-signature/boolean-annotation/boolean-signatures.js +7 -5
  110. package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +169 -98
  111. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.examples.json +24 -0
  112. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/call-of-a-call.js +34 -0
  113. package/src/infrastructure/engines/walker/built-unit-called-in-place/call-of-a-call/piece.json +9 -0
  114. package/src/infrastructure/engines/walker/claimed-type/cast-to-any/any-cast.js +6 -4
  115. package/src/infrastructure/engines/walker/claimed-type/unlisted-cast-site/cast-expressions.js +6 -4
  116. package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/piece.json +9 -0
  117. package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.examples.json +30 -0
  118. package/src/infrastructure/engines/walker/code-or-prose-read-as-text/raw-read/raw-read.js +166 -0
  119. package/src/infrastructure/engines/walker/computed-value-in-a-test/test-body/piece.json +0 -10
  120. package/src/infrastructure/engines/walker/date-used-directly/clock-sources/clock-sources.js +4 -4
  121. package/src/infrastructure/engines/walker/default-on-a-closed-union/default-arm/switch-defaults.js +8 -6
  122. package/src/infrastructure/engines/walker/double-with-a-body/logic-in-a-passed-function/piece.json +0 -10
  123. package/src/infrastructure/engines/walker/double-with-a-body/stub-implementation/dependency-isolation.js +9 -14
  124. package/src/infrastructure/engines/walker/drawer-path/drawer-names/categorical-paths.js +4 -4
  125. package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/piece.json +9 -0
  126. package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.examples.json +30 -0
  127. package/src/infrastructure/engines/walker/export-from-a-test-file/test-file-export/test-file-export.js +31 -0
  128. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.examples.json +18 -0
  129. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/empty-catch.js +32 -0
  130. package/src/infrastructure/engines/walker/failure-shaped-as-success/empty-catch/piece.json +9 -0
  131. package/src/infrastructure/engines/walker/floating-version/version-selector/piece.json +9 -0
  132. package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.examples.json +54 -0
  133. package/src/infrastructure/engines/walker/floating-version/version-selector/version-selector.js +75 -0
  134. package/src/infrastructure/engines/walker/inherited-environment-in-a-subprocess/git-spawn-environment/hermetic-git-spawns.js +8 -17
  135. package/src/infrastructure/engines/walker/loop-keyword/loop-statement/loops.js +8 -6
  136. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/piece.json +9 -0
  137. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.examples.json +36 -0
  138. package/src/infrastructure/engines/walker/many-spellings-of-one-concept/test-call-aliases/test-call-aliases.js +67 -0
  139. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mock-call.examples.json +34 -0
  140. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/module-mocking.js +64 -16
  141. package/src/infrastructure/engines/walker/module-or-global-patched/module-mock-call/piece.json +5 -1
  142. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.examples.json +24 -0
  143. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/committed-lock-file.js +41 -0
  144. package/src/infrastructure/engines/walker/no-lock-file/committed-lock-file/piece.json +9 -0
  145. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/import-boundaries.js +18 -16
  146. package/src/infrastructure/engines/walker/outside-import-past-a-boundary/import-or-require/piece.json +1 -1
  147. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.examples.json +18 -0
  148. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/debugger-statement.js +17 -0
  149. package/src/infrastructure/engines/walker/process-global-used-in-place/debugger-statement/piece.json +9 -0
  150. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/direct-global-use.examples.json +63 -0
  151. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/piece.json +13 -0
  152. package/src/infrastructure/engines/walker/process-global-used-in-place/direct-global-use/process-global-used-in-place.js +126 -0
  153. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/comment-prose.examples.json +42 -0
  154. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/piece.json +16 -0
  155. package/src/infrastructure/engines/walker/prose-in-code/comment-prose/prose-in-code.js +90 -0
  156. package/src/infrastructure/engines/walker/rebinding/test-body/piece.json +0 -10
  157. package/src/infrastructure/engines/walker/runner/pieces/walker-piece.d.ts +7 -5
  158. package/src/infrastructure/engines/walker/runner/runner.js +266 -77
  159. package/src/infrastructure/engines/walker/runner/toolchain/typescript-parse.d.ts +3 -0
  160. package/src/infrastructure/engines/walker/shorthand-name/identifier-names/identifier-names.js +12 -7
  161. package/src/infrastructure/engines/walker/strictness-weakened/exact-optional-property-types/piece.json +0 -10
  162. package/src/infrastructure/engines/walker/strictness-weakened/no-fallthrough-cases-in-switch/piece.json +0 -10
  163. package/src/infrastructure/engines/walker/strictness-weakened/no-implicit-override/piece.json +0 -10
  164. package/src/infrastructure/engines/walker/strictness-weakened/no-property-access-from-index-signature/piece.json +0 -10
  165. package/src/infrastructure/engines/walker/strictness-weakened/no-unchecked-indexed-access/piece.json +0 -10
  166. package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +30 -52
  167. package/src/infrastructure/engines/walker/strictness-weakened/use-unknown-in-catch-variables/piece.json +0 -10
  168. package/src/infrastructure/engines/walker/text-past-its-reader/test-body/piece.json +0 -10
  169. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/piece.json +9 -0
  170. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throw-statement.examples.json +36 -0
  171. package/src/infrastructure/engines/walker/throw-between-our-units/throw-statement/throws-in-production.js +12 -0
  172. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throw-statement.examples.json +6 -6
  173. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/throw-statement/throws-in-tests.js +5 -44
  174. package/src/infrastructure/engines/walker/throw-or-catch-in-a-test/try-block/piece.json +0 -10
  175. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.examples.json +42 -0
  176. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/fetch-command.js +152 -0
  177. package/src/infrastructure/engines/walker/tool-fetched-at-run-time/fetch-command/piece.json +9 -0
  178. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/piece.json +9 -0
  179. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +24 -0
  180. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +27 -0
  181. package/src/infrastructure/engines/walker/type-derived-from-code/factory-return-types/factory-return-types.js +8 -6
  182. package/src/infrastructure/engines/walker/unit-without-a-running-test/companion-test-file/export-test-sibling.js +16 -10
  183. package/src/infrastructure/engines/walker/untracked-escape/directive-pointers/comments-directives.js +18 -64
  184. package/src/infrastructure/engines/walker/write-into-a-parameter/parameter-mutation/parameter-mutation.js +7 -5
  185. package/src/rule-set.d.ts +2 -1
  186. package/src/testing.d.ts +2 -4
  187. package/src/testing.js +104 -317
  188. package/src/{audit.d.ts → walker.d.ts} +13 -8
  189. package/src/walker.js +28 -0
  190. package/chunks/chunk-5HRMJ4O2.js +0 -608
  191. package/chunks/chunk-IX2VZTBO.js +0 -887
  192. package/chunks/chunk-K2W3D3NB.js +0 -17
  193. package/chunks/chunk-M6SOGWT7.js +0 -82
  194. package/chunks/chunk-Q62Y25WS.js +0 -843
  195. package/chunks/chunk-R75QELTA.js +0 -481
  196. package/chunks/chunk-RANAKCTW.js +0 -31
  197. package/chunks/chunk-TNY2PASL.js +0 -38
  198. package/chunks/chunk-UJONWHA4.js +0 -22
  199. package/docs/output-contract.md +0 -1155
  200. package/src/audit.js +0 -18
  201. package/src/domain/runner/runner-module-types.d.ts +0 -15
@@ -1,887 +0,0 @@
1
- import {
2
- CATALOGUE_NAME,
3
- CHECK_ADDRESS_SEPARATOR,
4
- anchorKindSchema,
5
- checkAddressOfNames,
6
- checkAddressTextOf,
7
- checkNamesOf,
8
- everyOk,
9
- readNamedPiece,
10
- readVersionOneJson,
11
- versionOneEngineNameOf
12
- } from "./chunk-R75QELTA.js";
13
- import {
14
- clauseAddressSchema
15
- } from "./chunk-NRIQD3PI.js";
16
- import {
17
- NOT_INSTALLED,
18
- engineIdSchema,
19
- installRootAboveEntry
20
- } from "./chunk-GNOMK7CR.js";
21
- import {
22
- TOOL_IDENTITY,
23
- clauseAddressText,
24
- sameClauseAddress
25
- } from "./chunk-M6SOGWT7.js";
26
-
27
- // src/infrastructure/printed-report/load-failures/load-failure-text.ts
28
- var escapedLineBreaks = (request) => request.text.replaceAll("\n", "\\n").replaceAll("\r", "\\r");
29
- var JUDGEMENT_CLAUSE_LISTED_REPAIR = "a judgement clause is enforced by review and is left out of clauses, adopted or not; remove it";
30
- var CONFIG_ROOT_REPAIR = "an eslintConfigRoots entry is a folder git tracks files under outside every excluded path, spelled exactly as git spells it; fix or remove it in disciplines.json";
31
- var SELECTION_ABSENT_REPAIR = "holds no disciplines.json; give the folder that holds it, usually the repository root";
32
- var WHY_CHAINS_REQUIRED_REPAIR = `${TOOL_IDENTITY.command} 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`;
33
- var BOTH_LAYOUTS_REPAIR = `${TOOL_IDENTITY.name} reads exception records from one layout; keep each record in one of them and remove the other`;
34
- var SUPPORTED_VERSION_REPAIR = "add a supported version to the devDependencies of the repository root";
35
- var EACH_SUPPORTED_VERSION_REPAIR = "add a supported version of each to the devDependencies of the repository root";
36
- var unavailablePeerRepair = (request) => request.peer.peer === "required" && request.peer.found === NOT_INSTALLED ? `${request.peer.packageName} is a required peer of ${TOOL_IDENTITY.packageName}, so this install is incomplete; ${SUPPORTED_VERSION_REPAIR} and reinstall` : SUPPORTED_VERSION_REPAIR;
37
- var unavailablePeersRepair = (request) => {
38
- const [first, ...rest] = request.peers;
39
- return rest.length === 0 ? unavailablePeerRepair({ peer: first }) : EACH_SUPPORTED_VERSION_REPAIR;
40
- };
41
- var unavailablePeerText = (request) => `${request.peer.packageName} found ${request.peer.found}, supported ${request.peer.supported}`;
42
- var runnerFailureFields = (request) => {
43
- switch (request.failure.kind) {
44
- case "piece-invalid":
45
- return [request.failure.kind, request.failure.pieceRoot, request.failure.detail];
46
- case "file-unreadable":
47
- case "file-unparseable":
48
- return [request.failure.kind, request.failure.file, request.failure.detail];
49
- case "toolchain-unavailable":
50
- return [
51
- request.failure.kind,
52
- `${request.failure.peers.map((peer) => unavailablePeerText({ peer })).join("; ")}: ${unavailablePeersRepair({ peers: request.failure.peers })}`
53
- ];
54
- case "toolchain-shadowed":
55
- return [
56
- request.failure.kind,
57
- request.failure.packageName,
58
- `resolved from ${request.failure.location} inside the core install ${request.failure.installRoot}: delete ${request.failure.installRoot}/node_modules, then reinstall the package with the repository's package manager, so the repository's own copy is used`
59
- ];
60
- case "tool-failed":
61
- case "plugin-conflict":
62
- case "team-config-unloadable":
63
- case "runner-invalid-output":
64
- return [request.failure.kind, request.failure.detail];
65
- }
66
- };
67
- var loadFailureFields = (request) => {
68
- switch (request.failure.kind) {
69
- case "arguments-invalid":
70
- case "git-failed":
71
- case "unexpected-error":
72
- return [request.failure.detail];
73
- case "selection-absent":
74
- return [request.failure.repo, SELECTION_ABSENT_REPAIR];
75
- case "install-root-unresolvable":
76
- return [request.failure.url, request.failure.detail];
77
- case "file-unreadable":
78
- case "file-malformed":
79
- case "file-unwritable":
80
- case "records-unsplittable":
81
- case "rule-set-invalid":
82
- return [request.failure.path, request.failure.detail];
83
- case "records-in-both-layouts":
84
- return [request.failure.path, `${request.failure.folder}:`, BOTH_LAYOUTS_REPAIR];
85
- case "why-chains-required":
86
- return [`${request.failure.path}:`, WHY_CHAINS_REQUIRED_REPAIR];
87
- case "unsupported-version":
88
- return [request.failure.path, String(JSON.stringify(request.failure.found))];
89
- case "reserved-rule-set-name":
90
- case "unknown-rule-set":
91
- return [request.failure.name];
92
- case "duplicate-clause":
93
- return [request.failure.address, request.failure.prefixedAddress];
94
- case "rule-set-name-collision":
95
- return [request.failure.name, request.failure.other];
96
- case "unknown-discipline":
97
- case "unknown-clause":
98
- case "judgement-clause-selected":
99
- return [request.failure.address];
100
- case "judgement-clause-listed":
101
- return [`${request.failure.address}:`, JUDGEMENT_CLAUSE_LISTED_REPAIR];
102
- case "mechanism-not-allowed":
103
- case "piece-missing":
104
- return [request.failure.address, versionOneEngineNameOf(request.failure.mechanism)];
105
- case "config-root-untracked":
106
- return [`${request.failure.root}:`, CONFIG_ROOT_REPAIR];
107
- case "runner-missing":
108
- return [versionOneEngineNameOf(request.failure.mechanism)];
109
- case "runner-invalid":
110
- return [versionOneEngineNameOf(request.failure.mechanism), request.failure.detail];
111
- case "runner-failed":
112
- return [
113
- versionOneEngineNameOf(request.failure.mechanism),
114
- ...runnerFailureFields({ failure: request.failure.failure })
115
- ];
116
- }
117
- };
118
- var loadFailureDetail = (request) => [request.failure.kind, ...loadFailureFields(request)].map((text) => escapedLineBreaks({ text })).join(" ");
119
- var loadFailureText = (request) => `load failure: ${loadFailureDetail(request)}
120
- `;
121
-
122
- // src/infrastructure/command-line/installation/install-root.ts
123
- var DIRECTORIES_ABOVE_ENTRY = {
124
- api: "two directories",
125
- command: "two directories"
126
- };
127
- var installRootUnresolvable = (request) => ({
128
- outcome: "failed",
129
- error: { kind: "install-root-unresolvable", url: request.url, detail: request.detail }
130
- });
131
- var installRootAbove = (request) => {
132
- const entry = request.path.fromFileUrl({ url: request.moduleUrl });
133
- if (entry.outcome === "failed") {
134
- return installRootUnresolvable({ url: entry.error.url, detail: entry.error.detail });
135
- }
136
- const resolved2 = request.path.resolve({
137
- path: installRootAboveEntry({
138
- entryFile: entry.value,
139
- entry: request.entry,
140
- directoryOf: (path) => request.path.directoryOf({ path })
141
- })
142
- });
143
- if (resolved2.outcome === "failed") {
144
- return installRootUnresolvable({
145
- url: request.moduleUrl,
146
- detail: `the install root ${DIRECTORIES_ABOVE_ENTRY[request.entry]} above the entry file is not an absolute path`
147
- });
148
- }
149
- return resolved2;
150
- };
151
- var installRootOf = (request) => installRootAbove({ ...request, entry: "command" });
152
- var installRootOfApiEntry = (request) => installRootAbove({ ...request, entry: "api" });
153
-
154
- // src/infrastructure/disciplines-file/version-one-names.ts
155
- import { z as z2 } from "zod";
156
-
157
- // src/infrastructure/content-files/symptom-catalogues/symptom-catalogue-wire.ts
158
- import { z } from "zod";
159
-
160
- // src/domain/language-layer/check-address.ts
161
- var NO_CHECK = { found: "none" };
162
- var foundAmong = (request) => {
163
- const [check] = request.checks;
164
- return check === void 0 ? NO_CHECK : { found: "check", check };
165
- };
166
- var checkAddressOf = (request) => checkAddressTextOf(request);
167
- var checkAt = (request) => foundAmong({
168
- checks: request.catalogue.checks.filter(
169
- (candidate) => checkAddressOf({ check: candidate }) === request.address
170
- )
171
- });
172
- var checksOf = (request) => request.catalogue.checks.filter(
173
- (check) => sameClauseAddress({ left: check.clause, right: request.clause }) === "same"
174
- );
175
- var checkNamedAt = (request) => {
176
- const { address } = request;
177
- if (address === void 0) {
178
- return { named: "unnamed" };
179
- }
180
- const found = foundAmong({
181
- checks: checksOf(request).filter((check) => checkAddressOf({ check }) === address)
182
- });
183
- return found.found === "check" ? { named: "check", check: found.check } : { named: "not-of-the-clause", address };
184
- };
185
-
186
- // src/infrastructure/content-files/symptom-catalogues/symptom-catalogue-wire.ts
187
- var SUPPORTED_VERSION = 1;
188
- var NOT_A_CATALOGUE_NAME = "is not a lower-case hyphenated name";
189
- var catalogueNameSchema = z.string().regex(new RegExp(`^${CATALOGUE_NAME}$`), { error: NOT_A_CATALOGUE_NAME });
190
- var textSchema = z.string().min(1);
191
- var standingSchema = z.enum(["accepted", "proposed"]);
192
- var recordKindNameSchema = z.enum([
193
- "authorised-location",
194
- "deviation",
195
- "debt",
196
- "boundary-record",
197
- "dependency-record"
198
- ]);
199
- var pointedWireSchema = z.union([
200
- z.strictObject({ rule: catalogueNameSchema }),
201
- z.strictObject({ principle: catalogueNameSchema })
202
- ]);
203
- var caseWireSchema = z.strictObject({
204
- name: catalogueNameSchema,
205
- title: textSchema,
206
- standing: standingSchema,
207
- owes: z.array(pointedWireSchema).min(1)
208
- });
209
- var correctUseWireSchema = z.strictObject({
210
- situation: textSchema,
211
- kind: recordKindNameSchema,
212
- at: textSchema.optional()
213
- });
214
- var seenBySchema = z.enum([
215
- "syntax",
216
- "types",
217
- "graph",
218
- "app",
219
- "files",
220
- "history",
221
- "person"
222
- ]);
223
- var reportsSchema = z.enum(["seen", "seen-to-breach"]);
224
- var symptomWireSchema = z.strictObject({
225
- name: catalogueNameSchema,
226
- title: textSchema,
227
- group: textSchema,
228
- seen: textSchema,
229
- mayIndicate: z.array(
230
- z.strictObject({
231
- case: catalogueNameSchema,
232
- situation: textSchema.optional(),
233
- quote: textSchema.optional(),
234
- points: z.array(pointedWireSchema).min(1)
235
- })
236
- ).min(1),
237
- breachUsuallySits: textSchema,
238
- seenBy: z.array(seenBySchema).min(1),
239
- reports: reportsSchema.optional(),
240
- recipes: z.array(catalogueNameSchema),
241
- correctUses: z.array(correctUseWireSchema),
242
- howItIsSeen: textSchema.optional(),
243
- breachACheckCouldName: textSchema.optional(),
244
- toNameTheBreach: textSchema.optional()
245
- });
246
- var sightWireSchema = z.discriminatedUnion("kind", [
247
- z.strictObject({ kind: z.literal("one-symptom"), symptom: catalogueNameSchema }),
248
- z.strictObject({
249
- kind: z.literal("symptom-by-form"),
250
- forms: z.array(z.strictObject({ section: textSchema, symptom: catalogueNameSchema })).min(1)
251
- }),
252
- z.strictObject({
253
- kind: z.literal("method"),
254
- recipe: catalogueNameSchema,
255
- outcomeSeenBy: z.array(catalogueNameSchema).min(1)
256
- }),
257
- z.strictObject({ kind: z.literal("outside-the-cases") })
258
- ]);
259
- var recordKindWireSchema = z.strictObject({
260
- name: recordKindNameSchema,
261
- title: textSchema,
262
- phrase: textSchema,
263
- todaysFormat: z.enum(["authorised-location", "file-carve-out", "none-yet"])
264
- });
265
- var checkWireSchema = z.strictObject({
266
- symptom: catalogueNameSchema,
267
- name: catalogueNameSchema,
268
- clause: clauseAddressSchema,
269
- flagsBeyondTheSymptom: textSchema.optional(),
270
- misses: textSchema.optional(),
271
- settingsTracedTo: textSchema.optional()
272
- });
273
- var catalogueFileSchema = z.strictObject({
274
- version: z.literal(SUPPORTED_VERSION),
275
- principles: z.array(z.strictObject({ name: catalogueNameSchema, title: textSchema })),
276
- rules: z.array(
277
- z.strictObject({
278
- name: catalogueNameSchema,
279
- title: textSchema,
280
- principle: catalogueNameSchema,
281
- standing: standingSchema
282
- })
283
- ),
284
- cases: z.array(caseWireSchema),
285
- recipes: z.array(
286
- z.strictObject({
287
- name: catalogueNameSchema,
288
- title: textSchema,
289
- serves: pointedWireSchema,
290
- standing: standingSchema,
291
- reason: z.strictObject({ text: textSchema, standing: standingSchema })
292
- })
293
- ),
294
- recordKinds: z.array(recordKindWireSchema),
295
- engines: z.array(z.strictObject({ name: engineIdSchema })),
296
- symptoms: z.array(symptomWireSchema),
297
- clauses: z.array(z.strictObject({ clause: clauseAddressSchema, sight: sightWireSchema })),
298
- checks: z.array(checkWireSchema),
299
- namedBans: z.array(z.strictObject({ outsideDependency: textSchema }))
300
- });
301
- var resolved = (found) => ({ outcome: "ok", value: found });
302
- var faultsOf = (resolution) => resolution.outcome === "failed" ? resolution.error : [];
303
- var allResolved = (resolutions) => {
304
- const faults = resolutions.flatMap(faultsOf);
305
- return faults.length > 0 ? { outcome: "failed", error: faults } : resolved(
306
- resolutions.flatMap(
307
- (resolution) => resolution.outcome === "ok" ? [resolution.value] : []
308
- )
309
- );
310
- };
311
- var mapped = (request) => request.resolution.outcome === "failed" ? request.resolution : resolved(request.to(request.resolution.value));
312
- var entryNamed = (request) => {
313
- const entry = request.entries.find((candidate) => candidate.name === request.name);
314
- return entry === void 0 ? { outcome: "failed", error: [request.refusal] } : resolved(entry);
315
- };
316
- var notHeldRefusal = (request) => `${request.listing} names ${request.name}, which the catalogue does not hold`;
317
- var heldEntryNamed = (request) => entryNamed({ ...request, refusal: notHeldRefusal(request) });
318
- var principleOf = (wire) => ({ name: wire.name, title: wire.title });
319
- var recipeOf = (wire) => ({
320
- name: wire.name,
321
- title: wire.title,
322
- standing: wire.standing,
323
- reason: { text: wire.reason.text, standing: wire.reason.standing }
324
- });
325
- var recordKindOf = (wire) => ({
326
- name: wire.name,
327
- title: wire.title,
328
- phrase: wire.phrase,
329
- todaysFormat: wire.todaysFormat
330
- });
331
- var engineOf = (wire) => ({ name: wire.name });
332
- var namedBanOf = (wire) => ({
333
- outsideDependency: wire.outsideDependency
334
- });
335
- var ruleOf = (request) => mapped({
336
- resolution: heldEntryNamed({
337
- listing: "rules",
338
- entries: request.principles,
339
- name: request.wire.principle
340
- }),
341
- to: (principle) => ({
342
- name: request.wire.name,
343
- title: request.wire.title,
344
- principle,
345
- standing: request.wire.standing
346
- })
347
- });
348
- var pointedOf = (request) => "rule" in request.point ? mapped({
349
- resolution: heldEntryNamed({
350
- listing: request.listing,
351
- entries: request.pointable.rules,
352
- name: request.point.rule
353
- }),
354
- to: (rule) => ({ kind: "rule", rule })
355
- }) : mapped({
356
- resolution: heldEntryNamed({
357
- listing: request.listing,
358
- entries: request.pointable.principles,
359
- name: request.point.principle
360
- }),
361
- to: (principle) => ({ kind: "principle", principle })
362
- });
363
- var caseOf = (request) => mapped({
364
- resolution: allResolved(
365
- request.wire.owes.map(
366
- (point) => pointedOf({ listing: "cases", point, pointable: request.pointable })
367
- )
368
- ),
369
- to: (owes) => ({
370
- name: request.wire.name,
371
- title: request.wire.title,
372
- standing: request.wire.standing,
373
- owes
374
- })
375
- });
376
- var alwaysRecordableKindOf = (request) => entryNamed({
377
- entries: request.recordKinds,
378
- name: request.name,
379
- refusal: `recordKinds holds no ${request.name}, which every symptom takes`
380
- });
381
- var alwaysRecordableOf = (request) => {
382
- const debt = alwaysRecordableKindOf({ ...request, name: "debt" });
383
- const authorisedLocation = alwaysRecordableKindOf({ ...request, name: "authorised-location" });
384
- return debt.outcome === "failed" || authorisedLocation.outcome === "failed" ? { outcome: "failed", error: [...faultsOf(debt), ...faultsOf(authorisedLocation)] } : resolved({ debt: debt.value, authorisedLocation: authorisedLocation.value });
385
- };
386
- var pointableOf = (request) => {
387
- const principles = request.file.principles.map(principleOf);
388
- return mapped({
389
- resolution: allResolved(request.file.rules.map((wire) => ruleOf({ wire, principles }))),
390
- to: (rules) => ({ principles, rules })
391
- });
392
- };
393
- var definitionsOf = (request) => {
394
- const pointable = pointableOf(request);
395
- if (pointable.outcome === "failed") {
396
- return pointable;
397
- }
398
- const recordKinds = request.file.recordKinds.map(recordKindOf);
399
- const cases = allResolved(
400
- request.file.cases.map((wire) => caseOf({ wire, pointable: pointable.value }))
401
- );
402
- const alwaysRecordable = alwaysRecordableOf({ recordKinds });
403
- const served = allResolved(
404
- request.file.recipes.map(
405
- (wire) => pointedOf({ listing: "recipes", point: wire.serves, pointable: pointable.value })
406
- )
407
- );
408
- return cases.outcome === "failed" || alwaysRecordable.outcome === "failed" || served.outcome === "failed" ? {
409
- outcome: "failed",
410
- error: [...faultsOf(cases), ...faultsOf(alwaysRecordable), ...faultsOf(served)]
411
- } : resolved({
412
- ...pointable.value,
413
- cases: cases.value,
414
- recipes: request.file.recipes.map(recipeOf),
415
- recordKinds,
416
- alwaysRecordable: alwaysRecordable.value,
417
- engines: request.file.engines.map(engineOf)
418
- });
419
- };
420
- var indicationOf = (request) => {
421
- const indicated = heldEntryNamed({
422
- listing: "symptoms",
423
- entries: request.definitions.cases,
424
- name: request.indication.case
425
- });
426
- const points = allResolved(
427
- request.indication.points.map(
428
- (point) => pointedOf({ listing: "symptoms", point, pointable: request.definitions })
429
- )
430
- );
431
- return indicated.outcome === "failed" || points.outcome === "failed" ? { outcome: "failed", error: [...faultsOf(indicated), ...faultsOf(points)] } : resolved(
432
- request.indication.situation === void 0 ? { case: indicated.value, points: points.value } : {
433
- case: indicated.value,
434
- situation: request.indication.situation,
435
- points: points.value
436
- }
437
- );
438
- };
439
- var correctUseOf = (request) => mapped({
440
- resolution: heldEntryNamed({
441
- listing: "symptoms",
442
- entries: request.definitions.recordKinds,
443
- name: request.use.kind
444
- }),
445
- to: (kind) => request.use.at === void 0 ? { situation: request.use.situation, kind } : { situation: request.use.situation, kind, at: request.use.at }
446
- });
447
- var symptomOf = (request) => {
448
- const { wire, definitions } = request;
449
- const mayIndicate = allResolved(
450
- wire.mayIndicate.map((indication) => indicationOf({ indication, definitions }))
451
- );
452
- const recipes = allResolved(
453
- wire.recipes.map(
454
- (name) => heldEntryNamed({ listing: "symptoms", entries: definitions.recipes, name })
455
- )
456
- );
457
- const correctUses = allResolved(
458
- wire.correctUses.map((use) => correctUseOf({ use, definitions }))
459
- );
460
- if (mayIndicate.outcome === "failed" || recipes.outcome === "failed" || correctUses.outcome === "failed") {
461
- return {
462
- outcome: "failed",
463
- error: [...faultsOf(mayIndicate), ...faultsOf(recipes), ...faultsOf(correctUses)]
464
- };
465
- }
466
- return resolved({
467
- name: wire.name,
468
- title: wire.title,
469
- seen: wire.seen,
470
- mayIndicate: mayIndicate.value,
471
- breachUsuallySits: wire.breachUsuallySits,
472
- recipes: recipes.value,
473
- correctUses: correctUses.value
474
- });
475
- };
476
- var sightedSymptomOf = (request) => heldEntryNamed({ listing: "clauses", entries: request.symptoms, name: request.name });
477
- var methodSightOf = (request) => {
478
- const recipe = heldEntryNamed({
479
- listing: "clauses",
480
- entries: request.recipes,
481
- name: request.sight.recipe
482
- });
483
- const outcomeSeenBy = allResolved(
484
- request.sight.outcomeSeenBy.map((name) => sightedSymptomOf({ ...request, name }))
485
- );
486
- return recipe.outcome === "failed" || outcomeSeenBy.outcome === "failed" ? { outcome: "failed", error: [...faultsOf(recipe), ...faultsOf(outcomeSeenBy)] } : resolved({ kind: "method", recipe: recipe.value, outcomeSeenBy: outcomeSeenBy.value });
487
- };
488
- var sightOf = (request) => {
489
- const { sight } = request;
490
- switch (sight.kind) {
491
- case "one-symptom":
492
- return mapped({
493
- resolution: sightedSymptomOf({ ...request, name: sight.symptom }),
494
- to: (symptom) => ({ kind: "one-symptom", symptom })
495
- });
496
- case "symptom-by-form":
497
- return mapped({
498
- resolution: allResolved(
499
- sight.forms.map(
500
- (form) => mapped({
501
- resolution: sightedSymptomOf({ ...request, name: form.symptom }),
502
- to: (symptom) => ({ section: form.section, symptom })
503
- })
504
- )
505
- ),
506
- to: (forms) => ({ kind: "symptom-by-form", forms })
507
- });
508
- case "method":
509
- return methodSightOf({ ...request, sight });
510
- case "outside-the-cases":
511
- return resolved({ kind: "outside-the-cases" });
512
- }
513
- };
514
- var clauseOf = (request) => mapped({
515
- resolution: sightOf({ ...request, sight: request.wire.sight }),
516
- to: (sight) => ({ clause: request.wire.clause, sight })
517
- });
518
- var sightedSymptomsOf = (request) => {
519
- switch (request.sight.kind) {
520
- case "one-symptom":
521
- return [request.sight.symptom];
522
- case "symptom-by-form":
523
- return request.sight.forms.map((form) => form.symptom);
524
- case "method":
525
- case "outside-the-cases":
526
- return [];
527
- }
528
- };
529
- var sightedNamesOf = (request) => [
530
- ...new Set(sightedSymptomsOf({ sight: request.clause.sight }).map((symptom) => symptom.name))
531
- ];
532
- var formsOf = (request) => request.clause.sight.kind === "symptom-by-form" ? request.clause.sight.forms.filter((form) => form.symptom.name === request.symptom.name).map((form) => form.section) : [];
533
- var checkedClauseOf = (request) => {
534
- const clause = request.clauses.find(
535
- (candidate) => sameClauseAddress({ left: candidate.clause, right: request.wire.clause }) === "same"
536
- );
537
- return clause === void 0 ? {
538
- outcome: "failed",
539
- error: [
540
- notHeldRefusal({
541
- listing: "checks",
542
- name: clauseAddressText({ address: request.wire.clause })
543
- })
544
- ]
545
- } : resolved(clause);
546
- };
547
- var sightedCheckOf = (request) => sightedNamesOf({ clause: request.clause }).includes(request.symptom.name) ? resolved({
548
- name: request.wire.name,
549
- symptom: request.symptom,
550
- clause: request.clause.clause,
551
- forms: formsOf({ clause: request.clause, symptom: request.symptom })
552
- }) : {
553
- outcome: "failed",
554
- error: [
555
- `checks names ${request.symptom.name}#${request.wire.name} on ${clauseAddressText({ address: request.clause.clause })}, which does not see ${request.symptom.name}`
556
- ]
557
- };
558
- var checkOf = (request) => {
559
- const { wire } = request;
560
- const symptom = heldEntryNamed({
561
- listing: "checks",
562
- entries: request.symptoms,
563
- name: wire.symptom
564
- });
565
- const clause = checkedClauseOf(request);
566
- return symptom.outcome === "failed" || clause.outcome === "failed" ? { outcome: "failed", error: [...faultsOf(symptom), ...faultsOf(clause)] } : sightedCheckOf({ wire, symptom: symptom.value, clause: clause.value });
567
- };
568
- var uncheckedSightingsOf = (request) => {
569
- const checked = checksOf({ catalogue: request, clause: request.clause.clause });
570
- return checked.length === 0 ? [] : sightedNamesOf(request).filter((name) => !checked.some((check) => check.symptom.name === name)).map(
571
- (name) => `${clauseAddressText({ address: request.clause.clause })} sees ${name}, which no check names`
572
- );
573
- };
574
- var resolvedChecksOf = (request) => {
575
- const checks = allResolved(request.wires.map((wire) => checkOf({ ...request, wire })));
576
- if (checks.outcome === "failed") {
577
- return checks;
578
- }
579
- const unchecked = request.clauses.flatMap(
580
- (clause) => uncheckedSightingsOf({ clause, checks: checks.value })
581
- );
582
- return unchecked.length > 0 ? { outcome: "failed", error: unchecked } : checks;
583
- };
584
- var catalogueOf = (request) => {
585
- const definitions = definitionsOf(request);
586
- if (definitions.outcome === "failed") {
587
- return definitions;
588
- }
589
- const symptoms = allResolved(
590
- request.file.symptoms.map((wire) => symptomOf({ wire, definitions: definitions.value }))
591
- );
592
- if (symptoms.outcome === "failed") {
593
- return symptoms;
594
- }
595
- const sighting = { symptoms: symptoms.value, recipes: definitions.value.recipes };
596
- const clauses = allResolved(request.file.clauses.map((wire) => clauseOf({ ...sighting, wire })));
597
- if (clauses.outcome === "failed") {
598
- return clauses;
599
- }
600
- return mapped({
601
- resolution: resolvedChecksOf({
602
- symptoms: symptoms.value,
603
- clauses: clauses.value,
604
- wires: request.file.checks
605
- }),
606
- to: (checks) => ({
607
- ...definitions.value,
608
- symptoms: symptoms.value,
609
- clauses: clauses.value,
610
- checks,
611
- namedBans: request.file.namedBans.map(namedBanOf)
612
- })
613
- });
614
- };
615
- var repeatsIn = (request) => request.names.filter((name, index) => request.names.indexOf(name) !== index).map((name) => `${request.listing} holds ${name} more than once`);
616
- var formSectionRepeatsOf = (request) => request.file.clauses.flatMap(
617
- ({ clause, sight }) => sight.kind === "symptom-by-form" ? repeatsIn({
618
- listing: `the forms of ${clauseAddressText({ address: clause })}`,
619
- names: sight.forms.map((form) => form.section)
620
- }) : []
621
- );
622
- var indicatedCaseRepeatsOf = (request) => request.file.symptoms.flatMap(
623
- (symptom) => repeatsIn({
624
- listing: `the cases of ${symptom.name}`,
625
- names: symptom.mayIndicate.map(
626
- (indication) => indication.situation === void 0 ? indication.case : `${indication.case}: ${indication.situation}`
627
- )
628
- })
629
- );
630
- var checkedClauseRepeatsOf = (request) => [...new Set(request.file.checks.map((check) => check.symptom))].flatMap(
631
- (symptom) => repeatsIn({
632
- listing: `the checks of ${symptom}`,
633
- names: request.file.checks.filter((check) => check.symptom === symptom).map((check) => clauseAddressText({ address: check.clause }))
634
- })
635
- );
636
- var repeatedNamesOf = (request) => [
637
- ...repeatsIn({
638
- listing: "principles",
639
- names: request.file.principles.map((principle) => principle.name)
640
- }),
641
- ...repeatsIn({ listing: "rules", names: request.file.rules.map((rule) => rule.name) }),
642
- ...repeatsIn({ listing: "cases", names: request.file.cases.map((entry) => entry.name) }),
643
- ...repeatsIn({ listing: "recipes", names: request.file.recipes.map((recipe) => recipe.name) }),
644
- ...repeatsIn({
645
- listing: "recordKinds",
646
- names: request.file.recordKinds.map((kind) => kind.name)
647
- }),
648
- ...repeatsIn({ listing: "engines", names: request.file.engines.map((engine) => engine.name) }),
649
- ...repeatsIn({
650
- listing: "symptoms",
651
- names: request.file.symptoms.map((symptom) => symptom.name)
652
- }),
653
- ...repeatsIn({
654
- listing: "clauses",
655
- names: request.file.clauses.map(({ clause }) => clauseAddressText({ address: clause }))
656
- }),
657
- ...repeatsIn({
658
- listing: "checks",
659
- names: request.file.checks.map((check) => `${check.symptom}#${check.name}`)
660
- }),
661
- ...checkedClauseRepeatsOf(request),
662
- ...formSectionRepeatsOf(request),
663
- ...indicatedCaseRepeatsOf(request)
664
- ];
665
- var checkedCatalogueFileSchema = catalogueFileSchema.superRefine((file, context) => {
666
- repeatedNamesOf({ file }).forEach((message) => {
667
- context.addIssue({ code: "custom", message });
668
- });
669
- });
670
- var refusalText = (request) => request.faults.map((fault) => `\u2716 ${fault}`).join("\n");
671
- var catalogueContentFromFile = (request) => {
672
- const repeats = repeatedNamesOf({ file: request.file });
673
- if (repeats.length > 0) {
674
- return { outcome: "failed", error: refusalText({ faults: repeats }) };
675
- }
676
- const catalogue = catalogueOf({ file: request.file });
677
- return catalogue.outcome === "failed" ? { outcome: "failed", error: refusalText({ faults: catalogue.error }) } : catalogue;
678
- };
679
-
680
- // src/infrastructure/disciplines-file/version-one-names.ts
681
- var VERSION_ONE_NAMES_SEGMENTS = [
682
- "src",
683
- "infrastructure",
684
- "disciplines-file",
685
- "version-one-names.json"
686
- ];
687
- var formatOfTodaySchema = recordKindWireSchema.shape.todaysFormat.exclude(["none-yet"]);
688
- var checkAddressSchema = z2.string().regex(new RegExp(`^${CATALOGUE_NAME}#${CATALOGUE_NAME}$`), {
689
- error: "is not a check address of the form <symptom>#<check>"
690
- });
691
- var versionOneNamesSchema = z2.strictObject({
692
- version: z2.literal(1),
693
- clauses: z2.array(
694
- z2.strictObject({
695
- clause: clauseAddressSchema,
696
- sight: z2.union([sightWireSchema, z2.literal("piece-forms")]),
697
- checks: z2.array(checkAddressSchema),
698
- anchor: anchorKindSchema.optional(),
699
- review: z2.string().min(1).optional()
700
- })
701
- ),
702
- recordKinds: z2.partialRecord(recordKindNameSchema, formatOfTodaySchema)
703
- }).superRefine((file, context) => {
704
- const checks = file.clauses.flatMap((entry) => entry.checks);
705
- [...new Set(checks.filter((check, index) => checks.indexOf(check) !== index))].forEach(
706
- (check) => {
707
- context.addIssue({ code: "custom", message: `${check} is named by more than one clause` });
708
- }
709
- );
710
- file.clauses.filter((entry) => entry.anchor === void 0 === entry.checks.length > 0).forEach((entry) => {
711
- context.addIssue({
712
- code: "custom",
713
- message: `${clauseAddressText({ address: entry.clause })} needs an anchor exactly when it names a check`
714
- });
715
- });
716
- });
717
- var NO_VERSION_ONE_NAMES = {
718
- clauses: [],
719
- claimsPieceForms: [],
720
- namedClauses: [],
721
- clauseOfCheck: /* @__PURE__ */ new Map(),
722
- formatsOfToday: {}
723
- };
724
- var addressedCheckOf = (address) => {
725
- const mark = address.indexOf(CHECK_ADDRESS_SEPARATOR);
726
- return { name: address.slice(mark + 1), symptom: { name: address.slice(0, mark) } };
727
- };
728
- var namedClauseOf = (entry) => entry.anchor === void 0 ? { clause: entry.clause, kind: "judgement" } : {
729
- clause: entry.clause,
730
- kind: "mechanical",
731
- anchor: entry.anchor,
732
- checks: entry.checks.map(addressedCheckOf)
733
- };
734
- var namesOf = (file) => ({
735
- clauses: file.clauses.flatMap(
736
- ({ clause, sight }) => sight === "piece-forms" ? [] : [{ clause, sight }]
737
- ),
738
- claimsPieceForms: file.clauses.flatMap(
739
- ({ clause, sight }) => sight === "piece-forms" ? [clause] : []
740
- ),
741
- namedClauses: file.clauses.map(namedClauseOf),
742
- clauseOfCheck: new Map(
743
- file.clauses.flatMap(
744
- ({ clause, checks }) => checks.map((check) => [check, clause])
745
- )
746
- ),
747
- formatsOfToday: file.recordKinds
748
- });
749
- var checksNamedFor = (request) => request.names.namedClauses.flatMap((named) => {
750
- if (named.kind !== "mechanical" || sameClauseAddress({ left: named.clause, right: request.clause }) === "different") {
751
- return [];
752
- }
753
- return named.checks.flatMap((check) => {
754
- const names = checkNamesOf({ text: checkAddressTextOf({ check }) });
755
- return names === void 0 ? [] : [names];
756
- });
757
- });
758
- var versionOneNamesOf = (request) => {
759
- const parsed = versionOneNamesSchema.safeParse(request.document);
760
- return parsed.success ? { outcome: "ok", value: namesOf(parsed.data) } : { outcome: "failed", error: z2.prettifyError(parsed.error) };
761
- };
762
- var readVersionOneNames = (request) => {
763
- const document = readVersionOneJson(request);
764
- if (document.outcome === "failed") {
765
- return document;
766
- }
767
- const names = versionOneNamesOf({ document: document.value });
768
- return names.outcome === "failed" ? {
769
- outcome: "failed",
770
- error: { kind: "file-malformed", path: request.path, detail: names.error }
771
- } : names;
772
- };
773
-
774
- // src/infrastructure/content-files/rule-sets/installed-pieces.ts
775
- var installedNamesPathOf = (request) => request.path.join({ segments: [request.installRoot, ...VERSION_ONE_NAMES_SEGMENTS] });
776
- var readInstalledNames = (request) => readVersionOneNames({ fileText: request.fileText, path: installedNamesPathOf(request) });
777
- var installedPieceOf = (request) => {
778
- const location = { ...request, ruleSetRoot: request.installRoot };
779
- const piece = readNamedPiece(location);
780
- if (piece.outcome === "failed") {
781
- return piece.error.kind === "piece-missing" ? { outcome: "ok", value: void 0 } : piece;
782
- }
783
- return {
784
- outcome: "ok",
785
- value: {
786
- mechanism: request.mechanism,
787
- examplesPath: piece.value.examplesPath,
788
- piece: piece.value
789
- }
790
- };
791
- };
792
- var firstPieceFrom = (request) => {
793
- const [check, ...remaining] = request.checks;
794
- if (check === void 0) {
795
- return { outcome: "ok", value: void 0 };
796
- }
797
- const held = installedPieceOf({ ...request, ...check });
798
- return held.outcome === "failed" || held.value !== void 0 ? held : firstPieceFrom({ ...request, checks: remaining });
799
- };
800
- var firstInstalledPieceFor = (request) => firstPieceFrom({ ...request, checks: checksNamedFor(request) });
801
- var installedPiecesFor = (request) => {
802
- const held = everyOk({
803
- entries: request.mechanisms,
804
- resolve: (mechanism) => firstInstalledPieceFor({ ...request, mechanism })
805
- });
806
- return held.outcome === "failed" ? held : { outcome: "ok", value: held.value.filter((piece) => piece !== void 0) };
807
- };
808
- var catalogueClausesOf = (request) => {
809
- const forms = everyOk({
810
- entries: request.names.claimsPieceForms,
811
- resolve: (clause) => {
812
- const first = firstInstalledPieceFor({ ...request, clause, mechanism: "walker" });
813
- if (first.outcome === "failed") {
814
- return first;
815
- }
816
- const forms2 = Object.entries(first.value?.piece.forms ?? {});
817
- if (first.value === void 0 || forms2.length === 0) {
818
- return {
819
- outcome: "failed",
820
- error: {
821
- kind: "rule-set-invalid",
822
- path: installedNamesPathOf(request),
823
- detail: `no piece declares the forms of ${clauseAddressText({ address: clause })}`
824
- }
825
- };
826
- }
827
- const names = new Set(
828
- checksNamedFor({ names: request.names, clause }).map(checkAddressOfNames)
829
- );
830
- const unknown = forms2.find(([, check]) => !names.has(checkAddressOfNames(check)));
831
- if (unknown !== void 0) {
832
- const [section, check] = unknown;
833
- return {
834
- outcome: "failed",
835
- error: {
836
- kind: "file-malformed",
837
- path: first.value.piece.declarationPath,
838
- detail: `form ${section} names unregistered check ${checkAddressOfNames(check)}`
839
- }
840
- };
841
- }
842
- return {
843
- outcome: "ok",
844
- value: {
845
- clause,
846
- sight: {
847
- kind: "symptom-by-form",
848
- forms: forms2.map(([section, { symptom }]) => ({ section, symptom }))
849
- }
850
- }
851
- };
852
- }
853
- });
854
- return forms.outcome === "failed" ? forms : { outcome: "ok", value: [...request.names.clauses, ...forms.value] };
855
- };
856
-
857
- // src/infrastructure/engines/engine-registry.ts
858
- var ENGINE_REGISTRY = [{ name: "walker" }, { name: "eslint" }];
859
-
860
- export {
861
- checkAddressOf,
862
- checkAt,
863
- checksOf,
864
- checkNamedAt,
865
- loadFailureDetail,
866
- loadFailureText,
867
- installRootOf,
868
- installRootOfApiEntry,
869
- ENGINE_REGISTRY,
870
- SUPPORTED_VERSION,
871
- catalogueNameSchema,
872
- recordKindNameSchema,
873
- caseWireSchema,
874
- symptomWireSchema,
875
- recordKindWireSchema,
876
- checkWireSchema,
877
- catalogueFileSchema,
878
- catalogueContentFromFile,
879
- VERSION_ONE_NAMES_SEGMENTS,
880
- NO_VERSION_ONE_NAMES,
881
- readVersionOneNames,
882
- installedNamesPathOf,
883
- readInstalledNames,
884
- firstInstalledPieceFor,
885
- installedPiecesFor,
886
- catalogueClausesOf
887
- };