@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.
- package/CHANGELOG.md +49 -0
- package/README.md +3 -3
- package/bin/control/backend-records.test.mjs +276 -0
- package/bin/control/backend.mjs +212 -0
- package/bin/control/backend.test.mjs +325 -0
- package/bin/control/base.mjs +3 -7
- package/bin/control/browser-client.mjs +6 -4
- package/bin/control/browser.mjs +173 -36
- package/bin/control/build-cache.mjs +394 -0
- package/bin/control/build-cache.test.mjs +270 -0
- package/bin/control/build-inputs.mjs +172 -0
- package/bin/control/build-key-refusals.test.mjs +138 -0
- package/bin/control/build-key.mjs +479 -0
- package/bin/control/build-key.test.mjs +392 -0
- package/bin/control/build-layout.test.mjs +314 -0
- package/bin/control/commands-stack.mjs +46 -6
- package/bin/control/commands-verify.mjs +14 -25
- package/bin/control/doctor.mjs +87 -16
- package/bin/control/forwarder.mjs +86 -0
- package/bin/control/forwarder.test.mjs +141 -0
- package/bin/control/frontend-check.mjs +54 -0
- package/bin/control/frontend-workspace.mjs +150 -0
- package/bin/control/frontend-workspace.test.mjs +133 -0
- package/bin/control/helpers/env.mjs +21 -0
- package/bin/control/helpers/evidence.mjs +13 -0
- package/bin/control/helpers/fake-run.mjs +290 -0
- package/bin/control/helpers/key-fixture.mjs +82 -0
- package/bin/control/helpers/pids.mjs +27 -0
- package/bin/control/helpers/repo.mjs +13 -0
- package/bin/control/helpers/tree.mjs +40 -0
- package/bin/control/identity.mjs +238 -0
- package/bin/control/identity.test.mjs +166 -0
- package/bin/control/journey.mjs +64 -16
- package/bin/control/journey.test.mjs +60 -2
- package/bin/control/namespaces.test.mjs +211 -0
- package/bin/control/options.mjs +2 -0
- package/bin/control/pid-guard.test.mjs +202 -0
- package/bin/control/prepared-workspace.mjs +20 -0
- package/bin/control/processes.mjs +122 -33
- package/bin/control/processes.test.mjs +255 -0
- package/bin/control/renderer.test.mjs +2 -1
- package/bin/control/run-copy.mjs +77 -0
- package/bin/control/run-state.mjs +142 -16
- package/bin/control/stack.mjs +259 -210
- package/bin/control/tab.mjs +13 -6
- package/bin/control/tab.test.mjs +444 -0
- package/bin/control/timing.mjs +244 -0
- package/bin/control/timing.test.mjs +197 -0
- package/bin/control/verify/decode.mjs +34 -36
- package/bin/control/verify/decode.test.mjs +40 -14
- package/bin/control/verify/doors.test.mjs +2 -0
- package/bin/control/verify/map.mjs +57 -7
- package/bin/control/verify/map.test.mjs +264 -0
- package/bin/control/verify/skill.mjs +12 -3
- package/bin/control/verify/types.mjs +2 -2
- package/bin/control/verify/verdict.mjs +34 -37
- package/bin/dms-control.mjs +13 -6
- package/frontend-vue/layers/dms-layout/app/components/layout/DashboardSearch.vue +24 -1
- package/package.json +1 -1
- package/skills/dms-project/SKILL.md +6 -3
- package/bin/control/verify/publish.mjs +0 -186
|
@@ -28,6 +28,21 @@ export function isUserFacing(skill, file) {
|
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Whether a repository path is shared: matched by the config's `shared`
|
|
33
|
+
* globs and by none of its `notShared` globs. A change to it can alter any
|
|
34
|
+
* feature, so the plan runs them all.
|
|
35
|
+
*
|
|
36
|
+
* @param {import("./skill.mjs").Skill} skill The skill
|
|
37
|
+
* @param {string} file A repository path
|
|
38
|
+
* @returns {boolean} True when the file forces the full set
|
|
39
|
+
*/
|
|
40
|
+
export function isShared(skill, file) {
|
|
41
|
+
return (
|
|
42
|
+
matches(file, skill.config.shared) && !matches(file, skill.config.notShared)
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
31
46
|
/**
|
|
32
47
|
* The features whose `covers:` globs match a file.
|
|
33
48
|
*
|
|
@@ -84,6 +99,25 @@ async function featureProblems(skill, feature, tracked) {
|
|
|
84
99
|
return problems;
|
|
85
100
|
}
|
|
86
101
|
|
|
102
|
+
/**
|
|
103
|
+
* @param {import("./skill.mjs").Skill} skill The skill
|
|
104
|
+
* @param {string[]} tracked The tracked paths
|
|
105
|
+
* @returns {string[]} One line per problem
|
|
106
|
+
*/
|
|
107
|
+
function sharedProblems(skill, tracked) {
|
|
108
|
+
return skill.config.shared
|
|
109
|
+
.filter(
|
|
110
|
+
(glob) =>
|
|
111
|
+
!tracked.some(
|
|
112
|
+
(path) =>
|
|
113
|
+
matchesGlob(path, glob) && !matches(path, skill.config.notShared),
|
|
114
|
+
),
|
|
115
|
+
)
|
|
116
|
+
.map(
|
|
117
|
+
(glob) => `verify.config.ts: shared glob ${glob} matches no tracked file`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
87
121
|
/**
|
|
88
122
|
* @param {import("./skill.mjs").Skill} skill The skill
|
|
89
123
|
* @param {string[]} tracked The tracked paths
|
|
@@ -107,8 +141,8 @@ function doorProblems(skill, tracked) {
|
|
|
107
141
|
/**
|
|
108
142
|
* Checks the map against the repository: every user-facing file is
|
|
109
143
|
* covered, every feature has journeys, each described in its file,
|
|
110
|
-
* existing docs pages, and every feature and door glob matches a
|
|
111
|
-
* file.
|
|
144
|
+
* existing docs pages, and every feature, shared and door glob matches a
|
|
145
|
+
* tracked file.
|
|
112
146
|
*
|
|
113
147
|
* @param {import("./skill.mjs").Skill} skill The skill
|
|
114
148
|
* @returns {Promise<string[]>} One line per problem
|
|
@@ -134,22 +168,32 @@ export async function checkMap(skill) {
|
|
|
134
168
|
}
|
|
135
169
|
}
|
|
136
170
|
}
|
|
137
|
-
return [
|
|
171
|
+
return [
|
|
172
|
+
...problems,
|
|
173
|
+
...sharedProblems(skill, tracked),
|
|
174
|
+
...doorProblems(skill, tracked),
|
|
175
|
+
];
|
|
138
176
|
}
|
|
139
177
|
|
|
140
178
|
/**
|
|
141
179
|
* Maps the diff from the merge base of `baseRef` to HEAD onto features:
|
|
142
180
|
* every touched feature plus the smoke feature runs, a user-facing file
|
|
143
|
-
* outside every glob is an unmapped surface.
|
|
181
|
+
* outside every glob is an unmapped surface. A changed shared file, or
|
|
182
|
+
* `all`, runs the smoke feature and then every feature; `shared` lists the
|
|
183
|
+
* changed files that forced it.
|
|
144
184
|
*
|
|
145
185
|
* @param {import("./skill.mjs").Skill} skill The skill
|
|
146
186
|
* @param {string} baseRef The base, such as `origin/main`
|
|
187
|
+
* @param {boolean} [all] Run every feature whatever the diff, for a release
|
|
147
188
|
* @returns {import("./types.mjs").Plan} The plan
|
|
148
189
|
*/
|
|
149
|
-
export function planFor(skill, baseRef) {
|
|
190
|
+
export function planFor(skill, baseRef, all = false) {
|
|
150
191
|
const features = readFeatures(skill);
|
|
151
192
|
const baseSha = git(["merge-base", baseRef, "HEAD"], skill.repo);
|
|
152
|
-
const changed = git(
|
|
193
|
+
const changed = git(
|
|
194
|
+
["diff", "--name-only", "--no-renames", `${baseSha}...HEAD`],
|
|
195
|
+
skill.repo,
|
|
196
|
+
)
|
|
153
197
|
.split("\n")
|
|
154
198
|
.filter(Boolean);
|
|
155
199
|
const touched = features
|
|
@@ -170,15 +214,21 @@ export function planFor(skill, baseRef) {
|
|
|
170
214
|
.flatMap((feature) => feature.docs),
|
|
171
215
|
),
|
|
172
216
|
];
|
|
217
|
+
const shared = changed.filter((file) => isShared(skill, file));
|
|
173
218
|
const smoke = skill.config.smoke;
|
|
219
|
+
const names =
|
|
220
|
+
all || shared.length > 0
|
|
221
|
+
? features.map((feature) => feature.name)
|
|
222
|
+
: [...touchedNames];
|
|
174
223
|
return {
|
|
175
224
|
baseRef,
|
|
176
225
|
baseSha,
|
|
177
226
|
headSha: git(["rev-parse", "HEAD"], skill.repo),
|
|
178
227
|
changed,
|
|
179
228
|
touched,
|
|
229
|
+
shared,
|
|
180
230
|
unmapped,
|
|
181
231
|
docs,
|
|
182
|
-
run: [smoke, ...
|
|
232
|
+
run: [smoke, ...names.filter((name) => name !== smoke)],
|
|
183
233
|
};
|
|
184
234
|
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { execFileSync } from "node:child_process";
|
|
3
|
+
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
import test from "node:test";
|
|
7
|
+
import { checkMap, planFor } from "./map.mjs";
|
|
8
|
+
import { renderVerdict } from "./verdict.mjs";
|
|
9
|
+
|
|
10
|
+
const JOURNEYS = (/** @type {string} */ id) =>
|
|
11
|
+
`export const journeys = [{ id: "${id}", title: "t", entryPoint: "e", async run() {} }];\n`;
|
|
12
|
+
const FEATURE = (/** @type {string} */ id, /** @type {string[]} */ covers) =>
|
|
13
|
+
`---\ncovers:\n${covers.map((glob) => ` - ${glob}`).join("\n")}\n---\n\`${id}\`\n`;
|
|
14
|
+
|
|
15
|
+
const BASE_FILES = {
|
|
16
|
+
"package.json": "{}\n",
|
|
17
|
+
"pnpm-lock.yaml": "lock: 1\n",
|
|
18
|
+
"src/a/x.ts": "export const x = 1;\n",
|
|
19
|
+
"src/b/y.ts": "export const y = 1;\n",
|
|
20
|
+
"fixtures/host/package.json": "{}\n",
|
|
21
|
+
"skill/features/smoke.md": "---\ncovers:\n---\n`smoke`\n",
|
|
22
|
+
"skill/features/a.md": FEATURE("a-journey", ["src/a/**"]),
|
|
23
|
+
"skill/features/b.md": FEATURE("b-journey", ["src/b/**"]),
|
|
24
|
+
"skill/journeys/smoke.mjs": JOURNEYS("smoke"),
|
|
25
|
+
"skill/journeys/a.mjs": JOURNEYS("a-journey"),
|
|
26
|
+
"skill/journeys/b.mjs": JOURNEYS("b-journey"),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* @param {string} repo
|
|
31
|
+
* @param {...string} args
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
function git(repo, ...args) {
|
|
35
|
+
return execFileSync("git", args, { cwd: repo, encoding: "utf8" }).trim();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* @param {string} repo
|
|
40
|
+
* @param {Record<string, string>} files
|
|
41
|
+
* @returns {string} The new HEAD
|
|
42
|
+
*/
|
|
43
|
+
function commit(repo, files) {
|
|
44
|
+
for (const [path, content] of Object.entries(files)) {
|
|
45
|
+
mkdirSync(dirname(join(repo, path)), { recursive: true });
|
|
46
|
+
writeFileSync(join(repo, path), content);
|
|
47
|
+
}
|
|
48
|
+
git(repo, "add", "-A");
|
|
49
|
+
git(
|
|
50
|
+
repo,
|
|
51
|
+
"-c",
|
|
52
|
+
"user.name=t",
|
|
53
|
+
"-c",
|
|
54
|
+
"user.email=t@example.com",
|
|
55
|
+
"-c",
|
|
56
|
+
"commit.gpgsign=false",
|
|
57
|
+
"commit",
|
|
58
|
+
"-q",
|
|
59
|
+
"-m",
|
|
60
|
+
"change",
|
|
61
|
+
);
|
|
62
|
+
return git(repo, "rev-parse", "HEAD");
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* A repository with two features beside the smoke one, committed once, then
|
|
67
|
+
* changed by `changes` in a second commit.
|
|
68
|
+
*
|
|
69
|
+
* @param {import("node:test").TestContext} t
|
|
70
|
+
* @param {Record<string, string>} changes
|
|
71
|
+
* @param {Partial<import("./skill.mjs").SkillConfig>} [config]
|
|
72
|
+
*/
|
|
73
|
+
function fixture(t, changes, config = {}) {
|
|
74
|
+
const repo = mkdtempSync(join(tmpdir(), "dms-control-map-test-"));
|
|
75
|
+
t.after(() => rmSync(repo, { recursive: true, force: true }));
|
|
76
|
+
git(repo, "init", "-q");
|
|
77
|
+
git(repo, "remote", "add", "origin", "https://github.com/o/r.git");
|
|
78
|
+
const base = commit(repo, BASE_FILES);
|
|
79
|
+
const head = commit(repo, changes);
|
|
80
|
+
/** @type {import("./skill.mjs").Skill} */
|
|
81
|
+
const skill = {
|
|
82
|
+
dir: join(repo, "skill"),
|
|
83
|
+
name: "verify-x",
|
|
84
|
+
repo,
|
|
85
|
+
featuresDir: join(repo, "skill", "features"),
|
|
86
|
+
journeysDir: join(repo, "skill", "journeys"),
|
|
87
|
+
config: {
|
|
88
|
+
playground: "p",
|
|
89
|
+
prepare: [],
|
|
90
|
+
userFacing: ["src/**"],
|
|
91
|
+
notUserFacing: [],
|
|
92
|
+
shared: ["**/package.json", "pnpm-lock.yaml"],
|
|
93
|
+
notShared: ["fixtures/**"],
|
|
94
|
+
smoke: "smoke",
|
|
95
|
+
smokeJourney: "",
|
|
96
|
+
doors: {},
|
|
97
|
+
formal: [],
|
|
98
|
+
...config,
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
return { repo, base, head, skill };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
await test("a changed lockfile runs smoke and then every feature and names the file; a planner that maps only covers globs runs smoke alone", (t) => {
|
|
105
|
+
const { skill, base } = fixture(t, { "pnpm-lock.yaml": "lock: 2\n" });
|
|
106
|
+
const plan = planFor(skill, base);
|
|
107
|
+
assert.deepEqual(plan.run, ["smoke", "a", "b"]);
|
|
108
|
+
assert.deepEqual(plan.shared, ["pnpm-lock.yaml"]);
|
|
109
|
+
assert.deepEqual(plan.touched, []);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
await test("a nested manifest is shared too; a root-only package.json glob leaves it to the covers", (t) => {
|
|
113
|
+
const { skill, base } = fixture(t, { "src/a/package.json": "{ }\n" });
|
|
114
|
+
const plan = planFor(skill, base);
|
|
115
|
+
assert.deepEqual(plan.run, ["smoke", "a", "b"]);
|
|
116
|
+
assert.deepEqual(plan.shared, ["src/a/package.json"]);
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await test("a diff of covered files runs those features beside smoke; escalating on every change would run b too", (t) => {
|
|
120
|
+
const { skill, base } = fixture(t, { "src/a/x.ts": "export const x = 2;\n" });
|
|
121
|
+
const plan = planFor(skill, base);
|
|
122
|
+
assert.deepEqual(plan.run, ["smoke", "a"]);
|
|
123
|
+
assert.deepEqual(plan.shared, []);
|
|
124
|
+
assert.deepEqual(plan.touched, [{ feature: "a", files: ["src/a/x.ts"] }]);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
await test("a shared file next to a covered one keeps touched and shared apart; dropping touched on escalation loses the diff-to-feature evidence", (t) => {
|
|
128
|
+
const { skill, base } = fixture(t, {
|
|
129
|
+
"src/b/y.ts": "export const y = 2;\n",
|
|
130
|
+
"package.json": '{ "name": "x" }\n',
|
|
131
|
+
});
|
|
132
|
+
const plan = planFor(skill, base);
|
|
133
|
+
assert.deepEqual(plan.run, ["smoke", "a", "b"]);
|
|
134
|
+
assert.deepEqual(plan.shared, ["package.json"]);
|
|
135
|
+
assert.deepEqual(plan.touched, [{ feature: "b", files: ["src/b/y.ts"] }]);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
await test("a shared file renamed out of its shared path still runs every feature; a diff with rename detection lists only the new path and runs smoke alone", (t) => {
|
|
139
|
+
const { repo, skill, base } = fixture(t, { "README.md": "x\n" });
|
|
140
|
+
git(repo, "mv", "pnpm-lock.yaml", "moved-lock.txt");
|
|
141
|
+
commit(repo, {});
|
|
142
|
+
const plan = planFor(skill, base);
|
|
143
|
+
assert.deepEqual(plan.run, ["smoke", "a", "b"]);
|
|
144
|
+
assert.deepEqual(plan.shared, ["pnpm-lock.yaml"]);
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
await test("a fixture manifest under notShared stays on smoke; a planner that ignores notShared escalates on test fixtures", (t) => {
|
|
148
|
+
const { skill, base } = fixture(t, {
|
|
149
|
+
"fixtures/host/package.json": '{ "name": "host" }\n',
|
|
150
|
+
});
|
|
151
|
+
const plan = planFor(skill, base);
|
|
152
|
+
assert.deepEqual(plan.run, ["smoke"]);
|
|
153
|
+
assert.deepEqual(plan.shared, []);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
await test("a skill without shared globs still plans from covers alone; a planner that treats every package.json as shared breaks the other dms-* repositories", (t) => {
|
|
157
|
+
const { skill, base } = fixture(
|
|
158
|
+
t,
|
|
159
|
+
{ "pnpm-lock.yaml": "lock: 2\n" },
|
|
160
|
+
{ shared: [], notShared: [] },
|
|
161
|
+
);
|
|
162
|
+
assert.deepEqual(planFor(skill, base).run, ["smoke"]);
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
await test("all runs every feature on a diff that touches none and lists no shared file; ignoring the flag runs smoke alone", (t) => {
|
|
166
|
+
const { skill, base } = fixture(t, { "README.md": "x\n" });
|
|
167
|
+
const plan = planFor(skill, base, true);
|
|
168
|
+
assert.deepEqual(plan.run, ["smoke", "a", "b"]);
|
|
169
|
+
assert.deepEqual(plan.shared, []);
|
|
170
|
+
assert.deepEqual(planFor(skill, base).run, ["smoke"]);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
await test("map fails a shared glob that matches no tracked file or only notShared ones; a checkMap blind to shared globs lets a renamed lockfile glob rot", async (t) => {
|
|
174
|
+
const { skill } = fixture(
|
|
175
|
+
t,
|
|
176
|
+
{ "README.md": "x\n" },
|
|
177
|
+
{
|
|
178
|
+
shared: ["**/package.json", "gone/**", "fixtures/**"],
|
|
179
|
+
},
|
|
180
|
+
);
|
|
181
|
+
const problems = (await checkMap(skill)).filter((line) =>
|
|
182
|
+
line.includes("shared glob"),
|
|
183
|
+
);
|
|
184
|
+
assert.deepEqual(problems, [
|
|
185
|
+
"verify.config.ts: shared glob gone/** matches no tracked file",
|
|
186
|
+
"verify.config.ts: shared glob fixtures/** matches no tracked file",
|
|
187
|
+
]);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @param {string} evidence
|
|
192
|
+
* @param {string[]} features
|
|
193
|
+
*/
|
|
194
|
+
function recordPassing(evidence, features) {
|
|
195
|
+
for (const feature of features) {
|
|
196
|
+
mkdirSync(join(evidence, feature), { recursive: true });
|
|
197
|
+
const journey = feature === "smoke" ? "smoke" : `${feature}-journey`;
|
|
198
|
+
writeFileSync(
|
|
199
|
+
join(evidence, feature, "feature.json"),
|
|
200
|
+
JSON.stringify([
|
|
201
|
+
{
|
|
202
|
+
feature,
|
|
203
|
+
journey,
|
|
204
|
+
title: "t",
|
|
205
|
+
entryPoint: "e",
|
|
206
|
+
status: "PASS",
|
|
207
|
+
database: "d",
|
|
208
|
+
steps: [],
|
|
209
|
+
error: null,
|
|
210
|
+
folder: `${feature}/${journey}`,
|
|
211
|
+
},
|
|
212
|
+
]),
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const JUDGEMENT = {
|
|
218
|
+
notVerified: [],
|
|
219
|
+
attention: [],
|
|
220
|
+
docs: [],
|
|
221
|
+
doorsNone: "none",
|
|
222
|
+
doors: [],
|
|
223
|
+
falsePositives: [],
|
|
224
|
+
verifier: "v",
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
await test("the verdict fails a run that skipped features the shared-file plan required; a verdict that requires only the touched features passes the smoke-only run", async (t) => {
|
|
228
|
+
const { skill, base, head } = fixture(t, { "pnpm-lock.yaml": "lock: 2\n" });
|
|
229
|
+
const evidence = mkdtempSync(join(tmpdir(), "dms-control-evidence-test-"));
|
|
230
|
+
t.after(() => rmSync(evidence, { recursive: true, force: true }));
|
|
231
|
+
const state = /** @type {import("../run-state.mjs").RunState} */ (
|
|
232
|
+
/** @type {unknown} */ ({ baseRef: base, headSha: head, evidence })
|
|
233
|
+
);
|
|
234
|
+
recordPassing(evidence, ["smoke"]);
|
|
235
|
+
const skipped = await renderVerdict(skill, state, 1, JUDGEMENT);
|
|
236
|
+
assert.equal(skipped.result, "FAIL");
|
|
237
|
+
assert.deepEqual(skipped.reasons, [
|
|
238
|
+
"a/a-journey was not run",
|
|
239
|
+
"b/b-journey was not run",
|
|
240
|
+
]);
|
|
241
|
+
recordPassing(evidence, ["a", "b"]);
|
|
242
|
+
assert.equal(
|
|
243
|
+
(await renderVerdict(skill, state, 1, JUDGEMENT)).result,
|
|
244
|
+
"PASS",
|
|
245
|
+
);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
await test("the verdict of a covered-only diff needs the other features only when all is set; a verdict that drops all passes an incomplete release run", async (t) => {
|
|
249
|
+
const { skill, base, head } = fixture(t, {
|
|
250
|
+
"src/a/x.ts": "export const x = 2;\n",
|
|
251
|
+
});
|
|
252
|
+
const evidence = mkdtempSync(join(tmpdir(), "dms-control-evidence-test-"));
|
|
253
|
+
t.after(() => rmSync(evidence, { recursive: true, force: true }));
|
|
254
|
+
const state = /** @type {import("../run-state.mjs").RunState} */ (
|
|
255
|
+
/** @type {unknown} */ ({ baseRef: base, headSha: head, evidence })
|
|
256
|
+
);
|
|
257
|
+
recordPassing(evidence, ["smoke", "a"]);
|
|
258
|
+
assert.equal(
|
|
259
|
+
(await renderVerdict(skill, state, 1, JUDGEMENT)).result,
|
|
260
|
+
"PASS",
|
|
261
|
+
);
|
|
262
|
+
const release = await renderVerdict(skill, state, 1, JUDGEMENT, true);
|
|
263
|
+
assert.deepEqual(release.reasons, ["b/b-journey was not run"]);
|
|
264
|
+
});
|
|
@@ -4,6 +4,7 @@ import { basename, join, relative, resolve } from "node:path";
|
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
5
|
import { checkoutOf } from "../git.mjs";
|
|
6
6
|
import { isRecord } from "../json.mjs";
|
|
7
|
+
import { stopwatch } from "../timing.mjs";
|
|
7
8
|
import { decodeSkillConfig } from "./decode.mjs";
|
|
8
9
|
|
|
9
10
|
const CONFIG_FILE = "verify.config.ts";
|
|
@@ -11,7 +12,7 @@ const OUTPUT_LIMIT = 64 * 1024 * 1024;
|
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* @typedef {{ dir: string, name: string, repo: string, config: SkillConfig, featuresDir: string, journeysDir: string }} Skill
|
|
14
|
-
* @typedef {{ playground: string, renderer?: string, prepare: string[][], userFacing: string[], notUserFacing: string[], smoke: string, smokeJourney: string, doors: Record<string, { globs: string[], funnels: string[], why: string } | null>, formal: import("./types.mjs").FormalCheck[] }} SkillConfig
|
|
15
|
+
* @typedef {{ playground: string, renderer?: string, prepare: string[][], userFacing: string[], notUserFacing: string[], shared: string[], notShared: string[], smoke: string, smokeJourney: string, doors: Record<string, { globs: string[], funnels: string[], why: string } | null>, formal: import("./types.mjs").FormalCheck[] }} SkillConfig
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
/**
|
|
@@ -130,10 +131,12 @@ export function journeysFile(skill, feature) {
|
|
|
130
131
|
*
|
|
131
132
|
* @param {Skill} skill The skill
|
|
132
133
|
* @param {string} cwd The checkout
|
|
134
|
+
* @returns {import("../timing.mjs").TimingEntry[]} One timing entry per command, for the run folder that does not exist yet
|
|
133
135
|
* @throws When a command fails, with its output
|
|
134
136
|
*/
|
|
135
137
|
export function runPrepare(skill, cwd) {
|
|
136
|
-
|
|
138
|
+
return skill.config.prepare.map(([program, ...args]) => {
|
|
139
|
+
const stop = stopwatch();
|
|
137
140
|
const result = spawnSync(program, args, {
|
|
138
141
|
cwd,
|
|
139
142
|
encoding: "utf8",
|
|
@@ -145,5 +148,11 @@ export function runPrepare(skill, cwd) {
|
|
|
145
148
|
`${program} ${args.join(" ")} failed in ${cwd}:\n${result.stdout}${result.stderr}`,
|
|
146
149
|
);
|
|
147
150
|
}
|
|
148
|
-
|
|
151
|
+
return {
|
|
152
|
+
phase: "prepare",
|
|
153
|
+
...stop(),
|
|
154
|
+
ok: true,
|
|
155
|
+
command: [program, ...args].join(" "),
|
|
156
|
+
};
|
|
157
|
+
});
|
|
149
158
|
}
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* @typedef {{ exitCode: number | null, violated: string[], passing: string[] }} Rules
|
|
11
11
|
* @typedef {{ name: string, exitCode: number | null, violated: string[], passing: string[], folder: string, commits?: Commits, behaviour?: BehaviourChange, checkChanged?: boolean, base?: Rules | null, fixed?: string[], missing?: string[] }} FormalResult
|
|
12
12
|
* @typedef {{ feature: string, files: string[] }} TouchedFeature
|
|
13
|
-
* @typedef {{ baseRef: string, baseSha: string, headSha: string, changed: string[], touched: TouchedFeature[], unmapped: string[], docs: string[], run: string[] }} Plan
|
|
13
|
+
* @typedef {{ baseRef: string, baseSha: string, headSha: string, changed: string[], touched: TouchedFeature[], shared: string[], unmapped: string[], docs: string[], run: string[] }} Plan
|
|
14
14
|
* @typedef {{ kind?: string, location?: string, irreversible?: string, containment?: string }} RawDoorRow
|
|
15
15
|
* @typedef {{ kind?: string, location?: string, reason?: string }} RawFalsePositive
|
|
16
16
|
* @typedef {{ page: string, matches?: boolean, note?: string }} RawDocsJudgement
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* @typedef {{ page: string, matches: boolean, note: string }} DocsJudgement
|
|
21
21
|
* @typedef {{ notVerified: string[], attention: string[], docs: DocsJudgement[], doorsNone: string | null, doors: DoorRow[], falsePositives: FalsePositive[], verifier: string }} Judgement
|
|
22
22
|
* @typedef {{ name: string, pass: boolean, detail: string }} JourneyCheck
|
|
23
|
-
* @typedef {{ feature: string, journey: string, title: string, entryPoint: string, status: "PASS" | "FAIL", database: string, steps: { name: string, checks: JourneyCheck[] }[], error: string | null, folder: string }} FeatureResult
|
|
23
|
+
* @typedef {{ feature: string, journey: string, title: string, entryPoint: string, status: "PASS" | "FAIL", database: string, steps: { name: string, checks: JourneyCheck[] }[], error: string | null, folder: string, ms?: number }} FeatureResult
|
|
24
24
|
* @typedef {{ result: string, headSha: string, skillSha: string, pr: number, reasons: string[] }} VerdictCore
|
|
25
25
|
* @typedef {VerdictCore & { markdown: string }} Verdict
|
|
26
26
|
*/
|
|
@@ -2,6 +2,12 @@ import { existsSync, writeFileSync } from "node:fs";
|
|
|
2
2
|
import { join, relative } from "node:path";
|
|
3
3
|
import { git } from "../git.mjs";
|
|
4
4
|
import { loadJourneys } from "../journey.mjs";
|
|
5
|
+
import {
|
|
6
|
+
formatSeconds,
|
|
7
|
+
markdownTimings,
|
|
8
|
+
readTimings,
|
|
9
|
+
summarize,
|
|
10
|
+
} from "../timing.mjs";
|
|
5
11
|
import { readFeatureResults } from "./decode.mjs";
|
|
6
12
|
import { flaggedDoors } from "./doors.mjs";
|
|
7
13
|
import {
|
|
@@ -12,19 +18,6 @@ import {
|
|
|
12
18
|
import { planFor } from "./map.mjs";
|
|
13
19
|
import { journeysFile } from "./skill.mjs";
|
|
14
20
|
|
|
15
|
-
/**
|
|
16
|
-
* The GitHub `owner/repo` of the checkout's origin remote.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} repo The checkout
|
|
19
|
-
* @returns {string} The repository
|
|
20
|
-
*/
|
|
21
|
-
export function originRepository(repo) {
|
|
22
|
-
const url = git(["remote", "get-url", "origin"], repo);
|
|
23
|
-
const match = /github\.com[:/](.+?)(?:\.git)?$/.exec(url);
|
|
24
|
-
if (!match) throw new Error(`origin ${url} is not a GitHub repository`);
|
|
25
|
-
return match[1];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
21
|
/**
|
|
29
22
|
* @param {string} sha A commit
|
|
30
23
|
* @returns {string} Its first seven characters
|
|
@@ -55,10 +48,9 @@ function readResults(state, feature) {
|
|
|
55
48
|
* @param {import("./skill.mjs").Skill} skill The skill
|
|
56
49
|
* @param {import("../run-state.mjs").RunState} state The run
|
|
57
50
|
* @param {import("./types.mjs").Plan} plan The plan
|
|
58
|
-
* @param {(path: string) => string} link The evidence link of a path
|
|
59
51
|
* @returns {Promise<{ rows: string[], reasons: string[] }>} The table rows and why the verdict fails
|
|
60
52
|
*/
|
|
61
|
-
async function journeyRows(skill, state, plan
|
|
53
|
+
async function journeyRows(skill, state, plan) {
|
|
62
54
|
/** @type {string[]} */
|
|
63
55
|
const rows = [];
|
|
64
56
|
/** @type {string[]} */
|
|
@@ -82,8 +74,10 @@ async function journeyRows(skill, state, plan, link) {
|
|
|
82
74
|
if (result.status === "FAIL")
|
|
83
75
|
reasons.push(`${feature}/${result.journey} failed`);
|
|
84
76
|
const outcome = result.status === "PASS" ? "pass" : "**fail**";
|
|
77
|
+
const time =
|
|
78
|
+
result.ms === undefined ? "-" : `${formatSeconds(result.ms)} s`;
|
|
85
79
|
rows.push(
|
|
86
|
-
`| ${feature} | \`${result.journey}\`: ${result.entryPoint} | ${outcome}: ${result.title} |
|
|
80
|
+
`| ${feature} | \`${result.journey}\`: ${result.entryPoint} | ${outcome}: ${result.title} | ${time} | \`${result.folder}\` |`,
|
|
87
81
|
);
|
|
88
82
|
}
|
|
89
83
|
}
|
|
@@ -143,10 +137,9 @@ function doorsSection(judgement) {
|
|
|
143
137
|
* @param {import("./skill.mjs").Skill} skill The skill
|
|
144
138
|
* @param {import("../run-state.mjs").RunState} state The run
|
|
145
139
|
* @param {import("./types.mjs").Plan} plan The plan
|
|
146
|
-
* @param {(path: string) => string} link The evidence link of a path
|
|
147
140
|
* @returns {{ reasons: string[], lines: string[] }} Why the formal checks fail the verdict, and their lines
|
|
148
141
|
*/
|
|
149
|
-
function formalSection(skill, state, plan
|
|
142
|
+
function formalSection(skill, state, plan) {
|
|
150
143
|
const reasons = [];
|
|
151
144
|
const lines = [];
|
|
152
145
|
const touched = touchedFormalChecks(skill, plan.changed).map(
|
|
@@ -179,7 +172,7 @@ function formalSection(skill, state, plan, link) {
|
|
|
179
172
|
? "covers the diff, gates the verdict"
|
|
180
173
|
: "does not cover the diff, informational";
|
|
181
174
|
lines.push(
|
|
182
|
-
`\`${check.name}\` (${role}): ${summary}.
|
|
175
|
+
`\`${check.name}\` (${role}): ${summary}. Evidence: \`${result.folder}\``,
|
|
183
176
|
);
|
|
184
177
|
}
|
|
185
178
|
return { reasons, lines };
|
|
@@ -204,11 +197,12 @@ function docsReasons(judgement, plan) {
|
|
|
204
197
|
/**
|
|
205
198
|
* @param {import("./skill.mjs").Skill} skill The skill
|
|
206
199
|
* @param {import("./types.mjs").VerdictCore} verdict The verdict
|
|
207
|
-
* @param {{ plan: import("./types.mjs").Plan, judgement: import("./types.mjs").Judgement, journeys: Awaited<ReturnType<typeof journeyRows>>, formal: ReturnType<typeof formalSection>, reasons: string[], attention: string[]
|
|
200
|
+
* @param {{ plan: import("./types.mjs").Plan, judgement: import("./types.mjs").Judgement, journeys: Awaited<ReturnType<typeof journeyRows>>, formal: ReturnType<typeof formalSection>, timing: import("../timing.mjs").TimingSummary, reasons: string[], attention: string[] }} parts What the verdict is rendered from
|
|
208
201
|
* @returns {string} The verdict as Markdown
|
|
209
202
|
*/
|
|
210
203
|
function markdown(skill, verdict, parts) {
|
|
211
|
-
const { plan, judgement, journeys, formal, reasons, attention
|
|
204
|
+
const { plan, judgement, journeys, formal, timing, reasons, attention } =
|
|
205
|
+
parts;
|
|
212
206
|
const touched = plan.touched.map(
|
|
213
207
|
(entry) =>
|
|
214
208
|
`\`${entry.feature}\` (diff: ${entry.files.map((file) => `\`${file}\``).join(", ")})`,
|
|
@@ -229,6 +223,14 @@ function markdown(skill, verdict, parts) {
|
|
|
229
223
|
...bullets(touched, "none"),
|
|
230
224
|
`- ${skill.config.smoke}: ${skill.config.smokeJourney}`,
|
|
231
225
|
"",
|
|
226
|
+
...(plan.shared.length > 0
|
|
227
|
+
? [
|
|
228
|
+
"### Shared files",
|
|
229
|
+
`Every feature runs (${plan.run.length}), because the diff changes:`,
|
|
230
|
+
...plan.shared.map((file) => `- \`${file}\``),
|
|
231
|
+
"",
|
|
232
|
+
]
|
|
233
|
+
: []),
|
|
232
234
|
...(plan.unmapped.length > 0
|
|
233
235
|
? [
|
|
234
236
|
"### Unmapped surfaces",
|
|
@@ -243,10 +245,13 @@ function markdown(skill, verdict, parts) {
|
|
|
243
245
|
? ["### Why it fails", ...reasons.map((reason) => `- ${reason}`), ""]
|
|
244
246
|
: []),
|
|
245
247
|
"### Journeys",
|
|
246
|
-
"| Feature | Entry point | Result | Evidence |",
|
|
247
|
-
"
|
|
248
|
+
"| Feature | Entry point | Result | Time | Evidence |",
|
|
249
|
+
"|---|---|---|---|---|",
|
|
248
250
|
...journeys.rows,
|
|
249
251
|
"",
|
|
252
|
+
"### Timing",
|
|
253
|
+
...(timing.rows.length > 0 ? markdownTimings(timing) : ["None recorded."]),
|
|
254
|
+
"",
|
|
250
255
|
"### Formal checks",
|
|
251
256
|
...bullets(formal.lines, "None ran."),
|
|
252
257
|
"",
|
|
@@ -259,8 +264,6 @@ function markdown(skill, verdict, parts) {
|
|
|
259
264
|
"### Attention",
|
|
260
265
|
...bullets(attention, "Nothing."),
|
|
261
266
|
"",
|
|
262
|
-
`Evidence: \`verify-evidence\` branch, [\`pr-${verdict.pr}/${plan.headSha}/\`](${link("")})`,
|
|
263
|
-
"",
|
|
264
267
|
].join("\n");
|
|
265
268
|
}
|
|
266
269
|
|
|
@@ -273,30 +276,24 @@ function markdown(skill, verdict, parts) {
|
|
|
273
276
|
* @param {import("../run-state.mjs").RunState} state The run
|
|
274
277
|
* @param {number} pr The pull request
|
|
275
278
|
* @param {import("./types.mjs").Judgement} judgement The verifier's judgement
|
|
279
|
+
* @param {boolean} [all] Require every feature, as `plan --all` does for a release
|
|
276
280
|
* @returns {Promise<import("./types.mjs").Verdict>} The verdict
|
|
277
281
|
*/
|
|
278
|
-
export async function renderVerdict(skill, state, pr, judgement) {
|
|
279
|
-
const plan = planFor(skill, state.baseRef);
|
|
282
|
+
export async function renderVerdict(skill, state, pr, judgement, all = false) {
|
|
283
|
+
const plan = planFor(skill, state.baseRef, all);
|
|
280
284
|
const skillSha =
|
|
281
285
|
git(
|
|
282
286
|
["log", "-1", "--format=%H", "--", relative(skill.repo, skill.dir)],
|
|
283
287
|
skill.repo,
|
|
284
288
|
) || plan.headSha;
|
|
285
|
-
const repository = originRepository(skill.repo);
|
|
286
|
-
/**
|
|
287
|
-
* @param {string} path A path under the run's evidence
|
|
288
|
-
* @returns {string} Its link on the evidence branch
|
|
289
|
-
*/
|
|
290
|
-
const link = (path) =>
|
|
291
|
-
`https://github.com/${repository}/tree/verify-evidence/pr-${pr}/${plan.headSha}/${path}`;
|
|
292
289
|
const reasons = [];
|
|
293
290
|
if (plan.headSha !== state.headSha) {
|
|
294
291
|
reasons.push(
|
|
295
292
|
`the run was created at ${short(state.headSha ?? "unknown")} but HEAD is ${short(plan.headSha)}`,
|
|
296
293
|
);
|
|
297
294
|
}
|
|
298
|
-
const journeys = await journeyRows(skill, state, plan
|
|
299
|
-
const formal = formalSection(skill, state, plan
|
|
295
|
+
const journeys = await journeyRows(skill, state, plan);
|
|
296
|
+
const formal = formalSection(skill, state, plan);
|
|
300
297
|
reasons.push(
|
|
301
298
|
...journeys.reasons,
|
|
302
299
|
...plan.unmapped.map((file) => `unmapped surface ${file}`),
|
|
@@ -313,9 +310,9 @@ export async function renderVerdict(skill, state, pr, judgement) {
|
|
|
313
310
|
judgement,
|
|
314
311
|
journeys,
|
|
315
312
|
formal,
|
|
313
|
+
timing: summarize(readTimings(state.evidence)),
|
|
316
314
|
reasons,
|
|
317
315
|
attention,
|
|
318
|
-
link,
|
|
319
316
|
});
|
|
320
317
|
writeFileSync(join(state.evidence, "verdict.md"), text);
|
|
321
318
|
writeFileSync(
|
package/bin/dms-control.mjs
CHANGED
|
@@ -7,10 +7,15 @@ import { runVerifyCommand } from "./control/commands-verify.mjs";
|
|
|
7
7
|
const USAGE = `Usage: dms-control <command>
|
|
8
8
|
|
|
9
9
|
Drive an isolated DMS (run from the repository, or pass --playground):
|
|
10
|
-
up [--prepare] [--playground <dir>] [--renderer <dir>] [--runs <dir>] [--mongo-url <url>] [--env KEY=VALUE]... [--base <ref>] [--skill <dir>]
|
|
10
|
+
up [--prepare] [--playground <dir>] [--renderer <dir>] [--runs <dir>] [--mongo-url <url>] [--env KEY=VALUE]... [--base <ref>] [--skill <dir>] [--no-standby] [--no-build-cache]
|
|
11
11
|
build and start a playground copy on free ports; print the run folder
|
|
12
12
|
(--prepare first runs the skill's install and build commands;
|
|
13
|
-
--renderer serves that built @antelopejs/dms-frontend checkout
|
|
13
|
+
--renderer serves that built @antelopejs/dms-frontend checkout;
|
|
14
|
+
--no-standby, or DMS_CONTROL_NO_STANDBY=1, starts each fresh database's
|
|
15
|
+
backend when it is needed instead of one ahead: about 160 MB less while
|
|
16
|
+
journeys run, about 5 s more per journey;
|
|
17
|
+
the frontend build of the same inputs comes from $XDG_CACHE_HOME/dms-control/frontend,
|
|
18
|
+
--no-build-cache runs ajs dms build as it is)
|
|
14
19
|
doctor <run> [--verbose] check the run is worth driving; print the failing checks
|
|
15
20
|
onboard <run> [--platform-name <name>]
|
|
16
21
|
create the run's administrator through POST /api/onboarding/register
|
|
@@ -21,17 +26,19 @@ Drive an isolated DMS (run from the repository, or pass --playground):
|
|
|
21
26
|
api <run> <method> <path> [--as <account>|anon] [--body <json>]
|
|
22
27
|
an authenticated request; prints the status and the body
|
|
23
28
|
mail <run> the messages the run's mail sink captured
|
|
24
|
-
reset <run>
|
|
29
|
+
reset <run> move the run onto an empty database and a backend that served nothing
|
|
25
30
|
down <run> stop the run, drop its databases, keep its evidence
|
|
31
|
+
timings <run> the time each phase of the run took, from evidence/timings.jsonl
|
|
26
32
|
|
|
27
33
|
Verify a change (the .agents/skills/verify-* folder of the checkout, or --skill <dir>):
|
|
28
34
|
map check the feature map covers every user-facing file
|
|
29
|
-
plan [--base <ref>]
|
|
35
|
+
plan [--base <ref>] [--all] map the diff to features; list shared files and unmapped surfaces
|
|
36
|
+
(a shared file, or --all for a release, runs every feature)
|
|
30
37
|
journey <run> <feature> [ids...] run a feature's journeys and record evidence
|
|
31
38
|
doors [patch] [--base <ref>] print the One-way-door line for a patch, or for the diff
|
|
32
39
|
formal <run> [--all] run the formal checks that cover the diff (or every one)
|
|
33
|
-
verdict <run> --pr <n>
|
|
34
|
-
|
|
40
|
+
verdict <run> --pr <n> [--all] render evidence/verdict.md from the results and evidence/judgement.json
|
|
41
|
+
(--all requires every feature, for a release)
|
|
35
42
|
`;
|
|
36
43
|
|
|
37
44
|
/**
|