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

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 (135) hide show
  1. package/ADOPTING.md +10 -19
  2. package/CHANGELOG.md +46 -0
  3. package/MIGRATING.md +25 -14
  4. package/README.md +3 -4
  5. package/chunks/chunk-2U5EKYGS.js +14348 -0
  6. package/chunks/{chunk-FPIP7JEC.js → chunk-4AJQHZ7I.js} +1 -1
  7. package/chunks/chunk-4PHKVNM3.js +2377 -0
  8. package/chunks/{chunk-CXM5KBZX.js → chunk-6LTJRJOE.js} +1 -1
  9. package/chunks/{chunk-PVSC4SE3.js → chunk-BISP2JOL.js} +4 -6
  10. package/chunks/{chunk-BRANVR7K.js → chunk-FRE5IA3C.js} +1 -1
  11. package/chunks/{chunk-E4D5WDRX.js → chunk-GMLT3MHO.js} +252 -254
  12. package/chunks/chunk-M4VSJ27S.js +139 -0
  13. package/chunks/{chunk-YGMO5Z6U.js → chunk-P2VHWLK4.js} +182 -193
  14. package/chunks/{chunk-LD766VWU.js → chunk-U6W65ZOF.js} +31 -2
  15. package/chunks/{chunk-BKQ3K766.js → chunk-WPEOCLTP.js} +39 -33
  16. package/chunks/{chunk-A3RL4O5V.js → chunk-XNIXPQQ5.js} +35 -2
  17. package/docs/extending.md +2 -2
  18. package/methods/lenses/function-first.md +2 -2
  19. package/package.json +1 -1
  20. package/rules/README.md +5 -3
  21. package/rules/SPIRIT.md +1 -1
  22. package/rules/numbers.md +4 -4
  23. package/rules/principles/no-leak-across-a-boundary.md +1 -1
  24. package/rules/principles.md +1 -1
  25. package/rules/record-kinds/authorised-location.md +1 -1
  26. package/rules/records.md +11 -19
  27. package/rules/rules.md +5 -5
  28. package/rules/sources.md +6 -7
  29. package/rules/typescript/checks.md +55 -387
  30. package/rules/typescript/recipes/adapter-per-outside-party.md +10 -5
  31. package/rules/typescript/recipes/assert-to-narrow.md +114 -4
  32. package/rules/typescript/recipes/closure-factory.md +5 -5
  33. package/rules/typescript/recipes/companion-test-file.md +5 -3
  34. package/rules/typescript/recipes/composed-orchestrator.md +6 -4
  35. package/rules/typescript/recipes/composition-root.md +5 -3
  36. package/rules/typescript/recipes/{bounded-context-generic.md → constrained-context-generic.md} +6 -4
  37. package/rules/typescript/recipes/copy-never-write-in.md +6 -4
  38. package/rules/typescript/recipes/declared-not-bundled.md +5 -3
  39. package/rules/typescript/recipes/dependency-record.md +5 -3
  40. package/rules/typescript/recipes/domain-vocabulary-list.md +5 -3
  41. package/rules/typescript/recipes/entity-module.md +8 -5
  42. package/rules/typescript/recipes/exact-pins-and-a-lock-file.md +5 -3
  43. package/rules/typescript/recipes/extension-outside-the-vendored-code.md +5 -3
  44. package/rules/typescript/recipes/failure-asserted-as-a-value.md +44 -4
  45. package/rules/typescript/recipes/failure-mapping-at-the-adapter.md +8 -5
  46. package/rules/typescript/recipes/fix-the-declaration-not-the-value.md +5 -3
  47. package/rules/typescript/recipes/functional-iteration.md +8 -3
  48. package/rules/typescript/recipes/guard-clauses.md +5 -3
  49. package/rules/typescript/recipes/integration-test-owns-its-scratch.md +5 -3
  50. package/rules/typescript/recipes/integration-test-suffix.md +5 -3
  51. package/rules/typescript/recipes/it-each-over-typed-rows.md +117 -0
  52. package/rules/typescript/recipes/map-out-at-the-adapter.md +36 -4
  53. package/rules/typescript/recipes/meaning-in-names-not-comments.md +5 -5
  54. package/rules/typescript/recipes/named-exported-type.md +5 -3
  55. package/rules/typescript/recipes/narrow-ports.md +5 -3
  56. package/rules/typescript/recipes/one-argument-object.md +8 -3
  57. package/rules/typescript/recipes/{port-in-the-domain.md → port-in-a-module-of-its-own.md} +7 -5
  58. package/rules/typescript/recipes/ports-in-the-argument.md +5 -3
  59. package/rules/typescript/recipes/repo-scripts-only.md +5 -3
  60. package/rules/typescript/recipes/result-union.md +5 -5
  61. package/rules/typescript/recipes/screaming-folders.md +5 -5
  62. package/rules/typescript/recipes/shared-strict-base-config.md +5 -5
  63. package/rules/typescript/recipes/stub-with-vi-fn.md +130 -0
  64. package/rules/typescript/recipes/tagged-union-and-exhaustive-switch.md +5 -3
  65. package/rules/typescript/recipes/whole-words.md +5 -3
  66. package/rules/typescript/recipes/whole-written-out-expectation.md +284 -4
  67. package/rules/typescript/recipes/world-values-through-a-port.md +5 -3
  68. package/rules/typescript/recipes/zod-at-the-producers-adapter.md +8 -3
  69. package/rules/typescript/recipes.md +567 -21
  70. package/rules/typescript/symptoms/ambient-randomness.md +1 -1
  71. package/rules/typescript/symptoms/answer-set-in-a-hook.md +1 -1
  72. package/rules/typescript/symptoms/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site.md +1 -1
  73. package/rules/typescript/symptoms/{assertion-outside-a-test.md → assertion-outside-a-test-body.md} +1 -1
  74. package/rules/typescript/symptoms/branch-in-a-test/test-body.md +10 -184
  75. package/rules/typescript/symptoms/branch-in-a-test.md +11 -1
  76. package/rules/typescript/symptoms/claimed-type/non-null-assertions.md +1 -1
  77. package/rules/typescript/symptoms/{code-or-prose-read-as-text.md → code-or-prose-read-as-text-in-a-test.md} +2 -2
  78. package/rules/typescript/symptoms/computed-value-in-a-test/test-body.md +26 -117
  79. package/rules/typescript/symptoms/computed-value-in-a-test.md +1 -1
  80. package/rules/typescript/symptoms/date-used-directly.md +1 -1
  81. package/rules/typescript/symptoms/default-for-a-required-value.md +1 -1
  82. package/rules/typescript/symptoms/double-with-a-body/logic-in-a-passed-function.md +1 -18
  83. package/rules/typescript/symptoms/double-with-a-body.md +1 -1
  84. package/rules/typescript/symptoms/{export-from-a-test-file.md → export-from-a-test.md} +1 -1
  85. package/rules/typescript/symptoms/failure-shaped-as-success.md +1 -1
  86. package/rules/typescript/symptoms/inherited-environment-in-a-subprocess/git-spawn-environment.md +1 -1
  87. package/rules/typescript/symptoms/inner-layer-imports-outer.md +1 -1
  88. package/rules/typescript/symptoms/library-class-built-in-place.md +1 -1
  89. package/rules/typescript/symptoms/loop-keyword/loop-statement.md +1 -1
  90. package/rules/typescript/symptoms/outside-import-past-a-boundary/import-or-require.md +1 -0
  91. package/rules/typescript/symptoms/outside-import-past-a-boundary.md +5 -4
  92. package/rules/typescript/symptoms/outside-type-in-a-signature.md +2 -2
  93. package/rules/typescript/symptoms/{port-outside-the-domain.md → port-beside-its-adapter.md} +2 -2
  94. package/rules/typescript/symptoms/port-named-for-a-mechanism.md +1 -1
  95. package/rules/typescript/symptoms/process-global-used-in-place.md +1 -1
  96. package/rules/typescript/symptoms/rebinding/test-body.md +1 -18
  97. package/rules/typescript/symptoms/rebinding.md +11 -1
  98. package/rules/typescript/symptoms/schema-past-its-adapter.md +2 -2
  99. package/rules/typescript/symptoms/text-past-its-reader/test-body.md +2 -17
  100. package/rules/typescript/symptoms/text-past-its-reader.md +1 -1
  101. package/rules/typescript/symptoms/throw-or-catch-in-a-test/try-block.md +1 -25
  102. package/rules/typescript/symptoms/type-declared-in-a-test/test-type-declaration.md +1 -1
  103. package/rules/typescript/symptoms/unasserted-call.md +1 -1
  104. package/rules/typescript/symptoms.md +35 -35
  105. package/src/application/conformance/conformance-testing-types.d.ts +2 -0
  106. package/src/domain/language-layer/authored-item-types.d.ts +21 -5
  107. package/src/domain/runner/runner-result-types.d.ts +1 -2
  108. package/src/eslint-plugin.js +40 -38
  109. package/src/hone.js +15 -13638
  110. package/src/infrastructure/disciplines-file/version-one-names.json +4 -5
  111. package/src/infrastructure/engines/eslint/runner/runner.js +56 -70
  112. package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/assertion-site.js +1 -1
  113. package/src/infrastructure/engines/walker/branch-in-a-test/test-body/test-body-logic.js +39 -65
  114. package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/raw-read.js +1 -1
  115. package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/test-file-export.js +1 -1
  116. package/src/infrastructure/engines/walker/runner/runner.js +10 -10
  117. package/src/infrastructure/engines/walker/strictness-weakened/strict/compiler-overrides.js +3 -3
  118. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.examples.json +15 -3
  119. package/src/infrastructure/engines/walker/type-declared-in-a-test/test-type-declaration/test-type-declaration.js +118 -4
  120. package/src/measure-engines.process.js +80 -0
  121. package/src/testing.d.ts +1 -0
  122. package/src/testing.js +111 -26
  123. package/chunks/chunk-7FVSZ2VL.js +0 -1304
  124. package/chunks/chunk-BIDD2YWP.js +0 -398
  125. package/rules/record-kinds/boundary-record.md +0 -9
  126. package/rules/typescript/recipes/iteach-over-typed-rows.md +0 -18
  127. package/rules/typescript/recipes/stub-with-vifn.md +0 -20
  128. /package/rules/typescript/symptoms/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read.md +0 -0
  129. /package/rules/typescript/symptoms/{export-from-a-test-file → export-from-a-test}/test-file-export.md +0 -0
  130. /package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/assertion-site.examples.json +0 -0
  131. /package/src/infrastructure/engines/walker/{assertion-outside-a-test → assertion-outside-a-test-body}/assertion-site/piece.json +0 -0
  132. /package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/piece.json +0 -0
  133. /package/src/infrastructure/engines/walker/{code-or-prose-read-as-text → code-or-prose-read-as-text-in-a-test}/raw-read/raw-read.examples.json +0 -0
  134. /package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/piece.json +0 -0
  135. /package/src/infrastructure/engines/walker/{export-from-a-test-file → export-from-a-test}/test-file-export/test-file-export.examples.json +0 -0
@@ -0,0 +1,139 @@
1
+ import {
2
+ ownedNameText
3
+ } from "./chunk-4AJQHZ7I.js";
4
+ import {
5
+ checkAddressTextOf
6
+ } from "./chunk-WPEOCLTP.js";
7
+
8
+ // src/domain/repository/exclusion.ts
9
+ var exclusionOf = (request) => request.excluded.some(
10
+ (excludedPath) => request.path === excludedPath || request.path.startsWith(`${excludedPath}/`)
11
+ ) ? "excluded" : "checked";
12
+
13
+ // src/domain/records/answering/records-by-place.ts
14
+ var symptomKey = (request) => `symptom:${ownedNameText(request.symptom)}`;
15
+ var addressKey = (request) => `check:${ownedNameText(request.address)}`;
16
+ var checkKey = (request) => addressKey({
17
+ address: {
18
+ ruleSet: request.symptom.ruleSet,
19
+ name: checkAddressTextOf({ check: { name: request.check, symptom: request.symptom } })
20
+ }
21
+ });
22
+ var answeredByPlaceOf = (request) => new Map(
23
+ [...Map.groupBy(request.answered, ({ file }) => file)].map(([file, answers]) => [
24
+ file,
25
+ new Set(
26
+ answers.map(
27
+ ({ ruleSet, symptom, check }) => check === void 0 ? symptomKey({ symptom: { ruleSet, name: symptom } }) : checkKey({ symptom: { ruleSet, name: symptom }, check })
28
+ )
29
+ )
30
+ ])
31
+ );
32
+ var answeredAt = (request) => {
33
+ const answers = request.byPlace.get(request.file);
34
+ const { ruleSet } = request;
35
+ return answers !== void 0 && (answers.has(symptomKey({ symptom: { ruleSet, name: request.symptom } })) || answers.has(addressKey({ address: { ruleSet, name: request.address } }))) ? "holds" : "does-not-hold";
36
+ };
37
+ var recipeKey = (request) => `recipe:${ownedNameText(request.recipe)}`;
38
+ var symptomReachKeysOf = (request) => {
39
+ const { symptom, reach } = request;
40
+ switch (reach.reaches) {
41
+ case "whole-symptom":
42
+ return [symptomKey({ symptom })];
43
+ case "one-check":
44
+ return [checkKey({ symptom, check: reach.check.name })];
45
+ case "unknown-check":
46
+ return [];
47
+ }
48
+ };
49
+ var reachKeysOf = (request) => {
50
+ const { record } = request;
51
+ switch (record.kind) {
52
+ case "debt":
53
+ case "authorised-location":
54
+ return symptomReachKeysOf({ symptom: record.symptom, reach: record.reach });
55
+ case "deviation":
56
+ return [recipeKey({ recipe: record.recipe })];
57
+ case "dependency-record":
58
+ return [];
59
+ }
60
+ };
61
+ var keyedOf = (request) => reachKeysOf({ record: request.placed.record }).map((key) => ({
62
+ placed: request.placed,
63
+ rank: request.rank,
64
+ path: request.path,
65
+ key
66
+ }));
67
+ var byPathAndKey = (request) => new Map(
68
+ [...Map.groupBy(request.keyed, ({ path }) => path)].map(([path, entries]) => [
69
+ path,
70
+ Map.groupBy(entries, ({ key }) => key)
71
+ ])
72
+ );
73
+ var recordsByPlaceOf = (request) => {
74
+ const inFile = request.records.flatMap((placed, rank) => {
75
+ const { record } = placed;
76
+ return record.kind === "debt" || record.kind === "authorised-location" || record.kind === "deviation" ? keyedOf({ placed, rank, path: record.file }) : [];
77
+ });
78
+ return {
79
+ ranks: new Map(request.records.map((placed, rank) => [placed, rank])),
80
+ inFile: byPathAndKey({ keyed: inFile })
81
+ };
82
+ };
83
+ var rankEntry = (request) => [
84
+ request.placed,
85
+ request.rank
86
+ ];
87
+ var inRankOrder = (request) => [...request.ranked].toSorted(([, left], [, right]) => left - right).map(([placed]) => placed);
88
+ var placedInRecordOrder = (request) => inRankOrder({
89
+ ranked: new Map(
90
+ [...request.records].flatMap((placed) => {
91
+ const rank = request.byPlace.ranks.get(placed);
92
+ return rank === void 0 ? [] : [rankEntry({ placed, rank })];
93
+ })
94
+ )
95
+ });
96
+ var siteKeysOf = (request) => {
97
+ const { symptom, check, recipes } = request.site;
98
+ return [
99
+ symptomKey({ symptom }),
100
+ ...check.found === "check" ? [checkKey({ symptom, check: check.check.name })] : [],
101
+ ...recipes.map((recipe) => recipeKey({ recipe }))
102
+ ];
103
+ };
104
+ var rankedAt = (request) => {
105
+ const byKey = request.byPath.get(request.path);
106
+ return byKey === void 0 ? [] : request.keys.flatMap((key) => byKey.get(key) ?? []);
107
+ };
108
+ var recordsReachingSites = (request) => inRankOrder({
109
+ ranked: new Map(
110
+ request.sites.flatMap((site) => {
111
+ const keys = siteKeysOf({ site });
112
+ return rankedAt({ byPath: request.byPlace.inFile, path: site.file, keys }).map(rankEntry);
113
+ })
114
+ )
115
+ });
116
+
117
+ // src/infrastructure/engines/eslint/eslint-config-lookup.ts
118
+ import { z } from "zod";
119
+ var eslintConfigLookupSchema = z.enum(["nearest-to-file", "repository-root"]);
120
+
121
+ // src/domain/repository/absolute-within.ts
122
+ var BACKSLASH = "\\";
123
+ var BACKSLASH_FORM = /^(?:[A-Za-z]:\\|\\\\)/;
124
+ var absoluteWithin = (request) => {
125
+ const separator = BACKSLASH_FORM.test(request.root) ? BACKSLASH : "/";
126
+ const root = request.root.endsWith(separator) ? request.root.slice(0, -1) : request.root;
127
+ return `${root}${separator}${request.file.replaceAll("/", separator)}`;
128
+ };
129
+
130
+ export {
131
+ exclusionOf,
132
+ answeredByPlaceOf,
133
+ answeredAt,
134
+ recordsByPlaceOf,
135
+ placedInRecordOrder,
136
+ recordsReachingSites,
137
+ eslintConfigLookupSchema,
138
+ absoluteWithin
139
+ };
@@ -1,25 +1,36 @@
1
1
  import {
2
- caseVerdictSchema,
3
2
  checkHitSchema,
4
3
  checkMeasurementSchema,
5
4
  checkNativeExceptionSchema,
6
5
  hitSchema,
7
6
  measuredSchema,
8
7
  nativeExceptionKindSchema,
8
+ projectionWriteSchema,
9
9
  reportedCheckSchema,
10
10
  runnerFailureSchema,
11
11
  runnerResultSchema
12
- } from "./chunk-PVSC4SE3.js";
12
+ } from "./chunk-BISP2JOL.js";
13
13
  import {
14
14
  clauseAddressObjectSchema
15
- } from "./chunk-BRANVR7K.js";
15
+ } from "./chunk-FRE5IA3C.js";
16
16
  import {
17
17
  repoPathSchema,
18
18
  runnerModuleSegmentsOf
19
- } from "./chunk-BKQ3K766.js";
19
+ } from "./chunk-WPEOCLTP.js";
20
20
 
21
- // src/infrastructure/engines/protocol/conformance.ts
22
- import { z } from "zod";
21
+ // src/infrastructure/engines/protocol/runner-module/runner-module-at.ts
22
+ var runnerModuleAt = (location) => location.modules.load({
23
+ path: location.path.join({
24
+ segments: runnerModuleSegmentsOf({
25
+ installRoot: location.installRoot,
26
+ mechanism: location.mechanism,
27
+ moduleExtension: location.moduleExtension
28
+ })
29
+ })
30
+ });
31
+
32
+ // src/infrastructure/engines/protocol/engine-run/engine-run.ts
33
+ import { z as z4 } from "zod";
23
34
 
24
35
  // src/domain/runner/runner-failure.ts
25
36
  var runnerInvalidOutput = (request) => ({
@@ -29,73 +40,6 @@ var runnerInvalidOutput = (request) => ({
29
40
  var thrownMessage = (request) => request.thrown instanceof Error ? request.thrown.message : String(request.thrown);
30
41
  var rejectedCall = (request) => runnerInvalidOutput({ detail: `the runner call threw or rejected: ${thrownMessage(request)}` });
31
42
 
32
- // src/infrastructure/engines/protocol/conformance.ts
33
- var caseVerdictsResultSchema = runnerResultSchema({
34
- value: z.array(caseVerdictSchema).readonly()
35
- });
36
- var lineSet = (request) => [...new Set(request.lines)].toSorted((left, right) => left - right);
37
- var verdictsNaming = (request) => request.verdicts.filter((verdict) => verdict.caseName === request.caseName);
38
- var unmatchedVerdict = (request) => {
39
- const missing = request.cases.find(
40
- (sourceCase) => verdictsNaming({ verdicts: request.verdicts, caseName: sourceCase.name }).length !== 1
41
- );
42
- if (missing !== void 0) {
43
- return `case ${missing.name} has no single verdict`;
44
- }
45
- const unknown = request.verdicts.find(
46
- (verdict) => !request.cases.some((sourceCase) => sourceCase.name === verdict.caseName)
47
- );
48
- return unknown === void 0 ? void 0 : `a verdict names the unknown case ${unknown.caseName}`;
49
- };
50
- var caseConformance = (request) => {
51
- const { sourceCase } = request;
52
- const expectedLines = lineSet({ lines: sourceCase.expectedLines });
53
- const flaggedLines = lineSet({
54
- lines: verdictsNaming({ verdicts: request.verdicts, caseName: sourceCase.name }).flatMap(
55
- (verdict) => verdict.flaggedLines
56
- )
57
- });
58
- if (expectedLines.join(" ") === flaggedLines.join(" ")) {
59
- return [];
60
- }
61
- return [{ caseName: sourceCase.name, expectedLines, flaggedLines }];
62
- };
63
- var conformanceOf = (request) => {
64
- const parsed = caseVerdictsResultSchema.safeParse(request.returned);
65
- if (!parsed.success) {
66
- return runnerInvalidOutput({ detail: z.prettifyError(parsed.error) });
67
- }
68
- if (parsed.data.outcome === "failed") {
69
- return parsed.data;
70
- }
71
- const verdicts = parsed.data.value;
72
- const unmatched = unmatchedVerdict({ verdicts, cases: request.cases });
73
- if (unmatched !== void 0) {
74
- return runnerInvalidOutput({ detail: unmatched });
75
- }
76
- return {
77
- outcome: "ok",
78
- value: request.cases.flatMap((sourceCase) => caseConformance({ sourceCase, verdicts }))
79
- };
80
- };
81
- var compareCases = async (request) => Promise.resolve().then(request.act).then(
82
- (returned) => conformanceOf({ returned, cases: request.cases }),
83
- (thrown) => rejectedCall({ thrown })
84
- );
85
- var namedCheckConformance = async (request) => {
86
- const compared = await compareCases({
87
- ...request,
88
- act: () => request.runner.conform({ binding: request.binding, cases: request.cases })
89
- });
90
- return compared.outcome === "failed" ? compared : {
91
- outcome: "ok",
92
- value: compared.value.map((failure) => ({ ...failure, check: request.binding.address }))
93
- };
94
- };
95
-
96
- // src/infrastructure/engines/protocol/engine-run/engine-run.ts
97
- import { z as z5 } from "zod";
98
-
99
43
  // src/domain/runner/checked-observations.ts
100
44
  var unrequestedFileDetail = (request) => {
101
45
  const entry = request.entries.find(
@@ -113,73 +57,73 @@ var checkedObservations = (request) => {
113
57
  };
114
58
 
115
59
  // src/infrastructure/engines/protocol/checks/checks-runner-module-schema.ts
116
- import { z as z4 } from "zod";
60
+ import { z as z3 } from "zod";
117
61
 
118
62
  // src/infrastructure/engines/protocol/embedded/embedded-run-report-schema.ts
119
- import { z as z2 } from "zod";
63
+ import { z } from "zod";
120
64
  var namedCheck = { check: reportedCheckSchema.optional() };
121
- var inlineLineSchema = z2.number().int().min(1);
122
- var inlineDisableSchema = z2.object({
123
- kind: z2.literal("inline-disable"),
65
+ var inlineLineSchema = z.number().int().min(1);
66
+ var inlineDisableSchema = z.object({
67
+ kind: z.literal("inline-disable"),
124
68
  ...namedCheck,
125
69
  clause: clauseAddressObjectSchema,
126
70
  file: repoPathSchema,
127
71
  line: inlineLineSchema,
128
- text: z2.string(),
129
- reach: z2.enum(["one-clause", "every-selected-clause"])
72
+ text: z.string(),
73
+ reach: z.enum(["one-clause", "every-selected-clause"])
130
74
  }).readonly();
131
- var scriptOptionCauseSchema = z2.discriminatedUnion("kind", [
132
- z2.object({ kind: z2.literal("weakens-run") }).readonly(),
133
- z2.object({
134
- kind: z2.literal("after-another-command"),
135
- command: z2.string(),
136
- invocation: z2.string()
75
+ var scriptOptionCauseSchema = z.discriminatedUnion("kind", [
76
+ z.object({ kind: z.literal("weakens-run") }).readonly(),
77
+ z.object({
78
+ kind: z.literal("after-another-command"),
79
+ command: z.string(),
80
+ invocation: z.string()
137
81
  }).readonly(),
138
- z2.object({ kind: z2.literal("wrapped"), command: z2.string(), wrapper: z2.string() }).readonly(),
139
- z2.object({ kind: z2.literal("unreadable"), command: z2.string() }).readonly()
82
+ z.object({ kind: z.literal("wrapped"), command: z.string(), wrapper: z.string() }).readonly(),
83
+ z.object({ kind: z.literal("unreadable"), command: z.string() }).readonly()
140
84
  ]);
141
- var nativeExceptionSchema = z2.discriminatedUnion("kind", [
142
- z2.object({
143
- kind: z2.literal("ignore"),
85
+ var nativeExceptionSchema = z.discriminatedUnion("kind", [
86
+ z.object({
87
+ kind: z.literal("ignore"),
144
88
  ...namedCheck,
145
89
  clause: clauseAddressObjectSchema,
146
90
  file: repoPathSchema
147
91
  }).readonly(),
148
- z2.object({
149
- kind: z2.literal("config-override"),
92
+ z.object({
93
+ kind: z.literal("config-override"),
150
94
  ...namedCheck,
151
95
  clause: clauseAddressObjectSchema,
152
96
  file: repoPathSchema
153
97
  }).readonly(),
154
- z2.object({
155
- kind: z2.literal("suppression-entry"),
98
+ z.object({
99
+ kind: z.literal("suppression-entry"),
156
100
  ...namedCheck,
157
101
  clause: clauseAddressObjectSchema,
158
102
  file: repoPathSchema,
159
103
  location: repoPathSchema
160
104
  }).readonly(),
161
105
  inlineDisableSchema,
162
- z2.object({
163
- kind: z2.literal("inline-rule-config"),
106
+ z.object({
107
+ kind: z.literal("inline-rule-config"),
164
108
  ...namedCheck,
165
109
  clause: clauseAddressObjectSchema,
166
110
  file: repoPathSchema,
167
111
  line: inlineLineSchema,
168
- text: z2.string()
112
+ text: z.string()
169
113
  }).readonly(),
170
- z2.object({
171
- kind: z2.literal("command-line-option"),
114
+ z.object({
115
+ kind: z.literal("command-line-option"),
172
116
  ...namedCheck,
173
117
  clause: clauseAddressObjectSchema,
174
118
  location: repoPathSchema,
175
- script: z2.string(),
176
- option: z2.string(),
119
+ script: z.string(),
120
+ option: z.string(),
177
121
  cause: scriptOptionCauseSchema
178
122
  }).readonly()
179
123
  ]);
180
- var sliceProblemSchema = z2.object({
124
+ var sliceProblemSchema = z.object({
181
125
  slice: repoPathSchema,
182
- state: z2.enum([
126
+ state: z.enum([
183
127
  "out-of-date",
184
128
  "missing",
185
129
  "not-applied",
@@ -187,103 +131,103 @@ var sliceProblemSchema = z2.object({
187
131
  "nested-configuration"
188
132
  ])
189
133
  }).readonly();
190
- var unprojectedFolderSchema = z2.object({
134
+ var unprojectedFolderSchema = z.object({
191
135
  folder: repoPathSchema,
192
136
  selectionFolder: repoPathSchema
193
137
  }).readonly();
194
- var embeddedRunReportSchema = z2.object({
195
- hits: z2.array(hitSchema).readonly(),
196
- nativeExceptions: z2.array(nativeExceptionSchema).readonly(),
197
- projection: z2.enum(["current", "out-of-date", "missing", "not-included"]),
198
- slices: z2.array(sliceProblemSchema).readonly().default([]),
199
- unprojectedFolders: z2.array(unprojectedFolderSchema).readonly().default([]),
138
+ var embeddedRunReportSchema = z.object({
139
+ hits: z.array(hitSchema).readonly(),
140
+ nativeExceptions: z.array(nativeExceptionSchema).readonly(),
141
+ projection: z.enum(["current", "out-of-date", "missing", "not-included"]),
142
+ slices: z.array(sliceProblemSchema).readonly().default([]),
143
+ unprojectedFolders: z.array(unprojectedFolderSchema).readonly().default([]),
200
144
  measured: measuredSchema
201
145
  }).readonly();
202
146
 
203
147
  // src/infrastructure/engines/protocol/runner-module/runner-module-schema.ts
204
- import { z as z3 } from "zod";
205
- var runnerCallSchema = z3.function({
206
- input: [z3.unknown()],
207
- output: z3.promise(z3.unknown())
148
+ import { z as z2 } from "zod";
149
+ var runnerCallSchema = z2.function({
150
+ input: [z2.unknown()],
151
+ output: z2.promise(z2.unknown())
208
152
  });
209
- var standaloneRunnerModuleSchema = z3.object({
210
- exceptionPath: z3.literal("standalone"),
153
+ var standaloneRunnerModuleSchema = z2.object({
154
+ exceptionPath: z2.literal("standalone"),
211
155
  run: runnerCallSchema,
212
156
  conform: runnerCallSchema
213
157
  });
214
- var embeddedRunnerModuleSchema = z3.object({
215
- exceptionPath: z3.literal("embedded"),
216
- projectedKinds: z3.array(nativeExceptionKindSchema),
158
+ var embeddedRunnerModuleSchema = z2.object({
159
+ exceptionPath: z2.literal("embedded"),
160
+ projectedKinds: z2.array(nativeExceptionKindSchema),
217
161
  run: runnerCallSchema,
218
162
  conform: runnerCallSchema,
219
163
  project: runnerCallSchema
220
164
  });
221
- var runnerModuleSchema = z3.discriminatedUnion("exceptionPath", [
165
+ var runnerModuleSchema = z2.discriminatedUnion("exceptionPath", [
222
166
  standaloneRunnerModuleSchema,
223
167
  embeddedRunnerModuleSchema
224
168
  ]);
225
169
 
226
170
  // src/infrastructure/engines/protocol/checks/checks-runner-module-schema.ts
227
- var namedChecksRunnerModuleSchema = z4.object({
228
- projectedKinds: z4.array(nativeExceptionKindSchema),
229
- fileScope: z4.enum(["tracked", "typescript"]),
171
+ var namedChecksRunnerModuleSchema = z3.object({
172
+ projectedKinds: z3.array(nativeExceptionKindSchema),
173
+ fileScope: z3.enum(["tracked", "typescript"]),
230
174
  run: runnerCallSchema,
231
175
  conform: runnerCallSchema,
232
176
  project: runnerCallSchema
233
177
  });
234
178
  var misnamedDirectiveShape = {
235
- ruleId: z4.string().min(1),
179
+ ruleId: z3.string().min(1),
236
180
  file: repoPathSchema,
237
- line: z4.number().int().min(1),
238
- text: z4.string()
181
+ line: z3.number().int().min(1),
182
+ text: z3.string()
239
183
  };
240
- var misnamedRuleIdSchema = z4.discriminatedUnion("kind", [
241
- z4.strictObject({ kind: z4.literal("names-no-check"), ...misnamedDirectiveShape }).readonly(),
242
- z4.strictObject({
243
- kind: z4.literal("version-1-id"),
184
+ var misnamedRuleIdSchema = z3.discriminatedUnion("kind", [
185
+ z3.strictObject({ kind: z3.literal("names-no-check"), ...misnamedDirectiveShape }).readonly(),
186
+ z3.strictObject({
187
+ kind: z3.literal("version-1-id"),
244
188
  ...misnamedDirectiveShape,
245
- replacedBy: z4.tuple([z4.string().min(1)], z4.string().min(1)).readonly()
189
+ replacedBy: z3.tuple([z3.string().min(1)], z3.string().min(1)).readonly()
246
190
  }).readonly()
247
191
  ]);
248
- var checksSliceProblemSchema = z4.object({
192
+ var checksSliceProblemSchema = z3.object({
249
193
  slice: repoPathSchema,
250
- state: z4.enum(["missing", "out-of-date", "unconfigured"])
194
+ state: z3.enum(["missing", "out-of-date", "unconfigured"])
251
195
  }).readonly();
252
- var namedChecksRunReportSchema = z4.strictObject({
253
- slices: z4.array(checksSliceProblemSchema).readonly(),
254
- nestedConfigurations: z4.array(repoPathSchema).readonly(),
255
- unprojectedFolders: z4.array(unprojectedFolderSchema).readonly(),
256
- misnamedRuleIds: z4.array(misnamedRuleIdSchema).readonly(),
257
- hits: z4.array(checkHitSchema).readonly(),
258
- nativeExceptions: z4.array(checkNativeExceptionSchema).readonly(),
259
- measured: z4.array(checkMeasurementSchema).readonly(),
260
- projection: z4.enum(["none", "current", "out-of-date", "missing", "not-included"])
196
+ var namedChecksRunReportSchema = z3.strictObject({
197
+ slices: z3.array(checksSliceProblemSchema).readonly(),
198
+ nestedConfigurations: z3.array(repoPathSchema).readonly(),
199
+ unprojectedFolders: z3.array(unprojectedFolderSchema).readonly(),
200
+ misnamedRuleIds: z3.array(misnamedRuleIdSchema).readonly(),
201
+ hits: z3.array(checkHitSchema).readonly(),
202
+ nativeExceptions: z3.array(checkNativeExceptionSchema).readonly(),
203
+ measured: z3.array(checkMeasurementSchema).readonly(),
204
+ projection: z3.enum(["none", "current", "out-of-date", "missing", "not-included"])
261
205
  }).readonly();
262
- var namedChecksRunResultSchema = z4.discriminatedUnion("outcome", [
263
- z4.strictObject({ outcome: z4.literal("ok"), value: namedChecksRunReportSchema }).readonly(),
264
- z4.strictObject({
265
- outcome: z4.literal("failed"),
206
+ var namedChecksRunResultSchema = z3.discriminatedUnion("outcome", [
207
+ z3.strictObject({ outcome: z3.literal("ok"), value: namedChecksRunReportSchema }).readonly(),
208
+ z3.strictObject({
209
+ outcome: z3.literal("failed"),
266
210
  error: runnerFailureSchema
267
211
  }).readonly()
268
212
  ]);
269
- var measurementResultSchema = z4.discriminatedUnion("outcome", [
270
- z4.strictObject({
271
- outcome: z4.literal("ok"),
272
- value: z4.strictObject({
213
+ var measurementResultSchema = z3.discriminatedUnion("outcome", [
214
+ z3.strictObject({
215
+ outcome: z3.literal("ok"),
216
+ value: z3.strictObject({
273
217
  report: namedChecksRunReportSchema,
274
- unappliedSlices: z4.array(repoPathSchema).readonly()
218
+ unappliedSlices: z3.array(repoPathSchema).readonly()
275
219
  }).readonly()
276
220
  }).readonly(),
277
- z4.strictObject({
278
- outcome: z4.literal("failed"),
221
+ z3.strictObject({
222
+ outcome: z3.literal("failed"),
279
223
  error: runnerFailureSchema
280
224
  }).readonly()
281
225
  ]);
282
- var projectedFileSchema = z4.object({ file: repoPathSchema, text: z4.string() }).readonly();
283
- var checksProjectResultSchema = z4.union([
284
- z4.object({ outcome: z4.literal("ok"), value: z4.array(projectedFileSchema).readonly() }).readonly(),
285
- z4.object({
286
- outcome: z4.literal("failed"),
226
+ var projectedFileSchema = z3.object({ file: repoPathSchema, text: z3.string() }).readonly();
227
+ var checksProjectResultSchema = z3.union([
228
+ z3.object({ outcome: z3.literal("ok"), value: z3.array(projectedFileSchema).readonly() }).readonly(),
229
+ z3.object({
230
+ outcome: z3.literal("failed"),
287
231
  error: runnerFailureSchema
288
232
  }).readonly()
289
233
  ]);
@@ -297,27 +241,18 @@ var runnerFailed = (request) => ({
297
241
  outcome: "failed",
298
242
  error: { kind: "runner-failed", mechanism: request.mechanism, failure: request.failure }
299
243
  });
300
- var runnerModuleAt = (request) => request.modules.load({
301
- path: request.path.join({
302
- segments: runnerModuleSegmentsOf({
303
- installRoot: request.installRoot,
304
- mechanism: request.mechanism,
305
- moduleExtension: request.moduleExtension
306
- })
307
- })
308
- });
309
244
  var returnedBy = (request) => Promise.resolve().then(request.call).catch((thrown) => ({ outcome: "failed", error: rejectedCall({ thrown }).error }));
310
245
  var invalidChecksOutput = (request) => runnerFailed({
311
246
  mechanism: request.mechanism,
312
- failure: runnerInvalidOutput({ detail: z5.prettifyError(request.error) }).error
247
+ failure: runnerInvalidOutput({ detail: z4.prettifyError(request.error) }).error
313
248
  });
314
- var NAMED_RUNNER_MODULE = z5.object({ namedChecksRunner: namedChecksRunnerModuleSchema });
315
- var loadedNamedRunnerOf = async (request) => {
316
- const loaded = await runnerModuleAt(request);
249
+ var NAMED_RUNNER_MODULE = z4.object({ namedChecksRunner: namedChecksRunnerModuleSchema });
250
+ var loadedNamedRunnerOver = (ports) => async (request) => {
251
+ const loaded = await ports.runnerModuleOf(request);
317
252
  if (loaded.outcome === "failed")
318
253
  return invalid({ mechanism: request.mechanism, detail: loaded.error.detail });
319
254
  const parsed = NAMED_RUNNER_MODULE.safeParse(loaded.value);
320
- return parsed.success ? { outcome: "ok", value: parsed.data.namedChecksRunner } : invalid({ mechanism: request.mechanism, detail: z5.prettifyError(parsed.error) });
255
+ return parsed.success ? { outcome: "ok", value: parsed.data.namedChecksRunner } : invalid({ mechanism: request.mechanism, detail: z4.prettifyError(parsed.error) });
321
256
  };
322
257
  var namedRequestOf = (call) => ({
323
258
  ...call.request,
@@ -349,25 +284,22 @@ var namedEngineRunOf = async (call) => {
349
284
  }
350
285
  return verifiedNamedRun({ call, requested, report: parsed.data.value });
351
286
  };
352
- var versionOneMeasurementModuleSchema = z5.object({
287
+ var versionOneMeasurementModuleSchema = z4.object({
353
288
  measureVersionOne: runnerCallSchema.optional()
354
289
  });
355
290
  var measureNamedRun = async (call) => {
356
291
  const report = await namedEngineRunOf(call);
357
292
  return report.outcome === "failed" ? report : { outcome: "ok", value: { report: report.value, unappliedSlices: [] } };
358
293
  };
359
- var measureVersionOneProjection = async ({
360
- call,
361
- location,
362
- projection
363
- }) => {
294
+ var measuredVersionOne = async (request) => {
295
+ const { call, location, projection } = request;
364
296
  if (projection === void 0) return measureNamedRun(call);
365
- const loaded = await runnerModuleAt(location);
297
+ const loaded = await request.runnerModuleOf(location);
366
298
  if (loaded.outcome === "failed")
367
299
  return invalid({ mechanism: call.mechanism, detail: loaded.error.detail });
368
300
  const module = versionOneMeasurementModuleSchema.safeParse(loaded.value);
369
301
  if (!module.success)
370
- return invalid({ mechanism: call.mechanism, detail: z5.prettifyError(module.error) });
302
+ return invalid({ mechanism: call.mechanism, detail: z4.prettifyError(module.error) });
371
303
  const measureVersionOne = module.data.measureVersionOne;
372
304
  if (measureVersionOne === void 0) return measureNamedRun(call);
373
305
  const requested = namedRequestOf(call);
@@ -404,16 +336,74 @@ var namedEngineProjectionOf = async (call) => {
404
336
  }
405
337
  return parsed.data.outcome === "failed" ? runnerFailed({ mechanism: call.mechanism, failure: parsed.data.error }) : parsed.data;
406
338
  };
339
+ var measureVersionOneProjectionOver = (ports) => (measurement) => measuredVersionOne({ ...ports, ...measurement });
407
340
 
408
- // src/infrastructure/engines/protocol/engine-port.ts
409
- var createNamedConformancePort = (_options) => ({
410
- load: loadedNamedRunnerOf,
411
- conform: namedCheckConformance
341
+ // src/infrastructure/engines/protocol/upgrade/load-version-one-projection.ts
342
+ import { z as z5 } from "zod";
343
+ var projectionMethodsSchema = z5.object({
344
+ inspect: runnerCallSchema,
345
+ prepare: runnerCallSchema
346
+ });
347
+ var projectionModuleSchema = z5.object({
348
+ versionOneProjectionOver: z5.function({
349
+ input: [z5.unknown()],
350
+ output: projectionMethodsSchema
351
+ })
412
352
  });
413
- var createNamedEnginePort = (_options) => ({
414
- load: loadedNamedRunnerOf,
415
- run: namedEngineRunOf,
416
- project: namedEngineProjectionOf
353
+ var inspectionResult = z5.discriminatedUnion(
354
+ "outcome",
355
+ runnerResultSchema({
356
+ value: z5.object({
357
+ files: z5.array(repoPathSchema).readonly(),
358
+ ruleIds: z5.map(z5.string(), z5.string())
359
+ })
360
+ }).options
361
+ );
362
+ var preparationResult = runnerResultSchema({ value: z5.array(projectionWriteSchema).readonly() });
363
+ var methodsOf = async (request) => {
364
+ const { modules, installRoot, moduleExtension, path, fileText, fileRemoval } = request.options;
365
+ const loaded = await request.ports.runnerModuleOf({
366
+ modules,
367
+ installRoot,
368
+ moduleExtension,
369
+ path,
370
+ mechanism: "eslint"
371
+ });
372
+ if (loaded.outcome === "failed") return runnerInvalidOutput({ detail: loaded.error.detail });
373
+ const parsed = projectionModuleSchema.safeParse(loaded.value);
374
+ if (!parsed.success) return runnerInvalidOutput({ detail: z5.prettifyError(parsed.error) });
375
+ const platform = { path, fileText, fileRemoval, moduleExtension };
376
+ return { outcome: "ok", value: parsed.data.versionOneProjectionOver(platform) };
377
+ };
378
+ var projectionCall = async (request) => {
379
+ try {
380
+ const loaded = await request.methods();
381
+ if (loaded.outcome === "failed") return loaded;
382
+ const returned = await loaded.value[request.method](request.projection);
383
+ const parsed = request.output.safeParse(returned);
384
+ return parsed.success ? parsed.data : runnerInvalidOutput({ detail: z5.prettifyError(parsed.error) });
385
+ } catch (thrown) {
386
+ return rejectedCall({ thrown });
387
+ }
388
+ };
389
+ var versionOneProjectionPortOver = (ports) => (options) => {
390
+ let loaded;
391
+ const methods = () => loaded ??= methodsOf({ ports, options });
392
+ return {
393
+ inspect: (projection) => projectionCall({ methods, method: "inspect", projection, output: inspectionResult }),
394
+ prepare: (projection) => projectionCall({ methods, method: "prepare", projection, output: preparationResult })
395
+ };
396
+ };
397
+
398
+ // src/composition/runner-engines.ts
399
+ var runnerEnginesOver = (ports) => ({
400
+ namedEngine: {
401
+ load: loadedNamedRunnerOver(ports),
402
+ run: namedEngineRunOf,
403
+ project: namedEngineProjectionOf
404
+ },
405
+ versionOneProjectionOf: versionOneProjectionPortOver(ports),
406
+ measureVersionOne: measureVersionOneProjectionOver(ports)
417
407
  });
418
408
 
419
409
  // src/domain/settings/clause-settings/default-clause-settings.ts
@@ -423,10 +413,9 @@ var defaultClauseSettings = (request) => Object.fromEntries(
423
413
 
424
414
  export {
425
415
  defaultClauseSettings,
416
+ namedChecksRunReportSchema,
417
+ runnerModuleAt,
426
418
  runnerInvalidOutput,
427
419
  rejectedCall,
428
- runnerCallSchema,
429
- measureVersionOneProjection,
430
- createNamedConformancePort,
431
- createNamedEnginePort
420
+ runnerEnginesOver
432
421
  };