@aviaratech/ai-delivery 0.3.34 → 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.
Files changed (301) hide show
  1. package/CONTRIBUTING.md +12 -206
  2. package/README.md +57 -506
  3. package/dist/agent.d.ts +0 -2
  4. package/dist/agent.js +76 -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 +1746 -0
  9. package/dist/boardReconcile.test.js.map +7 -0
  10. package/dist/build.test.js +130 -0
  11. package/dist/build.test.js.map +7 -0
  12. package/dist/callerErrors.test.js +105 -0
  13. package/dist/callerErrors.test.js.map +7 -0
  14. package/dist/cli.js +406 -485
  15. package/dist/cli.js.map +7 -1
  16. package/dist/cliResult.d.ts +2 -2
  17. package/dist/cliResult.js +42 -25
  18. package/dist/cliResult.js.map +7 -1
  19. package/dist/cliResult.test.js +434 -297
  20. package/dist/cliResult.test.js.map +7 -1
  21. package/dist/config/deliveryConfig.d.ts +320 -14
  22. package/dist/config/deliveryConfig.js +472 -385
  23. package/dist/config/deliveryConfig.js.map +7 -1
  24. package/dist/config/deliveryConfig.test.js +775 -584
  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 -477
  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.d.ts +1 -0
  53. package/dist/deliveryBoard.test.js +649 -0
  54. package/dist/deliveryBoard.test.js.map +7 -0
  55. package/dist/deliveryHealth.test.js +179 -155
  56. package/dist/deliveryHealth.test.js.map +7 -1
  57. package/dist/dependencyCompatibility.test.js +154 -140
  58. package/dist/dependencyCompatibility.test.js.map +7 -1
  59. package/dist/directoryIndependent.test.js +417 -383
  60. package/dist/directoryIndependent.test.js.map +7 -1
  61. package/dist/dispatch.d.ts +17 -12
  62. package/dist/dispatch.js +330 -322
  63. package/dist/dispatch.js.map +7 -1
  64. package/dist/errors.d.ts +16 -3
  65. package/dist/errors.js +104 -82
  66. package/dist/errors.js.map +7 -1
  67. package/dist/fixtures/deliveryBoardReplay.d.ts +56 -0
  68. package/dist/fixtures/deliveryBoardReplay.js +617 -0
  69. package/dist/fixtures/deliveryBoardReplay.js.map +7 -0
  70. package/dist/fixtures/discovery.d.ts +59 -19
  71. package/dist/fixtures/discovery.js +96 -90
  72. package/dist/fixtures/discovery.js.map +7 -1
  73. package/dist/fixtures/inertEntrypointChild.js +57 -56
  74. package/dist/fixtures/inertEntrypointChild.js.map +7 -1
  75. package/dist/fixtures/inertEntrypoints.d.ts +1 -1
  76. package/dist/fixtures/inertEntrypoints.js +321 -276
  77. package/dist/fixtures/inertEntrypoints.js.map +7 -1
  78. package/dist/fixtures/inertTarget.d.ts +78 -7
  79. package/dist/fixtures/inertTarget.js +769 -691
  80. package/dist/fixtures/inertTarget.js.map +7 -1
  81. package/dist/fixtures/issue63.d.ts +4 -3
  82. package/dist/fixtures/issue63.js +260 -274
  83. package/dist/fixtures/issue63.js.map +7 -1
  84. package/dist/fixtures/issueProjectItems.d.ts +20 -0
  85. package/dist/fixtures/issueProjectItems.js +15 -0
  86. package/dist/fixtures/issueProjectItems.js.map +7 -0
  87. package/dist/fixtures/readView.d.ts +120 -0
  88. package/dist/fixtures/readView.js +172 -0
  89. package/dist/fixtures/readView.js.map +7 -0
  90. package/dist/fixtures/recordedGitHubFlows.d.ts +120 -0
  91. package/dist/fixtures/recordedGitHubFlows.js +109 -0
  92. package/dist/fixtures/recordedGitHubFlows.js.map +7 -0
  93. package/dist/genericCompatibility.test.js +64 -55
  94. package/dist/genericCompatibility.test.js.map +7 -1
  95. package/dist/git.js +73 -67
  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 +44 -51
  104. package/dist/github/commandIdentityPolicy.js.map +7 -1
  105. package/dist/github/discovery.d.ts +3 -0
  106. package/dist/github/discovery.js +197 -201
  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 +53 -1
  121. package/dist/github/projectDelivery.js +623 -460
  122. package/dist/github/projectDelivery.js.map +7 -1
  123. package/dist/github/relationships.d.ts +5 -2
  124. package/dist/github/relationships.js +434 -333
  125. package/dist/github/relationships.js.map +7 -1
  126. package/dist/github/repo.d.ts +1 -0
  127. package/dist/github/repo.js +123 -96
  128. package/dist/github/repo.js.map +7 -1
  129. package/dist/index.js +3 -3
  130. package/dist/index.js.map +7 -1
  131. package/dist/issue.d.ts +103 -7
  132. package/dist/issue.js +2104 -1547
  133. package/dist/issue.js.map +7 -1
  134. package/dist/issue63History.test.js +40 -42
  135. package/dist/issue63History.test.js.map +7 -1
  136. package/dist/issue63Routes.test.js +154 -143
  137. package/dist/issue63Routes.test.js.map +7 -1
  138. package/dist/issueBatchUpdate.test.js +1004 -683
  139. package/dist/issueBatchUpdate.test.js.map +7 -1
  140. package/dist/issueBlockerGuard.test.js +262 -226
  141. package/dist/issueBlockerGuard.test.js.map +7 -1
  142. package/dist/issueContract.d.ts +23 -4
  143. package/dist/issueContract.js +416 -395
  144. package/dist/issueContract.js.map +7 -1
  145. package/dist/issueContract.test.d.ts +4 -3
  146. package/dist/issueContract.test.js +358 -321
  147. package/dist/issueContract.test.js.map +7 -1
  148. package/dist/issueDates.test.js +235 -233
  149. package/dist/issueDates.test.js.map +7 -1
  150. package/dist/issueInfoReadback.test.js +304 -190
  151. package/dist/issueInfoReadback.test.js.map +7 -1
  152. package/dist/issueIntake.test.js +1945 -1732
  153. package/dist/issueIntake.test.js.map +7 -1
  154. package/dist/issueJournal.d.ts +40 -19
  155. package/dist/issueJournal.js +229 -138
  156. package/dist/issueJournal.js.map +7 -1
  157. package/dist/issueJournal.test.js +605 -422
  158. package/dist/issueJournal.test.js.map +7 -1
  159. package/dist/issueRollup.test.d.ts +1 -0
  160. package/dist/issueRollup.test.js +476 -0
  161. package/dist/issueRollup.test.js.map +7 -0
  162. package/dist/issueTracking.test.js +1088 -593
  163. package/dist/issueTracking.test.js.map +7 -1
  164. package/dist/issueWriteRecovery.test.d.ts +1 -0
  165. package/dist/issueWriteRecovery.test.js +260 -0
  166. package/dist/issueWriteRecovery.test.js.map +7 -0
  167. package/dist/lifecycle.test.js +112 -441
  168. package/dist/lifecycle.test.js.map +7 -1
  169. package/dist/logger.js +80 -74
  170. package/dist/logger.js.map +7 -1
  171. package/dist/mcp/index.js +116 -90
  172. package/dist/mcp/index.js.map +7 -1
  173. package/dist/mcp/tools.d.ts +790 -220
  174. package/dist/mcp/tools.js +267 -333
  175. package/dist/mcp/tools.js.map +7 -1
  176. package/dist/pluginAuthProbe.js +63 -52
  177. package/dist/pluginAuthProbe.js.map +7 -1
  178. package/dist/pluginAuthProbe.test.js +85 -62
  179. package/dist/pluginAuthProbe.test.js.map +7 -1
  180. package/dist/pluginCredentials.test.js +282 -259
  181. package/dist/pluginCredentials.test.js.map +7 -1
  182. package/dist/pluginDoctor.test.js +653 -588
  183. package/dist/pluginDoctor.test.js.map +7 -1
  184. package/dist/pluginInstaller.d.ts +7 -5
  185. package/dist/pluginInstaller.js +1173 -1231
  186. package/dist/pluginInstaller.js.map +7 -1
  187. package/dist/pluginInstaller.test.js +1822 -1283
  188. package/dist/pluginInstaller.test.js.map +7 -1
  189. package/dist/pluginPackaging.test.js +485 -305
  190. package/dist/pluginPackaging.test.js.map +7 -1
  191. package/dist/pr.d.ts +132 -94
  192. package/dist/pr.js +1521 -1323
  193. package/dist/pr.js.map +7 -1
  194. package/dist/pr.test.js +1678 -632
  195. package/dist/pr.test.js.map +7 -1
  196. package/dist/prAssociation.test.js +2419 -1788
  197. package/dist/prAssociation.test.js.map +7 -1
  198. package/dist/prDispatch.test.js +150 -89
  199. package/dist/prDispatch.test.js.map +7 -1
  200. package/dist/readView.d.ts +183 -0
  201. package/dist/readView.js +217 -0
  202. package/dist/readView.js.map +7 -0
  203. package/dist/readView.test.d.ts +1 -0
  204. package/dist/readView.test.js +119 -0
  205. package/dist/readView.test.js.map +7 -0
  206. package/dist/releaseReconciliation.test.js +267 -288
  207. package/dist/releaseReconciliation.test.js.map +7 -1
  208. package/dist/releaseWorkflow.test.js +2493 -422
  209. package/dist/releaseWorkflow.test.js.map +7 -1
  210. package/dist/review.d.ts +738 -2
  211. package/dist/review.js +601 -348
  212. package/dist/review.js.map +7 -1
  213. package/dist/review.test.js +1218 -812
  214. package/dist/review.test.js.map +7 -1
  215. package/dist/reviewSubmit.test.d.ts +1 -0
  216. package/dist/reviewSubmit.test.js +747 -0
  217. package/dist/reviewSubmit.test.js.map +7 -0
  218. package/dist/services/agentReadinessService.js +42 -37
  219. package/dist/services/agentReadinessService.js.map +7 -1
  220. package/dist/services/blockerGuardService.js +188 -188
  221. package/dist/services/blockerGuardService.js.map +7 -1
  222. package/dist/services/boardReconcileService.d.ts +1204 -0
  223. package/dist/services/boardReconcileService.js +1445 -0
  224. package/dist/services/boardReconcileService.js.map +7 -0
  225. package/dist/services/deliveryAdmission.d.ts +2 -0
  226. package/dist/services/deliveryAdmission.js +129 -152
  227. package/dist/services/deliveryAdmission.js.map +7 -1
  228. package/dist/services/deliveryHealthService.js +197 -199
  229. package/dist/services/deliveryHealthService.js.map +7 -1
  230. package/dist/services/legacyIssueMigration.js +263 -277
  231. package/dist/services/legacyIssueMigration.js.map +7 -1
  232. package/dist/services/worktreeRegistry.d.ts +27 -119
  233. package/dist/services/worktreeRegistry.js +765 -1182
  234. package/dist/services/worktreeRegistry.js.map +7 -1
  235. package/dist/stagedChecks.test.js +396 -194
  236. package/dist/stagedChecks.test.js.map +7 -1
  237. package/dist/start.test.js +99 -95
  238. package/dist/start.test.js.map +7 -1
  239. package/dist/stdoutRegression.test.js +354 -350
  240. package/dist/stdoutRegression.test.js.map +7 -1
  241. package/dist/targetPolicyDiscovery.test.js +141 -143
  242. package/dist/targetPolicyDiscovery.test.js.map +7 -1
  243. package/dist/targetPolicyEntrypoints.test.js +308 -269
  244. package/dist/targetPolicyEntrypoints.test.js.map +7 -1
  245. package/dist/targetPolicyLocal.test.js +580 -1051
  246. package/dist/targetPolicyLocal.test.js.map +7 -1
  247. package/dist/targetPolicyRoutes.test.js +305 -281
  248. package/dist/targetPolicyRoutes.test.js.map +7 -1
  249. package/dist/targetRepositoryExecution.test.d.ts +1 -0
  250. package/dist/targetRepositoryExecution.test.js +463 -0
  251. package/dist/targetRepositoryExecution.test.js.map +7 -0
  252. package/dist/terminalMessages.js +41 -35
  253. package/dist/terminalMessages.js.map +7 -1
  254. package/dist/toolOutput.d.ts +2 -0
  255. package/dist/toolOutput.js +36 -0
  256. package/dist/toolOutput.js.map +7 -0
  257. package/dist/toolOutput.test.d.ts +1 -0
  258. package/dist/toolOutput.test.js +240 -0
  259. package/dist/toolOutput.test.js.map +7 -0
  260. package/dist/utils/atomicJson.js +84 -76
  261. package/dist/utils/atomicJson.js.map +7 -1
  262. package/dist/utils/filesystem.js +15 -18
  263. package/dist/utils/filesystem.js.map +7 -1
  264. package/dist/utils/lockfile.js +68 -71
  265. package/dist/utils/lockfile.js.map +7 -1
  266. package/dist/verification.d.ts +1 -19
  267. package/dist/verification.js +1020 -1929
  268. package/dist/verification.js.map +7 -1
  269. package/dist/verificationGate.test.js +127 -117
  270. package/dist/verificationGate.test.js.map +7 -1
  271. package/dist/version.d.ts +6 -0
  272. package/dist/version.js +24 -10
  273. package/dist/version.js.map +7 -1
  274. package/dist/worktree.d.ts +3 -15
  275. package/dist/worktree.js +97 -177
  276. package/dist/worktree.js.map +7 -1
  277. package/package.json +10 -8
  278. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  279. package/plugins/ai-delivery/README.md +47 -156
  280. package/plugins/ai-delivery/plugin.json +1 -1
  281. package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +261 -43
  282. package/plugins/ai-delivery/runtime/dist/cli.js +369 -125
  283. package/plugins/ai-delivery/runtime/package.json +1 -1
  284. package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
  285. package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
  286. package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
  287. package/dist/investigationCompletion.test.js +0 -728
  288. package/dist/investigationCompletion.test.js.map +0 -1
  289. package/dist/setup.d.ts +0 -60
  290. package/dist/setup.js +0 -585
  291. package/dist/setup.js.map +0 -1
  292. package/dist/setup.test.js +0 -3058
  293. package/dist/setup.test.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 → boardReconcile.test.d.ts} +0 -0
  300. /package/dist/{setup.test.d.ts → build.test.d.ts} +0 -0
  301. /package/dist/{worktreeTransition.test.d.ts → callerErrors.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