@antelopejs/dms 0.18.0 → 0.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +3 -3
  3. package/bin/control/backend-records.test.mjs +276 -0
  4. package/bin/control/backend.mjs +212 -0
  5. package/bin/control/backend.test.mjs +325 -0
  6. package/bin/control/base.mjs +3 -7
  7. package/bin/control/browser-client.mjs +6 -4
  8. package/bin/control/browser.mjs +173 -36
  9. package/bin/control/build-cache.mjs +394 -0
  10. package/bin/control/build-cache.test.mjs +270 -0
  11. package/bin/control/build-inputs.mjs +172 -0
  12. package/bin/control/build-key-refusals.test.mjs +138 -0
  13. package/bin/control/build-key.mjs +479 -0
  14. package/bin/control/build-key.test.mjs +392 -0
  15. package/bin/control/build-layout.test.mjs +314 -0
  16. package/bin/control/commands-stack.mjs +46 -6
  17. package/bin/control/commands-verify.mjs +14 -25
  18. package/bin/control/doctor.mjs +87 -16
  19. package/bin/control/forwarder.mjs +86 -0
  20. package/bin/control/forwarder.test.mjs +141 -0
  21. package/bin/control/frontend-check.mjs +54 -0
  22. package/bin/control/frontend-workspace.mjs +150 -0
  23. package/bin/control/frontend-workspace.test.mjs +133 -0
  24. package/bin/control/helpers/env.mjs +21 -0
  25. package/bin/control/helpers/evidence.mjs +13 -0
  26. package/bin/control/helpers/fake-run.mjs +290 -0
  27. package/bin/control/helpers/key-fixture.mjs +82 -0
  28. package/bin/control/helpers/pids.mjs +27 -0
  29. package/bin/control/helpers/repo.mjs +13 -0
  30. package/bin/control/helpers/tree.mjs +40 -0
  31. package/bin/control/identity.mjs +238 -0
  32. package/bin/control/identity.test.mjs +166 -0
  33. package/bin/control/journey.mjs +64 -16
  34. package/bin/control/journey.test.mjs +60 -2
  35. package/bin/control/namespaces.test.mjs +211 -0
  36. package/bin/control/options.mjs +2 -0
  37. package/bin/control/pid-guard.test.mjs +202 -0
  38. package/bin/control/prepared-workspace.mjs +20 -0
  39. package/bin/control/processes.mjs +122 -33
  40. package/bin/control/processes.test.mjs +255 -0
  41. package/bin/control/renderer.test.mjs +2 -1
  42. package/bin/control/run-copy.mjs +77 -0
  43. package/bin/control/run-state.mjs +142 -16
  44. package/bin/control/stack.mjs +259 -210
  45. package/bin/control/tab.mjs +13 -6
  46. package/bin/control/tab.test.mjs +444 -0
  47. package/bin/control/timing.mjs +244 -0
  48. package/bin/control/timing.test.mjs +197 -0
  49. package/bin/control/verify/decode.mjs +34 -36
  50. package/bin/control/verify/decode.test.mjs +40 -14
  51. package/bin/control/verify/doors.test.mjs +2 -0
  52. package/bin/control/verify/map.mjs +57 -7
  53. package/bin/control/verify/map.test.mjs +264 -0
  54. package/bin/control/verify/skill.mjs +12 -3
  55. package/bin/control/verify/types.mjs +2 -2
  56. package/bin/control/verify/verdict.mjs +34 -37
  57. package/bin/dms-control.mjs +13 -6
  58. package/frontend-vue/layers/dms-layout/app/components/layout/DashboardSearch.vue +24 -1
  59. package/package.json +1 -1
  60. package/skills/dms-project/SKILL.md +6 -3
  61. package/bin/control/verify/publish.mjs +0 -186
@@ -0,0 +1,244 @@
1
+ import { appendFileSync, existsSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { isBoolean, isNumber, isString, objectOf } from "./json.mjs";
4
+
5
+ /**
6
+ * @typedef {{ feature?: string, journey?: string, step?: string, command?: string, action?: string, check?: string }} TimingDetail What a phase names besides its own name
7
+ * @typedef {{ phase: string, ms: number, startedAt: string, ok: boolean } & TimingDetail} TimingEntry One measured phase, as `timings.jsonl` holds it
8
+ * @typedef {{ name: string, count: number, totalMs: number, medianMs: number, maxMs: number }} TimingRow
9
+ * @typedef {{ rows: TimingRow[], totalMs: number }} TimingSummary
10
+ */
11
+
12
+ /** The file of a run's evidence that every process appends its phases to, one JSON object per line. */
13
+ export const TIMINGS_FILE = "timings.jsonl";
14
+
15
+ const MS_PER_SECOND = 1000;
16
+ const TOP_LEVEL = new Set(["prepare", "up", "journey", "formal"]);
17
+
18
+ const isTimingEntry = objectOf(
19
+ { phase: isString, ms: isNumber, startedAt: isString, ok: isBoolean },
20
+ {
21
+ feature: isString,
22
+ journey: isString,
23
+ step: isString,
24
+ command: isString,
25
+ action: isString,
26
+ check: isString,
27
+ },
28
+ );
29
+
30
+ /**
31
+ * Starts a clock.
32
+ *
33
+ * @returns {() => { ms: number, startedAt: string }} A function that reads the whole milliseconds elapsed and when the clock started
34
+ */
35
+ export function stopwatch() {
36
+ const startedAt = new Date().toISOString();
37
+ const began = performance.now();
38
+ return () => ({ ms: Math.round(performance.now() - began), startedAt });
39
+ }
40
+
41
+ /**
42
+ * Appends one entry to the run's `timings.jsonl`. Separate processes append
43
+ * to it, so no write reads the file first.
44
+ *
45
+ * @param {{ evidence: string }} state The run
46
+ * @param {TimingEntry} entry The entry
47
+ */
48
+ export function appendTiming(state, entry) {
49
+ appendFileSync(
50
+ join(state.evidence, TIMINGS_FILE),
51
+ `${JSON.stringify(entry)}\n`,
52
+ );
53
+ }
54
+
55
+ /**
56
+ * Appends the entry of a phase that was measured with {@link stopwatch}.
57
+ *
58
+ * @param {{ evidence: string }} state The run
59
+ * @param {string} phase The phase name
60
+ * @param {{ ms: number, startedAt: string }} lap What the stopwatch read
61
+ * @param {boolean} ok Whether the phase succeeded
62
+ * @param {TimingDetail} [detail] What the phase names
63
+ */
64
+ export function recordTiming(state, phase, lap, ok, detail = {}) {
65
+ appendTiming(state, {
66
+ phase,
67
+ ms: lap.ms,
68
+ startedAt: lap.startedAt,
69
+ ok,
70
+ ...detail,
71
+ });
72
+ }
73
+
74
+ /**
75
+ * Runs `action` and records how long it took, also when it throws (then with
76
+ * `ok: false`, and the error is rethrown).
77
+ *
78
+ * @template T
79
+ * @param {{ evidence: string }} state The run
80
+ * @param {string} phase The phase name
81
+ * @param {() => T | Promise<T>} action What to measure
82
+ * @param {TimingDetail} [detail] What the phase names
83
+ * @returns {Promise<T>} What `action` returned
84
+ */
85
+ export async function timed(state, phase, action, detail) {
86
+ const stop = stopwatch();
87
+ let ok = false;
88
+ try {
89
+ const result = await action();
90
+ ok = true;
91
+ return result;
92
+ } finally {
93
+ recordTiming(state, phase, stop(), ok, detail);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * @param {string} line A line of `timings.jsonl`
99
+ * @returns {TimingEntry[]} The entry, none for a line that holds no entry
100
+ */
101
+ function entryOf(line) {
102
+ try {
103
+ /** @type {unknown} */
104
+ const parsed = JSON.parse(line);
105
+ return isTimingEntry(parsed) ? [parsed] : [];
106
+ } catch {
107
+ return [];
108
+ }
109
+ }
110
+
111
+ /**
112
+ * The entries a run recorded, in the order they were written. A run with no
113
+ * `timings.jsonl`, and any line that is no entry, give none.
114
+ *
115
+ * @param {string} evidence The run's evidence folder
116
+ * @returns {TimingEntry[]} The entries
117
+ */
118
+ export function readTimings(evidence) {
119
+ const file = join(evidence, TIMINGS_FILE);
120
+ if (!existsSync(file)) return [];
121
+ return readFileSync(file, "utf8").split("\n").flatMap(entryOf);
122
+ }
123
+
124
+ /**
125
+ * @param {TimingEntry} entry An entry
126
+ * @returns {string} Its row name: the phase, or for a journey `journey <feature>/<id>`
127
+ */
128
+ function rowName(entry) {
129
+ return entry.phase === "journey" && entry.feature && entry.journey
130
+ ? `journey ${entry.feature}/${entry.journey}`
131
+ : entry.phase;
132
+ }
133
+
134
+ /**
135
+ * @param {number[]} sorted Durations, ascending and not empty
136
+ * @returns {number} Their median, the mean of the two middle ones when the count is even
137
+ */
138
+ function median(sorted) {
139
+ const middle = Math.floor(sorted.length / 2);
140
+ return sorted.length % 2 === 1
141
+ ? sorted[middle]
142
+ : Math.round((sorted[middle - 1] + sorted[middle]) / 2);
143
+ }
144
+
145
+ /**
146
+ * One row per phase name, a journey counting under its own name, ordered by
147
+ * when the phase first started, and the total: the sum of the top-level
148
+ * phases (`prepare`, `up`, each `journey`, `formal`), which contain the others.
149
+ *
150
+ * @param {TimingEntry[]} entries The entries of a run
151
+ * @returns {TimingSummary} The rows and the total
152
+ */
153
+ export function summarize(entries) {
154
+ /** @type {Map<string, TimingEntry[]>} */
155
+ const groups = new Map();
156
+ for (const entry of entries) {
157
+ const name = rowName(entry);
158
+ groups.set(name, [...(groups.get(name) ?? []), entry]);
159
+ }
160
+ /** @type {(group: TimingEntry[]) => string} */
161
+ const firstStart = (group) => group.map((entry) => entry.startedAt).sort()[0];
162
+ const rows = [...groups]
163
+ .sort(([, a], [, b]) => firstStart(a).localeCompare(firstStart(b)))
164
+ .map(([name, group]) => {
165
+ const durations = group.map((entry) => entry.ms).sort((a, b) => a - b);
166
+ return {
167
+ name,
168
+ count: group.length,
169
+ totalMs: durations.reduce((sum, ms) => sum + ms, 0),
170
+ medianMs: median(durations),
171
+ maxMs: durations[durations.length - 1],
172
+ };
173
+ });
174
+ const totalMs = entries
175
+ .filter((entry) => TOP_LEVEL.has(entry.phase))
176
+ .reduce((sum, entry) => sum + entry.ms, 0);
177
+ return { rows, totalMs };
178
+ }
179
+
180
+ /**
181
+ * @param {number} ms A duration
182
+ * @returns {string} It in seconds with one decimal
183
+ */
184
+ export function formatSeconds(ms) {
185
+ return (ms / MS_PER_SECOND).toFixed(1);
186
+ }
187
+
188
+ /**
189
+ * @param {TimingSummary} summary The summary
190
+ * @returns {string[][]} The header, a row per phase and the total, as cells
191
+ */
192
+ function cellsOf(summary) {
193
+ return [
194
+ ["phase", "count", "total s", "median ms", "max ms"],
195
+ ...summary.rows.map((row) => [
196
+ row.name,
197
+ String(row.count),
198
+ formatSeconds(row.totalMs),
199
+ String(row.medianMs),
200
+ String(row.maxMs),
201
+ ]),
202
+ ["total", "", formatSeconds(summary.totalMs), "", ""],
203
+ ];
204
+ }
205
+
206
+ /**
207
+ * The summary as the plain table `dms-control timings` prints.
208
+ *
209
+ * @param {TimingSummary} summary The summary
210
+ * @returns {string} The table
211
+ */
212
+ export function formatTimings(summary) {
213
+ const cells = cellsOf(summary);
214
+ const widths = cells[0].map((_, column) =>
215
+ Math.max(...cells.map((row) => row[column].length)),
216
+ );
217
+ return cells
218
+ .map((row) =>
219
+ row
220
+ .map((cell, column) =>
221
+ column === 0
222
+ ? cell.padEnd(widths[column])
223
+ : cell.padStart(widths[column]),
224
+ )
225
+ .join(" ")
226
+ .trimEnd(),
227
+ )
228
+ .join("\n");
229
+ }
230
+
231
+ /**
232
+ * The summary as the Markdown table of the verdict's Timing section.
233
+ *
234
+ * @param {TimingSummary} summary The summary
235
+ * @returns {string[]} The lines of the table
236
+ */
237
+ export function markdownTimings(summary) {
238
+ const [header, ...body] = cellsOf(summary);
239
+ return [
240
+ `| ${header.join(" | ")} |`,
241
+ `|${header.map(() => "---").join("|")}|`,
242
+ ...body.map((row) => `| ${row.join(" | ")} |`),
243
+ ];
244
+ }
@@ -0,0 +1,197 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import test from "node:test";
6
+ import {
7
+ formatTimings,
8
+ markdownTimings,
9
+ readTimings,
10
+ summarize,
11
+ timed,
12
+ TIMINGS_FILE,
13
+ } from "./timing.mjs";
14
+
15
+ /**
16
+ * @param {import("node:test").TestContext} t The test
17
+ * @returns {{ evidence: string }} A run whose evidence folder is removed when the test ends
18
+ */
19
+ function scratchRun(t) {
20
+ const evidence = mkdtempSync(join(tmpdir(), "dms-control-timing-test-"));
21
+ t.after(() => rmSync(evidence, { recursive: true, force: true }));
22
+ return { evidence };
23
+ }
24
+
25
+ /**
26
+ * @param {string} phase The phase
27
+ * @param {number} ms Its duration
28
+ * @param {string} second The second of the minute it started in
29
+ * @param {import("./timing.mjs").TimingDetail} [detail] What it names
30
+ * @returns {import("./timing.mjs").TimingEntry} The entry
31
+ */
32
+ function entry(phase, ms, second, detail = {}) {
33
+ return {
34
+ phase,
35
+ ms,
36
+ startedAt: `2026-11-07T10:00:${second}.000Z`,
37
+ ok: true,
38
+ ...detail,
39
+ };
40
+ }
41
+
42
+ await test("each journey is its own row, so two journeys of a feature are not merged", () => {
43
+ const { rows } = summarize([
44
+ entry("journey", 4000, "10", { feature: "auth", journey: "login" }),
45
+ entry("journey", 9000, "20", { feature: "auth", journey: "invite" }),
46
+ ]);
47
+ assert.deepEqual(
48
+ rows.map((row) => [row.name, row.count, row.totalMs]),
49
+ [
50
+ ["journey auth/login", 1, 4000],
51
+ ["journey auth/invite", 1, 9000],
52
+ ],
53
+ );
54
+ });
55
+
56
+ await test("the total sums the top-level phases and not the phases they contain", () => {
57
+ const { totalMs } = summarize([
58
+ entry("prepare", 1000, "00"),
59
+ entry("up", 5000, "01"),
60
+ entry("mongod", 2000, "02"),
61
+ entry("journey", 3000, "10", { feature: "auth", journey: "login" }),
62
+ entry("journey-run", 2500, "11", { feature: "auth", journey: "login" }),
63
+ entry("backend-stop", 700, "12"),
64
+ entry("formal", 400, "30", { check: "formal-add" }),
65
+ entry("browser-command", 900, "40", { action: "snapshot" }),
66
+ ]);
67
+ assert.equal(totalMs, 1000 + 5000 + 3000 + 400);
68
+ });
69
+
70
+ await test("a phase run several times has its count, total, median and maximum", () => {
71
+ const { rows } = summarize([
72
+ entry("aria", 30, "01"),
73
+ entry("aria", 10, "02"),
74
+ entry("aria", 200, "03"),
75
+ ]);
76
+ assert.deepEqual(rows, [
77
+ { name: "aria", count: 3, totalMs: 240, medianMs: 30, maxMs: 200 },
78
+ ]);
79
+ });
80
+
81
+ await test("the median of an even count is the mean of the two middle durations", () => {
82
+ const { rows } = summarize([
83
+ entry("screenshot", 400, "01"),
84
+ entry("screenshot", 100, "02"),
85
+ entry("screenshot", 300, "03"),
86
+ entry("screenshot", 200, "04"),
87
+ ]);
88
+ assert.equal(rows[0].medianMs, 250);
89
+ });
90
+
91
+ await test("rows follow when each phase first started, not the order its entries were written", () => {
92
+ const { rows } = summarize([
93
+ entry("mongod", 100, "02"),
94
+ entry("up", 900, "01"),
95
+ entry("prepare", 5000, "00"),
96
+ ]);
97
+ assert.deepEqual(
98
+ rows.map((row) => row.name),
99
+ ["prepare", "up", "mongod"],
100
+ );
101
+ });
102
+
103
+ await test("an empty run has no rows and a zero total", () => {
104
+ assert.deepEqual(summarize([]), { rows: [], totalMs: 0 });
105
+ });
106
+
107
+ await test("the plain table aligns its columns and ends with the total line", () => {
108
+ const summary = summarize([
109
+ entry("up", 123_400, "00"),
110
+ entry("aria", 20, "10"),
111
+ entry("aria", 80, "11"),
112
+ ]);
113
+ assert.equal(
114
+ formatTimings(summary),
115
+ [
116
+ "phase count total s median ms max ms",
117
+ "up 1 123.4 123400 123400",
118
+ "aria 2 0.1 50 80",
119
+ "total 123.4",
120
+ ].join("\n"),
121
+ );
122
+ });
123
+
124
+ await test("the Markdown table has the same cells as the plain one", () => {
125
+ const summary = summarize([entry("up", 2000, "00")]);
126
+ assert.deepEqual(markdownTimings(summary), [
127
+ "| phase | count | total s | median ms | max ms |",
128
+ "|---|---|---|---|---|",
129
+ "| up | 1 | 2.0 | 2000 | 2000 |",
130
+ "| total | | 2.0 | | |",
131
+ ]);
132
+ });
133
+
134
+ await test("timed records the phase and returns what the action returned", async (t) => {
135
+ const run = scratchRun(t);
136
+ const value = await timed(run, "mail", () => 7, { step: "01-open" });
137
+ const [recorded] = readTimings(run.evidence);
138
+ assert.equal(value, 7);
139
+ assert.equal(recorded.phase, "mail");
140
+ assert.equal(recorded.ok, true);
141
+ assert.equal(recorded.step, "01-open");
142
+ assert.equal(Number.isInteger(recorded.ms), true);
143
+ });
144
+
145
+ await test("timed records a failing action with ok false and rethrows its error", async (t) => {
146
+ const run = scratchRun(t);
147
+ await assert.rejects(
148
+ timed(run, "project-build", () => Promise.reject(new Error("boom"))),
149
+ /boom/,
150
+ );
151
+ const [recorded] = readTimings(run.evidence);
152
+ assert.equal(recorded.phase, "project-build");
153
+ assert.equal(recorded.ok, false);
154
+ });
155
+
156
+ await test("timed records a synchronous throw too", async (t) => {
157
+ const run = scratchRun(t);
158
+ await assert.rejects(
159
+ timed(run, "layout", () => {
160
+ throw new Error("no space");
161
+ }),
162
+ /no space/,
163
+ );
164
+ assert.equal(readTimings(run.evidence)[0].ok, false);
165
+ });
166
+
167
+ await test("entries appended one after another are all read back, none replaced", async (t) => {
168
+ const run = scratchRun(t);
169
+ await timed(run, "up", () => undefined);
170
+ await timed(run, "journey", () => undefined, { feature: "a", journey: "b" });
171
+ assert.deepEqual(
172
+ readTimings(run.evidence).map((recorded) => recorded.phase),
173
+ ["up", "journey"],
174
+ );
175
+ });
176
+
177
+ await test("a run without timings reads as none", (t) => {
178
+ assert.deepEqual(readTimings(scratchRun(t).evidence), []);
179
+ });
180
+
181
+ await test("lines that are no entry are skipped and the others are kept", (t) => {
182
+ const run = scratchRun(t);
183
+ writeFileSync(
184
+ join(run.evidence, TIMINGS_FILE),
185
+ [
186
+ JSON.stringify(entry("up", 10, "00")),
187
+ '{"phase":"half',
188
+ "",
189
+ JSON.stringify({ phase: "up", ms: "slow" }),
190
+ JSON.stringify(entry("mail", 5, "01")),
191
+ ].join("\n"),
192
+ );
193
+ assert.deepEqual(
194
+ readTimings(run.evidence).map((recorded) => recorded.phase),
195
+ ["up", "mail"],
196
+ );
197
+ });
@@ -56,24 +56,27 @@ export const isFormalResult = objectOf(
56
56
 
57
57
  /** @type {import("../json.mjs").Guard<import("./types.mjs").FeatureResult[]>} The journey results a run records in `<feature>/feature.json` */
58
58
  const isFeatureResults = arrayOf(
59
- objectOf({
60
- feature: isString,
61
- journey: isString,
62
- title: isString,
63
- entryPoint: isString,
64
- status: oneOf(["PASS", "FAIL"]),
65
- database: isString,
66
- steps: arrayOf(
67
- objectOf({
68
- name: isString,
69
- checks: arrayOf(
70
- objectOf({ name: isString, pass: isBoolean, detail: isString }),
71
- ),
72
- }),
73
- ),
74
- error: nullable(isString),
75
- folder: isString,
76
- }),
59
+ objectOf(
60
+ {
61
+ feature: isString,
62
+ journey: isString,
63
+ title: isString,
64
+ entryPoint: isString,
65
+ status: oneOf(["PASS", "FAIL"]),
66
+ database: isString,
67
+ steps: arrayOf(
68
+ objectOf({
69
+ name: isString,
70
+ checks: arrayOf(
71
+ objectOf({ name: isString, pass: isBoolean, detail: isString }),
72
+ ),
73
+ }),
74
+ ),
75
+ error: nullable(isString),
76
+ folder: isString,
77
+ },
78
+ { ms: isNumber },
79
+ ),
77
80
  );
78
81
 
79
82
  /** @type {import("../json.mjs").Guard<import("./types.mjs").RawJudgement>} The verifier's `judgement.json` */
@@ -112,11 +115,6 @@ export const isRawJudgement = objectOf(
112
115
  },
113
116
  );
114
117
 
115
- /** What `gh api repos/<repo>/commits/<sha>/statuses` answers, as far as the harness reads it. */
116
- export const isCommitStatuses = arrayOf(
117
- objectOf({ context: isString, state: isString }),
118
- );
119
-
120
118
  const isRegexOrNull = nullable(instanceOf(RegExp));
121
119
 
122
120
  const isFormalCheck = objectOf(
@@ -143,7 +141,7 @@ const isDoorRule = objectOf({
143
141
  why: isString,
144
142
  });
145
143
 
146
- /** The default export of a skill's `verify.config.ts`. `notUserFacing` may be absent. */
144
+ /** The default export of a skill's `verify.config.ts`. `notUserFacing`, `shared` and `notShared` may be absent. */
147
145
  export const isSkillConfig = objectOf(
148
146
  {
149
147
  playground: isString,
@@ -154,7 +152,12 @@ export const isSkillConfig = objectOf(
154
152
  doors: recordOf(nullable(isDoorRule)),
155
153
  formal: arrayOf(isFormalCheck),
156
154
  },
157
- { notUserFacing: strings, renderer: isString },
155
+ {
156
+ notUserFacing: strings,
157
+ shared: strings,
158
+ notShared: strings,
159
+ renderer: isString,
160
+ },
158
161
  );
159
162
 
160
163
  /**
@@ -170,7 +173,12 @@ export function decodeSkillConfig(exported, source) {
170
173
  source,
171
174
  "a verification skill config",
172
175
  );
173
- return { ...config, notUserFacing: config.notUserFacing ?? [] };
176
+ return {
177
+ ...config,
178
+ notUserFacing: config.notUserFacing ?? [],
179
+ shared: config.shared ?? [],
180
+ notShared: config.notShared ?? [],
181
+ };
174
182
  }
175
183
 
176
184
  /**
@@ -193,16 +201,6 @@ export function decodeRawJudgement(stored, source) {
193
201
  return decode(isRawJudgement, stored, source, "a verifier's judgement");
194
202
  }
195
203
 
196
- /**
197
- * @param {unknown} answer What `gh api` printed, parsed
198
- * @param {string} source The command
199
- * @returns {{ context: string, state: string }[]} The statuses
200
- * @throws When the value is not a list of statuses
201
- */
202
- export function decodeCommitStatuses(answer, source) {
203
- return decode(isCommitStatuses, answer, source, "a list of commit statuses");
204
- }
205
-
206
204
  /**
207
205
  * The journey results a run recorded for a feature.
208
206
  *
@@ -4,7 +4,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
4
4
  import { tmpdir } from "node:os";
5
5
  import { join } from "node:path";
6
6
  import test from "node:test";
7
- import { decodeCommitStatuses, readFeatureResults } from "./decode.mjs";
7
+ import { readFeatureResults } from "./decode.mjs";
8
8
  import { readFormalResult } from "./formal.mjs";
9
9
  import { readJudgement } from "./judgement.mjs";
10
10
  import { loadSkill } from "./skill.mjs";
@@ -84,6 +84,17 @@ await test("journey results are read as recorded and none when absent", (t) => {
84
84
  assert.deepEqual(readFeatureResults(join(dir, "feature.json")), [RESULT]);
85
85
  });
86
86
 
87
+ await test("a journey result keeps its duration, and one whose duration is no number is refused", (t) => {
88
+ const dir = scratch(t);
89
+ writeJson(join(dir, "feature.json"), [{ ...RESULT, ms: 4200 }]);
90
+ assert.equal(readFeatureResults(join(dir, "feature.json"))[0].ms, 4200);
91
+ writeJson(join(dir, "feature.json"), [{ ...RESULT, ms: "4.2s" }]);
92
+ assert.throws(
93
+ () => readFeatureResults(join(dir, "feature.json")),
94
+ /malformed: expected a list of journey results/,
95
+ );
96
+ });
97
+
87
98
  await test("a journey result with a status that is neither PASS nor FAIL is refused", (t) => {
88
99
  const dir = scratch(t);
89
100
  writeJson(join(dir, "feature.json"), [{ ...RESULT, status: "PASSED" }]);
@@ -105,19 +116,6 @@ await test("a journey result whose check does not say pass or fail is refused",
105
116
  );
106
117
  });
107
118
 
108
- await test("a status list without a context and state is refused", () => {
109
- const statuses = [{ context: "verify", state: "success", id: 1 }];
110
- assert.deepEqual(decodeCommitStatuses(statuses, "gh"), statuses);
111
- assert.throws(
112
- () => decodeCommitStatuses({ message: "Not Found" }, "gh api statuses"),
113
- /gh api statuses is malformed/,
114
- );
115
- assert.throws(
116
- () => decodeCommitStatuses([{ context: "verify" }], "gh"),
117
- /malformed: expected a list of commit statuses/,
118
- );
119
- });
120
-
121
119
  const CONFIG = `export default {
122
120
  playground: "playground",
123
121
  prepare: [["pnpm", "install"]],
@@ -166,6 +164,34 @@ await test("a config without the optional list of non-user-facing paths loads wi
166
164
  assert.equal(skill.config.doors.format, null);
167
165
  });
168
166
 
167
+ await test("a config loads its shared globs, and none when it lists none; a loader that drops the fields escalates nothing", async (t) => {
168
+ const bare = await loadSkill(skillFolder(t, CONFIG), tmpdir());
169
+ assert.deepEqual([bare.config.shared, bare.config.notShared], [[], []]);
170
+ const listed = await loadSkill(
171
+ skillFolder(
172
+ t,
173
+ CONFIG.replace(
174
+ " smoke:",
175
+ ' shared: ["**/package.json"],\n notShared: ["hosts/**"],\n smoke:',
176
+ ),
177
+ ),
178
+ tmpdir(),
179
+ );
180
+ assert.deepEqual(listed.config.shared, ["**/package.json"]);
181
+ assert.deepEqual(listed.config.notShared, ["hosts/**"]);
182
+ });
183
+
184
+ await test("a config whose shared globs are not strings is refused", async (t) => {
185
+ const dir = skillFolder(
186
+ t,
187
+ CONFIG.replace(" smoke:", ' shared: "**/package.json",\n smoke:'),
188
+ );
189
+ await assert.rejects(
190
+ loadSkill(dir, tmpdir()),
191
+ /verify\.config\.ts is malformed: expected a verification skill config/,
192
+ );
193
+ });
194
+
169
195
  await test("a config missing a field is refused where the skill loads", async (t) => {
170
196
  const dir = skillFolder(t, CONFIG.replace('smoke: "smoke",\n', ""));
171
197
  await assert.rejects(
@@ -17,6 +17,8 @@ const skill = {
17
17
  prepare: [],
18
18
  userFacing: [],
19
19
  notUserFacing: [],
20
+ shared: [],
21
+ notShared: [],
20
22
  smoke: "smoke",
21
23
  smokeJourney: "",
22
24
  formal: [],