@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,50 +1,49 @@
|
|
|
1
|
-
import assert from
|
|
2
|
-
import { spawnSync } from
|
|
3
|
-
import { gzipSync } from
|
|
4
|
-
import { appendFileSync, chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from
|
|
5
|
-
import { tmpdir } from
|
|
6
|
-
import { dirname, join } from
|
|
7
|
-
import { fileURLToPath, pathToFileURL } from
|
|
8
|
-
import { setTimeout as delay } from
|
|
9
|
-
import { test } from
|
|
10
|
-
const source = process.env[
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
// Optional caller-owned local evidence. Child environments still use the helper's
|
|
14
|
-
// explicit allowlist and never inherit this path or ambient credentials.
|
|
15
|
-
const evidencePath = process.env['AI_DELIVERY_CURRENT_CONSUMER_EVIDENCE_FILE'];
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { gzipSync } from "node:zlib";
|
|
4
|
+
import { appendFileSync, chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
5
|
+
import { tmpdir } from "node:os";
|
|
6
|
+
import { dirname, join } from "node:path";
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
+
import { setTimeout as delay } from "node:timers/promises";
|
|
9
|
+
import { test } from "vitest";
|
|
10
|
+
const source = process.env["AI_DELIVERY_CURRENT_CONSUMER_SCRIPT"] ?? fileURLToPath(new URL("../scripts/current-consumer.mjs", import.meta.url));
|
|
11
|
+
const api = await import(pathToFileURL(source).href);
|
|
12
|
+
const evidencePath = process.env["AI_DELIVERY_CURRENT_CONSUMER_EVIDENCE_FILE"];
|
|
16
13
|
function recordSynthetic(evidence) {
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
if (evidencePath)
|
|
15
|
+
appendFileSync(evidencePath, JSON.stringify({ boundary: "fictional synthetic fixture", evidence }) + "\n");
|
|
19
16
|
}
|
|
20
17
|
const helper = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
18
|
+
...api,
|
|
19
|
+
runOwnedProcess: async (command, args, options) => {
|
|
20
|
+
try {
|
|
21
|
+
const result = await api.runOwnedProcess(command, args, options);
|
|
22
|
+
recordSynthetic({ kind: "process-result", stdoutSha256: api.sha256(result.stdout), ...result.evidence });
|
|
23
|
+
return result;
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (error instanceof Error) {
|
|
26
|
+
const e = error;
|
|
27
|
+
recordSynthetic({ kind: "process-failure", code: e.code, evidence: e.evidence });
|
|
28
|
+
}
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
36
32
|
};
|
|
37
33
|
const failure = (code) => (error) => error instanceof Error && error.code === code;
|
|
38
|
-
test.each([false, true])(
|
|
34
|
+
test.each([false, true])(
|
|
35
|
+
"synthetic actual Node24 coverage parent preserves reused explicit env; frozen=%s",
|
|
36
|
+
{ tags: ["release"] },
|
|
37
|
+
(frozen) => {
|
|
39
38
|
const f = fixture();
|
|
40
39
|
let confirmedQuiescence = false;
|
|
41
40
|
try {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
const coverage = join(f.directory, "coverage");
|
|
42
|
+
mkdirSync(coverage);
|
|
43
|
+
const program = `import {runOwnedProcess,consumerEnvironment,sha256} from ${JSON.stringify(pathToFileURL(source).href)};
|
|
45
44
|
import process from 'node:process';
|
|
46
45
|
const input=consumerEnvironment(${JSON.stringify(f.directory)},process.execPath);
|
|
47
|
-
const env=${frozen ?
|
|
46
|
+
const env=${frozen ? "Object.freeze(input)" : "input"};
|
|
48
47
|
const before={...env};const keys=Object.keys(env).sort();
|
|
49
48
|
const report={boundary:'fictional synthetic process, actual Node24 coverage parent',actualRuntime:process.version,
|
|
50
49
|
coverageParentEnabled:typeof process.env.NODE_V8_COVERAGE==='string',frozenCaller:Object.isFrozen(env),
|
|
@@ -71,762 +70,845 @@ try{
|
|
|
71
70
|
report.callerKeysUnchanged=JSON.stringify(Object.keys(env).sort())===JSON.stringify(keys);
|
|
72
71
|
report.callerValuesUnchanged=keys.every(key=>env[key]===before[key]);
|
|
73
72
|
console.log(JSON.stringify(report));`;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
});
|
|
73
|
+
const parent = spawnSync(process.execPath, ["--input-type=module", "-e", program], {
|
|
74
|
+
cwd: f.directory,
|
|
75
|
+
env: {
|
|
76
|
+
PATH: dirname(process.execPath) + ":/usr/bin:/bin",
|
|
77
|
+
HOME: f.directory,
|
|
78
|
+
TMPDIR: f.directory,
|
|
79
|
+
NO_COLOR: "1",
|
|
80
|
+
NODE_V8_COVERAGE: coverage
|
|
81
|
+
},
|
|
82
|
+
encoding: "utf8",
|
|
83
|
+
maxBuffer: 512 * 1024
|
|
84
|
+
});
|
|
85
|
+
assert.ok(parent.status === 0, "Synthetic coverage parent failed before its bounded receipt");
|
|
86
|
+
const report = JSON.parse(parent.stdout);
|
|
87
|
+
recordSynthetic({ kind: "coverage-caller-env-regression", report, stderrSha256: helper.sha256(parent.stderr) });
|
|
88
|
+
confirmedQuiescence = !report.unresolvedOwnedChild && report.phases.every((phase) => phase.quiescent);
|
|
89
|
+
assert.equal(report.actualRuntime, "v24.21.0");
|
|
90
|
+
assert.equal(report.coverageParentEnabled, true);
|
|
91
|
+
assert.equal(report.status, "passed");
|
|
92
|
+
assert.equal(report.frozenCaller, frozen);
|
|
93
|
+
assert.equal(report.callerKeysUnchanged, true);
|
|
94
|
+
assert.equal(report.callerValuesUnchanged, true);
|
|
95
|
+
assert.equal(report.environmentValuesSerialized, false);
|
|
96
|
+
assert.equal(report.unresolvedOwnedChild, false);
|
|
97
|
+
assert.equal(report.phases.length, 2);
|
|
98
|
+
assert.ok(report.phases.every((phase) => phase.quiescent));
|
|
99
|
+
assert.deepEqual(report.rejectedKeys, [
|
|
100
|
+
"NODE_V8_COVERAGE",
|
|
101
|
+
"GH_TOKEN",
|
|
102
|
+
"GH_APP_ID_GPT_REVIEWER",
|
|
103
|
+
"AI_DELIVERY_CONFIG",
|
|
104
|
+
"NODE_PATH"
|
|
105
|
+
]);
|
|
106
|
+
} finally {
|
|
107
|
+
if (confirmedQuiescence) f.cleanup();
|
|
108
|
+
else recordSynthetic({ kind: "fixture-retained", directory: f.directory, quiescent: false });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
);
|
|
115
112
|
function archive(members) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
113
|
+
const chunks = [];
|
|
114
|
+
for (const member of members) {
|
|
115
|
+
const header = Buffer.alloc(512);
|
|
116
|
+
header.write(`package/${member.path}`, 0, 100);
|
|
117
|
+
const number = (value, offset, length) => header.write(value.toString(8).padStart(length - 1, "0") + "\0", offset, length);
|
|
118
|
+
number(member.mode, 100, 8);
|
|
119
|
+
number(0, 108, 8);
|
|
120
|
+
number(0, 116, 8);
|
|
121
|
+
number(member.bytes.length, 124, 12);
|
|
122
|
+
number(0, 136, 12);
|
|
123
|
+
header.fill(32, 148, 156);
|
|
124
|
+
header.write(member.type ?? "0", 156);
|
|
125
|
+
header.write("ustar\0", 257);
|
|
126
|
+
header.write("00", 263);
|
|
127
|
+
const sum = header.reduce((a, b) => a + b, 0);
|
|
128
|
+
header.write(sum.toString(8).padStart(6, "0") + "\0 ", 148, 8);
|
|
129
|
+
chunks.push(header, member.bytes, Buffer.alloc((512 - member.bytes.length % 512) % 512));
|
|
130
|
+
}
|
|
131
|
+
chunks.push(Buffer.alloc(1024));
|
|
132
|
+
return gzipSync(Buffer.concat(chunks));
|
|
136
133
|
}
|
|
137
134
|
function fixture() {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
135
|
+
const directory = mkdtempSync(join(tmpdir(), "synthetic-current-consumer-"));
|
|
136
|
+
const root = join(directory, "built");
|
|
137
|
+
mkdirSync(root);
|
|
138
|
+
const manifest = {
|
|
139
|
+
name: "@aviaratech/ai-delivery",
|
|
140
|
+
version: "0.0.0",
|
|
141
|
+
type: "module",
|
|
142
|
+
main: "./dist/index.js",
|
|
143
|
+
bin: { "ai-delivery": "./dist/cli.js" },
|
|
144
|
+
engines: { node: ">=24.21.0 <25 || 26.2.0", npm: "11.19.0" },
|
|
145
|
+
exports: {
|
|
146
|
+
".": { default: "./dist/index.js", types: "./dist/index.d.ts" },
|
|
147
|
+
"./agent": { default: "./dist/agent.js", types: "./dist/agent.d.ts" },
|
|
148
|
+
"./delivery": { default: "./dist/delivery/index.js", types: "./dist/delivery/index.d.ts" },
|
|
149
|
+
"./mcp": { default: "./dist/mcp/index.js", types: "./dist/mcp/index.d.ts" }
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const files = /* @__PURE__ */ new Map();
|
|
153
|
+
files.set("package.json", JSON.stringify(manifest));
|
|
154
|
+
for (const path of [
|
|
155
|
+
"LICENSE",
|
|
156
|
+
"README.md",
|
|
157
|
+
"CONTRIBUTING.md",
|
|
158
|
+
"dist/cli.js",
|
|
159
|
+
"plugins/ai-delivery/dist/mcp-launcher.js",
|
|
160
|
+
"plugins/ai-delivery/runtime/dist/cli.js",
|
|
161
|
+
"plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md"
|
|
162
|
+
])
|
|
163
|
+
files.set(path, "synthetic inert file\n");
|
|
164
|
+
for (const path of ["index", "agent", "delivery/index", "mcp/index"])
|
|
165
|
+
for (const ext of ["js", "d.ts"]) files.set(`dist/${path}.${ext}`, "synthetic inert export\n");
|
|
166
|
+
for (const path of ["plugins/ai-delivery/plugin.json", "plugins/ai-delivery/.claude-plugin/plugin.json"])
|
|
167
|
+
files.set(path, JSON.stringify({ name: "ai-delivery", version: "0.0.0" }));
|
|
168
|
+
files.set("plugins/ai-delivery/runtime/package.json", JSON.stringify({ version: "0.0.0" }));
|
|
169
|
+
files.set(
|
|
170
|
+
"plugins/ai-delivery/mcp.json",
|
|
171
|
+
JSON.stringify({
|
|
172
|
+
mcpServers: { "ai-delivery": { type: "stdio", command: "node", args: ["${PLUGIN_ROOT}/dist/mcp-launcher.js"] } }
|
|
173
|
+
})
|
|
174
|
+
);
|
|
175
|
+
for (const skill of ["intake-create", "worktree-lifecycle", "pr-handoff"])
|
|
176
|
+
files.set(
|
|
177
|
+
`plugins/ai-delivery/skills/${skill}/SKILL.md`,
|
|
178
|
+
`---
|
|
179
|
+
name: "ai-delivery:${skill}"
|
|
180
|
+
description: Synthetic fixture only
|
|
181
|
+
---
|
|
182
|
+
`
|
|
183
|
+
);
|
|
184
|
+
const members = [...files].map(([path, text]) => ({
|
|
185
|
+
path,
|
|
186
|
+
bytes: Buffer.from(text),
|
|
187
|
+
mode: path.endsWith("/cli.js") || path.endsWith("/mcp-launcher.js") ? 493 : 420
|
|
188
|
+
}));
|
|
189
|
+
for (const member of members) {
|
|
190
|
+
const path = join(root, member.path);
|
|
191
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
192
|
+
writeFileSync(path, member.bytes);
|
|
193
|
+
chmodSync(path, member.mode);
|
|
194
|
+
}
|
|
195
|
+
writeFileSync(
|
|
196
|
+
join(root, "package-lock.json"),
|
|
197
|
+
JSON.stringify({ name: manifest.name, version: manifest.version, lockfileVersion: 3, synthetic: true })
|
|
198
|
+
);
|
|
199
|
+
const make = (items = members) => {
|
|
200
|
+
const bytes = archive(items);
|
|
201
|
+
const archivePath = join(directory, "synthetic.tgz");
|
|
202
|
+
writeFileSync(archivePath, bytes);
|
|
203
|
+
const contract = {
|
|
204
|
+
sourceRoot: root,
|
|
205
|
+
archivePath,
|
|
206
|
+
archiveSha256: helper.sha256(bytes),
|
|
207
|
+
sourceManifestSha256: helper.sha256(readFileSync(join(root, "package.json"))),
|
|
208
|
+
sourceLockSha256: helper.sha256(readFileSync(join(root, "package-lock.json"))),
|
|
209
|
+
packageVersion: "0.0.0",
|
|
210
|
+
dryInventory: items.map(({ path, bytes: data, mode }) => ({ path, size: data.length, mode }))
|
|
205
211
|
};
|
|
206
|
-
|
|
212
|
+
recordSynthetic({ kind: "archive-contract", ...contract });
|
|
213
|
+
return contract;
|
|
214
|
+
};
|
|
215
|
+
return { directory, root, members, make, cleanup: () => rmSync(directory, { recursive: true, force: true }) };
|
|
207
216
|
}
|
|
208
|
-
test(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
217
|
+
test("synthetic current-layout archive binds all inventory bytes/modes; no actual candidate is qualified", async () => {
|
|
218
|
+
const f = fixture();
|
|
219
|
+
try {
|
|
220
|
+
const contract = f.make();
|
|
221
|
+
const result = helper.inspectCandidate(contract);
|
|
222
|
+
assert.equal(result.inventory.length, f.members.length);
|
|
223
|
+
assert.match(result.inventorySha256, /^[a-f0-9]{64}$/u);
|
|
224
|
+
const deferred = await helper.runCurrentConsumer(contract);
|
|
225
|
+
assert.equal(deferred.status, "incomplete");
|
|
226
|
+
assert.equal(deferred.qualified, false);
|
|
227
|
+
assert.match(deferred.reason, /not been admitted/u);
|
|
228
|
+
recordSynthetic({ kind: "noninstalling-helper-result", receipt: deferred });
|
|
229
|
+
} finally {
|
|
230
|
+
f.cleanup();
|
|
231
|
+
}
|
|
224
232
|
});
|
|
225
|
-
test.each([
|
|
233
|
+
test.each(["../escape", "/absolute", "dist/../../escape", "dist\\escape", "dist/.env", "other/file"])(
|
|
234
|
+
"synthetic unsafe inventory rejects %s",
|
|
235
|
+
(path) => {
|
|
226
236
|
const f = fixture();
|
|
227
237
|
try {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
238
|
+
const contract = f.make([{ path, bytes: Buffer.from("unsafe"), mode: 420 }]);
|
|
239
|
+
assert.throws(
|
|
240
|
+
() => helper.readArchive(readFileSync(contract.archivePath), contract.archiveSha256),
|
|
241
|
+
failure("unsafe-inventory")
|
|
242
|
+
);
|
|
243
|
+
} finally {
|
|
244
|
+
f.cleanup();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
);
|
|
235
248
|
function producerFixture() {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
249
|
+
const f = fixture();
|
|
250
|
+
const contract = f.make();
|
|
251
|
+
const init = spawnSync("git", ["init", "--quiet"], {
|
|
252
|
+
cwd: f.root,
|
|
253
|
+
env: { PATH: "/usr/bin:/bin", GIT_CONFIG_GLOBAL: "/dev/null", GIT_CONFIG_SYSTEM: "/dev/null" },
|
|
254
|
+
encoding: "utf8"
|
|
255
|
+
});
|
|
256
|
+
assert.equal(init.status, 0, init.stderr);
|
|
257
|
+
contract.sourceCommit = "a".repeat(40);
|
|
258
|
+
contract.sourceTree = "b".repeat(40);
|
|
259
|
+
contract.node24 = process.execPath;
|
|
260
|
+
contract.node26 = "/fictional/node26";
|
|
261
|
+
contract.npmCli = "/fictional/npm-cli.js";
|
|
262
|
+
const files = spawnSync("git", ["ls-files", "-co", "--exclude-standard", "-z"], {
|
|
263
|
+
cwd: f.root,
|
|
264
|
+
env: { PATH: "/usr/bin:/bin", GIT_CONFIG_GLOBAL: "/dev/null", GIT_CONFIG_SYSTEM: "/dev/null" },
|
|
265
|
+
encoding: "utf8"
|
|
266
|
+
});
|
|
267
|
+
assert.equal(files.status, 0);
|
|
268
|
+
const fingerprint = {
|
|
269
|
+
kind: "working-copy",
|
|
270
|
+
sha256: helper.sha256(
|
|
271
|
+
JSON.stringify(
|
|
272
|
+
[...new Set(files.stdout.split("\0").filter(Boolean))].sort().map((path) => ({
|
|
273
|
+
path,
|
|
274
|
+
executable: f.members.some((member) => member.path === path && (member.mode & 73) !== 0),
|
|
275
|
+
sha256: helper.sha256(readFileSync(join(f.root, path)))
|
|
276
|
+
}))
|
|
277
|
+
)
|
|
278
|
+
),
|
|
279
|
+
fileCount: new Set(files.stdout.split("\0").filter(Boolean)).size
|
|
280
|
+
};
|
|
281
|
+
const gates = ["format", "lint", "types", "build", "tests", "inventory"];
|
|
282
|
+
const checks = {
|
|
283
|
+
schemaVersion: "contributor-checks@1",
|
|
284
|
+
runId: "fictional-producer-run",
|
|
285
|
+
scope: "full",
|
|
286
|
+
status: "passed",
|
|
287
|
+
fullSuccess: true,
|
|
288
|
+
exitCode: 0,
|
|
289
|
+
selectedTestFiles: ["src/fictional.test.ts"],
|
|
290
|
+
tests: { files: 1, total: 1, passed: 1, skips: [] },
|
|
291
|
+
gates,
|
|
292
|
+
omitted: [],
|
|
293
|
+
tree: fingerprint,
|
|
294
|
+
commands: gates.map((stage) => ({ stage, status: "passed", exitCode: 0, signal: null, cleanupConfirmed: true })),
|
|
295
|
+
toolchain: {
|
|
296
|
+
controller: { version: "v24.21.0", executable: contract.node24 },
|
|
297
|
+
npm: { version: "11.19.0", executable: contract.npmCli },
|
|
298
|
+
libraryConsumer: { version: "v26.2.0", executable: contract.node26 }
|
|
299
|
+
},
|
|
300
|
+
inventory: {
|
|
301
|
+
kind: "dry-inventory-only",
|
|
302
|
+
name: "@aviaratech/ai-delivery",
|
|
303
|
+
version: "0.0.0",
|
|
304
|
+
fileCount: contract.dryInventory.length,
|
|
305
|
+
files: contract.dryInventory
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
const artifact = {
|
|
309
|
+
schemaVersion: "ai-delivery.current-artifact-producer@1",
|
|
310
|
+
status: "passed",
|
|
311
|
+
sourceCommit: contract.sourceCommit,
|
|
312
|
+
sourceTree: contract.sourceTree,
|
|
313
|
+
sourceManifestSha256: contract.sourceManifestSha256,
|
|
314
|
+
sourceLockSha256: contract.sourceLockSha256,
|
|
315
|
+
packageVersion: contract.packageVersion,
|
|
316
|
+
archiveSha256: contract.archiveSha256,
|
|
317
|
+
inventorySha256: helper.inspectCandidate(contract).inventorySha256,
|
|
318
|
+
sourceFingerprint: fingerprint,
|
|
319
|
+
pack: { status: "passed", exitCode: 0, quiescent: true, archiveSha256: contract.archiveSha256 }
|
|
320
|
+
};
|
|
321
|
+
const persist = () => {
|
|
322
|
+
const checksPath = join(f.directory, "checks.json");
|
|
323
|
+
writeFileSync(checksPath, JSON.stringify(checks));
|
|
324
|
+
const digest = helper.sha256(readFileSync(checksPath));
|
|
325
|
+
artifact["checksResultSha256"] = digest;
|
|
326
|
+
const artifactPath = join(f.directory, "producer.json");
|
|
327
|
+
writeFileSync(artifactPath, JSON.stringify(artifact));
|
|
328
|
+
contract.producer = {
|
|
329
|
+
checksResultPath: checksPath,
|
|
330
|
+
checksResultSha256: digest,
|
|
331
|
+
artifactReceiptPath: artifactPath,
|
|
332
|
+
artifactReceiptSha256: helper.sha256(readFileSync(artifactPath))
|
|
317
333
|
};
|
|
318
|
-
|
|
319
|
-
|
|
334
|
+
};
|
|
335
|
+
persist();
|
|
336
|
+
return { f, contract, checks, artifact, persist };
|
|
320
337
|
}
|
|
321
|
-
test(
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
}
|
|
338
|
+
test("synthetic canonical producer join accepts matching source and archive, but never qualifies without install admission", async () => {
|
|
339
|
+
const { f, contract } = producerFixture();
|
|
340
|
+
try {
|
|
341
|
+
const joined = helper.verifyProducerJoin(contract, helper.inspectCandidate(contract));
|
|
342
|
+
assert.equal(joined["actualArchiveSha256"], contract.archiveSha256);
|
|
343
|
+
const result = await helper.runCurrentConsumer(contract);
|
|
344
|
+
assert.equal(result.status, "incomplete");
|
|
345
|
+
assert.equal(result.qualified, false);
|
|
346
|
+
recordSynthetic({ kind: "fictional-canonical-producer-join", joined, result, actualApplicationBoundary: false });
|
|
347
|
+
} finally {
|
|
348
|
+
f.cleanup();
|
|
349
|
+
}
|
|
334
350
|
});
|
|
335
351
|
test.each([
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
])(
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
}
|
|
352
|
+
"scope",
|
|
353
|
+
"status",
|
|
354
|
+
"fullSuccess",
|
|
355
|
+
"exitCode",
|
|
356
|
+
"gates",
|
|
357
|
+
"omitted",
|
|
358
|
+
"tree",
|
|
359
|
+
"commands",
|
|
360
|
+
"toolchain",
|
|
361
|
+
"inventory",
|
|
362
|
+
"tests",
|
|
363
|
+
"selectedTestFiles"
|
|
364
|
+
])("synthetic canonical %s incompleteness cannot qualify rebuilt artifact", (field) => {
|
|
365
|
+
const { f, contract, checks, persist } = producerFixture();
|
|
366
|
+
try {
|
|
367
|
+
checks[field] = field === "gates" || field === "omitted" ? ["build"] : null;
|
|
368
|
+
persist();
|
|
369
|
+
assert.throws(() => helper.verifyProducerJoin(contract, helper.inspectCandidate(contract)), failure("producer"));
|
|
370
|
+
} finally {
|
|
371
|
+
f.cleanup();
|
|
372
|
+
}
|
|
358
373
|
});
|
|
359
374
|
test.each([
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
])(
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
}
|
|
375
|
+
"sourceCommit",
|
|
376
|
+
"sourceTree",
|
|
377
|
+
"sourceManifestSha256",
|
|
378
|
+
"sourceLockSha256",
|
|
379
|
+
"packageVersion",
|
|
380
|
+
"archiveSha256",
|
|
381
|
+
"inventorySha256",
|
|
382
|
+
"pack",
|
|
383
|
+
"sourceFingerprint"
|
|
384
|
+
])("synthetic artifact producer %s drift cannot reuse old producer proof", (field) => {
|
|
385
|
+
const { f, contract, artifact, persist } = producerFixture();
|
|
386
|
+
try {
|
|
387
|
+
artifact[field] = null;
|
|
388
|
+
persist();
|
|
389
|
+
assert.throws(() => helper.verifyProducerJoin(contract, helper.inspectCandidate(contract)), failure("producer"));
|
|
390
|
+
} finally {
|
|
391
|
+
f.cleanup();
|
|
392
|
+
}
|
|
379
393
|
});
|
|
380
|
-
test(
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
}
|
|
394
|
+
test("synthetic producer hash and source-file drift are refused before any install", () => {
|
|
395
|
+
const { f, contract, persist } = producerFixture();
|
|
396
|
+
try {
|
|
397
|
+
assert.ok(contract.producer);
|
|
398
|
+
appendFileSync(contract.producer.checksResultPath, " ");
|
|
399
|
+
assert.throws(() => helper.verifyProducerJoin(contract, helper.inspectCandidate(contract)), failure("producer"));
|
|
400
|
+
persist();
|
|
401
|
+
writeFileSync(join(f.root, "changed-untracked-source.ts"), "synthetic new source");
|
|
402
|
+
assert.throws(() => helper.verifyProducerJoin(contract, helper.inspectCandidate(contract)), failure("producer"));
|
|
403
|
+
delete contract.producer;
|
|
404
|
+
assert.throws(() => helper.verifyProducerJoin(contract, helper.inspectCandidate(contract)), failure("producer"));
|
|
405
|
+
} finally {
|
|
406
|
+
f.cleanup();
|
|
407
|
+
}
|
|
395
408
|
});
|
|
396
409
|
test.each([
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
])(
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
persist();
|
|
436
|
-
assert.throws(() => helper.verifyProducerJoin(contract, helper.inspectCandidate(contract)), failure('producer'));
|
|
437
|
-
}
|
|
438
|
-
finally {
|
|
439
|
-
f.cleanup();
|
|
440
|
-
}
|
|
410
|
+
"missing-gate",
|
|
411
|
+
"duplicate-gate",
|
|
412
|
+
"nonquiescent",
|
|
413
|
+
"zero-tests",
|
|
414
|
+
"zero-selection",
|
|
415
|
+
"unexpected-skip",
|
|
416
|
+
"dry-inventory-byte-drift"
|
|
417
|
+
])("synthetic canonical producer refuses %s despite a claimed full success", (kind) => {
|
|
418
|
+
const { f, contract, checks, persist } = producerFixture();
|
|
419
|
+
try {
|
|
420
|
+
const steps = checks["commands"];
|
|
421
|
+
if (kind === "missing-gate") steps.pop();
|
|
422
|
+
else if (kind === "duplicate-gate") steps[5] = steps[4];
|
|
423
|
+
else if (kind === "nonquiescent") steps[3]["cleanupConfirmed"] = false;
|
|
424
|
+
else if (kind === "zero-tests") checks["tests"] = { files: 1, total: 0, passed: 0, skips: [] };
|
|
425
|
+
else if (kind === "zero-selection") {
|
|
426
|
+
checks["selectedTestFiles"] = [];
|
|
427
|
+
checks["tests"] = { files: 0, total: 1, passed: 1, skips: [] };
|
|
428
|
+
} else if (kind === "unexpected-skip")
|
|
429
|
+
checks["tests"] = {
|
|
430
|
+
files: 1,
|
|
431
|
+
total: 2,
|
|
432
|
+
passed: 1,
|
|
433
|
+
skips: [{ file: "dist/fictional.test.js", title: "unreviewed skip", kind: "unreviewed" }]
|
|
434
|
+
};
|
|
435
|
+
else
|
|
436
|
+
checks["inventory"] = {
|
|
437
|
+
kind: "dry-inventory-only",
|
|
438
|
+
name: "@aviaratech/ai-delivery",
|
|
439
|
+
version: "0.0.0",
|
|
440
|
+
fileCount: 1,
|
|
441
|
+
files: [{ path: "package.json", size: 1, mode: 420 }]
|
|
442
|
+
};
|
|
443
|
+
persist();
|
|
444
|
+
assert.throws(() => helper.verifyProducerJoin(contract, helper.inspectCandidate(contract)), failure("producer"));
|
|
445
|
+
} finally {
|
|
446
|
+
f.cleanup();
|
|
447
|
+
}
|
|
441
448
|
});
|
|
442
|
-
test.each([
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
449
|
+
test.each(["1", "2", "3", "6"])("synthetic tar link/special type %s cannot reach npm extraction", (type) => {
|
|
450
|
+
const f = fixture();
|
|
451
|
+
try {
|
|
452
|
+
const contract = f.make([{ path: "dist/link", bytes: Buffer.alloc(0), mode: 420, type }]);
|
|
453
|
+
assert.throws(
|
|
454
|
+
() => helper.readArchive(readFileSync(contract.archivePath), contract.archiveSha256),
|
|
455
|
+
failure("unsafe-inventory")
|
|
456
|
+
);
|
|
457
|
+
} finally {
|
|
458
|
+
f.cleanup();
|
|
459
|
+
}
|
|
451
460
|
});
|
|
452
|
-
test(
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
461
|
+
test("synthetic corruption, duplicates, inventory omissions and built-byte drift fail closed", () => {
|
|
462
|
+
const f = fixture();
|
|
463
|
+
try {
|
|
464
|
+
let contract = f.make();
|
|
465
|
+
assert.throws(
|
|
466
|
+
() => helper.readArchive(readFileSync(contract.archivePath), "a".repeat(64)),
|
|
467
|
+
failure("archive-digest")
|
|
468
|
+
);
|
|
469
|
+
contract = f.make([...f.members, f.members[0]]);
|
|
470
|
+
assert.throws(() => helper.inspectCandidate(contract), failure("unsafe-inventory"));
|
|
471
|
+
contract = f.make();
|
|
472
|
+
contract.dryInventory.pop();
|
|
473
|
+
assert.throws(() => helper.inspectCandidate(contract), failure("inventory-mismatch"));
|
|
474
|
+
contract = f.make();
|
|
475
|
+
writeFileSync(join(f.root, "README.md"), "changed");
|
|
476
|
+
assert.throws(() => helper.inspectCandidate(contract), failure("built-bytes"));
|
|
477
|
+
} finally {
|
|
478
|
+
f.cleanup();
|
|
479
|
+
}
|
|
469
480
|
});
|
|
470
|
-
test(
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}
|
|
481
|
+
test("synthetic installed package rejects unexpected files beyond the accepted inventory", () => {
|
|
482
|
+
const f = fixture();
|
|
483
|
+
try {
|
|
484
|
+
const candidate = helper.inspectCandidate(f.make());
|
|
485
|
+
rmSync(join(f.root, "package-lock.json"));
|
|
486
|
+
helper.verifyInstalledPackage(f.root, candidate.inventory);
|
|
487
|
+
writeFileSync(join(f.root, "dist", "unexpected.js"), "unexpected");
|
|
488
|
+
assert.throws(() => helper.verifyInstalledPackage(f.root, candidate.inventory), failure("installed-bytes"));
|
|
489
|
+
} finally {
|
|
490
|
+
f.cleanup();
|
|
491
|
+
}
|
|
482
492
|
});
|
|
483
493
|
test.each([
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
])(
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
494
|
+
"dist/index.js",
|
|
495
|
+
"plugins/ai-delivery/runtime/dist/cli.js",
|
|
496
|
+
"plugins/ai-delivery/skills/intake-create/SKILL.md"
|
|
497
|
+
])("synthetic missing packaged entry %s fails inspection", (path) => {
|
|
498
|
+
const f = fixture();
|
|
499
|
+
try {
|
|
500
|
+
assert.throws(
|
|
501
|
+
() => helper.inspectCandidate(f.make(f.members.filter((member) => member.path !== path))),
|
|
502
|
+
failure("missing-file")
|
|
503
|
+
);
|
|
504
|
+
} finally {
|
|
505
|
+
f.cleanup();
|
|
506
|
+
}
|
|
495
507
|
});
|
|
496
|
-
test.each([
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
}
|
|
508
|
+
test.each(["name", "version", "runtime"])("synthetic wrong package %s cannot pass", (kind) => {
|
|
509
|
+
const f = fixture();
|
|
510
|
+
try {
|
|
511
|
+
const member = f.members.find((item) => item.path === "package.json");
|
|
512
|
+
const pkg = JSON.parse(member.bytes.toString());
|
|
513
|
+
if (kind === "name") pkg.name = "other";
|
|
514
|
+
else if (kind === "version") pkg.version = "0.0.1";
|
|
515
|
+
else pkg.engines.node = ">=20";
|
|
516
|
+
member.bytes = Buffer.from(JSON.stringify(pkg));
|
|
517
|
+
assert.throws(
|
|
518
|
+
() => helper.inspectCandidate(f.make()),
|
|
519
|
+
failure(kind === "runtime" ? "runtime" : "package-identity")
|
|
520
|
+
);
|
|
521
|
+
} finally {
|
|
522
|
+
f.cleanup();
|
|
523
|
+
}
|
|
513
524
|
});
|
|
514
|
-
test(
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
}
|
|
525
|
+
test("synthetic environment never borrows ambient author/reviewer/preload or npm configuration", () => {
|
|
526
|
+
const f = fixture();
|
|
527
|
+
try {
|
|
528
|
+
const env = helper.consumerEnvironment(f.directory, process.execPath);
|
|
529
|
+
for (const name of [
|
|
530
|
+
"GH_TOKEN",
|
|
531
|
+
"GH_APP_ID_GPT_REVIEWER",
|
|
532
|
+
"GH_INSTALLATION_ID_GPT_REVIEWER",
|
|
533
|
+
"GH_PRIVATE_KEY_GPT_REVIEWER",
|
|
534
|
+
"NODE_PATH",
|
|
535
|
+
"NODE_OPTIONS",
|
|
536
|
+
"AI_DELIVERY_CONFIG"
|
|
537
|
+
])
|
|
538
|
+
assert.equal(env[name], void 0);
|
|
539
|
+
assert.equal(readFileSync(env["npm_config_userconfig"], "utf8"), "");
|
|
540
|
+
assert.notEqual(env["npm_config_userconfig"], env["npm_config_globalconfig"]);
|
|
541
|
+
} finally {
|
|
542
|
+
f.cleanup();
|
|
543
|
+
}
|
|
534
544
|
});
|
|
535
|
-
test(
|
|
545
|
+
test(
|
|
546
|
+
"synthetic resolver demonstrates a borrowing false positive, then rejects external and undeclared hoisted dependencies",
|
|
547
|
+
{ tags: ["release"] },
|
|
548
|
+
async () => {
|
|
536
549
|
const f = fixture();
|
|
537
550
|
try {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
551
|
+
const consumer = join(f.directory, "consumer");
|
|
552
|
+
mkdirSync(consumer);
|
|
553
|
+
writeFileSync(join(consumer, "package.json"), JSON.stringify({ type: "module", dependencies: {} }));
|
|
554
|
+
const borrowed = join(f.directory, "node_modules", "borrowed-only");
|
|
555
|
+
mkdirSync(borrowed, { recursive: true });
|
|
556
|
+
writeFileSync(
|
|
557
|
+
join(borrowed, "package.json"),
|
|
558
|
+
JSON.stringify({ name: "borrowed-only", type: "module", exports: "./index.js" })
|
|
559
|
+
);
|
|
560
|
+
writeFileSync(join(borrowed, "index.js"), "export const borrowed=true;");
|
|
561
|
+
const env = helper.consumerEnvironment(f.directory, process.execPath);
|
|
562
|
+
const probe = join(consumer, "owned-probe.mjs");
|
|
563
|
+
writeFileSync(probe, "console.log((await import('borrowed-only')).borrowed)");
|
|
564
|
+
const args = [probe];
|
|
565
|
+
assert.equal(
|
|
566
|
+
(await helper.runOwnedProcess(process.execPath, args, { cwd: consumer, env })).stdout.trim(),
|
|
567
|
+
"true"
|
|
568
|
+
);
|
|
569
|
+
const guard = join(consumer, "owned-guard.mjs");
|
|
570
|
+
writeFileSync(guard, helper.resolutionGuard(consumer));
|
|
571
|
+
await assert.rejects(
|
|
572
|
+
helper.runOwnedProcess(process.execPath, ["--import", guard, ...args], { cwd: consumer, env }),
|
|
573
|
+
failure("isolation")
|
|
574
|
+
);
|
|
575
|
+
const hoisted = join(consumer, "node_modules", "borrowed-only");
|
|
576
|
+
mkdirSync(hoisted, { recursive: true });
|
|
577
|
+
writeFileSync(join(hoisted, "package.json"), readFileSync(join(borrowed, "package.json")));
|
|
578
|
+
writeFileSync(join(hoisted, "index.js"), "export const borrowed=true;");
|
|
579
|
+
await assert.rejects(
|
|
580
|
+
helper.runOwnedProcess(process.execPath, ["--import", guard, ...args], { cwd: consumer, env }),
|
|
581
|
+
failure("dependency")
|
|
582
|
+
);
|
|
583
|
+
} finally {
|
|
584
|
+
f.cleanup();
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
);
|
|
588
|
+
test.each(["network", "permission", "process"])(
|
|
589
|
+
"synthetic external %s failure retains bounded quiescent evidence",
|
|
590
|
+
{ tags: ["release"] },
|
|
591
|
+
async (kind) => {
|
|
564
592
|
const f = fixture();
|
|
565
593
|
try {
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
594
|
+
const env = helper.consumerEnvironment(f.directory, process.execPath);
|
|
595
|
+
const text = kind === "network" ? "ENOTFOUND" : kind === "permission" ? "EACCES" : "synthetic npm failure";
|
|
596
|
+
await assert.rejects(
|
|
597
|
+
helper.runOwnedProcess(
|
|
598
|
+
process.execPath,
|
|
599
|
+
["-e", `process.stderr.write(${JSON.stringify(text)});process.exit(1)`],
|
|
600
|
+
{ cwd: f.directory, env }
|
|
601
|
+
),
|
|
602
|
+
(error) => failure(kind)(error) && error.evidence.quiescent === true
|
|
603
|
+
);
|
|
604
|
+
assert.throws(() => helper.parseJsonOutput("startup banner\n{}"), failure("schema"));
|
|
605
|
+
} finally {
|
|
606
|
+
f.cleanup();
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
);
|
|
610
|
+
test(
|
|
611
|
+
"synthetic interrupted owned child is quiescent before disposable fixture cleanup",
|
|
612
|
+
{ tags: ["release"] },
|
|
613
|
+
async () => {
|
|
576
614
|
const f = fixture();
|
|
577
615
|
const cancellation = new AbortController();
|
|
578
616
|
try {
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
|
|
617
|
+
const env = helper.consumerEnvironment(f.directory, process.execPath);
|
|
618
|
+
await assert.rejects(
|
|
619
|
+
helper.runOwnedProcess(process.execPath, ["-e", "setInterval(()=>{},1000)"], {
|
|
620
|
+
cwd: f.directory,
|
|
621
|
+
env,
|
|
622
|
+
signal: cancellation.signal,
|
|
623
|
+
onSpawn: () => setTimeout(() => cancellation.abort(), 50)
|
|
624
|
+
}),
|
|
625
|
+
(error) => {
|
|
626
|
+
assert.equal(error.code, "cancelled");
|
|
627
|
+
assert.equal(error.evidence.quiescent, true);
|
|
628
|
+
assert.ok(error.evidence.birth);
|
|
629
|
+
return true;
|
|
630
|
+
}
|
|
631
|
+
);
|
|
632
|
+
} finally {
|
|
633
|
+
f.cleanup();
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
);
|
|
637
|
+
test(
|
|
638
|
+
"synthetic bounded-output failure never becomes successful stdout/schema proof",
|
|
639
|
+
{ tags: ["release"] },
|
|
640
|
+
async () => {
|
|
597
641
|
const f = fixture();
|
|
598
642
|
try {
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
|
|
643
|
+
await assert.rejects(
|
|
644
|
+
helper.runOwnedProcess(process.execPath, ["-e", "process.stdout.write('x'.repeat(10000))"], {
|
|
645
|
+
cwd: f.directory,
|
|
646
|
+
env: helper.consumerEnvironment(f.directory, process.execPath),
|
|
647
|
+
maxOutputBytes: 128
|
|
648
|
+
}),
|
|
649
|
+
failure("output-bound")
|
|
650
|
+
);
|
|
651
|
+
} finally {
|
|
652
|
+
f.cleanup();
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
);
|
|
609
656
|
test.each([
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
])(
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
}
|
|
657
|
+
'---\nname: "ai-delivery:intake-create"\ndescription: Synthetic fixture only\n',
|
|
658
|
+
'---\nother: Header\n---\nname: "ai-delivery:intake-create"\ndescription: Body only\n'
|
|
659
|
+
])("synthetic malformed skill frontmatter fails within the delimited header", (text) => {
|
|
660
|
+
const f = fixture();
|
|
661
|
+
try {
|
|
662
|
+
const member = f.members.find((item) => item.path === "plugins/ai-delivery/skills/intake-create/SKILL.md");
|
|
663
|
+
member.bytes = Buffer.from(text);
|
|
664
|
+
assert.throws(() => helper.inspectCandidate(f.make()), failure("schema"));
|
|
665
|
+
} finally {
|
|
666
|
+
f.cleanup();
|
|
667
|
+
}
|
|
622
668
|
});
|
|
623
|
-
test(
|
|
669
|
+
test(
|
|
670
|
+
"synthetic nested type-only manifest uses the installed package declaration owner",
|
|
671
|
+
{ tags: ["release"] },
|
|
672
|
+
async () => {
|
|
624
673
|
const f = fixture();
|
|
625
674
|
try {
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
675
|
+
const consumer = join(f.directory, "consumer");
|
|
676
|
+
mkdirSync(consumer);
|
|
677
|
+
writeFileSync(
|
|
678
|
+
join(consumer, "package.json"),
|
|
679
|
+
JSON.stringify({ name: "fictional-consumer", type: "module", dependencies: { "@fictional/sdk": "0" } })
|
|
680
|
+
);
|
|
681
|
+
const sdk = join(consumer, "node_modules", "@fictional", "sdk");
|
|
682
|
+
const esm = join(sdk, "dist", "esm");
|
|
683
|
+
mkdirSync(esm, { recursive: true });
|
|
684
|
+
writeFileSync(
|
|
685
|
+
join(sdk, "package.json"),
|
|
686
|
+
JSON.stringify({
|
|
687
|
+
name: "@fictional/sdk",
|
|
688
|
+
type: "module",
|
|
689
|
+
exports: "./dist/esm/index.js",
|
|
690
|
+
dependencies: { "declared-only": "0" }
|
|
691
|
+
})
|
|
692
|
+
);
|
|
693
|
+
writeFileSync(join(esm, "package.json"), '{"type":"module"}');
|
|
694
|
+
const dep = join(sdk, "node_modules", "declared-only");
|
|
695
|
+
mkdirSync(dep, { recursive: true });
|
|
696
|
+
writeFileSync(
|
|
697
|
+
join(dep, "package.json"),
|
|
698
|
+
JSON.stringify({ name: "declared-only", type: "module", exports: "./index.js" })
|
|
699
|
+
);
|
|
700
|
+
writeFileSync(join(dep, "index.js"), "export const value=true;");
|
|
701
|
+
writeFileSync(join(esm, "index.js"), "import {value} from 'declared-only';console.log(value);");
|
|
702
|
+
const guard = join(consumer, "owned-guard.mjs");
|
|
703
|
+
writeFileSync(guard, helper.resolutionGuard(consumer));
|
|
704
|
+
const env = helper.consumerEnvironment(f.directory, process.execPath);
|
|
705
|
+
const probe = join(consumer, "owned-probe.mjs");
|
|
706
|
+
writeFileSync(probe, "await import('@fictional/sdk')");
|
|
707
|
+
const args = ["--import", guard, probe];
|
|
708
|
+
assert.equal(
|
|
709
|
+
(await helper.runOwnedProcess(process.execPath, args, { cwd: consumer, env })).stdout.trim(),
|
|
710
|
+
"true"
|
|
711
|
+
);
|
|
712
|
+
writeFileSync(join(esm, "index.js"), "await import('missing-only');");
|
|
713
|
+
await assert.rejects(
|
|
714
|
+
helper.runOwnedProcess(process.execPath, args, { cwd: consumer, env }),
|
|
715
|
+
failure("dependency")
|
|
716
|
+
);
|
|
717
|
+
const hoisted = join(consumer, "node_modules", "undeclared-only");
|
|
718
|
+
mkdirSync(hoisted, { recursive: true });
|
|
719
|
+
writeFileSync(
|
|
720
|
+
join(hoisted, "package.json"),
|
|
721
|
+
JSON.stringify({ name: "undeclared-only", type: "module", exports: "./index.js" })
|
|
722
|
+
);
|
|
723
|
+
writeFileSync(join(hoisted, "index.js"), "export const value=true;");
|
|
724
|
+
writeFileSync(join(esm, "index.js"), "await import('undeclared-only');");
|
|
725
|
+
await assert.rejects(
|
|
726
|
+
helper.runOwnedProcess(process.execPath, args, { cwd: consumer, env }),
|
|
727
|
+
failure("dependency")
|
|
728
|
+
);
|
|
729
|
+
} finally {
|
|
730
|
+
f.cleanup();
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
);
|
|
734
|
+
test(
|
|
735
|
+
"synthetic cancellation kills an observed resistant descendant after its parent exits",
|
|
736
|
+
{ tags: ["release"], timeout: 5e3 },
|
|
737
|
+
async () => {
|
|
665
738
|
const f = fixture();
|
|
666
739
|
const cancellation = new AbortController();
|
|
667
740
|
let quiescent = false;
|
|
668
741
|
try {
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
});
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
742
|
+
const env = helper.consumerEnvironment(f.directory, process.execPath);
|
|
743
|
+
const descendant = join(f.directory, "descendant.cjs");
|
|
744
|
+
writeFileSync(
|
|
745
|
+
descendant,
|
|
746
|
+
"process.on('SIGTERM',()=>{});require('node:fs').writeFileSync('ready',String(process.pid));setInterval(()=>{},1000);"
|
|
747
|
+
);
|
|
748
|
+
const parent = join(f.directory, "parent.cjs");
|
|
749
|
+
writeFileSync(
|
|
750
|
+
parent,
|
|
751
|
+
"require('node:child_process').spawn(process.execPath,[process.argv[2]],{stdio:['ignore',process.stdout,process.stderr]});setInterval(()=>{},1000);"
|
|
752
|
+
);
|
|
753
|
+
const running = helper.runOwnedProcess(process.execPath, [parent, descendant], {
|
|
754
|
+
cwd: f.directory,
|
|
755
|
+
env,
|
|
756
|
+
signal: cancellation.signal
|
|
757
|
+
});
|
|
758
|
+
for (let i = 0; i < 100; i++) {
|
|
759
|
+
try {
|
|
760
|
+
readFileSync(join(f.directory, "ready"));
|
|
761
|
+
break;
|
|
762
|
+
} catch {
|
|
763
|
+
await delay(10);
|
|
688
764
|
}
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
finally {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
test(
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
765
|
+
}
|
|
766
|
+
await delay(150);
|
|
767
|
+
cancellation.abort();
|
|
768
|
+
await assert.rejects(running, (error) => {
|
|
769
|
+
const e = error;
|
|
770
|
+
quiescent = e.evidence.quiescent === true;
|
|
771
|
+
assert.equal(e.code, "cancelled");
|
|
772
|
+
assert.equal(quiescent, true);
|
|
773
|
+
assert.ok((e.evidence.observed?.length ?? 0) >= 2);
|
|
774
|
+
return true;
|
|
775
|
+
});
|
|
776
|
+
} finally {
|
|
777
|
+
if (quiescent) f.cleanup();
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
);
|
|
781
|
+
test("synthetic unknown or reused process identity is refused rather than signaled", () => {
|
|
782
|
+
const known = [{ pid: 1, birth: "first", rssBytes: 0 }];
|
|
783
|
+
assert.deepEqual(helper.ownedSignalTargets(known, null), { targets: [], unknown: true });
|
|
784
|
+
assert.deepEqual(helper.ownedSignalTargets(known, [{ pid: 1, birth: "reused", rssBytes: 0 }]), {
|
|
785
|
+
targets: [],
|
|
786
|
+
unknown: true
|
|
787
|
+
});
|
|
712
788
|
});
|
|
713
|
-
test.each([
|
|
789
|
+
test.each(["created", "prepared", "cleanup", "unknown-quiescence"])(
|
|
790
|
+
"synthetic disposable %s failure preserves receipt and owned cleanup evidence",
|
|
791
|
+
async (kind) => {
|
|
714
792
|
const f = fixture();
|
|
715
793
|
let retained;
|
|
716
794
|
try {
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
}
|
|
795
|
+
const receipt = {
|
|
796
|
+
status: "incomplete",
|
|
797
|
+
qualified: false,
|
|
798
|
+
phases: [{ phase: "prior", synthetic: true }],
|
|
799
|
+
cleanup: null
|
|
800
|
+
};
|
|
801
|
+
const result = await helper.withDisposableConsumer(
|
|
802
|
+
f.root,
|
|
803
|
+
process.execPath,
|
|
804
|
+
"a".repeat(64),
|
|
805
|
+
receipt,
|
|
806
|
+
async (context) => {
|
|
807
|
+
if (kind === "unknown-quiescence") context.setQuiescent(false);
|
|
808
|
+
return receipt;
|
|
809
|
+
},
|
|
810
|
+
{
|
|
811
|
+
fault: (phase, directory) => {
|
|
812
|
+
retained = directory;
|
|
813
|
+
if (kind === "cleanup" && phase === "cleanup")
|
|
814
|
+
writeFileSync(join(directory, "owned.json"), "corrupt marker");
|
|
815
|
+
if (kind === phase && (kind === "created" || kind === "prepared"))
|
|
816
|
+
throw Object.assign(new Error("fictional permission failure"), { code: "EACCES" });
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
);
|
|
820
|
+
assert.equal(result.status, "incomplete");
|
|
821
|
+
assert.equal(result.qualified, false);
|
|
822
|
+
assert.deepEqual(result.phases, [{ phase: "prior", synthetic: true }]);
|
|
823
|
+
assert.equal(result.cleanup?.removed, kind === "created" || kind === "prepared");
|
|
824
|
+
if (kind === "cleanup") assert.ok(result.cleanup?.failure);
|
|
825
|
+
if (kind === "unknown-quiescence") assert.equal(result.cleanup?.quiescent, false);
|
|
826
|
+
} finally {
|
|
827
|
+
if (retained) rmSync(retained, { recursive: true, force: true });
|
|
828
|
+
f.cleanup();
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
);
|
|
752
832
|
test.each([
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
])(
|
|
833
|
+
"startup",
|
|
834
|
+
"schema",
|
|
835
|
+
"matching-schema",
|
|
836
|
+
"resistant-startup",
|
|
837
|
+
"resistant-schema",
|
|
838
|
+
"resistant-matching-schema"
|
|
839
|
+
])(
|
|
840
|
+
"synthetic packaged stdio MCP %s exercises its explicit mocked schema and shutdown boundary",
|
|
841
|
+
{ tags: ["release"] },
|
|
842
|
+
async (kind) => {
|
|
760
843
|
const f = fixture();
|
|
761
844
|
let quiescent = true;
|
|
762
845
|
try {
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
846
|
+
const consumer = join(f.directory, "consumer");
|
|
847
|
+
mkdirSync(consumer);
|
|
848
|
+
writeFileSync(join(consumer, "package.json"), JSON.stringify({ type: "module" }));
|
|
849
|
+
const pkg = join(consumer, "node_modules", "@aviaratech", "ai-delivery");
|
|
850
|
+
mkdirSync(pkg, { recursive: true });
|
|
851
|
+
writeFileSync(
|
|
852
|
+
join(pkg, "package.json"),
|
|
853
|
+
JSON.stringify({ name: "@aviaratech/ai-delivery", type: "module", exports: { "./mcp": "./mcp.js" } })
|
|
854
|
+
);
|
|
855
|
+
writeFileSync(join(pkg, "mcp.js"), "export const AI_DELIVERY_MCP_TOOLS=[];");
|
|
856
|
+
const zod = join(pkg, "node_modules", "zod");
|
|
857
|
+
mkdirSync(zod, { recursive: true });
|
|
858
|
+
writeFileSync(join(zod, "package.json"), JSON.stringify({ name: "zod", main: "index.cjs" }));
|
|
859
|
+
writeFileSync(join(zod, "index.cjs"), "exports.toJSONSchema=()=>({});");
|
|
860
|
+
const launcher = join(consumer, "fictional-packaged-launcher.cjs");
|
|
861
|
+
const startup = kind === "startup";
|
|
862
|
+
const resistant = kind.startsWith("resistant-");
|
|
863
|
+
const tools = ["matching-schema", "resistant-matching-schema"].includes(kind) ? [] : [{ name: "unexpected", inputSchema: {} }];
|
|
864
|
+
const server = `process.on('SIGTERM',${resistant ? "()=>{}" : "()=>process.exit(0)"});
|
|
781
865
|
require('node:readline').createInterface({input:process.stdin}).on('line',line=>{
|
|
782
866
|
const m=JSON.parse(line);if(m.id===1)console.log(JSON.stringify({jsonrpc:'2.0',id:1,result:{serverInfo:{version:'0.0.0'}}}));
|
|
783
867
|
if(m.id===2)console.log(JSON.stringify({jsonrpc:'2.0',id:2,result:{tools:${JSON.stringify(tools)}}}));
|
|
784
868
|
});`;
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
869
|
+
writeFileSync(
|
|
870
|
+
launcher,
|
|
871
|
+
startup ? "process.exit(1);" : kind === "resistant-startup" ? "process.on('SIGTERM',()=>{});console.log('fictional startup banner');setInterval(()=>{},1000);" : server
|
|
872
|
+
);
|
|
873
|
+
const probe = join(consumer, "owned-mcp.mjs");
|
|
874
|
+
writeFileSync(probe, helper.MCP_PROBE);
|
|
875
|
+
quiescent = false;
|
|
876
|
+
const running = helper.runOwnedProcess(process.execPath, [probe, launcher, "0.0.0"], {
|
|
877
|
+
cwd: consumer,
|
|
878
|
+
env: helper.consumerEnvironment(f.directory, process.execPath)
|
|
879
|
+
});
|
|
880
|
+
if (kind === "matching-schema") {
|
|
881
|
+
const result = await running;
|
|
882
|
+
quiescent = result.evidence.quiescent;
|
|
883
|
+
assert.deepEqual(helper.parseJsonOutput(result.stdout), {
|
|
884
|
+
toolCount: 0,
|
|
885
|
+
schemas: [],
|
|
886
|
+
protocol: "stdio initialize/tools/list",
|
|
887
|
+
version: "0.0.0"
|
|
796
888
|
});
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
});
|
|
813
|
-
}
|
|
814
|
-
finally {
|
|
815
|
-
if (quiescent)
|
|
816
|
-
f.cleanup();
|
|
817
|
-
else
|
|
818
|
-
recordSynthetic({ kind: 'fixture-retained', directory: f.directory, quiescent: false });
|
|
819
|
-
}
|
|
820
|
-
});
|
|
821
|
-
test.each(['sourceManifestSha256', 'sourceLockSha256'])('synthetic integrated %s digest drift cannot reuse an older archive as candidate proof', (field) => {
|
|
889
|
+
assert.equal(result.evidence.quiescent, true);
|
|
890
|
+
} else
|
|
891
|
+
await assert.rejects(running, (error) => {
|
|
892
|
+
quiescent = error.evidence.quiescent === true;
|
|
893
|
+
return failure(kind === "resistant-matching-schema" ? "cleanup" : "schema")(error) && quiescent;
|
|
894
|
+
});
|
|
895
|
+
} finally {
|
|
896
|
+
if (quiescent) f.cleanup();
|
|
897
|
+
else recordSynthetic({ kind: "fixture-retained", directory: f.directory, quiescent: false });
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
test.each(["sourceManifestSha256", "sourceLockSha256"])(
|
|
902
|
+
"synthetic integrated %s digest drift cannot reuse an older archive as candidate proof",
|
|
903
|
+
(field) => {
|
|
822
904
|
const f = fixture();
|
|
823
905
|
try {
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
//# sourceMappingURL=currentConsumer.test.js.map
|
|
906
|
+
const contract = f.make();
|
|
907
|
+
contract[field] = "a".repeat(64);
|
|
908
|
+
assert.throws(() => helper.inspectCandidate(contract), failure("source-identity"));
|
|
909
|
+
} finally {
|
|
910
|
+
f.cleanup();
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
);
|
|
914
|
+
//# sourceMappingURL=currentConsumer.test.js.map
|