@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,843 +0,0 @@
1
- import {
2
- ENGINE_REGISTRY,
3
- checkNamedAt,
4
- firstInstalledPieceFor,
5
- installedNamesPathOf,
6
- installedPiecesFor,
7
- readInstalledNames
8
- } from "./chunk-IX2VZTBO.js";
9
- import {
10
- clauseCasesSchema,
11
- disciplineFilePath,
12
- everyOk,
13
- pieceFolderSegmentsOf,
14
- readDisciplineFile,
15
- readPieceFile,
16
- readVersionOneJson
17
- } from "./chunk-R75QELTA.js";
18
- import {
19
- caseVerdictSchema,
20
- hitSchema,
21
- measuredPairSchema,
22
- measuredSchema,
23
- nativeExceptionKindSchema,
24
- projectionWriteSchema,
25
- reportedCheckSchema,
26
- runnerFailureSchema,
27
- runnerResultSchema
28
- } from "./chunk-ASUN4AVC.js";
29
- import {
30
- clauseAddressObjectSchema
31
- } from "./chunk-NRIQD3PI.js";
32
- import {
33
- repoPathSchema,
34
- runnerModuleSegmentsOf
35
- } from "./chunk-GNOMK7CR.js";
36
- import {
37
- TOOL_RULE_SET,
38
- clauseAddressText,
39
- sameClauseAddress
40
- } from "./chunk-M6SOGWT7.js";
41
-
42
- // src/infrastructure/engines/protocol/conformance.ts
43
- import { z } from "zod";
44
-
45
- // src/domain/runner/runner-failure.ts
46
- var runnerInvalidOutput = (request) => ({
47
- outcome: "failed",
48
- error: { kind: "runner-invalid-output", detail: request.detail }
49
- });
50
- var thrownMessage = (request) => request.thrown instanceof Error ? request.thrown.message : String(request.thrown);
51
- var rejectedCall = (request) => runnerInvalidOutput({ detail: `the runner call threw or rejected: ${thrownMessage(request)}` });
52
-
53
- // src/infrastructure/engines/protocol/conformance.ts
54
- var caseVerdictsResultSchema = runnerResultSchema({
55
- value: z.array(caseVerdictSchema).readonly()
56
- });
57
- var lineSet = (request) => [...new Set(request.lines)].toSorted((left, right) => left - right);
58
- var verdictsNaming = (request) => request.verdicts.filter((verdict) => verdict.caseName === request.caseName);
59
- var unmatchedVerdict = (request) => {
60
- const missing = request.cases.find(
61
- (sourceCase) => verdictsNaming({ verdicts: request.verdicts, caseName: sourceCase.name }).length !== 1
62
- );
63
- if (missing !== void 0) {
64
- return `case ${missing.name} has no single verdict`;
65
- }
66
- const unknown = request.verdicts.find(
67
- (verdict) => !request.cases.some((sourceCase) => sourceCase.name === verdict.caseName)
68
- );
69
- return unknown === void 0 ? void 0 : `a verdict names the unknown case ${unknown.caseName}`;
70
- };
71
- var caseConformance = (request) => {
72
- const { sourceCase } = request;
73
- const expectedLines = lineSet({ lines: sourceCase.expectedLines });
74
- const flaggedLines = lineSet({
75
- lines: verdictsNaming({ verdicts: request.verdicts, caseName: sourceCase.name }).flatMap(
76
- (verdict) => verdict.flaggedLines
77
- )
78
- });
79
- if (expectedLines.join(" ") === flaggedLines.join(" ")) {
80
- return [];
81
- }
82
- return [
83
- { clause: request.clause.address, caseName: sourceCase.name, expectedLines, flaggedLines }
84
- ];
85
- };
86
- var conformanceOf = (request) => {
87
- const parsed = caseVerdictsResultSchema.safeParse(request.returned);
88
- if (!parsed.success) {
89
- return runnerInvalidOutput({ detail: z.prettifyError(parsed.error) });
90
- }
91
- if (parsed.data.outcome === "failed") {
92
- return parsed.data;
93
- }
94
- const verdicts = parsed.data.value;
95
- const unmatched = unmatchedVerdict({ verdicts, cases: request.cases });
96
- if (unmatched !== void 0) {
97
- return runnerInvalidOutput({ detail: unmatched });
98
- }
99
- return {
100
- outcome: "ok",
101
- value: request.cases.flatMap(
102
- (sourceCase) => caseConformance({ sourceCase, verdicts, clause: request.clause })
103
- )
104
- };
105
- };
106
- var checkConformance = (request) => Promise.resolve().then(() => request.runner.conform({ clause: request.clause, cases: request.cases })).then(
107
- (returned) => conformanceOf({ returned, clause: request.clause, cases: request.cases }),
108
- (thrown) => rejectedCall({ thrown })
109
- );
110
-
111
- // src/infrastructure/engines/protocol/embedded/embedded-mechanism-dispatch.ts
112
- import { z as z5 } from "zod";
113
-
114
- // src/infrastructure/engines/protocol/engine-run/standalone-mechanism-dispatch.ts
115
- import { z as z4 } from "zod";
116
-
117
- // src/infrastructure/engines/protocol/runner-module/standalone-run-report-schema.ts
118
- import { z as z3 } from "zod";
119
-
120
- // src/infrastructure/engines/protocol/embedded/embedded-run-report-schema.ts
121
- import { z as z2 } from "zod";
122
- var namedCheck = { check: reportedCheckSchema.optional() };
123
- var inlineLineSchema = z2.number().int().min(1);
124
- var inlineDisableSchema = z2.object({
125
- kind: z2.literal("inline-disable"),
126
- ...namedCheck,
127
- clause: clauseAddressObjectSchema,
128
- file: repoPathSchema,
129
- line: inlineLineSchema,
130
- text: z2.string(),
131
- reach: z2.enum(["one-clause", "every-selected-clause"])
132
- }).readonly();
133
- var scriptOptionCauseSchema = z2.discriminatedUnion("kind", [
134
- z2.object({ kind: z2.literal("weakens-run") }).readonly(),
135
- z2.object({
136
- kind: z2.literal("after-another-command"),
137
- command: z2.string(),
138
- invocation: z2.string()
139
- }).readonly(),
140
- z2.object({ kind: z2.literal("wrapped"), command: z2.string(), wrapper: z2.string() }).readonly(),
141
- z2.object({ kind: z2.literal("unreadable"), command: z2.string() }).readonly()
142
- ]);
143
- var nativeExceptionSchema = z2.discriminatedUnion("kind", [
144
- z2.object({
145
- kind: z2.literal("ignore"),
146
- ...namedCheck,
147
- clause: clauseAddressObjectSchema,
148
- file: repoPathSchema
149
- }).readonly(),
150
- z2.object({
151
- kind: z2.literal("config-override"),
152
- ...namedCheck,
153
- clause: clauseAddressObjectSchema,
154
- file: repoPathSchema
155
- }).readonly(),
156
- z2.object({
157
- kind: z2.literal("suppression-entry"),
158
- ...namedCheck,
159
- clause: clauseAddressObjectSchema,
160
- file: repoPathSchema,
161
- location: repoPathSchema
162
- }).readonly(),
163
- inlineDisableSchema,
164
- z2.object({
165
- kind: z2.literal("inline-rule-config"),
166
- ...namedCheck,
167
- clause: clauseAddressObjectSchema,
168
- file: repoPathSchema,
169
- line: inlineLineSchema,
170
- text: z2.string()
171
- }).readonly(),
172
- z2.object({
173
- kind: z2.literal("command-line-option"),
174
- ...namedCheck,
175
- clause: clauseAddressObjectSchema,
176
- location: repoPathSchema,
177
- script: z2.string(),
178
- option: z2.string(),
179
- cause: scriptOptionCauseSchema
180
- }).readonly()
181
- ]);
182
- var sliceProblemSchema = z2.object({
183
- slice: repoPathSchema,
184
- state: z2.enum([
185
- "out-of-date",
186
- "missing",
187
- "not-applied",
188
- "unconfigured",
189
- "nested-configuration"
190
- ])
191
- }).readonly();
192
- var unprojectedFolderSchema = z2.object({
193
- folder: repoPathSchema,
194
- selectionFolder: repoPathSchema
195
- }).readonly();
196
- var embeddedRunReportSchema = z2.object({
197
- hits: z2.array(hitSchema).readonly(),
198
- nativeExceptions: z2.array(nativeExceptionSchema).readonly(),
199
- projection: z2.enum(["current", "out-of-date", "missing", "not-included"]),
200
- slices: z2.array(sliceProblemSchema).readonly().default([]),
201
- unprojectedFolders: z2.array(unprojectedFolderSchema).readonly().default([]),
202
- measured: measuredSchema
203
- }).readonly();
204
-
205
- // src/infrastructure/engines/protocol/runner-module/standalone-run-report-schema.ts
206
- var STANDALONE_RUN_SHAPE_MESSAGE = "a standalone run's value is { hits, nativeExceptions }, not a bare list of hits";
207
- var standaloneRunReportSchema = z3.object(
208
- {
209
- hits: z3.array(hitSchema).readonly(),
210
- nativeExceptions: z3.array(inlineDisableSchema).readonly(),
211
- measured: measuredSchema
212
- },
213
- { error: STANDALONE_RUN_SHAPE_MESSAGE }
214
- ).readonly();
215
-
216
- // src/infrastructure/engines/protocol/engine-run/unrequested-entries.ts
217
- var requestHeldOf = (request) => ({
218
- files: new Set(request.files),
219
- clauses: new Set(request.clauses.map((address) => clauseAddressText({ address })))
220
- });
221
- var clauseHeld = (request) => request.held.clauses.has(clauseAddressText({ address: request.clause })) ? "held" : "not-held";
222
- var unrequestedDetailOf = (request) => {
223
- const entry = request.entries.find(
224
- (candidate) => !request.held.files.has(candidate.file) || clauseHeld({ held: request.held, clause: candidate.clause }) === "not-held"
225
- );
226
- return entry === void 0 ? [] : [
227
- `${request.noun} names ${clauseAddressText({ address: entry.clause })} in ${entry.file}, which the request did not hold`
228
- ];
229
- };
230
- var unrequestedClauseDetailOf = (request) => {
231
- const entry = request.entries.find(
232
- (candidate) => clauseHeld({ held: request.held, clause: candidate.clause }) === "not-held"
233
- );
234
- return entry === void 0 ? [] : [
235
- `${request.noun} names ${clauseAddressText({ address: entry.clause })}, which the request did not hold`
236
- ];
237
- };
238
-
239
- // src/infrastructure/engines/protocol/engine-run/standalone-mechanism-dispatch.ts
240
- var STANDALONE_COVERABLE_KINDS = ["inline-disable"];
241
- var NOTHING_MEASURED = [];
242
- var standaloneResultSchema = runnerResultSchema({ value: standaloneRunReportSchema });
243
- var firstUnrequestedDetail = (request) => {
244
- const held = requestHeldOf({
245
- files: request.checkedFiles,
246
- clauses: request.run.clauses.map((clause) => clause.address)
247
- });
248
- return request.groups.flatMap(
249
- (group) => unrequestedDetailOf({ noun: group.noun, entries: group.entries, held })
250
- )[0];
251
- };
252
- var okOutcomeSchema = z4.object({ outcome: z4.literal("ok") });
253
- var okStandaloneSchema = z4.object({ outcome: z4.literal("ok"), value: standaloneRunReportSchema });
254
- var invalidStandaloneDetail = (request) => {
255
- if (!okOutcomeSchema.safeParse(request.returned).success) {
256
- return z4.prettifyError(request.error);
257
- }
258
- const report = okStandaloneSchema.safeParse(request.returned);
259
- return z4.prettifyError(report.success ? request.error : report.error);
260
- };
261
- var standaloneRun = (request) => {
262
- const parsed = standaloneResultSchema.safeParse(request.returned);
263
- if (!parsed.success) {
264
- return runnerInvalidOutput({
265
- detail: invalidStandaloneDetail({ returned: request.returned, error: parsed.error })
266
- });
267
- }
268
- if (parsed.data.outcome === "failed") {
269
- return parsed.data;
270
- }
271
- const report = parsed.data.value;
272
- const unrequested = firstUnrequestedDetail({
273
- groups: [
274
- { noun: "a hit", entries: report.hits },
275
- { noun: "a native exception", entries: report.nativeExceptions },
276
- { noun: "a measured pair", entries: report.measured ?? NOTHING_MEASURED }
277
- ],
278
- run: request.run,
279
- checkedFiles: request.run.trackedPaths
280
- });
281
- if (unrequested !== void 0) {
282
- return runnerInvalidOutput({ detail: unrequested });
283
- }
284
- return {
285
- outcome: "ok",
286
- value: {
287
- mechanism: request.mechanism,
288
- hits: report.hits,
289
- nativeExceptions: report.nativeExceptions,
290
- coverableKinds: STANDALONE_COVERABLE_KINDS,
291
- projection: "none",
292
- slices: [],
293
- unprojectedFolders: [],
294
- measured: report.measured ?? NOTHING_MEASURED
295
- }
296
- };
297
- };
298
- var unrequestedNativeException = (request) => request.nativeExceptions.find(
299
- (nativeException) => !request.run.clauses.some(
300
- (clause) => sameClauseAddress({ left: clause.address, right: nativeException.clause }) === "same"
301
- )
302
- );
303
- var runMechanism = (request) => {
304
- const { runner } = request;
305
- return Promise.resolve().then(() => runner.run(request.run)).then(
306
- (returned) => standaloneRun({ returned, mechanism: request.mechanism, run: request.run }),
307
- (thrown) => rejectedCall({ thrown })
308
- );
309
- };
310
-
311
- // src/infrastructure/engines/protocol/embedded/embedded-mechanism-dispatch.ts
312
- var reportResultSchema = runnerResultSchema({ value: embeddedRunReportSchema });
313
- var projectionWriteResultSchema = runnerResultSchema({
314
- value: z5.array(projectionWriteSchema).readonly()
315
- });
316
- var embeddedRun = (request) => {
317
- const parsed = reportResultSchema.safeParse(request.returned);
318
- if (!parsed.success) {
319
- return runnerInvalidOutput({ detail: z5.prettifyError(parsed.error) });
320
- }
321
- if (parsed.data.outcome === "failed") {
322
- return parsed.data;
323
- }
324
- const report = parsed.data.value;
325
- const unrequested = firstUnrequestedDetail({
326
- groups: [
327
- { noun: "a hit", entries: report.hits },
328
- { noun: "a measured pair", entries: report.measured ?? NOTHING_MEASURED }
329
- ],
330
- run: request.run,
331
- checkedFiles: request.run.files
332
- });
333
- if (unrequested !== void 0) {
334
- return runnerInvalidOutput({ detail: unrequested });
335
- }
336
- const unrequestedNative = unrequestedNativeException({
337
- nativeExceptions: report.nativeExceptions,
338
- run: request.run
339
- });
340
- if (unrequestedNative !== void 0) {
341
- return runnerInvalidOutput({
342
- detail: `a native exception names ${clauseAddressText({ address: unrequestedNative.clause })}, which the request did not hold`
343
- });
344
- }
345
- return {
346
- outcome: "ok",
347
- value: {
348
- mechanism: request.mechanism,
349
- hits: report.hits,
350
- nativeExceptions: report.nativeExceptions,
351
- coverableKinds: request.projectedKinds,
352
- projection: report.projection,
353
- slices: report.slices,
354
- unprojectedFolders: report.unprojectedFolders,
355
- measured: report.measured ?? NOTHING_MEASURED
356
- }
357
- };
358
- };
359
- var embeddedProjection = (request) => {
360
- const parsed = projectionWriteResultSchema.safeParse(request.returned);
361
- if (!parsed.success) {
362
- return runnerInvalidOutput({ detail: z5.prettifyError(parsed.error) });
363
- }
364
- if (parsed.data.outcome === "failed") {
365
- return parsed.data;
366
- }
367
- return parsed.data;
368
- };
369
- var runMechanismWithRecords = (request) => {
370
- switch (request.runner.exceptionPath) {
371
- case "standalone":
372
- return runMechanism({
373
- runner: request.runner,
374
- mechanism: request.mechanism,
375
- run: request.run
376
- });
377
- case "embedded": {
378
- const runner = request.runner;
379
- return Promise.resolve().then(
380
- () => runner.run({
381
- ...request.run,
382
- declaredConfigRoots: request.declaredConfigRoots,
383
- records: request.records
384
- })
385
- ).then(
386
- (returned) => embeddedRun({
387
- returned,
388
- mechanism: request.mechanism,
389
- projectedKinds: runner.projectedKinds,
390
- run: request.run
391
- }),
392
- (thrown) => rejectedCall({ thrown })
393
- );
394
- }
395
- }
396
- };
397
- var projectMechanism = (request) => {
398
- switch (request.runner.exceptionPath) {
399
- case "standalone": {
400
- return Promise.resolve({ outcome: "ok", value: [] });
401
- }
402
- case "embedded": {
403
- const runner = request.runner;
404
- return Promise.resolve().then(() => runner.project(request.request)).then(
405
- (returned) => embeddedProjection({ returned }),
406
- (thrown) => rejectedCall({ thrown })
407
- );
408
- }
409
- }
410
- };
411
-
412
- // src/infrastructure/engines/protocol/engine-run/engine-run.ts
413
- import { z as z8 } from "zod";
414
-
415
- // src/domain/language-layer/reported-checks.ts
416
- var unheldCheckFailure = (request) => ({
417
- kind: "runner-invalid-output",
418
- detail: `the report names the check ${request.address} of ${clauseAddressText({ address: request.reported.clause })}, which that clause does not have`
419
- });
420
- var reportedChecksRefusal = (request) => {
421
- const [first] = request.reported.flatMap((reported) => {
422
- const named = checkNamedAt({
423
- catalogue: request.catalogue,
424
- clause: reported.clause,
425
- address: reported.check
426
- });
427
- return named.named === "not-of-the-clause" ? [unheldCheckFailure({ reported, address: named.address })] : [];
428
- });
429
- return first === void 0 ? { outcome: "ok", value: void 0 } : { outcome: "failed", error: first };
430
- };
431
-
432
- // src/infrastructure/engines/protocol/checks/checks-runner-module-schema.ts
433
- import { z as z7 } from "zod";
434
-
435
- // src/infrastructure/engines/protocol/runner-module/runner-module-schema.ts
436
- import { z as z6 } from "zod";
437
- var runnerCallSchema = z6.function({
438
- input: [z6.unknown()],
439
- output: z6.promise(z6.unknown())
440
- });
441
- var standaloneRunnerModuleSchema = z6.object({
442
- exceptionPath: z6.literal("standalone"),
443
- run: runnerCallSchema,
444
- conform: runnerCallSchema
445
- });
446
- var embeddedRunnerModuleSchema = z6.object({
447
- exceptionPath: z6.literal("embedded"),
448
- projectedKinds: z6.array(nativeExceptionKindSchema),
449
- run: runnerCallSchema,
450
- conform: runnerCallSchema,
451
- project: runnerCallSchema
452
- });
453
- var runnerModuleSchema = z6.discriminatedUnion("exceptionPath", [
454
- standaloneRunnerModuleSchema,
455
- embeddedRunnerModuleSchema
456
- ]);
457
-
458
- // src/infrastructure/engines/protocol/checks/checks-runner-module-schema.ts
459
- var checksRunnerModuleSchema = z7.object({
460
- projectedKinds: z7.array(nativeExceptionKindSchema),
461
- run: runnerCallSchema,
462
- conform: runnerCallSchema,
463
- project: runnerCallSchema
464
- });
465
- var misnamedDirectiveShape = {
466
- ruleId: z7.string().min(1),
467
- file: repoPathSchema,
468
- line: z7.number().int().min(1),
469
- text: z7.string()
470
- };
471
- var misnamedRuleIdSchema = z7.discriminatedUnion("kind", [
472
- z7.strictObject({ kind: z7.literal("names-no-check"), ...misnamedDirectiveShape }).readonly(),
473
- z7.strictObject({
474
- kind: z7.literal("version-1-id"),
475
- ...misnamedDirectiveShape,
476
- replacedBy: z7.tuple([z7.string().min(1)], z7.string().min(1)).readonly()
477
- }).readonly()
478
- ]);
479
- var checksSliceProblemSchema = z7.object({
480
- slice: repoPathSchema,
481
- state: z7.enum(["missing", "out-of-date", "unconfigured"])
482
- }).readonly();
483
- var checksRunReportSchema = z7.object({
484
- hits: z7.array(hitSchema).readonly(),
485
- nativeExceptions: z7.array(nativeExceptionSchema).readonly(),
486
- measured: z7.array(measuredPairSchema).readonly(),
487
- projection: z7.enum(["current", "out-of-date", "missing", "not-included"]),
488
- slices: z7.array(checksSliceProblemSchema).readonly(),
489
- misnamedRuleIds: z7.array(misnamedRuleIdSchema).readonly()
490
- }).readonly();
491
- var notReadyYetFailureSchema = z7.object({
492
- kind: z7.literal("not-ready-yet"),
493
- what: z7.object({
494
- thing: z7.literal("eslint-config-roots"),
495
- paths: z7.array(z7.string()).min(1).readonly()
496
- }).readonly()
497
- }).readonly();
498
- var checksRunResultSchema = z7.union([
499
- z7.object({ outcome: z7.literal("ok"), value: checksRunReportSchema }).readonly(),
500
- z7.object({
501
- outcome: z7.literal("failed"),
502
- error: z7.union([runnerFailureSchema, notReadyYetFailureSchema])
503
- }).readonly()
504
- ]);
505
- var projectedFileSchema = z7.object({ file: repoPathSchema, text: z7.string() }).readonly();
506
- var checksProjectResultSchema = z7.union([
507
- z7.object({ outcome: z7.literal("ok"), value: z7.array(projectedFileSchema).readonly() }).readonly(),
508
- z7.object({
509
- outcome: z7.literal("failed"),
510
- error: z7.union([runnerFailureSchema, notReadyYetFailureSchema])
511
- }).readonly()
512
- ]);
513
-
514
- // src/infrastructure/engines/protocol/engine-run/engine-run.ts
515
- var TYPESCRIPT_RUNNER_MODULE = z8.object({
516
- runner: runnerModuleSchema,
517
- checksRunner: checksRunnerModuleSchema.optional()
518
- });
519
- var NO_CHECKS_RUNNER_DETAIL = "the runner module exports no checksRunner, which a version 2 run needs of an engine that runs through a native tool";
520
- var invalid = (request) => ({
521
- outcome: "failed",
522
- error: { kind: "runner-invalid", mechanism: request.mechanism, detail: request.detail }
523
- });
524
- var runnerFailed = (request) => ({
525
- outcome: "failed",
526
- error: { kind: "runner-failed", mechanism: request.mechanism, failure: request.failure }
527
- });
528
- var loadedEngineOf = async (request) => {
529
- const loaded = await request.modules.load({
530
- path: request.path.join({
531
- segments: runnerModuleSegmentsOf({
532
- installRoot: request.installRoot,
533
- mechanism: request.mechanism,
534
- moduleExtension: request.moduleExtension
535
- })
536
- })
537
- });
538
- if (loaded.outcome === "failed") {
539
- return invalid({ mechanism: request.mechanism, detail: loaded.error.detail });
540
- }
541
- const parsed = TYPESCRIPT_RUNNER_MODULE.safeParse(loaded.value);
542
- return parsed.success ? {
543
- outcome: "ok",
544
- value: {
545
- mechanism: request.mechanism,
546
- runner: parsed.data.runner,
547
- checksRunner: parsed.data.checksRunner
548
- }
549
- } : invalid({ mechanism: request.mechanism, detail: z8.prettifyError(parsed.error) });
550
- };
551
- var clausesOf = (request) => request.request.bindings.filter((binding) => binding.mechanism === request.mechanism).map((binding) => binding.clause);
552
- var standaloneRunOf = async (request) => {
553
- const ran = await runMechanism({
554
- runner: request.runner,
555
- mechanism: request.mechanism,
556
- run: {
557
- repoRoot: request.run.repoRoot,
558
- installRoot: request.run.installRoot,
559
- files: request.run.files,
560
- trackedPaths: request.run.trackedPaths,
561
- clauses: clausesOf({ request: request.run, mechanism: request.mechanism })
562
- }
563
- });
564
- return ran.outcome === "failed" ? runnerFailed({ mechanism: request.mechanism, failure: ran.error }) : { outcome: "ok", value: { ...ran.value, slices: [], misnamedRuleIds: [] } };
565
- };
566
- var invalidReport = (request) => {
567
- const held = requestHeldOf({
568
- files: request.run.files,
569
- clauses: clausesOf({ request: request.run, mechanism: request.mechanism }).map(
570
- (clause) => clause.address
571
- )
572
- });
573
- return [
574
- ...unrequestedDetailOf({ noun: "a hit", entries: request.report.hits, held }),
575
- ...unrequestedDetailOf({ noun: "a measured pair", entries: request.report.measured, held }),
576
- ...unrequestedClauseDetailOf({
577
- noun: "a native exception",
578
- entries: request.report.nativeExceptions,
579
- held
580
- })
581
- ];
582
- };
583
- var engineRunOfReport = (request) => {
584
- const [unrequested] = invalidReport(request);
585
- if (unrequested !== void 0) {
586
- return runnerFailed({
587
- mechanism: request.mechanism,
588
- failure: runnerInvalidOutput({ detail: unrequested }).error
589
- });
590
- }
591
- const refusal = reportedChecksRefusal({
592
- catalogue: { checks: request.run.checks },
593
- reported: [...request.report.hits, ...request.report.nativeExceptions]
594
- });
595
- if (refusal.outcome === "failed") {
596
- return runnerFailed({ mechanism: request.mechanism, failure: refusal.error });
597
- }
598
- return {
599
- outcome: "ok",
600
- value: {
601
- mechanism: request.mechanism,
602
- hits: request.report.hits,
603
- nativeExceptions: request.report.nativeExceptions,
604
- coverableKinds: request.projectedKinds,
605
- projection: request.report.projection,
606
- slices: request.report.slices,
607
- unprojectedFolders: [],
608
- measured: request.report.measured,
609
- misnamedRuleIds: request.report.misnamedRuleIds
610
- }
611
- };
612
- };
613
- var returnedBy = (request) => Promise.resolve().then(request.call).catch((thrown) => ({ outcome: "failed", error: rejectedCall({ thrown }).error }));
614
- var invalidChecksOutput = (request) => runnerFailed({
615
- mechanism: request.mechanism,
616
- failure: runnerInvalidOutput({ detail: z8.prettifyError(request.error) }).error
617
- });
618
- var failedChecksCall = (request) => request.error.kind === "not-ready-yet" ? { outcome: "failed", error: request.error } : runnerFailed({ mechanism: request.mechanism, failure: request.error });
619
- var checksRunOf = async (request) => {
620
- const parsed = checksRunResultSchema.safeParse(
621
- await returnedBy({ call: () => request.checksRunner.run(request.run) })
622
- );
623
- if (!parsed.success) {
624
- return invalidChecksOutput({ mechanism: request.mechanism, error: parsed.error });
625
- }
626
- if (parsed.data.outcome === "failed") {
627
- return failedChecksCall({ mechanism: request.mechanism, error: parsed.data.error });
628
- }
629
- return engineRunOfReport({
630
- report: parsed.data.value,
631
- run: request.run,
632
- mechanism: request.mechanism,
633
- projectedKinds: request.checksRunner.projectedKinds
634
- });
635
- };
636
- var checksProjectionOf = async (request) => {
637
- const parsed = checksProjectResultSchema.safeParse(
638
- await returnedBy({ call: () => request.checksRunner.project(request.run) })
639
- );
640
- if (!parsed.success) {
641
- return invalidChecksOutput({ mechanism: request.mechanism, error: parsed.error });
642
- }
643
- return parsed.data.outcome === "failed" ? failedChecksCall({ mechanism: request.mechanism, error: parsed.data.error }) : parsed.data;
644
- };
645
- var engineRunOf = (request) => {
646
- const { engine } = request;
647
- if (engine.runner.exceptionPath === "standalone") {
648
- return standaloneRunOf({
649
- runner: engine.runner,
650
- mechanism: engine.mechanism,
651
- run: request.request
652
- });
653
- }
654
- return engine.checksRunner === void 0 ? Promise.resolve(invalid({ mechanism: engine.mechanism, detail: NO_CHECKS_RUNNER_DETAIL })) : checksRunOf({
655
- checksRunner: engine.checksRunner,
656
- mechanism: engine.mechanism,
657
- run: request.request
658
- });
659
- };
660
- var engineProjectionOf = (request) => {
661
- const { engine } = request;
662
- if (engine.runner.exceptionPath === "standalone") {
663
- return Promise.resolve({ outcome: "ok", value: [] });
664
- }
665
- return engine.checksRunner === void 0 ? Promise.resolve(invalid({ mechanism: engine.mechanism, detail: NO_CHECKS_RUNNER_DETAIL })) : checksProjectionOf({
666
- checksRunner: engine.checksRunner,
667
- mechanism: engine.mechanism,
668
- run: request.request
669
- });
670
- };
671
-
672
- // src/infrastructure/engines/protocol/engine-port.ts
673
- var createDefaultEnginePort = (_options) => ({
674
- load: loadedEngineOf,
675
- run: { checks: engineRunOf, withRecords: runMechanismWithRecords },
676
- project: { checks: engineProjectionOf, withRecords: projectMechanism },
677
- conform: checkConformance
678
- });
679
-
680
- // src/domain/settings/clause-settings/default-clause-settings.ts
681
- var defaultClauseSettings = (request) => Object.fromEntries(
682
- Object.entries(request.declarations).map(([key, declaration]) => [key, declaration.default])
683
- );
684
-
685
- // src/infrastructure/content-files/rule-sets/install-discipline.ts
686
- import { z as z9 } from "zod";
687
- var MECHANISMS = ENGINE_REGISTRY.map((engine) => engine.name);
688
- var ruleSetInvalid = (request) => ({
689
- outcome: "failed",
690
- error: { kind: "rule-set-invalid", path: request.path, detail: request.detail }
691
- });
692
- var casesOf = (request) => {
693
- const path = request.examplesPaths.find(
694
- (path2) => request.fileText.exists({ path: path2 }) === "present"
695
- );
696
- if (path === void 0) {
697
- return ruleSetInvalid({
698
- path: request.namesPath,
699
- detail: `no piece that runs ${request.address} holds its examples`
700
- });
701
- }
702
- const document = readVersionOneJson({ fileText: request.fileText, path });
703
- if (document.outcome === "failed") {
704
- return document;
705
- }
706
- const cases = clauseCasesSchema.safeParse(document.value);
707
- return cases.success ? { outcome: "ok", value: cases.data } : ruleSetInvalid({ path, detail: z9.prettifyError(cases.error) });
708
- };
709
- var definitionOf = (request) => {
710
- const { named } = request;
711
- if (named.kind === "judgement") {
712
- return {
713
- outcome: "ok",
714
- value: { kind: "judgement", id: named.clause.clause, enforcedBy: "review" }
715
- };
716
- }
717
- const running = installedPiecesFor({ ...request, clause: named.clause, mechanisms: MECHANISMS });
718
- if (running.outcome === "failed") {
719
- return running;
720
- }
721
- const address = `${request.discipline}#${named.clause.clause}`;
722
- if (running.value.length === 0) {
723
- return ruleSetInvalid({ path: request.namesPath, detail: `no piece runs ${address}` });
724
- }
725
- const cases = casesOf({
726
- ...request,
727
- address,
728
- examplesPaths: running.value.map((piece) => piece.examplesPath)
729
- });
730
- return cases.outcome === "failed" ? cases : {
731
- outcome: "ok",
732
- value: {
733
- kind: "mechanical",
734
- id: named.clause.clause,
735
- mechanisms: running.value.map((piece) => piece.mechanism),
736
- anchor: named.anchor,
737
- exceptions: "allowed",
738
- cases: cases.value
739
- }
740
- };
741
- };
742
- var readInstallDiscipline = (request) => {
743
- const namesPath = installedNamesPathOf(request);
744
- const names = readInstalledNames(request);
745
- if (names.outcome === "failed") {
746
- return names;
747
- }
748
- const named = names.value.namedClauses.filter(
749
- (entry) => entry.clause.discipline === request.discipline
750
- );
751
- if (named.length === 0) {
752
- return { outcome: "ok", value: { held: "absent" } };
753
- }
754
- const clauses = everyOk({
755
- entries: named,
756
- resolve: (entry) => definitionOf({ ...request, named: entry, names: names.value, namesPath })
757
- });
758
- return clauses.outcome === "failed" ? clauses : {
759
- outcome: "ok",
760
- value: {
761
- held: "present",
762
- file: { version: 1, id: request.discipline, clauses: clauses.value }
763
- }
764
- };
765
- };
766
-
767
- // src/infrastructure/content-files/rule-sets/held-discipline.ts
768
- var readTeamDiscipline = (request) => {
769
- const path = disciplineFilePath(request);
770
- if (request.fileText.exists({ path }) === "absent") {
771
- return { outcome: "ok", value: { held: "absent" } };
772
- }
773
- const read = readDisciplineFile({
774
- fileText: request.fileText,
775
- path,
776
- discipline: request.discipline
777
- });
778
- return read.outcome === "failed" ? read : { outcome: "ok", value: { held: "present", file: read.value } };
779
- };
780
- var readHeldDiscipline = (request) => request.ruleSetRoot === request.installRoot ? readInstallDiscipline(request) : readTeamDiscipline(request);
781
-
782
- // src/infrastructure/content-files/rule-sets/located-piece-file.ts
783
- var readInstalledPieceFile = (request) => {
784
- const names = readInstalledNames(request);
785
- if (names.outcome === "failed") {
786
- return names;
787
- }
788
- const clauses = everyOk({
789
- entries: request.discipline.clauses.filter(
790
- (clause) => clause.kind === "mechanical" && clause.mechanisms.includes(request.mechanism)
791
- ),
792
- resolve: ({ id }) => {
793
- const installed = firstInstalledPieceFor({
794
- ...request,
795
- names: names.value,
796
- clause: { ruleSet: TOOL_RULE_SET, discipline: request.discipline.id, clause: id }
797
- });
798
- if (installed.outcome === "failed") {
799
- return installed;
800
- }
801
- if (installed.value === void 0) {
802
- return { outcome: "ok", value: void 0 };
803
- }
804
- const { pieceRoot, settings, declarations, editions } = installed.value.piece;
805
- return {
806
- outcome: "ok",
807
- value: { clause: id, pieceRoot, settings, clauseSettings: declarations, editions }
808
- };
809
- }
810
- });
811
- return clauses.outcome === "failed" ? clauses : {
812
- outcome: "ok",
813
- value: {
814
- version: 1,
815
- discipline: request.discipline.id,
816
- mechanism: request.mechanism,
817
- clauses: clauses.value.filter((entry) => entry !== void 0)
818
- }
819
- };
820
- };
821
- var readLocatedPieceFile = (request) => {
822
- if (request.ruleSetRoot === request.installRoot) {
823
- return readInstalledPieceFile(request);
824
- }
825
- const read = readPieceFile(request);
826
- if (read.outcome === "failed") {
827
- return read;
828
- }
829
- const pieceRoot = request.path.join({
830
- segments: pieceFolderSegmentsOf({ ...request, discipline: request.discipline.id })
831
- });
832
- return {
833
- outcome: "ok",
834
- value: { ...read.value, clauses: read.value.clauses.map((entry) => ({ ...entry, pieceRoot })) }
835
- };
836
- };
837
-
838
- export {
839
- createDefaultEnginePort,
840
- defaultClauseSettings,
841
- readHeldDiscipline,
842
- readLocatedPieceFile
843
- };