@outerlayer/cli 0.37.0-next.20261104233800 → 0.37.0-next.20261105010834
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/dist/build-info.json +1 -1
- package/dist/{check-VOJWXIRZ.js → check-PJ5FLDTD.js} +7 -7
- package/dist/{chunk-SQWYFCEU.js → chunk-4A7D2HWQ.js} +1 -1
- package/dist/{chunk-VNMTA2JE.js → chunk-4TDBM3PK.js} +1 -1
- package/dist/{chunk-LLZG5A2J.js → chunk-77RLQS5V.js} +1 -1
- package/dist/{chunk-3Z5GISKU.js → chunk-KE5NFPP2.js} +111 -12
- package/dist/{chunk-TSYTPW6Y.js → chunk-P2UH4EBF.js} +13 -5
- package/dist/{chunk-ERGU3OZP.js → chunk-Q2JDKHOR.js} +42 -8
- package/dist/{chunk-W6GP4CNN.js → chunk-QK43VKE4.js} +1 -1
- package/dist/{chunk-FX4ZG4E5.js → chunk-XPIFUWWY.js} +1 -1
- package/dist/{chunk-IDYLPN4X.js → chunk-ZEHCE7ZE.js} +1 -1
- package/dist/{cli-FFPFIMPZ.js → cli-K62CS6XW.js} +31 -28
- package/dist/{command-MYYGFCW3.js → command-EG54FHMR.js} +3 -3
- package/dist/{container-start-ICNSSPBS.js → container-start-JBYD2XG4.js} +4 -4
- package/dist/{doctor-LEGPWSQ3.js → doctor-MXWODPPL.js} +4 -4
- package/dist/{host-checks-VGJVO23Y.js → host-checks-RK5TC3TX.js} +2 -2
- package/dist/index.js +1 -1
- package/dist/{init-Z6ZVLUJ5.js → init-CSWMBTTM.js} +2 -2
- package/dist/{init-F3L4CTBJ.js → init-GH74PR4K.js} +2 -2
- package/dist/{init-agent-DO233UTF.js → init-agent-54VT3S3Z.js} +2 -2
- package/dist/{init-cmd-AKIPYTNP.js → init-cmd-AIUYATFU.js} +1 -1
- package/dist/{loop-MUPQOIW6.js → loop-P7NDQS3G.js} +7 -7
- package/dist/{machine-WFZ5KM76.js → machine-UEW4P7I6.js} +2 -2
- package/dist/{runner-key-2SKLS37E.js → runner-key-PNZTLOK5.js} +2 -2
- package/dist/{status-WZCEHCL2.js → status-X7IK4XQU.js} +2 -2
- package/dist/{update-steps-5BGDQTVG.js → update-steps-R7AQAO6R.js} +3 -3
- package/dist/{work-claim-cmd-2IOJVHR5.js → work-claim-cmd-YE4MVGZH.js} +1 -1
- package/dist/{work-proofs-cmd-P33QGSIQ.js → work-proofs-cmd-Y7WZNTI3.js} +2 -2
- package/dist/{work-proofs-record-FN6M7BIZ.js → work-proofs-record-5DCQQT23.js} +66 -8
- package/package.json +1 -1
- package/skill-pack/maintained/outerlayer-build/references/agent-briefs.md +18 -7
- package/skill-pack/maintained/outerlayer-build/references/evidence.md +8 -5
- package/dist/{chunk-6SC66WGJ.js → chunk-BNYBHWYH.js} +172 -172
|
@@ -8,178 +8,6 @@ import { join } from 'path';
|
|
|
8
8
|
import { pathToFileURL } from 'url';
|
|
9
9
|
|
|
10
10
|
createRequire(import.meta.url);
|
|
11
|
-
var ARTIFACT_PROOF_REASON = "Its declared artifact proves it; the judge does not judge artifacts.";
|
|
12
|
-
var NO_NAMED_TEST_REASON = "The judge named no test file that proves this criterion.";
|
|
13
|
-
var NO_VERDICT_REASON = "The judge gave no result for this criterion.";
|
|
14
|
-
var JUDGE_GROUP_SIZE = 12;
|
|
15
|
-
function notReadAsTestReason(paths) {
|
|
16
|
-
const named = paths.slice(0, 3).map((path2) => `\`${path2}\``);
|
|
17
|
-
const list = named.length === 1 ? named[0] : `${named.slice(0, -1).join(", ")} and ${named.at(-1)}`;
|
|
18
|
-
const more = paths.length > 3 ? " and other files" : "";
|
|
19
|
-
const one = paths.length === 1;
|
|
20
|
-
return `The judge named ${list}${more}, which ${one ? "is" : "are"} not read as ${one ? "a test" : "tests"}. If ${one ? "that file holds" : "one of them holds"} the test, name it with a runner glob in \`.outerlayer-proofs.yaml\`.`;
|
|
21
|
-
}
|
|
22
|
-
function treePath(raw, treeRoot) {
|
|
23
|
-
let path2 = raw.trim().replace(/\\/g, "/");
|
|
24
|
-
const root = `${treeRoot.replace(/\/+$/, "")}/`;
|
|
25
|
-
if (path2.startsWith(root)) path2 = path2.slice(root.length);
|
|
26
|
-
while (path2.startsWith("./")) path2 = path2.slice(2);
|
|
27
|
-
if (path2 === "" || path2.length > CHECK_ITEM_REF_PATH_MAX_LENGTH || path2.startsWith("/") || /[\u0000-\u001f\u007f]/.test(path2)) return void 0;
|
|
28
|
-
if (path2.split("/").some((segment) => segment === ".." || segment === "")) return void 0;
|
|
29
|
-
return path2;
|
|
30
|
-
}
|
|
31
|
-
function criterionInputs(input) {
|
|
32
|
-
const hash = createHash("sha256");
|
|
33
|
-
const part = (text) => {
|
|
34
|
-
hash.update(`${Buffer.byteLength(text)}:`);
|
|
35
|
-
hash.update(text);
|
|
36
|
-
};
|
|
37
|
-
part("judge-criterion-v2");
|
|
38
|
-
part(input.brief);
|
|
39
|
-
part(input.criterion.id);
|
|
40
|
-
part(input.criterion.text);
|
|
41
|
-
part(input.criterion.proof ?? "");
|
|
42
|
-
for (const path2 of [...input.files.keys()].sort()) {
|
|
43
|
-
const text = input.files.get(path2);
|
|
44
|
-
part(path2);
|
|
45
|
-
part(text === void 0 ? "missing" : `text:${text}`);
|
|
46
|
-
}
|
|
47
|
-
return hash.digest("hex");
|
|
48
|
-
}
|
|
49
|
-
function refPaths(refs) {
|
|
50
|
-
return [...new Set((refs ?? []).map((ref) => ref.path))].sort();
|
|
51
|
-
}
|
|
52
|
-
function planCriteria(input) {
|
|
53
|
-
const previousById = new Map(input.previous.map((item) => [item.id, item]));
|
|
54
|
-
const settled = [];
|
|
55
|
-
const toJudge = [];
|
|
56
|
-
for (const criterion of input.criteria) {
|
|
57
|
-
const base = { id: criterion.id, criterion: criterion.id };
|
|
58
|
-
if (criterion.proof !== null) {
|
|
59
|
-
settled.push({ ...base, result: "skipped", reason: ARTIFACT_PROOF_REASON });
|
|
60
|
-
continue;
|
|
61
|
-
}
|
|
62
|
-
const kept = previousById.get(criterion.id);
|
|
63
|
-
const paths = refPaths(kept?.refs);
|
|
64
|
-
if (kept !== void 0 && kept.result === "pass" && kept.inputs !== void 0 && paths.length > 0) {
|
|
65
|
-
const inputs = input.inputsFor(criterion, paths);
|
|
66
|
-
if (inputs === kept.inputs) {
|
|
67
|
-
settled.push({ ...base, ...kept.commit === void 0 ? {} : { commit: kept.commit }, result: "pass", ...kept.reason === void 0 ? {} : { reason: kept.reason }, refs: kept.refs, inputs });
|
|
68
|
-
continue;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
toJudge.push(criterion);
|
|
72
|
-
}
|
|
73
|
-
return { settled, toJudge };
|
|
74
|
-
}
|
|
75
|
-
function judgeGroups(criteria, size = JUDGE_GROUP_SIZE) {
|
|
76
|
-
const groups = [];
|
|
77
|
-
for (let start = 0; start < criteria.length; start += size) groups.push(criteria.slice(start, start + size));
|
|
78
|
-
return groups;
|
|
79
|
-
}
|
|
80
|
-
var MAX_ANSWER_ENTRIES = 500;
|
|
81
|
-
var MAX_NAMED_TESTS = 50;
|
|
82
|
-
function readTests(raw) {
|
|
83
|
-
if (!Array.isArray(raw)) return void 0;
|
|
84
|
-
const tests = [];
|
|
85
|
-
for (const entry of raw.slice(0, MAX_NAMED_TESTS)) {
|
|
86
|
-
const { path: path2, line } = typeof entry === "object" && entry !== null ? entry : {};
|
|
87
|
-
if (typeof path2 !== "string" || path2 === "" || path2.length > 1024) continue;
|
|
88
|
-
tests.push({ path: path2, ...typeof line === "number" && Number.isInteger(line) && line > 0 ? { line } : {} });
|
|
89
|
-
}
|
|
90
|
-
return tests;
|
|
91
|
-
}
|
|
92
|
-
function readAnswer(raw) {
|
|
93
|
-
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return { ok: false, problem: "expected an object" };
|
|
94
|
-
const { result, items } = raw;
|
|
95
|
-
if (result !== void 0 && result !== "pass" && result !== "fail") return { ok: false, problem: 'result: must be "pass" or "fail"' };
|
|
96
|
-
if (items !== void 0 && !Array.isArray(items)) return { ok: false, problem: "items: must be an array" };
|
|
97
|
-
const entries = items ?? [];
|
|
98
|
-
if (entries.length > MAX_ANSWER_ENTRIES) return { ok: false, problem: `items: at most ${MAX_ANSWER_ENTRIES} entries` };
|
|
99
|
-
const read = [];
|
|
100
|
-
for (const [index, entry] of entries.entries()) {
|
|
101
|
-
const { id, result: itemResult, reason, tests } = typeof entry === "object" && entry !== null ? entry : {};
|
|
102
|
-
if (typeof id !== "string" || id === "" || id.length > 200) return { ok: false, problem: `items.${index}.id: must be text of 1 to 200 characters` };
|
|
103
|
-
if (itemResult !== "pass" && itemResult !== "fail") return { ok: false, problem: `items.${index}.result: must be "pass" or "fail"` };
|
|
104
|
-
if (reason !== void 0 && typeof reason !== "string") return { ok: false, problem: `items.${index}.reason: must be text` };
|
|
105
|
-
const named = readTests(tests);
|
|
106
|
-
read.push({ id, result: itemResult, ...reason === void 0 ? {} : { reason }, ...named === void 0 ? {} : { tests: named } });
|
|
107
|
-
}
|
|
108
|
-
return { ok: true, answer: { ...result === void 0 ? {} : { result }, items: read } };
|
|
109
|
-
}
|
|
110
|
-
function parseJudgeAnswer(text) {
|
|
111
|
-
if (text === void 0 || text.trim() === "") return void 0;
|
|
112
|
-
let raw;
|
|
113
|
-
try {
|
|
114
|
-
raw = JSON.parse(text);
|
|
115
|
-
} catch {
|
|
116
|
-
return { ok: false, reason: "the judge's items.json is not JSON" };
|
|
117
|
-
}
|
|
118
|
-
const read = readAnswer(raw);
|
|
119
|
-
return read.ok ? read : { ok: false, reason: `the judge's items.json does not match its shape: ${read.problem}` };
|
|
120
|
-
}
|
|
121
|
-
function oneLineReason(text) {
|
|
122
|
-
if (text === void 0) return void 0;
|
|
123
|
-
const line = text.replace(/\s+/g, " ").trim();
|
|
124
|
-
if (line === "") return void 0;
|
|
125
|
-
return line.length <= CHECK_ITEM_REASON_MAX_LENGTH ? line : `${line.slice(0, CHECK_ITEM_REASON_MAX_LENGTH - 1)}\u2026`;
|
|
126
|
-
}
|
|
127
|
-
function namedTests(tests, input) {
|
|
128
|
-
const refs = [];
|
|
129
|
-
const notTests = [];
|
|
130
|
-
const seen = /* @__PURE__ */ new Set();
|
|
131
|
-
for (const test of tests ?? []) {
|
|
132
|
-
const written = treePath(test.path, input.treeRoot);
|
|
133
|
-
if (written === void 0) continue;
|
|
134
|
-
const path2 = written.startsWith("tree/") && input.ownTree !== true ? written.slice("tree/".length) : written;
|
|
135
|
-
if (path2 === "") continue;
|
|
136
|
-
const known = input.check(path2, test.line);
|
|
137
|
-
if (known === void 0) continue;
|
|
138
|
-
const key = `${path2}:${test.line ?? ""}`;
|
|
139
|
-
if (seen.has(key)) continue;
|
|
140
|
-
if (known === "not-a-test") {
|
|
141
|
-
if (!notTests.includes(path2)) notTests.push(path2);
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
seen.add(key);
|
|
145
|
-
refs.push({ path: path2, ...test.line === void 0 ? {} : { line: test.line }, ...known.href === void 0 ? {} : { href: known.href } });
|
|
146
|
-
if (refs.length >= CHECK_ITEM_REFS_MAX) break;
|
|
147
|
-
}
|
|
148
|
-
return { refs, notTests };
|
|
149
|
-
}
|
|
150
|
-
function judgedItems(input) {
|
|
151
|
-
return input.toJudge.map((criterion) => {
|
|
152
|
-
const said = input.results.get(criterion.id);
|
|
153
|
-
const base = { id: criterion.id, criterion: criterion.id, commit: input.commit };
|
|
154
|
-
if (said === void 0) return { ...base, result: "fail", reason: NO_VERDICT_REASON };
|
|
155
|
-
const { refs, notTests } = namedTests(said.tests, { treeRoot: input.treeRoot, check: input.check, ownTree: input.ownTree });
|
|
156
|
-
const withRefs = refs.length === 0 ? {} : { refs };
|
|
157
|
-
if (said.result === "pass" && refs.length === 0) return { ...base, result: "fail", reason: notTests.length > 0 ? oneLineReason(notReadAsTestReason(notTests)) : NO_NAMED_TEST_REASON };
|
|
158
|
-
const reason = oneLineReason(said.reason);
|
|
159
|
-
const kept = said.result === "pass" ? { inputs: input.inputsFor(criterion, refPaths(refs)) } : {};
|
|
160
|
-
return { ...base, result: said.result, ...reason === void 0 ? {} : { reason }, ...withRefs, ...kept };
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
function failedItems(criteria, reason) {
|
|
164
|
-
const said = oneLineReason(reason) ?? NO_VERDICT_REASON;
|
|
165
|
-
return criteria.map((criterion) => ({ id: criterion.id, criterion: criterion.id, result: "fail", reason: said }));
|
|
166
|
-
}
|
|
167
|
-
function testsByCriterion(items) {
|
|
168
|
-
const tests = {};
|
|
169
|
-
for (const item of items) {
|
|
170
|
-
tests[item.id] = (item.refs ?? []).flatMap((ref) => ref.line === void 0 ? [] : [{ path: ref.path, line: ref.line, href: ref.href ?? null }]);
|
|
171
|
-
}
|
|
172
|
-
return tests;
|
|
173
|
-
}
|
|
174
|
-
function inCriteriaOrder(items, criteria) {
|
|
175
|
-
const order = new Map(criteria.map((criterion, index) => [criterion.id, index]));
|
|
176
|
-
return [...items].sort((a, b) => (order.get(a.id) ?? Number.MAX_SAFE_INTEGER) - (order.get(b.id) ?? Number.MAX_SAFE_INTEGER));
|
|
177
|
-
}
|
|
178
|
-
function itemsSentence(items, noun) {
|
|
179
|
-
const failing = items.filter((item) => item.result === "fail").map((item) => item.id);
|
|
180
|
-
if (failing.length === 0) return void 0;
|
|
181
|
-
return `${failing.length} of ${items.length} ${items.length === 1 ? noun.one : noun.many} not satisfied: ${failing.join(", ")}`;
|
|
182
|
-
}
|
|
183
11
|
|
|
184
12
|
// ../../node_modules/balanced-match/dist/esm/index.js
|
|
185
13
|
var balanced = (a, b, str) => {
|
|
@@ -2080,6 +1908,178 @@ function runnerMatcher(runners) {
|
|
|
2080
1908
|
return index === -1 ? void 0 : index;
|
|
2081
1909
|
};
|
|
2082
1910
|
}
|
|
1911
|
+
var ARTIFACT_PROOF_REASON = "Its declared artifact proves it; the judge does not judge artifacts.";
|
|
1912
|
+
var NO_NAMED_TEST_REASON = "The judge named no test file that proves this criterion.";
|
|
1913
|
+
var NO_VERDICT_REASON = "The judge gave no result for this criterion.";
|
|
1914
|
+
var JUDGE_GROUP_SIZE = 12;
|
|
1915
|
+
function notReadAsTestReason(paths) {
|
|
1916
|
+
const named = paths.slice(0, 3).map((path2) => `\`${path2}\``);
|
|
1917
|
+
const list = named.length === 1 ? named[0] : `${named.slice(0, -1).join(", ")} and ${named.at(-1)}`;
|
|
1918
|
+
const more = paths.length > 3 ? " and other files" : "";
|
|
1919
|
+
const one = paths.length === 1;
|
|
1920
|
+
return `The judge named ${list}${more}, which ${one ? "is" : "are"} not read as ${one ? "a test" : "tests"}. If ${one ? "that file holds" : "one of them holds"} the test, name it with a runner glob in \`.outerlayer-proofs.yaml\`.`;
|
|
1921
|
+
}
|
|
1922
|
+
function treePath(raw, treeRoot) {
|
|
1923
|
+
let path2 = raw.trim().replace(/\\/g, "/");
|
|
1924
|
+
const root = `${treeRoot.replace(/\/+$/, "")}/`;
|
|
1925
|
+
if (path2.startsWith(root)) path2 = path2.slice(root.length);
|
|
1926
|
+
while (path2.startsWith("./")) path2 = path2.slice(2);
|
|
1927
|
+
if (path2 === "" || path2.length > CHECK_ITEM_REF_PATH_MAX_LENGTH || path2.startsWith("/") || /[\u0000-\u001f\u007f]/.test(path2)) return void 0;
|
|
1928
|
+
if (path2.split("/").some((segment) => segment === ".." || segment === "")) return void 0;
|
|
1929
|
+
return path2;
|
|
1930
|
+
}
|
|
1931
|
+
function criterionInputs(input) {
|
|
1932
|
+
const hash = createHash("sha256");
|
|
1933
|
+
const part = (text) => {
|
|
1934
|
+
hash.update(`${Buffer.byteLength(text)}:`);
|
|
1935
|
+
hash.update(text);
|
|
1936
|
+
};
|
|
1937
|
+
part("judge-criterion-v2");
|
|
1938
|
+
part(input.brief);
|
|
1939
|
+
part(input.criterion.id);
|
|
1940
|
+
part(input.criterion.text);
|
|
1941
|
+
part(input.criterion.proof ?? "");
|
|
1942
|
+
for (const path2 of [...input.files.keys()].sort()) {
|
|
1943
|
+
const text = input.files.get(path2);
|
|
1944
|
+
part(path2);
|
|
1945
|
+
part(text === void 0 ? "missing" : `text:${text}`);
|
|
1946
|
+
}
|
|
1947
|
+
return hash.digest("hex");
|
|
1948
|
+
}
|
|
1949
|
+
function refPaths(refs) {
|
|
1950
|
+
return [...new Set((refs ?? []).map((ref) => ref.path))].sort();
|
|
1951
|
+
}
|
|
1952
|
+
function planCriteria(input) {
|
|
1953
|
+
const previousById = new Map(input.previous.map((item) => [item.id, item]));
|
|
1954
|
+
const settled = [];
|
|
1955
|
+
const toJudge = [];
|
|
1956
|
+
for (const criterion of input.criteria) {
|
|
1957
|
+
const base = { id: criterion.id, criterion: criterion.id };
|
|
1958
|
+
if (criterion.proof !== null) {
|
|
1959
|
+
settled.push({ ...base, result: "skipped", reason: ARTIFACT_PROOF_REASON });
|
|
1960
|
+
continue;
|
|
1961
|
+
}
|
|
1962
|
+
const kept = previousById.get(criterion.id);
|
|
1963
|
+
const paths = refPaths(kept?.refs);
|
|
1964
|
+
if (kept !== void 0 && kept.result === "pass" && kept.inputs !== void 0 && paths.length > 0) {
|
|
1965
|
+
const inputs = input.inputsFor(criterion, paths);
|
|
1966
|
+
if (inputs === kept.inputs) {
|
|
1967
|
+
settled.push({ ...base, ...kept.commit === void 0 ? {} : { commit: kept.commit }, result: "pass", ...kept.reason === void 0 ? {} : { reason: kept.reason }, refs: kept.refs, inputs });
|
|
1968
|
+
continue;
|
|
1969
|
+
}
|
|
1970
|
+
}
|
|
1971
|
+
toJudge.push(criterion);
|
|
1972
|
+
}
|
|
1973
|
+
return { settled, toJudge };
|
|
1974
|
+
}
|
|
1975
|
+
function judgeGroups(criteria, size = JUDGE_GROUP_SIZE) {
|
|
1976
|
+
const groups = [];
|
|
1977
|
+
for (let start = 0; start < criteria.length; start += size) groups.push(criteria.slice(start, start + size));
|
|
1978
|
+
return groups;
|
|
1979
|
+
}
|
|
1980
|
+
var MAX_ANSWER_ENTRIES = 500;
|
|
1981
|
+
var MAX_NAMED_TESTS = 50;
|
|
1982
|
+
function readTests(raw) {
|
|
1983
|
+
if (!Array.isArray(raw)) return void 0;
|
|
1984
|
+
const tests = [];
|
|
1985
|
+
for (const entry of raw.slice(0, MAX_NAMED_TESTS)) {
|
|
1986
|
+
const { path: path2, line } = typeof entry === "object" && entry !== null ? entry : {};
|
|
1987
|
+
if (typeof path2 !== "string" || path2 === "" || path2.length > 1024) continue;
|
|
1988
|
+
tests.push({ path: path2, ...typeof line === "number" && Number.isInteger(line) && line > 0 ? { line } : {} });
|
|
1989
|
+
}
|
|
1990
|
+
return tests;
|
|
1991
|
+
}
|
|
1992
|
+
function readAnswer(raw) {
|
|
1993
|
+
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) return { ok: false, problem: "expected an object" };
|
|
1994
|
+
const { result, items } = raw;
|
|
1995
|
+
if (result !== void 0 && result !== "pass" && result !== "fail") return { ok: false, problem: 'result: must be "pass" or "fail"' };
|
|
1996
|
+
if (items !== void 0 && !Array.isArray(items)) return { ok: false, problem: "items: must be an array" };
|
|
1997
|
+
const entries = items ?? [];
|
|
1998
|
+
if (entries.length > MAX_ANSWER_ENTRIES) return { ok: false, problem: `items: at most ${MAX_ANSWER_ENTRIES} entries` };
|
|
1999
|
+
const read = [];
|
|
2000
|
+
for (const [index, entry] of entries.entries()) {
|
|
2001
|
+
const { id, result: itemResult, reason, tests } = typeof entry === "object" && entry !== null ? entry : {};
|
|
2002
|
+
if (typeof id !== "string" || id === "" || id.length > 200) return { ok: false, problem: `items.${index}.id: must be text of 1 to 200 characters` };
|
|
2003
|
+
if (itemResult !== "pass" && itemResult !== "fail") return { ok: false, problem: `items.${index}.result: must be "pass" or "fail"` };
|
|
2004
|
+
if (reason !== void 0 && typeof reason !== "string") return { ok: false, problem: `items.${index}.reason: must be text` };
|
|
2005
|
+
const named = readTests(tests);
|
|
2006
|
+
read.push({ id, result: itemResult, ...reason === void 0 ? {} : { reason }, ...named === void 0 ? {} : { tests: named } });
|
|
2007
|
+
}
|
|
2008
|
+
return { ok: true, answer: { ...result === void 0 ? {} : { result }, items: read } };
|
|
2009
|
+
}
|
|
2010
|
+
function parseJudgeAnswer(text) {
|
|
2011
|
+
if (text === void 0 || text.trim() === "") return void 0;
|
|
2012
|
+
let raw;
|
|
2013
|
+
try {
|
|
2014
|
+
raw = JSON.parse(text);
|
|
2015
|
+
} catch {
|
|
2016
|
+
return { ok: false, reason: "the judge's items.json is not JSON" };
|
|
2017
|
+
}
|
|
2018
|
+
const read = readAnswer(raw);
|
|
2019
|
+
return read.ok ? read : { ok: false, reason: `the judge's items.json does not match its shape: ${read.problem}` };
|
|
2020
|
+
}
|
|
2021
|
+
function oneLineReason(text) {
|
|
2022
|
+
if (text === void 0) return void 0;
|
|
2023
|
+
const line = text.replace(/\s+/g, " ").trim();
|
|
2024
|
+
if (line === "") return void 0;
|
|
2025
|
+
return line.length <= CHECK_ITEM_REASON_MAX_LENGTH ? line : `${line.slice(0, CHECK_ITEM_REASON_MAX_LENGTH - 1)}\u2026`;
|
|
2026
|
+
}
|
|
2027
|
+
function namedTests(tests, input) {
|
|
2028
|
+
const refs = [];
|
|
2029
|
+
const notTests = [];
|
|
2030
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2031
|
+
for (const test of tests ?? []) {
|
|
2032
|
+
const written = treePath(test.path, input.treeRoot);
|
|
2033
|
+
if (written === void 0) continue;
|
|
2034
|
+
const path2 = written.startsWith("tree/") && input.ownTree !== true ? written.slice("tree/".length) : written;
|
|
2035
|
+
if (path2 === "") continue;
|
|
2036
|
+
const known = input.check(path2, test.line);
|
|
2037
|
+
if (known === void 0) continue;
|
|
2038
|
+
const key = `${path2}:${test.line ?? ""}`;
|
|
2039
|
+
if (seen.has(key)) continue;
|
|
2040
|
+
if (known === "not-a-test") {
|
|
2041
|
+
if (!notTests.includes(path2)) notTests.push(path2);
|
|
2042
|
+
continue;
|
|
2043
|
+
}
|
|
2044
|
+
seen.add(key);
|
|
2045
|
+
refs.push({ path: path2, ...test.line === void 0 ? {} : { line: test.line }, ...known.href === void 0 ? {} : { href: known.href } });
|
|
2046
|
+
if (refs.length >= CHECK_ITEM_REFS_MAX) break;
|
|
2047
|
+
}
|
|
2048
|
+
return { refs, notTests };
|
|
2049
|
+
}
|
|
2050
|
+
function judgedItems(input) {
|
|
2051
|
+
return input.toJudge.map((criterion) => {
|
|
2052
|
+
const said = input.results.get(criterion.id);
|
|
2053
|
+
const base = { id: criterion.id, criterion: criterion.id, commit: input.commit };
|
|
2054
|
+
if (said === void 0) return { ...base, result: "fail", reason: NO_VERDICT_REASON };
|
|
2055
|
+
const { refs, notTests } = namedTests(said.tests, { treeRoot: input.treeRoot, check: input.check, ownTree: input.ownTree });
|
|
2056
|
+
const withRefs = refs.length === 0 ? {} : { refs };
|
|
2057
|
+
if (said.result === "pass" && refs.length === 0) return { ...base, result: "fail", reason: notTests.length > 0 ? oneLineReason(notReadAsTestReason(notTests)) : NO_NAMED_TEST_REASON };
|
|
2058
|
+
const reason = oneLineReason(said.reason);
|
|
2059
|
+
const kept = said.result === "pass" ? { inputs: input.inputsFor(criterion, refPaths(refs)) } : {};
|
|
2060
|
+
return { ...base, result: said.result, ...reason === void 0 ? {} : { reason }, ...withRefs, ...kept };
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
2063
|
+
function failedItems(criteria, reason) {
|
|
2064
|
+
const said = oneLineReason(reason) ?? NO_VERDICT_REASON;
|
|
2065
|
+
return criteria.map((criterion) => ({ id: criterion.id, criterion: criterion.id, result: "fail", reason: said }));
|
|
2066
|
+
}
|
|
2067
|
+
function testsByCriterion(items) {
|
|
2068
|
+
const tests = {};
|
|
2069
|
+
for (const item of items) {
|
|
2070
|
+
tests[item.id] = (item.refs ?? []).flatMap((ref) => ref.line === void 0 ? [] : [{ path: ref.path, line: ref.line, href: ref.href ?? null }]);
|
|
2071
|
+
}
|
|
2072
|
+
return tests;
|
|
2073
|
+
}
|
|
2074
|
+
function inCriteriaOrder(items, criteria) {
|
|
2075
|
+
const order = new Map(criteria.map((criterion, index) => [criterion.id, index]));
|
|
2076
|
+
return [...items].sort((a, b) => (order.get(a.id) ?? Number.MAX_SAFE_INTEGER) - (order.get(b.id) ?? Number.MAX_SAFE_INTEGER));
|
|
2077
|
+
}
|
|
2078
|
+
function itemsSentence(items, noun) {
|
|
2079
|
+
const failing = items.filter((item) => item.result === "fail").map((item) => item.id);
|
|
2080
|
+
if (failing.length === 0) return void 0;
|
|
2081
|
+
return `${failing.length} of ${items.length} ${items.length === 1 ? noun.one : noun.many} not satisfied: ${failing.join(", ")}`;
|
|
2082
|
+
}
|
|
2083
2083
|
var MAX_TEST_FILE_BYTES = 1024 * 1024;
|
|
2084
2084
|
async function loadCitationFinder() {
|
|
2085
2085
|
return await import(pathToFileURL(join(resolvePackRoot(), "maintained", "outerlayer-build", "scripts", "criterion-citations.mjs")).href);
|