@hailstails/hone 2.0.0-pre.2 → 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 +76 -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 +10493 -10410
  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 +953 -1189
  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 +213 -126
  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-MWLBA4B3.js +0 -849
  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,481 +0,0 @@
1
- import {
2
- editionOrder,
3
- isEdition
4
- } from "./chunk-RANIXNWY.js";
5
- import {
6
- brandedTextSchema,
7
- clauseIdSchema,
8
- disciplineIdSchema,
9
- engineIdSchema,
10
- repoPathSchema,
11
- versionOneEngineIdSchema
12
- } from "./chunk-GNOMK7CR.js";
13
-
14
- // src/domain/language-layer/catalogue-name.ts
15
- var CATALOGUE_NAME = "[a-z][a-z0-9]*(?:-[a-z0-9]+)*";
16
- var WHOLE_CATALOGUE_NAME = new RegExp(`^${CATALOGUE_NAME}$`);
17
- var isCatalogueName = (text) => WHOLE_CATALOGUE_NAME.test(text);
18
-
19
- // src/domain/language-layer/check-address-text.ts
20
- var CHECK_ADDRESS_SEPARATOR = "#";
21
- var checkNamesOf = (request) => {
22
- const [symptom, check, trailingSegment] = request.text.split(CHECK_ADDRESS_SEPARATOR);
23
- return trailingSegment === void 0 && symptom !== void 0 && check !== void 0 && isCatalogueName(symptom) && isCatalogueName(check) ? { symptom, check } : void 0;
24
- };
25
- var checkAddressOfNames = (names) => `${names.symptom}${CHECK_ADDRESS_SEPARATOR}${names.check}`;
26
- var checkAddressTextOf = (request) => `${request.check.symptom.name}${CHECK_ADDRESS_SEPARATOR}${request.check.name}`;
27
-
28
- // src/infrastructure/content-files/parsed-json.ts
29
- var parsedJson = (request) => {
30
- try {
31
- const parsed = JSON.parse(request.text);
32
- return { outcome: "ok", value: parsed };
33
- } catch (thrown) {
34
- return {
35
- outcome: "failed",
36
- error: thrown instanceof Error ? thrown.message : String(thrown)
37
- };
38
- }
39
- };
40
-
41
- // src/domain/rule-set/engine-id.ts
42
- var versionOneEngineNameOf = (engine) => engine === "walker" ? "audit" : engine;
43
-
44
- // src/infrastructure/content-files/rule-sets/rule-set-reader.ts
45
- import { z as z2 } from "zod";
46
-
47
- // src/domain/rule-set/piece-folder.ts
48
- var enginesFolderSegmentsOf = (request) => request.ruleSetRoot === request.installRoot ? ["src", "infrastructure", "engines"] : ["mechanisms"];
49
- var engineFolderOf = (request) => request.ruleSetRoot === request.installRoot ? request.mechanism : versionOneEngineNameOf(request.mechanism);
50
- var pieceFolderSegmentsOf = (request) => [
51
- request.ruleSetRoot,
52
- ...enginesFolderSegmentsOf(request),
53
- engineFolderOf(request),
54
- request.discipline
55
- ];
56
- var namedPieceFolderSegmentsOf = (request) => [
57
- request.ruleSetRoot,
58
- ...enginesFolderSegmentsOf(request),
59
- request.mechanism,
60
- request.symptom,
61
- request.check
62
- ];
63
-
64
- // src/domain/settings/clause-settings/reserved-edition-setting.ts
65
- var RESERVED_EDITION_SETTING = "edition";
66
-
67
- // src/domain/settings/json-values/json-kind.ts
68
- var JSON_KIND_NAMES = {
69
- string: "a string",
70
- number: "a number",
71
- boolean: "a boolean",
72
- null: "null",
73
- array: "an array",
74
- object: "an object"
75
- };
76
- var jsonKindOf = (request) => {
77
- if (request.value === null) return "null";
78
- if (Array.isArray(request.value)) return "array";
79
- const kind = typeof request.value;
80
- if (kind === "string" || kind === "number" || kind === "boolean") return kind;
81
- return "object";
82
- };
83
- var isJsonObject = (candidate) => jsonKindOf({ value: candidate }) === "object";
84
- var sameItems = (request) => request.left.length === request.right.length && request.left.every(
85
- (leftItem, position) => sameJsonValue({ left: leftItem, right: request.right[position] }) === "same"
86
- ) ? "same" : "different";
87
- var sameObjects = (request) => Object.keys(request.left).length === Object.keys(request.right).length && Object.entries(request.left).every(
88
- ([key, leftEntry]) => Object.hasOwn(request.right, key) && sameJsonValue({ left: leftEntry, right: request.right[key] }) === "same"
89
- ) ? "same" : "different";
90
- var sameJsonValue = (request) => {
91
- const { left, right } = request;
92
- if (right === void 0 || jsonKindOf({ value: left }) !== jsonKindOf({ value: right }))
93
- return "different";
94
- if (Array.isArray(left) && Array.isArray(right)) return sameItems({ left, right });
95
- if (isJsonObject(left) && isJsonObject(right)) return sameObjects({ left, right });
96
- return left === right ? "same" : "different";
97
- };
98
-
99
- // src/infrastructure/content-files/edition.ts
100
- import { z } from "zod";
101
- var editionSchema = brandedTextSchema({
102
- text: z.string(),
103
- isBranded: isEdition,
104
- refusal: "not an edition: a whole number from 1, written as text"
105
- });
106
- var FIRST_EDITION = editionSchema.parse("1");
107
- var clauseEditionsSchema = z.tuple([editionSchema], editionSchema).default([FIRST_EDITION]).refine((editions) => editionOrder({ editions }) === "ascending", {
108
- error: "editions must be listed in ascending order, each once"
109
- }).transform(([first, ...later]) => ({
110
- declared: [first, ...later],
111
- default: first,
112
- latest: later.at(-1) ?? first
113
- }));
114
-
115
- // src/infrastructure/content-files/rule-sets/rule-set-reader.ts
116
- var SUPPORTED_VERSION = 1;
117
- var readVersionOneJson = (request) => {
118
- const text = request.fileText.read({ path: request.path });
119
- if (text.outcome === "failed") {
120
- return {
121
- outcome: "failed",
122
- error: { kind: "file-unreadable", path: request.path, detail: text.error.detail }
123
- };
124
- }
125
- const parsed = parsedJson({ text: text.value });
126
- if (parsed.outcome === "failed") {
127
- return {
128
- outcome: "failed",
129
- error: { kind: "file-malformed", path: request.path, detail: parsed.error }
130
- };
131
- }
132
- const document = parsed.value;
133
- if (typeof document === "object" && document !== null && "version" in document && document.version !== SUPPORTED_VERSION) {
134
- return {
135
- outcome: "failed",
136
- error: { kind: "unsupported-version", path: request.path, found: document.version }
137
- };
138
- }
139
- return { outcome: "ok", value: document };
140
- };
141
- var entryCount = (entries) => entries.length > 0 ? "some" : "empty";
142
- var textDistinctness = (texts) => new Set(texts).size === texts.length ? "distinct" : "repeated";
143
- var sourceCaseSchema = z2.object({
144
- name: z2.string(),
145
- fileName: repoPathSchema,
146
- source: z2.string(),
147
- expectedLines: z2.array(z2.number()),
148
- edition: editionSchema.optional()
149
- });
150
- var flagCaseSchema = sourceCaseSchema.refine(
151
- (sourceCase) => entryCount(sourceCase.expectedLines) === "some",
152
- { error: "a flag case names no expected line" }
153
- );
154
- var allowCaseSchema = sourceCaseSchema.refine(
155
- (sourceCase) => entryCount(sourceCase.expectedLines) === "empty",
156
- { error: "an allow case names expected lines" }
157
- );
158
- var anchorKindSchema = z2.discriminatedUnion("kind", [
159
- z2.object({ kind: z2.literal("keyword"), keyword: z2.string() }),
160
- z2.object({ kind: z2.literal("file") })
161
- ]);
162
- var ruleSetMechanismSchema = z2.string().transform((text, context) => {
163
- const parsed = versionOneEngineIdSchema.safeParse(text);
164
- if (parsed.success) {
165
- return parsed.data;
166
- }
167
- context.addIssue({
168
- code: "custom",
169
- message: `not a mechanism: expected one of ${engineIdSchema.options.join(", ")}`
170
- });
171
- return z2.NEVER;
172
- });
173
- var clauseCasesSchema = z2.object({
174
- flag: z2.array(flagCaseSchema).refine((entries) => entryCount(entries) === "some", {
175
- error: "a mechanical clause has no flag case"
176
- }),
177
- allow: z2.array(allowCaseSchema).refine((entries) => entryCount(entries) === "some", {
178
- error: "a mechanical clause has no allow case"
179
- })
180
- });
181
- var clauseDefinitionSchema = z2.discriminatedUnion("kind", [
182
- z2.object({
183
- kind: z2.literal("mechanical"),
184
- id: clauseIdSchema,
185
- summary: z2.string(),
186
- mechanisms: z2.array(ruleSetMechanismSchema).refine((entries) => entryCount(entries) === "some", {
187
- error: "a mechanical clause names no mechanism"
188
- }),
189
- anchor: anchorKindSchema,
190
- exceptions: z2.enum(["allowed", "refused"]).default("allowed"),
191
- cases: clauseCasesSchema
192
- }).transform((clause) => ({
193
- kind: clause.kind,
194
- id: clause.id,
195
- mechanisms: clause.mechanisms,
196
- anchor: clause.anchor,
197
- exceptions: clause.exceptions,
198
- cases: clause.cases
199
- })),
200
- z2.object({
201
- kind: z2.literal("judgement"),
202
- id: clauseIdSchema,
203
- summary: z2.string(),
204
- enforcedBy: z2.literal("review")
205
- }).transform((clause) => ({ kind: clause.kind, id: clause.id, enforcedBy: clause.enforcedBy }))
206
- ]);
207
- var disciplineFileSchema = z2.object({
208
- version: z2.literal(SUPPORTED_VERSION),
209
- id: disciplineIdSchema,
210
- clauses: z2.array(clauseDefinitionSchema).refine((clauses) => textDistinctness(clauses.map((clause) => clause.id)) === "distinct", {
211
- error: "two clauses share an id"
212
- })
213
- });
214
- var clauseSettingDeclarationSchema = z2.strictObject({
215
- default: z2.json(),
216
- choices: z2.array(z2.json()).min(1).optional()
217
- }).superRefine((declaration, context) => {
218
- if (declaration.choices === void 0) return;
219
- const defaultKind = jsonKindOf({ value: declaration.default });
220
- if (declaration.choices.some((choice) => jsonKindOf({ value: choice }) !== defaultKind)) {
221
- context.addIssue({
222
- code: "custom",
223
- path: ["choices"],
224
- message: `every choice must be ${JSON_KIND_NAMES[defaultKind]}, as the default is`
225
- });
226
- }
227
- if (!declaration.choices.some(
228
- (choice) => sameJsonValue({ left: choice, right: declaration.default }) === "same"
229
- )) {
230
- context.addIssue({
231
- code: "custom",
232
- path: ["default"],
233
- message: "the default must be one of the choices"
234
- });
235
- }
236
- });
237
- var pieceFileSchema = z2.object({
238
- version: z2.literal(SUPPORTED_VERSION),
239
- discipline: disciplineIdSchema,
240
- mechanism: ruleSetMechanismSchema,
241
- clauses: z2.array(
242
- z2.object({
243
- clause: clauseIdSchema,
244
- settings: z2.unknown(),
245
- clauseSettings: z2.record(z2.string().min(1), clauseSettingDeclarationSchema).default({}).refine((declarations) => !Object.hasOwn(declarations, RESERVED_EDITION_SETTING), {
246
- error: `${RESERVED_EDITION_SETTING} is reserved for the clause's editions; declare them under editions`
247
- }),
248
- editions: clauseEditionsSchema
249
- })
250
- ).refine((entries) => textDistinctness(entries.map((entry) => entry.clause)) === "distinct", {
251
- error: "two entries name the same clause"
252
- })
253
- });
254
- var isContentRefusal = (issue) => issue.code === "custom";
255
- var schemaRefusal = (request) => {
256
- const detail = z2.prettifyError(request.error);
257
- return request.error.issues.every(isContentRefusal) ? { kind: "rule-set-invalid", path: request.path, detail } : { kind: "file-malformed", path: request.path, detail };
258
- };
259
- var ruleSetInvalid = (request) => ({
260
- outcome: "failed",
261
- error: { kind: "rule-set-invalid", path: request.path, detail: request.detail }
262
- });
263
- var disciplineFilePath = (request) => request.path.join({
264
- segments: [request.ruleSetRoot, "rules", request.discipline, "discipline.json"]
265
- });
266
- var pieceFilePath = (request) => request.path.join({ segments: [...pieceFolderSegmentsOf(request), "piece.json"] });
267
- var readDisciplineFile = (request) => {
268
- const { path } = request;
269
- const document = readVersionOneJson({ fileText: request.fileText, path });
270
- if (document.outcome === "failed") {
271
- return document;
272
- }
273
- const parsed = disciplineFileSchema.safeParse(document.value);
274
- if (!parsed.success) {
275
- return { outcome: "failed", error: schemaRefusal({ path, error: parsed.error }) };
276
- }
277
- if (parsed.data.id !== request.discipline) {
278
- return ruleSetInvalid({
279
- path,
280
- detail: `id ${parsed.data.id} differs from its folder name ${request.discipline}`
281
- });
282
- }
283
- return { outcome: "ok", value: parsed.data };
284
- };
285
- var undeclaredCaseEditionOf = (request) => request.piece.clauses.flatMap((entry) => {
286
- const definition = request.discipline.clauses.find(
287
- (clause) => clause.id === entry.clause && clause.kind === "mechanical"
288
- );
289
- const cases = definition === void 0 ? [] : [...definition.cases.flag, ...definition.cases.allow];
290
- return cases.flatMap(
291
- (sourceCase) => sourceCase.edition === void 0 || entry.editions.declared.includes(sourceCase.edition) ? [] : [
292
- `case ${sourceCase.name} of clause ${entry.clause} runs under edition ${sourceCase.edition}, which this piece does not declare; it declares ${entry.editions.declared.join(", ")}`
293
- ]
294
- );
295
- }).at(0);
296
- var readPieceFile = (request) => {
297
- const path = pieceFilePath({
298
- path: request.path,
299
- ruleSetRoot: request.ruleSetRoot,
300
- installRoot: request.installRoot,
301
- mechanism: request.mechanism,
302
- discipline: request.discipline.id
303
- });
304
- const document = readVersionOneJson({ fileText: request.fileText, path });
305
- if (document.outcome === "failed") {
306
- return document;
307
- }
308
- const parsed = pieceFileSchema.safeParse(document.value);
309
- if (!parsed.success) {
310
- return { outcome: "failed", error: schemaRefusal({ path, error: parsed.error }) };
311
- }
312
- const piece = parsed.data;
313
- if (piece.discipline !== request.discipline.id) {
314
- return ruleSetInvalid({
315
- path,
316
- detail: `discipline ${piece.discipline} differs from its folder name ${request.discipline.id}`
317
- });
318
- }
319
- if (piece.mechanism !== request.mechanism) {
320
- return ruleSetInvalid({
321
- path,
322
- detail: `mechanism ${piece.mechanism} differs from its folder name ${request.mechanism}`
323
- });
324
- }
325
- const declared = request.discipline.clauses.map((clause) => clause.id);
326
- const undeclared = piece.clauses.find((entry) => !declared.includes(entry.clause));
327
- if (undeclared !== void 0) {
328
- return ruleSetInvalid({
329
- path,
330
- detail: `clause ${undeclared.clause} is not declared by discipline ${request.discipline.id}`
331
- });
332
- }
333
- const unsupported = undeclaredCaseEditionOf({ piece, discipline: request.discipline });
334
- if (unsupported !== void 0) {
335
- return ruleSetInvalid({ path, detail: unsupported });
336
- }
337
- return { outcome: "ok", value: piece };
338
- };
339
-
340
- // src/infrastructure/engines/named-piece.ts
341
- import { z as z3 } from "zod";
342
- var legacyPieceEntry = pieceFileSchema.shape.clauses.element.shape;
343
- var catalogueNameSchema = z3.string().refine(isCatalogueName);
344
- var namedPieceImplementationSchema = z3.strictObject({
345
- symptom: catalogueNameSchema,
346
- check: catalogueNameSchema
347
- });
348
- var namedPieceSchema = z3.strictObject({
349
- version: z3.literal(2),
350
- anchor: anchorKindSchema,
351
- exceptions: z3.enum(["allowed", "refused"]).default("allowed"),
352
- settings: z3.json(),
353
- implementation: namedPieceImplementationSchema.optional(),
354
- forms: z3.record(z3.string(), namedPieceImplementationSchema).default({}),
355
- examples: z3.literal("with-implementation").optional(),
356
- checkSettings: legacyPieceEntry.clauseSettings,
357
- editions: legacyPieceEntry.editions
358
- });
359
- var readPieceDeclaration = (request) => {
360
- const text = request.fileText.read({ path: request.path });
361
- if (text.outcome === "failed") {
362
- return {
363
- outcome: "failed",
364
- error: {
365
- kind: "file-unreadable",
366
- path: request.path,
367
- detail: `${request.address}: ${text.error.detail}`
368
- }
369
- };
370
- }
371
- const document = parsedJson({ text: text.value });
372
- if (document.outcome === "failed") {
373
- return {
374
- outcome: "failed",
375
- error: {
376
- kind: "file-malformed",
377
- path: request.path,
378
- detail: `${request.address}: ${document.error}`
379
- }
380
- };
381
- }
382
- const piece = namedPieceSchema.safeParse(document.value);
383
- return piece.success ? { outcome: "ok", value: piece.data } : {
384
- outcome: "failed",
385
- error: {
386
- kind: "file-malformed",
387
- path: request.path,
388
- detail: `${request.address}: ${z3.prettifyError(piece.error)}`
389
- }
390
- };
391
- };
392
- var namedPiecePathOf = (request) => request.path.join({ segments: [...namedPieceFolderSegmentsOf(request), "piece.json"] });
393
- var readNamedPiece = (request) => {
394
- const address = `${request.symptom}#${request.check}`;
395
- const path = namedPiecePathOf(request);
396
- if (request.fileText.exists({ path }) === "absent") {
397
- return {
398
- outcome: "failed",
399
- error: { kind: "piece-missing", address, mechanism: request.mechanism }
400
- };
401
- }
402
- const declared = readPieceDeclaration({ fileText: request.fileText, path, address });
403
- if (declared.outcome === "failed") return declared;
404
- const { anchor, exceptions, settings, checkSettings, editions, forms, implementation, examples } = declared.value;
405
- const implementationRoot = namedPieceFolderSegmentsOf({ ...request, ...implementation });
406
- const localCheck = { symptom: request.symptom, check: request.check };
407
- const exampleOwner = examples === "with-implementation" ? implementation : localCheck;
408
- if (exampleOwner === void 0) {
409
- return {
410
- outcome: "failed",
411
- error: {
412
- kind: "file-malformed",
413
- path,
414
- detail: `${address}: shared examples require an implementation`
415
- }
416
- };
417
- }
418
- const examplesPath = request.path.join({
419
- segments: [
420
- ...namedPieceFolderSegmentsOf({ ...request, ...exampleOwner }),
421
- `${exampleOwner.check}.examples.json`
422
- ]
423
- });
424
- return {
425
- outcome: "ok",
426
- value: {
427
- anchor,
428
- exceptions,
429
- settings,
430
- declarations: checkSettings,
431
- editions,
432
- forms,
433
- declarationPath: path,
434
- exampleOwner,
435
- examplesPath,
436
- pieceRoot: request.path.join({ segments: implementationRoot })
437
- }
438
- };
439
- };
440
-
441
- // src/domain/settings/every-ok.ts
442
- var everyOk = (request) => request.entries.reduce(
443
- (sofar, entry) => {
444
- if (sofar.outcome === "failed") {
445
- return sofar;
446
- }
447
- const resolved = request.resolve(entry);
448
- return resolved.outcome === "failed" ? resolved : { outcome: "ok", value: [...sofar.value, resolved.value] };
449
- },
450
- { outcome: "ok", value: [] }
451
- );
452
-
453
- export {
454
- CATALOGUE_NAME,
455
- isCatalogueName,
456
- CHECK_ADDRESS_SEPARATOR,
457
- checkNamesOf,
458
- checkAddressOfNames,
459
- checkAddressTextOf,
460
- parsedJson,
461
- versionOneEngineNameOf,
462
- RESERVED_EDITION_SETTING,
463
- everyOk,
464
- enginesFolderSegmentsOf,
465
- engineFolderOf,
466
- pieceFolderSegmentsOf,
467
- JSON_KIND_NAMES,
468
- jsonKindOf,
469
- sameJsonValue,
470
- readVersionOneJson,
471
- sourceCaseSchema,
472
- anchorKindSchema,
473
- clauseCasesSchema,
474
- pieceFileSchema,
475
- disciplineFilePath,
476
- pieceFilePath,
477
- readDisciplineFile,
478
- readPieceFile,
479
- namedPiecePathOf,
480
- readNamedPiece
481
- };
@@ -1,31 +0,0 @@
1
- // src/domain/repository/projection-outputs.ts
2
- var projectionOutputsOf = (request) => ({
3
- configuration: `hone.${request.engineName}.mjs`,
4
- declaration: `hone.${request.engineName}.d.mts`
5
- });
6
-
7
- // src/domain/repository/repo-path-of.ts
8
- var repoPathOf = (text) => {
9
- const plain = text;
10
- return plain;
11
- };
12
-
13
- // src/domain/repository/absolute-within.ts
14
- var BACKSLASH = "\\";
15
- var BACKSLASH_FORM = /^(?:[A-Za-z]:\\|\\\\)/;
16
- var absoluteWithin = (request) => {
17
- const separator = BACKSLASH_FORM.test(request.root) ? BACKSLASH : "/";
18
- const root = request.root.endsWith(separator) ? request.root.slice(0, -1) : request.root;
19
- return `${root}${separator}${request.file.replaceAll("/", separator)}`;
20
- };
21
-
22
- // src/infrastructure/engines/eslint/eslint-config-lookup.ts
23
- import { z } from "zod";
24
- var eslintConfigLookupSchema = z.enum(["nearest-to-file", "repository-root"]);
25
-
26
- export {
27
- projectionOutputsOf,
28
- eslintConfigLookupSchema,
29
- repoPathOf,
30
- absoluteWithin
31
- };
@@ -1,38 +0,0 @@
1
- // src/infrastructure/engines/protocol/toolchain/toolchain-bound-runner.ts
2
- var builtOnce = (request) => request.toolchain.then(
3
- (loaded) => loaded.outcome === "failed" ? loaded : { outcome: "ok", value: request.runnerOf(loaded.value) }
4
- );
5
- var withRunner = (request) => request.runner.then((built) => built.outcome === "failed" ? built : request.act(built.value));
6
- var toolchainBoundStandaloneRunner = (request) => {
7
- const runner = builtOnce(request);
8
- return {
9
- exceptionPath: "standalone",
10
- run: (run) => withRunner({ runner, act: (built) => built.run(run) }),
11
- conform: (conform) => withRunner({ runner, act: (built) => built.conform(conform) })
12
- };
13
- };
14
- var toolchainBoundEmbeddedRunner = (request) => {
15
- const runner = builtOnce(request);
16
- return {
17
- exceptionPath: "embedded",
18
- projectedKinds: request.projectedKinds,
19
- run: (run) => withRunner({ runner, act: (built) => built.run(run) }),
20
- conform: (conform) => withRunner({ runner, act: (built) => built.conform(conform) }),
21
- project: (project) => withRunner({ runner, act: (built) => built.project(project) })
22
- };
23
- };
24
- var toolchainBoundChecksRunner = (request) => {
25
- const runner = builtOnce(request);
26
- return {
27
- projectedKinds: request.projectedKinds,
28
- run: (run) => runner.then((built) => built.outcome === "failed" ? built : built.value.run(run)),
29
- conform: (conform) => withRunner({ runner, act: (built) => built.conform(conform) }),
30
- project: (project) => runner.then((built) => built.outcome === "failed" ? built : built.value.project(project))
31
- };
32
- };
33
-
34
- export {
35
- toolchainBoundStandaloneRunner,
36
- toolchainBoundEmbeddedRunner,
37
- toolchainBoundChecksRunner
38
- };
@@ -1,22 +0,0 @@
1
- import {
2
- clauseAddressText
3
- } from "./chunk-M6SOGWT7.js";
4
-
5
- // src/infrastructure/engines/walker/runner/pieces/piece-clause-settings.ts
6
- import { z } from "zod";
7
- var stringListClauseSettings = (request) => {
8
- const parsed = z.record(z.enum(request.keys), z.array(z.string().min(1)).readonly()).safeParse(request.clause.clauseSettings);
9
- if (parsed.success) return { outcome: "ok", value: parsed.data };
10
- return {
11
- outcome: "failed",
12
- error: {
13
- kind: "piece-invalid",
14
- pieceRoot: request.clause.pieceRoot,
15
- detail: `the clauseSettings of ${clauseAddressText({ address: request.clause.address })} are malformed: ${z.prettifyError(parsed.error)}`
16
- }
17
- };
18
- };
19
-
20
- export {
21
- stringListClauseSettings
22
- };