@hailstails/hone 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ADOPTING.md +33 -7
- package/CHANGELOG.md +13 -0
- package/MIGRATING.md +31 -6
- package/README.md +64 -17
- package/api/audit.d.ts +6 -0
- package/api/audit.js +9 -1
- package/api/testing.js +36 -8
- package/chunks/{chunk-XE6RNNZB.js → chunk-63SJV5ZY.js} +1395 -1339
- package/chunks/{chunk-RNXPEK2U.js → chunk-BLGGM7AV.js} +2 -2
- package/chunks/{chunk-OKQHVZLO.js → chunk-CBWWAKQY.js} +1 -1
- package/chunks/{chunk-5X2BR42Y.js → chunk-FR4FASVM.js} +15 -24
- package/chunks/chunk-MXSIQPCV.js +13 -0
- package/chunks/{chunk-LHVFZMXD.js → chunk-MZTLH4EU.js} +60 -20
- package/chunks/chunk-NA5L6PUE.js +15 -0
- package/chunks/{chunk-OVEQ37JQ.js → chunk-PVCA3ISA.js} +42 -17
- package/chunks/chunk-RWQ4UNKY.js +24 -0
- package/chunks/{chunk-YL6WR3QW.js → chunk-Y4SMWOD2.js} +1 -1
- package/chunks/chunk-YLZ73C7O.js +0 -0
- package/chunks/{chunk-NILRE23T.js → chunk-Z4UBS7WI.js} +1 -1
- package/core/check/tool-command.js +702 -22
- package/core/conformance/conformance-testing-types.d.ts +2 -0
- package/core/mechanism-port/runner-module-types.d.ts +2 -0
- package/core/rule-set-reader/authored-rule-set-types.d.ts +2 -0
- package/core/values/edition-types.d.ts +16 -0
- package/docs/extending.md +31 -9
- package/docs/output-contract.md +101 -15
- package/mechanisms/audit/CD-19/import-boundaries.js +3 -2
- package/mechanisms/audit/CD-27/piece.json +5 -1
- package/mechanisms/audit/CD-27/test-body-logic.js +55 -4
- package/mechanisms/audit/CD-5/comments-directives.js +4 -3
- package/mechanisms/audit/runner/runner.js +6 -5
- package/mechanisms/eslint/runner/runner.js +8 -4
- package/package.json +1 -1
- package/rules/CD-27/CHECKS.md +31 -1
- package/rules/CD-27/discipline.json +74 -0
|
@@ -3,9 +3,10 @@ import {
|
|
|
3
3
|
nativeExceptionKindSchema,
|
|
4
4
|
projectionWriteSchema,
|
|
5
5
|
runnerResultSchema
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BLGGM7AV.js";
|
|
7
7
|
import {
|
|
8
8
|
JSON_KIND_NAMES,
|
|
9
|
+
RESERVED_EDITION_SETTING,
|
|
9
10
|
disciplineFilePath,
|
|
10
11
|
eslintConfigLookupSchema,
|
|
11
12
|
jsonKindOf,
|
|
@@ -15,7 +16,7 @@ import {
|
|
|
15
16
|
readPieceFile,
|
|
16
17
|
readVersionOneJson,
|
|
17
18
|
sameJsonValue
|
|
18
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-PVCA3ISA.js";
|
|
19
20
|
import {
|
|
20
21
|
NOT_INSTALLED,
|
|
21
22
|
brandedRepoPathSchema,
|
|
@@ -23,7 +24,7 @@ import {
|
|
|
23
24
|
repoPathSchema,
|
|
24
25
|
repoPathTextSchema,
|
|
25
26
|
runnerModuleSegmentsOf
|
|
26
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-MZTLH4EU.js";
|
|
27
28
|
import {
|
|
28
29
|
NOT_ADOPTED,
|
|
29
30
|
NOT_RUN,
|
|
@@ -35,1399 +36,1455 @@ import {
|
|
|
35
36
|
mechanismIdSchema,
|
|
36
37
|
ruleSetNameSchema,
|
|
37
38
|
sameClauseAddress
|
|
38
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-FR4FASVM.js";
|
|
39
40
|
|
|
40
|
-
// core/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
41
|
+
// core/exception-records/exception-records.ts
|
|
42
|
+
import { z as z2 } from "zod";
|
|
43
|
+
|
|
44
|
+
// core/values/why-chain.ts
|
|
45
|
+
import { z } from "zod";
|
|
46
|
+
|
|
47
|
+
// core/values/chain-stems.ts
|
|
48
|
+
var FUNCTION_WORDS = /* @__PURE__ */ new Set([
|
|
49
|
+
"about",
|
|
50
|
+
"above",
|
|
51
|
+
"across",
|
|
52
|
+
"after",
|
|
53
|
+
"again",
|
|
54
|
+
"against",
|
|
55
|
+
"ago",
|
|
56
|
+
"all",
|
|
57
|
+
"almost",
|
|
58
|
+
"along",
|
|
59
|
+
"already",
|
|
60
|
+
"also",
|
|
61
|
+
"although",
|
|
62
|
+
"always",
|
|
63
|
+
"amid",
|
|
64
|
+
"among",
|
|
65
|
+
"and",
|
|
66
|
+
"another",
|
|
67
|
+
"any",
|
|
68
|
+
"anybody",
|
|
69
|
+
"anyone",
|
|
70
|
+
"anything",
|
|
71
|
+
"anyway",
|
|
72
|
+
"are",
|
|
73
|
+
"around",
|
|
74
|
+
"away",
|
|
75
|
+
"because",
|
|
76
|
+
"been",
|
|
77
|
+
"before",
|
|
78
|
+
"behind",
|
|
79
|
+
"being",
|
|
80
|
+
"below",
|
|
81
|
+
"beneath",
|
|
82
|
+
"beside",
|
|
83
|
+
"besides",
|
|
84
|
+
"between",
|
|
85
|
+
"beyond",
|
|
86
|
+
"both",
|
|
87
|
+
"but",
|
|
88
|
+
"can",
|
|
89
|
+
"cannot",
|
|
90
|
+
"could",
|
|
91
|
+
"despite",
|
|
92
|
+
"did",
|
|
93
|
+
"does",
|
|
94
|
+
"doing",
|
|
95
|
+
"done",
|
|
96
|
+
"down",
|
|
97
|
+
"during",
|
|
98
|
+
"each",
|
|
99
|
+
"either",
|
|
100
|
+
"else",
|
|
101
|
+
"enough",
|
|
102
|
+
"even",
|
|
103
|
+
"ever",
|
|
104
|
+
"every",
|
|
105
|
+
"everybody",
|
|
106
|
+
"everyone",
|
|
107
|
+
"everything",
|
|
108
|
+
"except",
|
|
109
|
+
"few",
|
|
110
|
+
"for",
|
|
111
|
+
"from",
|
|
112
|
+
"had",
|
|
113
|
+
"has",
|
|
114
|
+
"have",
|
|
115
|
+
"having",
|
|
116
|
+
"hence",
|
|
117
|
+
"her",
|
|
118
|
+
"here",
|
|
119
|
+
"hers",
|
|
120
|
+
"herself",
|
|
121
|
+
"him",
|
|
122
|
+
"himself",
|
|
123
|
+
"his",
|
|
124
|
+
"how",
|
|
125
|
+
"however",
|
|
126
|
+
"including",
|
|
127
|
+
"inside",
|
|
128
|
+
"instead",
|
|
129
|
+
"into",
|
|
130
|
+
"its",
|
|
131
|
+
"itself",
|
|
132
|
+
"just",
|
|
133
|
+
"less",
|
|
134
|
+
"like",
|
|
135
|
+
"many",
|
|
136
|
+
"may",
|
|
137
|
+
"maybe",
|
|
138
|
+
"might",
|
|
139
|
+
"mine",
|
|
140
|
+
"more",
|
|
141
|
+
"most",
|
|
142
|
+
"much",
|
|
143
|
+
"must",
|
|
144
|
+
"myself",
|
|
145
|
+
"near",
|
|
146
|
+
"neither",
|
|
147
|
+
"never",
|
|
148
|
+
"next",
|
|
149
|
+
"nobody",
|
|
150
|
+
"none",
|
|
151
|
+
"nor",
|
|
152
|
+
"not",
|
|
153
|
+
"nothing",
|
|
154
|
+
"now",
|
|
155
|
+
"off",
|
|
156
|
+
"often",
|
|
157
|
+
"once",
|
|
158
|
+
"one",
|
|
159
|
+
"only",
|
|
160
|
+
"onto",
|
|
161
|
+
"other",
|
|
162
|
+
"others",
|
|
163
|
+
"otherwise",
|
|
164
|
+
"our",
|
|
165
|
+
"ours",
|
|
166
|
+
"ourselves",
|
|
167
|
+
"out",
|
|
168
|
+
"outside",
|
|
169
|
+
"over",
|
|
170
|
+
"own",
|
|
171
|
+
"per",
|
|
172
|
+
"perhaps",
|
|
173
|
+
"quite",
|
|
174
|
+
"rather",
|
|
175
|
+
"really",
|
|
176
|
+
"same",
|
|
177
|
+
"she",
|
|
178
|
+
"shall",
|
|
179
|
+
"should",
|
|
180
|
+
"since",
|
|
181
|
+
"some",
|
|
182
|
+
"somebody",
|
|
183
|
+
"someone",
|
|
184
|
+
"something",
|
|
185
|
+
"soon",
|
|
186
|
+
"still",
|
|
187
|
+
"such",
|
|
188
|
+
"than",
|
|
189
|
+
"that",
|
|
190
|
+
"the",
|
|
191
|
+
"their",
|
|
192
|
+
"theirs",
|
|
193
|
+
"them",
|
|
194
|
+
"themselves",
|
|
195
|
+
"then",
|
|
196
|
+
"there",
|
|
197
|
+
"therefore",
|
|
198
|
+
"these",
|
|
199
|
+
"they",
|
|
200
|
+
"this",
|
|
201
|
+
"those",
|
|
202
|
+
"though",
|
|
203
|
+
"through",
|
|
204
|
+
"throughout",
|
|
205
|
+
"thus",
|
|
206
|
+
"too",
|
|
207
|
+
"toward",
|
|
208
|
+
"towards",
|
|
209
|
+
"under",
|
|
210
|
+
"unless",
|
|
211
|
+
"until",
|
|
212
|
+
"upon",
|
|
213
|
+
"very",
|
|
214
|
+
"via",
|
|
215
|
+
"was",
|
|
216
|
+
"were",
|
|
217
|
+
"what",
|
|
218
|
+
"whatever",
|
|
219
|
+
"when",
|
|
220
|
+
"whenever",
|
|
221
|
+
"where",
|
|
222
|
+
"whereas",
|
|
223
|
+
"whether",
|
|
224
|
+
"which",
|
|
225
|
+
"while",
|
|
226
|
+
"who",
|
|
227
|
+
"whoever",
|
|
228
|
+
"whom",
|
|
229
|
+
"whose",
|
|
230
|
+
"why",
|
|
231
|
+
"will",
|
|
232
|
+
"with",
|
|
233
|
+
"within",
|
|
234
|
+
"without",
|
|
235
|
+
"would",
|
|
236
|
+
"yet",
|
|
237
|
+
"you",
|
|
238
|
+
"your",
|
|
239
|
+
"yours",
|
|
240
|
+
"yourself",
|
|
241
|
+
"yourselves"
|
|
242
|
+
]);
|
|
243
|
+
var MINIMUM_LETTERS = 3;
|
|
244
|
+
var MINIMUM_STEM_LETTERS = 2;
|
|
245
|
+
var NEGATIVE_CONTRACTION = /n['’]t\b/gi;
|
|
246
|
+
var CAMEL_CASE_BOUNDARY = /([a-z0-9])([A-Z])/g;
|
|
247
|
+
var WORD_SEPARATOR = /[^a-z0-9]+/;
|
|
248
|
+
var BARE_NUMBER = /^\d+$/;
|
|
249
|
+
var PLURAL_RULES = [
|
|
250
|
+
[/ie[sd]$/, "y"],
|
|
251
|
+
[/(?<=ss|x|z|ch|sh)es$/, ""],
|
|
252
|
+
[/(?<![siu])s$/, ""]
|
|
253
|
+
];
|
|
254
|
+
var INFLECTION = /(?:ing|(?<!e)ed)$/;
|
|
255
|
+
var DOUBLED_FINAL_CONSONANT = /([bcdfghjkmnpqrtvwxy])\1$/;
|
|
256
|
+
var TRAILING_E = /e$/;
|
|
257
|
+
var VOWEL = /[aeiouy]/;
|
|
258
|
+
var shortenedTo = (request) => request.shortened.length >= request.floor ? request.shortened : request.stem;
|
|
259
|
+
var voicedShortenedTo = (request) => VOWEL.test(request.shortened) ? shortenedTo({ ...request, floor: MINIMUM_STEM_LETTERS }) : request.stem;
|
|
260
|
+
var singularOf = (request) => PLURAL_RULES.reduce(
|
|
261
|
+
(stem, [suffix, replacement]) => shortenedTo({ stem, shortened: stem.replace(suffix, replacement), floor: MINIMUM_LETTERS }),
|
|
262
|
+
request.word
|
|
263
|
+
);
|
|
264
|
+
var uninflectedOf = (request) => {
|
|
265
|
+
if (!INFLECTION.test(request.stem)) {
|
|
266
|
+
return request.stem;
|
|
118
267
|
}
|
|
268
|
+
const bare = voicedShortenedTo({ stem: request.stem, shortened: request.stem.replace(INFLECTION, "") });
|
|
269
|
+
return bare === request.stem ? bare : shortenedTo({ stem: bare, shortened: bare.replace(DOUBLED_FINAL_CONSONANT, "$1"), floor: MINIMUM_LETTERS });
|
|
119
270
|
};
|
|
120
|
-
var
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
// core/check/install-root.ts
|
|
125
|
-
var DIRECTORIES_ABOVE_ENTRY = {
|
|
126
|
-
api: "two directories",
|
|
127
|
-
command: "three directories"
|
|
271
|
+
var stemOf = (request) => {
|
|
272
|
+
const stem = uninflectedOf({ stem: singularOf(request) });
|
|
273
|
+
return shortenedTo({ stem, shortened: stem.replace(TRAILING_E, ""), floor: MINIMUM_STEM_LETTERS });
|
|
128
274
|
};
|
|
129
|
-
var
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
if (entry.outcome === "failed") {
|
|
136
|
-
return installRootUnresolvable({ url: entry.error.url, detail: entry.error.detail });
|
|
137
|
-
}
|
|
138
|
-
const resolved = request.path.resolve({
|
|
139
|
-
path: installRootAboveEntry({
|
|
140
|
-
entryFile: entry.value,
|
|
141
|
-
entry: request.entry,
|
|
142
|
-
directoryOf: (path) => request.path.directoryOf({ path })
|
|
143
|
-
})
|
|
144
|
-
});
|
|
145
|
-
if (resolved.outcome === "failed") {
|
|
146
|
-
return installRootUnresolvable({
|
|
147
|
-
url: request.moduleUrl,
|
|
148
|
-
detail: `the install root ${DIRECTORIES_ABOVE_ENTRY[request.entry]} above the entry file is not an absolute path`
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
return resolved;
|
|
275
|
+
var wordReadingOf = (request) => request.word.length >= MINIMUM_LETTERS && !FUNCTION_WORDS.has(request.word) && !BARE_NUMBER.test(request.word) ? "content" : "dropped";
|
|
276
|
+
var stemsOf = (request) => {
|
|
277
|
+
const spellings = request.text.replace(NEGATIVE_CONTRACTION, " not").replace(CAMEL_CASE_BOUNDARY, "$1 $2").toLowerCase().split(WORD_SEPARATOR).filter((word) => wordReadingOf({ word }) === "content").map((word) => [stemOf({ word }), word]);
|
|
278
|
+
return new Map(
|
|
279
|
+
spellings.filter(([stem], position) => spellings.findIndex(([earlier]) => earlier === stem) === position)
|
|
280
|
+
);
|
|
152
281
|
};
|
|
153
|
-
var
|
|
154
|
-
var
|
|
282
|
+
var stemsShared = (request) => new Map([...request.left].filter(([stem]) => request.right.has(stem)));
|
|
283
|
+
var stemsWithout = (request) => new Map([...request.stems].filter(([stem]) => request.excluded.every((excluded) => !excluded.has(stem))));
|
|
284
|
+
var wordsOf = (request) => [...request.stems.values()];
|
|
155
285
|
|
|
156
|
-
// core/values/
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
var
|
|
167
|
-
|
|
168
|
-
|
|
286
|
+
// core/values/why-chain.ts
|
|
287
|
+
var RESTATEMENT_PHRASES = [
|
|
288
|
+
String.raw`(?:the\s+)?(?:gate|check|ci|build|lint|test)s?\s+(?:was|were|is|are)\s+(?:failing|red|broken)`,
|
|
289
|
+
String.raw`(?:there\s+was\s+)?no\s+time`,
|
|
290
|
+
String.raw`we\s+(?:had\s+no|ran\s+out\s+of)\s+time`,
|
|
291
|
+
String.raw`(?:it\s+(?:is|was)\s+)?out\s+of\s+scope`,
|
|
292
|
+
String.raw`(?:it\s+(?:is|was)\s+)?(?:the\s+|an?\s+)?existing\s+(?:code|convention|pattern)`,
|
|
293
|
+
String.raw`(?:a\s+|the\s+)?time\s+constraint`,
|
|
294
|
+
String.raw`(?:a\s+|the\s+)?deadline`
|
|
295
|
+
];
|
|
296
|
+
var RESTATEMENT_OPENING = new RegExp(
|
|
297
|
+
String.raw`^(?:because\s+(?:of\s+)?)?(?:${RESTATEMENT_PHRASES.join("|")})\b`,
|
|
298
|
+
"i"
|
|
299
|
+
);
|
|
300
|
+
var MINIMUM_ANSWER_CHARACTERS = 12;
|
|
301
|
+
var MINIMUM_OWNER_CHARACTERS = 2;
|
|
302
|
+
var MINIMUM_SYMPTOM_STEMS_NAMED = 2;
|
|
303
|
+
var MINIMUM_NEW_STEM_SHARE = 0.25;
|
|
304
|
+
var ONE_REPEATED_CHARACTER = /^(.)\1+$/;
|
|
305
|
+
var PROSE_LOOKALIKES = /\b(?:e\.g\b\.?|i\.e\b\.?|a\.k\.a\.|etc\.|[ap]\.m\.)|(?<![\w./\\-])(?:and\/or|n\/a|w\/o|yes\/no)(?![\w./\\-])/gi;
|
|
306
|
+
var CHECKABLE_LOCATORS = [
|
|
307
|
+
/https?:\/\/\S/i,
|
|
308
|
+
/[\w.-][\\/][\w.-]/,
|
|
309
|
+
/(?:^|[\s(\x60'"])(?:\*|[\w-]+)(?:\.[\w-]+)*\.[a-z][a-z0-9]{0,9}\b/,
|
|
310
|
+
/(?:^|[\s(\x60'"])\.[a-z][\w-]+\b/,
|
|
311
|
+
/\d/
|
|
312
|
+
];
|
|
313
|
+
var THEREFORE = /\btherefore\b/i;
|
|
314
|
+
var rootCauseReading = (request) => RESTATEMENT_OPENING.test(request.rootCause.trim()) ? "restates-the-exception" : "names-a-cause";
|
|
315
|
+
var answerSubstance = (request) => request.answer.trim().length >= MINIMUM_ANSWER_CHARACTERS && !ONE_REPEATED_CHARACTER.test(request.answer.trim()) ? "substantive" : "placeholder";
|
|
316
|
+
var evidenceReading = (request) => CHECKABLE_LOCATORS.some((locator) => locator.test(request.evidence.replace(PROSE_LOOKALIKES, " "))) ? "checkable" : "unlocated";
|
|
317
|
+
var substantiveTextSchema = (request) => z.string({ error: request.refusal }).refine((answer) => answerSubstance({ answer }) === "substantive", {
|
|
318
|
+
error: request.refusal
|
|
169
319
|
});
|
|
170
|
-
var
|
|
171
|
-
|
|
172
|
-
return unbuilt.length === 0 ? [] : [`not available in this version: ${quotedKeys({ keys: unbuilt })}; assessment takes ${quotedKeys({ keys: Object.keys(ASSESSMENT_CONCERNS) })} only`];
|
|
173
|
-
};
|
|
174
|
-
var assessmentSchema = z.strictObject(ASSESSMENT_CONCERNS, {
|
|
175
|
-
error: (issue) => issue.code === "unrecognized_keys" ? [...removedKeyMessages({ keys: issue.keys }), ...unbuiltKeyMessages({ keys: issue.keys })].join(". ") : void 0
|
|
320
|
+
var checkableTextSchema = (request) => substantiveTextSchema({ refusal: request.missing }).refine((evidence) => evidenceReading({ evidence }) === "checkable", {
|
|
321
|
+
error: request.unlocated
|
|
176
322
|
});
|
|
177
|
-
var
|
|
178
|
-
var
|
|
179
|
-
|
|
323
|
+
var WHY_QUESTION_MISSING = "is missing its `why` question";
|
|
324
|
+
var BECAUSE_MISSING = "carries no real `because` answer: a placeholder is an absent answer";
|
|
325
|
+
var EVIDENCE_MISSING = "carries no real `evidence`: cite a command, path, record id, PR, or named ruling";
|
|
326
|
+
var EVIDENCE_UNLOCATED = "carries no checkable `evidence`: cite a path, a line, a record or PR number, a measurement or a link";
|
|
327
|
+
var ROOT_CAUSE_REQUIRED = "`whyChain.rootCause` is required: the fifth why names the cause, not another symptom";
|
|
328
|
+
var ROOT_CHECK_REQUIRED = "`whyChain.rootCheck` is required beside `readback` in a causal chain: name what was run or read today that shows the root still holds, with a path, record, measurement or link";
|
|
329
|
+
var ROOT_CHECK_UNLOCATED = "`whyChain.rootCheck` cites nothing checkable: name the path, record, measurement or link you checked today";
|
|
330
|
+
var READBACK_REQUIRED = '`whyChain.readback` is required beside `rootCheck` in a causal chain: read from the root back to the symptom with "therefore"';
|
|
331
|
+
var OWNER_REQUIRED = "`whyChain.owner` is required: a record dir, a capture id, or the holder of the reserved authority";
|
|
332
|
+
var whyQuestionSchema = z.string({ error: WHY_QUESTION_MISSING }).refine((question) => question.trim().length > 0, {
|
|
333
|
+
error: WHY_QUESTION_MISSING
|
|
180
334
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
var
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
var
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
};
|
|
240
|
-
default:
|
|
241
|
-
return failure;
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
var shownFailureOf = (request) => {
|
|
245
|
-
const { failure } = request;
|
|
246
|
-
switch (failure.kind) {
|
|
247
|
-
case "file-unreadable":
|
|
248
|
-
case "file-malformed":
|
|
249
|
-
case "unsupported-version":
|
|
250
|
-
case "rule-set-invalid":
|
|
251
|
-
return { ...failure, path: shownPathOf({ ...request, target: failure.path }) };
|
|
252
|
-
case "runner-failed":
|
|
253
|
-
return { ...failure, failure: shownRunnerFailureOf({ ...request, failure: failure.failure }) };
|
|
254
|
-
default:
|
|
255
|
-
return failure;
|
|
335
|
+
var legacyWhySchema = z.object(
|
|
336
|
+
{
|
|
337
|
+
why: whyQuestionSchema,
|
|
338
|
+
because: substantiveTextSchema({ refusal: BECAUSE_MISSING }),
|
|
339
|
+
evidence: substantiveTextSchema({ refusal: EVIDENCE_MISSING })
|
|
340
|
+
},
|
|
341
|
+
{ error: "is not a JSON object" }
|
|
342
|
+
);
|
|
343
|
+
var causalWhySchema = z.object(
|
|
344
|
+
{
|
|
345
|
+
why: whyQuestionSchema,
|
|
346
|
+
because: substantiveTextSchema({ refusal: BECAUSE_MISSING }),
|
|
347
|
+
evidence: checkableTextSchema({ missing: EVIDENCE_MISSING, unlocated: EVIDENCE_UNLOCATED })
|
|
348
|
+
},
|
|
349
|
+
{ error: "is not a JSON object" }
|
|
350
|
+
);
|
|
351
|
+
var fiveWhysSchema = (request) => z.tuple([request.why, request.why, request.why, request.why, request.why], {
|
|
352
|
+
error: "`whyChain.whys` must hold exactly 5 whys"
|
|
353
|
+
});
|
|
354
|
+
var rootCauseSchema = z.string({ error: ROOT_CAUSE_REQUIRED }).refine((answer) => answerSubstance({ answer }) === "substantive", {
|
|
355
|
+
error: ROOT_CAUSE_REQUIRED,
|
|
356
|
+
abort: true
|
|
357
|
+
}).refine((rootCause) => rootCauseReading({ rootCause }) === "names-a-cause", {
|
|
358
|
+
error: "`whyChain.rootCause` restates the exception rather than naming its cause"
|
|
359
|
+
});
|
|
360
|
+
var ownerSchema = z.string({ error: OWNER_REQUIRED }).refine((owner) => owner.trim().length >= MINIMUM_OWNER_CHARACTERS, {
|
|
361
|
+
error: OWNER_REQUIRED
|
|
362
|
+
});
|
|
363
|
+
var legacyWhyChainSchema = z.object(
|
|
364
|
+
{
|
|
365
|
+
whys: fiveWhysSchema({ why: legacyWhySchema }),
|
|
366
|
+
rootCause: rootCauseSchema,
|
|
367
|
+
owner: ownerSchema
|
|
368
|
+
},
|
|
369
|
+
{ error: "`whyChain` is not a JSON object" }
|
|
370
|
+
);
|
|
371
|
+
var causeNamed = (request) => wordsOf({ stems: request.cause }).join(", ");
|
|
372
|
+
var symptomProblems = (request) => request.symptom.size === 0 ? [{ path: ["whys", 0, "why"], message: "names no symptom: ask why the exception's own subject happens, naming it" }] : [];
|
|
373
|
+
var restatementProblems = (request) => request.introduced.flatMap(
|
|
374
|
+
(cause, position) => cause.size === 0 || cause.size < MINIMUM_NEW_STEM_SHARE * (request.answers[position]?.size ?? 0) ? [
|
|
375
|
+
{
|
|
376
|
+
path: ["whys", position, "because"],
|
|
377
|
+
message: `restates ${position === 0 ? "the symptom" : "the symptom or an earlier answer"}: give the cause behind it, with at least a quarter of its words new to the chain`
|
|
378
|
+
}
|
|
379
|
+
] : []
|
|
380
|
+
);
|
|
381
|
+
var linkProblems = (request) => request.introduced.slice(0, -1).flatMap(
|
|
382
|
+
(cause, position) => cause.size > 0 && stemsShared({ left: cause, right: stemsOf({ text: request.whys[position + 1]?.why ?? "" }) }).size === 0 ? [
|
|
383
|
+
{
|
|
384
|
+
path: ["whys", position + 1, "why"],
|
|
385
|
+
message: `does not ask about the cause why ${position + 1}'s answer gave: ask why that answer is true, naming its cause (${causeNamed({ cause })})`
|
|
386
|
+
}
|
|
387
|
+
] : []
|
|
388
|
+
);
|
|
389
|
+
var rootProblems = (request) => request.fifthCause.size > 0 && stemsShared({ left: request.fifthCause, right: stemsOf({ text: request.rootCause }) }).size === 0 ? [
|
|
390
|
+
{
|
|
391
|
+
path: ["rootCause"],
|
|
392
|
+
message: `\`whyChain.rootCause\` does not name the cause why 5's answer gave: the root is the cause behind that answer (${causeNamed({ cause: request.fifthCause })})`
|
|
256
393
|
}
|
|
394
|
+
] : [];
|
|
395
|
+
var readbackProblems = (request) => {
|
|
396
|
+
const readback = stemsOf({ text: request.readback });
|
|
397
|
+
const root = stemsOf({ text: request.rootCause });
|
|
398
|
+
const symptomNamed = stemsShared({ left: request.symptom, right: readback }).size;
|
|
399
|
+
return [
|
|
400
|
+
...THEREFORE.test(request.readback) ? [] : ['`whyChain.readback` must read from the root back to the symptom with "therefore"'],
|
|
401
|
+
...root.size > 0 && stemsShared({ left: root, right: readback }).size === 0 ? [`\`whyChain.readback\` must name the root it starts from (${causeNamed({ cause: root })})`] : [],
|
|
402
|
+
...symptomNamed < Math.min(MINIMUM_SYMPTOM_STEMS_NAMED, request.symptom.size) ? [`\`whyChain.readback\` must name the symptom why 1 asks about (${causeNamed({ cause: request.symptom })})`] : []
|
|
403
|
+
].map((message) => ({ path: ["readback"], message }));
|
|
404
|
+
};
|
|
405
|
+
var causalProblemsOf = (request) => {
|
|
406
|
+
const { whys, rootCause, readback } = request.chain;
|
|
407
|
+
const symptom = stemsOf({ text: whys[0].why });
|
|
408
|
+
const answers = whys.map((step) => stemsOf({ text: step.because }));
|
|
409
|
+
const introduced = answers.map(
|
|
410
|
+
(answer, position) => stemsWithout({ stems: answer, excluded: [symptom, ...answers.slice(0, position)] })
|
|
411
|
+
);
|
|
412
|
+
return [
|
|
413
|
+
...symptomProblems({ symptom }),
|
|
414
|
+
...restatementProblems({ answers, introduced }),
|
|
415
|
+
...linkProblems({ whys, introduced }),
|
|
416
|
+
...rootProblems({ rootCause, fifthCause: introduced[4] ?? /* @__PURE__ */ new Map() }),
|
|
417
|
+
...readbackProblems({ readback, rootCause, symptom })
|
|
418
|
+
];
|
|
257
419
|
};
|
|
420
|
+
var whyChainSchema = z.object(
|
|
421
|
+
{
|
|
422
|
+
whys: fiveWhysSchema({ why: causalWhySchema }),
|
|
423
|
+
rootCause: rootCauseSchema,
|
|
424
|
+
rootCheck: checkableTextSchema({ missing: ROOT_CHECK_REQUIRED, unlocated: ROOT_CHECK_UNLOCATED }),
|
|
425
|
+
readback: substantiveTextSchema({ refusal: READBACK_REQUIRED }),
|
|
426
|
+
owner: ownerSchema
|
|
427
|
+
},
|
|
428
|
+
{ error: "`whyChain` is not a JSON object" }
|
|
429
|
+
).superRefine((chain, context) => {
|
|
430
|
+
causalProblemsOf({ chain }).forEach((problem) => {
|
|
431
|
+
context.addIssue({ code: "custom", path: [...problem.path], message: problem.message });
|
|
432
|
+
});
|
|
433
|
+
});
|
|
434
|
+
var whyChainFormOf = (request) => typeof request.chain === "object" && request.chain !== null && !Array.isArray(request.chain) && !("rootCheck" in request.chain) && !("readback" in request.chain) ? "legacy" : "causal";
|
|
258
435
|
|
|
259
|
-
// core/
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
)
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
436
|
+
// core/exception-records/exception-records.ts
|
|
437
|
+
var exceptionsFileSchema = z2.object({
|
|
438
|
+
version: z2.literal(1),
|
|
439
|
+
exceptions: z2.array(
|
|
440
|
+
z2.discriminatedUnion("kind", [
|
|
441
|
+
z2.strictObject({
|
|
442
|
+
kind: z2.literal("authorised-location"),
|
|
443
|
+
clause: z2.string(),
|
|
444
|
+
file: z2.string(),
|
|
445
|
+
reason: z2.string(),
|
|
446
|
+
whyChain: z2.unknown().optional(),
|
|
447
|
+
provenance: z2.unknown().optional()
|
|
448
|
+
}),
|
|
449
|
+
z2.strictObject({
|
|
450
|
+
kind: z2.literal("file-carve-out"),
|
|
451
|
+
clause: z2.string(),
|
|
452
|
+
file: z2.string(),
|
|
453
|
+
reason: z2.string(),
|
|
454
|
+
whyChain: z2.unknown().optional(),
|
|
455
|
+
provenance: z2.unknown().optional()
|
|
456
|
+
}),
|
|
457
|
+
z2.strictObject({
|
|
458
|
+
kind: z2.literal("clause-wide-carve-out"),
|
|
459
|
+
clause: z2.string(),
|
|
460
|
+
reason: z2.string(),
|
|
461
|
+
whyChain: z2.unknown()
|
|
462
|
+
})
|
|
463
|
+
])
|
|
464
|
+
)
|
|
272
465
|
});
|
|
273
|
-
var
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
const { given, declaration } = request;
|
|
277
|
-
if (declaration === void 0) {
|
|
278
|
-
return `its piece takes no ${given.key}; it takes ${Object.keys(request.declarations).join(", ")}`;
|
|
279
|
-
}
|
|
280
|
-
const kind = jsonKindOf({ value: declaration.default });
|
|
281
|
-
if (jsonKindOf({ value: given.value }) !== kind) return `${given.key} must be ${JSON_KIND_NAMES[kind]}, as its default is`;
|
|
282
|
-
const choices = declaration.choices;
|
|
283
|
-
if (choices !== void 0 && !choices.some((choice) => sameJsonValue({ left: choice, right: given.value }) === "same")) {
|
|
284
|
-
return `${given.key} must be one of ${listed({ values: choices })}`;
|
|
285
|
-
}
|
|
286
|
-
return void 0;
|
|
466
|
+
var exceptionEntriesOfDocument = (request) => {
|
|
467
|
+
const parsed = exceptionsFileSchema.safeParse(request.document);
|
|
468
|
+
return parsed.success ? { outcome: "ok", value: parsed.data.exceptions } : { outcome: "failed", error: { detail: z2.prettifyError(parsed.error) } };
|
|
287
469
|
};
|
|
288
|
-
var
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
([key, settingValue]) => settingRefusalOf({
|
|
294
|
-
given: { key, value: settingValue },
|
|
295
|
-
declaration: Object.hasOwn(request.declarations, key) ? request.declarations[key] : void 0,
|
|
296
|
-
declarations: request.declarations
|
|
297
|
-
})
|
|
298
|
-
).find((found) => found !== void 0);
|
|
299
|
-
if (detail !== void 0) return refusal({ address: request.address, detail });
|
|
300
|
-
return { outcome: "ok", value: { ...defaults, ...request.given } };
|
|
470
|
+
var RECORDS_DOCUMENT_KEYS = Object.keys(exceptionsFileSchema.shape);
|
|
471
|
+
var documentKeysSchema = z2.record(z2.string(), z2.unknown());
|
|
472
|
+
var foreignKeysOfDocument = (request) => {
|
|
473
|
+
const keys = documentKeysSchema.safeParse(request.document);
|
|
474
|
+
return keys.success ? Object.keys(keys.data).filter((key) => !RECORDS_DOCUMENT_KEYS.includes(key)) : [];
|
|
301
475
|
};
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
// core/consumer-selection/consumer-selection.ts
|
|
308
|
-
import { z as z5 } from "zod";
|
|
309
|
-
var RULE_SET_SUFFIX_SEPARATOR = "-";
|
|
310
|
-
var CLAUSE_ADDRESS_RULE_SET_SEPARATOR = "/";
|
|
311
|
-
var LEADING_CURRENT_DIRECTORY = "./";
|
|
312
|
-
var clauseChoiceSchema = z5.union(
|
|
313
|
-
[
|
|
314
|
-
z5.literal(NOT_RUN).transform(() => ({ state: "not-run" })),
|
|
315
|
-
z5.literal(NOT_ADOPTED).transform(() => ({ state: "not-adopted" })),
|
|
316
|
-
mechanismIdSchema.transform((mechanism) => ({ state: "run", mechanism }))
|
|
317
|
-
],
|
|
318
|
-
{ error: `a clause takes a mechanism id, "${NOT_RUN}" or "${NOT_ADOPTED}"` }
|
|
319
|
-
);
|
|
320
|
-
var UNSETTABLE_LISTING_REFUSALS = {
|
|
321
|
-
unlisted: "clauses does not select it",
|
|
322
|
-
"not-run": "clauses runs no mechanism for it, so remove its settings",
|
|
323
|
-
"not-adopted": "clauses does not adopt it, so remove its settings"
|
|
476
|
+
var UNMEASURED_EXCEPTION_BASELINE = { measured: "no", base: { state: "not-given" } };
|
|
477
|
+
var LEGACY_DIRECTORY_OF = {
|
|
478
|
+
"inherited-debt": ".constitution-carve-outs",
|
|
479
|
+
"existing-authorisation": ".constitution-authorised-locations"
|
|
324
480
|
};
|
|
325
|
-
var
|
|
326
|
-
var
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
).pipe(repoPathSchema).transform((path) => ({ location: "folder", path }))
|
|
331
|
-
]);
|
|
332
|
-
var consumerSelectionFileSchema = z5.strictObject({
|
|
333
|
-
version: z5.literal(1),
|
|
334
|
-
ruleSets: z5.record(ruleSetNameSchema, z5.string()).transform((ruleSets) => Object.entries(ruleSets)).pipe(z5.array(z5.tuple([ruleSetNameSchema, ruleSetLocationSchema]))),
|
|
335
|
-
clauses: z5.record(z5.string(), z5.string()).transform((clauses) => Object.entries(clauses)).pipe(z5.array(z5.tuple([clauseAddressSchema, clauseChoiceSchema]))),
|
|
336
|
-
exclude: z5.array(
|
|
337
|
-
brandedRepoPathSchema({
|
|
338
|
-
text: repoPathTextSchema.refine((excludedPath) => !excludedPath.includes("*"), {
|
|
339
|
-
error: "an exclude entry is a repository path, not a glob"
|
|
340
|
-
})
|
|
341
|
-
})
|
|
342
|
-
).default([]),
|
|
343
|
-
eslintConfigLookup: eslintConfigLookupSchema.optional(),
|
|
344
|
-
eslintConfigRoots: z5.array(
|
|
345
|
-
brandedRepoPathSchema({
|
|
346
|
-
text: repoPathTextSchema.refine((rootPath) => !rootPath.includes("*"), {
|
|
347
|
-
error: "an eslintConfigRoots entry is a repository folder, not a glob"
|
|
348
|
-
})
|
|
349
|
-
})
|
|
350
|
-
).default([]),
|
|
351
|
-
fileExceptionWhyChains: fileExceptionWhyChainsSchema.default("required"),
|
|
352
|
-
reportOutput: reportOutputSchema.default("full"),
|
|
353
|
-
assessment: assessmentSchema.default(DEFAULT_ASSESSMENT),
|
|
354
|
-
clauseSettings: clauseSettingsSchema.default([])
|
|
355
|
-
}).superRefine((file, context) => {
|
|
356
|
-
const settingsAddresses = file.clauseSettings.map(([address]) => address);
|
|
357
|
-
settingsAddresses.flatMap((address) => {
|
|
358
|
-
const listing = clauseListingOf({ clauses: file.clauses, address });
|
|
359
|
-
return listing === "run" ? [] : [{ address, listing }];
|
|
360
|
-
}).forEach(({ address, listing }) => {
|
|
361
|
-
const text = clauseAddressText({ address });
|
|
362
|
-
context.addIssue({
|
|
363
|
-
code: "custom",
|
|
364
|
-
path: ["clauseSettings", text],
|
|
365
|
-
message: `clauseSettings for ${text}: ${UNSETTABLE_LISTING_REFUSALS[listing]}`
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
settingsAddresses.filter(
|
|
369
|
-
(address, index) => settingsAddresses.slice(0, index).some((earlier) => sameClauseAddress({ left: earlier, right: address }) === "same")
|
|
370
|
-
).forEach((address) => {
|
|
371
|
-
const text = clauseAddressText({ address });
|
|
372
|
-
context.addIssue({
|
|
373
|
-
code: "custom",
|
|
374
|
-
path: ["clauseSettings", text],
|
|
375
|
-
message: `clauseSettings for ${text}: given twice, also as ${TOOL_RULE_SET}${CLAUSE_ADDRESS_RULE_SET_SEPARATOR}${text}`
|
|
376
|
-
});
|
|
377
|
-
});
|
|
481
|
+
var LEGACY_SOURCE = /^(?<directory>[^/#]+)\/(?<stem>cd-[0-9a-z]+)\.json#(?<index>\d+)$/;
|
|
482
|
+
var legacySourceGroupsSchema = z2.object({
|
|
483
|
+
directory: z2.enum([LEGACY_DIRECTORY_OF["inherited-debt"], LEGACY_DIRECTORY_OF["existing-authorisation"]]),
|
|
484
|
+
stem: z2.string(),
|
|
485
|
+
index: z2.coerce.number().int().nonnegative()
|
|
378
486
|
});
|
|
379
|
-
var
|
|
380
|
-
|
|
381
|
-
|
|
487
|
+
var legacyRecordsSchema = z2.array(z2.looseObject({ files: z2.array(z2.string()) }));
|
|
488
|
+
var recordedTextSchema = z2.string().refine((text) => text.trim().length > 0, { error: "must not be blank" });
|
|
489
|
+
var existingAuthorisationProvenanceSchema = z2.strictObject({
|
|
490
|
+
kind: z2.literal("existing-authorisation"),
|
|
491
|
+
source: recordedTextSchema,
|
|
492
|
+
decision: recordedTextSchema.optional()
|
|
382
493
|
});
|
|
383
|
-
var
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
494
|
+
var inheritedDebtProvenanceSchema = z2.strictObject({
|
|
495
|
+
kind: z2.literal("inherited-debt"),
|
|
496
|
+
source: recordedTextSchema,
|
|
497
|
+
decision: recordedTextSchema
|
|
498
|
+
});
|
|
499
|
+
var authorisedLocationFields = {
|
|
500
|
+
kind: z2.literal("authorised-location"),
|
|
501
|
+
clause: z2.string(),
|
|
502
|
+
file: z2.string(),
|
|
503
|
+
reason: z2.string()
|
|
504
|
+
};
|
|
505
|
+
var unjudgedWhyChainSchema = z2.custom((whyChain) => whyChain !== void 0);
|
|
506
|
+
var reasonOnlyFields = { reason: recordedTextSchema, whyChain: z2.never().optional(), provenance: z2.never().optional() };
|
|
507
|
+
var chainedAuthorisedLocationSchema = z2.strictObject({ ...authorisedLocationFields, whyChain: unjudgedWhyChainSchema, provenance: existingAuthorisationProvenanceSchema.optional() });
|
|
508
|
+
var importedAuthorisedLocationSchema = z2.strictObject({ ...authorisedLocationFields, whyChain: z2.never().optional(), provenance: existingAuthorisationProvenanceSchema });
|
|
509
|
+
var reasonedAuthorisedLocationSchema = z2.strictObject({ ...authorisedLocationFields, ...reasonOnlyFields });
|
|
510
|
+
var fileCarveOutFields = {
|
|
511
|
+
kind: z2.literal("file-carve-out"),
|
|
512
|
+
clause: z2.string(),
|
|
513
|
+
file: z2.string(),
|
|
514
|
+
reason: z2.string()
|
|
515
|
+
};
|
|
516
|
+
var chainedFileCarveOutSchema = z2.strictObject({ ...fileCarveOutFields, whyChain: unjudgedWhyChainSchema, provenance: inheritedDebtProvenanceSchema.optional() });
|
|
517
|
+
var importedFileCarveOutSchema = z2.strictObject({ ...fileCarveOutFields, whyChain: z2.never().optional(), provenance: inheritedDebtProvenanceSchema });
|
|
518
|
+
var reasonedFileCarveOutSchema = z2.strictObject({ ...fileCarveOutFields, ...reasonOnlyFields });
|
|
519
|
+
var FILE_EVIDENCE_SCHEMAS_OF = {
|
|
520
|
+
required: {
|
|
521
|
+
"authorised-location": z2.union([chainedAuthorisedLocationSchema, importedAuthorisedLocationSchema]),
|
|
522
|
+
"file-carve-out": z2.union([chainedFileCarveOutSchema, importedFileCarveOutSchema])
|
|
523
|
+
},
|
|
524
|
+
optional: {
|
|
525
|
+
"authorised-location": z2.union([chainedAuthorisedLocationSchema, importedAuthorisedLocationSchema, reasonedAuthorisedLocationSchema]),
|
|
526
|
+
"file-carve-out": z2.union([chainedFileCarveOutSchema, importedFileCarveOutSchema, reasonedFileCarveOutSchema])
|
|
404
527
|
}
|
|
405
|
-
return { outcome: "ok", value: resolved.value };
|
|
406
528
|
};
|
|
407
|
-
var
|
|
408
|
-
const
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
if (loaded !== void 0) {
|
|
412
|
-
return { outcome: "ok", value: loaded.discipline };
|
|
529
|
+
var legacySourceOf = (request) => {
|
|
530
|
+
const groups = legacySourceGroupsSchema.safeParse(LEGACY_SOURCE.exec(request.source)?.groups);
|
|
531
|
+
if (!groups.success) {
|
|
532
|
+
return "not-legacy-source";
|
|
413
533
|
}
|
|
414
|
-
const
|
|
415
|
-
|
|
416
|
-
|
|
534
|
+
const path = repoPathSchema.safeParse(`${groups.data.directory}/${groups.data.stem}.json`);
|
|
535
|
+
return path.success ? { path: path.data, directory: groups.data.directory, discipline: groups.data.stem.toUpperCase(), index: groups.data.index } : "not-legacy-source";
|
|
536
|
+
};
|
|
537
|
+
var sameEntry = (request) => JSON.stringify(request.left) === JSON.stringify(request.right) ? "same" : "different";
|
|
538
|
+
var sameIdentity = (request) => request.entry.kind === request.identity.kind && request.entry.clause === request.identity.clause && request.entry.file === request.identity.file ? "same" : "different";
|
|
539
|
+
var legacyListing = (request) => {
|
|
540
|
+
const text = request.sourceTextsAtBase.get(request.source.path);
|
|
541
|
+
const document = text === void 0 ? void 0 : parsedJson({ text });
|
|
542
|
+
if (document === void 0 || document.outcome === "failed") {
|
|
543
|
+
return "not-listed";
|
|
417
544
|
}
|
|
418
|
-
|
|
545
|
+
const records = legacyRecordsSchema.safeParse(document.value);
|
|
546
|
+
return records.success && records.data[request.source.index]?.files.includes(request.file) === true ? "listed" : "not-listed";
|
|
419
547
|
};
|
|
420
|
-
var
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
548
|
+
var importRefused = (request) => ({
|
|
549
|
+
outcome: "failed",
|
|
550
|
+
error: { kind: "import-unverified", detail: `${request.detail}: give it a whyChain` }
|
|
551
|
+
});
|
|
552
|
+
var verifiedImport = (request) => {
|
|
553
|
+
const { baseline } = request;
|
|
554
|
+
if (baseline.measured === "no") {
|
|
555
|
+
return { outcome: "ok", value: request.record };
|
|
425
556
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
return failed({ kind: "unknown-clause", address });
|
|
557
|
+
if (baseline.entriesAtBase.some((baseEntry) => sameEntry({ left: baseEntry, right: request.entry }) === "same")) {
|
|
558
|
+
return { outcome: "ok", value: request.record };
|
|
429
559
|
}
|
|
430
|
-
if (
|
|
431
|
-
return
|
|
560
|
+
if (baseline.entriesAtBase.some((baseEntry) => sameIdentity({ entry: baseEntry, identity: request.identity }) === "same")) {
|
|
561
|
+
return importRefused({ detail: "the imported record was edited since the base revision" });
|
|
432
562
|
}
|
|
433
|
-
|
|
563
|
+
const source = legacySourceOf({ source: request.provenance.source });
|
|
564
|
+
const listed2 = source !== "not-legacy-source" && source.directory === LEGACY_DIRECTORY_OF[request.provenance.kind] && source.discipline === request.discipline.toUpperCase() && legacyListing({ sourceTextsAtBase: baseline.sourceTextsAtBase, source, file: request.identity.file }) === "listed";
|
|
565
|
+
return listed2 ? { outcome: "ok", value: request.record } : importRefused({
|
|
566
|
+
detail: `the record is new since the base revision, and its provenance source ${request.provenance.source} is not an entry at the base revision listing ${request.identity.file} under ${LEGACY_DIRECTORY_OF[request.provenance.kind]}/${request.discipline.toLowerCase()}.json`
|
|
567
|
+
});
|
|
568
|
+
};
|
|
569
|
+
var recordedFile = (request) => {
|
|
570
|
+
const parsed = repoPathSchema.safeParse(request.file);
|
|
571
|
+
return parsed.success ? { outcome: "ok", value: parsed.data } : { outcome: "failed", error: { kind: "file-not-repo-path", file: request.file } };
|
|
572
|
+
};
|
|
573
|
+
var LEGACY_CHAIN_NEW_OR_EDITED = `a new or edited entry's whyChain follows the causal contract (docs/why-chain-contract.md in the ${TOOL_IDENTITY.packageName} package); a chain without rootCheck and readback is accepted only while --base-revision holds its entry unchanged`;
|
|
574
|
+
var legacyChainStanding = (request) => {
|
|
575
|
+
if (request.baseline.measured === "no") {
|
|
576
|
+
return "base-unmeasured";
|
|
577
|
+
}
|
|
578
|
+
return request.baseline.entriesAtBase.some((baseEntry) => sameEntry({ left: baseEntry, right: request.entry }) === "same") ? "unchanged-since-base" : "new-or-edited";
|
|
579
|
+
};
|
|
580
|
+
var chainRefused = (request) => ({
|
|
581
|
+
outcome: "failed",
|
|
582
|
+
error: { kind: "why-chain-refused", detail: request.detail }
|
|
583
|
+
});
|
|
584
|
+
var causalChainOf = (request) => {
|
|
585
|
+
const parsed = whyChainSchema.safeParse(request.whyChain);
|
|
586
|
+
return parsed.success ? { outcome: "ok", value: parsed.data } : chainRefused({ detail: [...request.preface, z2.prettifyError(parsed.error)].join("\n") });
|
|
434
587
|
};
|
|
435
|
-
var
|
|
436
|
-
const
|
|
437
|
-
|
|
438
|
-
|
|
588
|
+
var legacyChainOf = (request) => {
|
|
589
|
+
const parsed = legacyWhyChainSchema.safeParse(request.whyChain);
|
|
590
|
+
return parsed.success ? { outcome: "ok", value: parsed.data } : chainRefused({ detail: z2.prettifyError(parsed.error) });
|
|
591
|
+
};
|
|
592
|
+
var judgedWhyChain = (request) => {
|
|
593
|
+
if (whyChainFormOf({ chain: request.whyChain }) === "causal") {
|
|
594
|
+
return causalChainOf({ whyChain: request.whyChain, preface: [] });
|
|
439
595
|
}
|
|
440
|
-
|
|
441
|
-
|
|
596
|
+
switch (legacyChainStanding(request)) {
|
|
597
|
+
case "unchanged-since-base":
|
|
598
|
+
case "base-unmeasured":
|
|
599
|
+
return legacyChainOf(request);
|
|
600
|
+
case "new-or-edited":
|
|
601
|
+
return causalChainOf({ whyChain: request.whyChain, preface: [LEGACY_CHAIN_NEW_OR_EDITED] });
|
|
442
602
|
}
|
|
443
|
-
return defined;
|
|
444
603
|
};
|
|
445
|
-
var
|
|
446
|
-
|
|
447
|
-
|
|
604
|
+
var unselectedKindOf = (request) => [
|
|
605
|
+
["clause-not-adopted", request.selection.notAdopted],
|
|
606
|
+
["clause-not-run", request.selection.notRun]
|
|
607
|
+
].find(
|
|
608
|
+
([, addresses]) => addresses.some((address) => sameClauseAddress({ left: address, right: request.clause }) === "same")
|
|
609
|
+
)?.[0] ?? "clause-not-selected";
|
|
610
|
+
var selectedClauseOf = (request) => {
|
|
611
|
+
const address = clauseAddressSchema.safeParse(request.entry.clause);
|
|
612
|
+
if (!address.success) {
|
|
613
|
+
return {
|
|
614
|
+
outcome: "failed",
|
|
615
|
+
error: { kind: "clause-unparseable", detail: z2.prettifyError(address.error) }
|
|
616
|
+
};
|
|
617
|
+
}
|
|
618
|
+
const clause = address.data;
|
|
619
|
+
const selected = request.selection.selected.find(
|
|
620
|
+
(candidate) => sameClauseAddress({ left: candidate.address, right: clause }) === "same"
|
|
448
621
|
);
|
|
449
|
-
if (
|
|
450
|
-
return { outcome: "
|
|
622
|
+
if (selected === void 0) {
|
|
623
|
+
return { outcome: "failed", error: { kind: unselectedKindOf({ selection: request.selection, clause }), clause } };
|
|
451
624
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
ruleSetRoot: request.ruleSetRoot,
|
|
455
|
-
discipline: request.address.discipline,
|
|
456
|
-
mechanism: request.mechanism
|
|
457
|
-
};
|
|
458
|
-
if (request.fileText.exists({ path: pieceFilePath(location) }) === "absent") {
|
|
459
|
-
return failed({
|
|
460
|
-
kind: "piece-missing",
|
|
461
|
-
address: clauseAddressText({ address: request.address }),
|
|
462
|
-
mechanism: request.mechanism
|
|
463
|
-
});
|
|
625
|
+
if (selected.exceptions === "refused") {
|
|
626
|
+
return { outcome: "failed", error: { kind: "non-exemptible-clause", clause } };
|
|
464
627
|
}
|
|
465
|
-
return
|
|
628
|
+
return { outcome: "ok", value: { clause, mechanism: selected.mechanism } };
|
|
466
629
|
};
|
|
467
|
-
var
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
return failed({ kind: "runner-missing", mechanism: request.mechanism });
|
|
473
|
-
}
|
|
474
|
-
const piece = pieceOf(request);
|
|
475
|
-
if (piece.outcome === "failed") {
|
|
476
|
-
return piece;
|
|
630
|
+
var fileRecordOf = (request) => {
|
|
631
|
+
const { evidence, entry, clause, mechanism, file, baseline } = request;
|
|
632
|
+
if (evidence.whyChain !== void 0) {
|
|
633
|
+
const whyChain = judgedWhyChain({ whyChain: evidence.whyChain, entry, baseline });
|
|
634
|
+
return whyChain.outcome === "failed" ? whyChain : { outcome: "ok", value: { ...evidence, whyChain: whyChain.value, clause, mechanism, file } };
|
|
477
635
|
}
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
return failed({
|
|
481
|
-
kind: "piece-missing",
|
|
482
|
-
address: clauseAddressText({ address: request.address }),
|
|
483
|
-
mechanism: request.mechanism
|
|
484
|
-
});
|
|
636
|
+
if (evidence.provenance === void 0) {
|
|
637
|
+
return { outcome: "ok", value: { ...evidence, clause, mechanism, file } };
|
|
485
638
|
}
|
|
486
|
-
return {
|
|
639
|
+
return verifiedImport({
|
|
640
|
+
record: { ...evidence, clause, mechanism, file },
|
|
641
|
+
entry,
|
|
642
|
+
identity: { kind: evidence.kind, clause: evidence.clause, file },
|
|
643
|
+
discipline: clause.discipline,
|
|
644
|
+
provenance: evidence.provenance,
|
|
645
|
+
baseline
|
|
646
|
+
});
|
|
487
647
|
};
|
|
488
|
-
var
|
|
489
|
-
const {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
anchor: defined.definition.anchor,
|
|
501
|
-
pieceRoot: clauseRequest.path.join({
|
|
502
|
-
segments: [clauseRequest.ruleSetRoot, "mechanisms", clauseRequest.mechanism, clauseRequest.address.discipline]
|
|
503
|
-
}),
|
|
504
|
-
settings: entry.settings,
|
|
505
|
-
clauseSettings: defaultClauseSettings({ declarations: entry.declarations })
|
|
648
|
+
var parsedRecord = (request) => {
|
|
649
|
+
const { entry } = request;
|
|
650
|
+
const selected = selectedClauseOf(request);
|
|
651
|
+
if (selected.outcome === "failed") {
|
|
652
|
+
return selected;
|
|
653
|
+
}
|
|
654
|
+
const { clause, mechanism } = selected.value;
|
|
655
|
+
switch (entry.kind) {
|
|
656
|
+
case "authorised-location": {
|
|
657
|
+
const file = recordedFile({ file: entry.file });
|
|
658
|
+
if (file.outcome === "failed") {
|
|
659
|
+
return file;
|
|
506
660
|
}
|
|
661
|
+
const evidence = request.fileEvidence["authorised-location"].safeParse(entry);
|
|
662
|
+
return evidence.success ? fileRecordOf({ evidence: evidence.data, entry, clause, mechanism, file: file.value, baseline: request.baseline }) : { outcome: "failed", error: { kind: "evidence-refused", detail: z2.prettifyError(evidence.error) } };
|
|
507
663
|
}
|
|
508
|
-
|
|
664
|
+
case "file-carve-out": {
|
|
665
|
+
const file = recordedFile({ file: entry.file });
|
|
666
|
+
if (file.outcome === "failed") {
|
|
667
|
+
return file;
|
|
668
|
+
}
|
|
669
|
+
const evidence = request.fileEvidence["file-carve-out"].safeParse(entry);
|
|
670
|
+
return evidence.success ? fileRecordOf({ evidence: evidence.data, entry, clause, mechanism, file: file.value, baseline: request.baseline }) : { outcome: "failed", error: { kind: "evidence-refused", detail: z2.prettifyError(evidence.error) } };
|
|
671
|
+
}
|
|
672
|
+
case "clause-wide-carve-out": {
|
|
673
|
+
const whyChain = judgedWhyChain({ whyChain: entry.whyChain, entry, baseline: request.baseline });
|
|
674
|
+
if (whyChain.outcome === "failed") {
|
|
675
|
+
return whyChain;
|
|
676
|
+
}
|
|
677
|
+
return {
|
|
678
|
+
outcome: "ok",
|
|
679
|
+
value: { kind: entry.kind, clause, mechanism, reason: entry.reason, whyChain: whyChain.value }
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
}
|
|
509
683
|
};
|
|
510
|
-
var
|
|
511
|
-
const
|
|
512
|
-
if (
|
|
513
|
-
return
|
|
684
|
+
var identityComparison = (request) => {
|
|
685
|
+
const { left, right } = request;
|
|
686
|
+
if (left.kind !== right.kind || sameClauseAddress({ left: left.clause, right: right.clause }) === "different") {
|
|
687
|
+
return "different-identity";
|
|
514
688
|
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
689
|
+
switch (left.kind) {
|
|
690
|
+
case "clause-wide-carve-out":
|
|
691
|
+
return "same-identity";
|
|
692
|
+
case "authorised-location":
|
|
693
|
+
case "file-carve-out":
|
|
694
|
+
return right.kind !== "clause-wide-carve-out" && left.file === right.file ? "same-identity" : "different-identity";
|
|
519
695
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
696
|
+
};
|
|
697
|
+
var originalRecordOf = (request) => request.valid.find(
|
|
698
|
+
(earlier) => earlier.index < request.candidate.index && identityComparison({ left: earlier.record, right: request.candidate.record }) === "same-identity"
|
|
699
|
+
);
|
|
700
|
+
var validRecordsOf = (request) => request.parsed.flatMap(
|
|
701
|
+
({ index, place, record }) => record.outcome === "ok" ? [{ index, place, record: record.value }] : []
|
|
702
|
+
);
|
|
703
|
+
var invalidRecordOf = (request) => {
|
|
704
|
+
const { index, place, record } = request.entry;
|
|
705
|
+
if (record.outcome === "failed") {
|
|
706
|
+
return [{ place, problem: record.error }];
|
|
523
707
|
}
|
|
524
|
-
|
|
708
|
+
const original = originalRecordOf({ valid: request.valid, candidate: { index, place, record: record.value } });
|
|
709
|
+
if (original === void 0) {
|
|
710
|
+
return [];
|
|
711
|
+
}
|
|
712
|
+
return [{ place, problem: { kind: "duplicate", of: original.place } }];
|
|
525
713
|
};
|
|
526
|
-
var
|
|
527
|
-
var
|
|
528
|
-
|
|
529
|
-
const
|
|
530
|
-
|
|
714
|
+
var invalidRecordsOf = (request) => request.parsed.flatMap((entry) => invalidRecordOf({ entry, valid: request.valid }));
|
|
715
|
+
var firstRecordsOf = (request) => request.valid.filter((candidate) => originalRecordOf({ valid: request.valid, candidate }) === void 0).map(({ record }) => record);
|
|
716
|
+
var parseExceptionEntries = (request) => {
|
|
717
|
+
const fileEvidence = FILE_EVIDENCE_SCHEMAS_OF[request.fileExceptionWhyChains];
|
|
718
|
+
const parsed = request.entries.map(
|
|
719
|
+
({ place, entry }, index) => ({
|
|
720
|
+
index,
|
|
721
|
+
place,
|
|
722
|
+
record: parsedRecord({ entry, selection: request.selection, baseline: request.baseline, fileEvidence })
|
|
723
|
+
})
|
|
531
724
|
);
|
|
532
|
-
|
|
725
|
+
const valid = validRecordsOf({ parsed });
|
|
726
|
+
return { records: firstRecordsOf({ valid }), invalid: invalidRecordsOf({ parsed, valid }) };
|
|
533
727
|
};
|
|
534
|
-
var
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
);
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
);
|
|
543
|
-
var resolvedClauses = (request) => adoptedEntries(request).reduce(
|
|
544
|
-
(sofar, [address, mechanism]) => appendedClause({
|
|
545
|
-
sofar,
|
|
546
|
-
resolve: ({ earlier }) => resolveClause({ ...request, ruleSets: request.file.ruleSets, address, mechanism, earlier })
|
|
547
|
-
}),
|
|
548
|
-
{ outcome: "ok", value: [] }
|
|
549
|
-
);
|
|
550
|
-
var unrunClause = (request) => {
|
|
551
|
-
const root = ruleSetRootOf({
|
|
552
|
-
...request,
|
|
553
|
-
ruleSet: request.address.ruleSet,
|
|
554
|
-
ruleSets: Object.fromEntries(request.file.ruleSets)
|
|
555
|
-
});
|
|
556
|
-
if (root.outcome === "failed") {
|
|
557
|
-
return root;
|
|
728
|
+
var importedEvidenceOf = (request) => {
|
|
729
|
+
switch (request.entry.kind) {
|
|
730
|
+
case "authorised-location":
|
|
731
|
+
return importedAuthorisedLocationSchema.safeParse(request.entry);
|
|
732
|
+
case "file-carve-out":
|
|
733
|
+
return importedFileCarveOutSchema.safeParse(request.entry);
|
|
734
|
+
case "clause-wide-carve-out":
|
|
735
|
+
return void 0;
|
|
558
736
|
}
|
|
559
|
-
const defined = mechanicalClause({
|
|
560
|
-
...request,
|
|
561
|
-
ruleSetRoot: root.value,
|
|
562
|
-
earlier: request.adopted,
|
|
563
|
-
judgementRefusal: "judgement-clause-listed"
|
|
564
|
-
});
|
|
565
|
-
return defined.outcome === "failed" ? defined : { outcome: "ok", value: { discipline: defined.value.discipline, address: request.address, state: request.state } };
|
|
566
737
|
};
|
|
567
|
-
var
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
var addressesIn = (request) => request.unrun.filter((clause) => clause.state === request.state).map((clause) => clause.address);
|
|
572
|
-
var appendedClause = (request) => {
|
|
573
|
-
if (request.sofar.outcome === "failed") {
|
|
574
|
-
return request.sofar;
|
|
738
|
+
var importEvidenceOf = (request) => {
|
|
739
|
+
const evidence = importedEvidenceOf(request);
|
|
740
|
+
if (evidence === void 0 || !evidence.success) {
|
|
741
|
+
return { imported: "no" };
|
|
575
742
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
743
|
+
return { imported: "yes", source: evidence.data.provenance.source };
|
|
744
|
+
};
|
|
745
|
+
var recordImportOf = (request) => {
|
|
746
|
+
const { record } = request;
|
|
747
|
+
if (record.kind === "clause-wide-carve-out" || record.whyChain !== void 0 || record.provenance === void 0) {
|
|
748
|
+
return { imported: "no" };
|
|
749
|
+
}
|
|
750
|
+
return { imported: "yes", source: record.provenance.source };
|
|
751
|
+
};
|
|
752
|
+
var importSourcePathsOf = (request) => {
|
|
753
|
+
const evidence = importEvidenceOf(request);
|
|
754
|
+
if (evidence.imported === "no") {
|
|
755
|
+
return [];
|
|
579
756
|
}
|
|
580
|
-
|
|
757
|
+
const source = legacySourceOf({ source: evidence.source });
|
|
758
|
+
return source === "not-legacy-source" ? [] : [source.path];
|
|
581
759
|
};
|
|
582
|
-
var
|
|
583
|
-
|
|
760
|
+
var importedEntriesIn = (request) => request.entries.some((entry) => importEvidenceOf({ entry }).imported === "yes") ? "present" : "absent";
|
|
761
|
+
var legacyChainsIn = (request) => request.entries.some((entry) => whyChainFormOf({ chain: entry.whyChain }) === "legacy") ? "present" : "absent";
|
|
762
|
+
var importSourcesOf = (request) => [...new Set(request.entries.flatMap((entry) => importSourcePathsOf({ entry })))];
|
|
763
|
+
var exceptionEntriesOfText = (request) => {
|
|
764
|
+
const document = parsedJson({ text: request.text });
|
|
584
765
|
if (document.outcome === "failed") {
|
|
585
|
-
return
|
|
586
|
-
}
|
|
587
|
-
const parsed = consumerSelectionFileSchema.safeParse(document.value);
|
|
588
|
-
if (!parsed.success) {
|
|
589
|
-
return failed({ kind: "file-malformed", path: request.path, detail: z5.prettifyError(parsed.error) });
|
|
766
|
+
return [];
|
|
590
767
|
}
|
|
591
|
-
const
|
|
592
|
-
return
|
|
593
|
-
};
|
|
594
|
-
var reservedRuleSetNameRefusalOf = (request) => {
|
|
595
|
-
const reserved = request.file.ruleSets.find(
|
|
596
|
-
([name]) => name === TOOL_RULE_SET || name.startsWith(`${TOOL_RULE_SET}${RULE_SET_SUFFIX_SEPARATOR}`)
|
|
597
|
-
);
|
|
598
|
-
return reserved === void 0 ? void 0 : { kind: "reserved-rule-set-name", name: reserved[0] };
|
|
768
|
+
const entries = exceptionEntriesOfDocument({ document: document.value });
|
|
769
|
+
return entries.outcome === "ok" ? entries.value : [];
|
|
599
770
|
};
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
771
|
+
|
|
772
|
+
// core/check/load-failure-text.ts
|
|
773
|
+
var escapedLineBreaks = (request) => request.text.replaceAll("\n", "\\n").replaceAll("\r", "\\r");
|
|
774
|
+
var JUDGEMENT_CLAUSE_LISTED_REPAIR = "a judgement clause is enforced by review and is left out of clauses, adopted or not; remove it";
|
|
775
|
+
var CONFIG_ROOT_REPAIR = "an eslintConfigRoots entry is a folder git tracks files under outside every excluded path, spelled exactly as git spells it; fix or remove it in disciplines.json";
|
|
776
|
+
var SELECTION_ABSENT_REPAIR = "holds no disciplines.json; give the folder that holds it, usually the repository root";
|
|
777
|
+
var WHY_CHAINS_REQUIRED_REPAIR = `${TOOL_IDENTITY.command} record-debt writes records that give only a reason, and this file requires a whyChain on every record; set "fileExceptionWhyChains": "optional" in it to accept them`;
|
|
778
|
+
var BOTH_LAYOUTS_REPAIR = `${TOOL_IDENTITY.name} reads exception records from one layout; keep each record in one of them and remove the other`;
|
|
779
|
+
var SUPPORTED_VERSION_REPAIR = "add a supported version to the devDependencies of the repository root";
|
|
780
|
+
var EACH_SUPPORTED_VERSION_REPAIR = "add a supported version of each to the devDependencies of the repository root";
|
|
781
|
+
var unavailablePeerRepair = (request) => request.peer.peer === "required" && request.peer.found === NOT_INSTALLED ? `${request.peer.packageName} is a required peer of ${TOOL_IDENTITY.packageName}, so this install is incomplete; ${SUPPORTED_VERSION_REPAIR} and reinstall` : SUPPORTED_VERSION_REPAIR;
|
|
782
|
+
var unavailablePeersRepair = (request) => {
|
|
783
|
+
const [first, ...rest] = request.peers;
|
|
784
|
+
return rest.length === 0 ? unavailablePeerRepair({ peer: first }) : EACH_SUPPORTED_VERSION_REPAIR;
|
|
606
785
|
};
|
|
607
|
-
var
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
786
|
+
var unavailablePeerText = (request) => `${request.peer.packageName} found ${request.peer.found}, supported ${request.peer.supported}`;
|
|
787
|
+
var runnerFailureFields = (request) => {
|
|
788
|
+
switch (request.failure.kind) {
|
|
789
|
+
case "piece-invalid":
|
|
790
|
+
return [request.failure.kind, request.failure.pieceRoot, request.failure.detail];
|
|
791
|
+
case "file-unreadable":
|
|
792
|
+
case "file-unparseable":
|
|
793
|
+
return [request.failure.kind, request.failure.file, request.failure.detail];
|
|
794
|
+
case "toolchain-unavailable":
|
|
795
|
+
return [
|
|
796
|
+
request.failure.kind,
|
|
797
|
+
`${request.failure.peers.map((peer) => unavailablePeerText({ peer })).join("; ")}: ${unavailablePeersRepair({ peers: request.failure.peers })}`
|
|
798
|
+
];
|
|
799
|
+
case "toolchain-shadowed":
|
|
800
|
+
return [
|
|
801
|
+
request.failure.kind,
|
|
802
|
+
request.failure.packageName,
|
|
803
|
+
`resolved from ${request.failure.location} inside the core install ${request.failure.installRoot}: delete ${request.failure.installRoot}/node_modules, then reinstall the package with the repository's package manager, so the repository's own copy is used`
|
|
804
|
+
];
|
|
805
|
+
case "tool-failed":
|
|
806
|
+
case "plugin-conflict":
|
|
807
|
+
case "team-config-unloadable":
|
|
808
|
+
case "runner-invalid-output":
|
|
809
|
+
return [request.failure.kind, request.failure.detail];
|
|
614
810
|
}
|
|
615
|
-
const address = clauseAddressText({ address: repeated });
|
|
616
|
-
return { kind: "duplicate-clause", address, prefixedAddress: `${TOOL_RULE_SET}${CLAUSE_ADDRESS_RULE_SET_SEPARATOR}${address}` };
|
|
617
811
|
};
|
|
618
|
-
var
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
812
|
+
var loadFailureFields = (request) => {
|
|
813
|
+
switch (request.failure.kind) {
|
|
814
|
+
case "arguments-invalid":
|
|
815
|
+
case "git-failed":
|
|
816
|
+
case "unexpected-error":
|
|
817
|
+
return [request.failure.detail];
|
|
818
|
+
case "selection-absent":
|
|
819
|
+
return [request.failure.repo, SELECTION_ABSENT_REPAIR];
|
|
820
|
+
case "install-root-unresolvable":
|
|
821
|
+
return [request.failure.url, request.failure.detail];
|
|
822
|
+
case "file-unreadable":
|
|
823
|
+
case "file-malformed":
|
|
824
|
+
case "file-unwritable":
|
|
825
|
+
case "records-unsplittable":
|
|
826
|
+
case "rule-set-invalid":
|
|
827
|
+
return [request.failure.path, request.failure.detail];
|
|
828
|
+
case "records-in-both-layouts":
|
|
829
|
+
return [request.failure.path, `${request.failure.folder}:`, BOTH_LAYOUTS_REPAIR];
|
|
830
|
+
case "why-chains-required":
|
|
831
|
+
return [`${request.failure.path}:`, WHY_CHAINS_REQUIRED_REPAIR];
|
|
832
|
+
case "unsupported-version":
|
|
833
|
+
return [request.failure.path, String(JSON.stringify(request.failure.found))];
|
|
834
|
+
case "reserved-rule-set-name":
|
|
835
|
+
case "unknown-rule-set":
|
|
836
|
+
return [request.failure.name];
|
|
837
|
+
case "duplicate-clause":
|
|
838
|
+
return [request.failure.address, request.failure.prefixedAddress];
|
|
839
|
+
case "rule-set-name-collision":
|
|
840
|
+
return [request.failure.name, request.failure.other];
|
|
841
|
+
case "unknown-discipline":
|
|
842
|
+
case "unknown-clause":
|
|
843
|
+
case "judgement-clause-selected":
|
|
844
|
+
return [request.failure.address];
|
|
845
|
+
case "judgement-clause-listed":
|
|
846
|
+
return [`${request.failure.address}:`, JUDGEMENT_CLAUSE_LISTED_REPAIR];
|
|
847
|
+
case "mechanism-not-allowed":
|
|
848
|
+
case "piece-missing":
|
|
849
|
+
return [request.failure.address, request.failure.mechanism];
|
|
850
|
+
case "config-root-untracked":
|
|
851
|
+
return [`${request.failure.root}:`, CONFIG_ROOT_REPAIR];
|
|
852
|
+
case "runner-missing":
|
|
853
|
+
return [request.failure.mechanism];
|
|
854
|
+
case "runner-invalid":
|
|
855
|
+
return [request.failure.mechanism, request.failure.detail];
|
|
856
|
+
case "runner-failed":
|
|
857
|
+
return [request.failure.mechanism, ...runnerFailureFields({ failure: request.failure.failure })];
|
|
651
858
|
}
|
|
652
|
-
const { binding } = request.clause;
|
|
653
|
-
return {
|
|
654
|
-
outcome: "ok",
|
|
655
|
-
value: { ...request.clause, binding: { ...binding, clause: { ...binding.clause, clauseSettings: clauseSettings.value } } }
|
|
656
|
-
};
|
|
657
859
|
};
|
|
658
|
-
var
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
var
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
return file;
|
|
667
|
-
}
|
|
668
|
-
return { outcome: "ok", value: { reportOutput: file.value.reportOutput, assessment: file.value.assessment } };
|
|
860
|
+
var loadFailureDetail = (request) => [request.failure.kind, ...loadFailureFields(request)].map((text) => escapedLineBreaks({ text })).join(" ");
|
|
861
|
+
var loadFailureText = (request) => `load failure: ${loadFailureDetail(request)}
|
|
862
|
+
`;
|
|
863
|
+
|
|
864
|
+
// core/check/install-root.ts
|
|
865
|
+
var DIRECTORIES_ABOVE_ENTRY = {
|
|
866
|
+
api: "two directories",
|
|
867
|
+
command: "three directories"
|
|
669
868
|
};
|
|
670
|
-
var
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
869
|
+
var installRootUnresolvable = (request) => ({
|
|
870
|
+
outcome: "failed",
|
|
871
|
+
error: { kind: "install-root-unresolvable", url: request.url, detail: request.detail }
|
|
872
|
+
});
|
|
873
|
+
var installRootAbove = (request) => {
|
|
874
|
+
const entry = request.path.fromFileUrl({ url: request.moduleUrl });
|
|
875
|
+
if (entry.outcome === "failed") {
|
|
876
|
+
return installRootUnresolvable({ url: entry.error.url, detail: entry.error.detail });
|
|
674
877
|
}
|
|
675
|
-
const resolved =
|
|
878
|
+
const resolved = request.path.resolve({
|
|
879
|
+
path: installRootAboveEntry({
|
|
880
|
+
entryFile: entry.value,
|
|
881
|
+
entry: request.entry,
|
|
882
|
+
directoryOf: (path) => request.path.directoryOf({ path })
|
|
883
|
+
})
|
|
884
|
+
});
|
|
676
885
|
if (resolved.outcome === "failed") {
|
|
677
|
-
return
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
return settled;
|
|
682
|
-
}
|
|
683
|
-
const unrun = unrunClauses({ ...request, file: file.value, adopted: settled.value });
|
|
684
|
-
if (unrun.outcome === "failed") {
|
|
685
|
-
return unrun;
|
|
886
|
+
return installRootUnresolvable({
|
|
887
|
+
url: request.moduleUrl,
|
|
888
|
+
detail: `the install root ${DIRECTORIES_ABOVE_ENTRY[request.entry]} above the entry file is not an absolute path`
|
|
889
|
+
});
|
|
686
890
|
}
|
|
687
|
-
return
|
|
891
|
+
return resolved;
|
|
688
892
|
};
|
|
893
|
+
var installRootOf = (request) => installRootAbove({ ...request, entry: "command" });
|
|
894
|
+
var installRootOfApiEntry = (request) => installRootAbove({ ...request, entry: "api" });
|
|
689
895
|
|
|
690
|
-
// core/
|
|
691
|
-
import { z as
|
|
896
|
+
// core/values/assessment.ts
|
|
897
|
+
import { z as z3 } from "zod";
|
|
898
|
+
var forfeitureAssessmentSchema = z3.enum(["this-run", "elsewhere"]);
|
|
899
|
+
var ASSESSMENT_CONCERNS = {
|
|
900
|
+
forfeiture: forfeitureAssessmentSchema.default("this-run")
|
|
901
|
+
};
|
|
902
|
+
var WAIVED_CLAUSES_REPLACEMENT = `in clauses, mark a clause "${NOT_RUN}" when its mechanism does not run, or "${NOT_ADOPTED}" when its rule does not apply; see MIGRATING.md section 12`;
|
|
903
|
+
var removedText = (request) => `removed: ${JSON.stringify(request.removed)}; ${request.instead}`;
|
|
904
|
+
var REMOVED_CONCERNS = /* @__PURE__ */ new Map([["waivedClauses", WAIVED_CLAUSES_REPLACEMENT]]);
|
|
905
|
+
var quotedKeys = (request) => request.keys.map((key) => JSON.stringify(key)).join(", ");
|
|
906
|
+
var removedKeyMessages = (request) => request.keys.flatMap((key) => {
|
|
907
|
+
const instead = REMOVED_CONCERNS.get(key);
|
|
908
|
+
return instead === void 0 ? [] : [removedText({ removed: key, instead })];
|
|
909
|
+
});
|
|
910
|
+
var unbuiltKeyMessages = (request) => {
|
|
911
|
+
const unbuilt = request.keys.filter((key) => !REMOVED_CONCERNS.has(key));
|
|
912
|
+
return unbuilt.length === 0 ? [] : [`not available in this version: ${quotedKeys({ keys: unbuilt })}; assessment takes ${quotedKeys({ keys: Object.keys(ASSESSMENT_CONCERNS) })} only`];
|
|
913
|
+
};
|
|
914
|
+
var assessmentSchema = z3.strictObject(ASSESSMENT_CONCERNS, {
|
|
915
|
+
error: (issue) => issue.code === "unrecognized_keys" ? [...removedKeyMessages({ keys: issue.keys }), ...unbuiltKeyMessages({ keys: issue.keys })].join(". ") : void 0
|
|
916
|
+
});
|
|
917
|
+
var DEFAULT_ASSESSMENT = assessmentSchema.parse({});
|
|
918
|
+
var assessmentInEffect = (request) => ({
|
|
919
|
+
forfeiture: request.requested.forfeiture ?? request.configured.forfeiture
|
|
920
|
+
});
|
|
692
921
|
|
|
693
|
-
// core/
|
|
694
|
-
import { z as
|
|
922
|
+
// core/values/report-output.ts
|
|
923
|
+
import { z as z4 } from "zod";
|
|
924
|
+
var reportOutputSchema = z4.enum(["full", "failures-only", "counts", "verdict-only"]);
|
|
925
|
+
var reportOutputInEffect = (request) => request.requested ?? request.configured;
|
|
695
926
|
|
|
696
|
-
// core/
|
|
697
|
-
|
|
927
|
+
// core/check/package-link.ts
|
|
928
|
+
var UNLINKED = { kind: "unlinked" };
|
|
929
|
+
var INSTALL_FOLDER = "node_modules";
|
|
930
|
+
var PACKAGE_MANIFEST = "package.json";
|
|
931
|
+
var manifestTextAt = (request) => {
|
|
932
|
+
const read = request.fileText.read({ path: request.path.join({ segments: [request.root, PACKAGE_MANIFEST] }) });
|
|
933
|
+
return read.outcome === "ok" ? read.value : void 0;
|
|
934
|
+
};
|
|
935
|
+
var sameFolder = (request) => {
|
|
936
|
+
const location = request.path.relative(request);
|
|
937
|
+
return location.relation === "within-root" && location.path === "" ? "same" : "different";
|
|
938
|
+
};
|
|
939
|
+
var holdsRunningPackage = (request) => {
|
|
940
|
+
const running = manifestTextAt({ ...request, root: request.installRoot });
|
|
941
|
+
return running !== void 0 && running === manifestTextAt({ ...request, root: request.linkRoot }) ? "holds" : "does-not-hold";
|
|
942
|
+
};
|
|
943
|
+
var packageLinkOf = (request) => {
|
|
944
|
+
const linkRoot = request.path.join({ segments: [request.repoRoot, INSTALL_FOLDER, TOOL_IDENTITY.packageName] });
|
|
945
|
+
const linked = { kind: "linked", installRoot: request.installRoot, linkRoot };
|
|
946
|
+
if (sameFolder({ path: request.path, from: linkRoot, to: request.installRoot }) === "same") {
|
|
947
|
+
return linked;
|
|
948
|
+
}
|
|
949
|
+
return holdsRunningPackage({ ...request, linkRoot }) === "holds" ? linked : UNLINKED;
|
|
950
|
+
};
|
|
698
951
|
|
|
699
|
-
// core/
|
|
700
|
-
var
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
"
|
|
706
|
-
|
|
707
|
-
"ago",
|
|
708
|
-
"all",
|
|
709
|
-
"almost",
|
|
710
|
-
"along",
|
|
711
|
-
"already",
|
|
712
|
-
"also",
|
|
713
|
-
"although",
|
|
714
|
-
"always",
|
|
715
|
-
"amid",
|
|
716
|
-
"among",
|
|
717
|
-
"and",
|
|
718
|
-
"another",
|
|
719
|
-
"any",
|
|
720
|
-
"anybody",
|
|
721
|
-
"anyone",
|
|
722
|
-
"anything",
|
|
723
|
-
"anyway",
|
|
724
|
-
"are",
|
|
725
|
-
"around",
|
|
726
|
-
"away",
|
|
727
|
-
"because",
|
|
728
|
-
"been",
|
|
729
|
-
"before",
|
|
730
|
-
"behind",
|
|
731
|
-
"being",
|
|
732
|
-
"below",
|
|
733
|
-
"beneath",
|
|
734
|
-
"beside",
|
|
735
|
-
"besides",
|
|
736
|
-
"between",
|
|
737
|
-
"beyond",
|
|
738
|
-
"both",
|
|
739
|
-
"but",
|
|
740
|
-
"can",
|
|
741
|
-
"cannot",
|
|
742
|
-
"could",
|
|
743
|
-
"despite",
|
|
744
|
-
"did",
|
|
745
|
-
"does",
|
|
746
|
-
"doing",
|
|
747
|
-
"done",
|
|
748
|
-
"down",
|
|
749
|
-
"during",
|
|
750
|
-
"each",
|
|
751
|
-
"either",
|
|
752
|
-
"else",
|
|
753
|
-
"enough",
|
|
754
|
-
"even",
|
|
755
|
-
"ever",
|
|
756
|
-
"every",
|
|
757
|
-
"everybody",
|
|
758
|
-
"everyone",
|
|
759
|
-
"everything",
|
|
760
|
-
"except",
|
|
761
|
-
"few",
|
|
762
|
-
"for",
|
|
763
|
-
"from",
|
|
764
|
-
"had",
|
|
765
|
-
"has",
|
|
766
|
-
"have",
|
|
767
|
-
"having",
|
|
768
|
-
"hence",
|
|
769
|
-
"her",
|
|
770
|
-
"here",
|
|
771
|
-
"hers",
|
|
772
|
-
"herself",
|
|
773
|
-
"him",
|
|
774
|
-
"himself",
|
|
775
|
-
"his",
|
|
776
|
-
"how",
|
|
777
|
-
"however",
|
|
778
|
-
"including",
|
|
779
|
-
"inside",
|
|
780
|
-
"instead",
|
|
781
|
-
"into",
|
|
782
|
-
"its",
|
|
783
|
-
"itself",
|
|
784
|
-
"just",
|
|
785
|
-
"less",
|
|
786
|
-
"like",
|
|
787
|
-
"many",
|
|
788
|
-
"may",
|
|
789
|
-
"maybe",
|
|
790
|
-
"might",
|
|
791
|
-
"mine",
|
|
792
|
-
"more",
|
|
793
|
-
"most",
|
|
794
|
-
"much",
|
|
795
|
-
"must",
|
|
796
|
-
"myself",
|
|
797
|
-
"near",
|
|
798
|
-
"neither",
|
|
799
|
-
"never",
|
|
800
|
-
"next",
|
|
801
|
-
"nobody",
|
|
802
|
-
"none",
|
|
803
|
-
"nor",
|
|
804
|
-
"not",
|
|
805
|
-
"nothing",
|
|
806
|
-
"now",
|
|
807
|
-
"off",
|
|
808
|
-
"often",
|
|
809
|
-
"once",
|
|
810
|
-
"one",
|
|
811
|
-
"only",
|
|
812
|
-
"onto",
|
|
813
|
-
"other",
|
|
814
|
-
"others",
|
|
815
|
-
"otherwise",
|
|
816
|
-
"our",
|
|
817
|
-
"ours",
|
|
818
|
-
"ourselves",
|
|
819
|
-
"out",
|
|
820
|
-
"outside",
|
|
821
|
-
"over",
|
|
822
|
-
"own",
|
|
823
|
-
"per",
|
|
824
|
-
"perhaps",
|
|
825
|
-
"quite",
|
|
826
|
-
"rather",
|
|
827
|
-
"really",
|
|
828
|
-
"same",
|
|
829
|
-
"she",
|
|
830
|
-
"shall",
|
|
831
|
-
"should",
|
|
832
|
-
"since",
|
|
833
|
-
"some",
|
|
834
|
-
"somebody",
|
|
835
|
-
"someone",
|
|
836
|
-
"something",
|
|
837
|
-
"soon",
|
|
838
|
-
"still",
|
|
839
|
-
"such",
|
|
840
|
-
"than",
|
|
841
|
-
"that",
|
|
842
|
-
"the",
|
|
843
|
-
"their",
|
|
844
|
-
"theirs",
|
|
845
|
-
"them",
|
|
846
|
-
"themselves",
|
|
847
|
-
"then",
|
|
848
|
-
"there",
|
|
849
|
-
"therefore",
|
|
850
|
-
"these",
|
|
851
|
-
"they",
|
|
852
|
-
"this",
|
|
853
|
-
"those",
|
|
854
|
-
"though",
|
|
855
|
-
"through",
|
|
856
|
-
"throughout",
|
|
857
|
-
"thus",
|
|
858
|
-
"too",
|
|
859
|
-
"toward",
|
|
860
|
-
"towards",
|
|
861
|
-
"under",
|
|
862
|
-
"unless",
|
|
863
|
-
"until",
|
|
864
|
-
"upon",
|
|
865
|
-
"very",
|
|
866
|
-
"via",
|
|
867
|
-
"was",
|
|
868
|
-
"were",
|
|
869
|
-
"what",
|
|
870
|
-
"whatever",
|
|
871
|
-
"when",
|
|
872
|
-
"whenever",
|
|
873
|
-
"where",
|
|
874
|
-
"whereas",
|
|
875
|
-
"whether",
|
|
876
|
-
"which",
|
|
877
|
-
"while",
|
|
878
|
-
"who",
|
|
879
|
-
"whoever",
|
|
880
|
-
"whom",
|
|
881
|
-
"whose",
|
|
882
|
-
"why",
|
|
883
|
-
"will",
|
|
884
|
-
"with",
|
|
885
|
-
"within",
|
|
886
|
-
"without",
|
|
887
|
-
"would",
|
|
888
|
-
"yet",
|
|
889
|
-
"you",
|
|
890
|
-
"your",
|
|
891
|
-
"yours",
|
|
892
|
-
"yourself",
|
|
893
|
-
"yourselves"
|
|
894
|
-
]);
|
|
895
|
-
var MINIMUM_LETTERS = 3;
|
|
896
|
-
var MINIMUM_STEM_LETTERS = 2;
|
|
897
|
-
var NEGATIVE_CONTRACTION = /n['’]t\b/gi;
|
|
898
|
-
var CAMEL_CASE_BOUNDARY = /([a-z0-9])([A-Z])/g;
|
|
899
|
-
var WORD_SEPARATOR = /[^a-z0-9]+/;
|
|
900
|
-
var BARE_NUMBER = /^\d+$/;
|
|
901
|
-
var PLURAL_RULES = [
|
|
902
|
-
[/ie[sd]$/, "y"],
|
|
903
|
-
[/(?<=ss|x|z|ch|sh)es$/, ""],
|
|
904
|
-
[/(?<![siu])s$/, ""]
|
|
905
|
-
];
|
|
906
|
-
var INFLECTION = /(?:ing|(?<!e)ed)$/;
|
|
907
|
-
var DOUBLED_FINAL_CONSONANT = /([bcdfghjkmnpqrtvwxy])\1$/;
|
|
908
|
-
var TRAILING_E = /e$/;
|
|
909
|
-
var VOWEL = /[aeiouy]/;
|
|
910
|
-
var shortenedTo = (request) => request.shortened.length >= request.floor ? request.shortened : request.stem;
|
|
911
|
-
var voicedShortenedTo = (request) => VOWEL.test(request.shortened) ? shortenedTo({ ...request, floor: MINIMUM_STEM_LETTERS }) : request.stem;
|
|
912
|
-
var singularOf = (request) => PLURAL_RULES.reduce(
|
|
913
|
-
(stem, [suffix, replacement]) => shortenedTo({ stem, shortened: stem.replace(suffix, replacement), floor: MINIMUM_LETTERS }),
|
|
914
|
-
request.word
|
|
915
|
-
);
|
|
916
|
-
var uninflectedOf = (request) => {
|
|
917
|
-
if (!INFLECTION.test(request.stem)) {
|
|
918
|
-
return request.stem;
|
|
952
|
+
// core/check/shown-path.ts
|
|
953
|
+
var NATIVE_SEPARATOR = "\\";
|
|
954
|
+
var SHOWN_SEPARATOR = "/";
|
|
955
|
+
var PARENT_FOLDER = "..";
|
|
956
|
+
var insidePackage = (request) => request.within === PARENT_FOLDER || request.within.startsWith(`${PARENT_FOLDER}${SHOWN_SEPARATOR}`) ? "outside" : "inside";
|
|
957
|
+
var throughLink = (request) => {
|
|
958
|
+
if (request.link.kind === "unlinked") {
|
|
959
|
+
return request.target;
|
|
919
960
|
}
|
|
920
|
-
const
|
|
921
|
-
return
|
|
961
|
+
const location = request.path.relative({ from: request.link.installRoot, to: request.target });
|
|
962
|
+
return location.relation === "within-root" && insidePackage({ within: location.path }) === "inside" ? request.path.join({ segments: [request.link.linkRoot, location.path] }) : request.target;
|
|
922
963
|
};
|
|
923
|
-
var
|
|
924
|
-
const
|
|
925
|
-
|
|
964
|
+
var shownPathOf = (request) => {
|
|
965
|
+
const target = throughLink(request);
|
|
966
|
+
const location = request.repoRoot === void 0 ? void 0 : request.path.relative({ from: request.repoRoot, to: target });
|
|
967
|
+
return location?.relation === "within-root" ? location.path : target.replaceAll(NATIVE_SEPARATOR, SHOWN_SEPARATOR);
|
|
968
|
+
};
|
|
969
|
+
var shownRunnerFailureOf = (request) => {
|
|
970
|
+
const { failure } = request;
|
|
971
|
+
switch (failure.kind) {
|
|
972
|
+
case "piece-invalid":
|
|
973
|
+
return { ...failure, pieceRoot: shownPathOf({ ...request, target: failure.pieceRoot }) };
|
|
974
|
+
case "toolchain-shadowed":
|
|
975
|
+
return {
|
|
976
|
+
...failure,
|
|
977
|
+
location: shownPathOf({ ...request, target: failure.location }),
|
|
978
|
+
installRoot: shownPathOf({ ...request, target: failure.installRoot })
|
|
979
|
+
};
|
|
980
|
+
default:
|
|
981
|
+
return failure;
|
|
982
|
+
}
|
|
926
983
|
};
|
|
927
|
-
var
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
984
|
+
var shownFailureOf = (request) => {
|
|
985
|
+
const { failure } = request;
|
|
986
|
+
switch (failure.kind) {
|
|
987
|
+
case "file-unreadable":
|
|
988
|
+
case "file-malformed":
|
|
989
|
+
case "file-unwritable":
|
|
990
|
+
case "why-chains-required":
|
|
991
|
+
case "records-unsplittable":
|
|
992
|
+
case "unsupported-version":
|
|
993
|
+
case "rule-set-invalid":
|
|
994
|
+
return { ...failure, path: shownPathOf({ ...request, target: failure.path }) };
|
|
995
|
+
case "records-in-both-layouts":
|
|
996
|
+
return {
|
|
997
|
+
...failure,
|
|
998
|
+
path: shownPathOf({ ...request, target: failure.path }),
|
|
999
|
+
folder: shownPathOf({ ...request, target: failure.folder })
|
|
1000
|
+
};
|
|
1001
|
+
case "runner-failed":
|
|
1002
|
+
return { ...failure, failure: shownRunnerFailureOf({ ...request, failure: failure.failure }) };
|
|
1003
|
+
default:
|
|
1004
|
+
return failure;
|
|
1005
|
+
}
|
|
933
1006
|
};
|
|
934
|
-
var stemsShared = (request) => new Map([...request.left].filter(([stem]) => request.right.has(stem)));
|
|
935
|
-
var stemsWithout = (request) => new Map([...request.stems].filter(([stem]) => request.excluded.every((excluded) => !excluded.has(stem))));
|
|
936
|
-
var wordsOf = (request) => [...request.stems.values()];
|
|
937
1007
|
|
|
938
|
-
// core/
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
];
|
|
948
|
-
var RESTATEMENT_OPENING = new RegExp(
|
|
949
|
-
String.raw`^(?:because\s+(?:of\s+)?)?(?:${RESTATEMENT_PHRASES.join("|")})\b`,
|
|
950
|
-
"i"
|
|
951
|
-
);
|
|
952
|
-
var MINIMUM_ANSWER_CHARACTERS = 12;
|
|
953
|
-
var MINIMUM_OWNER_CHARACTERS = 2;
|
|
954
|
-
var MINIMUM_SYMPTOM_STEMS_NAMED = 2;
|
|
955
|
-
var MINIMUM_NEW_STEM_SHARE = 0.25;
|
|
956
|
-
var ONE_REPEATED_CHARACTER = /^(.)\1+$/;
|
|
957
|
-
var PROSE_LOOKALIKES = /\b(?:e\.g\b\.?|i\.e\b\.?|a\.k\.a\.|etc\.|[ap]\.m\.)|(?<![\w./\\-])(?:and\/or|n\/a|w\/o|yes\/no)(?![\w./\\-])/gi;
|
|
958
|
-
var CHECKABLE_LOCATORS = [
|
|
959
|
-
/https?:\/\/\S/i,
|
|
960
|
-
/[\w.-][\\/][\w.-]/,
|
|
961
|
-
/(?:^|[\s(\x60'"])(?:\*|[\w-]+)(?:\.[\w-]+)*\.[a-z][a-z0-9]{0,9}\b/,
|
|
962
|
-
/(?:^|[\s(\x60'"])\.[a-z][\w-]+\b/,
|
|
963
|
-
/\d/
|
|
964
|
-
];
|
|
965
|
-
var THEREFORE = /\btherefore\b/i;
|
|
966
|
-
var rootCauseReading = (request) => RESTATEMENT_OPENING.test(request.rootCause.trim()) ? "restates-the-exception" : "names-a-cause";
|
|
967
|
-
var answerSubstance = (request) => request.answer.trim().length >= MINIMUM_ANSWER_CHARACTERS && !ONE_REPEATED_CHARACTER.test(request.answer.trim()) ? "substantive" : "placeholder";
|
|
968
|
-
var evidenceReading = (request) => CHECKABLE_LOCATORS.some((locator) => locator.test(request.evidence.replace(PROSE_LOOKALIKES, " "))) ? "checkable" : "unlocated";
|
|
969
|
-
var substantiveTextSchema = (request) => z6.string({ error: request.refusal }).refine((answer) => answerSubstance({ answer }) === "substantive", {
|
|
970
|
-
error: request.refusal
|
|
971
|
-
});
|
|
972
|
-
var checkableTextSchema = (request) => substantiveTextSchema({ refusal: request.missing }).refine((evidence) => evidenceReading({ evidence }) === "checkable", {
|
|
973
|
-
error: request.unlocated
|
|
974
|
-
});
|
|
975
|
-
var WHY_QUESTION_MISSING = "is missing its `why` question";
|
|
976
|
-
var BECAUSE_MISSING = "carries no real `because` answer: a placeholder is an absent answer";
|
|
977
|
-
var EVIDENCE_MISSING = "carries no real `evidence`: cite a command, path, record id, PR, or named ruling";
|
|
978
|
-
var EVIDENCE_UNLOCATED = "carries no checkable `evidence`: cite a path, a line, a record or PR number, a measurement or a link";
|
|
979
|
-
var ROOT_CAUSE_REQUIRED = "`whyChain.rootCause` is required: the fifth why names the cause, not another symptom";
|
|
980
|
-
var ROOT_CHECK_REQUIRED = "`whyChain.rootCheck` is required beside `readback` in a causal chain: name what was run or read today that shows the root still holds, with a path, record, measurement or link";
|
|
981
|
-
var ROOT_CHECK_UNLOCATED = "`whyChain.rootCheck` cites nothing checkable: name the path, record, measurement or link you checked today";
|
|
982
|
-
var READBACK_REQUIRED = '`whyChain.readback` is required beside `rootCheck` in a causal chain: read from the root back to the symptom with "therefore"';
|
|
983
|
-
var OWNER_REQUIRED = "`whyChain.owner` is required: a record dir, a capture id, or the holder of the reserved authority";
|
|
984
|
-
var whyQuestionSchema = z6.string({ error: WHY_QUESTION_MISSING }).refine((question) => question.trim().length > 0, {
|
|
985
|
-
error: WHY_QUESTION_MISSING
|
|
986
|
-
});
|
|
987
|
-
var legacyWhySchema = z6.object(
|
|
988
|
-
{
|
|
989
|
-
why: whyQuestionSchema,
|
|
990
|
-
because: substantiveTextSchema({ refusal: BECAUSE_MISSING }),
|
|
991
|
-
evidence: substantiveTextSchema({ refusal: EVIDENCE_MISSING })
|
|
992
|
-
},
|
|
993
|
-
{ error: "is not a JSON object" }
|
|
994
|
-
);
|
|
995
|
-
var causalWhySchema = z6.object(
|
|
996
|
-
{
|
|
997
|
-
why: whyQuestionSchema,
|
|
998
|
-
because: substantiveTextSchema({ refusal: BECAUSE_MISSING }),
|
|
999
|
-
evidence: checkableTextSchema({ missing: EVIDENCE_MISSING, unlocated: EVIDENCE_UNLOCATED })
|
|
1000
|
-
},
|
|
1001
|
-
{ error: "is not a JSON object" }
|
|
1008
|
+
// core/consumer-selection/clause-settings.ts
|
|
1009
|
+
import { z as z5 } from "zod";
|
|
1010
|
+
var clauseSettingsSchema = z5.record(z5.string(), z5.record(z5.string(), z5.json())).transform(
|
|
1011
|
+
(settings, context) => Object.entries(settings).flatMap(([key, values]) => {
|
|
1012
|
+
const address = clauseAddressSchema.safeParse(key);
|
|
1013
|
+
if (address.success) return [[address.data, values]];
|
|
1014
|
+
context.addIssue({ code: "custom", input: key, path: [key], message: `clauseSettings for ${key}: not a clause address` });
|
|
1015
|
+
return [];
|
|
1016
|
+
})
|
|
1002
1017
|
);
|
|
1003
|
-
var
|
|
1004
|
-
|
|
1005
|
-
})
|
|
1006
|
-
var rootCauseSchema = z6.string({ error: ROOT_CAUSE_REQUIRED }).refine((answer) => answerSubstance({ answer }) === "substantive", {
|
|
1007
|
-
error: ROOT_CAUSE_REQUIRED,
|
|
1008
|
-
abort: true
|
|
1009
|
-
}).refine((rootCause) => rootCauseReading({ rootCause }) === "names-a-cause", {
|
|
1010
|
-
error: "`whyChain.rootCause` restates the exception rather than naming its cause"
|
|
1011
|
-
});
|
|
1012
|
-
var ownerSchema = z6.string({ error: OWNER_REQUIRED }).refine((owner) => owner.trim().length >= MINIMUM_OWNER_CHARACTERS, {
|
|
1013
|
-
error: OWNER_REQUIRED
|
|
1018
|
+
var refusal = (request) => ({
|
|
1019
|
+
outcome: "failed",
|
|
1020
|
+
error: `clauseSettings for ${clauseAddressText({ address: request.address })}: ${request.detail}`
|
|
1014
1021
|
});
|
|
1015
|
-
var
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
{ error: "`whyChain` is not a JSON object" }
|
|
1022
|
-
);
|
|
1023
|
-
var causeNamed = (request) => wordsOf({ stems: request.cause }).join(", ");
|
|
1024
|
-
var symptomProblems = (request) => request.symptom.size === 0 ? [{ path: ["whys", 0, "why"], message: "names no symptom: ask why the exception's own subject happens, naming it" }] : [];
|
|
1025
|
-
var restatementProblems = (request) => request.introduced.flatMap(
|
|
1026
|
-
(cause, position) => cause.size === 0 || cause.size < MINIMUM_NEW_STEM_SHARE * (request.answers[position]?.size ?? 0) ? [
|
|
1027
|
-
{
|
|
1028
|
-
path: ["whys", position, "because"],
|
|
1029
|
-
message: `restates ${position === 0 ? "the symptom" : "the symptom or an earlier answer"}: give the cause behind it, with at least a quarter of its words new to the chain`
|
|
1030
|
-
}
|
|
1031
|
-
] : []
|
|
1032
|
-
);
|
|
1033
|
-
var linkProblems = (request) => request.introduced.slice(0, -1).flatMap(
|
|
1034
|
-
(cause, position) => cause.size > 0 && stemsShared({ left: cause, right: stemsOf({ text: request.whys[position + 1]?.why ?? "" }) }).size === 0 ? [
|
|
1035
|
-
{
|
|
1036
|
-
path: ["whys", position + 1, "why"],
|
|
1037
|
-
message: `does not ask about the cause why ${position + 1}'s answer gave: ask why that answer is true, naming its cause (${causeNamed({ cause })})`
|
|
1038
|
-
}
|
|
1039
|
-
] : []
|
|
1040
|
-
);
|
|
1041
|
-
var rootProblems = (request) => request.fifthCause.size > 0 && stemsShared({ left: request.fifthCause, right: stemsOf({ text: request.rootCause }) }).size === 0 ? [
|
|
1042
|
-
{
|
|
1043
|
-
path: ["rootCause"],
|
|
1044
|
-
message: `\`whyChain.rootCause\` does not name the cause why 5's answer gave: the root is the cause behind that answer (${causeNamed({ cause: request.fifthCause })})`
|
|
1022
|
+
var defaultClauseSettings = (request) => Object.fromEntries(Object.entries(request.declarations).map(([key, declaration]) => [key, declaration.default]));
|
|
1023
|
+
var listed = (request) => request.values.map((choice) => JSON.stringify(choice)).join(", ");
|
|
1024
|
+
var settingRefusalOf = (request) => {
|
|
1025
|
+
const { given, declaration } = request;
|
|
1026
|
+
if (declaration === void 0) {
|
|
1027
|
+
return `its piece takes no ${given.key}; it takes ${Object.keys(request.declarations).join(", ")}`;
|
|
1045
1028
|
}
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
const
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
...root.size > 0 && stemsShared({ left: root, right: readback }).size === 0 ? [`\`whyChain.readback\` must name the root it starts from (${causeNamed({ cause: root })})`] : [],
|
|
1054
|
-
...symptomNamed < Math.min(MINIMUM_SYMPTOM_STEMS_NAMED, request.symptom.size) ? [`\`whyChain.readback\` must name the symptom why 1 asks about (${causeNamed({ cause: request.symptom })})`] : []
|
|
1055
|
-
].map((message) => ({ path: ["readback"], message }));
|
|
1029
|
+
const kind = jsonKindOf({ value: declaration.default });
|
|
1030
|
+
if (jsonKindOf({ value: given.value }) !== kind) return `${given.key} must be ${JSON_KIND_NAMES[kind]}, as its default is`;
|
|
1031
|
+
const choices = declaration.choices;
|
|
1032
|
+
if (choices !== void 0 && !choices.some((choice) => sameJsonValue({ left: choice, right: given.value }) === "same")) {
|
|
1033
|
+
return `${given.key} must be one of ${listed({ values: choices })}`;
|
|
1034
|
+
}
|
|
1035
|
+
return void 0;
|
|
1056
1036
|
};
|
|
1057
|
-
var
|
|
1058
|
-
const
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
const
|
|
1062
|
-
(
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
];
|
|
1037
|
+
var settledClauseSettings = (request) => {
|
|
1038
|
+
const defaults = defaultClauseSettings(request);
|
|
1039
|
+
if (request.given === void 0) return { outcome: "ok", value: defaults };
|
|
1040
|
+
if (Object.keys(request.declarations).length === 0) return refusal({ address: request.address, detail: "its piece takes no settings" });
|
|
1041
|
+
const detail = Object.entries(request.given).map(
|
|
1042
|
+
([key, settingValue]) => settingRefusalOf({
|
|
1043
|
+
given: { key, value: settingValue },
|
|
1044
|
+
declaration: Object.hasOwn(request.declarations, key) ? request.declarations[key] : void 0,
|
|
1045
|
+
declarations: request.declarations
|
|
1046
|
+
})
|
|
1047
|
+
).find((found) => found !== void 0);
|
|
1048
|
+
if (detail !== void 0) return refusal({ address: request.address, detail });
|
|
1049
|
+
return { outcome: "ok", value: { ...defaults, ...request.given } };
|
|
1071
1050
|
};
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1051
|
+
|
|
1052
|
+
// core/values/check-editions.ts
|
|
1053
|
+
import { z as z6 } from "zod";
|
|
1054
|
+
var checkEditionsSchema = z6.enum(["pinned", "latest"]);
|
|
1055
|
+
|
|
1056
|
+
// core/values/file-exception-why-chains.ts
|
|
1057
|
+
import { z as z7 } from "zod";
|
|
1058
|
+
var fileExceptionWhyChainsSchema = z7.enum(["required", "optional"]);
|
|
1059
|
+
|
|
1060
|
+
// core/consumer-selection/consumer-selection.ts
|
|
1061
|
+
import { z as z8 } from "zod";
|
|
1062
|
+
|
|
1063
|
+
// core/consumer-selection/clause-edition.ts
|
|
1064
|
+
var editionPinOf = (request) => {
|
|
1065
|
+
if (request.given === void 0 || !Object.hasOwn(request.given, RESERVED_EDITION_SETTING)) {
|
|
1066
|
+
return { pin: void 0, rest: request.given };
|
|
1067
|
+
}
|
|
1068
|
+
const { [RESERVED_EDITION_SETTING]: pin, ...rest } = request.given;
|
|
1069
|
+
return { pin, rest: Object.keys(rest).length === 0 ? void 0 : rest };
|
|
1070
|
+
};
|
|
1071
|
+
var UNPINNED_EDITIONS = {
|
|
1072
|
+
pinned: (editions) => editions.default,
|
|
1073
|
+
latest: (editions) => editions.latest
|
|
1074
|
+
};
|
|
1075
|
+
var settledClauseEdition = (request) => {
|
|
1076
|
+
if (request.pin === void 0) {
|
|
1077
|
+
return { outcome: "ok", value: UNPINNED_EDITIONS[request.checkEditions](request.editions) };
|
|
1078
|
+
}
|
|
1079
|
+
const pinned = request.editions.declared.find((edition) => edition === request.pin);
|
|
1080
|
+
if (pinned !== void 0) {
|
|
1081
|
+
return { outcome: "ok", value: pinned };
|
|
1082
|
+
}
|
|
1083
|
+
return {
|
|
1084
|
+
outcome: "failed",
|
|
1085
|
+
error: `clauseSettings for ${clauseAddressText({ address: request.address })}: ${RESERVED_EDITION_SETTING} must be one of ${request.editions.declared.map((edition) => JSON.stringify(edition)).join(", ")}`
|
|
1086
|
+
};
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
// core/consumer-selection/consumer-selection.ts
|
|
1090
|
+
var RULE_SET_SUFFIX_SEPARATOR = "-";
|
|
1091
|
+
var CLAUSE_ADDRESS_RULE_SET_SEPARATOR = "/";
|
|
1092
|
+
var LEADING_CURRENT_DIRECTORY = "./";
|
|
1093
|
+
var clauseChoiceSchema = z8.union(
|
|
1094
|
+
[
|
|
1095
|
+
z8.literal(NOT_RUN).transform(() => ({ state: "not-run" })),
|
|
1096
|
+
z8.literal(NOT_ADOPTED).transform(() => ({ state: "not-adopted" })),
|
|
1097
|
+
mechanismIdSchema.transform((mechanism) => ({ state: "run", mechanism }))
|
|
1098
|
+
],
|
|
1099
|
+
{ error: `a clause takes a mechanism id, "${NOT_RUN}" or "${NOT_ADOPTED}"` }
|
|
1100
|
+
);
|
|
1101
|
+
var UNSETTABLE_LISTING_REFUSALS = {
|
|
1102
|
+
unlisted: "clauses does not select it",
|
|
1103
|
+
"not-run": "clauses runs no mechanism for it, so remove its settings",
|
|
1104
|
+
"not-adopted": "clauses does not adopt it, so remove its settings"
|
|
1105
|
+
};
|
|
1106
|
+
var clauseListingOf = (request) => request.clauses.find(([listed2]) => sameClauseAddress({ left: listed2, right: request.address }) === "same")?.[1].state ?? "unlisted";
|
|
1107
|
+
var ruleSetLocationSchema = z8.union([
|
|
1108
|
+
z8.enum([".", LEADING_CURRENT_DIRECTORY]).transform(() => ({ location: "repo-root" })),
|
|
1109
|
+
z8.string().transform(
|
|
1110
|
+
(text) => text.startsWith(LEADING_CURRENT_DIRECTORY) ? text.slice(LEADING_CURRENT_DIRECTORY.length) : text
|
|
1111
|
+
).pipe(repoPathSchema).transform((path) => ({ location: "folder", path }))
|
|
1112
|
+
]);
|
|
1113
|
+
var consumerSelectionFileSchema = z8.strictObject({
|
|
1114
|
+
version: z8.literal(1),
|
|
1115
|
+
ruleSets: z8.record(ruleSetNameSchema, z8.string()).transform((ruleSets) => Object.entries(ruleSets)).pipe(z8.array(z8.tuple([ruleSetNameSchema, ruleSetLocationSchema]))),
|
|
1116
|
+
clauses: z8.record(z8.string(), z8.string()).transform((clauses) => Object.entries(clauses)).pipe(z8.array(z8.tuple([clauseAddressSchema, clauseChoiceSchema]))),
|
|
1117
|
+
exclude: z8.array(
|
|
1118
|
+
brandedRepoPathSchema({
|
|
1119
|
+
text: repoPathTextSchema.refine((excludedPath) => !excludedPath.includes("*"), {
|
|
1120
|
+
error: "an exclude entry is a repository path, not a glob"
|
|
1121
|
+
})
|
|
1122
|
+
})
|
|
1123
|
+
).default([]),
|
|
1124
|
+
eslintConfigLookup: eslintConfigLookupSchema.optional(),
|
|
1125
|
+
eslintConfigRoots: z8.array(
|
|
1126
|
+
brandedRepoPathSchema({
|
|
1127
|
+
text: repoPathTextSchema.refine((rootPath) => !rootPath.includes("*"), {
|
|
1128
|
+
error: "an eslintConfigRoots entry is a repository folder, not a glob"
|
|
1129
|
+
})
|
|
1130
|
+
})
|
|
1131
|
+
).default([]),
|
|
1132
|
+
fileExceptionWhyChains: fileExceptionWhyChainsSchema.default("required"),
|
|
1133
|
+
reportOutput: reportOutputSchema.default("full"),
|
|
1134
|
+
assessment: assessmentSchema.default(DEFAULT_ASSESSMENT),
|
|
1135
|
+
clauseSettings: clauseSettingsSchema.default([]),
|
|
1136
|
+
checkEditions: checkEditionsSchema.default("pinned")
|
|
1137
|
+
}).superRefine((file, context) => {
|
|
1138
|
+
const settingsAddresses = file.clauseSettings.map(([address]) => address);
|
|
1139
|
+
settingsAddresses.flatMap((address) => {
|
|
1140
|
+
const listing = clauseListingOf({ clauses: file.clauses, address });
|
|
1141
|
+
return listing === "run" ? [] : [{ address, listing }];
|
|
1142
|
+
}).forEach(({ address, listing }) => {
|
|
1143
|
+
const text = clauseAddressText({ address });
|
|
1144
|
+
context.addIssue({
|
|
1145
|
+
code: "custom",
|
|
1146
|
+
path: ["clauseSettings", text],
|
|
1147
|
+
message: `clauseSettings for ${text}: ${UNSETTABLE_LISTING_REFUSALS[listing]}`
|
|
1148
|
+
});
|
|
1149
|
+
});
|
|
1150
|
+
settingsAddresses.filter(
|
|
1151
|
+
(address, index) => settingsAddresses.slice(0, index).some((earlier) => sameClauseAddress({ left: earlier, right: address }) === "same")
|
|
1152
|
+
).forEach((address) => {
|
|
1153
|
+
const text = clauseAddressText({ address });
|
|
1154
|
+
context.addIssue({
|
|
1155
|
+
code: "custom",
|
|
1156
|
+
path: ["clauseSettings", text],
|
|
1157
|
+
message: `clauseSettings for ${text}: given twice, also as ${TOOL_RULE_SET}${CLAUSE_ADDRESS_RULE_SET_SEPARATOR}${text}`
|
|
1158
|
+
});
|
|
1084
1159
|
});
|
|
1085
1160
|
});
|
|
1086
|
-
var
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
var exceptionsFileSchema = z7.object({
|
|
1090
|
-
version: z7.literal(1),
|
|
1091
|
-
exceptions: z7.array(
|
|
1092
|
-
z7.discriminatedUnion("kind", [
|
|
1093
|
-
z7.strictObject({
|
|
1094
|
-
kind: z7.literal("authorised-location"),
|
|
1095
|
-
clause: z7.string(),
|
|
1096
|
-
file: z7.string(),
|
|
1097
|
-
reason: z7.string(),
|
|
1098
|
-
whyChain: z7.unknown().optional(),
|
|
1099
|
-
provenance: z7.unknown().optional()
|
|
1100
|
-
}),
|
|
1101
|
-
z7.strictObject({
|
|
1102
|
-
kind: z7.literal("file-carve-out"),
|
|
1103
|
-
clause: z7.string(),
|
|
1104
|
-
file: z7.string(),
|
|
1105
|
-
reason: z7.string(),
|
|
1106
|
-
whyChain: z7.unknown().optional(),
|
|
1107
|
-
provenance: z7.unknown().optional()
|
|
1108
|
-
}),
|
|
1109
|
-
z7.strictObject({
|
|
1110
|
-
kind: z7.literal("clause-wide-carve-out"),
|
|
1111
|
-
clause: z7.string(),
|
|
1112
|
-
reason: z7.string(),
|
|
1113
|
-
whyChain: z7.unknown()
|
|
1114
|
-
})
|
|
1115
|
-
])
|
|
1116
|
-
)
|
|
1117
|
-
});
|
|
1118
|
-
var UNMEASURED_EXCEPTION_BASELINE = { measured: "no", base: { state: "not-given" } };
|
|
1119
|
-
var LEGACY_DIRECTORY_OF = {
|
|
1120
|
-
"inherited-debt": ".constitution-carve-outs",
|
|
1121
|
-
"existing-authorisation": ".constitution-authorised-locations"
|
|
1122
|
-
};
|
|
1123
|
-
var LEGACY_SOURCE = /^(?<directory>[^/#]+)\/(?<stem>cd-[0-9a-z]+)\.json#(?<index>\d+)$/;
|
|
1124
|
-
var legacySourceGroupsSchema = z7.object({
|
|
1125
|
-
directory: z7.enum([LEGACY_DIRECTORY_OF["inherited-debt"], LEGACY_DIRECTORY_OF["existing-authorisation"]]),
|
|
1126
|
-
stem: z7.string(),
|
|
1127
|
-
index: z7.coerce.number().int().nonnegative()
|
|
1128
|
-
});
|
|
1129
|
-
var legacyRecordsSchema = z7.array(z7.looseObject({ files: z7.array(z7.string()) }));
|
|
1130
|
-
var recordedTextSchema = z7.string().refine((text) => text.trim().length > 0, { error: "must not be blank" });
|
|
1131
|
-
var existingAuthorisationProvenanceSchema = z7.strictObject({
|
|
1132
|
-
kind: z7.literal("existing-authorisation"),
|
|
1133
|
-
source: recordedTextSchema,
|
|
1134
|
-
decision: recordedTextSchema.optional()
|
|
1135
|
-
});
|
|
1136
|
-
var inheritedDebtProvenanceSchema = z7.strictObject({
|
|
1137
|
-
kind: z7.literal("inherited-debt"),
|
|
1138
|
-
source: recordedTextSchema,
|
|
1139
|
-
decision: recordedTextSchema
|
|
1161
|
+
var failed = (error) => ({
|
|
1162
|
+
outcome: "failed",
|
|
1163
|
+
error
|
|
1140
1164
|
});
|
|
1141
|
-
var
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
reason: z7.string()
|
|
1146
|
-
};
|
|
1147
|
-
var unjudgedWhyChainSchema = z7.custom((whyChain) => whyChain !== void 0);
|
|
1148
|
-
var reasonOnlyFields = { reason: recordedTextSchema, whyChain: z7.never().optional(), provenance: z7.never().optional() };
|
|
1149
|
-
var chainedAuthorisedLocationSchema = z7.strictObject({ ...authorisedLocationFields, whyChain: unjudgedWhyChainSchema, provenance: existingAuthorisationProvenanceSchema.optional() });
|
|
1150
|
-
var importedAuthorisedLocationSchema = z7.strictObject({ ...authorisedLocationFields, whyChain: z7.never().optional(), provenance: existingAuthorisationProvenanceSchema });
|
|
1151
|
-
var reasonedAuthorisedLocationSchema = z7.strictObject({ ...authorisedLocationFields, ...reasonOnlyFields });
|
|
1152
|
-
var fileCarveOutFields = {
|
|
1153
|
-
kind: z7.literal("file-carve-out"),
|
|
1154
|
-
clause: z7.string(),
|
|
1155
|
-
file: z7.string(),
|
|
1156
|
-
reason: z7.string()
|
|
1157
|
-
};
|
|
1158
|
-
var chainedFileCarveOutSchema = z7.strictObject({ ...fileCarveOutFields, whyChain: unjudgedWhyChainSchema, provenance: inheritedDebtProvenanceSchema.optional() });
|
|
1159
|
-
var importedFileCarveOutSchema = z7.strictObject({ ...fileCarveOutFields, whyChain: z7.never().optional(), provenance: inheritedDebtProvenanceSchema });
|
|
1160
|
-
var reasonedFileCarveOutSchema = z7.strictObject({ ...fileCarveOutFields, ...reasonOnlyFields });
|
|
1161
|
-
var FILE_EVIDENCE_SCHEMAS_OF = {
|
|
1162
|
-
required: {
|
|
1163
|
-
"authorised-location": z7.union([chainedAuthorisedLocationSchema, importedAuthorisedLocationSchema]),
|
|
1164
|
-
"file-carve-out": z7.union([chainedFileCarveOutSchema, importedFileCarveOutSchema])
|
|
1165
|
-
},
|
|
1166
|
-
optional: {
|
|
1167
|
-
"authorised-location": z7.union([chainedAuthorisedLocationSchema, importedAuthorisedLocationSchema, reasonedAuthorisedLocationSchema]),
|
|
1168
|
-
"file-carve-out": z7.union([chainedFileCarveOutSchema, importedFileCarveOutSchema, reasonedFileCarveOutSchema])
|
|
1165
|
+
var ruleSetRootOf = (request) => {
|
|
1166
|
+
const ruleSet = request.ruleSet;
|
|
1167
|
+
if (ruleSet === TOOL_RULE_SET) {
|
|
1168
|
+
return { outcome: "ok", value: request.installRoot };
|
|
1169
1169
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
if (!groups.success) {
|
|
1174
|
-
return "not-legacy-source";
|
|
1170
|
+
const declared = Object.entries(request.ruleSets).find(([name]) => name === ruleSet.name);
|
|
1171
|
+
if (declared === void 0) {
|
|
1172
|
+
return failed({ kind: "unknown-rule-set", name: ruleSet.name });
|
|
1175
1173
|
}
|
|
1176
|
-
const
|
|
1177
|
-
|
|
1178
|
-
};
|
|
1179
|
-
var sameEntry = (request) => JSON.stringify(request.left) === JSON.stringify(request.right) ? "same" : "different";
|
|
1180
|
-
var sameIdentity = (request) => request.entry.kind === request.identity.kind && request.entry.clause === request.identity.clause && request.entry.file === request.identity.file ? "same" : "different";
|
|
1181
|
-
var legacyListing = (request) => {
|
|
1182
|
-
const text = request.sourceTextsAtBase.get(request.source.path);
|
|
1183
|
-
const document = text === void 0 ? void 0 : parsedJson({ text });
|
|
1184
|
-
if (document === void 0 || document.outcome === "failed") {
|
|
1185
|
-
return "not-listed";
|
|
1174
|
+
const location = declared[1];
|
|
1175
|
+
if (location.location === "repo-root") {
|
|
1176
|
+
return { outcome: "ok", value: request.repoRoot };
|
|
1186
1177
|
}
|
|
1187
|
-
const
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
const { baseline } = request;
|
|
1196
|
-
if (baseline.measured === "no") {
|
|
1197
|
-
return { outcome: "ok", value: request.record };
|
|
1178
|
+
const directory = request.path.join({ segments: [request.repoRoot, location.path] });
|
|
1179
|
+
const resolved = request.path.resolve({ path: directory });
|
|
1180
|
+
if (resolved.outcome === "failed") {
|
|
1181
|
+
return failed({
|
|
1182
|
+
kind: "rule-set-invalid",
|
|
1183
|
+
path: directory,
|
|
1184
|
+
detail: `the directory of rule set ${ruleSet.name} resolves to no absolute path`
|
|
1185
|
+
});
|
|
1198
1186
|
}
|
|
1199
|
-
|
|
1200
|
-
|
|
1187
|
+
return { outcome: "ok", value: resolved.value };
|
|
1188
|
+
};
|
|
1189
|
+
var disciplineOf = (request) => {
|
|
1190
|
+
const loaded = request.earlier.find(
|
|
1191
|
+
(earlier) => earlier.ruleSetRoot === request.ruleSetRoot && earlier.discipline.id === request.address.discipline
|
|
1192
|
+
);
|
|
1193
|
+
if (loaded !== void 0) {
|
|
1194
|
+
return { outcome: "ok", value: loaded.discipline };
|
|
1201
1195
|
}
|
|
1202
|
-
|
|
1203
|
-
|
|
1196
|
+
const location = { path: request.path, ruleSetRoot: request.ruleSetRoot, discipline: request.address.discipline };
|
|
1197
|
+
if (request.fileText.exists({ path: disciplineFilePath(location) }) === "absent") {
|
|
1198
|
+
return failed({ kind: "unknown-discipline", address: clauseAddressText({ address: request.address }) });
|
|
1204
1199
|
}
|
|
1205
|
-
|
|
1206
|
-
const listed2 = source !== "not-legacy-source" && source.directory === LEGACY_DIRECTORY_OF[request.provenance.kind] && source.discipline === request.discipline.toUpperCase() && legacyListing({ sourceTextsAtBase: baseline.sourceTextsAtBase, source, file: request.identity.file }) === "listed";
|
|
1207
|
-
return listed2 ? { outcome: "ok", value: request.record } : importRefused({
|
|
1208
|
-
detail: `the record is new since the base revision, and its provenance source ${request.provenance.source} is not an entry at the base revision listing ${request.identity.file} under ${LEGACY_DIRECTORY_OF[request.provenance.kind]}/${request.discipline.toLowerCase()}.json`
|
|
1209
|
-
});
|
|
1210
|
-
};
|
|
1211
|
-
var recordedFile = (request) => {
|
|
1212
|
-
const parsed = repoPathSchema.safeParse(request.file);
|
|
1213
|
-
return parsed.success ? { outcome: "ok", value: parsed.data } : { outcome: "failed", error: { kind: "file-not-repo-path", file: request.file } };
|
|
1200
|
+
return readDisciplineFile({ ...location, fileText: request.fileText });
|
|
1214
1201
|
};
|
|
1215
|
-
var
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1202
|
+
var mechanicalClause = (request) => {
|
|
1203
|
+
const address = clauseAddressText({ address: request.address });
|
|
1204
|
+
const discipline = disciplineOf(request);
|
|
1205
|
+
if (discipline.outcome === "failed") {
|
|
1206
|
+
return discipline;
|
|
1219
1207
|
}
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
outcome: "failed",
|
|
1224
|
-
error: { kind: "why-chain-refused", detail: request.detail }
|
|
1225
|
-
});
|
|
1226
|
-
var causalChainOf = (request) => {
|
|
1227
|
-
const parsed = whyChainSchema.safeParse(request.whyChain);
|
|
1228
|
-
return parsed.success ? { outcome: "ok", value: parsed.data } : chainRefused({ detail: [...request.preface, z7.prettifyError(parsed.error)].join("\n") });
|
|
1229
|
-
};
|
|
1230
|
-
var legacyChainOf = (request) => {
|
|
1231
|
-
const parsed = legacyWhyChainSchema.safeParse(request.whyChain);
|
|
1232
|
-
return parsed.success ? { outcome: "ok", value: parsed.data } : chainRefused({ detail: z7.prettifyError(parsed.error) });
|
|
1233
|
-
};
|
|
1234
|
-
var judgedWhyChain = (request) => {
|
|
1235
|
-
if (whyChainFormOf({ chain: request.whyChain }) === "causal") {
|
|
1236
|
-
return causalChainOf({ whyChain: request.whyChain, preface: [] });
|
|
1208
|
+
const definition = discipline.value.clauses.find((clause) => clause.id === request.address.clause);
|
|
1209
|
+
if (definition === void 0) {
|
|
1210
|
+
return failed({ kind: "unknown-clause", address });
|
|
1237
1211
|
}
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
case "base-unmeasured":
|
|
1241
|
-
return legacyChainOf(request);
|
|
1242
|
-
case "new-or-edited":
|
|
1243
|
-
return causalChainOf({ whyChain: request.whyChain, preface: [LEGACY_CHAIN_NEW_OR_EDITED] });
|
|
1212
|
+
if (definition.kind === "judgement") {
|
|
1213
|
+
return failed({ kind: request.judgementRefusal, address });
|
|
1244
1214
|
}
|
|
1215
|
+
return { outcome: "ok", value: { discipline: discipline.value, definition } };
|
|
1245
1216
|
};
|
|
1246
|
-
var
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
([, addresses]) => addresses.some((address) => sameClauseAddress({ left: address, right: request.clause }) === "same")
|
|
1251
|
-
)?.[0] ?? "clause-not-selected";
|
|
1252
|
-
var selectedClauseOf = (request) => {
|
|
1253
|
-
const address = clauseAddressSchema.safeParse(request.entry.clause);
|
|
1254
|
-
if (!address.success) {
|
|
1255
|
-
return {
|
|
1256
|
-
outcome: "failed",
|
|
1257
|
-
error: { kind: "clause-unparseable", detail: z7.prettifyError(address.error) }
|
|
1258
|
-
};
|
|
1217
|
+
var definedClause = (request) => {
|
|
1218
|
+
const defined = mechanicalClause({ ...request, judgementRefusal: "judgement-clause-selected" });
|
|
1219
|
+
if (defined.outcome === "failed") {
|
|
1220
|
+
return defined;
|
|
1259
1221
|
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1222
|
+
if (!defined.value.definition.mechanisms.includes(request.mechanism)) {
|
|
1223
|
+
return failed({ kind: "mechanism-not-allowed", address: clauseAddressText({ address: request.address }), mechanism: request.mechanism });
|
|
1224
|
+
}
|
|
1225
|
+
return defined;
|
|
1226
|
+
};
|
|
1227
|
+
var pieceOf = (request) => {
|
|
1228
|
+
const loaded = request.earlier.find(
|
|
1229
|
+
(earlier) => earlier.ruleSetRoot === request.ruleSetRoot && earlier.discipline.id === request.address.discipline && earlier.binding.mechanism === request.mechanism
|
|
1263
1230
|
);
|
|
1264
|
-
if (
|
|
1265
|
-
return { outcome: "
|
|
1231
|
+
if (loaded !== void 0) {
|
|
1232
|
+
return { outcome: "ok", value: loaded.piece };
|
|
1266
1233
|
}
|
|
1267
|
-
|
|
1268
|
-
|
|
1234
|
+
const location = {
|
|
1235
|
+
path: request.path,
|
|
1236
|
+
ruleSetRoot: request.ruleSetRoot,
|
|
1237
|
+
discipline: request.address.discipline,
|
|
1238
|
+
mechanism: request.mechanism
|
|
1239
|
+
};
|
|
1240
|
+
if (request.fileText.exists({ path: pieceFilePath(location) }) === "absent") {
|
|
1241
|
+
return failed({
|
|
1242
|
+
kind: "piece-missing",
|
|
1243
|
+
address: clauseAddressText({ address: request.address }),
|
|
1244
|
+
mechanism: request.mechanism
|
|
1245
|
+
});
|
|
1269
1246
|
}
|
|
1270
|
-
return {
|
|
1247
|
+
return readPieceFile({ ...location, fileText: request.fileText, discipline: request.discipline });
|
|
1271
1248
|
};
|
|
1272
|
-
var
|
|
1273
|
-
const
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1249
|
+
var pieceEntry = (request) => {
|
|
1250
|
+
const runnerPath = request.path.join({
|
|
1251
|
+
segments: runnerModuleSegmentsOf({ installRoot: request.installRoot, mechanism: request.mechanism, moduleExtension: request.moduleExtension })
|
|
1252
|
+
});
|
|
1253
|
+
if (request.fileText.exists({ path: runnerPath }) === "absent") {
|
|
1254
|
+
return failed({ kind: "runner-missing", mechanism: request.mechanism });
|
|
1277
1255
|
}
|
|
1278
|
-
|
|
1279
|
-
|
|
1256
|
+
const piece = pieceOf(request);
|
|
1257
|
+
if (piece.outcome === "failed") {
|
|
1258
|
+
return piece;
|
|
1280
1259
|
}
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
});
|
|
1289
|
-
};
|
|
1290
|
-
var parsedRecord = (request) => {
|
|
1291
|
-
const { entry } = request;
|
|
1292
|
-
const selected = selectedClauseOf(request);
|
|
1293
|
-
if (selected.outcome === "failed") {
|
|
1294
|
-
return selected;
|
|
1260
|
+
const entry = piece.value.clauses.find((candidate) => candidate.clause === request.address.clause);
|
|
1261
|
+
if (entry === void 0) {
|
|
1262
|
+
return failed({
|
|
1263
|
+
kind: "piece-missing",
|
|
1264
|
+
address: clauseAddressText({ address: request.address }),
|
|
1265
|
+
mechanism: request.mechanism
|
|
1266
|
+
});
|
|
1295
1267
|
}
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1268
|
+
return { outcome: "ok", value: { piece: piece.value, settings: entry.settings, declarations: entry.clauseSettings, editions: entry.editions } };
|
|
1269
|
+
};
|
|
1270
|
+
var resolvedClauseOf = (request) => {
|
|
1271
|
+
const { clauseRequest, defined, entry } = request;
|
|
1272
|
+
return {
|
|
1273
|
+
ruleSetRoot: clauseRequest.ruleSetRoot,
|
|
1274
|
+
discipline: defined.discipline,
|
|
1275
|
+
piece: entry.piece,
|
|
1276
|
+
exceptions: defined.definition.exceptions,
|
|
1277
|
+
declarations: entry.declarations,
|
|
1278
|
+
editions: entry.editions,
|
|
1279
|
+
binding: {
|
|
1280
|
+
mechanism: clauseRequest.mechanism,
|
|
1281
|
+
clause: {
|
|
1282
|
+
address: clauseRequest.address,
|
|
1283
|
+
anchor: defined.definition.anchor,
|
|
1284
|
+
pieceRoot: clauseRequest.path.join({
|
|
1285
|
+
segments: [clauseRequest.ruleSetRoot, "mechanisms", clauseRequest.mechanism, clauseRequest.address.discipline]
|
|
1286
|
+
}),
|
|
1287
|
+
settings: entry.settings,
|
|
1288
|
+
clauseSettings: defaultClauseSettings({ declarations: entry.declarations }),
|
|
1289
|
+
edition: entry.editions.default
|
|
1318
1290
|
}
|
|
1319
|
-
return {
|
|
1320
|
-
outcome: "ok",
|
|
1321
|
-
value: { kind: entry.kind, clause, mechanism, reason: entry.reason, whyChain: whyChain.value }
|
|
1322
|
-
};
|
|
1323
1291
|
}
|
|
1324
|
-
}
|
|
1292
|
+
};
|
|
1325
1293
|
};
|
|
1326
|
-
var
|
|
1327
|
-
const {
|
|
1328
|
-
if (
|
|
1329
|
-
return
|
|
1294
|
+
var resolveClause = (request) => {
|
|
1295
|
+
const root = ruleSetRootOf({ ...request, ruleSet: request.address.ruleSet, ruleSets: Object.fromEntries(request.ruleSets) });
|
|
1296
|
+
if (root.outcome === "failed") {
|
|
1297
|
+
return root;
|
|
1330
1298
|
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
case "file-carve-out":
|
|
1336
|
-
return right.kind !== "clause-wide-carve-out" && left.file === right.file ? "same-identity" : "different-identity";
|
|
1299
|
+
const clauseRequest = { ...request, ruleSetRoot: root.value };
|
|
1300
|
+
const defined = definedClause(clauseRequest);
|
|
1301
|
+
if (defined.outcome === "failed") {
|
|
1302
|
+
return defined;
|
|
1337
1303
|
}
|
|
1304
|
+
const entry = pieceEntry({ ...clauseRequest, discipline: defined.value.discipline });
|
|
1305
|
+
if (entry.outcome === "failed") {
|
|
1306
|
+
return entry;
|
|
1307
|
+
}
|
|
1308
|
+
return { outcome: "ok", value: resolvedClauseOf({ clauseRequest, defined: defined.value, entry: entry.value }) };
|
|
1338
1309
|
};
|
|
1339
|
-
var
|
|
1340
|
-
|
|
1310
|
+
var addressOf = (request) => request.resolved.binding.clause.address;
|
|
1311
|
+
var occurrenceInDiscipline = (request) => {
|
|
1312
|
+
const address = request.clause.address;
|
|
1313
|
+
const firstIndex = request.listed.findIndex(
|
|
1314
|
+
(earlier) => sameClauseAddress({ left: { ...earlier.address, clause: address.clause }, right: address }) === "same"
|
|
1315
|
+
);
|
|
1316
|
+
return firstIndex === request.index ? "first" : "repeat";
|
|
1317
|
+
};
|
|
1318
|
+
var listingOf = (request) => request.listed.some((listed2) => sameClauseAddress({ left: listed2.address, right: request.address }) === "same") ? "listed" : "unlisted";
|
|
1319
|
+
var unlistedClausesOf = (request) => request.representative.discipline.clauses.filter((definition) => definition.kind === "mechanical").map((definition) => ({ ...request.representative.address, clause: definition.id })).filter((address) => listingOf({ listed: request.listed, address }) === "unlisted");
|
|
1320
|
+
var uncoveredClauses = (request) => request.listed.filter((clause, index) => occurrenceInDiscipline({ listed: request.listed, clause, index }) === "first").flatMap((representative) => unlistedClausesOf({ listed: request.listed, representative }));
|
|
1321
|
+
var adoptedEntries = (request) => request.file.clauses.flatMap(
|
|
1322
|
+
([address, choice]) => choice.state === "run" ? [[address, choice.mechanism]] : []
|
|
1341
1323
|
);
|
|
1342
|
-
var
|
|
1343
|
-
(
|
|
1324
|
+
var unrunEntries = (request) => request.file.clauses.flatMap(
|
|
1325
|
+
([address, choice]) => choice.state === "run" ? [] : [[address, choice.state]]
|
|
1344
1326
|
);
|
|
1345
|
-
var
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1327
|
+
var resolvedClauses = (request) => adoptedEntries(request).reduce(
|
|
1328
|
+
(sofar, [address, mechanism]) => appendedClause({
|
|
1329
|
+
sofar,
|
|
1330
|
+
resolve: ({ earlier }) => resolveClause({ ...request, ruleSets: request.file.ruleSets, address, mechanism, earlier })
|
|
1331
|
+
}),
|
|
1332
|
+
{ outcome: "ok", value: [] }
|
|
1333
|
+
);
|
|
1334
|
+
var unrunClause = (request) => {
|
|
1335
|
+
const root = ruleSetRootOf({
|
|
1336
|
+
...request,
|
|
1337
|
+
ruleSet: request.address.ruleSet,
|
|
1338
|
+
ruleSets: Object.fromEntries(request.file.ruleSets)
|
|
1339
|
+
});
|
|
1340
|
+
if (root.outcome === "failed") {
|
|
1341
|
+
return root;
|
|
1353
1342
|
}
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
(entry, index) => ({
|
|
1362
|
-
index,
|
|
1363
|
-
record: parsedRecord({ entry, selection: request.selection, baseline: request.baseline, fileEvidence })
|
|
1364
|
-
})
|
|
1365
|
-
);
|
|
1366
|
-
const valid = validRecordsOf({ parsed });
|
|
1367
|
-
return { records: firstRecordsOf({ valid }), invalid: invalidRecordsOf({ parsed, valid }) };
|
|
1343
|
+
const defined = mechanicalClause({
|
|
1344
|
+
...request,
|
|
1345
|
+
ruleSetRoot: root.value,
|
|
1346
|
+
earlier: request.adopted,
|
|
1347
|
+
judgementRefusal: "judgement-clause-listed"
|
|
1348
|
+
});
|
|
1349
|
+
return defined.outcome === "failed" ? defined : { outcome: "ok", value: { discipline: defined.value.discipline, address: request.address, state: request.state } };
|
|
1368
1350
|
};
|
|
1369
|
-
var
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1351
|
+
var unrunClauses = (request) => unrunEntries(request).reduce(
|
|
1352
|
+
(sofar, [address, state]) => appendedClause({ sofar, resolve: () => unrunClause({ ...request, address, state }) }),
|
|
1353
|
+
{ outcome: "ok", value: [] }
|
|
1354
|
+
);
|
|
1355
|
+
var addressesIn = (request) => request.unrun.filter((clause) => clause.state === request.state).map((clause) => clause.address);
|
|
1356
|
+
var appendedClause = (request) => {
|
|
1357
|
+
if (request.sofar.outcome === "failed") {
|
|
1358
|
+
return request.sofar;
|
|
1359
|
+
}
|
|
1360
|
+
const clause = request.resolve({ earlier: request.sofar.value });
|
|
1361
|
+
if (clause.outcome === "failed") {
|
|
1362
|
+
return clause;
|
|
1373
1363
|
}
|
|
1374
|
-
|
|
1364
|
+
return { outcome: "ok", value: [...request.sofar.value, clause.value] };
|
|
1365
|
+
};
|
|
1366
|
+
var parsedSelectionFile = (request) => {
|
|
1367
|
+
const document = readVersionOneJson(request);
|
|
1375
1368
|
if (document.outcome === "failed") {
|
|
1376
1369
|
return document;
|
|
1377
1370
|
}
|
|
1378
|
-
const parsed =
|
|
1371
|
+
const parsed = consumerSelectionFileSchema.safeParse(document.value);
|
|
1379
1372
|
if (!parsed.success) {
|
|
1380
|
-
return {
|
|
1381
|
-
outcome: "failed",
|
|
1382
|
-
error: { kind: "file-malformed", path, detail: z7.prettifyError(parsed.error) }
|
|
1383
|
-
};
|
|
1373
|
+
return failed({ kind: "file-malformed", path: request.path, detail: z8.prettifyError(parsed.error) });
|
|
1384
1374
|
}
|
|
1385
|
-
|
|
1375
|
+
const refusal2 = selectionFileRefusalOf({ file: parsed.data });
|
|
1376
|
+
return refusal2 === void 0 ? { outcome: "ok", value: parsed.data } : failed(refusal2);
|
|
1386
1377
|
};
|
|
1387
|
-
var
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
return importedFileCarveOutSchema.safeParse(request.entry);
|
|
1393
|
-
case "clause-wide-carve-out":
|
|
1394
|
-
return void 0;
|
|
1395
|
-
}
|
|
1378
|
+
var reservedRuleSetNameRefusalOf = (request) => {
|
|
1379
|
+
const reserved = request.file.ruleSets.find(
|
|
1380
|
+
([name]) => name === TOOL_RULE_SET || name.startsWith(`${TOOL_RULE_SET}${RULE_SET_SUFFIX_SEPARATOR}`)
|
|
1381
|
+
);
|
|
1382
|
+
return reserved === void 0 ? void 0 : { kind: "reserved-rule-set-name", name: reserved[0] };
|
|
1396
1383
|
};
|
|
1397
|
-
var
|
|
1398
|
-
const
|
|
1399
|
-
|
|
1400
|
-
|
|
1384
|
+
var ruleSetNameCollisionRefusalOf = (request) => {
|
|
1385
|
+
const names = request.file.ruleSets.map(([name]) => name);
|
|
1386
|
+
const collisions = names.flatMap(
|
|
1387
|
+
(name) => names.filter((candidate) => candidate.startsWith(`${name}${RULE_SET_SUFFIX_SEPARATOR}`)).map((other) => ({ kind: "rule-set-name-collision", name, other }))
|
|
1388
|
+
);
|
|
1389
|
+
return collisions[0];
|
|
1390
|
+
};
|
|
1391
|
+
var duplicateClauseRefusalOf = (request) => {
|
|
1392
|
+
const addresses = request.file.clauses.map(([address2]) => address2);
|
|
1393
|
+
const repeated = addresses.find(
|
|
1394
|
+
(address2, index) => addresses.slice(0, index).some((earlier) => sameClauseAddress({ left: earlier, right: address2 }) === "same")
|
|
1395
|
+
);
|
|
1396
|
+
if (repeated === void 0) {
|
|
1397
|
+
return void 0;
|
|
1401
1398
|
}
|
|
1402
|
-
|
|
1399
|
+
const address = clauseAddressText({ address: repeated });
|
|
1400
|
+
return { kind: "duplicate-clause", address, prefixedAddress: `${TOOL_RULE_SET}${CLAUSE_ADDRESS_RULE_SET_SEPARATOR}${address}` };
|
|
1403
1401
|
};
|
|
1404
|
-
var
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1402
|
+
var selectionFileRefusalOf = (request) => reservedRuleSetNameRefusalOf(request) ?? ruleSetNameCollisionRefusalOf(request) ?? duplicateClauseRefusalOf(request);
|
|
1403
|
+
var editionReadingsOf = (request) => request.resolved.filter(({ editions }) => editions.declared.length > 1).map(({ binding, editions }) => ({
|
|
1404
|
+
address: binding.clause.address,
|
|
1405
|
+
mechanism: binding.mechanism,
|
|
1406
|
+
edition: binding.clause.edition,
|
|
1407
|
+
latest: editions.latest
|
|
1408
|
+
}));
|
|
1409
|
+
var selectionReadingOf = (request) => ({
|
|
1410
|
+
selection: {
|
|
1411
|
+
selected: request.resolved.map(({ binding, exceptions }) => ({
|
|
1412
|
+
address: binding.clause.address,
|
|
1413
|
+
mechanism: binding.mechanism,
|
|
1414
|
+
exceptions
|
|
1415
|
+
})),
|
|
1416
|
+
uncovered: uncoveredClauses({
|
|
1417
|
+
listed: [
|
|
1418
|
+
...request.resolved.map((resolved) => ({ discipline: resolved.discipline, address: addressOf({ resolved }) })),
|
|
1419
|
+
...request.unrun
|
|
1420
|
+
]
|
|
1421
|
+
}),
|
|
1422
|
+
notAdopted: addressesIn({ unrun: request.unrun, state: "not-adopted" }),
|
|
1423
|
+
notRun: addressesIn({ unrun: request.unrun, state: "not-run" }),
|
|
1424
|
+
editions: editionReadingsOf({ resolved: request.resolved })
|
|
1425
|
+
},
|
|
1426
|
+
bindings: request.resolved.map(({ binding }) => binding),
|
|
1427
|
+
clauseRoots: request.resolved.map((resolved) => ({ clause: addressOf({ resolved }), ruleSetRoot: resolved.ruleSetRoot })),
|
|
1428
|
+
excluded: request.file.exclude,
|
|
1429
|
+
eslintConfigRoots: request.file.eslintConfigRoots,
|
|
1430
|
+
fileExceptionWhyChains: request.file.fileExceptionWhyChains
|
|
1431
|
+
});
|
|
1432
|
+
var givenClauseSettings = (request) => request.file.clauseSettings.find(([address]) => sameClauseAddress({ left: address, right: request.address }) === "same")?.[1];
|
|
1433
|
+
var settledClause = (request) => {
|
|
1434
|
+
const address = addressOf({ resolved: request.clause });
|
|
1435
|
+
const { pin, rest } = editionPinOf({ given: givenClauseSettings({ file: request.file, address }) });
|
|
1436
|
+
const edition = settledClauseEdition({ address, editions: request.clause.editions, pin, checkEditions: request.file.checkEditions });
|
|
1437
|
+
if (edition.outcome === "failed") {
|
|
1438
|
+
return failed({ kind: "file-malformed", path: request.path, detail: edition.error });
|
|
1408
1439
|
}
|
|
1409
|
-
|
|
1440
|
+
const clauseSettings = settledClauseSettings({ address, declarations: request.clause.declarations, given: rest });
|
|
1441
|
+
if (clauseSettings.outcome === "failed") {
|
|
1442
|
+
return failed({ kind: "file-malformed", path: request.path, detail: clauseSettings.error });
|
|
1443
|
+
}
|
|
1444
|
+
const { binding } = request.clause;
|
|
1445
|
+
return {
|
|
1446
|
+
outcome: "ok",
|
|
1447
|
+
value: {
|
|
1448
|
+
...request.clause,
|
|
1449
|
+
binding: { ...binding, clause: { ...binding.clause, clauseSettings: clauseSettings.value, edition: edition.value } }
|
|
1450
|
+
}
|
|
1451
|
+
};
|
|
1410
1452
|
};
|
|
1411
|
-
var
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1453
|
+
var withClauseSettings = (request) => request.resolved.reduce(
|
|
1454
|
+
(sofar, clause) => appendedClause({ sofar, resolve: () => settledClause({ clause, file: request.file, path: request.path }) }),
|
|
1455
|
+
{ outcome: "ok", value: [] }
|
|
1456
|
+
);
|
|
1457
|
+
var selectionFilePath = (request) => request.path.join({ segments: [request.repoRoot, "disciplines.json"] });
|
|
1458
|
+
var readRunSettings = (request) => {
|
|
1459
|
+
const file = parsedSelectionFile({ fileText: request.fileText, path: selectionFilePath(request) });
|
|
1460
|
+
if (file.outcome === "failed") {
|
|
1461
|
+
return file;
|
|
1415
1462
|
}
|
|
1416
|
-
|
|
1417
|
-
return source === "not-legacy-source" ? [] : [source.path];
|
|
1463
|
+
return { outcome: "ok", value: { reportOutput: file.value.reportOutput, assessment: file.value.assessment } };
|
|
1418
1464
|
};
|
|
1419
|
-
var
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1465
|
+
var readSelection = (request) => {
|
|
1466
|
+
const file = parsedSelectionFile({ fileText: request.fileText, path: selectionFilePath(request) });
|
|
1467
|
+
if (file.outcome === "failed") {
|
|
1468
|
+
return file;
|
|
1469
|
+
}
|
|
1470
|
+
const resolved = resolvedClauses({ ...request, file: file.value });
|
|
1471
|
+
if (resolved.outcome === "failed") {
|
|
1472
|
+
return resolved;
|
|
1473
|
+
}
|
|
1474
|
+
const settled = withClauseSettings({ resolved: resolved.value, file: file.value, path: selectionFilePath(request) });
|
|
1475
|
+
if (settled.outcome === "failed") {
|
|
1476
|
+
return settled;
|
|
1477
|
+
}
|
|
1478
|
+
const unrun = unrunClauses({ ...request, file: file.value, adopted: settled.value });
|
|
1479
|
+
if (unrun.outcome === "failed") {
|
|
1480
|
+
return unrun;
|
|
1426
1481
|
}
|
|
1427
|
-
|
|
1428
|
-
return parsed.success ? parsed.data.exceptions : [];
|
|
1482
|
+
return { outcome: "ok", value: selectionReadingOf({ resolved: settled.value, unrun: unrun.value, file: file.value }) };
|
|
1429
1483
|
};
|
|
1430
1484
|
|
|
1485
|
+
// core/check/run-check.ts
|
|
1486
|
+
import { z as z13 } from "zod";
|
|
1487
|
+
|
|
1431
1488
|
// core/governance/governance.ts
|
|
1432
1489
|
var clauseKey = (request) => clauseAddressText({ address: request.clause });
|
|
1433
1490
|
var clauseFileKey = (request) => `${clauseKey({ clause: request.clause })} ${request.file}`;
|
|
@@ -1538,24 +1595,24 @@ var applyGovernance = (request) => {
|
|
|
1538
1595
|
};
|
|
1539
1596
|
|
|
1540
1597
|
// core/mechanism-port/runner-module-schema.ts
|
|
1541
|
-
import { z as
|
|
1542
|
-
var runnerCallSchema =
|
|
1543
|
-
input: [
|
|
1544
|
-
output:
|
|
1598
|
+
import { z as z9 } from "zod";
|
|
1599
|
+
var runnerCallSchema = z9.function({
|
|
1600
|
+
input: [z9.unknown()],
|
|
1601
|
+
output: z9.promise(z9.unknown())
|
|
1545
1602
|
});
|
|
1546
|
-
var standaloneRunnerModuleSchema =
|
|
1547
|
-
exceptionPath:
|
|
1603
|
+
var standaloneRunnerModuleSchema = z9.object({
|
|
1604
|
+
exceptionPath: z9.literal("standalone"),
|
|
1548
1605
|
run: runnerCallSchema,
|
|
1549
1606
|
conform: runnerCallSchema
|
|
1550
1607
|
});
|
|
1551
|
-
var embeddedRunnerModuleSchema =
|
|
1552
|
-
exceptionPath:
|
|
1553
|
-
projectedKinds:
|
|
1608
|
+
var embeddedRunnerModuleSchema = z9.object({
|
|
1609
|
+
exceptionPath: z9.literal("embedded"),
|
|
1610
|
+
projectedKinds: z9.array(nativeExceptionKindSchema),
|
|
1554
1611
|
run: runnerCallSchema,
|
|
1555
1612
|
conform: runnerCallSchema,
|
|
1556
1613
|
project: runnerCallSchema
|
|
1557
1614
|
});
|
|
1558
|
-
var runnerModuleSchema =
|
|
1615
|
+
var runnerModuleSchema = z9.discriminatedUnion("exceptionPath", [
|
|
1559
1616
|
standaloneRunnerModuleSchema,
|
|
1560
1617
|
embeddedRunnerModuleSchema
|
|
1561
1618
|
]);
|
|
@@ -1651,63 +1708,63 @@ var clauseReadingsOf = (request) => {
|
|
|
1651
1708
|
};
|
|
1652
1709
|
|
|
1653
1710
|
// core/check/mechanism-dispatch.ts
|
|
1654
|
-
import { z as
|
|
1711
|
+
import { z as z12 } from "zod";
|
|
1655
1712
|
|
|
1656
1713
|
// core/mechanism-port/embedded-run-report-schema.ts
|
|
1657
|
-
import { z as
|
|
1658
|
-
var inlineLineSchema =
|
|
1659
|
-
var inlineDisableSchema =
|
|
1660
|
-
kind:
|
|
1714
|
+
import { z as z10 } from "zod";
|
|
1715
|
+
var inlineLineSchema = z10.number().int().min(1);
|
|
1716
|
+
var inlineDisableSchema = z10.object({
|
|
1717
|
+
kind: z10.literal("inline-disable"),
|
|
1661
1718
|
clause: clauseAddressObjectSchema,
|
|
1662
1719
|
file: repoPathSchema,
|
|
1663
1720
|
line: inlineLineSchema,
|
|
1664
|
-
text:
|
|
1665
|
-
reach:
|
|
1721
|
+
text: z10.string(),
|
|
1722
|
+
reach: z10.enum(["one-clause", "every-selected-clause"])
|
|
1666
1723
|
}).readonly();
|
|
1667
|
-
var scriptOptionCauseSchema =
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1724
|
+
var scriptOptionCauseSchema = z10.discriminatedUnion("kind", [
|
|
1725
|
+
z10.object({ kind: z10.literal("weakens-run") }).readonly(),
|
|
1726
|
+
z10.object({ kind: z10.literal("after-another-command"), command: z10.string(), invocation: z10.string() }).readonly(),
|
|
1727
|
+
z10.object({ kind: z10.literal("wrapped"), command: z10.string(), wrapper: z10.string() }).readonly()
|
|
1671
1728
|
]);
|
|
1672
|
-
var nativeExceptionSchema =
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
kind:
|
|
1729
|
+
var nativeExceptionSchema = z10.discriminatedUnion("kind", [
|
|
1730
|
+
z10.object({ kind: z10.literal("ignore"), clause: clauseAddressObjectSchema, file: repoPathSchema }).readonly(),
|
|
1731
|
+
z10.object({
|
|
1732
|
+
kind: z10.literal("config-override"),
|
|
1676
1733
|
clause: clauseAddressObjectSchema,
|
|
1677
1734
|
file: repoPathSchema
|
|
1678
1735
|
}).readonly(),
|
|
1679
|
-
|
|
1680
|
-
kind:
|
|
1736
|
+
z10.object({
|
|
1737
|
+
kind: z10.literal("suppression-entry"),
|
|
1681
1738
|
clause: clauseAddressObjectSchema,
|
|
1682
1739
|
file: repoPathSchema,
|
|
1683
1740
|
location: repoPathSchema
|
|
1684
1741
|
}).readonly(),
|
|
1685
1742
|
inlineDisableSchema,
|
|
1686
|
-
|
|
1687
|
-
kind:
|
|
1743
|
+
z10.object({
|
|
1744
|
+
kind: z10.literal("inline-rule-config"),
|
|
1688
1745
|
clause: clauseAddressObjectSchema,
|
|
1689
1746
|
file: repoPathSchema,
|
|
1690
1747
|
line: inlineLineSchema,
|
|
1691
|
-
text:
|
|
1748
|
+
text: z10.string()
|
|
1692
1749
|
}).readonly(),
|
|
1693
|
-
|
|
1694
|
-
kind:
|
|
1750
|
+
z10.object({
|
|
1751
|
+
kind: z10.literal("command-line-option"),
|
|
1695
1752
|
clause: clauseAddressObjectSchema,
|
|
1696
1753
|
location: repoPathSchema,
|
|
1697
|
-
script:
|
|
1698
|
-
option:
|
|
1754
|
+
script: z10.string(),
|
|
1755
|
+
option: z10.string(),
|
|
1699
1756
|
cause: scriptOptionCauseSchema
|
|
1700
1757
|
}).readonly()
|
|
1701
1758
|
]);
|
|
1702
|
-
var sliceProblemSchema =
|
|
1759
|
+
var sliceProblemSchema = z10.object({
|
|
1703
1760
|
slice: repoPathSchema,
|
|
1704
|
-
state:
|
|
1761
|
+
state: z10.enum(["out-of-date", "missing", "not-applied", "unconfigured", "nested-configuration"])
|
|
1705
1762
|
}).readonly();
|
|
1706
|
-
var embeddedRunReportSchema =
|
|
1707
|
-
hits:
|
|
1708
|
-
nativeExceptions:
|
|
1709
|
-
projection:
|
|
1710
|
-
slices:
|
|
1763
|
+
var embeddedRunReportSchema = z10.object({
|
|
1764
|
+
hits: z10.array(hitSchema).readonly(),
|
|
1765
|
+
nativeExceptions: z10.array(nativeExceptionSchema).readonly(),
|
|
1766
|
+
projection: z10.enum(["current", "out-of-date", "missing", "not-included"]),
|
|
1767
|
+
slices: z10.array(sliceProblemSchema).readonly().default([])
|
|
1711
1768
|
}).readonly();
|
|
1712
1769
|
|
|
1713
1770
|
// core/mechanism-port/runner-failure.ts
|
|
@@ -1719,12 +1776,12 @@ var thrownMessage = (request) => request.thrown instanceof Error ? request.throw
|
|
|
1719
1776
|
var rejectedCall = (request) => runnerInvalidOutput({ detail: `the runner call threw or rejected: ${thrownMessage(request)}` });
|
|
1720
1777
|
|
|
1721
1778
|
// core/mechanism-port/standalone-run-report-schema.ts
|
|
1722
|
-
import { z as
|
|
1779
|
+
import { z as z11 } from "zod";
|
|
1723
1780
|
var STANDALONE_RUN_SHAPE_MESSAGE = "a standalone run's value is { hits, nativeExceptions }, not a bare list of hits";
|
|
1724
|
-
var standaloneRunReportSchema =
|
|
1781
|
+
var standaloneRunReportSchema = z11.object(
|
|
1725
1782
|
{
|
|
1726
|
-
hits:
|
|
1727
|
-
nativeExceptions:
|
|
1783
|
+
hits: z11.array(hitSchema).readonly(),
|
|
1784
|
+
nativeExceptions: z11.array(inlineDisableSchema).readonly()
|
|
1728
1785
|
},
|
|
1729
1786
|
{ error: STANDALONE_RUN_SHAPE_MESSAGE }
|
|
1730
1787
|
).readonly();
|
|
@@ -1737,14 +1794,14 @@ var unrequestedHit = (request) => request.hits.find(
|
|
|
1737
1794
|
(clause) => sameClauseAddress({ left: clause.address, right: hit.clause }) === "same"
|
|
1738
1795
|
)
|
|
1739
1796
|
);
|
|
1740
|
-
var okOutcomeSchema =
|
|
1741
|
-
var okStandaloneSchema =
|
|
1797
|
+
var okOutcomeSchema = z12.object({ outcome: z12.literal("ok") });
|
|
1798
|
+
var okStandaloneSchema = z12.object({ outcome: z12.literal("ok"), value: standaloneRunReportSchema });
|
|
1742
1799
|
var invalidStandaloneDetail = (request) => {
|
|
1743
1800
|
if (!okOutcomeSchema.safeParse(request.returned).success) {
|
|
1744
|
-
return
|
|
1801
|
+
return z12.prettifyError(request.error);
|
|
1745
1802
|
}
|
|
1746
1803
|
const report = okStandaloneSchema.safeParse(request.returned);
|
|
1747
|
-
return
|
|
1804
|
+
return z12.prettifyError(report.success ? request.error : report.error);
|
|
1748
1805
|
};
|
|
1749
1806
|
var standaloneRun = (request) => {
|
|
1750
1807
|
const parsed = standaloneResultSchema.safeParse(request.returned);
|
|
@@ -1780,7 +1837,7 @@ var standaloneRun = (request) => {
|
|
|
1780
1837
|
};
|
|
1781
1838
|
};
|
|
1782
1839
|
var reportResultSchema = runnerResultSchema({ value: embeddedRunReportSchema });
|
|
1783
|
-
var projectionWriteResultSchema = runnerResultSchema({ value:
|
|
1840
|
+
var projectionWriteResultSchema = runnerResultSchema({ value: z12.array(projectionWriteSchema).readonly() });
|
|
1784
1841
|
var unrequestedNativeException = (request) => request.nativeExceptions.find(
|
|
1785
1842
|
(nativeException) => !request.run.clauses.some(
|
|
1786
1843
|
(clause) => sameClauseAddress({ left: clause.address, right: nativeException.clause }) === "same"
|
|
@@ -1789,7 +1846,7 @@ var unrequestedNativeException = (request) => request.nativeExceptions.find(
|
|
|
1789
1846
|
var embeddedRun = (request) => {
|
|
1790
1847
|
const parsed = reportResultSchema.safeParse(request.returned);
|
|
1791
1848
|
if (!parsed.success) {
|
|
1792
|
-
return runnerInvalidOutput({ detail:
|
|
1849
|
+
return runnerInvalidOutput({ detail: z12.prettifyError(parsed.error) });
|
|
1793
1850
|
}
|
|
1794
1851
|
if (parsed.data.outcome === "failed") {
|
|
1795
1852
|
return parsed.data;
|
|
@@ -1825,7 +1882,7 @@ var embeddedRun = (request) => {
|
|
|
1825
1882
|
var embeddedProjection = (request) => {
|
|
1826
1883
|
const parsed = projectionWriteResultSchema.safeParse(request.returned);
|
|
1827
1884
|
if (!parsed.success) {
|
|
1828
|
-
return runnerInvalidOutput({ detail:
|
|
1885
|
+
return runnerInvalidOutput({ detail: z12.prettifyError(parsed.error) });
|
|
1829
1886
|
}
|
|
1830
1887
|
if (parsed.data.outcome === "failed") {
|
|
1831
1888
|
return parsed.data;
|
|
@@ -1874,8 +1931,7 @@ var projectMechanism = (request) => {
|
|
|
1874
1931
|
|
|
1875
1932
|
// core/check/run-check.ts
|
|
1876
1933
|
var TYPESCRIPT_FILE = /\.(?:ts|tsx|mts|cts)$/;
|
|
1877
|
-
var
|
|
1878
|
-
var runnerExportSchema = z12.object({ runner: runnerModuleSchema });
|
|
1934
|
+
var runnerExportSchema = z13.object({ runner: runnerModuleSchema });
|
|
1879
1935
|
var failed2 = (error) => ({
|
|
1880
1936
|
outcome: "failed",
|
|
1881
1937
|
error
|
|
@@ -1904,7 +1960,7 @@ var loadRunner = async (request) => {
|
|
|
1904
1960
|
}
|
|
1905
1961
|
const parsed = runnerExportSchema.safeParse(loaded.value);
|
|
1906
1962
|
if (!parsed.success) {
|
|
1907
|
-
return failed2({ kind: "runner-invalid", mechanism: request.mechanism, detail:
|
|
1963
|
+
return failed2({ kind: "runner-invalid", mechanism: request.mechanism, detail: z13.prettifyError(parsed.error) });
|
|
1908
1964
|
}
|
|
1909
1965
|
return { outcome: "ok", value: parsed.data.runner };
|
|
1910
1966
|
};
|
|
@@ -1935,11 +1991,11 @@ var loadInputs = async (request) => {
|
|
|
1935
1991
|
if (reading.outcome === "failed") {
|
|
1936
1992
|
return reading;
|
|
1937
1993
|
}
|
|
1938
|
-
const entries =
|
|
1994
|
+
const entries = request.exceptionRepository.read();
|
|
1939
1995
|
if (entries.outcome === "failed") {
|
|
1940
1996
|
return entries;
|
|
1941
1997
|
}
|
|
1942
|
-
const exceptionBaseline = request.exceptionBaselineOf({ entries: entries.value });
|
|
1998
|
+
const exceptionBaseline = request.exceptionBaselineOf({ entries: entries.value.map(({ entry }) => entry) });
|
|
1943
1999
|
const parsed = parseExceptionEntries({
|
|
1944
2000
|
entries: entries.value,
|
|
1945
2001
|
selection: reading.value.selection,
|
|
@@ -2001,20 +2057,15 @@ var exceptionBaselineOf = (request) => {
|
|
|
2001
2057
|
if (baseRevision === void 0 || importedEntriesIn({ entries: request.entries }) === "absent" && legacyChainsIn({ entries: request.entries }) === "absent") {
|
|
2002
2058
|
return UNMEASURED_EXCEPTION_BASELINE;
|
|
2003
2059
|
}
|
|
2004
|
-
const
|
|
2005
|
-
|
|
2006
|
-
baseRevision,
|
|
2007
|
-
|
|
2008
|
-
});
|
|
2060
|
+
const entriesAtBase = request.check.exceptionRepository.readAt({ revision: baseRevision });
|
|
2061
|
+
if (entriesAtBase.outcome === "failed") {
|
|
2062
|
+
return { measured: "no", base: baseRevisionAvailabilityOf({ revision: baseRevision, failure: entriesAtBase.error }) };
|
|
2063
|
+
}
|
|
2064
|
+
const texts = textsInBase({ check: request.check, baseRevision, files: importSourcesOf({ entries: request.entries }) });
|
|
2009
2065
|
if (texts.outcome === "failed") {
|
|
2010
2066
|
return { measured: "no", base: baseRevisionAvailabilityOf({ revision: baseRevision, failure: texts.error }) };
|
|
2011
2067
|
}
|
|
2012
|
-
|
|
2013
|
-
return {
|
|
2014
|
-
measured: "yes",
|
|
2015
|
-
entriesAtBase: exceptionsAtBase === void 0 ? [] : exceptionEntriesOfText({ text: exceptionsAtBase }),
|
|
2016
|
-
sourceTextsAtBase: texts.value
|
|
2017
|
-
};
|
|
2068
|
+
return { measured: "yes", entriesAtBase: entriesAtBase.value, sourceTextsAtBase: texts.value };
|
|
2018
2069
|
};
|
|
2019
2070
|
var projectionOutcome = (request) => {
|
|
2020
2071
|
switch (request.run.projection) {
|
|
@@ -2113,6 +2164,7 @@ var checkReportOf = (request) => {
|
|
|
2113
2164
|
excluded: request.inputs.excluded,
|
|
2114
2165
|
notAdopted: request.inputs.selection.notAdopted,
|
|
2115
2166
|
notRun: request.inputs.selection.notRun,
|
|
2167
|
+
editions: request.inputs.selection.editions,
|
|
2116
2168
|
...governed,
|
|
2117
2169
|
uncovered: request.inputs.selection.uncovered,
|
|
2118
2170
|
invalidRecords: request.inputs.invalidRecords,
|
|
@@ -2159,14 +2211,17 @@ var runCheck = async (request) => {
|
|
|
2159
2211
|
};
|
|
2160
2212
|
|
|
2161
2213
|
export {
|
|
2214
|
+
exceptionEntriesOfDocument,
|
|
2215
|
+
foreignKeysOfDocument,
|
|
2216
|
+
UNMEASURED_EXCEPTION_BASELINE,
|
|
2217
|
+
recordImportOf,
|
|
2218
|
+
exceptionEntriesOfText,
|
|
2162
2219
|
forfeitureAssessmentSchema,
|
|
2163
2220
|
WAIVED_CLAUSES_REPLACEMENT,
|
|
2164
2221
|
removedText,
|
|
2165
2222
|
assessmentInEffect,
|
|
2166
2223
|
reportOutputSchema,
|
|
2167
2224
|
reportOutputInEffect,
|
|
2168
|
-
UNMEASURED_EXCEPTION_BASELINE,
|
|
2169
|
-
recordImportOf,
|
|
2170
2225
|
ASSESSMENT_FILE_NAME,
|
|
2171
2226
|
assessmentSectionHeading,
|
|
2172
2227
|
loadFailureDetail,
|
|
@@ -2178,6 +2233,7 @@ export {
|
|
|
2178
2233
|
shownFailureOf,
|
|
2179
2234
|
defaultClauseSettings,
|
|
2180
2235
|
readRunSettings,
|
|
2236
|
+
readSelection,
|
|
2181
2237
|
runnerInvalidOutput,
|
|
2182
2238
|
rejectedCall,
|
|
2183
2239
|
projectMechanism,
|