@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.
Files changed (297) hide show
  1. package/CONTRIBUTING.md +12 -206
  2. package/README.md +57 -554
  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 +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 +105 -0
  13. package/dist/callerErrors.test.js.map +7 -0
  14. package/dist/cli.js +402 -515
  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 +329 -353
  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 +59 -19
  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.js +73 -67
  95. package/dist/git.js.map +7 -1
  96. package/dist/gitProcess.d.ts +1 -1
  97. package/dist/gitProcess.js +58 -53
  98. package/dist/gitProcess.js.map +7 -1
  99. package/dist/github/client.d.ts +2 -2
  100. package/dist/github/client.js +484 -379
  101. package/dist/github/client.js.map +7 -1
  102. package/dist/github/commandIdentityPolicy.js +44 -52
  103. package/dist/github/commandIdentityPolicy.js.map +7 -1
  104. package/dist/github/discovery.d.ts +1 -0
  105. package/dist/github/discovery.js +197 -215
  106. package/dist/github/discovery.js.map +7 -1
  107. package/dist/github/discovery.test.js +223 -177
  108. package/dist/github/discovery.test.js.map +7 -1
  109. package/dist/github/issueHistory.d.ts +2 -2
  110. package/dist/github/issueHistory.js +117 -125
  111. package/dist/github/issueHistory.js.map +7 -1
  112. package/dist/github/machineAuth.d.ts +1 -1
  113. package/dist/github/machineAuth.js +126 -117
  114. package/dist/github/machineAuth.js.map +7 -1
  115. package/dist/github/machineAuth.test.js +755 -639
  116. package/dist/github/machineAuth.test.js.map +7 -1
  117. package/dist/github/nativeIssueMetadata.js +286 -273
  118. package/dist/github/nativeIssueMetadata.js.map +7 -1
  119. package/dist/github/projectDelivery.d.ts +18 -2
  120. package/dist/github/projectDelivery.js +615 -557
  121. package/dist/github/projectDelivery.js.map +7 -1
  122. package/dist/github/relationships.js +433 -389
  123. package/dist/github/relationships.js.map +7 -1
  124. package/dist/github/repo.d.ts +1 -0
  125. package/dist/github/repo.js +123 -96
  126. package/dist/github/repo.js.map +7 -1
  127. package/dist/index.js +3 -3
  128. package/dist/index.js.map +7 -1
  129. package/dist/issue.d.ts +40 -9
  130. package/dist/issue.js +2102 -1742
  131. package/dist/issue.js.map +7 -1
  132. package/dist/issue63History.test.js +40 -42
  133. package/dist/issue63History.test.js.map +7 -1
  134. package/dist/issue63Routes.test.js +154 -143
  135. package/dist/issue63Routes.test.js.map +7 -1
  136. package/dist/issueBatchUpdate.test.js +989 -885
  137. package/dist/issueBatchUpdate.test.js.map +7 -1
  138. package/dist/issueBlockerGuard.test.js +262 -226
  139. package/dist/issueBlockerGuard.test.js.map +7 -1
  140. package/dist/issueContract.d.ts +23 -4
  141. package/dist/issueContract.js +416 -395
  142. package/dist/issueContract.js.map +7 -1
  143. package/dist/issueContract.test.d.ts +4 -3
  144. package/dist/issueContract.test.js +358 -321
  145. package/dist/issueContract.test.js.map +7 -1
  146. package/dist/issueDates.test.js +235 -233
  147. package/dist/issueDates.test.js.map +7 -1
  148. package/dist/issueInfoReadback.test.js +304 -190
  149. package/dist/issueInfoReadback.test.js.map +7 -1
  150. package/dist/issueIntake.test.js +1945 -1732
  151. package/dist/issueIntake.test.js.map +7 -1
  152. package/dist/issueJournal.d.ts +40 -19
  153. package/dist/issueJournal.js +229 -138
  154. package/dist/issueJournal.js.map +7 -1
  155. package/dist/issueJournal.test.js +605 -422
  156. package/dist/issueJournal.test.js.map +7 -1
  157. package/dist/issueRollup.test.d.ts +1 -0
  158. package/dist/issueRollup.test.js +476 -0
  159. package/dist/issueRollup.test.js.map +7 -0
  160. package/dist/issueTracking.test.js +1059 -989
  161. package/dist/issueTracking.test.js.map +7 -1
  162. package/dist/issueWriteRecovery.test.d.ts +1 -0
  163. package/dist/issueWriteRecovery.test.js +260 -0
  164. package/dist/issueWriteRecovery.test.js.map +7 -0
  165. package/dist/lifecycle.test.js +112 -441
  166. package/dist/lifecycle.test.js.map +7 -1
  167. package/dist/logger.js +80 -74
  168. package/dist/logger.js.map +7 -1
  169. package/dist/mcp/index.js +116 -94
  170. package/dist/mcp/index.js.map +7 -1
  171. package/dist/mcp/tools.d.ts +264 -286
  172. package/dist/mcp/tools.js +267 -340
  173. package/dist/mcp/tools.js.map +7 -1
  174. package/dist/pluginAuthProbe.js +63 -52
  175. package/dist/pluginAuthProbe.js.map +7 -1
  176. package/dist/pluginAuthProbe.test.js +85 -62
  177. package/dist/pluginAuthProbe.test.js.map +7 -1
  178. package/dist/pluginCredentials.test.js +282 -259
  179. package/dist/pluginCredentials.test.js.map +7 -1
  180. package/dist/pluginDoctor.test.js +653 -588
  181. package/dist/pluginDoctor.test.js.map +7 -1
  182. package/dist/pluginInstaller.d.ts +7 -5
  183. package/dist/pluginInstaller.js +1173 -1229
  184. package/dist/pluginInstaller.js.map +7 -1
  185. package/dist/pluginInstaller.test.js +1842 -1423
  186. package/dist/pluginInstaller.test.js.map +7 -1
  187. package/dist/pluginPackaging.test.js +460 -409
  188. package/dist/pluginPackaging.test.js.map +7 -1
  189. package/dist/pr.d.ts +132 -94
  190. package/dist/pr.js +1521 -1323
  191. package/dist/pr.js.map +7 -1
  192. package/dist/pr.test.js +1678 -632
  193. package/dist/pr.test.js.map +7 -1
  194. package/dist/prAssociation.test.js +2419 -1788
  195. package/dist/prAssociation.test.js.map +7 -1
  196. package/dist/prDispatch.test.js +150 -89
  197. package/dist/prDispatch.test.js.map +7 -1
  198. package/dist/readView.d.ts +183 -0
  199. package/dist/readView.js +217 -0
  200. package/dist/readView.js.map +7 -0
  201. package/dist/readView.test.d.ts +1 -0
  202. package/dist/readView.test.js +119 -0
  203. package/dist/readView.test.js.map +7 -0
  204. package/dist/releaseReconciliation.test.js +267 -288
  205. package/dist/releaseReconciliation.test.js.map +7 -1
  206. package/dist/releaseWorkflow.test.js +2493 -422
  207. package/dist/releaseWorkflow.test.js.map +7 -1
  208. package/dist/review.d.ts +738 -2
  209. package/dist/review.js +601 -348
  210. package/dist/review.js.map +7 -1
  211. package/dist/review.test.js +1218 -812
  212. package/dist/review.test.js.map +7 -1
  213. package/dist/reviewSubmit.test.d.ts +1 -0
  214. package/dist/reviewSubmit.test.js +747 -0
  215. package/dist/reviewSubmit.test.js.map +7 -0
  216. package/dist/services/agentReadinessService.js +42 -37
  217. package/dist/services/agentReadinessService.js.map +7 -1
  218. package/dist/services/blockerGuardService.js +188 -188
  219. package/dist/services/blockerGuardService.js.map +7 -1
  220. package/dist/services/boardReconcileService.d.ts +125 -125
  221. package/dist/services/boardReconcileService.js +1295 -1421
  222. package/dist/services/boardReconcileService.js.map +7 -1
  223. package/dist/services/deliveryAdmission.js +131 -154
  224. package/dist/services/deliveryAdmission.js.map +7 -1
  225. package/dist/services/deliveryHealthService.js +197 -199
  226. package/dist/services/deliveryHealthService.js.map +7 -1
  227. package/dist/services/legacyIssueMigration.js +263 -277
  228. package/dist/services/legacyIssueMigration.js.map +7 -1
  229. package/dist/services/worktreeRegistry.d.ts +27 -119
  230. package/dist/services/worktreeRegistry.js +765 -1182
  231. package/dist/services/worktreeRegistry.js.map +7 -1
  232. package/dist/stagedChecks.test.js +396 -194
  233. package/dist/stagedChecks.test.js.map +7 -1
  234. package/dist/start.test.js +99 -95
  235. package/dist/start.test.js.map +7 -1
  236. package/dist/stdoutRegression.test.js +353 -352
  237. package/dist/stdoutRegression.test.js.map +7 -1
  238. package/dist/targetPolicyDiscovery.test.js +141 -143
  239. package/dist/targetPolicyDiscovery.test.js.map +7 -1
  240. package/dist/targetPolicyEntrypoints.test.js +308 -269
  241. package/dist/targetPolicyEntrypoints.test.js.map +7 -1
  242. package/dist/targetPolicyLocal.test.js +580 -1051
  243. package/dist/targetPolicyLocal.test.js.map +7 -1
  244. package/dist/targetPolicyRoutes.test.js +305 -281
  245. package/dist/targetPolicyRoutes.test.js.map +7 -1
  246. package/dist/targetRepositoryExecution.test.d.ts +1 -0
  247. package/dist/targetRepositoryExecution.test.js +463 -0
  248. package/dist/targetRepositoryExecution.test.js.map +7 -0
  249. package/dist/terminalMessages.js +41 -35
  250. package/dist/terminalMessages.js.map +7 -1
  251. package/dist/toolOutput.d.ts +2 -0
  252. package/dist/toolOutput.js +36 -0
  253. package/dist/toolOutput.js.map +7 -0
  254. package/dist/toolOutput.test.d.ts +1 -0
  255. package/dist/toolOutput.test.js +240 -0
  256. package/dist/toolOutput.test.js.map +7 -0
  257. package/dist/utils/atomicJson.js +84 -76
  258. package/dist/utils/atomicJson.js.map +7 -1
  259. package/dist/utils/filesystem.js +15 -18
  260. package/dist/utils/filesystem.js.map +7 -1
  261. package/dist/utils/lockfile.js +68 -71
  262. package/dist/utils/lockfile.js.map +7 -1
  263. package/dist/verification.d.ts +1 -19
  264. package/dist/verification.js +1020 -1939
  265. package/dist/verification.js.map +7 -1
  266. package/dist/verificationGate.test.js +127 -117
  267. package/dist/verificationGate.test.js.map +7 -1
  268. package/dist/version.js +23 -24
  269. package/dist/version.js.map +7 -1
  270. package/dist/worktree.d.ts +3 -15
  271. package/dist/worktree.js +97 -177
  272. package/dist/worktree.js.map +7 -1
  273. package/package.json +9 -8
  274. package/plugins/ai-delivery/.claude-plugin/plugin.json +2 -2
  275. package/plugins/ai-delivery/README.md +47 -156
  276. package/plugins/ai-delivery/plugin.json +1 -1
  277. package/plugins/ai-delivery/runtime/dist/THIRD-PARTY-NOTICES.md +238 -44
  278. package/plugins/ai-delivery/runtime/dist/cli.js +358 -115
  279. package/plugins/ai-delivery/runtime/package.json +1 -1
  280. package/plugins/ai-delivery/skills/intake-create/SKILL.md +14 -78
  281. package/plugins/ai-delivery/skills/pr-handoff/SKILL.md +35 -36
  282. package/plugins/ai-delivery/skills/worktree-lifecycle/SKILL.md +14 -15
  283. package/dist/investigationCompletion.test.js +0 -728
  284. package/dist/investigationCompletion.test.js.map +0 -1
  285. package/dist/setup.d.ts +0 -60
  286. package/dist/setup.js +0 -585
  287. package/dist/setup.js.map +0 -1
  288. package/dist/setup.test.js +0 -3329
  289. package/dist/setup.test.js.map +0 -1
  290. package/dist/worktreeTransition.d.ts +0 -211
  291. package/dist/worktreeTransition.js +0 -1037
  292. package/dist/worktreeTransition.js.map +0 -1
  293. package/dist/worktreeTransition.test.js +0 -1191
  294. package/dist/worktreeTransition.test.js.map +0 -1
  295. /package/dist/{investigationCompletion.test.d.ts → build.test.d.ts} +0 -0
  296. /package/dist/{setup.test.d.ts → callerErrors.test.d.ts} +0 -0
  297. /package/dist/{worktreeTransition.test.d.ts → deliveryBoard.test.d.ts} +0 -0
@@ -1,8 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import type { RepositoryClassificationReceipt } from './policy.js';
3
3
  export declare const RepositoryStageInputSchema: z.ZodUnion<readonly [z.ZodObject<{
4
- classificationReceiptId: z.ZodString;
5
- schemaVersion: z.ZodLiteral<"ai-delivery.stage-input@1">;
6
4
  definitionHash: z.ZodString;
7
5
  environmentDigest: z.ZodString;
8
6
  inputId: z.ZodString;
@@ -16,14 +14,9 @@ export declare const RepositoryStageInputSchema: z.ZodUnion<readonly [z.ZodObjec
16
14
  receiptId: z.ZodString;
17
15
  stageId: z.ZodString;
18
16
  }, z.core.$strict>>;
17
+ classificationReceiptId: z.ZodString;
18
+ schemaVersion: z.ZodLiteral<"ai-delivery.stage-input@1">;
19
19
  }, z.core.$strict>, z.ZodObject<{
20
- configDigest: z.ZodString;
21
- policyProducer: z.ZodString;
22
- policyArtifacts: z.ZodArray<z.ZodObject<{
23
- digest: z.ZodString;
24
- path: z.ZodString;
25
- }, z.core.$strict>>;
26
- schemaVersion: z.ZodLiteral<"ai-delivery.stage-input@2">;
27
20
  definitionHash: z.ZodString;
28
21
  environmentDigest: z.ZodString;
29
22
  inputId: z.ZodString;
@@ -37,6 +30,13 @@ export declare const RepositoryStageInputSchema: z.ZodUnion<readonly [z.ZodObjec
37
30
  receiptId: z.ZodString;
38
31
  stageId: z.ZodString;
39
32
  }, z.core.$strict>>;
33
+ configDigest: z.ZodString;
34
+ policyProducer: z.ZodString;
35
+ policyArtifacts: z.ZodArray<z.ZodObject<{
36
+ digest: z.ZodString;
37
+ path: z.ZodString;
38
+ }, z.core.$strict>>;
39
+ schemaVersion: z.ZodLiteral<"ai-delivery.stage-input@2">;
40
40
  }, z.core.$strict>]>;
41
41
  export type RepositoryStageInput = z.infer<typeof RepositoryStageInputSchema>;
42
42
  export declare const RepositoryStageReceiptSchema: z.ZodObject<{
@@ -51,8 +51,6 @@ export declare const RepositoryStageReceiptSchema: z.ZodObject<{
51
51
  }, z.core.$strict>>;
52
52
  completedAt: z.ZodISODateTime;
53
53
  input: z.ZodUnion<readonly [z.ZodObject<{
54
- classificationReceiptId: z.ZodString;
55
- schemaVersion: z.ZodLiteral<"ai-delivery.stage-input@1">;
56
54
  definitionHash: z.ZodString;
57
55
  environmentDigest: z.ZodString;
58
56
  inputId: z.ZodString;
@@ -66,14 +64,9 @@ export declare const RepositoryStageReceiptSchema: z.ZodObject<{
66
64
  receiptId: z.ZodString;
67
65
  stageId: z.ZodString;
68
66
  }, z.core.$strict>>;
67
+ classificationReceiptId: z.ZodString;
68
+ schemaVersion: z.ZodLiteral<"ai-delivery.stage-input@1">;
69
69
  }, z.core.$strict>, z.ZodObject<{
70
- configDigest: z.ZodString;
71
- policyProducer: z.ZodString;
72
- policyArtifacts: z.ZodArray<z.ZodObject<{
73
- digest: z.ZodString;
74
- path: z.ZodString;
75
- }, z.core.$strict>>;
76
- schemaVersion: z.ZodLiteral<"ai-delivery.stage-input@2">;
77
70
  definitionHash: z.ZodString;
78
71
  environmentDigest: z.ZodString;
79
72
  inputId: z.ZodString;
@@ -87,6 +80,13 @@ export declare const RepositoryStageReceiptSchema: z.ZodObject<{
87
80
  receiptId: z.ZodString;
88
81
  stageId: z.ZodString;
89
82
  }, z.core.$strict>>;
83
+ configDigest: z.ZodString;
84
+ policyProducer: z.ZodString;
85
+ policyArtifacts: z.ZodArray<z.ZodObject<{
86
+ digest: z.ZodString;
87
+ path: z.ZodString;
88
+ }, z.core.$strict>>;
89
+ schemaVersion: z.ZodLiteral<"ai-delivery.stage-input@2">;
90
90
  }, z.core.$strict>]>;
91
91
  receiptId: z.ZodString;
92
92
  result: z.ZodLiteral<"passed">;
@@ -1,257 +1,242 @@
1
- import { join } from 'node:path';
2
- import { z } from 'zod';
3
- import { assertArtifact, assertPrivateFile, DigestSchema, digestBytes, digestValue, isUniqueSorted, stableJson, StageIdSchema, writeCreateOnly, } from './common.js';
4
- import { assertRepositoryClassificationCurrent, RepositoryClassificationReceiptSchema } from './policy.js';
1
+ import { join } from "node:path";
2
+ import { z } from "zod";
3
+ import {
4
+ assertArtifact,
5
+ assertPrivateFile,
6
+ DigestSchema,
7
+ digestBytes,
8
+ digestValue,
9
+ isUniqueSorted,
10
+ stableJson,
11
+ StageIdSchema,
12
+ writeCreateOnly
13
+ } from "./common.js";
14
+ import { assertRepositoryClassificationCurrent, RepositoryClassificationReceiptSchema } from "./policy.js";
5
15
  const SemanticInputSchema = z.object({ digest: DigestSchema, key: z.string().min(1) }).strict();
6
16
  const UpstreamSchema = z.object({ receiptId: DigestSchema, stageId: StageIdSchema }).strict();
7
- const compareText = (left, right) => (left < right ? -1 : left > right ? 1 : 0);
17
+ const compareText = (left, right) => left < right ? -1 : left > right ? 1 : 0;
8
18
  const StageInputFields = {
9
- definitionHash: DigestSchema,
10
- environmentDigest: DigestSchema,
11
- inputId: DigestSchema,
12
- policyDigest: DigestSchema,
13
- semanticInputs: z.array(SemanticInputSchema).min(1),
14
- stageId: StageIdSchema,
15
- upstream: z.array(UpstreamSchema),
19
+ definitionHash: DigestSchema,
20
+ environmentDigest: DigestSchema,
21
+ inputId: DigestSchema,
22
+ policyDigest: DigestSchema,
23
+ semanticInputs: z.array(SemanticInputSchema).min(1),
24
+ stageId: StageIdSchema,
25
+ upstream: z.array(UpstreamSchema)
16
26
  };
17
- export const RepositoryStageInputSchema = z
18
- .union([
19
- z.strictObject({
20
- ...StageInputFields,
21
- classificationReceiptId: DigestSchema,
22
- schemaVersion: z.literal('ai-delivery.stage-input@1'),
23
- }),
24
- z.strictObject({
25
- ...StageInputFields,
26
- configDigest: DigestSchema,
27
- policyProducer: z.string().min(1),
28
- policyArtifacts: z.array(z.strictObject({ digest: DigestSchema, path: z.string().min(1) })),
29
- schemaVersion: z.literal('ai-delivery.stage-input@2'),
30
- }),
31
- ])
32
- .superRefine((value, ctx) => {
33
- const { inputId, ...content } = value;
34
- if (inputId !== digestValue(content) ||
35
- !isUniqueSorted(value.semanticInputs.map((x) => x.key)) ||
36
- !isUniqueSorted(value.upstream.map((x) => x.stageId)) ||
37
- (value.schemaVersion === 'ai-delivery.stage-input@2' && !isUniqueSorted(value.policyArtifacts.map((x) => x.path))))
38
- ctx.addIssue({ code: 'custom', message: 'Stage input identity or inventory is invalid.' });
27
+ const RepositoryStageInputSchema = z.union([
28
+ z.strictObject({
29
+ ...StageInputFields,
30
+ classificationReceiptId: DigestSchema,
31
+ schemaVersion: z.literal("ai-delivery.stage-input@1")
32
+ }),
33
+ z.strictObject({
34
+ ...StageInputFields,
35
+ configDigest: DigestSchema,
36
+ policyProducer: z.string().min(1),
37
+ policyArtifacts: z.array(z.strictObject({ digest: DigestSchema, path: z.string().min(1) })),
38
+ schemaVersion: z.literal("ai-delivery.stage-input@2")
39
+ })
40
+ ]).superRefine((value, ctx) => {
41
+ const { inputId, ...content } = value;
42
+ if (inputId !== digestValue(content) || !isUniqueSorted(value.semanticInputs.map((x) => x.key)) || !isUniqueSorted(value.upstream.map((x) => x.stageId)) || value.schemaVersion === "ai-delivery.stage-input@2" && !isUniqueSorted(value.policyArtifacts.map((x) => x.path)))
43
+ ctx.addIssue({ code: "custom", message: "Stage input identity or inventory is invalid." });
39
44
  });
40
- export const RepositoryStageReceiptSchema = z
41
- .object({
42
- artifacts: z.array(z.object({ digest: DigestSchema, path: z.string().min(1) }).strict()),
43
- commands: z.array(z
44
- .object({ exitCode: z.number().int().nonnegative(), label: z.string().min(1), outputDigest: DigestSchema })
45
- .strict()),
46
- completedAt: z.iso.datetime(),
47
- input: RepositoryStageInputSchema,
48
- receiptId: DigestSchema,
49
- result: z.literal('passed'),
50
- schemaVersion: z.enum(['ai-delivery.stage-receipt@1', 'ai-delivery.stage-receipt@2']),
51
- startedAt: z.iso.datetime(),
52
- })
53
- .strict()
54
- .superRefine((value, ctx) => {
55
- const { receiptId, ...content } = value;
56
- if (receiptId !== digestValue(content) ||
57
- (value.schemaVersion === 'ai-delivery.stage-receipt@2') !==
58
- (value.input.schemaVersion === 'ai-delivery.stage-input@2') ||
59
- Date.parse(value.completedAt) < Date.parse(value.startedAt) ||
60
- value.commands.some((command) => command.exitCode !== 0) ||
61
- !isUniqueSorted(value.artifacts.map((a) => a.path)))
62
- ctx.addIssue({ code: 'custom', message: 'Stage receipt has incomplete or corrupt proof.' });
45
+ const RepositoryStageReceiptSchema = z.object({
46
+ artifacts: z.array(z.object({ digest: DigestSchema, path: z.string().min(1) }).strict()),
47
+ commands: z.array(
48
+ z.object({ exitCode: z.number().int().nonnegative(), label: z.string().min(1), outputDigest: DigestSchema }).strict()
49
+ ),
50
+ completedAt: z.iso.datetime(),
51
+ input: RepositoryStageInputSchema,
52
+ receiptId: DigestSchema,
53
+ result: z.literal("passed"),
54
+ schemaVersion: z.enum(["ai-delivery.stage-receipt@1", "ai-delivery.stage-receipt@2"]),
55
+ startedAt: z.iso.datetime()
56
+ }).strict().superRefine((value, ctx) => {
57
+ const { receiptId, ...content } = value;
58
+ if (receiptId !== digestValue(content) || value.schemaVersion === "ai-delivery.stage-receipt@2" !== (value.input.schemaVersion === "ai-delivery.stage-input@2") || Date.parse(value.completedAt) < Date.parse(value.startedAt) || value.commands.some((command) => command.exitCode !== 0) || !isUniqueSorted(value.artifacts.map((a) => a.path)))
59
+ ctx.addIssue({ code: "custom", message: "Stage receipt has incomplete or corrupt proof." });
63
60
  });
64
- export const RepositoryStageAggregateSchema = z
65
- .object({
66
- aggregateId: DigestSchema,
67
- classificationReceiptId: DigestSchema,
68
- policyDigest: DigestSchema,
69
- result: z.literal('passed'),
70
- schemaVersion: z.enum(['ai-delivery.stage-aggregate@1', 'ai-delivery.stage-aggregate@2']),
71
- stages: z
72
- .array(z.object({ inputId: DigestSchema, receiptId: DigestSchema, stageId: StageIdSchema }).strict())
73
- .min(1),
74
- })
75
- .strict()
76
- .superRefine((value, ctx) => {
77
- const { aggregateId, ...content } = value;
78
- if (aggregateId !== digestValue(content) ||
79
- new Set(value.stages.map((x) => x.stageId)).size !== value.stages.length)
80
- ctx.addIssue({ code: 'custom', message: 'Stage aggregate identity or inventory is invalid.' });
61
+ const RepositoryStageAggregateSchema = z.object({
62
+ aggregateId: DigestSchema,
63
+ classificationReceiptId: DigestSchema,
64
+ policyDigest: DigestSchema,
65
+ result: z.literal("passed"),
66
+ schemaVersion: z.enum(["ai-delivery.stage-aggregate@1", "ai-delivery.stage-aggregate@2"]),
67
+ stages: z.array(z.object({ inputId: DigestSchema, receiptId: DigestSchema, stageId: StageIdSchema }).strict()).min(1)
68
+ }).strict().superRefine((value, ctx) => {
69
+ const { aggregateId, ...content } = value;
70
+ if (aggregateId !== digestValue(content) || new Set(value.stages.map((x) => x.stageId)).size !== value.stages.length)
71
+ ctx.addIssue({ code: "custom", message: "Stage aggregate identity or inventory is invalid." });
81
72
  });
82
- export function createRepositoryStageInput(input) {
83
- const classification = RepositoryClassificationReceiptSchema.parse(input.classification);
84
- const definition = classification.requiredStages.find((stage) => stage.id === input.stageId);
85
- if (definition === undefined)
86
- throw new Error('Stage is absent from selected policy.');
87
- const semanticInputs = [...input.semanticInputs]
88
- .sort((a, b) => compareText(a.key, b.key))
89
- .map((x) => SemanticInputSchema.parse(x));
90
- const upstream = [...input.upstream]
91
- .sort((a, b) => compareText(a.stageId, b.stageId))
92
- .map((x) => UpstreamSchema.parse(x));
93
- if (stableJson(semanticInputs.map((x) => x.key)) !== stableJson(definition.semanticInputKeys) ||
94
- (classification.schemaVersion === 'ai-delivery.classification@2' &&
95
- stableJson(semanticInputs) !== stableJson(definition.semanticInputs)) ||
96
- stableJson(upstream.map((x) => x.stageId)) !== stableJson([...definition.dependsOn].sort()))
97
- throw new Error('Stage input lacks required semantic or upstream proof.');
98
- const content = {
99
- ...(classification.schemaVersion === 'ai-delivery.classification@1'
100
- ? { classificationReceiptId: classification.receiptId, schemaVersion: 'ai-delivery.stage-input@1' }
101
- : {
102
- configDigest: classification.configDigest,
103
- policyProducer: classification.policyEvidence.producer,
104
- schemaVersion: 'ai-delivery.stage-input@2',
105
- policyArtifacts: classification.policyEvidence.artifacts
106
- .filter((artifact) => artifact.path === definition.attestationKey)
107
- .map(({ digest, path }) => ({ digest, path })),
108
- }),
109
- definitionHash: digestValue(definition),
110
- environmentDigest: DigestSchema.parse(input.environmentDigest),
111
- policyDigest: classification.policyDigest,
112
- semanticInputs,
113
- stageId: definition.id,
114
- upstream,
115
- };
116
- return RepositoryStageInputSchema.parse({ ...content, inputId: digestValue(content) });
73
+ function createRepositoryStageInput(input) {
74
+ const classification = RepositoryClassificationReceiptSchema.parse(input.classification);
75
+ const definition = classification.requiredStages.find((stage) => stage.id === input.stageId);
76
+ if (definition === void 0) throw new Error("Stage is absent from selected policy.");
77
+ const semanticInputs = [...input.semanticInputs].sort((a, b) => compareText(a.key, b.key)).map((x) => SemanticInputSchema.parse(x));
78
+ const upstream = [...input.upstream].sort((a, b) => compareText(a.stageId, b.stageId)).map((x) => UpstreamSchema.parse(x));
79
+ if (stableJson(semanticInputs.map((x) => x.key)) !== stableJson(definition.semanticInputKeys) || classification.schemaVersion === "ai-delivery.classification@2" && stableJson(semanticInputs) !== stableJson(definition.semanticInputs) || stableJson(upstream.map((x) => x.stageId)) !== stableJson([...definition.dependsOn].sort()))
80
+ throw new Error("Stage input lacks required semantic or upstream proof.");
81
+ const content = {
82
+ ...classification.schemaVersion === "ai-delivery.classification@1" ? { classificationReceiptId: classification.receiptId, schemaVersion: "ai-delivery.stage-input@1" } : {
83
+ configDigest: classification.configDigest,
84
+ policyProducer: classification.policyEvidence.producer,
85
+ schemaVersion: "ai-delivery.stage-input@2",
86
+ policyArtifacts: classification.policyEvidence.artifacts.filter((artifact) => artifact.path === definition.attestationKey).map(({ digest, path }) => ({ digest, path }))
87
+ },
88
+ definitionHash: digestValue(definition),
89
+ environmentDigest: DigestSchema.parse(input.environmentDigest),
90
+ policyDigest: classification.policyDigest,
91
+ semanticInputs,
92
+ stageId: definition.id,
93
+ upstream
94
+ };
95
+ return RepositoryStageInputSchema.parse({ ...content, inputId: digestValue(content) });
117
96
  }
118
- export function createRepositoryStageReceipt(input) {
119
- const classification = RepositoryClassificationReceiptSchema.parse(input.classification);
120
- const stageInput = RepositoryStageInputSchema.parse(input.stageInput);
121
- const definition = classification.requiredStages.find((stage) => stage.id === stageInput.stageId);
122
- if (definition === undefined ||
123
- createRepositoryStageInput({
124
- classification,
125
- stageId: stageInput.stageId,
126
- environmentDigest: stageInput.environmentDigest,
127
- semanticInputs: stageInput.semanticInputs,
128
- upstream: stageInput.upstream,
129
- }).inputId !== stageInput.inputId ||
130
- (stageInput.schemaVersion === 'ai-delivery.stage-input@2' &&
131
- stableJson(input.artifacts) !== stableJson(stageInput.policyArtifacts)) ||
132
- input.commands.length !== definition.commands.length ||
133
- input.commands.some((command, index) => command.label !== definition.commands[index]?.label || command.exitCode !== 0) ||
134
- (definition.attestationKey !== undefined && input.artifacts.length === 0))
135
- throw new Error('Stage receipt does not prove selected definition.');
136
- const content = {
137
- artifacts: [...input.artifacts].sort((a, b) => compareText(a.path, b.path)),
138
- commands: input.commands.map((x) => ({ ...x })),
139
- completedAt: input.completedAt,
140
- input: stageInput,
141
- result: 'passed',
142
- schemaVersion: stageInput.schemaVersion === 'ai-delivery.stage-input@2'
143
- ? 'ai-delivery.stage-receipt@2'
144
- : 'ai-delivery.stage-receipt@1',
145
- startedAt: input.startedAt,
146
- };
147
- return RepositoryStageReceiptSchema.parse({ ...content, receiptId: digestValue(content) });
97
+ function createRepositoryStageReceipt(input) {
98
+ const classification = RepositoryClassificationReceiptSchema.parse(input.classification);
99
+ const stageInput = RepositoryStageInputSchema.parse(input.stageInput);
100
+ const definition = classification.requiredStages.find((stage) => stage.id === stageInput.stageId);
101
+ if (definition === void 0 || createRepositoryStageInput({
102
+ classification,
103
+ stageId: stageInput.stageId,
104
+ environmentDigest: stageInput.environmentDigest,
105
+ semanticInputs: stageInput.semanticInputs,
106
+ upstream: stageInput.upstream
107
+ }).inputId !== stageInput.inputId || stageInput.schemaVersion === "ai-delivery.stage-input@2" && stableJson(input.artifacts) !== stableJson(stageInput.policyArtifacts) || input.commands.length !== definition.commands.length || input.commands.some(
108
+ (command, index) => command.label !== definition.commands[index]?.label || command.exitCode !== 0
109
+ ) || definition.attestationKey !== void 0 && input.artifacts.length === 0)
110
+ throw new Error("Stage receipt does not prove selected definition.");
111
+ const content = {
112
+ artifacts: [...input.artifacts].sort((a, b) => compareText(a.path, b.path)),
113
+ commands: input.commands.map((x) => ({ ...x })),
114
+ completedAt: input.completedAt,
115
+ input: stageInput,
116
+ result: "passed",
117
+ schemaVersion: stageInput.schemaVersion === "ai-delivery.stage-input@2" ? "ai-delivery.stage-receipt@2" : "ai-delivery.stage-receipt@1",
118
+ startedAt: input.startedAt
119
+ };
120
+ return RepositoryStageReceiptSchema.parse({ ...content, receiptId: digestValue(content) });
148
121
  }
149
- export function createRepositoryStageAggregate(input) {
150
- const classification = RepositoryClassificationReceiptSchema.parse(input.classification);
151
- if (input.receipts.length !== classification.requiredStages.length)
152
- throw new Error('Aggregate requires every selected stage.');
153
- const receipts = input.receipts.map((receipt) => RepositoryStageReceiptSchema.parse(receipt));
154
- const byStage = new Map(receipts.map((receipt) => [receipt.input.stageId, receipt]));
155
- if (byStage.size !== receipts.length)
156
- throw new Error('Aggregate contains duplicate stages.');
157
- for (const definition of classification.requiredStages) {
158
- const receipt = byStage.get(definition.id);
159
- if (receipt === undefined ||
160
- stableJson(receipt.input.upstream) !==
161
- stableJson(definition.dependsOn
162
- .map((stageId) => ({ stageId, receiptId: byStage.get(stageId)?.receiptId }))
163
- .sort((a, b) => compareText(a.stageId, b.stageId))) ||
164
- createRepositoryStageReceipt({
165
- artifacts: receipt.artifacts,
166
- classification,
167
- commands: receipt.commands,
168
- completedAt: receipt.completedAt,
169
- stageInput: receipt.input,
170
- startedAt: receipt.startedAt,
171
- }).receiptId !== receipt.receiptId)
172
- throw new Error('Aggregate contains missing, foreign or stale stage proof.');
173
- }
174
- const content = {
175
- classificationReceiptId: classification.receiptId,
176
- policyDigest: classification.policyDigest,
177
- result: 'passed',
178
- schemaVersion: classification.schemaVersion === 'ai-delivery.classification@2'
179
- ? 'ai-delivery.stage-aggregate@2'
180
- : 'ai-delivery.stage-aggregate@1',
181
- stages: classification.requiredStages.map((stage) => {
182
- const receipt = byStage.get(stage.id);
183
- return { inputId: receipt.input.inputId, receiptId: receipt.receiptId, stageId: stage.id };
184
- }),
185
- };
186
- return RepositoryStageAggregateSchema.parse({ ...content, aggregateId: digestValue(content) });
122
+ function createRepositoryStageAggregate(input) {
123
+ const classification = RepositoryClassificationReceiptSchema.parse(input.classification);
124
+ if (input.receipts.length !== classification.requiredStages.length)
125
+ throw new Error("Aggregate requires every selected stage.");
126
+ const receipts = input.receipts.map((receipt) => RepositoryStageReceiptSchema.parse(receipt));
127
+ const byStage = new Map(receipts.map((receipt) => [receipt.input.stageId, receipt]));
128
+ if (byStage.size !== receipts.length) throw new Error("Aggregate contains duplicate stages.");
129
+ for (const definition of classification.requiredStages) {
130
+ const receipt = byStage.get(definition.id);
131
+ if (receipt === void 0 || stableJson(receipt.input.upstream) !== stableJson(
132
+ definition.dependsOn.map((stageId) => ({ stageId, receiptId: byStage.get(stageId)?.receiptId })).sort((a, b) => compareText(a.stageId, b.stageId))
133
+ ) || createRepositoryStageReceipt({
134
+ artifacts: receipt.artifacts,
135
+ classification,
136
+ commands: receipt.commands,
137
+ completedAt: receipt.completedAt,
138
+ stageInput: receipt.input,
139
+ startedAt: receipt.startedAt
140
+ }).receiptId !== receipt.receiptId)
141
+ throw new Error("Aggregate contains missing, foreign or stale stage proof.");
142
+ }
143
+ const content = {
144
+ classificationReceiptId: classification.receiptId,
145
+ policyDigest: classification.policyDigest,
146
+ result: "passed",
147
+ schemaVersion: classification.schemaVersion === "ai-delivery.classification@2" ? "ai-delivery.stage-aggregate@2" : "ai-delivery.stage-aggregate@1",
148
+ stages: classification.requiredStages.map((stage) => {
149
+ const receipt = byStage.get(stage.id);
150
+ return { inputId: receipt.input.inputId, receiptId: receipt.receiptId, stageId: stage.id };
151
+ })
152
+ };
153
+ return RepositoryStageAggregateSchema.parse({ ...content, aggregateId: digestValue(content) });
187
154
  }
188
155
  function storeRoot(gitCommonDir, version = 1) {
189
- return join(gitCommonDir, 'ai-delivery', `verification@${String(version)}`);
156
+ return join(gitCommonDir, "ai-delivery", `verification@${String(version)}`);
190
157
  }
191
158
  function outputPath(gitCommonDir, digest) {
192
- return join(storeRoot(gitCommonDir), 'command-output', `${DigestSchema.parse(digest).slice(7)}.bin`);
159
+ return join(storeRoot(gitCommonDir), "command-output", `${DigestSchema.parse(digest).slice(7)}.bin`);
193
160
  }
194
161
  function checkpointPath(gitCommonDir, stageInput) {
195
- return join(storeRoot(gitCommonDir, stageInput.schemaVersion === 'ai-delivery.stage-input@2' ? 2 : 1), 'stages', stageInput.stageId, `${stageInput.inputId.slice(7)}.json`);
162
+ return join(
163
+ storeRoot(gitCommonDir, stageInput.schemaVersion === "ai-delivery.stage-input@2" ? 2 : 1),
164
+ "stages",
165
+ stageInput.stageId,
166
+ `${stageInput.inputId.slice(7)}.json`
167
+ );
196
168
  }
197
- export function writeRepositoryCommandOutput(input) {
198
- if (input.bytes.length > 8 * 1024 * 1024)
199
- throw new Error('Command output exceeds bounded evidence limit.');
200
- const digest = digestBytes(input.bytes);
201
- writeCreateOnly(outputPath(input.gitCommonDir, digest), input.bytes, digest);
202
- return digest;
169
+ function writeRepositoryCommandOutput(input) {
170
+ if (input.bytes.length > 8 * 1024 * 1024) throw new Error("Command output exceeds bounded evidence limit.");
171
+ const digest = digestBytes(input.bytes);
172
+ writeCreateOnly(outputPath(input.gitCommonDir, digest), input.bytes, digest);
173
+ return digest;
203
174
  }
204
- /** @internal Read immutable command evidence through its existing storage owner. */
205
- export function readRepositoryCommandOutput(input) {
206
- const bytes = assertPrivateFile(outputPath(input.gitCommonDir, input.digest), {
207
- maxBytes: 8 * 1024 ** 2,
208
- ...(input.expectedBytes === undefined ? {} : { expectedBytes: input.expectedBytes }),
209
- });
210
- if (digestBytes(bytes) !== input.digest)
211
- throw new Error('Command output bytes are corrupt.');
212
- return bytes;
175
+ function readRepositoryCommandOutput(input) {
176
+ const bytes = assertPrivateFile(outputPath(input.gitCommonDir, input.digest), {
177
+ maxBytes: 8 * 1024 ** 2,
178
+ ...input.expectedBytes === void 0 ? {} : { expectedBytes: input.expectedBytes }
179
+ });
180
+ if (digestBytes(bytes) !== input.digest) throw new Error("Command output bytes are corrupt.");
181
+ return bytes;
213
182
  }
214
- export function assertRepositoryStageProof(input) {
215
- const receipt = RepositoryStageReceiptSchema.parse(input.receipt);
216
- for (const artifact of receipt.artifacts)
217
- assertArtifact(input.repoRoot, artifact);
218
- for (const command of receipt.commands)
219
- readRepositoryCommandOutput({ gitCommonDir: input.gitCommonDir, digest: command.outputDigest });
183
+ function assertRepositoryStageProof(input) {
184
+ const receipt = RepositoryStageReceiptSchema.parse(input.receipt);
185
+ for (const artifact of receipt.artifacts) assertArtifact(input.repoRoot, artifact);
186
+ for (const command of receipt.commands)
187
+ readRepositoryCommandOutput({ gitCommonDir: input.gitCommonDir, digest: command.outputDigest });
220
188
  }
221
- export function writeRepositoryStageCheckpoint(input) {
222
- const receipt = RepositoryStageReceiptSchema.parse(input.receipt);
223
- assertRepositoryStageProof({ ...input, receipt });
224
- return writeCreateOnly(checkpointPath(input.gitCommonDir, receipt.input), Buffer.from(stableJson(receipt), 'utf8'));
189
+ function writeRepositoryStageCheckpoint(input) {
190
+ const receipt = RepositoryStageReceiptSchema.parse(input.receipt);
191
+ assertRepositoryStageProof({ ...input, receipt });
192
+ return writeCreateOnly(checkpointPath(input.gitCommonDir, receipt.input), Buffer.from(stableJson(receipt), "utf8"));
225
193
  }
226
- export function loadRepositoryStageCheckpoint(input) {
227
- const stageInput = RepositoryStageInputSchema.parse(input.stageInput);
228
- assertRepositoryClassificationCurrent(input);
229
- let bytes;
230
- try {
231
- bytes = assertPrivateFile(checkpointPath(input.gitCommonDir, stageInput));
232
- }
233
- catch (error) {
234
- if (error.code === 'ENOENT')
235
- return undefined;
236
- throw error;
237
- }
238
- const receipt = RepositoryStageReceiptSchema.parse(JSON.parse(bytes.toString('utf8')));
239
- if (!bytes.equals(Buffer.from(stableJson(receipt), 'utf8')) ||
240
- receipt.input.inputId !== stageInput.inputId ||
241
- createRepositoryStageReceipt({
242
- artifacts: receipt.artifacts,
243
- classification: input.classification,
244
- commands: receipt.commands,
245
- completedAt: receipt.completedAt,
246
- stageInput,
247
- startedAt: receipt.startedAt,
248
- }).receiptId !== receipt.receiptId)
249
- throw new Error('Stage checkpoint is corrupt or belongs to another input.');
250
- assertRepositoryStageProof({ gitCommonDir: input.gitCommonDir, receipt, repoRoot: input.repoRoot });
251
- return receipt;
194
+ function loadRepositoryStageCheckpoint(input) {
195
+ const stageInput = RepositoryStageInputSchema.parse(input.stageInput);
196
+ assertRepositoryClassificationCurrent(input);
197
+ let bytes;
198
+ try {
199
+ bytes = assertPrivateFile(checkpointPath(input.gitCommonDir, stageInput));
200
+ } catch (error) {
201
+ if (error.code === "ENOENT") return void 0;
202
+ throw error;
203
+ }
204
+ const receipt = RepositoryStageReceiptSchema.parse(JSON.parse(bytes.toString("utf8")));
205
+ if (!bytes.equals(Buffer.from(stableJson(receipt), "utf8")) || receipt.input.inputId !== stageInput.inputId || createRepositoryStageReceipt({
206
+ artifacts: receipt.artifacts,
207
+ classification: input.classification,
208
+ commands: receipt.commands,
209
+ completedAt: receipt.completedAt,
210
+ stageInput,
211
+ startedAt: receipt.startedAt
212
+ }).receiptId !== receipt.receiptId)
213
+ throw new Error("Stage checkpoint is corrupt or belongs to another input.");
214
+ assertRepositoryStageProof({ gitCommonDir: input.gitCommonDir, receipt, repoRoot: input.repoRoot });
215
+ return receipt;
252
216
  }
253
- export function writeRepositoryStageAggregate(input) {
254
- const aggregate = RepositoryStageAggregateSchema.parse(input.aggregate);
255
- return writeCreateOnly(join(storeRoot(input.gitCommonDir, aggregate.schemaVersion === 'ai-delivery.stage-aggregate@2' ? 2 : 1), 'aggregates', `${aggregate.aggregateId.slice(7)}.json`), Buffer.from(stableJson(aggregate), 'utf8'));
217
+ function writeRepositoryStageAggregate(input) {
218
+ const aggregate = RepositoryStageAggregateSchema.parse(input.aggregate);
219
+ return writeCreateOnly(
220
+ join(
221
+ storeRoot(input.gitCommonDir, aggregate.schemaVersion === "ai-delivery.stage-aggregate@2" ? 2 : 1),
222
+ "aggregates",
223
+ `${aggregate.aggregateId.slice(7)}.json`
224
+ ),
225
+ Buffer.from(stableJson(aggregate), "utf8")
226
+ );
256
227
  }
257
- //# sourceMappingURL=stage.js.map
228
+ export {
229
+ RepositoryStageAggregateSchema,
230
+ RepositoryStageInputSchema,
231
+ RepositoryStageReceiptSchema,
232
+ assertRepositoryStageProof,
233
+ createRepositoryStageAggregate,
234
+ createRepositoryStageInput,
235
+ createRepositoryStageReceipt,
236
+ loadRepositoryStageCheckpoint,
237
+ readRepositoryCommandOutput,
238
+ writeRepositoryCommandOutput,
239
+ writeRepositoryStageAggregate,
240
+ writeRepositoryStageCheckpoint
241
+ };
242
+ //# sourceMappingURL=stage.js.map