@warpgogol/forge 9.7.1 → 10.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/AGENTS.md +50 -27
- package/CHANGELOG.md +39 -0
- package/bin/cli.js +0 -0
- package/dist/os/codebase/handlers/codebase-measure-symbols.d.ts.map +1 -1
- package/dist/os/codebase/handlers/codebase-measure-symbols.js +35 -4
- package/dist/os/codebase/handlers/codebase-measure-symbols.js.map +1 -1
- package/dist/os/core/core.module.d.ts.map +1 -1
- package/dist/os/core/core.module.js +1 -69
- package/dist/os/core/core.module.js.map +1 -1
- package/dist/os/core/handlers/assets-helpers.d.ts.map +1 -1
- package/dist/os/core/handlers/assets-helpers.js +2 -3
- package/dist/os/core/handlers/assets-helpers.js.map +1 -1
- package/dist/os/core/handlers/determinism-check.d.ts.map +1 -1
- package/dist/os/core/handlers/determinism-check.js +2 -3
- package/dist/os/core/handlers/determinism-check.js.map +1 -1
- package/dist/os/core/handlers/release-prepare.d.ts.map +1 -1
- package/dist/os/core/handlers/release-prepare.js +2 -4
- package/dist/os/core/handlers/release-prepare.js.map +1 -1
- package/dist/os/flow/handlers/flow-peers.js +1 -1
- package/dist/os/flow/handlers/flow-peers.js.map +1 -1
- package/dist/os/{mission → flow}/open-missions.d.ts +1 -2
- package/dist/os/flow/open-missions.d.ts.map +1 -0
- package/dist/os/flow/open-missions.js +37 -0
- package/dist/os/flow/open-missions.js.map +1 -0
- package/dist/os/flow/preflight.js +1 -1
- package/dist/os/flow/preflight.js.map +1 -1
- package/dist/os/rfc/probe-batch.d.ts.map +1 -1
- package/dist/os/rfc/probe-batch.js +13 -6
- package/dist/os/rfc/probe-batch.js.map +1 -1
- package/dist/src/command-modules.d.ts.map +1 -1
- package/dist/src/command-modules.js +0 -2
- package/dist/src/command-modules.js.map +1 -1
- package/dist/src/contract/core-nodes.d.ts +8 -0
- package/dist/src/contract/core-nodes.d.ts.map +1 -0
- package/dist/src/contract/core-nodes.js +101 -0
- package/dist/src/contract/core-nodes.js.map +1 -0
- package/dist/src/contract/evaluator.d.ts +48 -0
- package/dist/src/contract/evaluator.d.ts.map +1 -0
- package/dist/src/contract/evaluator.js +158 -0
- package/dist/src/contract/evaluator.js.map +1 -0
- package/dist/src/contract/evidence-store.d.ts +17 -0
- package/dist/src/contract/evidence-store.d.ts.map +1 -0
- package/dist/src/contract/evidence-store.js +113 -0
- package/dist/src/contract/evidence-store.js.map +1 -0
- package/dist/src/contract/executors/zero-deps.d.ts +3 -0
- package/dist/src/contract/executors/zero-deps.d.ts.map +1 -0
- package/dist/src/contract/executors/zero-deps.js +88 -0
- package/dist/src/contract/executors/zero-deps.js.map +1 -0
- package/dist/src/contract/fingerprint.d.ts +34 -0
- package/dist/src/contract/fingerprint.d.ts.map +1 -0
- package/dist/src/contract/fingerprint.js +153 -0
- package/dist/src/contract/fingerprint.js.map +1 -0
- package/dist/src/contract/graph.d.ts +23 -0
- package/dist/src/contract/graph.d.ts.map +1 -0
- package/dist/src/contract/graph.js +158 -0
- package/dist/src/contract/graph.js.map +1 -0
- package/dist/src/contract/migration-map.d.ts +51 -0
- package/dist/src/contract/migration-map.d.ts.map +1 -0
- package/dist/src/contract/migration-map.js +130 -0
- package/dist/src/contract/migration-map.js.map +1 -0
- package/dist/src/contract/types.d.ts +108 -0
- package/dist/src/contract/types.d.ts.map +1 -0
- package/dist/src/contract/types.js +23 -0
- package/dist/src/contract/types.js.map +1 -0
- package/dist/src/index.d.ts +0 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +0 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/integration/drain.d.ts +31 -0
- package/dist/src/integration/drain.d.ts.map +1 -0
- package/dist/src/integration/drain.js +195 -0
- package/dist/src/integration/drain.js.map +1 -0
- package/dist/src/integration/enqueue.d.ts +30 -0
- package/dist/src/integration/enqueue.d.ts.map +1 -0
- package/dist/src/integration/enqueue.js +64 -0
- package/dist/src/integration/enqueue.js.map +1 -0
- package/dist/src/integration/gitops.d.ts +33 -0
- package/dist/src/integration/gitops.d.ts.map +1 -0
- package/dist/src/integration/gitops.js +128 -0
- package/dist/src/integration/gitops.js.map +1 -0
- package/dist/src/integration/lease.d.ts +16 -0
- package/dist/src/integration/lease.d.ts.map +1 -0
- package/dist/src/integration/lease.js +140 -0
- package/dist/src/integration/lease.js.map +1 -0
- package/dist/src/integration/materialize.d.ts +7 -0
- package/dist/src/integration/materialize.d.ts.map +1 -0
- package/dist/src/integration/materialize.js +34 -0
- package/dist/src/integration/materialize.js.map +1 -0
- package/dist/src/integration/store.d.ts +21 -0
- package/dist/src/integration/store.d.ts.map +1 -0
- package/dist/src/integration/store.js +131 -0
- package/dist/src/integration/store.js.map +1 -0
- package/dist/src/integration/types.d.ts +71 -0
- package/dist/src/integration/types.d.ts.map +1 -0
- package/dist/src/integration/types.js +18 -0
- package/dist/src/integration/types.js.map +1 -0
- package/dist/src/onboarding/doctor.d.ts +0 -5
- package/dist/src/onboarding/doctor.d.ts.map +1 -1
- package/dist/src/onboarding/doctor.js +6 -79
- package/dist/src/onboarding/doctor.js.map +1 -1
- package/dist/src/onboarding/npm-token-check.d.ts +1 -1
- package/dist/src/onboarding/npm-token-check.d.ts.map +1 -1
- package/dist/src/onboarding/npm-token-check.js +2 -2
- package/dist/src/onboarding/npm-token-check.js.map +1 -1
- package/dist/src/sdk/context.d.ts +13 -0
- package/dist/src/sdk/context.d.ts.map +1 -0
- package/dist/src/sdk/context.js +128 -0
- package/dist/src/sdk/context.js.map +1 -0
- package/dist/src/sdk/loader.d.ts +25 -0
- package/dist/src/sdk/loader.d.ts.map +1 -0
- package/dist/src/sdk/loader.js +155 -0
- package/dist/src/sdk/loader.js.map +1 -0
- package/dist/src/sdk/scan.d.ts +16 -0
- package/dist/src/sdk/scan.d.ts.map +1 -0
- package/dist/src/sdk/scan.js +126 -0
- package/dist/src/sdk/scan.js.map +1 -0
- package/dist/src/sdk/skills-gen.d.ts +27 -0
- package/dist/src/sdk/skills-gen.d.ts.map +1 -0
- package/dist/src/sdk/skills-gen.js +87 -0
- package/dist/src/sdk/skills-gen.js.map +1 -0
- package/dist/src/sdk/types.d.ts +124 -0
- package/dist/src/sdk/types.d.ts.map +1 -0
- package/dist/src/sdk/types.js +34 -0
- package/dist/src/sdk/types.js.map +1 -0
- package/dist/src/utils/hash.d.ts +1 -0
- package/dist/src/utils/hash.d.ts.map +1 -1
- package/dist/src/utils/hash.js +4 -0
- package/dist/src/utils/hash.js.map +1 -1
- package/dist/{os/mission → src/utils}/lockfile.d.ts +1 -18
- package/dist/src/utils/lockfile.d.ts.map +1 -0
- package/dist/src/utils/lockfile.js +70 -0
- package/dist/src/utils/lockfile.js.map +1 -0
- package/os/codebase/handlers/codebase-measure-symbols.ts +32 -4
- package/os/core/core.module.ts +3 -76
- package/os/core/handlers/assets-helpers.ts +2 -4
- package/os/core/handlers/determinism-check.ts +2 -3
- package/os/core/handlers/lifecycle-handlers.test.ts +529 -0
- package/os/core/handlers/release-prepare.ts +2 -4
- package/os/correctness/gate/trust-boundary-cx18.test.ts +1 -1
- package/os/flow/handlers/flow-peers.ts +1 -1
- package/os/flow/open-missions.ts +45 -0
- package/os/flow/preflight.ts +1 -1
- package/os/flow/tests/release-lines.test.ts +136 -0
- package/os/flow/tests/state-roots.test.ts +1 -48
- package/os/rfc/handlers/validate-corpus.test.ts +149 -0
- package/os/rfc/probe-batch.test.ts +253 -0
- package/os/rfc/probe-batch.ts +13 -6
- package/os/rfc/verifier/rfc-1391/ac10-operating-model-policy.acceptance.test.ts +63 -0
- package/package.json +177 -506
- package/src/command-modules.ts +0 -2
- package/src/contract/core-nodes.ts +111 -0
- package/src/contract/evaluator.ts +207 -0
- package/src/contract/evidence-store.ts +119 -0
- package/src/contract/executors/zero-deps.ts +92 -0
- package/src/contract/fingerprint.ts +176 -0
- package/src/contract/graph.ts +181 -0
- package/src/contract/migration-map.ts +174 -0
- package/src/contract/types.ts +125 -0
- package/src/index.ts +0 -2
- package/src/integration/drain.ts +271 -0
- package/src/integration/enqueue.ts +92 -0
- package/src/integration/gitops.ts +174 -0
- package/src/integration/lease.ts +144 -0
- package/src/integration/materialize.ts +40 -0
- package/src/integration/store.ts +153 -0
- package/src/integration/types.ts +79 -0
- package/src/onboarding/doctor.ts +9 -96
- package/src/onboarding/npm-token-check.ts +3 -3
- package/src/sdk/context.ts +135 -0
- package/src/sdk/loader.ts +170 -0
- package/src/sdk/scan.ts +132 -0
- package/src/sdk/skills-gen.ts +104 -0
- package/src/sdk/types.ts +135 -0
- package/src/tests/pkg-health-self-scan.test.ts +29 -0
- package/src/tests/rfc-evidence-sync.test.ts +369 -0
- package/src/tests/skill-agents-sync.test.ts +192 -0
- package/src/utils/hash.ts +5 -0
- package/src/utils/lockfile.ts +78 -0
- package/dist/os/core/handlers/forge-autonomy-validate.d.ts +0 -25
- package/dist/os/core/handlers/forge-autonomy-validate.d.ts.map +0 -1
- package/dist/os/core/handlers/forge-autonomy-validate.js +0 -208
- package/dist/os/core/handlers/forge-autonomy-validate.js.map +0 -1
- package/dist/os/mission/handlers/archive.d.ts +0 -4
- package/dist/os/mission/handlers/archive.d.ts.map +0 -1
- package/dist/os/mission/handlers/archive.js +0 -583
- package/dist/os/mission/handlers/archive.js.map +0 -1
- package/dist/os/mission/importer-block.d.ts +0 -19
- package/dist/os/mission/importer-block.d.ts.map +0 -1
- package/dist/os/mission/importer-block.js +0 -124
- package/dist/os/mission/importer-block.js.map +0 -1
- package/dist/os/mission/index.d.ts +0 -2
- package/dist/os/mission/index.d.ts.map +0 -1
- package/dist/os/mission/index.js +0 -15
- package/dist/os/mission/index.js.map +0 -1
- package/dist/os/mission/lockfile.d.ts.map +0 -1
- package/dist/os/mission/lockfile.js +0 -138
- package/dist/os/mission/lockfile.js.map +0 -1
- package/dist/os/mission/mission.module.d.ts +0 -3
- package/dist/os/mission/mission.module.d.ts.map +0 -1
- package/dist/os/mission/mission.module.js +0 -63
- package/dist/os/mission/mission.module.js.map +0 -1
- package/dist/os/mission/open-missions.d.ts.map +0 -1
- package/dist/os/mission/open-missions.js +0 -42
- package/dist/os/mission/open-missions.js.map +0 -1
- package/dist/os/mission/types.d.ts +0 -23
- package/dist/os/mission/types.d.ts.map +0 -1
- package/dist/os/mission/types.js +0 -19
- package/dist/os/mission/types.js.map +0 -1
- package/dist/os/werkstatt/handlers/lock.d.ts +0 -10
- package/dist/os/werkstatt/handlers/lock.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/lock.js +0 -153
- package/dist/os/werkstatt/handlers/lock.js.map +0 -1
- package/dist/os/werkstatt/handlers/schema.d.ts +0 -33
- package/dist/os/werkstatt/handlers/schema.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/schema.js +0 -42
- package/dist/os/werkstatt/handlers/schema.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts +0 -15
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js +0 -171
- package/dist/os/werkstatt/handlers/werkstatt-lock-recover.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts +0 -18
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.js +0 -51
- package/dist/os/werkstatt/handlers/werkstatt-lock-status.js.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts +0 -11
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js +0 -86
- package/dist/os/werkstatt/handlers/werkstatt-operation-validate.js.map +0 -1
- package/dist/os/werkstatt/handlers/workspace-deps.d.ts +0 -12
- package/dist/os/werkstatt/handlers/workspace-deps.d.ts.map +0 -1
- package/dist/os/werkstatt/handlers/workspace-deps.js +0 -42
- package/dist/os/werkstatt/handlers/workspace-deps.js.map +0 -1
- package/dist/os/werkstatt/index.d.ts +0 -7
- package/dist/os/werkstatt/index.d.ts.map +0 -1
- package/dist/os/werkstatt/index.js +0 -18
- package/dist/os/werkstatt/index.js.map +0 -1
- package/dist/os/werkstatt/werkstatt.module.d.ts +0 -3
- package/dist/os/werkstatt/werkstatt.module.d.ts.map +0 -1
- package/dist/os/werkstatt/werkstatt.module.js +0 -91
- package/dist/os/werkstatt/werkstatt.module.js.map +0 -1
- package/os/core/handlers/forge-autonomy-validate.ts +0 -276
- package/os/correctness/gate/trust-boundary-cx19.test.ts +0 -514
- package/os/mission/handlers/archive.test.ts +0 -764
- package/os/mission/handlers/archive.ts +0 -711
- package/os/mission/handlers/ship-inflight-degraded.test.ts +0 -105
- package/os/mission/importer-block.ts +0 -119
- package/os/mission/index.ts +0 -15
- package/os/mission/lockfile.ts +0 -152
- package/os/mission/mission.module.ts +0 -68
- package/os/mission/open-missions.ts +0 -50
- package/os/mission/types.ts +0 -42
- package/os/werkstatt/handlers/lock.ts +0 -168
- package/os/werkstatt/handlers/schema.ts +0 -47
- package/os/werkstatt/handlers/werkstatt-lock-recover.ts +0 -206
- package/os/werkstatt/handlers/werkstatt-lock-status.ts +0 -82
- package/os/werkstatt/handlers/werkstatt-operation-validate.ts +0 -112
- package/os/werkstatt/handlers/workspace-deps.ts +0 -56
- package/os/werkstatt/index.ts +0 -39
- package/os/werkstatt/werkstatt.module.ts +0 -95
- package/src/tests/doctor-autonomy.test.ts +0 -246
- package/src/tests/forge-autonomy-validate.test.ts +0 -159
- package/src/tests/werkstatt-lock.test.ts +0 -357
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>Release-line discovery tests (RFC-1488, AC-2 foundation): temp
|
|
4
|
+
workspaces exercise the pnpm-workspace glob expansion, the
|
|
5
|
+
`extract.config.yaml` publishability marker, negated globs and the
|
|
6
|
+
FLOW-VER-02 basename collision; a read-only pass over the real werkstatt
|
|
7
|
+
root pins the expected line set.</purpose>
|
|
8
|
+
<non-goals>
|
|
9
|
+
<item>No tag or version math — release-tags/release-level tests own those.</item>
|
|
10
|
+
</non-goals>
|
|
11
|
+
</MODULE_CONTRACT>
|
|
12
|
+
<CHANGE_SUMMARY>
|
|
13
|
+
<item>RFC-1488: step 1 — release-lines discovery tests</item>
|
|
14
|
+
<item>RFC-1488: step 1 — semver helper + release-line discovery (extract.config.yaml workspace globs)</item>
|
|
15
|
+
<item>RFC-1540: count the intake-validator release line in the werkstatt root discovery test</item>
|
|
16
|
+
</CHANGE_SUMMARY>
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
|
|
20
|
+
import { tmpdir } from "node:os";
|
|
21
|
+
import { dirname, join } from "node:path";
|
|
22
|
+
import { fileURLToPath } from "node:url";
|
|
23
|
+
|
|
24
|
+
import { afterEach, describe, expect, it } from "vitest";
|
|
25
|
+
|
|
26
|
+
import { ambientIo } from "../../../src/utils/io.ts";
|
|
27
|
+
import { discoverReleaseLines } from "../release-lines.ts";
|
|
28
|
+
|
|
29
|
+
const dirs: string[] = [];
|
|
30
|
+
|
|
31
|
+
afterEach(async () => {
|
|
32
|
+
for (const dir of dirs.splice(0)) {
|
|
33
|
+
await rm(dir, { recursive: true, force: true });
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
async function tempRepo(): Promise<string> {
|
|
38
|
+
const dir = await mkdtemp(join(tmpdir(), "flow-lines-"));
|
|
39
|
+
dirs.push(dir);
|
|
40
|
+
return dir;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function touch(repo: string, rel: string, content = ""): Promise<void> {
|
|
44
|
+
await mkdir(join(repo, rel.split("/").slice(0, -1).join("/")), { recursive: true });
|
|
45
|
+
await writeFile(join(repo, rel), content);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe("discoverReleaseLines", () => {
|
|
49
|
+
it("reports the repo line plus every extract.config.yaml workspace dir", async () => {
|
|
50
|
+
const repo = await tempRepo();
|
|
51
|
+
await touch(repo, "package.json", '{ "version": "1.0.0" }\n');
|
|
52
|
+
await touch(
|
|
53
|
+
repo,
|
|
54
|
+
"pnpm-workspace.yaml",
|
|
55
|
+
"packages:\n - 'packages/*'\n - 'missions/*/workpiece'\n",
|
|
56
|
+
);
|
|
57
|
+
await touch(repo, "packages/forge/package.json", '{ "version": "9.0.0" }\n');
|
|
58
|
+
await touch(repo, "packages/forge/extract.config.yaml", "forgePlugin: true\n");
|
|
59
|
+
await touch(repo, "packages/pbp/package.json", '{ "version": "2.1.0" }\n');
|
|
60
|
+
await touch(repo, "packages/pbp/extract.config.yaml", "forgePlugin: false\n");
|
|
61
|
+
await touch(repo, "packages/no-extract/package.json", '{ "version": "0.0.1" }\n');
|
|
62
|
+
await touch(repo, "missions/m1/workpiece/src/index.ts", "// workpiece\n");
|
|
63
|
+
|
|
64
|
+
const { lines, diagnostics } = await discoverReleaseLines(repo, ambientIo);
|
|
65
|
+
expect(diagnostics).toEqual([]);
|
|
66
|
+
expect(lines.map((l) => l.id).sort()).toEqual(["forge", "pbp", "repo"]);
|
|
67
|
+
const forge = lines.find((l) => l.id === "forge");
|
|
68
|
+
expect(forge).toMatchObject({
|
|
69
|
+
tagPrefix: "forge@",
|
|
70
|
+
versionFile: "packages/forge/package.json",
|
|
71
|
+
paths: ["packages/forge"],
|
|
72
|
+
});
|
|
73
|
+
const repoLine = lines.find((l) => l.id === "repo");
|
|
74
|
+
expect(repoLine).toMatchObject({ tagPrefix: "v", versionFile: "package.json", paths: [] });
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("reports a null versionFile when the repo has no root package.json", async () => {
|
|
78
|
+
const repo = await tempRepo();
|
|
79
|
+
const { lines } = await discoverReleaseLines(repo, ambientIo);
|
|
80
|
+
expect(lines).toEqual([
|
|
81
|
+
{ id: "repo", tagPrefix: "v", versionFile: null, paths: [] },
|
|
82
|
+
]);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("skips negated glob matches and node_modules", async () => {
|
|
86
|
+
const repo = await tempRepo();
|
|
87
|
+
await touch(repo, "package.json", '{ "version": "1.0.0" }\n');
|
|
88
|
+
await touch(
|
|
89
|
+
repo,
|
|
90
|
+
"pnpm-workspace.yaml",
|
|
91
|
+
"packages:\n - 'packages/*'\n - '!packages/internal'\n",
|
|
92
|
+
);
|
|
93
|
+
await touch(repo, "packages/internal/extract.config.yaml", "forgePlugin: false\n");
|
|
94
|
+
await touch(repo, "packages/forge/extract.config.yaml", "forgePlugin: true\n");
|
|
95
|
+
await touch(repo, "packages/node_modules/x/extract.config.yaml", "x: 1\n");
|
|
96
|
+
|
|
97
|
+
const { lines, diagnostics } = await discoverReleaseLines(repo, ambientIo);
|
|
98
|
+
expect(diagnostics).toEqual([]);
|
|
99
|
+
expect(lines.map((l) => l.id).sort()).toEqual(["forge", "repo"]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("refuses colliding basenames with FLOW-VER-02 naming both dirs", async () => {
|
|
103
|
+
const repo = await tempRepo();
|
|
104
|
+
await touch(repo, "package.json", '{ "version": "1.0.0" }\n');
|
|
105
|
+
await touch(
|
|
106
|
+
repo,
|
|
107
|
+
"pnpm-workspace.yaml",
|
|
108
|
+
"packages:\n - 'packages/*/x'\n - 'services/*'\n",
|
|
109
|
+
);
|
|
110
|
+
await touch(repo, "packages/a/x/extract.config.yaml", "forgePlugin: false\n");
|
|
111
|
+
await touch(repo, "services/x/extract.config.yaml", "forgePlugin: false\n");
|
|
112
|
+
await touch(repo, "services/keep/extract.config.yaml", "forgePlugin: false\n");
|
|
113
|
+
|
|
114
|
+
const { lines, diagnostics } = await discoverReleaseLines(repo, ambientIo);
|
|
115
|
+
const collision = diagnostics.filter((d) => d.ruleId === "FLOW-VER-02");
|
|
116
|
+
expect(collision).toHaveLength(1);
|
|
117
|
+
expect(collision[0]?.severity).toBe("error");
|
|
118
|
+
expect(collision[0]?.message).toContain("x");
|
|
119
|
+
expect(collision[0]?.message).toContain("packages/a/x");
|
|
120
|
+
expect(collision[0]?.message).toContain("services/x");
|
|
121
|
+
// The non-colliding line still lands; the collided id is absent.
|
|
122
|
+
expect(lines.map((l) => l.id).sort()).toEqual(["keep", "repo"]);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it("the real monorepo root discovers repo plus its published package lines", async () => {
|
|
126
|
+
const root = join(dirname(fileURLToPath(import.meta.url)), "../../../../..");
|
|
127
|
+
const { lines, diagnostics } = await discoverReleaseLines(root, ambientIo);
|
|
128
|
+
expect(diagnostics.filter((d) => d.ruleId === "FLOW-VER-02")).toEqual([]);
|
|
129
|
+
// v10 authoring monorepo (RFC-1649): a directory joins the release-line set
|
|
130
|
+
// when it carries extract.config.yaml — the publishability fact. Today that
|
|
131
|
+
// is packages/forge + packages/forge-typescript plus the repo line itself;
|
|
132
|
+
// the first-party plugin scaffolds (forge-astro, forge-repo-extract,
|
|
133
|
+
// forge-system) join when WP-5 makes them publishable.
|
|
134
|
+
expect(lines.map((l) => l.id).sort()).toEqual(["forge", "forge-typescript", "repo"]);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -17,17 +17,14 @@ mission source stays where the command ran.
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { test, expect, describe, afterEach } from "vitest";
|
|
20
|
-
import { mkdtemp,
|
|
21
|
-
import { existsSync } from "node:fs";
|
|
20
|
+
import { mkdtemp, rm } from "node:fs/promises";
|
|
22
21
|
import { tmpdir } from "node:os";
|
|
23
22
|
import { basename, dirname, join } from "node:path";
|
|
24
23
|
|
|
25
24
|
import { ambientIo } from "../../../src/utils/io.ts";
|
|
26
25
|
import { canonicalRepoDir } from "../../../src/utils/repo-path.ts";
|
|
27
|
-
import type { ForgeCommandInput, ForgeRuntimeContext } from "../../../src/types.ts";
|
|
28
26
|
|
|
29
27
|
import { resolveStateRoots } from "../worktree-path.ts";
|
|
30
|
-
import { runMissionArchive } from "../../mission/handlers/archive.ts";
|
|
31
28
|
import { gitExec, initRepo } from "./helpers.ts";
|
|
32
29
|
|
|
33
30
|
const io = ambientIo;
|
|
@@ -37,26 +34,6 @@ afterEach(async () => {
|
|
|
37
34
|
for (const d of dirs.splice(0)) await rm(d, { recursive: true, force: true });
|
|
38
35
|
});
|
|
39
36
|
|
|
40
|
-
function makeContext(workspaceRoot: string): ForgeRuntimeContext {
|
|
41
|
-
return {
|
|
42
|
-
workspaceRoot,
|
|
43
|
-
io,
|
|
44
|
-
logger: {
|
|
45
|
-
info: () => {},
|
|
46
|
-
success: () => {},
|
|
47
|
-
warn: () => {},
|
|
48
|
-
error: () => {},
|
|
49
|
-
debug: () => {},
|
|
50
|
-
},
|
|
51
|
-
outputFormat: "json",
|
|
52
|
-
dryRun: false,
|
|
53
|
-
} as unknown as ForgeRuntimeContext;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function makeInput(flags: Record<string, unknown> = {}): ForgeCommandInput {
|
|
57
|
-
return { commandName: "mission.archive", flags } as unknown as ForgeCommandInput;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
37
|
describe("resolveStateRoots (RFC-1495)", () => {
|
|
61
38
|
test("single-worktree repo resolves every root to itself", async () => {
|
|
62
39
|
const repo = await initRepo({ prefix: "state-roots-" });
|
|
@@ -100,28 +77,4 @@ describe("resolveStateRoots (RFC-1495)", () => {
|
|
|
100
77
|
});
|
|
101
78
|
});
|
|
102
79
|
|
|
103
|
-
test("mission.archive run in a session worktree lands in the primary archive", async () => {
|
|
104
|
-
const repo = await initRepo({ prefix: "state-roots-" });
|
|
105
|
-
dirs.push(repo);
|
|
106
|
-
const wt = join(dirname(repo), `${basename(repo)}@session-y`);
|
|
107
|
-
const add = await gitExec(repo, ["worktree", "add", "-b", "session-y", wt]);
|
|
108
|
-
expect(add.exitCode).toBe(0);
|
|
109
|
-
dirs.push(wt);
|
|
110
|
-
|
|
111
|
-
// A closed mission exists in the session worktree only.
|
|
112
|
-
const missionId = "acme-m000001";
|
|
113
|
-
const missionDir = join(wt, "missions", missionId);
|
|
114
|
-
await mkdir(missionDir, { recursive: true });
|
|
115
|
-
await writeFile(join(missionDir, "mission.yaml"), `missionId: ${missionId}\nstate: closed\n`);
|
|
116
|
-
|
|
117
|
-
const result = await runMissionArchive(makeInput(), makeContext(wt));
|
|
118
|
-
expect(result.exitCode ?? 0).toBe(0);
|
|
119
|
-
|
|
120
|
-
// Durable target: the primary's missions/archive/closed/, never the wt's.
|
|
121
|
-
expect(existsSync(join(repo, "missions", "archive", "closed", missionId, "mission.yaml"))).toBe(
|
|
122
|
-
true,
|
|
123
|
-
);
|
|
124
|
-
expect(existsSync(join(wt, "missions", "archive"))).toBe(false);
|
|
125
|
-
expect(existsSync(missionDir)).toBe(false);
|
|
126
|
-
});
|
|
127
80
|
});
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
Unit tests for the frontmatter-only corpus read path — readRfcFrontmatter bounded-head semantics, >64 KiB full-parse fallback, error parity, and AC-9 frontmatter parity across the real corpus (RFC-1489).
|
|
5
|
+
</purpose>
|
|
6
|
+
<non-goals>
|
|
7
|
+
<item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
|
|
8
|
+
</non-goals>
|
|
9
|
+
</MODULE_CONTRACT>
|
|
10
|
+
<CHANGE_SUMMARY>
|
|
11
|
+
<item>RFC-1489: frontmatter-only corpus read coverage.</item>
|
|
12
|
+
</CHANGE_SUMMARY>
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { test, expect, describe } from "vitest";
|
|
16
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
import { tmpdir } from "node:os";
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
readRfcFrontmatter,
|
|
22
|
+
readAndParseRfc,
|
|
23
|
+
listRfcFiles,
|
|
24
|
+
} from "../frontmatter-io.ts";
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
describe("readRfcFrontmatter — AC-5/AC-6 corpus reads", () => {
|
|
28
|
+
const fmDoc = (id: string, extra = ""): string =>
|
|
29
|
+
`---\nid: ${id}\nstatus: draft\n${extra}---\n\n# Body ${id}\n\nSome body text.\n`;
|
|
30
|
+
|
|
31
|
+
test("returns frontmatter with an empty body (AC-5)", async () => {
|
|
32
|
+
const dir = mkdtempSync(join(tmpdir(), "fm-io-"));
|
|
33
|
+
try {
|
|
34
|
+
writeFileSync(join(dir, "rfc-0001-a.md"), fmDoc("RFC-0001"));
|
|
35
|
+
const res = await readRfcFrontmatter(dir, "rfc-0001-a.md");
|
|
36
|
+
expect(res && "parsed" in res ? res.parsed.frontmatter["id"] : undefined).toBe("RFC-0001");
|
|
37
|
+
expect(res && "parsed" in res ? res.parsed.body : "x").toBe("");
|
|
38
|
+
} finally {
|
|
39
|
+
rmSync(dir, { recursive: true, force: true });
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test("falls back to full parse when the closing fence exceeds the bound (AC-6)", async () => {
|
|
44
|
+
const dir = mkdtempSync(join(tmpdir(), "fm-io-big-"));
|
|
45
|
+
try {
|
|
46
|
+
// A >64 KiB frontmatter block: the bounded head cannot see the fence.
|
|
47
|
+
const big = `note: "${"y".repeat(70 * 1024)}"\n`;
|
|
48
|
+
writeFileSync(join(dir, "rfc-0002-big.md"), fmDoc("RFC-0002", big));
|
|
49
|
+
const res = await readRfcFrontmatter(dir, "rfc-0002-big.md");
|
|
50
|
+
expect(res && "parsed" in res ? res.parsed.frontmatter["id"] : undefined).toBe("RFC-0002");
|
|
51
|
+
// Full-parse fallback populates the body.
|
|
52
|
+
expect(res && "parsed" in res ? res.parsed.body : "").toContain("# Body RFC-0002");
|
|
53
|
+
} finally {
|
|
54
|
+
rmSync(dir, { recursive: true, force: true });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("small file without a closing fence yields empty frontmatter", async () => {
|
|
59
|
+
const dir = mkdtempSync(join(tmpdir(), "fm-io-nofm-"));
|
|
60
|
+
try {
|
|
61
|
+
writeFileSync(join(dir, "rfc-0003-bare.md"), "# No frontmatter\n\nbody\n");
|
|
62
|
+
const res = await readRfcFrontmatter(dir, "rfc-0003-bare.md");
|
|
63
|
+
expect(res && "parsed" in res ? res.parsed.frontmatter : { x: 1 }).toEqual({});
|
|
64
|
+
} finally {
|
|
65
|
+
rmSync(dir, { recursive: true, force: true });
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("malformed YAML produces the same error variant as full parse", async () => {
|
|
70
|
+
const dir = mkdtempSync(join(tmpdir(), "fm-io-bad-"));
|
|
71
|
+
try {
|
|
72
|
+
writeFileSync(join(dir, "rfc-0004-bad.md"), "---\nid: [unclosed\n---\nbody\n");
|
|
73
|
+
const slim = await readRfcFrontmatter(dir, "rfc-0004-bad.md");
|
|
74
|
+
const full = await readAndParseRfc(dir, "rfc-0004-bad.md");
|
|
75
|
+
expect(slim && "error" in slim).toBe(true);
|
|
76
|
+
expect(full && "error" in full).toBe(true);
|
|
77
|
+
expect(slim && "error" in slim ? slim.error : "").toBe(
|
|
78
|
+
full && "error" in full ? full.error : "",
|
|
79
|
+
);
|
|
80
|
+
} finally {
|
|
81
|
+
rmSync(dir, { recursive: true, force: true });
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe("AC-9 — frontmatter-only corpus produces the same rule input as full parse", () => {
|
|
87
|
+
test(
|
|
88
|
+
"every corpus file: frontmatter identical between the two paths",
|
|
89
|
+
async () => {
|
|
90
|
+
// v10 (RFC-1649): the authoring monorepo carries no hundred-file RFC
|
|
91
|
+
// corpus of its own — the v9 test scanned werkstatt's. The parity
|
|
92
|
+
// property is generic, so the corpus is synthesized here: diverse YAML
|
|
93
|
+
// shapes exercising exactly the scan/parse divergence surface (nested
|
|
94
|
+
// maps, flow + block sequences, multiline scalars, unicode, quotes,
|
|
95
|
+
// empty + malformed frontmatter).
|
|
96
|
+
const dir = mkdtempSync(join(tmpdir(), "fm-corpus-"));
|
|
97
|
+
try {
|
|
98
|
+
const shapes: Array<[string, string]> = [
|
|
99
|
+
["simple", "id: RFC-1001\nstatus: draft\n"],
|
|
100
|
+
["nested-map", "id: RFC-1002\nmeta:\n author: a\n tags:\n x: 1\n"],
|
|
101
|
+
["flow-seq", "id: RFC-1003\nrefs: [RFC-0001, RFC-0002]\n"],
|
|
102
|
+
["block-seq", "id: RFC-1004\nrefs:\n - RFC-0001\n - RFC-0002\n"],
|
|
103
|
+
["multiline-literal", "id: RFC-1005\nnote: |\n line one\n line two\n"],
|
|
104
|
+
["multiline-folded", "id: RFC-1006\nnote: >\n fold one\n fold two\n"],
|
|
105
|
+
["unicode", "id: RFC-1007\ntitle: Ünïcödé — тест\n"],
|
|
106
|
+
["quoted", 'id: RFC-1008\ntitle: "quoted: with colon"\n'],
|
|
107
|
+
["single-quoted", "id: RFC-1009\ntitle: 'single ''quote'''\n"],
|
|
108
|
+
["numbers", "id: RFC-1010\nversion: 2\nratio: 0.5\n"],
|
|
109
|
+
["booleans", "id: RFC-1011\nactive: true\narchived: false\n"],
|
|
110
|
+
["null-value", "id: RFC-1012\nsuperseded-by: null\n"],
|
|
111
|
+
["empty-fm", ""],
|
|
112
|
+
["deep-nesting", "id: RFC-1014\na:\n b:\n c:\n d: [1, 2, { e: f }]\n"],
|
|
113
|
+
["colon-in-value", "id: RFC-1015\nurl: https://example.com/x\n"],
|
|
114
|
+
["dashes-in-key", "id: RFC-1016\nx-custom-key: v\n"],
|
|
115
|
+
["long-value", `id: RFC-1017\nnote: "${"y".repeat(2000)}"\n`],
|
|
116
|
+
["mixed-types", "id: RFC-1018\nn: 1\ns: text\nb: true\nl:\n - 1\n - two\n"],
|
|
117
|
+
["indented-seq", "id: RFC-1019\nitems:\n - one\n - two\n"],
|
|
118
|
+
["comment-in-fm", "id: RFC-1020\n# a comment\nstatus: draft\n"],
|
|
119
|
+
["date-ish", "id: RFC-1021\ncreated: 2026-11-25\n"],
|
|
120
|
+
["empty-string", 'id: RFC-1022\nnote: ""\n'],
|
|
121
|
+
["anchor-free-dup", "id: RFC-1023\nx: a\ny: a\nz: a\n"],
|
|
122
|
+
["malformed-unclosed", "id: [unclosed\n"],
|
|
123
|
+
];
|
|
124
|
+
for (const [name, fm] of shapes) {
|
|
125
|
+
writeFileSync(join(dir, `rfc-${name}.md`), `---\n${fm}---\n\n# Body\n\ntext\n`);
|
|
126
|
+
}
|
|
127
|
+
const files = await listRfcFiles(dir);
|
|
128
|
+
expect(files.length).toBeGreaterThan(15);
|
|
129
|
+
for (const f of files) {
|
|
130
|
+
const slim = await readRfcFrontmatter(dir, f);
|
|
131
|
+
const full = await readAndParseRfc(dir, f);
|
|
132
|
+
if (!slim || !full) continue;
|
|
133
|
+
if ("error" in slim || "error" in full) {
|
|
134
|
+
expect("error" in slim, `error parity for ${f}`).toBe("error" in full);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
// Referential rules consume only this map — identical input means an
|
|
138
|
+
// identical violation set.
|
|
139
|
+
expect(slim.parsed.frontmatter, `frontmatter parity for ${f}`).toEqual(
|
|
140
|
+
full.parsed.frontmatter,
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
} finally {
|
|
144
|
+
rmSync(dir, { recursive: true, force: true });
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
120_000,
|
|
148
|
+
);
|
|
149
|
+
});
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/*
|
|
2
|
+
<MODULE_CONTRACT>
|
|
3
|
+
<purpose>
|
|
4
|
+
Unit tests for probe-batch — segment planning across barriers, per-(file,testName) report attribution, runProbeSet ordering and --no-batch escape, and the one-spawn e2e (RFC-1489).
|
|
5
|
+
</purpose>
|
|
6
|
+
<non-goals>
|
|
7
|
+
<item>Not a contract source of truth — the module under test owns the authoritative behavior; fixtures are minimal scaffolding only.</item>
|
|
8
|
+
</non-goals>
|
|
9
|
+
</MODULE_CONTRACT>
|
|
10
|
+
<CHANGE_SUMMARY>
|
|
11
|
+
<item>RFC-1489: batched test-probe planning + attribution coverage.</item>
|
|
12
|
+
</CHANGE_SUMMARY>
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { test, expect, describe } from "vitest";
|
|
16
|
+
import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
|
|
17
|
+
import { join } from "node:path";
|
|
18
|
+
import { tmpdir } from "node:os";
|
|
19
|
+
|
|
20
|
+
import {
|
|
21
|
+
planProbeSegments,
|
|
22
|
+
attributeProbeResult,
|
|
23
|
+
runBatchedTestSegment,
|
|
24
|
+
type ProbeSegment,
|
|
25
|
+
} from "./probe-batch.ts";
|
|
26
|
+
import { runProbeSet } from "./acceptance.ts";
|
|
27
|
+
import type { AcceptanceProbe } from "./types.ts";
|
|
28
|
+
|
|
29
|
+
const WORKSPACE_ROOT = join(__dirname, "..", "..", "..", "..");
|
|
30
|
+
|
|
31
|
+
const testProbe = (
|
|
32
|
+
file: string,
|
|
33
|
+
overrides: Partial<Extract<AcceptanceProbe, { probe: "test" }>> = {},
|
|
34
|
+
): Extract<AcceptanceProbe, { probe: "test" }> => ({
|
|
35
|
+
probe: "test",
|
|
36
|
+
file,
|
|
37
|
+
expect: { exitCode: 0 },
|
|
38
|
+
...overrides,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const fileExists = (path: string): AcceptanceProbe => ({ probe: "file-exists", path });
|
|
42
|
+
const runProbe = (command: string): AcceptanceProbe => ({
|
|
43
|
+
probe: "run",
|
|
44
|
+
command,
|
|
45
|
+
expect: { exitCode: 0 },
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
describe("planProbeSegments — AC-1 barrier-free grouping", () => {
|
|
49
|
+
test("contiguous same-bound test probes form one segment", () => {
|
|
50
|
+
const probes = [
|
|
51
|
+
testProbe("a.test.ts"),
|
|
52
|
+
testProbe("b.test.ts"),
|
|
53
|
+
testProbe("c.test.ts", { timeoutMs: 120_000 }),
|
|
54
|
+
];
|
|
55
|
+
expect(planProbeSegments(probes, 120_000)).toEqual([
|
|
56
|
+
{ start: 0, members: [0, 1, 2], boundMs: 120_000 },
|
|
57
|
+
]);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("a timeoutMs change closes the segment", () => {
|
|
61
|
+
const probes = [
|
|
62
|
+
testProbe("a.test.ts"),
|
|
63
|
+
testProbe("b.test.ts", { timeoutMs: 5_000 }),
|
|
64
|
+
testProbe("c.test.ts"),
|
|
65
|
+
];
|
|
66
|
+
expect(planProbeSegments(probes, 120_000)).toEqual([
|
|
67
|
+
{ start: 0, members: [0], boundMs: 120_000 },
|
|
68
|
+
{ start: 1, members: [1], boundMs: 5_000 },
|
|
69
|
+
{ start: 2, members: [2], boundMs: 120_000 },
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("run/page/proof are the only barriers — other kinds span without splitting", () => {
|
|
74
|
+
const probes: AcceptanceProbe[] = [
|
|
75
|
+
testProbe("a.test.ts"),
|
|
76
|
+
runProbe("site-kernel run x"),
|
|
77
|
+
testProbe("b.test.ts"),
|
|
78
|
+
{ probe: "page", target: "site", path: "/", expect: { status: 200 } } as AcceptanceProbe,
|
|
79
|
+
testProbe("c.test.ts"),
|
|
80
|
+
{ probe: "proof", spec: "s.yaml" },
|
|
81
|
+
testProbe("d.test.ts"),
|
|
82
|
+
fileExists("x.txt"),
|
|
83
|
+
testProbe("e.test.ts"),
|
|
84
|
+
];
|
|
85
|
+
expect(planProbeSegments(probes, 120_000)).toEqual([
|
|
86
|
+
{ start: 0, members: [0], boundMs: 120_000 },
|
|
87
|
+
{ start: 2, members: [2], boundMs: 120_000 },
|
|
88
|
+
{ start: 4, members: [4], boundMs: 120_000 },
|
|
89
|
+
{ start: 6, members: [6, 8], boundMs: 120_000 },
|
|
90
|
+
]);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("attributeProbeResult — AC-2/AC-3 per-slice attribution", () => {
|
|
95
|
+
const report = {
|
|
96
|
+
testResults: [
|
|
97
|
+
{
|
|
98
|
+
name: join(WORKSPACE_ROOT, "os/rfc/a.test.ts"),
|
|
99
|
+
status: "passed",
|
|
100
|
+
assertionResults: [
|
|
101
|
+
{ title: "first", fullName: "suite first", status: "passed" },
|
|
102
|
+
{ title: "second", fullName: "suite second", status: "passed" },
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: join(WORKSPACE_ROOT, "os/rfc/b.test.ts"),
|
|
107
|
+
status: "failed",
|
|
108
|
+
assertionResults: [
|
|
109
|
+
{ title: "x", fullName: "bsuite x", status: "failed" },
|
|
110
|
+
{ title: "y", fullName: "bsuite y", status: "passed" },
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
test("each probe derives only from its own file slice", () => {
|
|
117
|
+
const a = attributeProbeResult(testProbe("os/rfc/a.test.ts"), WORKSPACE_ROOT, report);
|
|
118
|
+
const b = attributeProbeResult(testProbe("os/rfc/b.test.ts"), WORKSPACE_ROOT, report);
|
|
119
|
+
expect(a.ok).toBe(true);
|
|
120
|
+
expect(a.verdict).toBe("pass");
|
|
121
|
+
expect(b.ok).toBe(false);
|
|
122
|
+
expect(b.verdict).toBe("fail");
|
|
123
|
+
expect(b.detail).toContain("expected 0");
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
test("testName attribution matches only its own assertions", () => {
|
|
127
|
+
const ok = attributeProbeResult(
|
|
128
|
+
testProbe("os/rfc/b.test.ts", { testName: "bsuite y" }),
|
|
129
|
+
WORKSPACE_ROOT,
|
|
130
|
+
report,
|
|
131
|
+
);
|
|
132
|
+
expect(ok.ok).toBe(true);
|
|
133
|
+
const fail = attributeProbeResult(
|
|
134
|
+
testProbe("os/rfc/b.test.ts", { testName: "bsuite x" }),
|
|
135
|
+
WORKSPACE_ROOT,
|
|
136
|
+
report,
|
|
137
|
+
);
|
|
138
|
+
expect(fail.ok).toBe(false);
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
test("expected-nonzero exitCode inverts the derived verdict", () => {
|
|
142
|
+
const p = attributeProbeResult(
|
|
143
|
+
testProbe("os/rfc/b.test.ts", { expect: { exitCode: 1 } }),
|
|
144
|
+
WORKSPACE_ROOT,
|
|
145
|
+
report,
|
|
146
|
+
);
|
|
147
|
+
expect(p.ok).toBe(true);
|
|
148
|
+
expect(p.verdict).toBe("pass");
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("absent file slice is unverified, never pass", () => {
|
|
152
|
+
const p = attributeProbeResult(testProbe("os/rfc/missing.test.ts"), WORKSPACE_ROOT, report);
|
|
153
|
+
expect(p.ok).toBe(false);
|
|
154
|
+
expect(p.verdict).toBe("unverified");
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("testName matching no assertion is a fail (vitest -t parity, spec §4)", () => {
|
|
158
|
+
const p = attributeProbeResult(
|
|
159
|
+
testProbe("os/rfc/a.test.ts", { testName: "no such test" }),
|
|
160
|
+
WORKSPACE_ROOT,
|
|
161
|
+
report,
|
|
162
|
+
);
|
|
163
|
+
expect(p.ok).toBe(false);
|
|
164
|
+
expect(p.verdict).toBe("fail");
|
|
165
|
+
expect(p.detail).toContain("no testName match");
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test("file-level requires status passed — skipped cannot prove execution", () => {
|
|
169
|
+
const skipped = {
|
|
170
|
+
testResults: [
|
|
171
|
+
{
|
|
172
|
+
name: join(WORKSPACE_ROOT, "os/rfc/s.test.ts"),
|
|
173
|
+
status: "skipped",
|
|
174
|
+
assertionResults: [{ title: "x", fullName: "s x", status: "skipped" }],
|
|
175
|
+
},
|
|
176
|
+
],
|
|
177
|
+
};
|
|
178
|
+
const p = attributeProbeResult(testProbe("os/rfc/s.test.ts"), WORKSPACE_ROOT, skipped);
|
|
179
|
+
expect(p.ok).toBe(false);
|
|
180
|
+
expect(p.verdict).not.toBe("pass");
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe("runProbeSet — AC-2 order/shape, AC-4 --no-batch", () => {
|
|
185
|
+
test("preserves declared order across barriers; missing files are unverified", async () => {
|
|
186
|
+
const dir = mkdtempSync(join(tmpdir(), "probe-set-"));
|
|
187
|
+
try {
|
|
188
|
+
writeFileSync(join(dir, "present.txt"), "x");
|
|
189
|
+
const probes: AcceptanceProbe[] = [
|
|
190
|
+
fileExists("present.txt"),
|
|
191
|
+
testProbe("missing-a.test.ts"),
|
|
192
|
+
testProbe("missing-b.test.ts"),
|
|
193
|
+
fileExists("absent.txt"),
|
|
194
|
+
testProbe("missing-c.test.ts"),
|
|
195
|
+
];
|
|
196
|
+
const { results, durationsMs } = await runProbeSet(probes, { workspaceRoot: dir });
|
|
197
|
+
expect(results).toHaveLength(5);
|
|
198
|
+
expect(results[0]!.ok).toBe(true);
|
|
199
|
+
expect(results[1]!.verdict).toBe("unverified");
|
|
200
|
+
expect(results[1]!.detail).toContain("missing-a.test.ts");
|
|
201
|
+
expect(results[2]!.verdict).toBe("unverified");
|
|
202
|
+
expect(results[3]!.ok).toBe(false);
|
|
203
|
+
expect(results[3]!.verdict).not.toBe("unverified");
|
|
204
|
+
// Indexes 1,2,4 are all same-bound test probes with no run/page/proof
|
|
205
|
+
// barrier between them — they share ONE segment; each missing file is
|
|
206
|
+
// attributed unverified from its own slice.
|
|
207
|
+
expect(results[4]!.verdict).toBe("unverified");
|
|
208
|
+
expect(results[4]!.detail).toContain("missing-c.test.ts");
|
|
209
|
+
expect(durationsMs).toHaveLength(5);
|
|
210
|
+
// Each batched result echoes its own declared probe.
|
|
211
|
+
results.forEach((r, i) => expect(r.probe).toBe(probes[i]));
|
|
212
|
+
} finally {
|
|
213
|
+
rmSync(dir, { recursive: true, force: true });
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
test("--no-batch forces the legacy per-probe path (spawn-failure != unverified)", async () => {
|
|
218
|
+
const dir = mkdtempSync(join(tmpdir(), "probe-set-nb-"));
|
|
219
|
+
try {
|
|
220
|
+
const probes = [testProbe("missing-a.test.ts"), testProbe("missing-b.test.ts")];
|
|
221
|
+
const legacy = await runProbeSet(probes, { workspaceRoot: dir, noBatch: true });
|
|
222
|
+
// Legacy spawns vitest per probe in the tmp workspace — the spawn fails,
|
|
223
|
+
// producing a fail verdict rather than the batched "unverified".
|
|
224
|
+
for (const r of legacy.results) {
|
|
225
|
+
expect(r.verdict).not.toBe("unverified");
|
|
226
|
+
expect(r.ok).toBe(false);
|
|
227
|
+
}
|
|
228
|
+
} finally {
|
|
229
|
+
rmSync(dir, { recursive: true, force: true });
|
|
230
|
+
}
|
|
231
|
+
}, 60_000);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
describe("e2e — one instrumented Vitest run attributes two files", () => {
|
|
235
|
+
test(
|
|
236
|
+
"two real test files in one segment produce per-file verdicts (AC-1/AC-2)",
|
|
237
|
+
async () => {
|
|
238
|
+
const segment: ProbeSegment = { start: 0, members: [0, 1], boundMs: 120_000 };
|
|
239
|
+
const probes = [
|
|
240
|
+
testProbe("packages/forge/os/rfc/verification-normalize.test.ts"),
|
|
241
|
+
testProbe("packages/forge/os/rfc/frontmatter-io.test.ts"),
|
|
242
|
+
];
|
|
243
|
+
const results = await runBatchedTestSegment(probes, segment, WORKSPACE_ROOT);
|
|
244
|
+
expect(results.size).toBe(2);
|
|
245
|
+
const a = results.get(0)!;
|
|
246
|
+
const b = results.get(1)!;
|
|
247
|
+
expect(a.verdict, `probe 0 must attribute its own file — ${a.detail}`).toBe("pass");
|
|
248
|
+
expect(b.verdict, `probe 1 must attribute its own file — ${b.detail}`).toBe("pass");
|
|
249
|
+
expect(a.detail).toContain("batched:");
|
|
250
|
+
},
|
|
251
|
+
180_000,
|
|
252
|
+
);
|
|
253
|
+
});
|
package/os/rfc/probe-batch.ts
CHANGED
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
|
|
14
14
|
import { spawn } from "../../src/utils/sync-fs.ts";
|
|
15
15
|
import { resolveSpawnPlan } from "../../src/utils/spawn.ts";
|
|
16
|
-
import { mkdtempSync, rmSync } from "node:fs";
|
|
16
|
+
import { mkdtempSync, readFileSync, rmSync } from "node:fs";
|
|
17
|
+
import { createRequire } from "node:module";
|
|
17
18
|
import { tmpdir } from "node:os";
|
|
18
19
|
import path from "node:path";
|
|
19
20
|
|
|
@@ -115,9 +116,17 @@ export async function spawnBatchedVitest(
|
|
|
115
116
|
boundMs: number,
|
|
116
117
|
outputFile: string,
|
|
117
118
|
): Promise<BatchSpawnOutcome> {
|
|
119
|
+
// v10 monorepo topology: vitest is a per-package dependency, never a workspace-root
|
|
120
|
+
// one — `pnpm exec vitest` from the root resolves nothing. Resolve the vitest
|
|
121
|
+
// entrypoint through THIS module's own package resolution (probe-batch ships inside
|
|
122
|
+
// the forge package, so its resolution always reaches the package-local vitest)
|
|
123
|
+
// and spawn node directly with cwd=workspaceRoot so probe paths stay root-relative.
|
|
124
|
+
const vitestPkgJson = createRequire(import.meta.url).resolve("vitest/package.json");
|
|
125
|
+
const vitestBin = JSON.parse(readFileSync(vitestPkgJson, "utf8")) as { bin?: Record<string, string> };
|
|
126
|
+
const binRel = vitestBin.bin?.vitest ?? "./vitest.mjs";
|
|
127
|
+
const vitestEntry = path.join(path.dirname(vitestPkgJson), binRel);
|
|
118
128
|
const args = [
|
|
119
|
-
|
|
120
|
-
"vitest",
|
|
129
|
+
vitestEntry,
|
|
121
130
|
"run",
|
|
122
131
|
...files,
|
|
123
132
|
"--reporter=json",
|
|
@@ -130,9 +139,7 @@ export async function spawnBatchedVitest(
|
|
|
130
139
|
|
|
131
140
|
let stderrTail = "";
|
|
132
141
|
const exit = await new Promise<{ exitCode: number | null; timedOut: boolean }>((resolve) => {
|
|
133
|
-
|
|
134
|
-
// cmd.exe; a missing pnpm keeps spawn ENOENT for the caller to classify.
|
|
135
|
-
const plan = resolveSpawnPlan("pnpm", args);
|
|
142
|
+
const plan = resolveSpawnPlan(process.execPath, args);
|
|
136
143
|
const child = spawn(plan.command, plan.args, {
|
|
137
144
|
cwd: workspaceRoot,
|
|
138
145
|
stdio: ["ignore", "ignore", "pipe"],
|