@aviaratech/ai-delivery 0.3.35 → 0.3.36
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/CONTRIBUTING.md +12 -206
- package/README.md +57 -554
- package/dist/agent.d.ts +0 -2
- package/dist/agent.js +76 -16
- package/dist/agent.js.map +7 -1
- package/dist/agentReadiness.test.js +73 -67
- package/dist/agentReadiness.test.js.map +7 -1
- package/dist/boardReconcile.test.js +1651 -1590
- package/dist/boardReconcile.test.js.map +7 -1
- package/dist/build.test.js +130 -0
- package/dist/build.test.js.map +7 -0
- package/dist/callerErrors.test.js +105 -0
- package/dist/callerErrors.test.js.map +7 -0
- package/dist/cli.js +402 -515
- package/dist/cli.js.map +7 -1
- package/dist/cliResult.d.ts +2 -2
- package/dist/cliResult.js +42 -45
- package/dist/cliResult.js.map +7 -1
- package/dist/cliResult.test.js +424 -369
- package/dist/cliResult.test.js.map +7 -1
- package/dist/config/deliveryConfig.d.ts +288 -14
- package/dist/config/deliveryConfig.js +472 -390
- package/dist/config/deliveryConfig.js.map +7 -1
- package/dist/config/deliveryConfig.test.js +773 -649
- package/dist/config/deliveryConfig.test.js.map +7 -1
- package/dist/contributorChecks.test.js +1694 -916
- package/dist/contributorChecks.test.js.map +7 -1
- package/dist/currentConsumer.test.js +819 -737
- package/dist/currentConsumer.test.js.map +7 -1
- package/dist/currentTrackingScenario.test.js +499 -479
- package/dist/currentTrackingScenario.test.js.map +7 -1
- package/dist/delivery/common.js +160 -172
- package/dist/delivery/common.js.map +7 -1
- package/dist/delivery/delivery.test.js +509 -431
- package/dist/delivery/delivery.test.js.map +7 -1
- package/dist/delivery/evidence.d.ts +2 -2
- package/dist/delivery/evidence.js +133 -120
- package/dist/delivery/evidence.js.map +7 -1
- package/dist/delivery/index.js +7 -2
- package/dist/delivery/index.js.map +7 -1
- package/dist/delivery/legacy.js +65 -5
- package/dist/delivery/legacy.js.map +7 -1
- package/dist/delivery/policy.d.ts +10 -10
- package/dist/delivery/policy.js +211 -238
- package/dist/delivery/policy.js.map +7 -1
- package/dist/delivery/stage.d.ts +18 -18
- package/dist/delivery/stage.js +220 -235
- package/dist/delivery/stage.js.map +7 -1
- package/dist/deliveryBoard.d.ts +74 -0
- package/dist/deliveryBoard.js +644 -0
- package/dist/deliveryBoard.js.map +7 -0
- package/dist/deliveryBoard.test.js +649 -0
- package/dist/deliveryBoard.test.js.map +7 -0
- package/dist/deliveryHealth.test.js +179 -155
- package/dist/deliveryHealth.test.js.map +7 -1
- package/dist/dependencyCompatibility.test.js +154 -140
- package/dist/dependencyCompatibility.test.js.map +7 -1
- package/dist/directoryIndependent.test.js +417 -383
- package/dist/directoryIndependent.test.js.map +7 -1
- package/dist/dispatch.d.ts +16 -11
- package/dist/dispatch.js +329 -353
- package/dist/dispatch.js.map +7 -1
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +103 -96
- package/dist/errors.js.map +7 -1
- package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
- package/dist/fixtures/deliveryBoardReplay.js +617 -0
- package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
- package/dist/fixtures/discovery.d.ts +59 -19
- package/dist/fixtures/discovery.js +96 -90
- package/dist/fixtures/discovery.js.map +7 -1
- package/dist/fixtures/inertEntrypointChild.js +57 -56
- package/dist/fixtures/inertEntrypointChild.js.map +7 -1
- package/dist/fixtures/inertEntrypoints.d.ts +1 -1
- package/dist/fixtures/inertEntrypoints.js +321 -276
- package/dist/fixtures/inertEntrypoints.js.map +7 -1
- package/dist/fixtures/inertTarget.d.ts +78 -7
- package/dist/fixtures/inertTarget.js +769 -691
- package/dist/fixtures/inertTarget.js.map +7 -1
- package/dist/fixtures/issue63.d.ts +4 -3
- package/dist/fixtures/issue63.js +260 -274
- package/dist/fixtures/issue63.js.map +7 -1
- package/dist/fixtures/issueProjectItems.d.ts +20 -0
- package/dist/fixtures/issueProjectItems.js +15 -0
- package/dist/fixtures/issueProjectItems.js.map +7 -0
- package/dist/fixtures/readView.d.ts +120 -0
- package/dist/fixtures/readView.js +172 -0
- package/dist/fixtures/readView.js.map +7 -0
- package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
- package/dist/fixtures/recordedGitHubFlows.js +109 -0
- package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
- package/dist/genericCompatibility.test.js +64 -55
- package/dist/genericCompatibility.test.js.map +7 -1
- package/dist/git.js +73 -67
- package/dist/git.js.map +7 -1
- package/dist/gitProcess.d.ts +1 -1
- package/dist/gitProcess.js +58 -53
- package/dist/gitProcess.js.map +7 -1
- package/dist/github/client.d.ts +2 -2
- package/dist/github/client.js +484 -379
- package/dist/github/client.js.map +7 -1
- package/dist/github/commandIdentityPolicy.js +44 -52
- package/dist/github/commandIdentityPolicy.js.map +7 -1
- package/dist/github/discovery.d.ts +1 -0
- package/dist/github/discovery.js +197 -215
- package/dist/github/discovery.js.map +7 -1
- package/dist/github/discovery.test.js +223 -177
- package/dist/github/discovery.test.js.map +7 -1
- package/dist/github/issueHistory.d.ts +2 -2
- package/dist/github/issueHistory.js +117 -125
- package/dist/github/issueHistory.js.map +7 -1
- package/dist/github/machineAuth.d.ts +1 -1
- package/dist/github/machineAuth.js +126 -117
- package/dist/github/machineAuth.js.map +7 -1
- package/dist/github/machineAuth.test.js +755 -639
- package/dist/github/machineAuth.test.js.map +7 -1
- package/dist/github/nativeIssueMetadata.js +286 -273
- package/dist/github/nativeIssueMetadata.js.map +7 -1
- package/dist/github/projectDelivery.d.ts +18 -2
- package/dist/github/projectDelivery.js +615 -557
- package/dist/github/projectDelivery.js.map +7 -1
- package/dist/github/relationships.js +433 -389
- package/dist/github/relationships.js.map +7 -1
- package/dist/github/repo.d.ts +1 -0
- package/dist/github/repo.js +123 -96
- package/dist/github/repo.js.map +7 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +7 -1
- package/dist/issue.d.ts +40 -9
- package/dist/issue.js +2102 -1742
- package/dist/issue.js.map +7 -1
- package/dist/issue63History.test.js +40 -42
- package/dist/issue63History.test.js.map +7 -1
- package/dist/issue63Routes.test.js +154 -143
- package/dist/issue63Routes.test.js.map +7 -1
- package/dist/issueBatchUpdate.test.js +989 -885
- package/dist/issueBatchUpdate.test.js.map +7 -1
- package/dist/issueBlockerGuard.test.js +262 -226
- package/dist/issueBlockerGuard.test.js.map +7 -1
- package/dist/issueContract.d.ts +23 -4
- package/dist/issueContract.js +416 -395
- package/dist/issueContract.js.map +7 -1
- package/dist/issueContract.test.d.ts +4 -3
- package/dist/issueContract.test.js +358 -321
- package/dist/issueContract.test.js.map +7 -1
- package/dist/issueDates.test.js +235 -233
- package/dist/issueDates.test.js.map +7 -1
- package/dist/issueInfoReadback.test.js +304 -190
- package/dist/issueInfoReadback.test.js.map +7 -1
- package/dist/issueIntake.test.js +1945 -1732
- package/dist/issueIntake.test.js.map +7 -1
- package/dist/issueJournal.d.ts +40 -19
- package/dist/issueJournal.js +229 -138
- package/dist/issueJournal.js.map +7 -1
- package/dist/issueJournal.test.js +605 -422
- package/dist/issueJournal.test.js.map +7 -1
- package/dist/issueRollup.test.d.ts +1 -0
- package/dist/issueRollup.test.js +476 -0
- package/dist/issueRollup.test.js.map +7 -0
- package/dist/issueTracking.test.js +1059 -989
- package/dist/issueTracking.test.js.map +7 -1
- package/dist/issueWriteRecovery.test.d.ts +1 -0
- package/dist/issueWriteRecovery.test.js +260 -0
- package/dist/issueWriteRecovery.test.js.map +7 -0
- package/dist/lifecycle.test.js +112 -441
- package/dist/lifecycle.test.js.map +7 -1
- package/dist/logger.js +80 -74
- package/dist/logger.js.map +7 -1
- package/dist/mcp/index.js +116 -94
- package/dist/mcp/index.js.map +7 -1
- package/dist/mcp/tools.d.ts +264 -286
- package/dist/mcp/tools.js +267 -340
- package/dist/mcp/tools.js.map +7 -1
- package/dist/pluginAuthProbe.js +63 -52
- package/dist/pluginAuthProbe.js.map +7 -1
- package/dist/pluginAuthProbe.test.js +85 -62
- package/dist/pluginAuthProbe.test.js.map +7 -1
- package/dist/pluginCredentials.test.js +282 -259
- package/dist/pluginCredentials.test.js.map +7 -1
- package/dist/pluginDoctor.test.js +653 -588
- package/dist/pluginDoctor.test.js.map +7 -1
- package/dist/pluginInstaller.d.ts +7 -5
- package/dist/pluginInstaller.js +1173 -1229
- package/dist/pluginInstaller.js.map +7 -1
- package/dist/pluginInstaller.test.js +1842 -1423
- package/dist/pluginInstaller.test.js.map +7 -1
- package/dist/pluginPackaging.test.js +460 -409
- package/dist/pluginPackaging.test.js.map +7 -1
- package/dist/pr.d.ts +132 -94
- package/dist/pr.js +1521 -1323
- package/dist/pr.js.map +7 -1
- package/dist/pr.test.js +1678 -632
- package/dist/pr.test.js.map +7 -1
- package/dist/prAssociation.test.js +2419 -1788
- package/dist/prAssociation.test.js.map +7 -1
- package/dist/prDispatch.test.js +150 -89
- package/dist/prDispatch.test.js.map +7 -1
- package/dist/readView.d.ts +183 -0
- package/dist/readView.js +217 -0
- package/dist/readView.js.map +7 -0
- package/dist/readView.test.d.ts +1 -0
- package/dist/readView.test.js +119 -0
- package/dist/readView.test.js.map +7 -0
- package/dist/releaseReconciliation.test.js +267 -288
- package/dist/releaseReconciliation.test.js.map +7 -1
- package/dist/releaseWorkflow.test.js +2493 -422
- package/dist/releaseWorkflow.test.js.map +7 -1
- package/dist/review.d.ts +738 -2
- package/dist/review.js +601 -348
- package/dist/review.js.map +7 -1
- package/dist/review.test.js +1218 -812
- package/dist/review.test.js.map +7 -1
- package/dist/reviewSubmit.test.d.ts +1 -0
- package/dist/reviewSubmit.test.js +747 -0
- package/dist/reviewSubmit.test.js.map +7 -0
- package/dist/services/agentReadinessService.js +42 -37
- package/dist/services/agentReadinessService.js.map +7 -1
- package/dist/services/blockerGuardService.js +188 -188
- package/dist/services/blockerGuardService.js.map +7 -1
- package/dist/services/boardReconcileService.d.ts +125 -125
- package/dist/services/boardReconcileService.js +1295 -1421
- package/dist/services/boardReconcileService.js.map +7 -1
- package/dist/services/deliveryAdmission.js +131 -154
- package/dist/services/deliveryAdmission.js.map +7 -1
- package/dist/services/deliveryHealthService.js +197 -199
- package/dist/services/deliveryHealthService.js.map +7 -1
- package/dist/services/legacyIssueMigration.js +263 -277
- package/dist/services/legacyIssueMigration.js.map +7 -1
- package/dist/services/worktreeRegistry.d.ts +27 -119
- package/dist/services/worktreeRegistry.js +765 -1182
- package/dist/services/worktreeRegistry.js.map +7 -1
- package/dist/stagedChecks.test.js +396 -194
- package/dist/stagedChecks.test.js.map +7 -1
- package/dist/start.test.js +99 -95
- package/dist/start.test.js.map +7 -1
- package/dist/stdoutRegression.test.js +353 -352
- package/dist/stdoutRegression.test.js.map +7 -1
- package/dist/targetPolicyDiscovery.test.js +141 -143
- package/dist/targetPolicyDiscovery.test.js.map +7 -1
- package/dist/targetPolicyEntrypoints.test.js +308 -269
- package/dist/targetPolicyEntrypoints.test.js.map +7 -1
- package/dist/targetPolicyLocal.test.js +580 -1051
- package/dist/targetPolicyLocal.test.js.map +7 -1
- package/dist/targetPolicyRoutes.test.js +305 -281
- package/dist/targetPolicyRoutes.test.js.map +7 -1
- package/dist/targetRepositoryExecution.test.d.ts +1 -0
- package/dist/targetRepositoryExecution.test.js +463 -0
- package/dist/targetRepositoryExecution.test.js.map +7 -0
- package/dist/terminalMessages.js +41 -35
- package/dist/terminalMessages.js.map +7 -1
- package/dist/toolOutput.d.ts +2 -0
- package/dist/toolOutput.js +36 -0
- package/dist/toolOutput.js.map +7 -0
- package/dist/toolOutput.test.d.ts +1 -0
- package/dist/toolOutput.test.js +240 -0
- package/dist/toolOutput.test.js.map +7 -0
- package/dist/utils/atomicJson.js +84 -76
- package/dist/utils/atomicJson.js.map +7 -1
- package/dist/utils/filesystem.js +15 -18
- package/dist/utils/filesystem.js.map +7 -1
- package/dist/utils/lockfile.js +68 -71
- package/dist/utils/lockfile.js.map +7 -1
- package/dist/verification.d.ts +1 -19
- package/dist/verification.js +1020 -1939
- package/dist/verification.js.map +7 -1
- package/dist/verificationGate.test.js +127 -117
- package/dist/verificationGate.test.js.map +7 -1
- package/dist/version.js +23 -24
- package/dist/version.js.map +7 -1
- package/dist/worktree.d.ts +3 -15
- package/dist/worktree.js +97 -177
- package/dist/worktree.js.map +7 -1
- package/package.json +9 -8
- package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
- package/plugins/ai-delivery/README.md +47 -156
- package/plugins/ai-delivery/plugin.json +1 -1
- package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +238 -44
- package/plugins/ai-delivery/runtime/dist/cli.js +358 -115
- package/plugins/ai-delivery/runtime/package.json +1 -1
- package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
- package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
- package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
- package/dist/investigationCompletion.test.js +0 -728
- package/dist/investigationCompletion.test.js.map +0 -1
- package/dist/setup.d.ts +0 -60
- package/dist/setup.js +0 -585
- package/dist/setup.js.map +0 -1
- package/dist/setup.test.js +0 -3329
- package/dist/setup.test.js.map +0 -1
- package/dist/worktreeTransition.d.ts +0 -211
- package/dist/worktreeTransition.js +0 -1037
- package/dist/worktreeTransition.js.map +0 -1
- package/dist/worktreeTransition.test.js +0 -1191
- package/dist/worktreeTransition.test.js.map +0 -1
- /package/dist/{investigationCompletion.test.d.ts → build.test.d.ts} +0 -0
- /package/dist/{setup.test.d.ts → callerErrors.test.d.ts} +0 -0
- /package/dist/{worktreeTransition.test.d.ts → deliveryBoard.test.d.ts} +0 -0
|
@@ -1,367 +1,909 @@
|
|
|
1
|
-
import assert from
|
|
2
|
-
import { execFileSync, spawn, spawnSync } from
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
3
|
+
import {
|
|
4
|
+
chmodSync,
|
|
5
|
+
existsSync,
|
|
6
|
+
mkdirSync,
|
|
7
|
+
mkdtempSync,
|
|
8
|
+
readFileSync,
|
|
9
|
+
readdirSync,
|
|
10
|
+
realpathSync,
|
|
11
|
+
renameSync,
|
|
12
|
+
rmSync,
|
|
13
|
+
symlinkSync,
|
|
14
|
+
writeFileSync
|
|
15
|
+
} from "node:fs";
|
|
16
|
+
import { availableParallelism, tmpdir } from "node:os";
|
|
17
|
+
import { dirname, join, relative } from "node:path";
|
|
18
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
19
|
+
import { test } from "vitest";
|
|
20
|
+
const checks = await import(new URL("../scripts/checks.mjs", import.meta.url).href);
|
|
21
|
+
const repository = fileURLToPath(new URL("../", import.meta.url));
|
|
22
|
+
test(
|
|
23
|
+
"Vitest source and compiled inputs are unique and use isolated core-aware fork workers",
|
|
24
|
+
{ tags: ["release"] },
|
|
25
|
+
async () => {
|
|
26
|
+
const f = fixture();
|
|
27
|
+
try {
|
|
28
|
+
const { default: configure } = await import(pathToFileURL(join(repository, "vitest.config.ts")).href);
|
|
29
|
+
assert.equal(typeof configure, "function");
|
|
30
|
+
for (const mode of ["source", "compiled"]) {
|
|
31
|
+
const config = configure({ mode }).test;
|
|
32
|
+
assert.ok(Number.isFinite(config.testTimeout) && config.testTimeout > 0);
|
|
33
|
+
assert.equal(config.pool, "forks");
|
|
34
|
+
assert.equal(config.maxWorkers, availableParallelism());
|
|
35
|
+
assert.equal(config.fileParallelism, true);
|
|
36
|
+
const output = join(f.base, `projects-${mode}.json`);
|
|
37
|
+
execFileSync(
|
|
38
|
+
process.execPath,
|
|
39
|
+
[
|
|
40
|
+
join(repository, "node_modules/vitest/vitest.mjs"),
|
|
41
|
+
"list",
|
|
42
|
+
`--mode=${mode}`,
|
|
43
|
+
"--filesOnly",
|
|
44
|
+
`--json=${output}`
|
|
45
|
+
],
|
|
46
|
+
{
|
|
47
|
+
cwd: repository,
|
|
48
|
+
env: checks.safeEnvironment({ PATH: process.env.PATH ?? "" }),
|
|
49
|
+
encoding: "utf8",
|
|
50
|
+
maxBuffer: 1024 ** 2
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
const rows = JSON.parse(readFileSync(output, "utf8"));
|
|
54
|
+
const selected = rows.map((row) => relative(repository, row.file).replaceAll("\\", "/"));
|
|
55
|
+
assert.deepEqual([...selected].sort(), checks.expectedTests(repository, mode));
|
|
56
|
+
assert.equal(new Set(selected).size, selected.length, "No file may execute more than once");
|
|
57
|
+
}
|
|
58
|
+
} finally {
|
|
59
|
+
f.cleanup();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
test("ordinary full and focused checks exclude release cases without claiming archive proof", async () => {
|
|
64
|
+
for (const focused of [false, true]) {
|
|
65
|
+
const f = fixture();
|
|
66
|
+
try {
|
|
67
|
+
const delegated = executor(f);
|
|
68
|
+
const report = await checks.runChecks({
|
|
69
|
+
cwd: f.cwd,
|
|
70
|
+
resultsDir: join(f.base, "checks"),
|
|
71
|
+
...focused ? { fast: true, testFiles: ["dist/original.test.js"] } : {},
|
|
72
|
+
toolchain: () => f.toolchain,
|
|
73
|
+
environment: {
|
|
74
|
+
...checks.safeEnvironment({}),
|
|
75
|
+
AI_DELIVERY_TEST_LANE: "release",
|
|
76
|
+
AI_DELIVERY_RELEASE_CONTRACT: "/ambient/untrusted"
|
|
77
|
+
},
|
|
78
|
+
execute: (command2, options) => {
|
|
79
|
+
assert.equal(options.env.AI_DELIVERY_TEST_LANE, "pr");
|
|
80
|
+
assert.equal(options.env.AI_DELIVERY_RELEASE_CONTRACT, void 0);
|
|
81
|
+
return delegated(command2, options);
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const testCommand = report.commands.find((command2) => command2.stage === "tests").command;
|
|
85
|
+
assert.equal(
|
|
86
|
+
testCommand.some((argument) => argument.startsWith("--maxWorkers")),
|
|
87
|
+
false
|
|
88
|
+
);
|
|
89
|
+
assert.equal(report.status, focused ? "partial-passed" : "passed");
|
|
90
|
+
assert.equal(report.artifactQualified, false);
|
|
91
|
+
if (!focused) assert.deepEqual(report.omitted, []);
|
|
92
|
+
const command = report.commands.find((command2) => command2.stage === "tests")?.command;
|
|
93
|
+
assert.ok(command?.includes("--tags-filter=!release"));
|
|
94
|
+
assert.ok(
|
|
95
|
+
!report.commands.some(
|
|
96
|
+
(command2) => command2.command.some((arg) => /current-consumer|current-qualification/u.test(arg))
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
} finally {
|
|
100
|
+
f.cleanup();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
test("PR reports exclude release identities while scoped release reports require all mandatory outcomes", () => {
|
|
105
|
+
assert.ok(Array.isArray(checks.RELEASE_CASES));
|
|
106
|
+
const mandatory = checks.RELEASE_CASES.filter((test2) => test2.kind === "mandatory");
|
|
107
|
+
assert.equal(new Set(mandatory.map(({ file, title }) => JSON.stringify([file, title]))).size, mandatory.length);
|
|
108
|
+
const f = fixture();
|
|
109
|
+
const files = [...new Set(checks.RELEASE_CASES.map((test2) => test2.file))];
|
|
110
|
+
const report = (release) => {
|
|
111
|
+
const testResults = files.map((file) => ({
|
|
112
|
+
name: join(f.cwd, file),
|
|
113
|
+
status: "passed",
|
|
114
|
+
assertionResults: [
|
|
115
|
+
...release ? [] : [{ fullName: "synthetic retained unit", status: "passed" }],
|
|
116
|
+
...checks.RELEASE_CASES.filter((test2) => test2.file === file).map((test2) => ({
|
|
117
|
+
fullName: test2.title,
|
|
118
|
+
status: release && test2.kind === "mandatory" ? "passed" : "pending"
|
|
119
|
+
}))
|
|
120
|
+
]
|
|
21
121
|
}));
|
|
22
|
-
|
|
23
|
-
execFileSync('git', ['add', '.'], { cwd });
|
|
24
|
-
const toolchain = {
|
|
25
|
-
controller: { version: 'v24.21.0', executable: process.execPath },
|
|
26
|
-
npm: { version: '11.19.0', executable: 'synthetic-npm' },
|
|
27
|
-
libraryConsumer: { version: 'v26.2.0', executable: 'synthetic-node26' },
|
|
28
|
-
};
|
|
29
|
-
const cleanup = () => rmSync(base, { recursive: true, force: true });
|
|
30
|
-
return { base, cwd, toolchain, cleanup };
|
|
31
|
-
}
|
|
32
|
-
function passingReport(cwd, names) {
|
|
122
|
+
const cases = testResults.flatMap((file) => file.assertionResults);
|
|
33
123
|
return {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
name: join(cwd, name),
|
|
39
|
-
status: 'passed',
|
|
40
|
-
assertionResults: [{ fullName: 'synthetic assertion', status: 'passed' }],
|
|
41
|
-
})),
|
|
124
|
+
success: true,
|
|
125
|
+
testResults,
|
|
126
|
+
numTotalTests: cases.length,
|
|
127
|
+
numPassedTests: cases.filter((test2) => test2.status === "passed").length
|
|
42
128
|
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
writeFileSync(stdoutPath, JSON.stringify([
|
|
80
|
-
{
|
|
81
|
-
name: '@example/fixture',
|
|
82
|
-
version: '1.0.0',
|
|
83
|
-
files: [
|
|
84
|
-
'dist/cli.js',
|
|
85
|
-
'dist/index.js',
|
|
86
|
-
'plugins/ai-delivery/runtime/dist/cli.js',
|
|
87
|
-
'plugins/ai-delivery/dist/mcp-launcher.js',
|
|
88
|
-
].map((path) => ({ path, mode: 0o755, size: readFileSync(join(f.cwd, path)).length })),
|
|
89
|
-
},
|
|
90
|
-
]));
|
|
91
|
-
const coverage = options.env.NODE_V8_COVERAGE;
|
|
92
|
-
mkdirSync(coverage, { recursive: true });
|
|
93
|
-
writeFileSync(join(coverage, 'synthetic.json'), JSON.stringify({
|
|
94
|
-
result: [
|
|
95
|
-
{
|
|
96
|
-
url: new URL(`file://${join(f.cwd, 'dist/index.js')}`).href,
|
|
97
|
-
functions: [{ ranges: [{ startOffset: 0, endOffset: 1, count: 1 }] }],
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
}));
|
|
101
|
-
}
|
|
102
|
-
const result = {
|
|
103
|
-
status: stage === failStage ? 'failed' : 'passed',
|
|
104
|
-
exitCode: stage === failStage ? 7 : 0,
|
|
105
|
-
stdoutPath,
|
|
106
|
-
stderrPath,
|
|
107
|
-
};
|
|
108
|
-
options.progress?.(result);
|
|
109
|
-
return result;
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
test('local and CI share full entry; fast explicitly omits gates and no CI duplicate build', () => {
|
|
113
|
-
const manifest = JSON.parse(readFileSync(join(repository, 'package.json'), 'utf8'));
|
|
114
|
-
assert.equal(manifest.scripts.checks, 'node scripts/current-qualification.mjs');
|
|
115
|
-
assert.equal(manifest.scripts['checks:producer'], 'node scripts/current-qualification.mjs --producer-only');
|
|
116
|
-
assert.equal(manifest.scripts['checks:fast'], 'node scripts/checks.mjs --fast');
|
|
117
|
-
const ci = readFileSync(join(repository, '.github/workflows/ci.yml'), 'utf8');
|
|
118
|
-
assert.match(ci, /npm run checks -- --results-dir/u);
|
|
119
|
-
assert.doesNotMatch(ci, /npm run build|npm pack/u);
|
|
120
|
-
assert.match(ci, /if: always\(\)/u);
|
|
121
|
-
assert.deepEqual(checks.FULL_GATES, ['format', 'lint', 'types', 'build', 'tests', 'inventory']);
|
|
129
|
+
};
|
|
130
|
+
try {
|
|
131
|
+
const pr = checks.analyzeTests(
|
|
132
|
+
report(false),
|
|
133
|
+
files,
|
|
134
|
+
f.cwd,
|
|
135
|
+
"",
|
|
136
|
+
{ AI_DELIVERY_REAL_PACKAGE_ARCHIVE: "/explicit-historical-input" },
|
|
137
|
+
"pr"
|
|
138
|
+
);
|
|
139
|
+
assert.equal(pr.passed, files.length);
|
|
140
|
+
assert.equal(pr.total, files.length);
|
|
141
|
+
assert.deepEqual(pr.skips, []);
|
|
142
|
+
assert.equal(pr.laneExcluded.length, checks.RELEASE_CASES.length);
|
|
143
|
+
const release = checks.analyzeTests(report(true), files, f.cwd, "", {}, "release");
|
|
144
|
+
assert.equal(release.passed, checks.RELEASE_CASES.filter((test2) => test2.kind === "mandatory").length);
|
|
145
|
+
assert.equal(release.skips.length, checks.RELEASE_CASES.filter((test2) => test2.kind !== "mandatory").length);
|
|
146
|
+
for (const failure of ["missing", "duplicate", "unexpected", "failed", "pr-executed"]) {
|
|
147
|
+
const data = report(failure !== "pr-executed");
|
|
148
|
+
const tests = data.testResults[0].assertionResults;
|
|
149
|
+
if (failure === "missing") tests.shift();
|
|
150
|
+
if (failure === "duplicate") tests.push({ ...tests[0] });
|
|
151
|
+
if (failure === "unexpected") tests.push({ fullName: "unreviewed release case", status: "passed" });
|
|
152
|
+
if (failure === "failed") tests[0].status = "failed";
|
|
153
|
+
if (failure === "pr-executed") tests[1].status = "passed";
|
|
154
|
+
const cases = data.testResults.flatMap((file) => file.assertionResults);
|
|
155
|
+
data.numTotalTests = cases.length;
|
|
156
|
+
data.numPassedTests = cases.filter((test2) => test2.status === "passed").length;
|
|
157
|
+
assert.throws(
|
|
158
|
+
() => checks.analyzeTests(data, files, f.cwd, "", {}, failure === "pr-executed" ? "pr" : "release"),
|
|
159
|
+
failure
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
} finally {
|
|
163
|
+
f.cleanup();
|
|
164
|
+
}
|
|
122
165
|
});
|
|
123
|
-
test(
|
|
166
|
+
test(
|
|
167
|
+
"runtime-expanded tags match every reviewed mandatory identity without executing cases",
|
|
168
|
+
{ tags: ["release"] },
|
|
169
|
+
() => {
|
|
124
170
|
const f = fixture();
|
|
125
171
|
try {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
172
|
+
const config = join(f.base, "collection-only.config.mjs");
|
|
173
|
+
const base = pathToFileURL(join(repository, "vitest.config.ts")).href;
|
|
174
|
+
writeFileSync(
|
|
175
|
+
config,
|
|
176
|
+
`if(!process.argv.includes('list'))throw new Error('Collection only');const base=(await import(${JSON.stringify(base)})).default({mode:'compiled'});export default {...base,test:{...base.test,tags:base.test.tags.map(tag=>tag.name==='release'?{...tag,skip:false}:tag)}};`
|
|
177
|
+
);
|
|
178
|
+
const output = join(f.base, "inventory.json");
|
|
179
|
+
execFileSync(
|
|
180
|
+
process.execPath,
|
|
181
|
+
[
|
|
182
|
+
join(repository, "node_modules/vitest/vitest.mjs"),
|
|
183
|
+
"list",
|
|
184
|
+
...new Set(checks.RELEASE_CASES.map((test2) => test2.file)),
|
|
185
|
+
"--tags-filter=release",
|
|
186
|
+
"--no-staticParse",
|
|
187
|
+
"--maxWorkers=1",
|
|
188
|
+
`--config=${config}`,
|
|
189
|
+
`--json=${output}`
|
|
190
|
+
],
|
|
191
|
+
{
|
|
192
|
+
cwd: repository,
|
|
193
|
+
env: { ...checks.safeEnvironment({ PATH: process.env.PATH ?? "" }), AI_DELIVERY_TEST_LANE: "pr" },
|
|
194
|
+
encoding: "utf8",
|
|
195
|
+
maxBuffer: 1024 ** 2
|
|
196
|
+
}
|
|
197
|
+
);
|
|
198
|
+
const rows = JSON.parse(readFileSync(output, "utf8"));
|
|
199
|
+
const actual = rows.map((row) => ({
|
|
200
|
+
file: relative(repository, row.file).replaceAll("\\", "/"),
|
|
201
|
+
title: row.name.replaceAll(" > ", " ")
|
|
202
|
+
}));
|
|
203
|
+
const expected = checks.RELEASE_CASES.filter((test2) => test2.kind === "mandatory").map(({ file, title }) => ({
|
|
204
|
+
file,
|
|
205
|
+
title
|
|
206
|
+
}));
|
|
207
|
+
assert.equal(actual.length, expected.length);
|
|
208
|
+
const compare = (a, b) => JSON.stringify(a).localeCompare(JSON.stringify(b));
|
|
209
|
+
assert.deepEqual(actual.sort(compare), expected.sort(compare));
|
|
210
|
+
} finally {
|
|
211
|
+
f.cleanup();
|
|
144
212
|
}
|
|
145
|
-
|
|
146
|
-
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
test("unknown lane and mismatched release context fail before child launch", async () => {
|
|
216
|
+
const f = fixture();
|
|
217
|
+
try {
|
|
218
|
+
let calls = 0;
|
|
219
|
+
const release = {
|
|
220
|
+
contractPath: join(f.base, "missing/contract.json"),
|
|
221
|
+
checkpoint: { path: join(f.base, "missing/checkpoint.json"), sha256: "a".repeat(64) },
|
|
222
|
+
sourceCommit: "a".repeat(40),
|
|
223
|
+
sourceTree: "b".repeat(40),
|
|
224
|
+
sourceManifestSha256: "a".repeat(64),
|
|
225
|
+
sourceLockSha256: "b".repeat(64),
|
|
226
|
+
producerSha256: "c".repeat(64),
|
|
227
|
+
archiveSha256: "d".repeat(64)
|
|
228
|
+
};
|
|
229
|
+
for (const options of [
|
|
230
|
+
{ environment: { AI_DELIVERY_TEST_LANE: "unknown" } },
|
|
231
|
+
{ release },
|
|
232
|
+
{ release, fast: true }
|
|
233
|
+
]) {
|
|
234
|
+
const result = await checks.runChecks({
|
|
235
|
+
cwd: f.cwd,
|
|
236
|
+
resultsDir: join(f.base, `invalid-${calls}-${Object.keys(options).join("-")}`),
|
|
237
|
+
toolchain: () => f.toolchain,
|
|
238
|
+
...options,
|
|
239
|
+
execute: (command, options2) => {
|
|
240
|
+
calls++;
|
|
241
|
+
return executor(f)(command, options2);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
assert.equal(result.status, "failed");
|
|
245
|
+
assert.equal(calls, 0);
|
|
147
246
|
}
|
|
247
|
+
} finally {
|
|
248
|
+
f.cleanup();
|
|
249
|
+
}
|
|
148
250
|
});
|
|
149
|
-
|
|
251
|
+
function directFocus(f, title, env, name) {
|
|
252
|
+
const marker = join(f.base, `${name}-npm-launched`);
|
|
253
|
+
const loaded = join(f.base, `${name}-guard-loaded`);
|
|
254
|
+
const guard = join(f.base, `${name}-guard.mjs`);
|
|
255
|
+
writeFileSync(
|
|
256
|
+
guard,
|
|
257
|
+
`import cp from 'node:child_process';import {syncBuiltinESMExports} from 'node:module';import {appendFileSync,writeFileSync} from 'node:fs';appendFileSync(${JSON.stringify(loaded)},String(process.pid)+String.fromCharCode(10));for(const name of ['spawn','spawnSync','execFile','execFileSync','exec','execSync','fork']){const original=cp[name];cp[name]=function(command,args,...rest){if([command,...(Array.isArray(args)?args:[])].some(x=>['npm','npm-cli.js'].includes(String(x).split('/').at(-1)))){writeFileSync(${JSON.stringify(marker)},'forbidden npm launch');throw new Error('Controlled direct-focus guard forbids npm');}return Reflect.apply(original,this,[command,args,...rest]);};}syncBuiltinESMExports();`
|
|
258
|
+
);
|
|
259
|
+
const guardUrl = pathToFileURL(guard).href;
|
|
260
|
+
const workerArgs = ["--maxWorkers=1", "--pool=forks", `--execArgv=--import=${guardUrl}`, "--no-cache"];
|
|
261
|
+
const childEnv = { ...checks.safeEnvironment({ PATH: process.env.PATH ?? "" }), ...env };
|
|
262
|
+
mkdirSync(join(f.cwd, "dist"), { recursive: true });
|
|
263
|
+
if (!existsSync(join(f.cwd, "node_modules")))
|
|
264
|
+
symlinkSync(join(repository, "node_modules"), join(f.cwd, "node_modules"));
|
|
265
|
+
const config = join(f.cwd, "guard.config.mjs");
|
|
266
|
+
writeFileSync(
|
|
267
|
+
config,
|
|
268
|
+
`import {defineConfig} from 'vitest/config';export default defineConfig({test:{include:['dist/guard.test.js']}});`
|
|
269
|
+
);
|
|
270
|
+
writeFileSync(
|
|
271
|
+
join(f.cwd, "dist/guard.test.js"),
|
|
272
|
+
`import assert from 'node:assert/strict';import {execFileSync,spawnSync} from 'node:child_process';import {test} from 'vitest';test('controlled worker npm guard',()=>{assert.throws(()=>execFileSync(process.execPath,['/controlled/nonexistent/npm-cli.js']),/Controlled direct-focus guard forbids npm/);});test('controlled shell npm guard',()=>{assert.throws(()=>spawnSync('/bin/sh',['-c','exit 125','controlled','/controlled/nonexistent/npm']),/Controlled direct-focus guard forbids npm/);});`
|
|
273
|
+
);
|
|
274
|
+
const probeReport = join(f.base, `${name}-probe.json`);
|
|
275
|
+
const probe = spawnSync(
|
|
276
|
+
process.execPath,
|
|
277
|
+
[
|
|
278
|
+
"--import",
|
|
279
|
+
guardUrl,
|
|
280
|
+
join(repository, "node_modules/vitest/vitest.mjs"),
|
|
281
|
+
"run",
|
|
282
|
+
"--root",
|
|
283
|
+
f.cwd,
|
|
284
|
+
"--config",
|
|
285
|
+
config,
|
|
286
|
+
...workerArgs,
|
|
287
|
+
"--reporter=json",
|
|
288
|
+
`--outputFile.json=${probeReport}`
|
|
289
|
+
],
|
|
290
|
+
{ cwd: f.cwd, env: childEnv, encoding: "utf8", maxBuffer: 1024 ** 2 }
|
|
291
|
+
);
|
|
292
|
+
assert.equal(probe.status, 0, probe.stderr.slice(-1500));
|
|
293
|
+
assert.equal(JSON.parse(readFileSync(probeReport, "utf8")).numPassedTests, 2);
|
|
294
|
+
assert.equal(existsSync(marker), true, "The fake npm invocation must be intercepted inside the worker.");
|
|
295
|
+
assert.ok(readFileSync(loaded, "utf8").trim().split(String.fromCharCode(10)).length >= 2);
|
|
296
|
+
rmSync(marker);
|
|
297
|
+
const reportPath = join(f.base, `${name}.json`);
|
|
298
|
+
const result = spawnSync(
|
|
299
|
+
process.execPath,
|
|
300
|
+
[
|
|
301
|
+
"--import",
|
|
302
|
+
guardUrl,
|
|
303
|
+
join(repository, "node_modules/vitest/vitest.mjs"),
|
|
304
|
+
"run",
|
|
305
|
+
"--mode=compiled",
|
|
306
|
+
"dist/lifecycle.test.js",
|
|
307
|
+
...workerArgs,
|
|
308
|
+
"-t",
|
|
309
|
+
title,
|
|
310
|
+
"--reporter=json",
|
|
311
|
+
`--outputFile.json=${reportPath}`
|
|
312
|
+
],
|
|
313
|
+
{ cwd: repository, env: childEnv, encoding: "utf8", maxBuffer: 1024 ** 2 }
|
|
314
|
+
);
|
|
315
|
+
assert.equal(existsSync(marker), false, "No npm subprocess may launch, even if the direct-entry guard regresses.");
|
|
316
|
+
assert.ok(existsSync(loaded), "The direct-process npm guard must load.");
|
|
317
|
+
return { result, reportPath, loaded };
|
|
318
|
+
}
|
|
319
|
+
test(
|
|
320
|
+
"direct-focus npm interception reaches the pinned worker before real-case selection",
|
|
321
|
+
{ tags: ["release"] },
|
|
322
|
+
() => {
|
|
150
323
|
const f = fixture();
|
|
151
324
|
try {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
toolchain: () => f.toolchain,
|
|
157
|
-
execute: executor(f),
|
|
158
|
-
});
|
|
159
|
-
assert.equal(fast.status, 'partial-passed');
|
|
160
|
-
assert.equal(fast.fullSuccess, false);
|
|
161
|
-
assert.deepEqual(fast.omitted, ['build', 'tests', 'inventory']);
|
|
162
|
-
const failed = await checks.runChecks({
|
|
163
|
-
cwd: f.cwd,
|
|
164
|
-
resultsDir: join(f.base, 'failed'),
|
|
165
|
-
toolchain: () => f.toolchain,
|
|
166
|
-
execute: executor(f, 'lint'),
|
|
167
|
-
});
|
|
168
|
-
assert.equal(failed.exitCode, 1);
|
|
169
|
-
assert.equal(failed.fullSuccess, false);
|
|
170
|
-
assert.deepEqual(failed.commands.map((entry) => entry.stage), ['format', 'lint']);
|
|
171
|
-
assert.match(failed.error, /lint: failed/u);
|
|
172
|
-
const testFailure = await checks.runChecks({
|
|
173
|
-
cwd: f.cwd,
|
|
174
|
-
resultsDir: join(f.base, 'failed-tests'),
|
|
175
|
-
toolchain: () => f.toolchain,
|
|
176
|
-
execute: executor(f, 'tests'),
|
|
177
|
-
});
|
|
178
|
-
assert.equal(testFailure.fullSuccess, false);
|
|
179
|
-
assert.equal(testFailure.observedTests?.total, 1);
|
|
180
|
-
assert.match(readFileSync(join(f.base, 'failed-tests/result.txt'), 'utf8'), /Observed test results/u);
|
|
181
|
-
assert.equal(testFailure.commands.at(-1).status, 'failed');
|
|
325
|
+
const run = directFocus(f, "controlled nonexistent selection", {}, "worker-probe");
|
|
326
|
+
assert.equal(run.result.status, 0);
|
|
327
|
+
} finally {
|
|
328
|
+
f.cleanup();
|
|
182
329
|
}
|
|
183
|
-
|
|
184
|
-
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
test("direct release focus rejects invalid contracts before any npm launch", { tags: ["release"] }, () => {
|
|
333
|
+
const f = fixture();
|
|
334
|
+
try {
|
|
335
|
+
for (const kind of ["absent", "missing", "malformed"]) {
|
|
336
|
+
const contractPath = join(f.base, kind, "contract.json");
|
|
337
|
+
if (kind === "malformed") {
|
|
338
|
+
mkdirSync(dirname(contractPath));
|
|
339
|
+
writeFileSync(contractPath, "{broken");
|
|
340
|
+
}
|
|
341
|
+
const run = directFocus(
|
|
342
|
+
f,
|
|
343
|
+
"(?!)",
|
|
344
|
+
{
|
|
345
|
+
AI_DELIVERY_TEST_LANE: "release",
|
|
346
|
+
...kind === "absent" ? {} : { AI_DELIVERY_RELEASE_CONTRACT: contractPath }
|
|
347
|
+
},
|
|
348
|
+
kind
|
|
349
|
+
);
|
|
350
|
+
assert.notEqual(run.result.status, 0);
|
|
351
|
+
assert.match(run.result.stderr + run.result.stdout, /contract|checkpoint/iu);
|
|
185
352
|
}
|
|
353
|
+
} finally {
|
|
354
|
+
f.cleanup();
|
|
355
|
+
}
|
|
186
356
|
});
|
|
187
|
-
test(
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
GH_TOKEN: 'fictional-do-not-forward',
|
|
192
|
-
GH_PRIVATE_KEY_GPT_REVIEWER: 'fictional-ref',
|
|
193
|
-
NODE_OPTIONS: '--require fictional',
|
|
194
|
-
NODE_PATH: 'checkout-only',
|
|
195
|
-
NPM_TOKEN: 'fictional-token',
|
|
196
|
-
AI_DELIVERY_REAL_PACKAGE_ARCHIVE: '/synthetic/explicit-historical.tgz',
|
|
197
|
-
});
|
|
198
|
-
assert.equal(env.GH_TOKEN, undefined);
|
|
199
|
-
assert.equal(env.NODE_OPTIONS, undefined);
|
|
200
|
-
assert.equal(env.NODE_PATH, undefined);
|
|
201
|
-
assert.equal(env.NPM_TOKEN, undefined);
|
|
202
|
-
assert.equal(env.AI_DELIVERY_REAL_PACKAGE_ARCHIVE, '/synthetic/explicit-historical.tgz');
|
|
203
|
-
assert.throws(() => checks.validateToolchain(repository, env), /AI_DELIVERY_NODE26_EXECUTABLE/u);
|
|
204
|
-
assert.throws(() => checks.validateToolchain(repository, { ...env, AI_DELIVERY_NODE26_EXECUTABLE: '/nonexistent/synthetic-node' }), /ENOENT/u);
|
|
205
|
-
assert.throws(() => checks.validateToolchain(repository, { ...env, AI_DELIVERY_NODE26_EXECUTABLE: process.execPath }), /Node 26\.2\.0/u);
|
|
357
|
+
test(
|
|
358
|
+
"qualification CLI finishes module loading before its owned graph reuses the validator",
|
|
359
|
+
{ tags: ["release"] },
|
|
360
|
+
() => {
|
|
206
361
|
const f = fixture();
|
|
207
362
|
try {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
363
|
+
const scripts = join(f.cwd, "scripts");
|
|
364
|
+
mkdirSync(scripts);
|
|
365
|
+
const entry = join(scripts, "current-qualification.mjs");
|
|
366
|
+
writeFileSync(entry, readFileSync(join(repository, "scripts/current-qualification.mjs")));
|
|
367
|
+
const marker = join(f.base, "module-ready");
|
|
368
|
+
writeFileSync(
|
|
369
|
+
join(scripts, "checks.mjs"),
|
|
370
|
+
`export {RELEASE_CASES,confirmCommandQuiescence,errorMessage,executeCommand,safeEnvironment,treeIdentity} from ${JSON.stringify(pathToFileURL(join(repository, "scripts/checks.mjs")).href)};import {writeFileSync} from 'node:fs';export async function runChecks(){await import('./current-qualification.mjs');writeFileSync(${JSON.stringify(marker)},'ready');throw new Error('Controlled stop before pack');}`
|
|
371
|
+
);
|
|
372
|
+
writeFileSync(
|
|
373
|
+
join(scripts, "current-consumer.mjs"),
|
|
374
|
+
`export {inspectCandidate,sha256,verifyProducerJoin} from ${JSON.stringify(pathToFileURL(join(repository, "scripts/current-consumer.mjs")).href)};`
|
|
375
|
+
);
|
|
376
|
+
writeFileSync(
|
|
377
|
+
join(f.cwd, "package.json"),
|
|
378
|
+
JSON.stringify({ type: "module", name: "@example/entry-fixture", version: "0.0.0" })
|
|
379
|
+
);
|
|
380
|
+
writeFileSync(join(f.cwd, "package-lock.json"), "{}\n");
|
|
381
|
+
execFileSync("git", ["add", "."], { cwd: f.cwd });
|
|
382
|
+
execFileSync(
|
|
383
|
+
"git",
|
|
384
|
+
[
|
|
385
|
+
"-c",
|
|
386
|
+
"user.name=Fictional Fixture",
|
|
387
|
+
"-c",
|
|
388
|
+
"user.email=fixture@example.invalid",
|
|
389
|
+
"-c",
|
|
390
|
+
"commit.gpgsign=false",
|
|
391
|
+
"commit",
|
|
392
|
+
"-qm",
|
|
393
|
+
"controlled entry source"
|
|
394
|
+
],
|
|
395
|
+
{ cwd: f.cwd }
|
|
396
|
+
);
|
|
397
|
+
const output = join(f.base, "entry-result");
|
|
398
|
+
const result = spawnSync(process.execPath, [entry, "--results-dir", output], {
|
|
399
|
+
cwd: f.cwd,
|
|
400
|
+
env: checks.safeEnvironment(process.env),
|
|
401
|
+
encoding: "utf8",
|
|
402
|
+
maxBuffer: 1024 ** 2
|
|
403
|
+
});
|
|
404
|
+
assert.equal(
|
|
405
|
+
existsSync(marker),
|
|
406
|
+
true,
|
|
407
|
+
"The entry module must finish evaluating before its graph awaits its validation exports."
|
|
408
|
+
);
|
|
409
|
+
assert.equal(result.status, 1);
|
|
410
|
+
const report = JSON.parse(readFileSync(join(output, "result.json"), "utf8"));
|
|
411
|
+
assert.equal(report.status, "failed");
|
|
412
|
+
assert.match(report.error, /Controlled stop before pack/u);
|
|
413
|
+
assert.equal(report.pack, void 0);
|
|
414
|
+
assert.equal(report.consumer, void 0);
|
|
415
|
+
} finally {
|
|
416
|
+
f.cleanup();
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
);
|
|
420
|
+
function fixture() {
|
|
421
|
+
const base = mkdtempSync(join(tmpdir(), "contributor-check-fixture-"));
|
|
422
|
+
const cwd = join(base, "repo");
|
|
423
|
+
mkdirSync(join(cwd, "src"), { recursive: true });
|
|
424
|
+
writeFileSync(
|
|
425
|
+
join(cwd, ".gitignore"),
|
|
426
|
+
"/dist/\n/node_modules/\n/plugins/ai-delivery/runtime/dist/\n/plugins/ai-delivery/dist/\n"
|
|
427
|
+
);
|
|
428
|
+
writeFileSync(join(cwd, "src/original.test.ts"), "// synthetic original test\n");
|
|
429
|
+
writeFileSync(
|
|
430
|
+
join(cwd, "package.json"),
|
|
431
|
+
JSON.stringify({
|
|
432
|
+
name: "@example/fixture",
|
|
433
|
+
version: "1.0.0",
|
|
434
|
+
bin: { fixture: "./dist/cli.js" },
|
|
435
|
+
exports: { ".": { default: "./dist/index.js" } }
|
|
436
|
+
})
|
|
437
|
+
);
|
|
438
|
+
execFileSync("git", ["init", "-q", cwd]);
|
|
439
|
+
execFileSync("git", ["add", "."], { cwd });
|
|
440
|
+
const toolchain = {
|
|
441
|
+
controller: { version: "v24.21.0", executable: process.execPath },
|
|
442
|
+
npm: { version: "11.19.0", executable: "synthetic-npm" },
|
|
443
|
+
libraryConsumer: { version: "v26.2.0", executable: "synthetic-node26" }
|
|
444
|
+
};
|
|
445
|
+
const cleanup = () => rmSync(base, { recursive: true, force: true });
|
|
446
|
+
return { base, cwd, toolchain, cleanup };
|
|
447
|
+
}
|
|
448
|
+
function passingReport(cwd, names) {
|
|
449
|
+
return {
|
|
450
|
+
success: true,
|
|
451
|
+
numTotalTests: names.length,
|
|
452
|
+
numPassedTests: names.length,
|
|
453
|
+
testResults: names.map((name) => ({
|
|
454
|
+
name: join(cwd, name),
|
|
455
|
+
status: "passed",
|
|
456
|
+
assertionResults: [{ fullName: "synthetic assertion", status: "passed" }]
|
|
457
|
+
}))
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
function executor(f, failStage = "") {
|
|
461
|
+
return async (command, options) => {
|
|
462
|
+
mkdirSync(options.directory, { recursive: true });
|
|
463
|
+
const stdoutPath = join(options.directory, "stdout.txt");
|
|
464
|
+
const stderrPath = join(options.directory, "stderr.txt");
|
|
465
|
+
writeFileSync(stdoutPath, "");
|
|
466
|
+
writeFileSync(stderrPath, "");
|
|
467
|
+
const stage = options.directory.split("/").at(-1);
|
|
468
|
+
if (stage === "build") {
|
|
469
|
+
assert.equal(
|
|
470
|
+
existsSync(join(f.cwd, "dist/stale.test.js")),
|
|
471
|
+
false,
|
|
472
|
+
"clean before build, rather than after selection"
|
|
473
|
+
);
|
|
474
|
+
mkdirSync(join(f.cwd, "dist"), { recursive: true });
|
|
475
|
+
for (const source of readdirSync(join(f.cwd, "src")).filter((name) => name.endsWith(".test.ts")))
|
|
476
|
+
writeFileSync(join(f.cwd, "dist", source.replace(/\.ts$/u, ".js")), "// compiled synthetic test\n");
|
|
477
|
+
for (const path of [
|
|
478
|
+
"dist/cli.js",
|
|
479
|
+
"dist/index.js",
|
|
480
|
+
"plugins/ai-delivery/runtime/dist/cli.js",
|
|
481
|
+
"plugins/ai-delivery/dist/mcp-launcher.js"
|
|
482
|
+
]) {
|
|
483
|
+
mkdirSync(dirname(join(f.cwd, path)), { recursive: true });
|
|
484
|
+
writeFileSync(join(f.cwd, path), "// fictional packaged output\n");
|
|
485
|
+
chmodSync(join(f.cwd, path), 493);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
if (stage === "tests") {
|
|
489
|
+
const names = command.filter((arg) => /^(?:dist\/.*\.test\.js|src\/.*\.test\.ts)$/u.test(arg));
|
|
490
|
+
assert.equal(names.length, 1);
|
|
491
|
+
const path = command.find((arg) => arg.startsWith("--outputFile.json=")).split("=").slice(1).join("=");
|
|
492
|
+
writeFileSync(path, JSON.stringify(passingReport(f.cwd, names)));
|
|
217
493
|
}
|
|
218
|
-
|
|
219
|
-
|
|
494
|
+
if (stage === "inventory") {
|
|
495
|
+
writeFileSync(
|
|
496
|
+
stdoutPath,
|
|
497
|
+
JSON.stringify([
|
|
498
|
+
{
|
|
499
|
+
name: "@example/fixture",
|
|
500
|
+
version: "1.0.0",
|
|
501
|
+
files: [
|
|
502
|
+
"dist/cli.js",
|
|
503
|
+
"dist/index.js",
|
|
504
|
+
"plugins/ai-delivery/runtime/dist/cli.js",
|
|
505
|
+
"plugins/ai-delivery/dist/mcp-launcher.js"
|
|
506
|
+
].map((path) => ({ path, mode: 493, size: readFileSync(join(f.cwd, path)).length }))
|
|
507
|
+
}
|
|
508
|
+
])
|
|
509
|
+
);
|
|
510
|
+
const coverage = options.env.NODE_V8_COVERAGE;
|
|
511
|
+
mkdirSync(coverage, { recursive: true });
|
|
512
|
+
writeFileSync(
|
|
513
|
+
join(coverage, "synthetic.json"),
|
|
514
|
+
JSON.stringify({
|
|
515
|
+
result: [
|
|
516
|
+
{
|
|
517
|
+
url: new URL(`file://${join(f.cwd, "dist/index.js")}`).href,
|
|
518
|
+
functions: [{ ranges: [{ startOffset: 0, endOffset: 1, count: 1 }] }]
|
|
519
|
+
}
|
|
520
|
+
]
|
|
521
|
+
})
|
|
522
|
+
);
|
|
220
523
|
}
|
|
524
|
+
const result = {
|
|
525
|
+
status: stage === failStage ? "failed" : "passed",
|
|
526
|
+
exitCode: stage === failStage ? 7 : 0,
|
|
527
|
+
stdoutPath,
|
|
528
|
+
stderrPath
|
|
529
|
+
};
|
|
530
|
+
options.progress?.(result);
|
|
531
|
+
return { ...result, cleanupConfirmed: true };
|
|
532
|
+
};
|
|
533
|
+
}
|
|
534
|
+
test("local and CI share the PR producer while explicit release owns package qualification", () => {
|
|
535
|
+
const manifest = JSON.parse(readFileSync(join(repository, "package.json"), "utf8"));
|
|
536
|
+
assert.equal(manifest.scripts.checks, "node scripts/checks.mjs");
|
|
537
|
+
assert.equal(manifest.scripts["checks:release"], "node scripts/current-qualification.mjs");
|
|
538
|
+
assert.equal(manifest.scripts["checks:producer"], "node scripts/current-qualification.mjs --producer-only");
|
|
539
|
+
assert.equal(manifest.scripts["checks:fast"], "node scripts/checks.mjs --fast");
|
|
540
|
+
const ci = readFileSync(join(repository, ".github/workflows/ci.yml"), "utf8");
|
|
541
|
+
assert.match(ci, /npm run checks -- --results-dir/u);
|
|
542
|
+
assert.doesNotMatch(ci, /npm run build|npm pack/u);
|
|
543
|
+
assert.doesNotMatch(ci, /checks:release|current-qualification/u);
|
|
544
|
+
assert.match(ci, /Retain PR producer and interrupted check evidence/u);
|
|
545
|
+
assert.match(ci, /if: always\(\)/u);
|
|
546
|
+
assert.deepEqual(checks.FULL_GATES, ["format", "lint", "types", "build", "tests", "inventory"]);
|
|
221
547
|
});
|
|
222
|
-
test(
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
];
|
|
241
|
-
report.
|
|
242
|
-
report.
|
|
243
|
-
|
|
244
|
-
assert.equal(
|
|
245
|
-
assert.
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
file.assertionResults[2].fullName = 'unexpected conditional skip';
|
|
252
|
-
assert.throws(() => checks.analyzeTests(report, ['dist/setup.test.js'], cwd, ''), /Unexpected skip/u);
|
|
253
|
-
assert.throws(() => checks.analyzeTests({ success: true, numTotalTests: 0, numPassedTests: 0, testResults: [] }, [], cwd, ''), /Zero tests/u);
|
|
548
|
+
test("clean full graph removes deleted/renamed compiled tests and retains exact command evidence", async () => {
|
|
549
|
+
const f = fixture();
|
|
550
|
+
try {
|
|
551
|
+
mkdirSync(join(f.cwd, "dist"));
|
|
552
|
+
writeFileSync(join(f.cwd, "dist/stale.test.js"), "// deleted source output\n");
|
|
553
|
+
renameSync(join(f.cwd, "src/original.test.ts"), join(f.cwd, "src/renamed.test.ts"));
|
|
554
|
+
const resultsDir = join(f.base, "results");
|
|
555
|
+
const report = await checks.runChecks({
|
|
556
|
+
cwd: f.cwd,
|
|
557
|
+
resultsDir,
|
|
558
|
+
toolchain: () => f.toolchain,
|
|
559
|
+
execute: executor(f)
|
|
560
|
+
});
|
|
561
|
+
assert.equal(report.fullSuccess, true, report.error);
|
|
562
|
+
assert.deepEqual(
|
|
563
|
+
report.commands.map((entry) => entry.stage),
|
|
564
|
+
checks.FULL_GATES
|
|
565
|
+
);
|
|
566
|
+
assert.deepEqual(report.selectedTestFiles, ["src/renamed.test.ts"]);
|
|
567
|
+
assert.ok(report.commands[2].command.includes("--emitDeclarationOnly"));
|
|
568
|
+
assert.deepEqual(report.commands[3].command.slice(1), [join(f.cwd, "scripts/build.mjs"), "--plugin"]);
|
|
569
|
+
assert.match(readFileSync(join(resultsDir, "result.txt"), "utf8"), /FULL contributor checks: passed/u);
|
|
570
|
+
assert.equal(existsSync(join(f.cwd, "dist/stale.test.js")), false);
|
|
571
|
+
await assert.rejects(checks.runChecks({ cwd: f.cwd, resultsDir }), /Existing result/u);
|
|
572
|
+
writeFileSync(join(f.cwd, "dist/stale.test.js"), "// unexpected survivor\n");
|
|
573
|
+
assert.throws(() => checks.assertCleanSelection(f.cwd), /stale, deleted, renamed/u);
|
|
574
|
+
} finally {
|
|
575
|
+
f.cleanup();
|
|
576
|
+
}
|
|
254
577
|
});
|
|
255
|
-
test(
|
|
578
|
+
test("successful required checks bind only the same clean committed head through finalization", async () => {
|
|
579
|
+
for (const scenario of ["stable", "head-drift", "hidden-change", "cleanup-unconfirmed"]) {
|
|
256
580
|
const f = fixture();
|
|
257
581
|
try {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
582
|
+
const git = (...args) => execFileSync(
|
|
583
|
+
"git",
|
|
584
|
+
[
|
|
585
|
+
"-c",
|
|
586
|
+
"user.name=Fixture",
|
|
587
|
+
"-c",
|
|
588
|
+
"user.email=fixture@example.invalid",
|
|
589
|
+
"-c",
|
|
590
|
+
"commit.gpgsign=false",
|
|
591
|
+
"-c",
|
|
592
|
+
"core.hooksPath=/dev/null",
|
|
593
|
+
...args
|
|
594
|
+
],
|
|
595
|
+
{ cwd: f.cwd, encoding: "utf8" }
|
|
596
|
+
).trim();
|
|
597
|
+
git("commit", "-qm", "Clean source");
|
|
598
|
+
const expected = { sha: git("rev-parse", "HEAD"), tree: git("rev-parse", "HEAD^{tree}") };
|
|
599
|
+
if (scenario === "hidden-change") {
|
|
600
|
+
git("update-index", "--assume-unchanged", "src/original.test.ts");
|
|
601
|
+
writeFileSync(join(f.cwd, "src/original.test.ts"), "// bytes outside the committed head\n");
|
|
602
|
+
}
|
|
603
|
+
const execute = executor(f);
|
|
604
|
+
const report = await checks.runChecks({
|
|
605
|
+
cwd: f.cwd,
|
|
606
|
+
resultsDir: join(f.base, "head-results"),
|
|
607
|
+
toolchain: () => f.toolchain,
|
|
608
|
+
execute: async (command, options) => {
|
|
609
|
+
const result = await execute(command, options);
|
|
610
|
+
if (scenario === "head-drift" && options.directory.endsWith("/inventory"))
|
|
611
|
+
git("commit", "--allow-empty", "-qm", "Same-tree drift");
|
|
612
|
+
return { ...result, cleanupConfirmed: scenario !== "cleanup-unconfirmed" };
|
|
613
|
+
}
|
|
614
|
+
});
|
|
615
|
+
assert.equal(report.status, "passed", report.error);
|
|
616
|
+
assert.deepEqual(
|
|
617
|
+
report.verifiedHead,
|
|
618
|
+
scenario === "stable" ? expected : void 0
|
|
619
|
+
);
|
|
620
|
+
} finally {
|
|
621
|
+
f.cleanup();
|
|
271
622
|
}
|
|
623
|
+
}
|
|
272
624
|
});
|
|
273
|
-
test(
|
|
625
|
+
test("fast success and command failure remain partial and preserve omitted/remaining proof", async () => {
|
|
626
|
+
const f = fixture();
|
|
627
|
+
try {
|
|
628
|
+
const fast = await checks.runChecks({
|
|
629
|
+
cwd: f.cwd,
|
|
630
|
+
resultsDir: join(f.base, "fast"),
|
|
631
|
+
fast: true,
|
|
632
|
+
toolchain: () => f.toolchain,
|
|
633
|
+
execute: executor(f)
|
|
634
|
+
});
|
|
635
|
+
assert.equal(fast.status, "partial-passed");
|
|
636
|
+
assert.equal(fast.fullSuccess, false);
|
|
637
|
+
assert.deepEqual(fast.omitted, ["build", "tests", "inventory"]);
|
|
638
|
+
const failed = await checks.runChecks({
|
|
639
|
+
cwd: f.cwd,
|
|
640
|
+
resultsDir: join(f.base, "failed"),
|
|
641
|
+
toolchain: () => f.toolchain,
|
|
642
|
+
execute: executor(f, "lint")
|
|
643
|
+
});
|
|
644
|
+
assert.equal(failed.exitCode, 1);
|
|
645
|
+
assert.equal(failed.fullSuccess, false);
|
|
646
|
+
assert.deepEqual(
|
|
647
|
+
failed.commands.map((entry) => entry.stage),
|
|
648
|
+
["format", "lint"]
|
|
649
|
+
);
|
|
650
|
+
assert.match(failed.error, /lint: failed/u);
|
|
651
|
+
const testFailure = await checks.runChecks({
|
|
652
|
+
cwd: f.cwd,
|
|
653
|
+
resultsDir: join(f.base, "failed-tests"),
|
|
654
|
+
toolchain: () => f.toolchain,
|
|
655
|
+
execute: executor(f, "tests")
|
|
656
|
+
});
|
|
657
|
+
assert.equal(testFailure.fullSuccess, false);
|
|
658
|
+
assert.equal(testFailure.observedTests?.total, 1);
|
|
659
|
+
assert.match(readFileSync(join(f.base, "failed-tests/result.txt"), "utf8"), /Observed test results/u);
|
|
660
|
+
assert.equal(testFailure.commands.at(-1).status, "failed");
|
|
661
|
+
} finally {
|
|
662
|
+
f.cleanup();
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
test("explicit focused files run only their compilation and tests without install, inventory or plugin bundling", async () => {
|
|
666
|
+
for (const selected of ["original", "tooling"]) {
|
|
274
667
|
const f = fixture();
|
|
275
|
-
const peer = spawn(process.execPath, ['-e', 'setInterval(()=>{},1000)'], { stdio: 'ignore' });
|
|
276
668
|
try {
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
process.kill(peer.pid, 0);
|
|
305
|
-
}
|
|
306
|
-
finally {
|
|
307
|
-
peer.kill('SIGKILL');
|
|
308
|
-
await new Promise((done) => {
|
|
309
|
-
if (peer.exitCode !== null || peer.signalCode !== null)
|
|
310
|
-
done();
|
|
311
|
-
else
|
|
312
|
-
peer.once('close', () => done());
|
|
313
|
-
});
|
|
314
|
-
f.cleanup();
|
|
669
|
+
writeFileSync(join(f.cwd, "src/tooling.test.ts"), "// another changed contract\n");
|
|
670
|
+
const report = await checks.runChecks({
|
|
671
|
+
cwd: f.cwd,
|
|
672
|
+
resultsDir: join(f.base, "focused"),
|
|
673
|
+
fast: true,
|
|
674
|
+
testFiles: [`dist/${selected}.test.js`],
|
|
675
|
+
toolchain: () => f.toolchain,
|
|
676
|
+
execute: executor(f)
|
|
677
|
+
});
|
|
678
|
+
assert.equal(report.exitCode, 0, report.error);
|
|
679
|
+
assert.equal(report.scope, "focused");
|
|
680
|
+
assert.equal(report.status, "partial-passed");
|
|
681
|
+
assert.equal(report.fullSuccess, false);
|
|
682
|
+
assert.deepEqual(report.selectedTestFiles, [`dist/${selected}.test.js`]);
|
|
683
|
+
assert.deepEqual(
|
|
684
|
+
report.commands.map((entry) => entry.stage),
|
|
685
|
+
["format", "lint", "types", "build", "tests"]
|
|
686
|
+
);
|
|
687
|
+
assert.deepEqual(report.commands[3].command.slice(1), [join(f.cwd, "scripts/build.mjs")]);
|
|
688
|
+
assert.ok(report.omitted.includes("unselected tests"));
|
|
689
|
+
assert.ok(report.omitted.includes("inventory"));
|
|
690
|
+
assert.equal(
|
|
691
|
+
report.commands.some((entry) => entry.command.includes("ci") || entry.command.includes("pack")),
|
|
692
|
+
false
|
|
693
|
+
);
|
|
694
|
+
} finally {
|
|
695
|
+
f.cleanup();
|
|
315
696
|
}
|
|
697
|
+
}
|
|
316
698
|
});
|
|
317
|
-
test(
|
|
699
|
+
test("invalid focused selection or local dependency install refuses before launching any gate", async () => {
|
|
700
|
+
for (const options of [
|
|
701
|
+
{ fast: true, testFiles: [] },
|
|
702
|
+
{ fast: true, testFiles: ["dist/missing.test.js"] },
|
|
703
|
+
{ fast: true, testFiles: ["../dist/original.test.js"] },
|
|
704
|
+
{ fast: true, testFiles: ["dist/*.test.js"] },
|
|
705
|
+
{ fast: true, testFiles: ["dist/original.test.js", "dist/original.test.js"] },
|
|
706
|
+
{ testFiles: ["dist/original.test.js"] },
|
|
707
|
+
{ fast: true, install: true }
|
|
708
|
+
]) {
|
|
318
709
|
const f = fixture();
|
|
319
710
|
try {
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
711
|
+
const report = await checks.runChecks({
|
|
712
|
+
cwd: f.cwd,
|
|
713
|
+
resultsDir: join(f.base, "invalid"),
|
|
714
|
+
...options,
|
|
715
|
+
toolchain: () => f.toolchain,
|
|
716
|
+
execute: executor(f)
|
|
717
|
+
});
|
|
718
|
+
assert.equal(report.exitCode, 1);
|
|
719
|
+
assert.equal(report.fullSuccess, false);
|
|
720
|
+
assert.deepEqual(report.commands, []);
|
|
721
|
+
assert.match(report.error, /focused|install|selection|explicit/iu);
|
|
722
|
+
} finally {
|
|
723
|
+
f.cleanup();
|
|
332
724
|
}
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
test("focused plugin bundling requires an explicit artifact-dependent selection", async () => {
|
|
728
|
+
const f = fixture();
|
|
729
|
+
try {
|
|
730
|
+
const report = await checks.runChecks({
|
|
731
|
+
cwd: f.cwd,
|
|
732
|
+
resultsDir: join(f.base, "plugin-focused"),
|
|
733
|
+
fast: true,
|
|
734
|
+
testFiles: ["dist/original.test.js"],
|
|
735
|
+
buildPlugin: true,
|
|
736
|
+
toolchain: () => f.toolchain,
|
|
737
|
+
execute: executor(f)
|
|
738
|
+
});
|
|
739
|
+
assert.equal(report.exitCode, 0, report.error);
|
|
740
|
+
assert.deepEqual(
|
|
741
|
+
report.commands.map((entry) => entry.stage),
|
|
742
|
+
["format", "lint", "types", "build", "plugin-build", "tests"]
|
|
743
|
+
);
|
|
744
|
+
assert.equal(report.fullSuccess, false);
|
|
745
|
+
} finally {
|
|
746
|
+
f.cleanup();
|
|
747
|
+
}
|
|
748
|
+
});
|
|
749
|
+
test("toolchain preflight rejects absent/inaccessible/wrong consumer before gates; environment excludes credentials and ambient preloads", async () => {
|
|
750
|
+
const env = checks.safeEnvironment({
|
|
751
|
+
PATH: process.env.PATH,
|
|
752
|
+
HOME: process.env.HOME,
|
|
753
|
+
GH_TOKEN: "fictional-do-not-forward",
|
|
754
|
+
GH_PRIVATE_KEY_GPT_REVIEWER: "fictional-ref",
|
|
755
|
+
NODE_OPTIONS: "--require fictional",
|
|
756
|
+
NODE_PATH: "checkout-only",
|
|
757
|
+
NPM_TOKEN: "fictional-token",
|
|
758
|
+
AI_DELIVERY_REAL_PACKAGE_ARCHIVE: "/synthetic/explicit-historical.tgz"
|
|
759
|
+
});
|
|
760
|
+
assert.equal(env.GH_TOKEN, void 0);
|
|
761
|
+
assert.equal(env.NODE_OPTIONS, void 0);
|
|
762
|
+
assert.equal(env.NODE_PATH, void 0);
|
|
763
|
+
assert.equal(env.NPM_TOKEN, void 0);
|
|
764
|
+
assert.equal(env.AI_DELIVERY_REAL_PACKAGE_ARCHIVE, "/synthetic/explicit-historical.tgz");
|
|
765
|
+
assert.throws(() => checks.validateToolchain(repository, env), /AI_DELIVERY_NODE26_EXECUTABLE/u);
|
|
766
|
+
assert.throws(
|
|
767
|
+
() => checks.validateToolchain(repository, { ...env, AI_DELIVERY_NODE26_EXECUTABLE: "/nonexistent/synthetic-node" }),
|
|
768
|
+
/ENOENT/u
|
|
769
|
+
);
|
|
770
|
+
assert.throws(
|
|
771
|
+
() => checks.validateToolchain(repository, { ...env, AI_DELIVERY_NODE26_EXECUTABLE: process.execPath }),
|
|
772
|
+
/Node 26\.2\.0/u
|
|
773
|
+
);
|
|
774
|
+
const f = fixture();
|
|
775
|
+
try {
|
|
776
|
+
const report = await checks.runChecks({
|
|
777
|
+
cwd: f.cwd,
|
|
778
|
+
resultsDir: join(f.base, "missing"),
|
|
779
|
+
toolchain: () => {
|
|
780
|
+
throw new Error("missing runtime");
|
|
781
|
+
}
|
|
782
|
+
});
|
|
783
|
+
assert.equal(report.fullSuccess, false);
|
|
784
|
+
assert.deepEqual(report.commands, []);
|
|
785
|
+
} finally {
|
|
786
|
+
f.cleanup();
|
|
787
|
+
}
|
|
333
788
|
});
|
|
334
|
-
test(
|
|
789
|
+
test(
|
|
790
|
+
"real failed and explicitly timed-out commands preserve logs and prove owned cleanup",
|
|
791
|
+
{ tags: ["release"] },
|
|
792
|
+
async () => {
|
|
335
793
|
const f = fixture();
|
|
336
794
|
try {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
795
|
+
const env = checks.safeEnvironment(process.env);
|
|
796
|
+
const failed = await checks.executeCommand(
|
|
797
|
+
[process.execPath, "-e", "console.log('partial failure evidence');process.exit(7)"],
|
|
798
|
+
{ cwd: f.cwd, env, directory: join(f.base, "failure") }
|
|
799
|
+
);
|
|
800
|
+
assert.equal(failed.status, "failed");
|
|
801
|
+
assert.equal(failed.exitCode, 7);
|
|
802
|
+
assert.match(readFileSync(failed.stdoutPath, "utf8"), /partial failure evidence/u);
|
|
803
|
+
const timed = await checks.executeCommand(
|
|
804
|
+
[process.execPath, "-e", "console.log('started');setInterval(()=>{},1000)"],
|
|
805
|
+
{ cwd: f.cwd, env, directory: join(f.base, "timeout"), timeoutMs: 200 }
|
|
806
|
+
);
|
|
807
|
+
assert.equal(timed.status, "command-timeout");
|
|
808
|
+
assert.equal(timed.cleanupConfirmed, true);
|
|
809
|
+
assert.ok(timed.observedProcesses.length > 0);
|
|
810
|
+
assert.ok(timed.observedProcesses.every((row) => row.birth.length > 0));
|
|
811
|
+
} finally {
|
|
812
|
+
f.cleanup();
|
|
346
813
|
}
|
|
347
|
-
|
|
348
|
-
|
|
814
|
+
}
|
|
815
|
+
);
|
|
816
|
+
test(
|
|
817
|
+
"cancellation reaps observed detached descendants and preserves an unrelated peer",
|
|
818
|
+
{ tags: ["release"] },
|
|
819
|
+
async () => {
|
|
820
|
+
const f = fixture();
|
|
821
|
+
const peer = spawn(process.execPath, ["-e", "setInterval(()=>{},1000)"], { stdio: "ignore" });
|
|
822
|
+
try {
|
|
823
|
+
const controller = new AbortController();
|
|
824
|
+
const marker = join(f.base, "owned-child");
|
|
825
|
+
const script = `const cp=require('node:child_process'),fs=require('node:fs');const c=cp.spawn(process.execPath,['-e','setInterval(()=>{},1000)'],{detached:true,stdio:'ignore'});fs.writeFileSync(${JSON.stringify(marker)},String(c.pid));setInterval(()=>{},1000);`;
|
|
826
|
+
const timer = setInterval(() => {
|
|
827
|
+
if (existsSync(marker)) {
|
|
828
|
+
clearInterval(timer);
|
|
829
|
+
setTimeout(() => controller.abort(), 250);
|
|
830
|
+
}
|
|
831
|
+
}, 20);
|
|
832
|
+
const result = await checks.executeCommand([process.execPath, "-e", script], {
|
|
833
|
+
cwd: f.cwd,
|
|
834
|
+
env: checks.safeEnvironment(process.env),
|
|
835
|
+
directory: join(f.base, "cancelled"),
|
|
836
|
+
signal: controller.signal
|
|
837
|
+
});
|
|
838
|
+
clearInterval(timer);
|
|
839
|
+
assert.equal(result.status, "cancelled");
|
|
840
|
+
assert.equal(result.cleanupConfirmed, true);
|
|
841
|
+
const ownedPid = readFileSync(marker, "utf8");
|
|
842
|
+
const state = execFileSync("/bin/ps", ["-p", ownedPid, "-o", "stat="], { encoding: "utf8" }).trim();
|
|
843
|
+
assert.ok(state.startsWith("Z"));
|
|
844
|
+
process.kill(peer.pid, 0);
|
|
845
|
+
} catch (error) {
|
|
846
|
+
if (!(error instanceof Error && "status" in error && error.status === 1)) throw error;
|
|
847
|
+
process.kill(peer.pid, 0);
|
|
848
|
+
} finally {
|
|
849
|
+
peer.kill("SIGKILL");
|
|
850
|
+
await new Promise((done) => {
|
|
851
|
+
if (peer.exitCode !== null || peer.signalCode !== null) done();
|
|
852
|
+
else peer.once("close", () => done());
|
|
853
|
+
});
|
|
854
|
+
f.cleanup();
|
|
349
855
|
}
|
|
856
|
+
}
|
|
857
|
+
);
|
|
858
|
+
test("existing temporary aliases resolve to the same physical directory without creating a new destination", () => {
|
|
859
|
+
const f = fixture();
|
|
860
|
+
try {
|
|
861
|
+
const target = join(f.base, "existing-temp");
|
|
862
|
+
const alias = join(f.base, "temp-alias");
|
|
863
|
+
mkdirSync(target);
|
|
864
|
+
symlinkSync(target, alias);
|
|
865
|
+
const env = checks.safeEnvironment({ TMPDIR: alias, TEMP: alias, TMP: alias });
|
|
866
|
+
assert.equal(env.TMPDIR, realpathSync(target));
|
|
867
|
+
assert.equal(env.TEMP, realpathSync(target));
|
|
868
|
+
assert.equal(env.TMP, realpathSync(target));
|
|
869
|
+
assert.equal(readFileSync(join(f.cwd, "src/original.test.ts"), "utf8"), "// synthetic original test\n");
|
|
870
|
+
} finally {
|
|
871
|
+
f.cleanup();
|
|
872
|
+
}
|
|
873
|
+
});
|
|
874
|
+
test("source identity preserves leading filename whitespace and refuses dangling tracked symlinks", () => {
|
|
875
|
+
const f = fixture();
|
|
876
|
+
try {
|
|
877
|
+
const path = join(f.cwd, " leading.txt");
|
|
878
|
+
writeFileSync(path, "first source bytes");
|
|
879
|
+
execFileSync("git", ["add", "--", " leading.txt"], { cwd: f.cwd });
|
|
880
|
+
const before = checks.treeIdentity(f.cwd).sha256;
|
|
881
|
+
writeFileSync(path, "changed source bytes");
|
|
882
|
+
assert.notEqual(checks.treeIdentity(f.cwd).sha256, before);
|
|
883
|
+
symlinkSync("nonexistent-target", join(f.cwd, "dangling-link"));
|
|
884
|
+
execFileSync("git", ["add", "--", "dangling-link"], { cwd: f.cwd });
|
|
885
|
+
assert.throws(() => checks.treeIdentity(f.cwd), /regular tracked\/source files/u);
|
|
886
|
+
} finally {
|
|
887
|
+
f.cleanup();
|
|
888
|
+
}
|
|
350
889
|
});
|
|
351
|
-
test(
|
|
890
|
+
test(
|
|
891
|
+
"cancellation discovers children born from a detached owner after the root exits and preserves a peer",
|
|
892
|
+
{ tags: ["release"] },
|
|
893
|
+
async () => {
|
|
352
894
|
const f = fixture();
|
|
353
|
-
const peer = spawn(process.execPath, [
|
|
354
|
-
const marker = join(f.base,
|
|
895
|
+
const peer = spawn(process.execPath, ["-e", "setInterval(()=>{},1000)"], { stdio: "ignore" });
|
|
896
|
+
const marker = join(f.base, "late-children.json");
|
|
355
897
|
const controller = new AbortController();
|
|
356
898
|
const identity = (pid) => {
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
899
|
+
const result = spawnSync("/bin/ps", ["-p", String(pid), "-o", "stat=,lstart="], { encoding: "utf8" });
|
|
900
|
+
assert.ok(!result.error, result.error?.message);
|
|
901
|
+
assert.ok(result.status === 0 || result.status === 1, result.stderr);
|
|
902
|
+
return result.status === 1 ? void 0 : result.stdout.trim();
|
|
361
903
|
};
|
|
362
904
|
let timer;
|
|
363
905
|
try {
|
|
364
|
-
|
|
906
|
+
const descendant = `const cp=require('node:child_process'),fs=require('node:fs');
|
|
365
907
|
const id=(pid)=>cp.execFileSync('/bin/ps',['-p',String(pid),'-o','stat=,lstart='],{encoding:'utf8'}).trim().split(/\\s+/).slice(1).join(' ');
|
|
366
908
|
const record={a:process.pid,aBirth:id(process.pid)};fs.writeFileSync(${JSON.stringify(marker)},JSON.stringify(record));
|
|
367
909
|
process.once('SIGTERM',()=>setTimeout(()=>{
|
|
@@ -370,641 +912,877 @@ record.rootExited=root.status===1||root.stdout.trim().startsWith('Z');
|
|
|
370
912
|
const b=cp.spawn(process.execPath,['-e','setInterval(()=>{},1000)'],{detached:true,stdio:'ignore'});
|
|
371
913
|
record.b=b.pid;record.bBirth=id(b.pid);fs.writeFileSync(${JSON.stringify(marker)},JSON.stringify(record));
|
|
372
914
|
},200));setInterval(()=>{},1000);`;
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
timer = setInterval(() => {
|
|
376
|
-
if (existsSync(marker)) {
|
|
377
|
-
clearInterval(timer);
|
|
378
|
-
setTimeout(() => controller.abort(), 250);
|
|
379
|
-
}
|
|
380
|
-
}, 20);
|
|
381
|
-
const result = await checks.executeCommand([process.execPath, '-e', script], {
|
|
382
|
-
cwd: f.cwd,
|
|
383
|
-
env: checks.safeEnvironment(process.env),
|
|
384
|
-
directory: join(f.base, 'late-cancellation'),
|
|
385
|
-
signal: controller.signal,
|
|
386
|
-
});
|
|
387
|
-
const children = JSON.parse(readFileSync(marker, 'utf8'));
|
|
388
|
-
assert.ok(children.b, 'The TERM-resistant owner must create a late descendant.');
|
|
389
|
-
assert.equal(children.rootExited, true, 'The late descendant must be born after the root exits.');
|
|
390
|
-
assert.equal(result.status, 'cancelled');
|
|
391
|
-
assert.equal(result.cleanupConfirmed, true);
|
|
392
|
-
assert.ok(result.observedProcesses?.some((row) => row.pid === children.b && row.birth === children.bBirth));
|
|
393
|
-
for (const pid of [children.a, children.b])
|
|
394
|
-
assert.ok(identity(pid)?.startsWith('Z') ?? true);
|
|
395
|
-
process.kill(peer.pid, 0);
|
|
396
|
-
}
|
|
397
|
-
finally {
|
|
398
|
-
clearInterval(timer);
|
|
399
|
-
// On a failing assertion, signal only the synthetic identities this fixture recorded.
|
|
915
|
+
const script = `const cp=require('node:child_process');cp.spawn(process.execPath,['-e',${JSON.stringify(descendant)},String(process.pid)],{detached:true,stdio:'ignore'});setInterval(()=>{},1000);`;
|
|
916
|
+
timer = setInterval(() => {
|
|
400
917
|
if (existsSync(marker)) {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
[children.a, children.aBirth],
|
|
404
|
-
[children.b, children.bBirth],
|
|
405
|
-
]) {
|
|
406
|
-
if (pid && birth) {
|
|
407
|
-
const state = identity(pid);
|
|
408
|
-
if (state && !state.startsWith('Z') && state.split(/\s+/u).slice(1).join(' ') === birth)
|
|
409
|
-
process.kill(pid, 'SIGKILL');
|
|
410
|
-
}
|
|
411
|
-
}
|
|
918
|
+
clearInterval(timer);
|
|
919
|
+
setTimeout(() => controller.abort(), 250);
|
|
412
920
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
f.cleanup();
|
|
921
|
+
}, 20);
|
|
922
|
+
const result = await checks.executeCommand([process.execPath, "-e", script], {
|
|
923
|
+
cwd: f.cwd,
|
|
924
|
+
env: checks.safeEnvironment(process.env),
|
|
925
|
+
directory: join(f.base, "late-cancellation"),
|
|
926
|
+
signal: controller.signal
|
|
927
|
+
});
|
|
928
|
+
const children = JSON.parse(readFileSync(marker, "utf8"));
|
|
929
|
+
assert.ok(children.b, "The TERM-resistant owner must create a late descendant.");
|
|
930
|
+
assert.equal(children.rootExited, true, "The late descendant must be born after the root exits.");
|
|
931
|
+
assert.equal(result.status, "cancelled");
|
|
932
|
+
assert.equal(result.cleanupConfirmed, true);
|
|
933
|
+
assert.ok(result.observedProcesses?.some((row) => row.pid === children.b && row.birth === children.bBirth));
|
|
934
|
+
for (const pid of [children.a, children.b]) assert.ok(identity(pid)?.startsWith("Z") ?? true);
|
|
935
|
+
process.kill(peer.pid, 0);
|
|
936
|
+
} finally {
|
|
937
|
+
clearInterval(timer);
|
|
938
|
+
if (existsSync(marker)) {
|
|
939
|
+
const children = JSON.parse(readFileSync(marker, "utf8"));
|
|
940
|
+
for (const [pid, birth] of [
|
|
941
|
+
[children.a, children.aBirth],
|
|
942
|
+
[children.b, children.bBirth]
|
|
943
|
+
]) {
|
|
944
|
+
if (pid && birth) {
|
|
945
|
+
const state = identity(pid);
|
|
946
|
+
if (state && !state.startsWith("Z") && state.split(/\s+/u).slice(1).join(" ") === birth)
|
|
947
|
+
process.kill(pid, "SIGKILL");
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
peer.kill("SIGKILL");
|
|
952
|
+
await new Promise((done) => {
|
|
953
|
+
if (peer.exitCode !== null || peer.signalCode !== null) done();
|
|
954
|
+
else peer.once("close", () => done());
|
|
955
|
+
});
|
|
956
|
+
f.cleanup();
|
|
450
957
|
}
|
|
958
|
+
}
|
|
959
|
+
);
|
|
960
|
+
test("coverage labels unobserved contributor scripts without synthesizing measured ranges or floors", () => {
|
|
961
|
+
const f = fixture();
|
|
962
|
+
try {
|
|
963
|
+
const directory = join(f.base, "unit-coverage");
|
|
964
|
+
mkdirSync(directory);
|
|
965
|
+
writeFileSync(
|
|
966
|
+
join(directory, "fixture.json"),
|
|
967
|
+
JSON.stringify({
|
|
968
|
+
result: [
|
|
969
|
+
{
|
|
970
|
+
url: new URL("scripts/build-plugin.mjs", `file://${f.cwd}/`).href,
|
|
971
|
+
functions: [{ ranges: [{ startOffset: 0, endOffset: 1, count: 1 }] }]
|
|
972
|
+
}
|
|
973
|
+
]
|
|
974
|
+
})
|
|
975
|
+
);
|
|
976
|
+
const baseline = checks.coverageBaseline(directory, f.cwd);
|
|
977
|
+
assert.deepEqual(
|
|
978
|
+
baseline.files.map((file) => file.path),
|
|
979
|
+
["scripts/build-plugin.mjs"]
|
|
980
|
+
);
|
|
981
|
+
assert.deepEqual(
|
|
982
|
+
baseline.unmeasuredContributorScripts.map((file) => file.path),
|
|
983
|
+
[
|
|
984
|
+
"scripts/checks.mjs",
|
|
985
|
+
"scripts/pre-commit.mjs",
|
|
986
|
+
"scripts/current-qualification.mjs",
|
|
987
|
+
"scripts/current-consumer.mjs"
|
|
988
|
+
]
|
|
989
|
+
);
|
|
990
|
+
assert.ok(baseline.unmeasuredContributorScripts.every((file) => file.threshold === null && file.reason.length > 0));
|
|
991
|
+
assert.match(baseline.thresholdProposal, /no derived floor until actual instrumentation/u);
|
|
992
|
+
} finally {
|
|
993
|
+
f.cleanup();
|
|
994
|
+
}
|
|
451
995
|
});
|
|
452
|
-
const qualification =
|
|
453
|
-
const consumerProof =
|
|
996
|
+
const qualification = await import(new URL("../scripts/current-qualification.mjs", import.meta.url).href);
|
|
997
|
+
const consumerProof = await import(new URL("../scripts/current-consumer.mjs", import.meta.url).href);
|
|
454
998
|
function qualificationFixture() {
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
status: 'passed',
|
|
507
|
-
fullSuccess: true,
|
|
508
|
-
exitCode: 0,
|
|
509
|
-
gates: checks.FULL_GATES,
|
|
510
|
-
omitted: [],
|
|
511
|
-
tree: qualification.sourceIdentity(f.cwd).fingerprint,
|
|
512
|
-
commands: checks.FULL_GATES.map((stage) => ({
|
|
513
|
-
stage,
|
|
514
|
-
status: 'passed',
|
|
515
|
-
exitCode: 0,
|
|
516
|
-
signal: null,
|
|
517
|
-
cleanupConfirmed: true,
|
|
518
|
-
})),
|
|
519
|
-
tests: { files: 1, total: 1, passed: 1, skips: [] },
|
|
520
|
-
selectedTestFiles: ['dist/original.test.js'],
|
|
521
|
-
toolchain: f.toolchain,
|
|
522
|
-
inventory: {
|
|
523
|
-
kind: 'dry-inventory-only',
|
|
524
|
-
name: '@aviaratech/ai-delivery',
|
|
525
|
-
version: '1.0.0',
|
|
526
|
-
fileCount: members.length,
|
|
527
|
-
files: members.map((item) => ({ ...item, sha256: consumerProof.sha256(readFileSync(join(f.cwd, item.path))) })),
|
|
528
|
-
},
|
|
529
|
-
};
|
|
530
|
-
mutateProducer(report);
|
|
531
|
-
writeFileSync(join(resultsDir, 'result.json'), JSON.stringify(report));
|
|
532
|
-
return report;
|
|
999
|
+
const f = fixture();
|
|
1000
|
+
mkdirSync(join(f.cwd, "dist"));
|
|
1001
|
+
writeFileSync(join(f.cwd, "dist/generated.js"), "original");
|
|
1002
|
+
writeFileSync(join(f.cwd, "package-lock.json"), "{}\n");
|
|
1003
|
+
execFileSync("git", ["add", "."], { cwd: f.cwd });
|
|
1004
|
+
execFileSync(
|
|
1005
|
+
"git",
|
|
1006
|
+
[
|
|
1007
|
+
"-c",
|
|
1008
|
+
"user.name=Fictional fixture",
|
|
1009
|
+
"-c",
|
|
1010
|
+
"user.email=fixture@example.invalid",
|
|
1011
|
+
"-c",
|
|
1012
|
+
"core.hooksPath=/dev/null",
|
|
1013
|
+
"commit",
|
|
1014
|
+
"-qm",
|
|
1015
|
+
"fictional clean source"
|
|
1016
|
+
],
|
|
1017
|
+
{ cwd: f.cwd }
|
|
1018
|
+
);
|
|
1019
|
+
let producers = 0;
|
|
1020
|
+
let packs = 0;
|
|
1021
|
+
let consumers = 0;
|
|
1022
|
+
let releases = 0;
|
|
1023
|
+
let releaseHook = async () => {
|
|
1024
|
+
};
|
|
1025
|
+
const order = [];
|
|
1026
|
+
let packStatus = "passed";
|
|
1027
|
+
let cleanup = true;
|
|
1028
|
+
let mutateProducer = () => {
|
|
1029
|
+
};
|
|
1030
|
+
const members = [
|
|
1031
|
+
{ path: "dist/generated.js", size: 8, mode: 420 },
|
|
1032
|
+
{ path: "package.json", size: readFileSync(join(f.cwd, "package.json")).length, mode: 420 }
|
|
1033
|
+
];
|
|
1034
|
+
const inspect = (contract) => {
|
|
1035
|
+
assert.equal(consumerProof.sha256(readFileSync(contract.archivePath)), contract.archiveSha256);
|
|
1036
|
+
assert.deepEqual(contract.dryInventory, members);
|
|
1037
|
+
const inventory = members.map((item) => ({
|
|
1038
|
+
...item,
|
|
1039
|
+
sha256: consumerProof.sha256(readFileSync(join(f.cwd, item.path)))
|
|
1040
|
+
}));
|
|
1041
|
+
return {
|
|
1042
|
+
archiveSha256: contract.archiveSha256,
|
|
1043
|
+
sourceManifestSha256: contract.sourceManifestSha256,
|
|
1044
|
+
sourceLockSha256: contract.sourceLockSha256,
|
|
1045
|
+
archiveManifestSha256: contract.sourceManifestSha256,
|
|
1046
|
+
packageVersion: contract.packageVersion,
|
|
1047
|
+
inventorySha256: consumerProof.sha256(JSON.stringify(inventory)),
|
|
1048
|
+
inventory,
|
|
1049
|
+
skills: ["intake-create", "worktree-lifecycle", "pr-handoff"].map((path) => ({ path, sha256: "a".repeat(64) }))
|
|
533
1050
|
};
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
1051
|
+
};
|
|
1052
|
+
const produce = async ({ resultsDir, release, signal }) => {
|
|
1053
|
+
if (release) {
|
|
1054
|
+
releases++;
|
|
1055
|
+
order.push("release");
|
|
1056
|
+
mkdirSync(resultsDir);
|
|
1057
|
+
const observed = await releaseHook({ resultsDir, ...signal ? { signal } : {} });
|
|
1058
|
+
const cancelled = signal?.aborted === true;
|
|
1059
|
+
const report2 = {
|
|
1060
|
+
schemaVersion: "contributor-checks@1",
|
|
1061
|
+
runId: "fictional-release",
|
|
1062
|
+
scope: "release",
|
|
1063
|
+
status: cancelled ? "cancelled" : "passed",
|
|
1064
|
+
exitCode: cancelled ? 130 : 0,
|
|
1065
|
+
fullSuccess: false,
|
|
1066
|
+
artifactQualified: false,
|
|
1067
|
+
gates: ["tests"],
|
|
1068
|
+
omitted: ["PR producer and consumer"],
|
|
1069
|
+
resultsDir,
|
|
1070
|
+
tree: qualification.sourceIdentity(f.cwd).fingerprint,
|
|
1071
|
+
toolchain: f.toolchain,
|
|
1072
|
+
release: {
|
|
1073
|
+
...release,
|
|
1074
|
+
contractSha256: consumerProof.sha256(readFileSync(release.contractPath)),
|
|
1075
|
+
historicalInputSupplied: false,
|
|
1076
|
+
temporary: { path: join(resultsDir, "temporary"), dev: 1, ino: 1, quiescent: true, removed: true }
|
|
1077
|
+
},
|
|
1078
|
+
commands: [
|
|
1079
|
+
{
|
|
1080
|
+
stage: "tests",
|
|
1081
|
+
status: cancelled ? "cancelled" : "passed",
|
|
1082
|
+
exitCode: cancelled ? 130 : 0,
|
|
1083
|
+
signal: cancelled ? "SIGTERM" : null,
|
|
1084
|
+
cleanupConfirmed: true,
|
|
1085
|
+
...observed
|
|
1086
|
+
}
|
|
1087
|
+
],
|
|
1088
|
+
selectedTestFiles: [...new Set(checks.RELEASE_CASES.map((test2) => test2.file))],
|
|
1089
|
+
tests: {
|
|
1090
|
+
lane: "release",
|
|
1091
|
+
files: new Set(checks.RELEASE_CASES.map((test2) => test2.file)).size,
|
|
1092
|
+
total: checks.RELEASE_CASES.length,
|
|
1093
|
+
passed: checks.RELEASE_CASES.filter((test2) => test2.kind === "mandatory").length,
|
|
1094
|
+
skips: checks.RELEASE_CASES.filter((test2) => test2.kind !== "mandatory"),
|
|
1095
|
+
selectedCases: checks.RELEASE_CASES.map(({ file, title }) => ({ file, title })),
|
|
1096
|
+
laneExcluded: []
|
|
558
1097
|
}
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
sourceLockSha256: contract.sourceLockSha256,
|
|
594
|
-
archiveManifestSha256: contract.sourceManifestSha256,
|
|
595
|
-
archiveSha256: contract.archiveSha256,
|
|
596
|
-
packageVersion: contract.packageVersion,
|
|
597
|
-
inventorySha256: candidate.inventorySha256,
|
|
598
|
-
inventory: candidate.inventory,
|
|
599
|
-
producerJoin: consumerProof.verifyProducerJoin(contract, candidate),
|
|
600
|
-
cleanup: { quiescent: true, removed: true },
|
|
601
|
-
productionClosure: {},
|
|
602
|
-
mcp: {},
|
|
603
|
-
skills: candidate.skills,
|
|
604
|
-
resolutions: ['fictional owned resolution'],
|
|
605
|
-
phases: [
|
|
606
|
-
'node24',
|
|
607
|
-
'node26',
|
|
608
|
-
'npm',
|
|
609
|
-
'production-install',
|
|
610
|
-
'production-closure',
|
|
611
|
-
'cli-version',
|
|
612
|
-
'cli-json',
|
|
613
|
-
'exports-node24',
|
|
614
|
-
'library-node26',
|
|
615
|
-
'packaged-mcp',
|
|
616
|
-
].map((phase) => ({ phase, code: 0, signal: null, quiescent: true })),
|
|
617
|
-
};
|
|
1098
|
+
};
|
|
1099
|
+
writeFileSync(join(resultsDir, "result.json"), JSON.stringify(report2));
|
|
1100
|
+
return report2;
|
|
1101
|
+
}
|
|
1102
|
+
producers++;
|
|
1103
|
+
order.push("producer");
|
|
1104
|
+
mkdirSync(resultsDir);
|
|
1105
|
+
const report = {
|
|
1106
|
+
schemaVersion: "contributor-checks@1",
|
|
1107
|
+
runId: "fictional-one-producer",
|
|
1108
|
+
scope: "full",
|
|
1109
|
+
status: "passed",
|
|
1110
|
+
fullSuccess: true,
|
|
1111
|
+
exitCode: 0,
|
|
1112
|
+
gates: checks.FULL_GATES,
|
|
1113
|
+
omitted: [],
|
|
1114
|
+
tree: qualification.sourceIdentity(f.cwd).fingerprint,
|
|
1115
|
+
commands: checks.FULL_GATES.map((stage) => ({
|
|
1116
|
+
stage,
|
|
1117
|
+
status: "passed",
|
|
1118
|
+
exitCode: 0,
|
|
1119
|
+
signal: null,
|
|
1120
|
+
cleanupConfirmed: true
|
|
1121
|
+
})),
|
|
1122
|
+
tests: { files: 1, total: 1, passed: 1, skips: [] },
|
|
1123
|
+
selectedTestFiles: ["src/original.test.ts"],
|
|
1124
|
+
toolchain: f.toolchain,
|
|
1125
|
+
inventory: {
|
|
1126
|
+
kind: "dry-inventory-only",
|
|
1127
|
+
name: "@aviaratech/ai-delivery",
|
|
1128
|
+
version: "1.0.0",
|
|
1129
|
+
fileCount: members.length,
|
|
1130
|
+
files: members.map((item) => ({ ...item, sha256: consumerProof.sha256(readFileSync(join(f.cwd, item.path))) }))
|
|
1131
|
+
}
|
|
618
1132
|
};
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
1133
|
+
mutateProducer(report);
|
|
1134
|
+
writeFileSync(join(resultsDir, "result.json"), JSON.stringify(report));
|
|
1135
|
+
return report;
|
|
1136
|
+
};
|
|
1137
|
+
const execute = async (command, options2) => {
|
|
1138
|
+
if (command.at(-1) === "--authorize-install") {
|
|
1139
|
+
const contractPath = command[2];
|
|
1140
|
+
const resultPath = command[3];
|
|
1141
|
+
assert.ok(contractPath && resultPath, "Synthetic consumer requires contract and result paths.");
|
|
1142
|
+
const contract = JSON.parse(readFileSync(contractPath, "utf8"));
|
|
1143
|
+
const receipt = await consume(contract, { authorizeInstall: true });
|
|
1144
|
+
mkdirSync(options2.directory);
|
|
1145
|
+
const stdoutPath2 = join(options2.directory, "stdout.txt");
|
|
1146
|
+
const stderrPath2 = join(options2.directory, "stderr.txt");
|
|
1147
|
+
writeFileSync(stdoutPath2, "fictional supervised consumer");
|
|
1148
|
+
writeFileSync(stderrPath2, "");
|
|
1149
|
+
writeFileSync(resultPath, JSON.stringify(receipt));
|
|
1150
|
+
const result = {
|
|
1151
|
+
command,
|
|
1152
|
+
status: "passed",
|
|
1153
|
+
exitCode: 0,
|
|
1154
|
+
signal: null,
|
|
1155
|
+
stdoutPath: stdoutPath2,
|
|
1156
|
+
stderrPath: stderrPath2,
|
|
1157
|
+
cleanupConfirmed: true
|
|
1158
|
+
};
|
|
1159
|
+
options2.progress?.(result);
|
|
1160
|
+
return result;
|
|
1161
|
+
}
|
|
1162
|
+
packs++;
|
|
1163
|
+
order.push("pack");
|
|
1164
|
+
assert.deepEqual(command.slice(2, 5), ["pack", "--ignore-scripts", "--json"]);
|
|
1165
|
+
mkdirSync(options2.directory);
|
|
1166
|
+
const destination = command.at(-1);
|
|
1167
|
+
writeFileSync(join(destination, "fictional.tgz"), "fictional archive boundary");
|
|
1168
|
+
const stdoutPath = join(options2.directory, "stdout.txt");
|
|
1169
|
+
const stderrPath = join(options2.directory, "stderr.txt");
|
|
1170
|
+
writeFileSync(stdoutPath, JSON.stringify([{ filename: "fictional.tgz", files: members }]));
|
|
1171
|
+
writeFileSync(stderrPath, "");
|
|
1172
|
+
return {
|
|
1173
|
+
command,
|
|
1174
|
+
startedAt: "fictional",
|
|
1175
|
+
status: packStatus,
|
|
1176
|
+
exitCode: packStatus === "passed" ? 0 : 9,
|
|
1177
|
+
signal: null,
|
|
1178
|
+
stdoutPath,
|
|
1179
|
+
stderrPath,
|
|
1180
|
+
cleanupConfirmed: cleanup
|
|
625
1181
|
};
|
|
1182
|
+
};
|
|
1183
|
+
const consume = async (contract, options2) => {
|
|
1184
|
+
consumers++;
|
|
1185
|
+
order.push("consumer");
|
|
1186
|
+
assert.equal(options2.authorizeInstall, true);
|
|
1187
|
+
const candidate = inspect(contract);
|
|
626
1188
|
return {
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
1189
|
+
schemaVersion: "ai-delivery.current-consumer@1",
|
|
1190
|
+
boundary: "current-artifact",
|
|
1191
|
+
status: "passed",
|
|
1192
|
+
qualified: true,
|
|
1193
|
+
sourceIdentityVerified: true,
|
|
1194
|
+
scriptsDisabled: true,
|
|
1195
|
+
sourceCommit: contract.sourceCommit,
|
|
1196
|
+
sourceTree: contract.sourceTree,
|
|
1197
|
+
sourceManifestSha256: contract.sourceManifestSha256,
|
|
1198
|
+
sourceLockSha256: contract.sourceLockSha256,
|
|
1199
|
+
archiveManifestSha256: contract.sourceManifestSha256,
|
|
1200
|
+
archiveSha256: contract.archiveSha256,
|
|
1201
|
+
packageVersion: contract.packageVersion,
|
|
1202
|
+
inventorySha256: candidate.inventorySha256,
|
|
1203
|
+
inventory: candidate.inventory,
|
|
1204
|
+
producerJoin: consumerProof.verifyProducerJoin(contract, candidate),
|
|
1205
|
+
cleanup: { quiescent: true, removed: true },
|
|
1206
|
+
productionClosure: {},
|
|
1207
|
+
mcp: {},
|
|
1208
|
+
skills: candidate.skills,
|
|
1209
|
+
resolutions: ["fictional owned resolution"],
|
|
1210
|
+
phases: [
|
|
1211
|
+
"node24",
|
|
1212
|
+
"node26",
|
|
1213
|
+
"npm",
|
|
1214
|
+
"production-install",
|
|
1215
|
+
"production-closure",
|
|
1216
|
+
"cli-version",
|
|
1217
|
+
"cli-json",
|
|
1218
|
+
"exports-node24",
|
|
1219
|
+
"library-node26",
|
|
1220
|
+
"packaged-mcp"
|
|
1221
|
+
].map((phase) => ({ phase, code: 0, signal: null, quiescent: true }))
|
|
639
1222
|
};
|
|
640
|
-
}
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
|
|
1223
|
+
};
|
|
1224
|
+
const options = {
|
|
1225
|
+
cwd: f.cwd,
|
|
1226
|
+
resultsDir: join(f.base, "qualification"),
|
|
1227
|
+
checks: produce,
|
|
1228
|
+
execute,
|
|
1229
|
+
inspect
|
|
1230
|
+
};
|
|
1231
|
+
return {
|
|
1232
|
+
...f,
|
|
1233
|
+
options,
|
|
1234
|
+
inspect,
|
|
1235
|
+
consume,
|
|
1236
|
+
counts: () => ({ producers, packs, consumers }),
|
|
1237
|
+
releases: () => releases,
|
|
1238
|
+
order,
|
|
1239
|
+
releaseHook: (hook) => {
|
|
1240
|
+
releaseHook = hook;
|
|
1241
|
+
},
|
|
1242
|
+
mutate: (fn) => {
|
|
1243
|
+
mutateProducer = fn;
|
|
1244
|
+
},
|
|
1245
|
+
packFailure: (status, quiescent = true) => {
|
|
1246
|
+
packStatus = status;
|
|
1247
|
+
cleanup = quiescent;
|
|
664
1248
|
}
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
test("qualification checkpoints one producer and pack, resumes without replay, and retains immutable digests", async () => {
|
|
1252
|
+
const f = qualificationFixture();
|
|
1253
|
+
try {
|
|
1254
|
+
const report = await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1255
|
+
assert.equal(report.status, "incomplete");
|
|
1256
|
+
assert.equal(report.qualified, false);
|
|
1257
|
+
assert.equal(report.exitCode, 2);
|
|
1258
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 0 });
|
|
1259
|
+
const checkpoint = join(f.options.resultsDir, "checkpoint.json");
|
|
1260
|
+
const producer = readFileSync(join(f.options.resultsDir, "producer/result.json"));
|
|
1261
|
+
const resumed = await qualification.runQualification({
|
|
1262
|
+
...f.options,
|
|
1263
|
+
resume: checkpoint,
|
|
1264
|
+
resultsDir: join(f.base, "resumed")
|
|
1265
|
+
});
|
|
1266
|
+
assert.equal(resumed.qualified, true);
|
|
1267
|
+
assert.equal(resumed.exitCode, 0);
|
|
1268
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 1 });
|
|
1269
|
+
assert.deepEqual(readFileSync(join(f.options.resultsDir, "producer/result.json")), producer);
|
|
1270
|
+
await assert.rejects(
|
|
1271
|
+
qualification.runQualification({ ...f.options, resume: checkpoint, resultsDir: join(f.base, "resumed") }),
|
|
1272
|
+
/Existing overall result/u
|
|
1273
|
+
);
|
|
1274
|
+
} finally {
|
|
1275
|
+
f.cleanup();
|
|
1276
|
+
}
|
|
665
1277
|
});
|
|
666
|
-
test(
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
1278
|
+
test("qualification joins producer pack release tests and consumer in order", async () => {
|
|
1279
|
+
const f = qualificationFixture();
|
|
1280
|
+
try {
|
|
1281
|
+
const report = await qualification.runQualification(f.options);
|
|
1282
|
+
assert.equal(report.qualified, true);
|
|
1283
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 1 });
|
|
1284
|
+
assert.equal(f.releases(), 1);
|
|
1285
|
+
assert.deepEqual(f.order, ["producer", "pack", "release", "consumer"]);
|
|
1286
|
+
assert.ok(report.releaseTests);
|
|
1287
|
+
} finally {
|
|
1288
|
+
f.cleanup();
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
test("producer-only omits release and consumer proof", async () => {
|
|
1292
|
+
const f = qualificationFixture();
|
|
1293
|
+
try {
|
|
1294
|
+
const report = await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1295
|
+
assert.equal(f.releases(), 0);
|
|
1296
|
+
assert.match(report.omitted.join(" "), /release/u);
|
|
1297
|
+
assert.equal(report.releaseTests, void 0);
|
|
1298
|
+
} finally {
|
|
1299
|
+
f.cleanup();
|
|
1300
|
+
}
|
|
1301
|
+
});
|
|
1302
|
+
test("resume reuses compatible completed release proof", async () => {
|
|
1303
|
+
const f = qualificationFixture();
|
|
1304
|
+
try {
|
|
1305
|
+
const first = await qualification.runQualification(f.options);
|
|
1306
|
+
assert.ok(first.releaseTests);
|
|
1307
|
+
const original = readFileSync(first.releaseTests.path);
|
|
1308
|
+
const resumed = await qualification.runQualification({
|
|
1309
|
+
...f.options,
|
|
1310
|
+
resume: join(f.options.resultsDir, "checkpoint.json"),
|
|
1311
|
+
resultsDir: join(f.base, "outer-reuse")
|
|
1312
|
+
});
|
|
1313
|
+
assert.equal(resumed.qualified, true, resumed.error);
|
|
1314
|
+
assert.deepEqual(resumed.releaseTests, first.releaseTests);
|
|
1315
|
+
assert.deepEqual(readFileSync(first.releaseTests.path), original);
|
|
1316
|
+
assert.equal(f.releases(), 1);
|
|
1317
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 1 });
|
|
1318
|
+
} finally {
|
|
1319
|
+
f.cleanup();
|
|
1320
|
+
}
|
|
676
1321
|
});
|
|
677
|
-
test(
|
|
1322
|
+
test("uncertain release attempt blocks a duplicate launch through fresh outer results", async () => {
|
|
1323
|
+
const f = qualificationFixture();
|
|
1324
|
+
try {
|
|
1325
|
+
await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1326
|
+
f.releaseHook(async () => {
|
|
1327
|
+
throw new Error("fictional lost release response");
|
|
1328
|
+
});
|
|
1329
|
+
const resume = join(f.options.resultsDir, "checkpoint.json");
|
|
1330
|
+
const first = await qualification.runQualification({
|
|
1331
|
+
...f.options,
|
|
1332
|
+
resume,
|
|
1333
|
+
resultsDir: join(f.base, "release-lost")
|
|
1334
|
+
});
|
|
1335
|
+
assert.match(first.error, /lost release/u);
|
|
1336
|
+
const second = await qualification.runQualification({
|
|
1337
|
+
...f.options,
|
|
1338
|
+
resume,
|
|
1339
|
+
resultsDir: join(f.base, "release-uncertain")
|
|
1340
|
+
});
|
|
1341
|
+
assert.match(second.error, /Unresolved release/u);
|
|
1342
|
+
assert.equal(f.releases(), 1);
|
|
1343
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 0 });
|
|
1344
|
+
} finally {
|
|
1345
|
+
f.cleanup();
|
|
1346
|
+
}
|
|
1347
|
+
});
|
|
1348
|
+
test(
|
|
1349
|
+
"interrupted release retry preserves prior evidence and skips completed producer and pack",
|
|
1350
|
+
{ tags: ["release"] },
|
|
1351
|
+
async () => {
|
|
678
1352
|
const f = qualificationFixture();
|
|
679
1353
|
try {
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
for (const change of ['bytes', 'missing-digest']) {
|
|
695
|
-
const f = qualificationFixture();
|
|
696
|
-
try {
|
|
697
|
-
if (change === 'missing-digest')
|
|
698
|
-
f.mutate((report) => {
|
|
699
|
-
const inventory = report.inventory;
|
|
700
|
-
const first = inventory.files[0];
|
|
701
|
-
assert.ok(first, 'Synthetic producer inventory must contain a member.');
|
|
702
|
-
delete first.sha256;
|
|
703
|
-
});
|
|
704
|
-
const produced = await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
705
|
-
if (change === 'bytes') {
|
|
706
|
-
assert.equal(produced.status, 'incomplete');
|
|
707
|
-
writeFileSync(join(f.cwd, 'dist/generated.js'), 'replaced');
|
|
708
|
-
const resumed = await qualification.runQualification({
|
|
709
|
-
...f.options,
|
|
710
|
-
resume: join(f.options.resultsDir, 'checkpoint.json'),
|
|
711
|
-
resultsDir: join(f.base, 'changed-bytes'),
|
|
712
|
-
});
|
|
713
|
-
assert.match(resumed.error, /Archive bytes differ|freshness join is incomplete/u);
|
|
1354
|
+
await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1355
|
+
const controller = new AbortController();
|
|
1356
|
+
const sentinel = join(f.base, "unrelated");
|
|
1357
|
+
writeFileSync(sentinel, "preserve");
|
|
1358
|
+
f.releaseHook(
|
|
1359
|
+
async ({ resultsDir, signal }) => checks.executeCommand(
|
|
1360
|
+
[process.execPath, "-e", "console.log('controlled release started');setInterval(()=>{},1000)"],
|
|
1361
|
+
{
|
|
1362
|
+
cwd: f.cwd,
|
|
1363
|
+
env: checks.safeEnvironment({}),
|
|
1364
|
+
directory: join(resultsDir, "tests"),
|
|
1365
|
+
...signal ? { signal } : {},
|
|
1366
|
+
progress: (partial) => {
|
|
1367
|
+
if (partial.observedProcesses?.length) controller.abort();
|
|
714
1368
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
1369
|
+
}
|
|
1370
|
+
)
|
|
1371
|
+
);
|
|
1372
|
+
const resume = join(f.options.resultsDir, "checkpoint.json");
|
|
1373
|
+
const interrupted = await qualification.runQualification({
|
|
1374
|
+
...f.options,
|
|
1375
|
+
resume,
|
|
1376
|
+
signal: controller.signal,
|
|
1377
|
+
resultsDir: join(f.base, "release-interrupted")
|
|
1378
|
+
});
|
|
1379
|
+
assert.equal(interrupted.status, "cancelled");
|
|
1380
|
+
const attemptPath = join(f.options.resultsDir, "release-tests-attempt.json");
|
|
1381
|
+
const old = readFileSync(attemptPath);
|
|
1382
|
+
const prior = JSON.parse(old.toString());
|
|
1383
|
+
assert.equal(prior.command.cleanupConfirmed, true);
|
|
1384
|
+
assert.ok(prior.command.observedProcesses?.length);
|
|
1385
|
+
const receipt = readFileSync(prior.receipt.path);
|
|
1386
|
+
f.releaseHook(async () => {
|
|
1387
|
+
});
|
|
1388
|
+
const retried = await qualification.runQualification({
|
|
1389
|
+
...f.options,
|
|
1390
|
+
resume,
|
|
1391
|
+
resultsDir: join(f.base, "release-retry")
|
|
1392
|
+
});
|
|
1393
|
+
assert.equal(retried.qualified, true, retried.error);
|
|
1394
|
+
assert.deepEqual(readFileSync(join(prior.directory, "retired-attempt.json")), old);
|
|
1395
|
+
assert.deepEqual(readFileSync(prior.receipt.path), receipt);
|
|
1396
|
+
assert.equal(readFileSync(sentinel, "utf8"), "preserve");
|
|
1397
|
+
assert.equal(f.releases(), 2);
|
|
1398
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 1 });
|
|
1399
|
+
const uninterrupted = qualificationFixture();
|
|
1400
|
+
try {
|
|
1401
|
+
assert.equal((await qualification.runQualification(uninterrupted.options)).qualified, true);
|
|
1402
|
+
assert.deepEqual(uninterrupted.order, ["producer", "pack", "release", "consumer"]);
|
|
1403
|
+
} finally {
|
|
1404
|
+
uninterrupted.cleanup();
|
|
1405
|
+
}
|
|
1406
|
+
} finally {
|
|
1407
|
+
f.cleanup();
|
|
722
1408
|
}
|
|
1409
|
+
}
|
|
1410
|
+
);
|
|
1411
|
+
test("two competing resumes release at most one checkpoint-owned test child", { tags: ["release"] }, async () => {
|
|
1412
|
+
const f = qualificationFixture();
|
|
1413
|
+
try {
|
|
1414
|
+
await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1415
|
+
let started, complete;
|
|
1416
|
+
const start = new Promise((resolve) => {
|
|
1417
|
+
started = resolve;
|
|
1418
|
+
});
|
|
1419
|
+
const gate = new Promise((resolve) => {
|
|
1420
|
+
complete = resolve;
|
|
1421
|
+
});
|
|
1422
|
+
f.releaseHook(async () => {
|
|
1423
|
+
started();
|
|
1424
|
+
await gate;
|
|
1425
|
+
});
|
|
1426
|
+
const resume = join(f.options.resultsDir, "checkpoint.json");
|
|
1427
|
+
const first = qualification.runQualification({ ...f.options, resume, resultsDir: join(f.base, "race-a") });
|
|
1428
|
+
await Promise.race([
|
|
1429
|
+
start,
|
|
1430
|
+
first.then(() => {
|
|
1431
|
+
throw new Error("Release stage never started.");
|
|
1432
|
+
})
|
|
1433
|
+
]);
|
|
1434
|
+
const second = await qualification.runQualification({ ...f.options, resume, resultsDir: join(f.base, "race-b") });
|
|
1435
|
+
complete();
|
|
1436
|
+
assert.equal((await first).qualified, true);
|
|
1437
|
+
assert.match(second.error, /Unresolved release/u);
|
|
1438
|
+
assert.equal(f.releases(), 1);
|
|
1439
|
+
} finally {
|
|
1440
|
+
f.cleanup();
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
test("producer byte inventory rejects a same-length ignored build change before consumer launch", async () => {
|
|
1444
|
+
const f = qualificationFixture();
|
|
1445
|
+
try {
|
|
1446
|
+
const before = qualification.sourceIdentity(f.cwd).fingerprint;
|
|
1447
|
+
f.mutate(() => writeFileSync(join(f.cwd, "dist/generated.js"), "replaced"));
|
|
1448
|
+
const report = await qualification.runQualification(f.options);
|
|
1449
|
+
assert.deepEqual(qualification.sourceIdentity(f.cwd).fingerprint, before);
|
|
1450
|
+
assert.equal(report.qualified, false);
|
|
1451
|
+
assert.match(report.error, /Archive bytes differ from the successful producer/u);
|
|
1452
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 0 });
|
|
1453
|
+
assert.equal(existsSync(join(f.options.resultsDir, "checkpoint.json")), false);
|
|
1454
|
+
} finally {
|
|
1455
|
+
f.cleanup();
|
|
1456
|
+
}
|
|
723
1457
|
});
|
|
724
|
-
test(
|
|
1458
|
+
test("resume rejects changed generated bytes and missing retained producer member hashes", async () => {
|
|
1459
|
+
for (const change of ["bytes", "missing-digest"]) {
|
|
725
1460
|
const f = qualificationFixture();
|
|
726
1461
|
try {
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
...options,
|
|
734
|
-
progress: (partial) => {
|
|
735
|
-
options.progress?.(partial);
|
|
736
|
-
if (partial.observedProcesses?.length)
|
|
737
|
-
controller.abort();
|
|
738
|
-
},
|
|
739
|
-
});
|
|
740
|
-
};
|
|
741
|
-
const resume = join(f.options.resultsDir, 'checkpoint.json');
|
|
742
|
-
const report = await qualification.runQualification({
|
|
743
|
-
...f.options,
|
|
744
|
-
execute,
|
|
745
|
-
resume,
|
|
746
|
-
signal: controller.signal,
|
|
747
|
-
resultsDir: join(f.base, 'cancelled-consumer'),
|
|
1462
|
+
if (change === "missing-digest")
|
|
1463
|
+
f.mutate((report) => {
|
|
1464
|
+
const inventory = report.inventory;
|
|
1465
|
+
const first = inventory.files[0];
|
|
1466
|
+
assert.ok(first, "Synthetic producer inventory must contain a member.");
|
|
1467
|
+
delete first.sha256;
|
|
748
1468
|
});
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
assert.equal(
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
...f.options,
|
|
758
|
-
execute,
|
|
759
|
-
resume,
|
|
760
|
-
resultsDir: join(f.base, 'blocked-retry'),
|
|
1469
|
+
const produced = await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1470
|
+
if (change === "bytes") {
|
|
1471
|
+
assert.equal(produced.status, "incomplete");
|
|
1472
|
+
writeFileSync(join(f.cwd, "dist/generated.js"), "replaced");
|
|
1473
|
+
const resumed = await qualification.runQualification({
|
|
1474
|
+
...f.options,
|
|
1475
|
+
resume: join(f.options.resultsDir, "checkpoint.json"),
|
|
1476
|
+
resultsDir: join(f.base, "changed-bytes")
|
|
761
1477
|
});
|
|
762
|
-
assert.
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
}
|
|
766
|
-
|
|
767
|
-
f.cleanup();
|
|
1478
|
+
assert.match(resumed.error, /Archive bytes differ|freshness join is incomplete/u);
|
|
1479
|
+
} else assert.equal(produced.status, "failed");
|
|
1480
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 0 });
|
|
1481
|
+
} finally {
|
|
1482
|
+
f.cleanup();
|
|
768
1483
|
}
|
|
1484
|
+
}
|
|
769
1485
|
});
|
|
770
|
-
test(
|
|
1486
|
+
test(
|
|
1487
|
+
"consumer cancellation retains actual PID/birth and logs, and resume cannot duplicate it",
|
|
1488
|
+
{ tags: ["release"] },
|
|
1489
|
+
async () => {
|
|
771
1490
|
const f = qualificationFixture();
|
|
772
1491
|
try {
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
execute,
|
|
816
|
-
resume,
|
|
817
|
-
reconcileConsumer: true,
|
|
818
|
-
resultsDir: join(f.base, 'reconciled'),
|
|
819
|
-
});
|
|
820
|
-
assert.equal(reconciled.qualified, true);
|
|
821
|
-
assert.equal(launches, 1);
|
|
822
|
-
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 1 });
|
|
823
|
-
assert.equal(JSON.parse(readFileSync(attemptPath, 'utf8')).status, 'reconciled');
|
|
1492
|
+
await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1493
|
+
const controller = new AbortController();
|
|
1494
|
+
let launches = 0;
|
|
1495
|
+
const execute = async (_command, options) => {
|
|
1496
|
+
launches++;
|
|
1497
|
+
return checks.executeCommand(
|
|
1498
|
+
[process.execPath, "-e", "console.log('fictional consumer started');setInterval(()=>{},1000)"],
|
|
1499
|
+
{
|
|
1500
|
+
...options,
|
|
1501
|
+
progress: (partial) => {
|
|
1502
|
+
options.progress?.(partial);
|
|
1503
|
+
if (partial.observedProcesses?.length) controller.abort();
|
|
1504
|
+
}
|
|
1505
|
+
}
|
|
1506
|
+
);
|
|
1507
|
+
};
|
|
1508
|
+
const resume = join(f.options.resultsDir, "checkpoint.json");
|
|
1509
|
+
const report = await qualification.runQualification({
|
|
1510
|
+
...f.options,
|
|
1511
|
+
execute,
|
|
1512
|
+
resume,
|
|
1513
|
+
signal: controller.signal,
|
|
1514
|
+
resultsDir: join(f.base, "cancelled-consumer")
|
|
1515
|
+
});
|
|
1516
|
+
assert.equal(report.status, "cancelled");
|
|
1517
|
+
const attempt = JSON.parse(readFileSync(join(f.options.resultsDir, "consumer-attempt.json"), "utf8"));
|
|
1518
|
+
assert.equal(attempt.status, "completed");
|
|
1519
|
+
assert.equal(attempt.command.status, "cancelled");
|
|
1520
|
+
assert.equal(attempt.command.cleanupConfirmed, true);
|
|
1521
|
+
assert.ok(attempt.command.observedProcesses.every((row) => row.birth.length > 0));
|
|
1522
|
+
assert.ok(existsSync(attempt.tempRoot));
|
|
1523
|
+
const retried = await qualification.runQualification({
|
|
1524
|
+
...f.options,
|
|
1525
|
+
execute,
|
|
1526
|
+
resume,
|
|
1527
|
+
resultsDir: join(f.base, "blocked-retry")
|
|
1528
|
+
});
|
|
1529
|
+
assert.equal(retried.qualified, false);
|
|
1530
|
+
assert.equal(launches, 1);
|
|
1531
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 0 });
|
|
1532
|
+
} finally {
|
|
1533
|
+
f.cleanup();
|
|
824
1534
|
}
|
|
825
|
-
|
|
826
|
-
|
|
1535
|
+
}
|
|
1536
|
+
);
|
|
1537
|
+
test(
|
|
1538
|
+
"lost consumer completion retains a reservation, blocks duplicate launch and reconciles without producer or pack replay",
|
|
1539
|
+
{ tags: ["release"] },
|
|
1540
|
+
async () => {
|
|
1541
|
+
const f = qualificationFixture();
|
|
1542
|
+
try {
|
|
1543
|
+
await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1544
|
+
const resume = join(f.options.resultsDir, "checkpoint.json");
|
|
1545
|
+
const contract = JSON.parse(
|
|
1546
|
+
readFileSync(join(f.options.resultsDir, "contract.json"), "utf8")
|
|
1547
|
+
);
|
|
1548
|
+
const fictionalReceipt = await f.consume(contract, { authorizeInstall: true });
|
|
1549
|
+
let launches = 0;
|
|
1550
|
+
const execute = async (command, options) => {
|
|
1551
|
+
launches++;
|
|
1552
|
+
const resultPath = command[3];
|
|
1553
|
+
assert.ok(resultPath, "Synthetic consumer requires a result path.");
|
|
1554
|
+
const code = "const fs=require('node:fs');setTimeout(()=>fs.writeFileSync(process.argv[1],process.argv[2]),200)";
|
|
1555
|
+
const completed = await checks.executeCommand(
|
|
1556
|
+
[process.execPath, "-e", code, resultPath, JSON.stringify(fictionalReceipt)],
|
|
1557
|
+
{
|
|
1558
|
+
...options,
|
|
1559
|
+
progress: (partial) => {
|
|
1560
|
+
if (!partial.completedAt) options.progress?.(partial);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
);
|
|
1564
|
+
assert.equal(completed.cleanupConfirmed, true);
|
|
1565
|
+
throw new Error("fictional controller lost terminal consumer response");
|
|
1566
|
+
};
|
|
1567
|
+
const lost = await qualification.runQualification({
|
|
1568
|
+
...f.options,
|
|
1569
|
+
execute,
|
|
1570
|
+
resume,
|
|
1571
|
+
resultsDir: join(f.base, "lost-response")
|
|
1572
|
+
});
|
|
1573
|
+
assert.equal(lost.qualified, false);
|
|
1574
|
+
const attemptPath = join(f.options.resultsDir, "consumer-attempt.json");
|
|
1575
|
+
const attempt = JSON.parse(readFileSync(attemptPath, "utf8"));
|
|
1576
|
+
assert.equal(attempt.status, "running");
|
|
1577
|
+
assert.ok(attempt.command.observedProcesses.length > 0);
|
|
1578
|
+
const blocked = await qualification.runQualification({
|
|
1579
|
+
...f.options,
|
|
1580
|
+
execute,
|
|
1581
|
+
resume,
|
|
1582
|
+
resultsDir: join(f.base, "unreconciled")
|
|
1583
|
+
});
|
|
1584
|
+
assert.match(blocked.error, /Unresolved consumer attempt/u);
|
|
1585
|
+
const reconciled = await qualification.runQualification({
|
|
1586
|
+
...f.options,
|
|
1587
|
+
execute,
|
|
1588
|
+
resume,
|
|
1589
|
+
reconcileConsumer: true,
|
|
1590
|
+
resultsDir: join(f.base, "reconciled")
|
|
1591
|
+
});
|
|
1592
|
+
assert.equal(reconciled.qualified, true);
|
|
1593
|
+
assert.equal(launches, 1);
|
|
1594
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 1 });
|
|
1595
|
+
assert.equal(JSON.parse(readFileSync(attemptPath, "utf8")).status, "reconciled");
|
|
1596
|
+
} finally {
|
|
1597
|
+
f.cleanup();
|
|
827
1598
|
}
|
|
828
|
-
}
|
|
829
|
-
|
|
1599
|
+
}
|
|
1600
|
+
);
|
|
1601
|
+
test(
|
|
1602
|
+
"reservation before launch survives an uncertain spawn and refuses automatic retry",
|
|
1603
|
+
{ tags: ["release"] },
|
|
1604
|
+
async () => {
|
|
830
1605
|
const f = qualificationFixture();
|
|
831
1606
|
try {
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
1607
|
+
await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1608
|
+
let launches = 0;
|
|
1609
|
+
const execute = async () => {
|
|
1610
|
+
launches++;
|
|
1611
|
+
throw new Error("fictional spawn response unknown");
|
|
1612
|
+
};
|
|
1613
|
+
const resume = join(f.options.resultsDir, "checkpoint.json");
|
|
1614
|
+
await qualification.runQualification({
|
|
1615
|
+
...f.options,
|
|
1616
|
+
execute,
|
|
1617
|
+
resume,
|
|
1618
|
+
resultsDir: join(f.base, "uncertain-launch")
|
|
1619
|
+
});
|
|
1620
|
+
const blocked = await qualification.runQualification({
|
|
1621
|
+
...f.options,
|
|
1622
|
+
execute,
|
|
1623
|
+
resume,
|
|
1624
|
+
reconcileConsumer: true,
|
|
1625
|
+
resultsDir: join(f.base, "uncertain-retry")
|
|
1626
|
+
});
|
|
1627
|
+
assert.match(blocked.error, /launch identity is unavailable/u);
|
|
1628
|
+
assert.equal(launches, 1);
|
|
1629
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 0 });
|
|
1630
|
+
} finally {
|
|
1631
|
+
f.cleanup();
|
|
855
1632
|
}
|
|
856
|
-
|
|
857
|
-
|
|
1633
|
+
}
|
|
1634
|
+
);
|
|
1635
|
+
for (const mutation of ["zero-selection", "counts", "skip", "inventory", "command-cleanup", "ordered-gates"]) {
|
|
1636
|
+
test(`qualification rejects ${mutation} producer proof without installation`, async () => {
|
|
1637
|
+
const f = qualificationFixture();
|
|
1638
|
+
try {
|
|
1639
|
+
f.mutate((report2) => {
|
|
1640
|
+
if (mutation === "zero-selection") report2.selectedTestFiles = [];
|
|
1641
|
+
if (mutation === "counts") report2.tests = { files: 1, total: 99, passed: 1, skips: [] };
|
|
1642
|
+
if (mutation === "skip")
|
|
1643
|
+
report2.tests = {
|
|
1644
|
+
files: 1,
|
|
1645
|
+
total: 2,
|
|
1646
|
+
passed: 1,
|
|
1647
|
+
skips: [{ file: "dist/original.test.js", title: "unreviewed", kind: "arbitrary" }]
|
|
1648
|
+
};
|
|
1649
|
+
if (mutation === "inventory")
|
|
1650
|
+
report2.inventory = {
|
|
1651
|
+
kind: "dry-inventory-only",
|
|
1652
|
+
name: "@aviaratech/ai-delivery",
|
|
1653
|
+
version: "1.0.0",
|
|
1654
|
+
fileCount: 0,
|
|
1655
|
+
files: []
|
|
1656
|
+
};
|
|
1657
|
+
if (mutation === "command-cleanup")
|
|
1658
|
+
report2.commands = checks.FULL_GATES.map((stage) => ({
|
|
1659
|
+
stage,
|
|
1660
|
+
status: "passed",
|
|
1661
|
+
exitCode: 0,
|
|
1662
|
+
signal: null,
|
|
1663
|
+
cleanupConfirmed: false
|
|
1664
|
+
}));
|
|
1665
|
+
if (mutation === "ordered-gates") report2.gates = [...checks.FULL_GATES].reverse();
|
|
1666
|
+
});
|
|
1667
|
+
const report = await qualification.runQualification(f.options);
|
|
1668
|
+
assert.equal(report.qualified, false);
|
|
1669
|
+
assert.equal(report.status, "failed");
|
|
1670
|
+
assert.equal(f.counts().consumers, 0);
|
|
1671
|
+
} finally {
|
|
1672
|
+
f.cleanup();
|
|
858
1673
|
}
|
|
859
|
-
});
|
|
860
|
-
for (const mutation of ['zero-selection', 'counts', 'skip', 'inventory', 'command-cleanup', 'ordered-gates']) {
|
|
861
|
-
test(`qualification rejects ${mutation} producer proof without installation`, async () => {
|
|
862
|
-
const f = qualificationFixture();
|
|
863
|
-
try {
|
|
864
|
-
f.mutate((report) => {
|
|
865
|
-
if (mutation === 'zero-selection')
|
|
866
|
-
report.selectedTestFiles = [];
|
|
867
|
-
if (mutation === 'counts')
|
|
868
|
-
report.tests = { files: 1, total: 99, passed: 1, skips: [] };
|
|
869
|
-
if (mutation === 'skip')
|
|
870
|
-
report.tests = {
|
|
871
|
-
files: 1,
|
|
872
|
-
total: 2,
|
|
873
|
-
passed: 1,
|
|
874
|
-
skips: [{ file: 'dist/original.test.js', title: 'unreviewed', kind: 'arbitrary' }],
|
|
875
|
-
};
|
|
876
|
-
if (mutation === 'inventory')
|
|
877
|
-
report.inventory = {
|
|
878
|
-
kind: 'dry-inventory-only',
|
|
879
|
-
name: '@aviaratech/ai-delivery',
|
|
880
|
-
version: '1.0.0',
|
|
881
|
-
fileCount: 0,
|
|
882
|
-
files: [],
|
|
883
|
-
};
|
|
884
|
-
if (mutation === 'command-cleanup')
|
|
885
|
-
report.commands = checks.FULL_GATES.map((stage) => ({
|
|
886
|
-
stage,
|
|
887
|
-
status: 'passed',
|
|
888
|
-
exitCode: 0,
|
|
889
|
-
signal: null,
|
|
890
|
-
cleanupConfirmed: false,
|
|
891
|
-
}));
|
|
892
|
-
if (mutation === 'ordered-gates')
|
|
893
|
-
report.gates = [...checks.FULL_GATES].reverse();
|
|
894
|
-
});
|
|
895
|
-
const report = await qualification.runQualification(f.options);
|
|
896
|
-
assert.equal(report.qualified, false);
|
|
897
|
-
assert.equal(report.status, 'failed');
|
|
898
|
-
assert.equal(f.counts().consumers, 0);
|
|
899
|
-
}
|
|
900
|
-
finally {
|
|
901
|
-
f.cleanup();
|
|
902
|
-
}
|
|
903
|
-
});
|
|
904
|
-
}
|
|
905
|
-
for (const mutation of ['wrong-head', 'producer-digest', 'archive-digest', 'contract-digest']) {
|
|
906
|
-
test(`resume rejects ${mutation} without replaying any process`, async () => {
|
|
907
|
-
const f = qualificationFixture();
|
|
908
|
-
try {
|
|
909
|
-
await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
910
|
-
const checkpoint = join(f.options.resultsDir, 'checkpoint.json');
|
|
911
|
-
if (mutation === 'wrong-head')
|
|
912
|
-
execFileSync('git', [
|
|
913
|
-
'-c',
|
|
914
|
-
'user.name=Fictional fixture',
|
|
915
|
-
'-c',
|
|
916
|
-
'user.email=fixture@example.invalid',
|
|
917
|
-
'-c',
|
|
918
|
-
'core.hooksPath=/dev/null',
|
|
919
|
-
'commit',
|
|
920
|
-
'--allow-empty',
|
|
921
|
-
'-qm',
|
|
922
|
-
'different head same tree',
|
|
923
|
-
], { cwd: f.cwd });
|
|
924
|
-
if (mutation === 'producer-digest')
|
|
925
|
-
writeFileSync(join(f.options.resultsDir, 'producer/result.json'), '{}');
|
|
926
|
-
if (mutation === 'archive-digest')
|
|
927
|
-
writeFileSync(join(f.options.resultsDir, 'pack/fictional.tgz'), 'changed');
|
|
928
|
-
if (mutation === 'contract-digest') {
|
|
929
|
-
const value = JSON.parse(readFileSync(checkpoint, 'utf8'));
|
|
930
|
-
value.contractSha256 = '0'.repeat(64);
|
|
931
|
-
writeFileSync(checkpoint, JSON.stringify(value));
|
|
932
|
-
}
|
|
933
|
-
const resumed = await qualification.runQualification({
|
|
934
|
-
...f.options,
|
|
935
|
-
resume: checkpoint,
|
|
936
|
-
resultsDir: join(f.base, 'resume-bad'),
|
|
937
|
-
});
|
|
938
|
-
assert.equal(resumed.status, 'failed');
|
|
939
|
-
assert.equal(resumed.qualified, false);
|
|
940
|
-
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 0 });
|
|
941
|
-
}
|
|
942
|
-
finally {
|
|
943
|
-
f.cleanup();
|
|
944
|
-
}
|
|
945
|
-
});
|
|
1674
|
+
});
|
|
946
1675
|
}
|
|
947
|
-
|
|
1676
|
+
for (const mutation of ["wrong-head", "producer-digest", "archive-digest", "contract-digest"]) {
|
|
1677
|
+
test(`resume rejects ${mutation} without replaying any process`, async () => {
|
|
948
1678
|
const f = qualificationFixture();
|
|
949
1679
|
try {
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
1680
|
+
await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1681
|
+
const checkpoint = join(f.options.resultsDir, "checkpoint.json");
|
|
1682
|
+
if (mutation === "wrong-head")
|
|
1683
|
+
execFileSync(
|
|
1684
|
+
"git",
|
|
1685
|
+
[
|
|
1686
|
+
"-c",
|
|
1687
|
+
"user.name=Fictional fixture",
|
|
1688
|
+
"-c",
|
|
1689
|
+
"user.email=fixture@example.invalid",
|
|
1690
|
+
"-c",
|
|
1691
|
+
"core.hooksPath=/dev/null",
|
|
1692
|
+
"commit",
|
|
1693
|
+
"--allow-empty",
|
|
1694
|
+
"-qm",
|
|
1695
|
+
"different head same tree"
|
|
1696
|
+
],
|
|
1697
|
+
{ cwd: f.cwd }
|
|
1698
|
+
);
|
|
1699
|
+
if (mutation === "producer-digest") writeFileSync(join(f.options.resultsDir, "producer/result.json"), "{}");
|
|
1700
|
+
if (mutation === "archive-digest") writeFileSync(join(f.options.resultsDir, "pack/fictional.tgz"), "changed");
|
|
1701
|
+
if (mutation === "contract-digest") {
|
|
1702
|
+
const value = JSON.parse(readFileSync(checkpoint, "utf8"));
|
|
1703
|
+
value.contractSha256 = "0".repeat(64);
|
|
1704
|
+
writeFileSync(checkpoint, JSON.stringify(value));
|
|
1705
|
+
}
|
|
1706
|
+
const resumed = await qualification.runQualification({
|
|
1707
|
+
...f.options,
|
|
1708
|
+
resume: checkpoint,
|
|
1709
|
+
resultsDir: join(f.base, "resume-bad")
|
|
1710
|
+
});
|
|
1711
|
+
assert.equal(resumed.status, "failed");
|
|
1712
|
+
assert.equal(resumed.qualified, false);
|
|
1713
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 0 });
|
|
1714
|
+
} finally {
|
|
1715
|
+
f.cleanup();
|
|
977
1716
|
}
|
|
978
|
-
});
|
|
979
|
-
for (const status of ['failed', 'timed-out', 'cancelled', 'cleanup-unconfirmed']) {
|
|
980
|
-
test(`actual pack ${status} cannot produce a successful checkpoint`, async () => {
|
|
981
|
-
const f = qualificationFixture();
|
|
982
|
-
try {
|
|
983
|
-
f.packFailure(status === 'cleanup-unconfirmed' ? 'passed' : status, status !== 'cleanup-unconfirmed');
|
|
984
|
-
const report = await qualification.runQualification(f.options);
|
|
985
|
-
assert.equal(report.qualified, false);
|
|
986
|
-
assert.equal(existsSync(join(f.options.resultsDir, 'checkpoint.json')), false);
|
|
987
|
-
assert.equal(f.counts().consumers, 0);
|
|
988
|
-
}
|
|
989
|
-
finally {
|
|
990
|
-
f.cleanup();
|
|
991
|
-
}
|
|
992
|
-
});
|
|
1717
|
+
});
|
|
993
1718
|
}
|
|
994
|
-
test(
|
|
1719
|
+
test(
|
|
1720
|
+
"external consumer join never installs twice and rejects unconfirmed owned removal",
|
|
1721
|
+
{ tags: ["release"] },
|
|
1722
|
+
async () => {
|
|
995
1723
|
const f = qualificationFixture();
|
|
996
1724
|
try {
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1725
|
+
await qualification.runQualification({ ...f.options, producerOnly: true });
|
|
1726
|
+
const contract = JSON.parse(
|
|
1727
|
+
readFileSync(join(f.options.resultsDir, "contract.json"), "utf8")
|
|
1728
|
+
);
|
|
1729
|
+
const receipt = await f.consume(contract, { authorizeInstall: true });
|
|
1730
|
+
const consumerResult = join(f.base, "external-consumer.json");
|
|
1731
|
+
writeFileSync(consumerResult, JSON.stringify(receipt));
|
|
1732
|
+
const resume = join(f.options.resultsDir, "checkpoint.json");
|
|
1733
|
+
const joined = await qualification.runQualification({
|
|
1734
|
+
...f.options,
|
|
1735
|
+
resume,
|
|
1736
|
+
consumerResult,
|
|
1737
|
+
resultsDir: join(f.base, "join")
|
|
1738
|
+
});
|
|
1739
|
+
assert.equal(joined.qualified, true);
|
|
1740
|
+
assert.deepEqual(f.counts(), { producers: 1, packs: 1, consumers: 1 });
|
|
1741
|
+
receipt.cleanup = { quiescent: true, removed: false };
|
|
1742
|
+
writeFileSync(consumerResult, JSON.stringify(receipt));
|
|
1743
|
+
const bad = await qualification.runQualification({
|
|
1744
|
+
...f.options,
|
|
1745
|
+
resume,
|
|
1746
|
+
consumerResult,
|
|
1747
|
+
resultsDir: join(f.base, "bad-join")
|
|
1748
|
+
});
|
|
1749
|
+
assert.equal(bad.qualified, false);
|
|
1750
|
+
assert.match(bad.error, /removal/u);
|
|
1751
|
+
} finally {
|
|
1752
|
+
f.cleanup();
|
|
1005
1753
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1754
|
+
}
|
|
1755
|
+
);
|
|
1756
|
+
for (const status of ["failed", "timed-out", "cancelled", "cleanup-unconfirmed"]) {
|
|
1757
|
+
test(`actual pack ${status} cannot produce a successful checkpoint`, async () => {
|
|
1758
|
+
const f = qualificationFixture();
|
|
1759
|
+
try {
|
|
1760
|
+
f.packFailure(status === "cleanup-unconfirmed" ? "passed" : status, status !== "cleanup-unconfirmed");
|
|
1761
|
+
const report = await qualification.runQualification(f.options);
|
|
1762
|
+
assert.equal(report.qualified, false);
|
|
1763
|
+
assert.equal(existsSync(join(f.options.resultsDir, "checkpoint.json")), false);
|
|
1764
|
+
assert.equal(f.counts().consumers, 0);
|
|
1765
|
+
} finally {
|
|
1766
|
+
f.cleanup();
|
|
1008
1767
|
}
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
test("pre-start cancellation and inside-source evidence refuse all graph launches", async () => {
|
|
1771
|
+
const f = qualificationFixture();
|
|
1772
|
+
try {
|
|
1773
|
+
const controller = new AbortController();
|
|
1774
|
+
controller.abort();
|
|
1775
|
+
const report = await qualification.runQualification({ ...f.options, signal: controller.signal });
|
|
1776
|
+
assert.equal(report.status, "cancelled");
|
|
1777
|
+
assert.equal(report.exitCode, 130);
|
|
1778
|
+
assert.deepEqual(f.counts(), { producers: 0, packs: 0, consumers: 0 });
|
|
1779
|
+
await assert.rejects(
|
|
1780
|
+
qualification.runQualification({ ...f.options, resultsDir: join(f.cwd, "..looks-outside") }),
|
|
1781
|
+
/outside source/u
|
|
1782
|
+
);
|
|
1783
|
+
assert.deepEqual(f.counts(), { producers: 0, packs: 0, consumers: 0 });
|
|
1784
|
+
} finally {
|
|
1785
|
+
f.cleanup();
|
|
1786
|
+
}
|
|
1009
1787
|
});
|
|
1010
|
-
//# sourceMappingURL=contributorChecks.test.js.map
|
|
1788
|
+
//# sourceMappingURL=contributorChecks.test.js.map
|