@aviaratech/ai-delivery 0.3.35 → 0.3.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (301) hide show
  1. package/CONTRIBUTING.md +12 -206
  2. package/README.md +56 -554
  3. package/dist/agent.d.ts +1 -3
  4. package/dist/agent.js +74 -16
  5. package/dist/agent.js.map +7 -1
  6. package/dist/agentReadiness.test.js +73 -67
  7. package/dist/agentReadiness.test.js.map +7 -1
  8. package/dist/boardReconcile.test.js +1651 -1590
  9. package/dist/boardReconcile.test.js.map +7 -1
  10. package/dist/build.test.js +130 -0
  11. package/dist/build.test.js.map +7 -0
  12. package/dist/callerErrors.test.js +91 -0
  13. package/dist/callerErrors.test.js.map +7 -0
  14. package/dist/cli.js +389 -517
  15. package/dist/cli.js.map +7 -1
  16. package/dist/cliResult.d.ts +2 -2
  17. package/dist/cliResult.js +42 -45
  18. package/dist/cliResult.js.map +7 -1
  19. package/dist/cliResult.test.js +424 -369
  20. package/dist/cliResult.test.js.map +7 -1
  21. package/dist/config/deliveryConfig.d.ts +288 -14
  22. package/dist/config/deliveryConfig.js +472 -390
  23. package/dist/config/deliveryConfig.js.map +7 -1
  24. package/dist/config/deliveryConfig.test.js +773 -649
  25. package/dist/config/deliveryConfig.test.js.map +7 -1
  26. package/dist/contributorChecks.test.js +1694 -916
  27. package/dist/contributorChecks.test.js.map +7 -1
  28. package/dist/currentConsumer.test.js +819 -737
  29. package/dist/currentConsumer.test.js.map +7 -1
  30. package/dist/currentTrackingScenario.test.js +499 -479
  31. package/dist/currentTrackingScenario.test.js.map +7 -1
  32. package/dist/delivery/common.js +160 -172
  33. package/dist/delivery/common.js.map +7 -1
  34. package/dist/delivery/delivery.test.js +509 -431
  35. package/dist/delivery/delivery.test.js.map +7 -1
  36. package/dist/delivery/evidence.d.ts +2 -2
  37. package/dist/delivery/evidence.js +133 -120
  38. package/dist/delivery/evidence.js.map +7 -1
  39. package/dist/delivery/index.js +7 -2
  40. package/dist/delivery/index.js.map +7 -1
  41. package/dist/delivery/legacy.js +65 -5
  42. package/dist/delivery/legacy.js.map +7 -1
  43. package/dist/delivery/policy.d.ts +10 -10
  44. package/dist/delivery/policy.js +211 -238
  45. package/dist/delivery/policy.js.map +7 -1
  46. package/dist/delivery/stage.d.ts +18 -18
  47. package/dist/delivery/stage.js +220 -235
  48. package/dist/delivery/stage.js.map +7 -1
  49. package/dist/deliveryBoard.d.ts +74 -0
  50. package/dist/deliveryBoard.js +644 -0
  51. package/dist/deliveryBoard.js.map +7 -0
  52. package/dist/deliveryBoard.test.js +649 -0
  53. package/dist/deliveryBoard.test.js.map +7 -0
  54. package/dist/deliveryHealth.test.js +179 -155
  55. package/dist/deliveryHealth.test.js.map +7 -1
  56. package/dist/dependencyCompatibility.test.js +154 -140
  57. package/dist/dependencyCompatibility.test.js.map +7 -1
  58. package/dist/directoryIndependent.test.js +417 -383
  59. package/dist/directoryIndependent.test.js.map +7 -1
  60. package/dist/dispatch.d.ts +16 -11
  61. package/dist/dispatch.js +316 -354
  62. package/dist/dispatch.js.map +7 -1
  63. package/dist/errors.d.ts +3 -3
  64. package/dist/errors.js +103 -96
  65. package/dist/errors.js.map +7 -1
  66. package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
  67. package/dist/fixtures/deliveryBoardReplay.js +617 -0
  68. package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
  69. package/dist/fixtures/discovery.d.ts +63 -23
  70. package/dist/fixtures/discovery.js +96 -90
  71. package/dist/fixtures/discovery.js.map +7 -1
  72. package/dist/fixtures/inertEntrypointChild.js +57 -56
  73. package/dist/fixtures/inertEntrypointChild.js.map +7 -1
  74. package/dist/fixtures/inertEntrypoints.d.ts +1 -1
  75. package/dist/fixtures/inertEntrypoints.js +321 -276
  76. package/dist/fixtures/inertEntrypoints.js.map +7 -1
  77. package/dist/fixtures/inertTarget.d.ts +78 -7
  78. package/dist/fixtures/inertTarget.js +769 -691
  79. package/dist/fixtures/inertTarget.js.map +7 -1
  80. package/dist/fixtures/issue63.d.ts +4 -3
  81. package/dist/fixtures/issue63.js +260 -274
  82. package/dist/fixtures/issue63.js.map +7 -1
  83. package/dist/fixtures/issueProjectItems.d.ts +20 -0
  84. package/dist/fixtures/issueProjectItems.js +15 -0
  85. package/dist/fixtures/issueProjectItems.js.map +7 -0
  86. package/dist/fixtures/readView.d.ts +120 -0
  87. package/dist/fixtures/readView.js +172 -0
  88. package/dist/fixtures/readView.js.map +7 -0
  89. package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
  90. package/dist/fixtures/recordedGitHubFlows.js +109 -0
  91. package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
  92. package/dist/genericCompatibility.test.js +64 -55
  93. package/dist/genericCompatibility.test.js.map +7 -1
  94. package/dist/git.d.ts +0 -3
  95. package/dist/git.js +59 -76
  96. package/dist/git.js.map +7 -1
  97. package/dist/gitProcess.d.ts +1 -1
  98. package/dist/gitProcess.js +58 -53
  99. package/dist/gitProcess.js.map +7 -1
  100. package/dist/github/client.d.ts +2 -2
  101. package/dist/github/client.js +484 -379
  102. package/dist/github/client.js.map +7 -1
  103. package/dist/github/commandIdentityPolicy.js +42 -52
  104. package/dist/github/commandIdentityPolicy.js.map +7 -1
  105. package/dist/github/discovery.d.ts +1 -0
  106. package/dist/github/discovery.js +197 -215
  107. package/dist/github/discovery.js.map +7 -1
  108. package/dist/github/discovery.test.js +223 -177
  109. package/dist/github/discovery.test.js.map +7 -1
  110. package/dist/github/issueHistory.d.ts +2 -2
  111. package/dist/github/issueHistory.js +117 -125
  112. package/dist/github/issueHistory.js.map +7 -1
  113. package/dist/github/machineAuth.d.ts +1 -1
  114. package/dist/github/machineAuth.js +126 -117
  115. package/dist/github/machineAuth.js.map +7 -1
  116. package/dist/github/machineAuth.test.js +755 -639
  117. package/dist/github/machineAuth.test.js.map +7 -1
  118. package/dist/github/nativeIssueMetadata.js +286 -273
  119. package/dist/github/nativeIssueMetadata.js.map +7 -1
  120. package/dist/github/projectDelivery.d.ts +18 -2
  121. package/dist/github/projectDelivery.js +615 -557
  122. package/dist/github/projectDelivery.js.map +7 -1
  123. package/dist/github/relationships.js +433 -389
  124. package/dist/github/relationships.js.map +7 -1
  125. package/dist/github/repo.d.ts +1 -0
  126. package/dist/github/repo.js +123 -96
  127. package/dist/github/repo.js.map +7 -1
  128. package/dist/index.js +3 -3
  129. package/dist/index.js.map +7 -1
  130. package/dist/issue.d.ts +40 -9
  131. package/dist/issue.js +2102 -1742
  132. package/dist/issue.js.map +7 -1
  133. package/dist/issue63History.test.js +40 -42
  134. package/dist/issue63History.test.js.map +7 -1
  135. package/dist/issue63Routes.test.js +154 -143
  136. package/dist/issue63Routes.test.js.map +7 -1
  137. package/dist/issueBatchUpdate.test.js +989 -885
  138. package/dist/issueBatchUpdate.test.js.map +7 -1
  139. package/dist/issueBlockerGuard.test.js +262 -226
  140. package/dist/issueBlockerGuard.test.js.map +7 -1
  141. package/dist/issueContract.d.ts +23 -4
  142. package/dist/issueContract.js +416 -395
  143. package/dist/issueContract.js.map +7 -1
  144. package/dist/issueContract.test.d.ts +4 -3
  145. package/dist/issueContract.test.js +358 -321
  146. package/dist/issueContract.test.js.map +7 -1
  147. package/dist/issueDates.test.js +235 -233
  148. package/dist/issueDates.test.js.map +7 -1
  149. package/dist/issueInfoReadback.test.js +304 -190
  150. package/dist/issueInfoReadback.test.js.map +7 -1
  151. package/dist/issueIntake.test.js +1938 -1732
  152. package/dist/issueIntake.test.js.map +7 -1
  153. package/dist/issueJournal.d.ts +40 -19
  154. package/dist/issueJournal.js +229 -138
  155. package/dist/issueJournal.js.map +7 -1
  156. package/dist/issueJournal.test.js +605 -422
  157. package/dist/issueJournal.test.js.map +7 -1
  158. package/dist/issueRollup.test.d.ts +1 -0
  159. package/dist/issueRollup.test.js +476 -0
  160. package/dist/issueRollup.test.js.map +7 -0
  161. package/dist/issueTracking.test.js +1059 -989
  162. package/dist/issueTracking.test.js.map +7 -1
  163. package/dist/issueWriteRecovery.test.d.ts +1 -0
  164. package/dist/issueWriteRecovery.test.js +260 -0
  165. package/dist/issueWriteRecovery.test.js.map +7 -0
  166. package/dist/lifecycle.test.js +112 -441
  167. package/dist/lifecycle.test.js.map +7 -1
  168. package/dist/logger.js +80 -74
  169. package/dist/logger.js.map +7 -1
  170. package/dist/mcp/index.js +116 -94
  171. package/dist/mcp/index.js.map +7 -1
  172. package/dist/mcp/tools.d.ts +252 -310
  173. package/dist/mcp/tools.js +235 -342
  174. package/dist/mcp/tools.js.map +7 -1
  175. package/dist/pluginAuthProbe.js +63 -52
  176. package/dist/pluginAuthProbe.js.map +7 -1
  177. package/dist/pluginAuthProbe.test.js +85 -62
  178. package/dist/pluginAuthProbe.test.js.map +7 -1
  179. package/dist/pluginCredentials.test.js +282 -259
  180. package/dist/pluginCredentials.test.js.map +7 -1
  181. package/dist/pluginDoctor.test.js +653 -588
  182. package/dist/pluginDoctor.test.js.map +7 -1
  183. package/dist/pluginInstaller.d.ts +7 -5
  184. package/dist/pluginInstaller.js +1173 -1229
  185. package/dist/pluginInstaller.js.map +7 -1
  186. package/dist/pluginInstaller.test.js +1842 -1423
  187. package/dist/pluginInstaller.test.js.map +7 -1
  188. package/dist/pluginPackaging.test.js +417 -413
  189. package/dist/pluginPackaging.test.js.map +7 -1
  190. package/dist/pr.d.ts +114 -131
  191. package/dist/pr.js +1314 -1327
  192. package/dist/pr.js.map +7 -1
  193. package/dist/pr.test.js +967 -653
  194. package/dist/pr.test.js.map +7 -1
  195. package/dist/prAssociation.test.js +2419 -1788
  196. package/dist/prAssociation.test.js.map +7 -1
  197. package/dist/prDispatch.test.js +123 -89
  198. package/dist/prDispatch.test.js.map +7 -1
  199. package/dist/readView.d.ts +184 -0
  200. package/dist/readView.js +218 -0
  201. package/dist/readView.js.map +7 -0
  202. package/dist/readView.test.d.ts +1 -0
  203. package/dist/readView.test.js +146 -0
  204. package/dist/readView.test.js.map +7 -0
  205. package/dist/releaseReconciliation.test.js +267 -288
  206. package/dist/releaseReconciliation.test.js.map +7 -1
  207. package/dist/releaseWorkflow.test.js +2493 -422
  208. package/dist/releaseWorkflow.test.js.map +7 -1
  209. package/dist/review.d.ts +738 -2
  210. package/dist/review.js +601 -348
  211. package/dist/review.js.map +7 -1
  212. package/dist/review.test.js +1218 -812
  213. package/dist/review.test.js.map +7 -1
  214. package/dist/reviewSubmit.test.d.ts +1 -0
  215. package/dist/reviewSubmit.test.js +747 -0
  216. package/dist/reviewSubmit.test.js.map +7 -0
  217. package/dist/services/agentReadinessService.js +42 -37
  218. package/dist/services/agentReadinessService.js.map +7 -1
  219. package/dist/services/blockerGuardService.js +188 -188
  220. package/dist/services/blockerGuardService.js.map +7 -1
  221. package/dist/services/boardReconcileService.d.ts +125 -125
  222. package/dist/services/boardReconcileService.js +1295 -1421
  223. package/dist/services/boardReconcileService.js.map +7 -1
  224. package/dist/services/deliveryHealthService.js +197 -199
  225. package/dist/services/deliveryHealthService.js.map +7 -1
  226. package/dist/services/legacyIssueMigration.js +263 -277
  227. package/dist/services/legacyIssueMigration.js.map +7 -1
  228. package/dist/stagedChecks.test.js +396 -194
  229. package/dist/stagedChecks.test.js.map +7 -1
  230. package/dist/start.test.js +99 -95
  231. package/dist/start.test.js.map +7 -1
  232. package/dist/stdoutRegression.test.js +321 -358
  233. package/dist/stdoutRegression.test.js.map +7 -1
  234. package/dist/targetPolicyDiscovery.test.js +141 -143
  235. package/dist/targetPolicyDiscovery.test.js.map +7 -1
  236. package/dist/targetPolicyEntrypoints.test.js +308 -269
  237. package/dist/targetPolicyEntrypoints.test.js.map +7 -1
  238. package/dist/targetPolicyLocal.test.js +580 -1051
  239. package/dist/targetPolicyLocal.test.js.map +7 -1
  240. package/dist/targetPolicyRoutes.test.js +274 -281
  241. package/dist/targetPolicyRoutes.test.js.map +7 -1
  242. package/dist/targetRepositoryExecution.test.d.ts +1 -0
  243. package/dist/targetRepositoryExecution.test.js +451 -0
  244. package/dist/targetRepositoryExecution.test.js.map +7 -0
  245. package/dist/terminalMessages.js +41 -35
  246. package/dist/terminalMessages.js.map +7 -1
  247. package/dist/toolOutput.d.ts +2 -0
  248. package/dist/toolOutput.js +36 -0
  249. package/dist/toolOutput.js.map +7 -0
  250. package/dist/toolOutput.test.d.ts +1 -0
  251. package/dist/toolOutput.test.js +240 -0
  252. package/dist/toolOutput.test.js.map +7 -0
  253. package/dist/utils/atomicJson.d.ts +0 -2
  254. package/dist/utils/atomicJson.js +81 -77
  255. package/dist/utils/atomicJson.js.map +7 -1
  256. package/dist/utils/filesystem.d.ts +0 -8
  257. package/dist/utils/filesystem.js +5 -19
  258. package/dist/utils/filesystem.js.map +7 -1
  259. package/dist/utils/lockfile.js +68 -71
  260. package/dist/utils/lockfile.js.map +7 -1
  261. package/dist/verification.d.ts +1 -54
  262. package/dist/verification.js +976 -1941
  263. package/dist/verification.js.map +7 -1
  264. package/dist/verificationGate.test.js +127 -117
  265. package/dist/verificationGate.test.js.map +7 -1
  266. package/dist/version.js +45 -24
  267. package/dist/version.js.map +7 -1
  268. package/package.json +9 -8
  269. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  270. package/plugins/ai-delivery/README.md +47 -156
  271. package/plugins/ai-delivery/plugin.json +1 -1
  272. package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +238 -44
  273. package/plugins/ai-delivery/runtime/dist/cli.js +351 -115
  274. package/plugins/ai-delivery/runtime/package.json +1 -1
  275. package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
  276. package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
  277. package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
  278. package/dist/investigationCompletion.test.js +0 -728
  279. package/dist/investigationCompletion.test.js.map +0 -1
  280. package/dist/services/deliveryAdmission.d.ts +0 -49
  281. package/dist/services/deliveryAdmission.js +0 -165
  282. package/dist/services/deliveryAdmission.js.map +0 -1
  283. package/dist/services/worktreeRegistry.d.ts +0 -434
  284. package/dist/services/worktreeRegistry.js +0 -1248
  285. package/dist/services/worktreeRegistry.js.map +0 -1
  286. package/dist/setup.d.ts +0 -60
  287. package/dist/setup.js +0 -585
  288. package/dist/setup.js.map +0 -1
  289. package/dist/setup.test.js +0 -3329
  290. package/dist/setup.test.js.map +0 -1
  291. package/dist/worktree.d.ts +0 -28
  292. package/dist/worktree.js +0 -188
  293. package/dist/worktree.js.map +0 -1
  294. package/dist/worktreeTransition.d.ts +0 -211
  295. package/dist/worktreeTransition.js +0 -1037
  296. package/dist/worktreeTransition.js.map +0 -1
  297. package/dist/worktreeTransition.test.js +0 -1191
  298. package/dist/worktreeTransition.test.js.map +0 -1
  299. /package/dist/{investigationCompletion.test.d.ts → build.test.d.ts} +0 -0
  300. /package/dist/{setup.test.d.ts → callerErrors.test.d.ts} +0 -0
  301. /package/dist/{worktreeTransition.test.d.ts → deliveryBoard.test.d.ts} +0 -0
@@ -1,318 +1,297 @@
1
- import assert from 'node:assert/strict';
2
- import { createHash } from 'node:crypto';
3
- import { readFileSync } from 'node:fs';
4
- import { posix } from 'node:path';
5
- import { Script } from 'node:vm';
6
- import { test } from 'vitest';
7
- const workflow = readFileSync(new URL('../.github/workflows/release.yml', import.meta.url), 'utf8');
1
+ import assert from "node:assert/strict";
2
+ import { createHash } from "node:crypto";
3
+ import { readFileSync } from "node:fs";
4
+ import { posix } from "node:path";
5
+ import { Script } from "node:vm";
6
+ import { test } from "vitest";
7
+ const workflow = readFileSync(new URL("../.github/workflows/release.yml", import.meta.url), "utf8");
8
8
  const scripts = [...workflow.matchAll(/node --input-type=module <<'JS'\n([\s\S]*?)\n\s+JS/gu)];
9
9
  const publishedScript = scripts.at(-1)?.[1];
10
- assert.ok(publishedScript, 'The actual release workflow must contain its publication script.');
11
- // Substitute only external imports; all publication decisions and guards execute unchanged.
12
- const program = publishedScript.replace(/^\s*import .+;\n/gmu, '');
13
- const archive = Buffer.from('independently reviewed synthetic archive');
14
- const digest = createHash('sha256').update(archive).digest('hex');
15
- const integrity = `sha512-${createHash('sha512').update(archive).digest('base64')}`;
16
- const source = 'a'.repeat(40);
17
- const registry = 'https://registry.npmjs.org';
10
+ assert.ok(publishedScript, "The actual release workflow must contain its publication script.");
11
+ const program = publishedScript.replace(/^\s*import .+;\n/gmu, "");
12
+ const archive = Buffer.from("independently reviewed synthetic archive");
13
+ const digest = createHash("sha256").update(archive).digest("hex");
14
+ const integrity = `sha512-${createHash("sha512").update(archive).digest("base64")}`;
15
+ const source = "a".repeat(40);
16
+ const registry = "https://registry.npmjs.org";
18
17
  const packageUrl = `${registry}/@aviaratech%2fai-delivery`;
19
- const version = '0.8.1';
20
- const archivePath = posix.resolve('/synthetic/package-artifact', `aviaratech-ai-delivery-${version}.tgz`);
18
+ const version = "0.8.1";
19
+ const archivePath = posix.resolve("/synthetic/package-artifact", `aviaratech-ai-delivery-${version}.tgz`);
21
20
  const pkg = {
22
- name: '@aviaratech/ai-delivery',
23
- version,
24
- private: false,
25
- license: 'MIT',
26
- repository: { url: 'git+https://github.com/aviaratech/ai-delivery.git' },
21
+ name: "@aviaratech/ai-delivery",
22
+ version,
23
+ private: false,
24
+ license: "MIT",
25
+ repository: { url: "git+https://github.com/aviaratech/ai-delivery.git" }
27
26
  };
28
27
  const manifest = {
29
- name: pkg.name,
30
- version,
31
- dist: {
32
- integrity,
33
- tarball: `${registry}/@aviaratech/ai-delivery/-/ai-delivery-${version}.tgz`,
34
- attestations: { provenance: { predicateType: 'https://slsa.dev/provenance/v1' } },
35
- },
28
+ name: pkg.name,
29
+ version,
30
+ dist: {
31
+ integrity,
32
+ tarball: `${registry}/@aviaratech/ai-delivery/-/ai-delivery-${version}.tgz`,
33
+ attestations: { provenance: { predicateType: "https://slsa.dev/provenance/v1" } }
34
+ }
36
35
  };
37
36
  async function runRelease(fixture = {}) {
38
- let publications = 0;
39
- let reads = 0;
40
- let elapsed = 0;
41
- const requests = [];
42
- const commands = [];
43
- const waits = [];
44
- const timeouts = [];
45
- const messages = [];
46
- const ready = (at = 1) => reads >= at;
47
- const published = () => fixture.occupied || publications > 0;
48
- const visibleManifest = (indexed = false) => {
49
- const value = structuredClone(manifest);
50
- if (!ready(fixture.provenanceReadyAt))
51
- Reflect.deleteProperty(value.dist, 'attestations');
52
- if (fixture.conflict === 'name')
53
- value.name = '@someone/else';
54
- if (fixture.conflict === 'version')
55
- value.version = '0.8.0';
56
- if (fixture.conflict === 'integrity' || (indexed && fixture.conflict === 'index'))
57
- value.dist.integrity = 'sha512-conflicting';
58
- if (fixture.conflict === 'provenance')
59
- value.dist.attestations = { provenance: { predicateType: 'https://unexpected.example/predicate' } };
60
- if (fixture.conflict === 'origin')
61
- value.dist.tarball = 'https://unexpected.example/archive.tgz';
62
- if (fixture.conflict === 'credentials') {
63
- const tarball = new URL('/archive.tgz', registry);
64
- tarball.username = 'user';
65
- tarball.password = 'password';
66
- value.dist.tarball = tarball.href;
67
- }
68
- return value;
69
- };
70
- const fetch = async (input, options = {}) => {
71
- const url = String(input);
72
- requests.push({ url, method: options.method ?? 'GET', at: elapsed });
73
- assert.equal(options.redirect, 'error');
74
- elapsed += fixture.fetchDurationMs ?? 100;
75
- const phase = url.includes('api.github.com')
76
- ? 'main'
77
- : url === packageUrl
78
- ? 'index'
79
- : url === `${packageUrl}/${version}`
80
- ? 'version'
81
- : 'archive';
82
- if (phase === fixture.errorPhase && (published() || phase === 'main')) {
83
- if (fixture.networkFailure)
84
- throw new Error('synthetic network failure');
85
- return new Response(null, { status: fixture.errorStatus ?? 503 });
86
- }
87
- if (url === 'https://api.github.com/repos/aviaratech/ai-delivery/branches/main') {
88
- return Response.json({
89
- name: 'main',
90
- protected: true,
91
- commit: { sha: fixture.conflict === 'main' ? 'b'.repeat(40) : source },
92
- protection: { required_status_checks: { enforcement_level: 'everyone', contexts: ['checks', 'secrets'] } },
93
- });
94
- }
95
- if (url === `${packageUrl}/${version}`) {
96
- if (published())
97
- reads++;
98
- return published() && ready(fixture.versionReadyAt)
99
- ? fixture.oversizedManifest
100
- ? new Response('x'.repeat(4 * 1024 * 1024 + 1))
101
- : Response.json(visibleManifest())
102
- : new Response(null, { status: 404 });
103
- }
104
- if (url === manifest.dist.tarball) {
105
- if (fixture.bodyDeadlineExceeded) {
106
- return new Response(new ReadableStream({
107
- start: (controller) => {
108
- elapsed += 5 * 60_000;
109
- controller.error(new DOMException('Readback body timed out', 'TimeoutError'));
110
- },
111
- }));
37
+ let publications = 0;
38
+ let reads = 0;
39
+ let elapsed = 0;
40
+ const requests = [];
41
+ const commands = [];
42
+ const waits = [];
43
+ const timeouts = [];
44
+ const messages = [];
45
+ const ready = (at = 1) => reads >= at;
46
+ const published = () => fixture.occupied || publications > 0;
47
+ const visibleManifest = (indexed = false) => {
48
+ const value = structuredClone(manifest);
49
+ if (!ready(fixture.provenanceReadyAt)) Reflect.deleteProperty(value.dist, "attestations");
50
+ if (fixture.conflict === "name") value.name = "@someone/else";
51
+ if (fixture.conflict === "version") value.version = "0.8.0";
52
+ if (fixture.conflict === "integrity" || indexed && fixture.conflict === "index")
53
+ value.dist.integrity = "sha512-conflicting";
54
+ if (fixture.conflict === "provenance")
55
+ value.dist.attestations = { provenance: { predicateType: "https://unexpected.example/predicate" } };
56
+ if (fixture.conflict === "origin") value.dist.tarball = "https://unexpected.example/archive.tgz";
57
+ if (fixture.conflict === "credentials") {
58
+ const tarball = new URL("/archive.tgz", registry);
59
+ tarball.username = "user";
60
+ tarball.password = "password";
61
+ value.dist.tarball = tarball.href;
62
+ }
63
+ return value;
64
+ };
65
+ const fetch = async (input, options = {}) => {
66
+ const url = String(input);
67
+ requests.push({ url, method: options.method ?? "GET", at: elapsed });
68
+ assert.equal(options.redirect, "error");
69
+ elapsed += fixture.fetchDurationMs ?? 100;
70
+ const phase = url.includes("api.github.com") ? "main" : url === packageUrl ? "index" : url === `${packageUrl}/${version}` ? "version" : "archive";
71
+ if (phase === fixture.errorPhase && (published() || phase === "main")) {
72
+ if (fixture.networkFailure) throw new Error("synthetic network failure");
73
+ return new Response(null, { status: fixture.errorStatus ?? 503 });
74
+ }
75
+ if (url === "https://api.github.com/repos/aviaratech/ai-delivery/branches/main") {
76
+ return Response.json({
77
+ name: "main",
78
+ protected: true,
79
+ commit: { sha: fixture.conflict === "main" ? "b".repeat(40) : source },
80
+ protection: { required_status_checks: { enforcement_level: "everyone", contexts: ["checks", "secrets"] } }
81
+ });
82
+ }
83
+ if (url === `${packageUrl}/${version}`) {
84
+ if (published()) reads++;
85
+ return published() && ready(fixture.versionReadyAt) ? fixture.oversizedManifest ? new Response("x".repeat(4 * 1024 * 1024 + 1)) : Response.json(visibleManifest()) : new Response(null, { status: 404 });
86
+ }
87
+ if (url === manifest.dist.tarball) {
88
+ if (fixture.bodyDeadlineExceeded) {
89
+ return new Response(
90
+ new ReadableStream({
91
+ start: (controller) => {
92
+ elapsed += 5 * 6e4;
93
+ controller.error(new DOMException("Readback body timed out", "TimeoutError"));
112
94
  }
113
- return ready(fixture.archiveReadyAt)
114
- ? new Response(fixture.corruptArchive ? Buffer.from('conflicting registry bytes') : archive)
115
- : new Response(null, { status: 404 });
116
- }
117
- if (url === packageUrl) {
118
- return Response.json({
119
- name: pkg.name,
120
- 'dist-tags': {
121
- latest: published() && fixture.conflict === 'latest'
122
- ? '0.8.2'
123
- : published() && ready(fixture.latestReadyAt)
124
- ? version
125
- : '0.8.0',
126
- },
127
- versions: published() && ready(fixture.indexReadyAt) ? { [version]: visibleManifest(true) } : {},
128
- });
129
- }
130
- throw new Error(`Unexpected external request: ${url}`);
131
- };
132
- const context = {
133
- createHash,
134
- resolve: (path) => posix.resolve('/synthetic/package-artifact/unpacked/package', path),
135
- readFileSync: (path) => {
136
- assert.equal(path, archivePath);
137
- return archive;
138
- },
139
- spawnSync: (command, args) => {
140
- commands.push({ command, args: [...args] });
141
- assert.equal(command, 'npm');
142
- assert.equal(args[0], 'publish');
143
- assert.equal(args[1], archivePath);
144
- publications++;
145
- return { status: fixture.publishStatus === undefined ? 0 : fixture.publishStatus };
146
- },
147
- pkg,
148
- process: {
149
- env: {
150
- GITHUB_SHA: source,
151
- REVIEWED_SOURCE_SHA: source,
152
- RELEASE_VERSION: version,
153
- REVIEWED_ARCHIVE_SHA256: digest,
154
- GH_TOKEN: 'synthetic',
155
- },
156
- },
157
- fetch,
158
- AbortSignal: {
159
- timeout: (ms) => {
160
- timeouts.push(ms);
161
- return new AbortController().signal;
162
- },
163
- },
164
- URL,
165
- Buffer,
166
- performance: { now: () => elapsed },
167
- console: {
168
- log: (message) => {
169
- messages.push(String(message));
170
- },
171
- },
172
- setTimeout: (callback, ms) => {
173
- waits.push(ms);
174
- elapsed += ms;
175
- queueMicrotask(callback);
176
- return 0;
95
+ })
96
+ );
97
+ }
98
+ return ready(fixture.archiveReadyAt) ? new Response(fixture.corruptArchive ? Buffer.from("conflicting registry bytes") : archive) : new Response(null, { status: 404 });
99
+ }
100
+ if (url === packageUrl) {
101
+ return Response.json({
102
+ name: pkg.name,
103
+ "dist-tags": {
104
+ latest: published() && fixture.conflict === "latest" ? "0.8.2" : published() && ready(fixture.latestReadyAt) ? version : "0.8.0"
177
105
  },
178
- };
179
- let error = null;
180
- try {
181
- await new Script(`(async () => {${program}\n})()`).runInNewContext(context);
106
+ versions: published() && ready(fixture.indexReadyAt) ? { [version]: visibleManifest(true) } : {}
107
+ });
182
108
  }
183
- catch (failure) {
184
- error = String(failure);
109
+ throw new Error(`Unexpected external request: ${url}`);
110
+ };
111
+ const context = {
112
+ createHash,
113
+ resolve: (path) => posix.resolve("/synthetic/package-artifact/unpacked/package", path),
114
+ readFileSync: (path) => {
115
+ assert.equal(path, archivePath);
116
+ return archive;
117
+ },
118
+ spawnSync: (command, args) => {
119
+ commands.push({ command, args: [...args] });
120
+ assert.equal(command, "npm");
121
+ assert.equal(args[0], "publish");
122
+ assert.equal(args[1], archivePath);
123
+ publications++;
124
+ return { status: fixture.publishStatus === void 0 ? 0 : fixture.publishStatus };
125
+ },
126
+ pkg,
127
+ process: {
128
+ env: {
129
+ GITHUB_SHA: source,
130
+ REVIEWED_SOURCE_SHA: source,
131
+ RELEASE_VERSION: version,
132
+ REVIEWED_ARCHIVE_SHA256: digest,
133
+ GH_TOKEN: "synthetic"
134
+ }
135
+ },
136
+ fetch,
137
+ AbortSignal: {
138
+ timeout: (ms) => {
139
+ timeouts.push(ms);
140
+ return new AbortController().signal;
141
+ }
142
+ },
143
+ URL,
144
+ Buffer,
145
+ performance: { now: () => elapsed },
146
+ console: {
147
+ log: (message) => {
148
+ messages.push(String(message));
149
+ }
150
+ },
151
+ setTimeout: (callback, ms) => {
152
+ waits.push(ms);
153
+ elapsed += ms;
154
+ queueMicrotask(callback);
155
+ return 0;
185
156
  }
186
- return { error, publications, requests, commands, waits, timeouts, messages, elapsed, reads };
157
+ };
158
+ let error = null;
159
+ try {
160
+ await new Script(`(async () => {${program}
161
+ })()`).runInNewContext(context);
162
+ } catch (failure) {
163
+ error = String(failure);
164
+ }
165
+ return { error, publications, requests, commands, waits, timeouts, messages, elapsed, reads };
187
166
  }
188
- test('successful publication reconciles staggered registry visibility without another npm invocation', async () => {
189
- const result = await runRelease({
190
- versionReadyAt: 2,
191
- archiveReadyAt: 3,
192
- provenanceReadyAt: 4,
193
- indexReadyAt: 5,
194
- latestReadyAt: 6,
195
- });
196
- assert.equal(result.error, null);
197
- assert.equal(result.publications, 1);
198
- assert.equal(result.commands.length, 1);
199
- assert.deepEqual(result.commands[0]?.args, [
200
- 'publish',
201
- archivePath,
202
- '--ignore-scripts',
203
- '--access',
204
- 'public',
205
- '--tag',
206
- 'latest',
207
- '--registry',
208
- registry,
209
- '--provenance',
210
- ]);
211
- assert.ok(result.waits.length > 0, 'Stale reads must be paced.');
212
- assert.ok(result.waits.every((ms) => ms > 0));
213
- assert.ok(result.requests.every((request) => request.method === 'GET'));
214
- assert.ok(result.timeouts.every((ms) => ms > 0 && ms <= 30_000));
215
- assert.ok(result.messages.some((message) => /exact reviewed registry/iu.test(message)));
167
+ test("successful publication reconciles staggered registry visibility without another npm invocation", async () => {
168
+ const result = await runRelease({
169
+ versionReadyAt: 2,
170
+ archiveReadyAt: 3,
171
+ provenanceReadyAt: 4,
172
+ indexReadyAt: 5,
173
+ latestReadyAt: 6
174
+ });
175
+ assert.equal(result.error, null);
176
+ assert.equal(result.publications, 1);
177
+ assert.equal(result.commands.length, 1);
178
+ assert.deepEqual(result.commands[0]?.args, [
179
+ "publish",
180
+ archivePath,
181
+ "--ignore-scripts",
182
+ "--access",
183
+ "public",
184
+ "--tag",
185
+ "latest",
186
+ "--registry",
187
+ registry,
188
+ "--provenance"
189
+ ]);
190
+ assert.ok(result.waits.length > 0, "Stale reads must be paced.");
191
+ assert.ok(result.waits.every((ms) => ms > 0));
192
+ assert.ok(result.requests.every((request) => request.method === "GET"));
193
+ assert.ok(result.timeouts.every((ms) => ms > 0 && ms <= 3e4));
194
+ assert.ok(result.messages.some((message) => /exact reviewed registry/iu.test(message)));
216
195
  });
217
- test('matching occupied release reconciles latest without publication or retag', async () => {
218
- const result = await runRelease({ occupied: true, latestReadyAt: 3 });
219
- assert.equal(result.error, null);
220
- assert.equal(result.publications, 0);
221
- assert.deepEqual(result.commands, []);
222
- assert.ok(result.messages.some((message) => /no publication repeated/iu.test(message)));
196
+ test("matching occupied release reconciles latest without publication or retag", async () => {
197
+ const result = await runRelease({ occupied: true, latestReadyAt: 3 });
198
+ assert.equal(result.error, null);
199
+ assert.equal(result.publications, 0);
200
+ assert.deepEqual(result.commands, []);
201
+ assert.ok(result.messages.some((message) => /no publication repeated/iu.test(message)));
223
202
  });
224
- test('conflicting archive bytes fail immediately after one publication', async () => {
225
- const result = await runRelease({ corruptArchive: true });
226
- assert.match(result.error ?? '', /archive differs/iu);
227
- assert.equal(result.publications, 1);
228
- assert.deepEqual(result.waits, []);
203
+ test("conflicting archive bytes fail immediately after one publication", async () => {
204
+ const result = await runRelease({ corruptArchive: true });
205
+ assert.match(result.error ?? "", /archive differs/iu);
206
+ assert.equal(result.publications, 1);
207
+ assert.deepEqual(result.waits, []);
229
208
  });
230
- test('unresolved visibility reports the external reconciliation bound without republishing', async () => {
231
- const result = await runRelease({ versionReadyAt: Infinity });
232
- assert.match(result.error ?? '', /reconciliation unresolved/iu);
233
- assert.equal(result.publications, 1);
234
- assert.ok(result.waits.length > 0);
235
- assert.ok(result.elapsed < 10 * 60_000, 'Reconciliation must fit the existing external publish job.');
236
- assert.ok(result.timeouts.some((ms) => ms < 30_000), 'Requests must respect the remaining reconciliation allowance.');
209
+ test("unresolved visibility reports the external reconciliation bound without republishing", async () => {
210
+ const result = await runRelease({ versionReadyAt: Infinity });
211
+ assert.match(result.error ?? "", /reconciliation unresolved/iu);
212
+ assert.equal(result.publications, 1);
213
+ assert.ok(result.waits.length > 0);
214
+ assert.ok(result.elapsed < 10 * 6e4, "Reconciliation must fit the existing external publish job.");
215
+ assert.ok(
216
+ result.timeouts.some((ms) => ms < 3e4),
217
+ "Requests must respect the remaining reconciliation allowance."
218
+ );
237
219
  });
238
- test('an occupied version visible only in the index never enters publication', async () => {
239
- const result = await runRelease({ occupied: true, versionReadyAt: 3, latestReadyAt: 4 });
240
- assert.equal(result.error, null);
241
- assert.deepEqual(result.commands, []);
242
- assert.ok(result.waits.length > 0);
220
+ test("an occupied version visible only in the index never enters publication", async () => {
221
+ const result = await runRelease({ occupied: true, versionReadyAt: 3, latestReadyAt: 4 });
222
+ assert.equal(result.error, null);
223
+ assert.deepEqual(result.commands, []);
224
+ assert.ok(result.waits.length > 0);
243
225
  });
244
226
  for (const conflict of [
245
- 'name',
246
- 'version',
247
- 'integrity',
248
- 'provenance',
249
- 'origin',
250
- 'credentials',
251
- 'index',
252
- 'latest',
227
+ "name",
228
+ "version",
229
+ "integrity",
230
+ "provenance",
231
+ "origin",
232
+ "credentials",
233
+ "index",
234
+ "latest"
253
235
  ]) {
254
- test(`present ${conflict} conflict is refused without another publication`, async () => {
255
- const result = await runRelease({ conflict });
256
- assert.match(result.error ?? '', /differs|unexpected|advanced/iu);
257
- assert.equal(result.publications, 1);
258
- // The package index is initially absent; its conflict is observed on the second read.
259
- if (conflict !== 'index')
260
- assert.deepEqual(result.waits, []);
261
- else
262
- assert.equal(result.waits.length, 1);
263
- });
236
+ test(`present ${conflict} conflict is refused without another publication`, async () => {
237
+ const result = await runRelease({ conflict });
238
+ assert.match(result.error ?? "", /differs|unexpected|advanced/iu);
239
+ assert.equal(result.publications, 1);
240
+ if (conflict !== "index") assert.deepEqual(result.waits, []);
241
+ else assert.equal(result.waits.length, 1);
242
+ });
264
243
  }
265
- for (const errorPhase of ['version', 'index', 'archive']) {
266
- for (const errorStatus of [401, 403, 429, 503]) {
267
- test(`${errorPhase} HTTP ${errorStatus} remains a permanent failure`, async () => {
268
- const result = await runRelease({ errorPhase, errorStatus });
269
- assert.match(result.error ?? '', new RegExp(`readback failed: ${errorStatus}`, 'u'));
270
- assert.equal(result.publications, 1);
271
- assert.deepEqual(result.waits, []);
272
- });
273
- }
244
+ for (const errorPhase of ["version", "index", "archive"]) {
245
+ for (const errorStatus of [401, 403, 429, 503]) {
246
+ test(`${errorPhase} HTTP ${errorStatus} remains a permanent failure`, async () => {
247
+ const result = await runRelease({ errorPhase, errorStatus });
248
+ assert.match(result.error ?? "", new RegExp(`readback failed: ${errorStatus}`, "u"));
249
+ assert.equal(result.publications, 1);
250
+ assert.deepEqual(result.waits, []);
251
+ });
252
+ }
274
253
  }
275
- test('network failure is not retried as propagation', async () => {
276
- const result = await runRelease({ errorPhase: 'version', networkFailure: true });
277
- assert.match(result.error ?? '', /synthetic network failure/u);
278
- assert.equal(result.publications, 1);
279
- assert.deepEqual(result.waits, []);
254
+ test("network failure is not retried as propagation", async () => {
255
+ const result = await runRelease({ errorPhase: "version", networkFailure: true });
256
+ assert.match(result.error ?? "", /synthetic network failure/u);
257
+ assert.equal(result.publications, 1);
258
+ assert.deepEqual(result.waits, []);
280
259
  });
281
260
  for (const publishStatus of [1, null]) {
282
- test(`publish status ${publishStatus} remains ambiguous after matching readback`, async () => {
283
- const result = await runRelease({ publishStatus, versionReadyAt: 3 });
284
- assert.match(result.error ?? '', /failed or was ambiguous/iu);
285
- assert.equal(result.publications, 1);
286
- assert.ok(result.messages.some((message) => message.includes(`"status":${publishStatus}`)));
287
- assert.ok(result.messages.some((message) => /exact reviewed registry/iu.test(message)));
288
- });
261
+ test(`publish status ${publishStatus} remains ambiguous after matching readback`, async () => {
262
+ const result = await runRelease({ publishStatus, versionReadyAt: 3 });
263
+ assert.match(result.error ?? "", /failed or was ambiguous/iu);
264
+ assert.equal(result.publications, 1);
265
+ assert.ok(result.messages.some((message) => message.includes(`"status":${publishStatus}`)));
266
+ assert.ok(result.messages.some((message) => /exact reviewed registry/iu.test(message)));
267
+ });
289
268
  }
290
- test('an occupied conflicting release is never republished', async () => {
291
- const result = await runRelease({ occupied: true, conflict: 'integrity' });
292
- assert.match(result.error ?? '', /integrity differs/iu);
293
- assert.deepEqual(result.commands, []);
269
+ test("an occupied conflicting release is never republished", async () => {
270
+ const result = await runRelease({ occupied: true, conflict: "integrity" });
271
+ assert.match(result.error ?? "", /integrity differs/iu);
272
+ assert.deepEqual(result.commands, []);
294
273
  });
295
- test('protected source drift refuses publication', async () => {
296
- const result = await runRelease({ conflict: 'main' });
297
- assert.match(result.error ?? '', /protected main.*drifted/iu);
298
- assert.deepEqual(result.commands, []);
274
+ test("protected source drift refuses publication", async () => {
275
+ const result = await runRelease({ conflict: "main" });
276
+ assert.match(result.error ?? "", /protected main.*drifted/iu);
277
+ assert.deepEqual(result.commands, []);
299
278
  });
300
- test('oversized registry metadata fails within the readback output bound', async () => {
301
- const result = await runRelease({ oversizedManifest: true });
302
- assert.match(result.error ?? '', /readback bound/iu);
303
- assert.equal(result.publications, 1);
304
- assert.deepEqual(result.waits, []);
279
+ test("oversized registry metadata fails within the readback output bound", async () => {
280
+ const result = await runRelease({ oversizedManifest: true });
281
+ assert.match(result.error ?? "", /readback bound/iu);
282
+ assert.equal(result.publications, 1);
283
+ assert.deepEqual(result.waits, []);
305
284
  });
306
- test('a body timeout at the reconciliation bound retains an explicit unresolved result', async () => {
307
- const result = await runRelease({ bodyDeadlineExceeded: true });
308
- assert.match(result.error ?? '', /reconciliation unresolved/iu);
309
- assert.equal(result.publications, 1);
285
+ test("a body timeout at the reconciliation bound retains an explicit unresolved result", async () => {
286
+ const result = await runRelease({ bodyDeadlineExceeded: true });
287
+ assert.match(result.error ?? "", /reconciliation unresolved/iu);
288
+ assert.equal(result.publications, 1);
310
289
  });
311
- for (const phase of ['archiveReadyAt', 'provenanceReadyAt', 'indexReadyAt', 'latestReadyAt']) {
312
- test(`unresolved ${phase} cannot be accepted as a completed release`, async () => {
313
- const result = await runRelease({ [phase]: Infinity });
314
- assert.match(result.error ?? '', /reconciliation unresolved/iu);
315
- assert.equal(result.publications, 1);
316
- });
290
+ for (const phase of ["archiveReadyAt", "provenanceReadyAt", "indexReadyAt", "latestReadyAt"]) {
291
+ test(`unresolved ${phase} cannot be accepted as a completed release`, async () => {
292
+ const result = await runRelease({ [phase]: Infinity });
293
+ assert.match(result.error ?? "", /reconciliation unresolved/iu);
294
+ assert.equal(result.publications, 1);
295
+ });
317
296
  }
318
- //# sourceMappingURL=releaseReconciliation.test.js.map
297
+ //# sourceMappingURL=releaseReconciliation.test.js.map