@kungfu-tech/buildchain 4.0.9 → 4.1.0-alpha.0

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 (1536) hide show
  1. package/AGENTS.md +35 -5
  2. package/CONTRIBUTING.md +18 -29
  3. package/README.md +55 -29
  4. package/actions/build/artifact/prepare-attestation/README.md +26 -0
  5. package/actions/build/artifact/seal-attestation/README.md +26 -0
  6. package/actions/build/lifecycle/run/README.md +71 -0
  7. package/actions/build/lifecycle/validate/README.md +52 -0
  8. package/actions/governance/incident/report/README.md +107 -0
  9. package/actions/release/promotion/ref/README.md +92 -0
  10. package/architecture/action-taxonomy.json +543 -0
  11. package/architecture/agent-change-map.md +2061 -431
  12. package/architecture/build-environments.json +18 -2
  13. package/architecture/build-orchestration.json +58 -9
  14. package/architecture/capability-state-machine-manifest.json +15 -16
  15. package/architecture/capability-state-machine-manifest.schema.json +2 -2
  16. package/architecture/ci-lane-change-budget.json +2105 -225
  17. package/architecture/code-layout.json +55 -0
  18. package/architecture/core-mechanisms.json +1160 -0
  19. package/architecture/cross-platform-adopter-qualification.json +4 -14
  20. package/architecture/delivery-authority-parity.json +46 -46
  21. package/architecture/delivery-warrant-shadow-bootstrap-plan.json +4 -4
  22. package/architecture/delivery-warrant-shadow-bootstrap-plan.md +3 -3
  23. package/architecture/dev-delivery-orchestration.json +175 -0
  24. package/architecture/floating-consumer-policy.json +15 -11
  25. package/architecture/history/warrant-shadow-observations.json +900 -0
  26. package/architecture/internal-capabilities.json +2332 -358
  27. package/architecture/layered-transition.json +32 -0
  28. package/architecture/maintainability-debt.json +883 -1840
  29. package/architecture/maintainability-policy.json +63 -1438
  30. package/architecture/partial-mutation-recovery-qualification.json +4 -4
  31. package/architecture/platform-stage-checkpoints.json +1 -1
  32. package/architecture/promotion-job-topology.json +85 -0
  33. package/architecture/provider-operation-journal-contract.json +5 -5
  34. package/architecture/publication-facade-patches.json +5 -5
  35. package/architecture/release-activation-shadow-domain.json +4 -4
  36. package/architecture/release-invocation-fixtures.json +31 -16
  37. package/architecture/release-tail-contract-inventory.json +1 -9
  38. package/architecture/release-tail-contract.json +273 -0
  39. package/architecture/release-topology.json +245 -215
  40. package/architecture/runtime-ref-resume-authority.json +1 -1
  41. package/architecture/runtime-semantic-closure.json +27 -17
  42. package/architecture/rust-libnode-bridge-evaluation.json +1 -1
  43. package/architecture/rust-wasm-production-authority.json +7 -7
  44. package/architecture/stable-publication-fence.json +4 -4
  45. package/architecture/stage-capsule-qualification.json +4 -4
  46. package/architecture/stage-capsule-resume-planner.json +1 -1
  47. package/architecture/stage-capsule-store-contract.json +2 -2
  48. package/architecture/tail-reseal-parity.json +22 -17
  49. package/architecture/universal-workflow-bootstrap.json +121 -102
  50. package/architecture/universal-workflow-fault-campaign.json +11 -11
  51. package/architecture/universal-workflow-train-admission.json +44 -8
  52. package/architecture/workflow-taxonomy.json +81 -798
  53. package/bin/buildchain.mjs +2 -1820
  54. package/contracts/buildchain-v2-residuals-v1.json +2 -138
  55. package/contracts/dev-delivery-authority-v2.schema.json +509 -231
  56. package/contracts/fixtures/v4-tail-reseal-v1/valid.json +1 -1
  57. package/contracts/promotion-invocation-v1.schema.json +547 -0
  58. package/contracts/promotion-request-v1.schema.json +472 -0
  59. package/contracts/v4-adopter-delivery-v1.schema.json +1 -1
  60. package/contracts/v4-compatibility-facts-v1.schema.json +4 -4
  61. package/contracts/v4-floating-consumer-policy-receipt-v1.schema.json +124 -21
  62. package/contracts/v4-release-invocation-v1.schema.json +1 -1
  63. package/crates/buildchain-host-bridge/src/main.rs +1 -1
  64. package/dist/site/buildchain-contract.json +145 -2206
  65. package/dist/site/buildchain-site.json +350 -326
  66. package/dist/site/capability-registry.json +17 -17
  67. package/dist/site/cli-registry.json +354 -365
  68. package/dist/site/controller-registry.json +142 -715
  69. package/dist/site/kfd-claims.json +5871 -3138
  70. package/dist/site/kfd-upstream-aggregate.json +1 -1
  71. package/dist/site/manual-registry.json +26 -26
  72. package/dist/site/node-api-registry.json +12561 -16063
  73. package/dist/site/page-registry.json +312 -292
  74. package/dist/site/public-surface-audit.json +3844 -3601
  75. package/dist/site/publication-authority-registry.json +295 -1117
  76. package/dist/site/publication-registry.json +5 -5
  77. package/dist/site/release-provenance.json +80 -90
  78. package/dist/site/schemas/dev-delivery-authority-v2.schema.json +509 -231
  79. package/dist/site/schemas/v4-adopter-delivery-v1.schema.json +1 -1
  80. package/dist/site/schemas/v4-compatibility-facts-v1.schema.json +4 -4
  81. package/dist/site/site-manifest.json +31 -31
  82. package/dist/site/workflow-registry.json +7274 -5321
  83. package/docs/MAP.md +8 -6
  84. package/docs/auditable-demo.md +4 -4
  85. package/docs/aws-us-elastic-runner-burst-plane.md +5 -5
  86. package/docs/binary-distribution.md +2 -2
  87. package/docs/bootstrap-recovery.md +50 -0
  88. package/docs/cli-reference.md +2 -35
  89. package/docs/cli.md +6 -6
  90. package/docs/code-organization.md +131 -0
  91. package/docs/consumer-issue-reporting.md +1 -1
  92. package/docs/dev-alpha-candidate-patrol.md +1 -1
  93. package/docs/dev-delivery-orchestration.md +116 -0
  94. package/docs/dev-delivery-qualification-landing-adr.md +1 -1
  95. package/docs/dev-delivery-warrant.md +5 -2
  96. package/docs/dev-qualification-patrol.md +1 -1
  97. package/docs/engineering-housekeeper.md +3 -3
  98. package/docs/github-artifact-attestation.md +3 -3
  99. package/docs/kfd-support.md +1 -1
  100. package/docs/lifecycle-protocol.md +8 -8
  101. package/docs/migration-inventory.md +6 -6
  102. package/docs/next-development-transition.md +4 -4
  103. package/docs/node-api-reference.md +2273 -2644
  104. package/docs/ownership.md +3 -3
  105. package/docs/publication-artifacts.md +5 -5
  106. package/docs/publication-authority.md +4 -4
  107. package/docs/publish-transaction.md +10 -10
  108. package/docs/release-activation-transaction.md +1 -1
  109. package/docs/release-candidate.md +4 -4
  110. package/docs/release-governance.md +25 -25
  111. package/docs/release-passport.md +2 -2
  112. package/docs/release-promotion-request.md +64 -0
  113. package/docs/release-propagation.md +19 -18
  114. package/docs/release-tail-contract.md +40 -76
  115. package/docs/release-tail-provider-plane.md +17 -26
  116. package/docs/reusable-build-surface.md +34 -21
  117. package/docs/shifu-gate-profiles.md +4 -4
  118. package/docs/site-bundle-contract.md +1 -1
  119. package/docs/stable-candidate-patrol.md +1 -1
  120. package/docs/v4-adopter-delivery.md +50 -121
  121. package/docs/v4-canonical-contracts.md +3 -3
  122. package/docs/v4-compatibility-facts.md +1 -1
  123. package/docs/v4-declarative-release-tail-migration.md +24 -29
  124. package/docs/v4-production-release.md +16 -1
  125. package/docs/v4-publication-rehearsal.md +1 -1
  126. package/docs/v4-runtime-ref-resume-authority.md +2 -2
  127. package/docs/v4-rust-wasm-production-authority.md +2 -2
  128. package/docs/v4-stage-capsule.md +1 -1
  129. package/docs/web-surface-deployments.md +22 -28
  130. package/docs/workflow-catalog.md +82 -127
  131. package/docs/workflow-path-migration.md +1 -5
  132. package/package.json +99 -102
  133. package/packages/core/README.md +41 -164
  134. package/packages/core/adoption/adopter-delivery-parity.js +219 -0
  135. package/packages/core/adoption/adopter-delivery.js +210 -0
  136. package/packages/core/adoption/buildchain-kfd-claims.js +733 -0
  137. package/packages/core/adoption/cli/delivery.mjs +39 -0
  138. package/packages/core/adoption/cli/dispatch.mjs +5 -0
  139. package/packages/core/adoption/cli/kfd-aggregate.mjs +20 -0
  140. package/packages/core/adoption/cli/kfd-hub.mjs +53 -0
  141. package/packages/core/adoption/cli/kfd-migrate-layout.mjs +27 -0
  142. package/packages/core/adoption/cli/kfd-schema.mjs +55 -0
  143. package/packages/core/adoption/cli/kfd-status.mjs +21 -0
  144. package/packages/core/adoption/cli/kfd-upstream.mjs +69 -0
  145. package/packages/core/adoption/cli/kfd.mjs +63 -0
  146. package/packages/core/adoption/cli/output.mjs +18 -0
  147. package/packages/core/adoption/cli/product-gate.mjs +110 -0
  148. package/packages/core/adoption/cli/project.mjs +38 -0
  149. package/packages/core/adoption/cli/standards.mjs +282 -0
  150. package/packages/core/adoption/cli/support.mjs +101 -0
  151. package/packages/core/adoption/cli/surface-register.mjs +172 -0
  152. package/packages/core/adoption/commands/cross-platform-adopter-qualification.mjs +28 -0
  153. package/packages/core/adoption/commands/init-repo.mjs +518 -0
  154. package/packages/core/adoption/cross-platform-adopter-qualification.js +217 -0
  155. package/packages/core/adoption/kfd-agent-hub.js +496 -0
  156. package/packages/core/adoption/kfd.js +966 -0
  157. package/packages/core/adoption/kfd2-product-claims.js +454 -0
  158. package/packages/core/adoption/kfd3-surface-register.js +924 -0
  159. package/packages/core/adoption/qualification/actions.js +106 -0
  160. package/packages/core/adoption/qualification/admission.js +96 -0
  161. package/packages/core/adoption/qualification/aggregate.js +10 -0
  162. package/packages/core/adoption/qualification/io.js +51 -0
  163. package/packages/core/adoption/qualification/platform.js +120 -0
  164. package/packages/core/build/anchored-version-material.js +281 -0
  165. package/packages/core/build/artifact/actions.js +47 -0
  166. package/packages/core/build/artifact/attestation.js +166 -0
  167. package/packages/core/build/artifact/contracts.js +168 -0
  168. package/packages/core/build/artifact/coordinates.js +113 -0
  169. package/packages/core/build/artifact/credential-transport.js +68 -0
  170. package/packages/core/build/artifact/expectations.js +94 -0
  171. package/packages/core/build/artifact/files.js +14 -0
  172. package/packages/core/build/artifact/naming.js +65 -0
  173. package/packages/core/build/artifact/services.js +17 -0
  174. package/packages/core/build/artifact/store.js +119 -0
  175. package/packages/core/build/artifact/summary.js +20 -0
  176. package/packages/core/build/artifact/transfer-policy.js +34 -0
  177. package/packages/core/build/artifact/transport.js +112 -0
  178. package/packages/core/build/artifact/upload.js +178 -0
  179. package/packages/core/build/artifact-coordinate-action.js +46 -0
  180. package/packages/core/build/artifact-coordinate.js +58 -0
  181. package/packages/core/build/artifact-integrity.js +10 -0
  182. package/packages/core/build/artifact-passport.js +842 -0
  183. package/packages/core/build/artifact-verification-envelope.js +500 -0
  184. package/packages/core/build/binary/actions.js +77 -0
  185. package/packages/core/build/binary/checksums.js +33 -0
  186. package/packages/core/build/binary/distribution.js +271 -0
  187. package/packages/core/build/binary-publication-dispatch.js +49 -0
  188. package/packages/core/build/build-facts.js +518 -0
  189. package/packages/core/build/cache/compiler-evidence.js +287 -0
  190. package/packages/core/build/cli/cache.mjs +77 -0
  191. package/packages/core/build/cli/facts.mjs +120 -0
  192. package/packages/core/build/cli/homebrew.mjs +101 -0
  193. package/packages/core/build/cli/lifecycle.mjs +66 -0
  194. package/packages/core/build/commands/aggregate-build-summary.mjs +75 -0
  195. package/packages/core/build/commands/anchored-version-material.mjs +42 -0
  196. package/packages/core/build/commands/artifact-signing-controller.mjs +112 -0
  197. package/packages/core/build/commands/artifact-signing-delegation.mjs +34 -0
  198. package/packages/core/build/commands/auditable-demo-platform.mjs +77 -0
  199. package/packages/core/build/commands/auditable-demo-transport-smoke.mjs +24 -0
  200. package/packages/core/build/commands/auditable-demo.mjs +63 -0
  201. package/packages/core/build/commands/compiler-cache-evidence.mjs +39 -0
  202. package/packages/core/build/commands/dispatch-artifact-signing-authority.mjs +19 -0
  203. package/packages/core/build/commands/import-artifact-signing-results.mjs +10 -0
  204. package/packages/core/build/commands/lifecycle-substage-evidence.mjs +42 -0
  205. package/packages/core/build/commands/resolve-artifact-coordinates.mjs +58 -0
  206. package/packages/core/build/commands/resolve-artifact-transfer-mode.mjs +54 -0
  207. package/packages/core/build/commands/resolve-build-configuration.mjs +23 -0
  208. package/packages/core/build/commands/resolve-build-contract.mjs +94 -0
  209. package/packages/core/build/commands/run-candidate-body-prefix-renderer.mjs +24 -0
  210. package/packages/core/build/commands/run-lifecycle.mjs +56 -0
  211. package/packages/core/build/commands/seal-artifact-signing-requests.mjs +10 -0
  212. package/packages/core/build/commands/seal-macos-credential-input.mjs +4 -0
  213. package/packages/core/build/commands/shifu-gate-profile.mjs +43 -0
  214. package/packages/core/build/commands/source-verification-evidence.mjs +14 -0
  215. package/packages/core/build/commands/stage-capsule-qualification.mjs +79 -0
  216. package/packages/core/build/commands/validate-package-manager-contract.mjs +24 -0
  217. package/packages/core/build/credential/seal-input.js +109 -0
  218. package/packages/core/build/demo/action-context.js +25 -0
  219. package/packages/core/build/demo/adapter-actions.js +35 -0
  220. package/packages/core/build/demo/adapter-transactions.js +66 -0
  221. package/packages/core/build/demo/adapter.js +272 -0
  222. package/packages/core/build/demo/binary-action.js +29 -0
  223. package/packages/core/build/demo/bundle-verification.js +211 -0
  224. package/packages/core/build/demo/capture-adaptation.js +37 -0
  225. package/packages/core/build/demo/capture.js +377 -0
  226. package/packages/core/build/demo/collection-actions.js +62 -0
  227. package/packages/core/build/demo/collection-containers.js +136 -0
  228. package/packages/core/build/demo/collection-context.js +40 -0
  229. package/packages/core/build/demo/collection.js +129 -0
  230. package/packages/core/build/demo/composition.js +319 -0
  231. package/packages/core/build/demo/container.js +113 -0
  232. package/packages/core/build/demo/gate.js +297 -0
  233. package/packages/core/build/demo/inspection-worker.js +4 -0
  234. package/packages/core/build/demo/io.js +220 -0
  235. package/packages/core/build/demo/materialization.js +350 -0
  236. package/packages/core/build/demo/media-bundle.js +112 -0
  237. package/packages/core/build/demo/media-inspection.js +332 -0
  238. package/packages/core/build/demo/media-profile.js +399 -0
  239. package/packages/core/build/demo/media-qualification-action.js +37 -0
  240. package/packages/core/build/demo/media-qualification.js +117 -0
  241. package/packages/core/build/demo/presentation.js +222 -0
  242. package/packages/core/build/demo/publication.js +118 -0
  243. package/packages/core/build/demo/renderer-evidence.js +193 -0
  244. package/packages/core/build/demo/renditions.js +398 -0
  245. package/packages/core/build/demo/scenario.js +493 -0
  246. package/packages/core/build/demo/schema.js +278 -0
  247. package/packages/core/build/demo/transport-smoke.js +149 -0
  248. package/packages/core/build/demo/values.js +137 -0
  249. package/packages/core/build/environment/action.js +17 -0
  250. package/packages/core/build/environment/provision.js +121 -0
  251. package/packages/core/build/gate/actions.js +99 -0
  252. package/packages/core/build/gate/aggregate.js +21 -0
  253. package/packages/core/build/gate/commands.js +66 -0
  254. package/packages/core/build/gate/controller.js +43 -0
  255. package/packages/core/build/gate/environment.js +18 -0
  256. package/packages/core/build/gate/execution.js +88 -0
  257. package/packages/core/build/gate/files.js +46 -0
  258. package/packages/core/build/gate/outputs.js +31 -0
  259. package/packages/core/build/gate/plan.js +61 -0
  260. package/packages/core/build/github-artifact-attestation.js +642 -0
  261. package/packages/core/build/github-attestation/action.js +26 -0
  262. package/packages/core/build/github-attestation/admission.js +34 -0
  263. package/packages/core/build/github-attestation/transaction.js +83 -0
  264. package/packages/core/build/homebrew.js +416 -0
  265. package/packages/core/build/lifecycle/action.js +65 -0
  266. package/packages/core/build/lifecycle/artifacts.js +123 -0
  267. package/packages/core/build/lifecycle/context.js +202 -0
  268. package/packages/core/build/lifecycle/diagnostics.js +254 -0
  269. package/packages/core/build/lifecycle/errors.js +44 -0
  270. package/packages/core/build/lifecycle/execution.js +221 -0
  271. package/packages/core/build/lifecycle/files.js +61 -0
  272. package/packages/core/build/lifecycle/manifest.js +107 -0
  273. package/packages/core/build/lifecycle/sampling.js +209 -0
  274. package/packages/core/build/lifecycle/stage-action.js +18 -0
  275. package/packages/core/build/lifecycle/stage.js +143 -0
  276. package/packages/core/build/lifecycle/substage-evidence.js +232 -0
  277. package/packages/core/build/lifecycle/transaction.js +13 -0
  278. package/packages/core/build/macos-credential-island/action.js +704 -0
  279. package/packages/core/build/macos-credential-island/cleanup.js +48 -0
  280. package/packages/core/build/macos-credential-island/dmg-assembly.js +443 -0
  281. package/packages/core/build/macos-credential-island/lib.js +816 -0
  282. package/packages/core/build/package-manager.js +315 -0
  283. package/packages/core/build/plan/action-context.js +30 -0
  284. package/packages/core/build/plan/action.js +79 -0
  285. package/packages/core/build/plan/admission.js +93 -0
  286. package/packages/core/build/plan/configuration.js +196 -0
  287. package/packages/core/build/plan/environment.js +18 -0
  288. package/packages/core/build/plan/identity.js +49 -0
  289. package/packages/core/build/plan/lifecycle.js +38 -0
  290. package/packages/core/build/plan/matrices.js +58 -0
  291. package/packages/core/build/plan/resolve.js +76 -0
  292. package/packages/core/build/plan/runners.js +48 -0
  293. package/packages/core/build/plan/source.js +58 -0
  294. package/packages/core/build/plan/stage-order.js +10 -0
  295. package/packages/core/build/plan/values.js +10 -0
  296. package/packages/core/build/platform-stage-checkpoints.js +471 -0
  297. package/packages/core/build/release-evidence-bundle.js +156 -0
  298. package/packages/core/build/runner/matrix.js +266 -0
  299. package/packages/core/build/runner/presets.js +115 -0
  300. package/packages/core/build/signing/actions.js +54 -0
  301. package/packages/core/build/signing/authority-actions.js +147 -0
  302. package/packages/core/build/signing/authority-transaction.js +82 -0
  303. package/packages/core/build/signing/control.js +223 -0
  304. package/packages/core/build/signing/controller-transaction.js +110 -0
  305. package/packages/core/build/signing/credential-transaction.js +66 -0
  306. package/packages/core/build/signing/delegation.js +281 -0
  307. package/packages/core/build/signing/detached.js +170 -0
  308. package/packages/core/build/signing/dispatch.js +307 -0
  309. package/packages/core/build/signing/environment.js +13 -0
  310. package/packages/core/build/signing/files.js +53 -0
  311. package/packages/core/build/signing/import-results.js +151 -0
  312. package/packages/core/build/signing/intake.js +113 -0
  313. package/packages/core/build/signing/materialize.js +54 -0
  314. package/packages/core/build/signing/merge-results.js +82 -0
  315. package/packages/core/build/signing/native-result.js +244 -0
  316. package/packages/core/build/signing/prepare.js +44 -0
  317. package/packages/core/build/signing/request.js +519 -0
  318. package/packages/core/build/signing/seal-requests.js +402 -0
  319. package/packages/core/build/signing/transaction.js +158 -0
  320. package/packages/core/build/signing/verify-results.js +118 -0
  321. package/packages/core/build/source/checkout-action.js +16 -0
  322. package/packages/core/build/source/controller-actions.js +52 -0
  323. package/packages/core/build/source/controller.js +182 -0
  324. package/packages/core/build/source/lifecycle-action.js +32 -0
  325. package/packages/core/build/source/lifecycle.js +134 -0
  326. package/packages/core/build/source/proof-actions.js +57 -0
  327. package/packages/core/build/source/proof-lookup.js +82 -0
  328. package/packages/core/build/source/proof.js +134 -0
  329. package/packages/core/build/source-admission.js +35 -0
  330. package/packages/core/build/stage-capsule/actions.js +53 -0
  331. package/packages/core/build/stage-capsule/campaign/aggregate.js +51 -0
  332. package/packages/core/build/stage-capsule/campaign/context.js +51 -0
  333. package/packages/core/build/stage-capsule/campaign/resume.js +240 -0
  334. package/packages/core/build/stage-capsule/campaign/run.js +47 -0
  335. package/packages/core/build/stage-capsule/campaign/seed.js +124 -0
  336. package/packages/core/build/stage-capsule/campaign/worker.js +17 -0
  337. package/packages/core/build/stage-capsule/canary.js +62 -0
  338. package/packages/core/build/stage-capsule/rehearsal/checkpoint.js +110 -0
  339. package/packages/core/build/stage-capsule/rehearsal/files.js +36 -0
  340. package/packages/core/build/stage-capsule/rehearsal/macos-tail.js +104 -0
  341. package/packages/core/build/stage-capsule/rehearsal/resume.js +38 -0
  342. package/packages/core/build/stage-capsule/rehearsal/run.js +46 -0
  343. package/packages/core/build/stage-capsule/rehearsal/verify.js +56 -0
  344. package/packages/core/build/stage-capsule/rehearsal/worker.js +11 -0
  345. package/packages/core/build/stage-capsule-local-store.js +428 -0
  346. package/packages/core/build/stage-capsule-qualification-campaign.js +511 -0
  347. package/packages/core/build/stage-capsule-qualification.js +455 -0
  348. package/packages/core/build/stage-capsule-resume-planner.js +397 -0
  349. package/packages/core/build/stage-capsule-store.js +404 -0
  350. package/packages/core/build/stage-capsule.js +319 -0
  351. package/packages/core/build/standalone/build.js +266 -0
  352. package/packages/core/build/standalone/bundle.js +69 -0
  353. package/packages/core/build/standalone/identity.js +47 -0
  354. package/packages/core/build/standalone/logging.js +72 -0
  355. package/packages/core/build/standalone/process.js +50 -0
  356. package/packages/core/build/summary/action.js +33 -0
  357. package/packages/core/build/summary/aggregation.js +120 -0
  358. package/packages/core/build/summary/artifacts.js +165 -0
  359. package/packages/core/build/summary/controller-receipt.js +50 -0
  360. package/packages/core/build/summary/execution.js +39 -0
  361. package/packages/core/build/summary/finalization.js +133 -0
  362. package/packages/core/build/summary/payloads.js +80 -0
  363. package/packages/core/build/validate-config/action.js +58 -0
  364. package/packages/core/build/validate-config/lib.js +42 -0
  365. package/packages/core/build/verification/actions.js +54 -0
  366. package/packages/core/build/verification/discovery.js +115 -0
  367. package/packages/core/build/verification/identity.js +123 -0
  368. package/packages/core/build/verification/proof.js +8 -0
  369. package/packages/core/build/verification/repository.js +4 -0
  370. package/packages/core/build/verification/runner.js +69 -0
  371. package/packages/core/build/verification/source.js +169 -0
  372. package/packages/core/consumer/buildchain-config.js +1825 -0
  373. package/packages/core/consumer/channel-selection.js +211 -0
  374. package/packages/core/consumer/cli/infrastructure.mjs +6 -0
  375. package/packages/core/consumer/commands/buildchain-channel-router.mjs +81 -0
  376. package/packages/core/consumer/commands/consumer-policy.mjs +229 -0
  377. package/packages/core/consumer/floating-consumer-evidence.js +341 -0
  378. package/packages/core/consumer/floating-consumer-policy.js +596 -0
  379. package/packages/core/consumer/invocation-selector.js +4 -0
  380. package/packages/core/consumer/policy-admission.js +103 -0
  381. package/packages/core/consumer/policy-scan.js +33 -0
  382. package/packages/core/consumer/runtime-selector-persistence.js +291 -0
  383. package/packages/core/consumer/workflow-definition-authority.js +64 -0
  384. package/packages/core/contracts/action-inventory.js +78 -0
  385. package/packages/core/contracts/action-taxonomy.js +46 -0
  386. package/packages/core/contracts/buildchain-contract.js +1038 -0
  387. package/packages/core/contracts/canonical-contracts.js +239 -0
  388. package/packages/core/contracts/cli/context.mjs +28 -0
  389. package/packages/core/contracts/cli/introspection.mjs +47 -0
  390. package/packages/core/contracts/cli/options.mjs +85 -0
  391. package/packages/core/contracts/cli-reference.js +192 -0
  392. package/packages/core/contracts/commands/buildchain-contract-lock.mjs +120 -0
  393. package/packages/core/contracts/commands/workflow-call-contract.mjs +133 -0
  394. package/packages/core/contracts/public-surface-audit.js +274 -0
  395. package/packages/core/contracts/public-surface-cli.js +134 -0
  396. package/packages/core/contracts/runtime-contract-action.js +48 -0
  397. package/packages/core/contracts/runtime-contract-inspection.js +115 -0
  398. package/packages/core/contracts/structured-values.js +29 -0
  399. package/packages/core/contracts/workflow-yaml-contract.js +373 -0
  400. package/packages/core/dev-delivery/admission/gh-cli-client.js +110 -0
  401. package/packages/core/dev-delivery/admission/github-client.js +274 -0
  402. package/packages/core/dev-delivery/admission/policy.js +177 -0
  403. package/packages/core/dev-delivery/admission/queue.js +554 -0
  404. package/packages/core/dev-delivery/admission/readiness.js +222 -0
  405. package/packages/core/dev-delivery/admission/report.js +27 -0
  406. package/packages/core/dev-delivery/admission/request.js +34 -0
  407. package/packages/core/dev-delivery/admission/targeted.js +375 -0
  408. package/packages/core/dev-delivery/admission/transaction.js +47 -0
  409. package/packages/core/dev-delivery/buildchain-delivery-bootstrap.js +240 -0
  410. package/packages/core/dev-delivery/buildchain-delivery-infrastructure.js +164 -0
  411. package/packages/core/dev-delivery/buildchain-delivery-self-dogfood.js +395 -0
  412. package/packages/core/dev-delivery/candidate/admission-actions.js +34 -0
  413. package/packages/core/dev-delivery/candidate/admission.js +172 -0
  414. package/packages/core/dev-delivery/candidate/coordinates.js +46 -0
  415. package/packages/core/dev-delivery/candidate/evidence.js +20 -0
  416. package/packages/core/dev-delivery/candidate/request.js +39 -0
  417. package/packages/core/dev-delivery/candidate/reservation-action.js +21 -0
  418. package/packages/core/dev-delivery/candidate/reservation.js +98 -0
  419. package/packages/core/dev-delivery/candidate/source-paths.js +102 -0
  420. package/packages/core/dev-delivery/candidate/submission.js +41 -0
  421. package/packages/core/dev-delivery/cli/dispatch.mjs +54 -0
  422. package/packages/core/dev-delivery/commands/dev-delivery-authority-command-adapters.mjs +193 -0
  423. package/packages/core/dev-delivery/commands/dev-delivery-authority-provider.mjs +28 -0
  424. package/packages/core/dev-delivery/commands/dev-delivery-authority.mjs +454 -0
  425. package/packages/core/dev-delivery/commands/dev-delivery-process-boundary.mjs +93 -0
  426. package/packages/core/dev-delivery/commands/dev-delivery-proof.mjs +258 -0
  427. package/packages/core/dev-delivery/commands/dev-delivery-provider-heartbeat.mjs +76 -0
  428. package/packages/core/dev-delivery/commands/dev-delivery-request.sh +160 -0
  429. package/packages/core/dev-delivery/commands/dev-delivery-source-proof-reuse.mjs +128 -0
  430. package/packages/core/dev-delivery/commands/dev-delivery-two-phase.mjs +180 -0
  431. package/packages/core/dev-delivery/commands/dev-delivery-warrant-options.mjs +283 -0
  432. package/packages/core/dev-delivery/commands/dev-delivery-warrant.mjs +65 -0
  433. package/packages/core/dev-delivery/commands/dev-merge-queue.mjs +98 -0
  434. package/packages/core/dev-delivery/commands/dev-pr-auto-merge.mjs +111 -0
  435. package/packages/core/dev-delivery/commands/dev-pr-delivery-warrant.mjs +467 -0
  436. package/packages/core/dev-delivery/commands/dev-pr-prequeue-guard.mjs +381 -0
  437. package/packages/core/dev-delivery/commands/dev-qualification-patrol.mjs +21 -0
  438. package/packages/core/dev-delivery/delivery-warrant-fixture-runner.js +375 -0
  439. package/packages/core/dev-delivery/delivery-warrant-read-candidate.js +281 -0
  440. package/packages/core/dev-delivery/delivery-warrant-semantic-diff-gate.js +351 -0
  441. package/packages/core/dev-delivery/delivery-warrant-shadow-adapter.js +444 -0
  442. package/packages/core/dev-delivery/dev-delivery-authority-candidate.js +197 -0
  443. package/packages/core/dev-delivery/dev-delivery-authority-landing.js +459 -0
  444. package/packages/core/dev-delivery/dev-delivery-authority-state.js +424 -0
  445. package/packages/core/dev-delivery/dev-delivery-candidate-identity.js +152 -0
  446. package/packages/core/dev-delivery/dev-delivery-contract-surface.js +74 -0
  447. package/packages/core/dev-delivery/dev-delivery-native-proof.js +509 -0
  448. package/packages/core/dev-delivery/dev-delivery-proof.js +282 -0
  449. package/packages/core/dev-delivery/dev-delivery-warrant-native-requirements.js +7 -0
  450. package/packages/core/dev-delivery/dev-delivery-warrant-state.js +580 -0
  451. package/packages/core/dev-delivery/dev-delivery-warrant.js +588 -0
  452. package/packages/core/dev-delivery/merge-queue-policy.js +543 -0
  453. package/packages/core/dev-delivery/native/action-context.js +59 -0
  454. package/packages/core/dev-delivery/native/actions.js +74 -0
  455. package/packages/core/dev-delivery/native/attempt.js +93 -0
  456. package/packages/core/dev-delivery/native/candidate.js +101 -0
  457. package/packages/core/dev-delivery/native/context-record.js +26 -0
  458. package/packages/core/dev-delivery/native/execution.js +176 -0
  459. package/packages/core/dev-delivery/native/failure.js +105 -0
  460. package/packages/core/dev-delivery/native/files.js +11 -0
  461. package/packages/core/dev-delivery/native/finalizer-admission.js +93 -0
  462. package/packages/core/dev-delivery/native/heartbeat-action.js +29 -0
  463. package/packages/core/dev-delivery/native/heartbeat.js +137 -0
  464. package/packages/core/dev-delivery/native/provider-boundary.js +71 -0
  465. package/packages/core/dev-delivery/native/qualification.js +228 -0
  466. package/packages/core/dev-delivery/native/readback.js +32 -0
  467. package/packages/core/dev-delivery/native/reuse.js +60 -0
  468. package/packages/core/dev-delivery/native/seal-action.js +19 -0
  469. package/packages/core/dev-delivery/native/transactions.js +156 -0
  470. package/packages/core/dev-delivery/native/transfer.js +122 -0
  471. package/packages/core/dev-delivery/published-delivery-authority.js +266 -0
  472. package/packages/core/dev-delivery/qualification/action.js +60 -0
  473. package/packages/core/dev-delivery/qualification/controller.js +218 -0
  474. package/packages/core/dev-delivery/qualification/github-client.js +108 -0
  475. package/packages/core/dev-delivery/qualification/model.js +186 -0
  476. package/packages/core/dev-delivery/qualification/report.js +25 -0
  477. package/packages/core/dev-delivery/queue/completion.js +52 -0
  478. package/packages/core/dev-delivery/queue/landing-action.js +60 -0
  479. package/packages/core/dev-delivery/queue/reconciliation-action.js +45 -0
  480. package/packages/core/dev-delivery/source-proof/evidence.js +92 -0
  481. package/packages/core/dev-delivery/source-proof/io.js +97 -0
  482. package/packages/core/dev-delivery/source-proof/predicates.js +88 -0
  483. package/packages/core/dev-delivery/source-proof/replay.js +143 -0
  484. package/packages/core/dev-delivery/source-proof/reuse.js +116 -0
  485. package/packages/core/dev-delivery/source-proof/seal.js +32 -0
  486. package/packages/core/dev-delivery/warrant/actions.js +78 -0
  487. package/packages/core/dev-delivery/warrant/cancellation.js +49 -0
  488. package/packages/core/dev-delivery/warrant/failure-settlement.js +93 -0
  489. package/packages/core/dev-delivery/warrant/handoff.js +107 -0
  490. package/packages/core/dev-delivery/warrant/observation.js +59 -0
  491. package/packages/core/dev-delivery/warrant/persistence.js +109 -0
  492. package/packages/core/dev-delivery/warrant/reservation-readback.js +72 -0
  493. package/packages/core/dev-delivery/warrant/service.js +134 -0
  494. package/packages/core/dev-delivery/warrant/terminal-policy.js +53 -0
  495. package/packages/core/dev-delivery/warrant/terminal.js +89 -0
  496. package/packages/core/dev-delivery/warrant/transitions.js +222 -0
  497. package/packages/core/dev-delivery/warrant/values.js +102 -0
  498. package/packages/core/governance/alpha-candidate/action.js +96 -0
  499. package/packages/core/governance/alpha-candidate/controller.js +490 -0
  500. package/packages/core/governance/alpha-candidate/lifecycle.js +121 -0
  501. package/packages/core/governance/alpha-candidate/options.js +60 -0
  502. package/packages/core/governance/alpha-candidate/outputs.js +23 -0
  503. package/packages/core/governance/alpha-candidate/provider.js +192 -0
  504. package/packages/core/governance/alpha-candidate/report.js +56 -0
  505. package/packages/core/governance/alpha-candidate/state.js +184 -0
  506. package/packages/core/governance/alpha-candidate/values.js +90 -0
  507. package/packages/core/governance/architecture-graph.js +24 -0
  508. package/packages/core/governance/audit/actions.js +57 -0
  509. package/packages/core/governance/audit/collection.js +259 -0
  510. package/packages/core/governance/audit/github-reader.js +204 -0
  511. package/packages/core/governance/audit/identity.js +86 -0
  512. package/packages/core/governance/audit/incident.mjs +39 -0
  513. package/packages/core/governance/audit/transactions.js +75 -0
  514. package/packages/core/governance/buildchain-compatibility-authority.js +335 -0
  515. package/packages/core/governance/buildchain-compatibility-fact.js +386 -0
  516. package/packages/core/governance/buildchain-compatibility-facts.json +18 -0
  517. package/packages/core/governance/buildchain-compatibility-proof.js +523 -0
  518. package/packages/core/governance/buildchain-publication-authority.js +117 -0
  519. package/packages/core/governance/candidate/body-action.js +18 -0
  520. package/packages/core/governance/candidate/body-renderer.js +160 -0
  521. package/packages/core/governance/ci-lane-change-budget.js +260 -0
  522. package/packages/core/governance/cli/compatibility-facts.mjs +101 -0
  523. package/packages/core/governance/cli/dispatch.mjs +19 -0
  524. package/packages/core/governance/cli/doctor.mjs +144 -0
  525. package/packages/core/governance/commands/architecture.mjs +594 -0
  526. package/packages/core/governance/commands/audit-github-governance.mjs +43 -0
  527. package/packages/core/governance/commands/audit-publication-control-plane.mjs +26 -0
  528. package/packages/core/governance/commands/buildchain-patrol.mjs +32 -0
  529. package/packages/core/governance/commands/create-github-artifact-attestation-policy.mjs +62 -0
  530. package/packages/core/governance/commands/engineering-housekeeper-workflow.mjs +23 -0
  531. package/packages/core/governance/commands/reconcile-github-governance.mjs +689 -0
  532. package/packages/core/governance/commands/reconcile-release-governance.mjs +77 -0
  533. package/packages/core/governance/commands/workflow-friction-report.mjs +375 -0
  534. package/packages/core/governance/github-governance-authority.js +1367 -0
  535. package/packages/core/governance/housekeeping/action.js +45 -0
  536. package/packages/core/governance/housekeeping/execution.js +75 -0
  537. package/packages/core/governance/housekeeping/options.js +103 -0
  538. package/packages/core/governance/housekeeping/report.js +53 -0
  539. package/packages/core/governance/housekeeping/transactions.js +96 -0
  540. package/packages/core/governance/patrol/action.js +41 -0
  541. package/packages/core/governance/patrol/controller.js +125 -0
  542. package/packages/core/governance/patrol/options.js +121 -0
  543. package/packages/core/governance/patrol/report.js +53 -0
  544. package/packages/core/governance/patrol/transaction.js +30 -0
  545. package/packages/core/governance/publication/audit.js +26 -0
  546. package/packages/core/governance/publication/collection.js +396 -0
  547. package/packages/core/governance/publication/policy-values.js +227 -0
  548. package/packages/core/governance/publication/source-authorization.js +293 -0
  549. package/packages/core/governance/receipt-admission-action.js +12 -0
  550. package/packages/core/governance/receipt-admission.js +34 -0
  551. package/packages/core/governance/release-check-policy.js +179 -0
  552. package/packages/core/governance/release-reconciliation-action.js +25 -0
  553. package/packages/core/governance/release-reconciliation.js +122 -0
  554. package/packages/core/governance/report-issue/action.js +201 -0
  555. package/packages/core/index.js +85 -117
  556. package/packages/core/observability/cli/candidate.mjs +42 -0
  557. package/packages/core/observability/cli/context.mjs +47 -0
  558. package/packages/core/observability/cli/diagnostics.mjs +88 -0
  559. package/packages/core/observability/cli/events.mjs +126 -0
  560. package/packages/core/observability/cli/process-sample.mjs +71 -0
  561. package/packages/core/observability/commands/aggregate-diagnostics-summary.mjs +45 -0
  562. package/packages/core/observability/commands/controller-evidence.mjs +109 -0
  563. package/packages/core/observability/commands/observed-evidence.mjs +27 -0
  564. package/packages/core/observability/controller/identity-action.js +11 -0
  565. package/packages/core/observability/controller/identity.js +32 -0
  566. package/packages/core/observability/controller-actions.js +63 -0
  567. package/packages/core/observability/controller-evidence-io.js +112 -0
  568. package/packages/core/observability/controller-evidence.js +555 -0
  569. package/packages/core/observability/controller-input-boundary.js +47 -0
  570. package/packages/core/observability/diagnostics/aggregate.js +25 -0
  571. package/packages/core/observability/diagnostics.js +1904 -0
  572. package/packages/core/observability/evidence/actions.js +20 -0
  573. package/packages/core/observability/evidence/bundle.js +163 -0
  574. package/packages/core/observability/evidence/publication.js +360 -0
  575. package/packages/core/observability/evidence/transactions.js +62 -0
  576. package/packages/core/observability/process/sampling.js +128 -0
  577. package/packages/core/observability/publisher-admission.js +26 -0
  578. package/packages/core/observability/transaction-journal.js +40 -0
  579. package/packages/core/paper/cli/dispatch.mjs +17 -0
  580. package/packages/core/paper/commands/paper-agent-cli.mjs +35 -0
  581. package/packages/core/paper/commands/paper-work-fleet-cli.mjs +577 -0
  582. package/packages/core/paper/commands/paper.mjs +632 -0
  583. package/packages/core/paper/operations/bootstrap.js +73 -0
  584. package/packages/core/paper/operations/files.js +48 -0
  585. package/packages/core/paper/operations/github-observation.js +136 -0
  586. package/packages/core/paper/operations/identity.js +59 -0
  587. package/packages/core/paper/operations/npm-observation.js +118 -0
  588. package/packages/core/paper/operations/plans.js +213 -0
  589. package/packages/core/paper/operations/preflight-checks.js +269 -0
  590. package/packages/core/paper/operations/provisioning-validation.js +155 -0
  591. package/packages/core/paper/operations/provisioning.js +113 -0
  592. package/packages/core/paper/operations/runtime-observation.js +25 -0
  593. package/packages/core/paper/operations/runtime.js +84 -0
  594. package/packages/core/paper/operations/scaffold-config.js +77 -0
  595. package/packages/core/paper/operations/scaffold-workflows.js +99 -0
  596. package/packages/core/paper/operations/scaffold.js +370 -0
  597. package/packages/core/paper/operations/status-facts.js +264 -0
  598. package/packages/core/paper/operations/status.js +353 -0
  599. package/packages/core/paper/operations/toolchain-observation.js +49 -0
  600. package/packages/core/paper/operations/workspace.js +60 -0
  601. package/packages/core/paper/paper-agent-entry.js +396 -0
  602. package/packages/core/paper/paper-fleet.js +310 -0
  603. package/packages/core/paper/paper-npm-bootstrap.js +492 -0
  604. package/packages/core/paper/paper-repository.js +214 -0
  605. package/packages/core/paper/paper-runtime-channels.js +344 -0
  606. package/packages/core/paper/paper-scaffold-content.js +574 -0
  607. package/packages/core/paper/paper.js +308 -0
  608. package/packages/core/paper/publication/actions.js +109 -0
  609. package/packages/core/paper/publication/candidate.js +140 -0
  610. package/packages/core/paper/publication/controller.js +117 -0
  611. package/packages/core/paper/publication/envelope.js +118 -0
  612. package/packages/core/paper/publication/propagation.js +135 -0
  613. package/packages/core/paper/publication/readback.js +89 -0
  614. package/packages/core/paper/publication/target.js +54 -0
  615. package/packages/core/paper/publication-controller.js +144 -0
  616. package/packages/core/providers/artifact-relay/files.js +71 -0
  617. package/packages/core/providers/artifact-relay/s3-client.js +259 -0
  618. package/packages/core/providers/artifact-relay/transactions.js +258 -0
  619. package/packages/core/providers/commands/artifact-relay-s3.mjs +62 -0
  620. package/packages/core/providers/commands/aws-codebuild-toolchain.mjs +15 -0
  621. package/packages/core/providers/commands/aws-macos-jit-controller-runtime.mjs +82 -0
  622. package/packages/core/providers/commands/aws-runner-burst-core.mjs +249 -0
  623. package/packages/core/providers/commands/aws-runner-burst.mjs +80 -0
  624. package/packages/core/providers/commands/aws-windows-jit-campaign.mjs +202 -0
  625. package/packages/core/providers/commands/aws-windows-jit-controller.mjs +578 -0
  626. package/packages/core/providers/commands/aws-windows-jit-operator.sh +506 -0
  627. package/packages/core/providers/commands/infra-contract-core.mjs +1032 -0
  628. package/packages/core/providers/commands/infra-contract.mjs +345 -0
  629. package/packages/core/providers/commands/locked-source-checkout.mjs +9 -0
  630. package/packages/core/providers/commands/route-offline-runners.mjs +30 -0
  631. package/packages/core/providers/demo/capture-worker.py +541 -0
  632. package/packages/core/providers/dev-delivery/candidate.js +112 -0
  633. package/packages/core/providers/dev-delivery/protection.js +29 -0
  634. package/packages/core/providers/dev-delivery/store.js +292 -0
  635. package/packages/core/providers/git/fetch-process.js +27 -0
  636. package/packages/core/providers/git/fetch-worker.js +146 -0
  637. package/packages/core/providers/git/patch-root.js +54 -0
  638. package/packages/core/providers/git-ref-readback.mjs +22 -0
  639. package/packages/core/providers/github/artifact-attestation.js +32 -0
  640. package/packages/core/providers/github/commits.js +32 -0
  641. package/packages/core/providers/github/json-client.js +65 -0
  642. package/packages/core/providers/github/product-publication.js +44 -0
  643. package/packages/core/providers/github/publication-control-plane.js +116 -0
  644. package/packages/core/providers/github/pull-requests.js +24 -0
  645. package/packages/core/providers/github/qualification.js +181 -0
  646. package/packages/core/providers/github/release-assets.js +91 -0
  647. package/packages/core/providers/github/signing-request.js +81 -0
  648. package/packages/core/providers/github/source-lock.js +98 -0
  649. package/packages/core/providers/github-cli-api.js +35 -0
  650. package/packages/core/providers/github-issue-comment.js +83 -0
  651. package/packages/core/providers/github-permission.js +11 -0
  652. package/packages/core/providers/github-token.js +121 -0
  653. package/packages/core/providers/process/sample-worker.mjs +14 -0
  654. package/packages/core/providers/runner/observation.js +30 -0
  655. package/packages/core/providers/runner/offline-routing.js +205 -0
  656. package/packages/core/providers/signing/detached-key.js +20 -0
  657. package/packages/core/providers/signing/macos/compound-archive.py +434 -0
  658. package/packages/core/providers/signing/macos/sign-request.sh +145 -0
  659. package/packages/core/providers/signing/native.js +77 -0
  660. package/packages/core/providers/signing/windows/sign-request.ps1 +48 -0
  661. package/packages/core/providers/source-checkout/action.js +31 -0
  662. package/packages/core/providers/source-checkout/auth.js +32 -0
  663. package/packages/core/providers/source-checkout/fetch.js +135 -0
  664. package/packages/core/providers/source-checkout/git.js +220 -0
  665. package/packages/core/providers/source-checkout/transaction.js +360 -0
  666. package/packages/core/providers/source-checkout/values.js +115 -0
  667. package/packages/core/providers/source-checkout/workspace.js +50 -0
  668. package/packages/core/providers/sync-git/action.mjs +16 -0
  669. package/packages/core/providers/sync-git/transfer.mjs +86 -0
  670. package/packages/core/providers/toolchain/codebuild-policy.js +36 -0
  671. package/packages/core/providers/toolchain/codebuild.js +220 -0
  672. package/packages/core/publication/authority/actions.js +156 -0
  673. package/packages/core/publication/authority/admission.js +113 -0
  674. package/packages/core/publication/authority/assembly.js +77 -0
  675. package/packages/core/publication/authority/binary-evidence.js +77 -0
  676. package/packages/core/publication/authority/candidate-evidence.js +42 -0
  677. package/packages/core/publication/authority/consumer-gate.js +80 -0
  678. package/packages/core/publication/authority/control-plane.js +38 -0
  679. package/packages/core/publication/authority/evidence.js +113 -0
  680. package/packages/core/publication/authority/gate.js +39 -0
  681. package/packages/core/publication/authority/governance.js +61 -0
  682. package/packages/core/publication/authority/paper-evidence.js +24 -0
  683. package/packages/core/publication/authority/request.js +13 -0
  684. package/packages/core/publication/authority/result.js +37 -0
  685. package/packages/core/publication/authority/runner.js +26 -0
  686. package/packages/core/publication/authority/seal.js +97 -0
  687. package/packages/core/publication/authority/verification-evidence.js +80 -0
  688. package/packages/core/publication/authority/verification.js +94 -0
  689. package/packages/core/publication/binary/action.js +33 -0
  690. package/packages/core/publication/binary/capability.js +55 -0
  691. package/packages/core/publication/binary/evidence.js +109 -0
  692. package/packages/core/publication/binary/transaction.js +38 -0
  693. package/packages/core/publication/candidate/artifact.js +71 -0
  694. package/packages/core/publication/candidate/collection-action.js +24 -0
  695. package/packages/core/publication/candidate/collection.js +70 -0
  696. package/packages/core/publication/candidate/kind.js +93 -0
  697. package/packages/core/publication/candidate/manifest.js +35 -0
  698. package/packages/core/publication/candidate/package-binding.js +42 -0
  699. package/packages/core/publication/candidate/package.js +50 -0
  700. package/packages/core/publication/candidate/paper-package.js +120 -0
  701. package/packages/core/publication/candidate/passport.js +36 -0
  702. package/packages/core/publication/candidate/qualification-action.js +41 -0
  703. package/packages/core/publication/candidate/qualification.js +56 -0
  704. package/packages/core/publication/candidate/registry-hydration.js +204 -0
  705. package/packages/core/publication/candidate/reproducibility.js +29 -0
  706. package/packages/core/publication/candidate/sealing.js +184 -0
  707. package/packages/core/publication/candidate/stage-capsules.js +205 -0
  708. package/packages/core/publication/candidate/toolchain.js +80 -0
  709. package/packages/core/publication/cli/dispatch.mjs +107 -0
  710. package/packages/core/publication/commands/create-release-bundle.mjs +32 -0
  711. package/packages/core/publication/commands/generate-release-candidate-passport.mjs +80 -0
  712. package/packages/core/publication/commands/installer-publication.mjs +45 -0
  713. package/packages/core/publication/commands/npm-publish-dry-run.mjs +48 -0
  714. package/packages/core/publication/commands/npm-publish-transaction.mjs +55 -0
  715. package/packages/core/publication/commands/publication-artifact-candidate.mjs +48 -0
  716. package/packages/core/publication/commands/publication-artifact.mjs +67 -0
  717. package/packages/core/publication/commands/publication-package.mjs +38 -0
  718. package/packages/core/publication/commands/publication-registry-hydrate.mjs +19 -0
  719. package/packages/core/publication/commands/publication-reproducibility.mjs +62 -0
  720. package/packages/core/publication/installer/evidence.js +319 -0
  721. package/packages/core/publication/npm/environment.js +18 -0
  722. package/packages/core/publication/npm/evidence.js +57 -0
  723. package/packages/core/publication/npm/pack-preview.js +22 -0
  724. package/packages/core/publication/npm/package-plan.js +82 -0
  725. package/packages/core/publication/npm/package.js +120 -0
  726. package/packages/core/publication/npm/preview-action.js +30 -0
  727. package/packages/core/publication/npm/preview.js +92 -0
  728. package/packages/core/publication/npm/registry.js +61 -0
  729. package/packages/core/publication/npm/transaction.js +115 -0
  730. package/packages/core/publication/oci/preview-actions.js +48 -0
  731. package/packages/core/publication/oci/preview-admission.js +93 -0
  732. package/packages/core/publication/oci/preview-promotion.js +64 -0
  733. package/packages/core/publication/oci/preview-registry.js +36 -0
  734. package/packages/core/publication/oci/preview-transaction.js +42 -0
  735. package/packages/core/publication/oci/preview-values.js +8 -0
  736. package/packages/core/publication/oci-compose-qualification.js +143 -0
  737. package/packages/core/publication/oci-publication-bundle.js +281 -0
  738. package/packages/core/publication/publication-artifact-candidate.js +128 -0
  739. package/packages/core/publication/publication-artifact.js +641 -0
  740. package/packages/core/publication/publication-authority.js +1163 -0
  741. package/packages/core/publication/publication-development.js +72 -0
  742. package/packages/core/publication/publication-package.js +252 -0
  743. package/packages/core/publication/publication-rehearsal-capsule.js +468 -0
  744. package/packages/core/publication/publication-rehearsal-projection.js +104 -0
  745. package/packages/core/publication/publication-rehearsal-runtime.js +190 -0
  746. package/packages/core/publication/publication-rehearsal.js +481 -0
  747. package/packages/core/publication/publication-reproducibility.js +947 -0
  748. package/packages/core/publication/settlement/actions.js +63 -0
  749. package/packages/core/publication/settlement/transaction.js +197 -0
  750. package/packages/core/release/binary/coordinates-action.js +25 -0
  751. package/packages/core/release/binary/coordinates.js +76 -0
  752. package/packages/core/release/candidate/download.js +64 -0
  753. package/packages/core/release/candidate/lineage.js +72 -0
  754. package/packages/core/release/candidate/materialize.js +155 -0
  755. package/packages/core/release/candidate/payloads.js +330 -0
  756. package/packages/core/release/candidate/publication-intent.js +89 -0
  757. package/packages/core/release/candidate/resolve.js +132 -0
  758. package/packages/core/release/candidate/run-selection.js +88 -0
  759. package/packages/core/release/candidate/selection.js +181 -0
  760. package/packages/core/release/candidate/transport.js +143 -0
  761. package/packages/core/release/cli/command-handlers.mjs +14 -0
  762. package/packages/core/release/cli/dispatch.mjs +39 -0
  763. package/packages/core/release/cli/inspection-handlers.mjs +178 -0
  764. package/packages/core/release/cli/release-handlers.mjs +332 -0
  765. package/packages/core/release/cli/trust-release.mjs +19 -0
  766. package/packages/core/release/cli/verification-handlers.mjs +303 -0
  767. package/packages/core/release/commands/dev-alpha-candidate-patrol.mjs +42 -0
  768. package/packages/core/release/commands/ensure-github-release.mjs +199 -0
  769. package/packages/core/release/commands/next-development-review.mjs +77 -0
  770. package/packages/core/release/commands/next-development-transition.mjs +47 -0
  771. package/packages/core/release/commands/promotion-channel-router.mjs +62 -0
  772. package/packages/core/release/commands/promotion-identity-resolver.mjs +77 -0
  773. package/packages/core/release/commands/publish-source-ref-resolver.mjs +113 -0
  774. package/packages/core/release/commands/release-candidate-resolver.mjs +122 -0
  775. package/packages/core/release/commands/release-line-dry-run.mjs +53 -0
  776. package/packages/core/release/commands/release-propagation.mjs +411 -0
  777. package/packages/core/release/commands/release-tail.mjs +169 -0
  778. package/packages/core/release/commands/release-transaction.mjs +212 -0
  779. package/packages/core/release/commands/resolve-publish-gate.mjs +34 -0
  780. package/packages/core/release/commands/resolve-publish-source.mjs +96 -0
  781. package/packages/core/release/commands/resume-from-candidate-run.mjs +107 -0
  782. package/packages/core/release/commands/stable-candidate-patrol.mjs +31 -0
  783. package/packages/core/release/commands/stable-candidate-qualification.mjs +24 -0
  784. package/packages/core/release/commands/stable-release-gate.mjs +351 -0
  785. package/packages/core/release/commands/tail-reseal.mjs +148 -0
  786. package/packages/core/release/commands/verify-promotion-router-binding.sh +36 -0
  787. package/packages/core/release/commands/verify-publish-channel-ref.mjs +83 -0
  788. package/packages/core/release/commands/verify-publish-source-lock.mjs +37 -0
  789. package/packages/core/release/commands/verify-release-pr.mjs +6 -0
  790. package/packages/core/release/commands/verify-version-state-delta.mjs +21 -0
  791. package/packages/core/release/github-provider-plane.js +319 -0
  792. package/packages/core/release/github-release.js +385 -0
  793. package/packages/core/release/line/action.js +49 -0
  794. package/packages/core/release/line/governance.js +96 -0
  795. package/packages/core/release/line/plan.js +56 -0
  796. package/packages/core/release/line/policy.js +320 -0
  797. package/packages/core/release/line/protection.js +35 -0
  798. package/packages/core/release/line/request.js +22 -0
  799. package/packages/core/release/line/source.js +79 -0
  800. package/packages/core/release/line/transaction.js +33 -0
  801. package/packages/core/release/line/verification-action.js +13 -0
  802. package/packages/core/release/line/verification.js +13 -0
  803. package/packages/core/release/next-development/actions.js +122 -0
  804. package/packages/core/release/next-development/approval.js +59 -0
  805. package/packages/core/release/next-development/enqueue.js +51 -0
  806. package/packages/core/release/next-development/finalization.js +127 -0
  807. package/packages/core/release/next-development/observation.js +41 -0
  808. package/packages/core/release/next-development/review-policy.js +56 -0
  809. package/packages/core/release/next-development/verification.js +89 -0
  810. package/packages/core/release/next-development-projection.js +310 -0
  811. package/packages/core/release/next-development-transition.js +737 -0
  812. package/packages/core/release/partial-mutation-recovery-qualification.js +18 -0
  813. package/packages/core/release/passport/artifact-index.js +65 -0
  814. package/packages/core/release/passport/assembly-artifacts.js +43 -0
  815. package/packages/core/release/passport/assembly-inputs.js +107 -0
  816. package/packages/core/release/passport/assembly-material.js +261 -0
  817. package/packages/core/release/passport/assembly-render.js +320 -0
  818. package/packages/core/release/passport/assembly.js +12 -0
  819. package/packages/core/release/passport/assets.js +46 -0
  820. package/packages/core/release/passport/attachments.js +88 -0
  821. package/packages/core/release/passport/authoritative-base.js +123 -0
  822. package/packages/core/release/passport/build.js +39 -0
  823. package/packages/core/release/passport/collection-inputs.js +383 -0
  824. package/packages/core/release/passport/collection-material.js +199 -0
  825. package/packages/core/release/passport/collection-options.js +97 -0
  826. package/packages/core/release/passport/collection-output.js +303 -0
  827. package/packages/core/release/passport/collection.js +10 -0
  828. package/packages/core/release/passport/commands.js +44 -0
  829. package/packages/core/release/passport/consumer-input.js +18 -0
  830. package/packages/core/release/passport/consumer-validation.js +83 -0
  831. package/packages/core/release/passport/discovery.js +36 -0
  832. package/packages/core/release/passport/documents.js +116 -0
  833. package/packages/core/release/passport/evidence-validation.js +280 -0
  834. package/packages/core/release/passport/files.js +43 -0
  835. package/packages/core/release/passport/fixture.js +19 -0
  836. package/packages/core/release/passport/identity.js +46 -0
  837. package/packages/core/release/passport/impact-validation.js +230 -0
  838. package/packages/core/release/passport/impact.js +149 -0
  839. package/packages/core/release/passport/inputs.js +55 -0
  840. package/packages/core/release/passport/invariants.js +93 -0
  841. package/packages/core/release/passport/issues.js +29 -0
  842. package/packages/core/release/passport/json.js +16 -0
  843. package/packages/core/release/passport/locations.js +82 -0
  844. package/packages/core/release/passport/packages.js +123 -0
  845. package/packages/core/release/passport/publish-validation.js +279 -0
  846. package/packages/core/release/passport/publish.js +58 -0
  847. package/packages/core/release/passport/report.js +154 -0
  848. package/packages/core/release/passport/state-validation.js +163 -0
  849. package/packages/core/release/passport/transaction.js +69 -0
  850. package/packages/core/release/passport/trust-claims.js +365 -0
  851. package/packages/core/release/passport/trust-validation.js +528 -0
  852. package/packages/core/release/product-publication.js +59 -0
  853. package/packages/core/release/promote-candidate/action.js +9 -0
  854. package/packages/core/release/promote-candidate/development-source.js +39 -0
  855. package/packages/core/release/promote-candidate/evidence-binding.js +142 -0
  856. package/packages/core/release/promote-candidate/evidence-inputs.js +99 -0
  857. package/packages/core/release/promote-candidate/files.js +10 -0
  858. package/packages/core/release/promote-candidate/next-development-provider.js +300 -0
  859. package/packages/core/release/promote-candidate/next-development-queue.js +63 -0
  860. package/packages/core/release/promote-candidate/oci-provider.js +241 -0
  861. package/packages/core/release/promote-candidate/oci-registry-client.js +67 -0
  862. package/packages/core/release/promote-candidate/outputs.js +29 -0
  863. package/packages/core/release/promote-candidate/product-finalization-wait.js +52 -0
  864. package/packages/core/release/promote-candidate/product-provider-adapters.js +462 -0
  865. package/packages/core/release/promote-candidate/product-provider-github-adapters.js +595 -0
  866. package/packages/core/release/promote-candidate/product-provider.js +188 -0
  867. package/packages/core/release/promote-candidate/provider-request.js +51 -0
  868. package/packages/core/release/promote-candidate/provider-settlement.js +83 -0
  869. package/packages/core/release/promote-candidate/publication-completion.js +56 -0
  870. package/packages/core/release/promote-candidate/release-documents.js +156 -0
  871. package/packages/core/release/promote-candidate/transaction.js +130 -0
  872. package/packages/core/release/promote-ref/action-environment.js +2 -0
  873. package/packages/core/release/promote-ref/action-inputs.js +285 -0
  874. package/packages/core/release/promote-ref/action-outputs.js +140 -0
  875. package/packages/core/release/promote-ref/action-request.js +205 -0
  876. package/packages/core/release/promote-ref/action.js +92 -0
  877. package/packages/core/release/promote-ref/internal/branch-protection.js +218 -0
  878. package/packages/core/release/promote-ref/internal/candidate-admission.js +149 -0
  879. package/packages/core/release/promote-ref/internal/channel-governance.js +297 -0
  880. package/packages/core/release/promote-ref/internal/channel-resume.js +198 -0
  881. package/packages/core/release/promote-ref/internal/channel-tags.js +207 -0
  882. package/packages/core/release/promote-ref/internal/contained-published-version-state.js +80 -0
  883. package/packages/core/release/promote-ref/internal/durable-transaction-operations.js +463 -0
  884. package/packages/core/release/promote-ref/internal/durable-transaction-store.js +395 -0
  885. package/packages/core/release/promote-ref/internal/generated-branch.js +16 -0
  886. package/packages/core/release/promote-ref/internal/generated-identity.js +12 -0
  887. package/packages/core/release/promote-ref/internal/generated-ref.js +93 -0
  888. package/packages/core/release/promote-ref/internal/github-adapter.js +312 -0
  889. package/packages/core/release/promote-ref/internal/npm-distribution.js +185 -0
  890. package/packages/core/release/promote-ref/internal/npm-existing-evidence.js +61 -0
  891. package/packages/core/release/promote-ref/internal/passport-files.js +116 -0
  892. package/packages/core/release/promote-ref/internal/passport-generation.js +567 -0
  893. package/packages/core/release/promote-ref/internal/promote-alpha-channel.js +588 -0
  894. package/packages/core/release/promote-ref/internal/promote-major-channel.js +476 -0
  895. package/packages/core/release/promote-ref/internal/promote-release-channel.js +573 -0
  896. package/packages/core/release/promote-ref/internal/promotion-operations.js +1170 -0
  897. package/packages/core/release/promote-ref/internal/promotion-options.js +101 -0
  898. package/packages/core/release/promote-ref/internal/promotion-policy.js +218 -0
  899. package/packages/core/release/promote-ref/internal/publish-command.js +211 -0
  900. package/packages/core/release/promote-ref/internal/publish-contract.js +181 -0
  901. package/packages/core/release/promote-ref/internal/publish-transaction.js +510 -0
  902. package/packages/core/release/promote-ref/internal/tag-selection.js +159 -0
  903. package/packages/core/release/promote-ref/internal/transaction-context.js +506 -0
  904. package/packages/core/release/promote-ref/internal/transaction-recovery.js +379 -0
  905. package/packages/core/release/promote-ref/internal/version-state-operations.js +545 -0
  906. package/packages/core/release/promote-ref/lib.js +600 -0
  907. package/packages/core/release/promote-ref/release-tail.js +102 -0
  908. package/packages/core/release/promote-ref/source-lock.js +91 -0
  909. package/packages/core/release/promotion/actions.js +133 -0
  910. package/packages/core/release/promotion/admission.js +52 -0
  911. package/packages/core/release/promotion/candidate.js +71 -0
  912. package/packages/core/release/promotion/channel.js +104 -0
  913. package/packages/core/release/promotion/identities.js +56 -0
  914. package/packages/core/release/promotion/product-state.js +68 -0
  915. package/packages/core/release/promotion/publish-gate.js +128 -0
  916. package/packages/core/release/promotion/qualification-action.js +72 -0
  917. package/packages/core/release/promotion/qualification.js +95 -0
  918. package/packages/core/release/promotion/routing.js +94 -0
  919. package/packages/core/release/promotion/selection.js +55 -0
  920. package/packages/core/release/promotion/source-intent.js +35 -0
  921. package/packages/core/release/promotion-request.js +148 -0
  922. package/packages/core/release/propagation/actions.js +75 -0
  923. package/packages/core/release/propagation/delivery.js +202 -0
  924. package/packages/core/release/propagation/planning.js +197 -0
  925. package/packages/core/release/propagation/report.js +97 -0
  926. package/packages/core/release/propagation/store.js +26 -0
  927. package/packages/core/release/propagation/transactions.js +213 -0
  928. package/packages/core/release/propagation/work.js +146 -0
  929. package/packages/core/release/protected-publication-source.js +91 -0
  930. package/packages/core/release/provider-operation-journal.js +62 -0
  931. package/packages/core/release/provider-readback-idempotency.js +309 -0
  932. package/packages/core/release/qualification/actions.js +51 -0
  933. package/packages/core/release/qualification/campaign.js +154 -0
  934. package/packages/core/release/qualification/options.js +102 -0
  935. package/packages/core/release/qualification/public-build.js +109 -0
  936. package/packages/core/release/recovery/artifacts.js +161 -0
  937. package/packages/core/release/recovery/candidate.js +529 -0
  938. package/packages/core/release/recovery/capsules.js +102 -0
  939. package/packages/core/release/recovery/download.js +191 -0
  940. package/packages/core/release/recovery/files.js +39 -0
  941. package/packages/core/release/recovery/provenance.js +199 -0
  942. package/packages/core/release/recovery/publication.js +193 -0
  943. package/packages/core/release/recovery/readback.js +169 -0
  944. package/packages/core/release/recovery/runtime.js +224 -0
  945. package/packages/core/release/recovery/transactions.js +139 -0
  946. package/packages/core/release/release-activation-shadow.js +32 -0
  947. package/packages/core/release/release-blocker-priority.js +183 -0
  948. package/packages/core/release/release-candidate-recovery.js +595 -0
  949. package/packages/core/release/release-candidate.js +591 -0
  950. package/packages/core/release/release-invocation.js +64 -0
  951. package/packages/core/release/release-line-bootstrap.js +292 -0
  952. package/packages/core/release/release-line-dry-run.js +302 -0
  953. package/packages/core/release/release-passport-contract.js +479 -0
  954. package/packages/core/release/release-passport.js +74 -0
  955. package/packages/core/release/release-tail-provider-adapters.js +460 -0
  956. package/packages/core/release/release-tail-provider-plane.js +248 -0
  957. package/packages/core/release/reseal/actions.js +84 -0
  958. package/packages/core/release/reseal/admission.js +75 -0
  959. package/packages/core/release/reseal/files.js +39 -0
  960. package/packages/core/release/reseal/finalize-platform.js +65 -0
  961. package/packages/core/release/reseal/outputs.js +21 -0
  962. package/packages/core/release/reseal/plan.js +24 -0
  963. package/packages/core/release/reseal/platform.js +135 -0
  964. package/packages/core/release/reseal/readbacks.js +36 -0
  965. package/packages/core/release/reseal/seal.js +125 -0
  966. package/packages/core/release/reuse-complete-release.js +240 -0
  967. package/packages/core/release/runtime-override-authorization.js +242 -0
  968. package/packages/core/release/settle/action.js +412 -0
  969. package/packages/core/release/source/channel.js +45 -0
  970. package/packages/core/release/source/coordinates.js +160 -0
  971. package/packages/core/release/source/lineage.js +144 -0
  972. package/packages/core/release/source/manifest.js +114 -0
  973. package/packages/core/release/stable-patrol/action.js +87 -0
  974. package/packages/core/release/stable-patrol/controller.js +346 -0
  975. package/packages/core/release/stable-patrol/coordinates.js +16 -0
  976. package/packages/core/release/stable-patrol/github-client.js +181 -0
  977. package/packages/core/release/stable-patrol/options.js +87 -0
  978. package/packages/core/release/stable-patrol/report.js +28 -0
  979. package/packages/core/release/stable-publication-fence.js +28 -0
  980. package/packages/core/release/tail-reseal-github.js +175 -0
  981. package/packages/core/release/tail-reseal-receipt.js +228 -0
  982. package/packages/core/release/tail-reseal.js +594 -0
  983. package/packages/core/release/version-state/verification.js +164 -0
  984. package/packages/core/release/version-state.js +458 -0
  985. package/packages/core/runtime/action-host.js +19 -0
  986. package/packages/core/runtime/action-process.mjs +23 -0
  987. package/packages/core/runtime/buildchain-domain.wasm +0 -0
  988. package/packages/core/runtime/checkout-identity.js +27 -0
  989. package/packages/core/runtime/commands/bridge-bootstrap.mjs +147 -0
  990. package/packages/core/runtime/commands/host-adapter.mjs +185 -0
  991. package/packages/core/runtime/commands/runtime-ref-core.mjs +171 -0
  992. package/packages/core/runtime/consumer-shell.js +174 -0
  993. package/packages/core/runtime/domain-wasm-artifact.js +7 -0
  994. package/packages/core/runtime/installation-root.js +29 -0
  995. package/packages/core/runtime/locked-dependencies.js +74 -0
  996. package/packages/core/runtime/provider-closure.js +60 -0
  997. package/packages/core/runtime/runtime-selection-action.js +34 -0
  998. package/packages/core/runtime/runtime-selection.js +136 -0
  999. package/packages/core/runtime/toolchain/actions.js +14 -0
  1000. package/packages/core/runtime/toolchain/user-paths.js +9 -0
  1001. package/packages/core/runtime/toolchain/windows-rust.js +67 -0
  1002. package/packages/core/runtime/workflow-runtime.js +11 -0
  1003. package/packages/core/web/apply-admission-action.js +20 -0
  1004. package/packages/core/web/apply-admission.js +44 -0
  1005. package/packages/core/web/cli/badges.mjs +100 -0
  1006. package/packages/core/web/cli/surface.mjs +6 -0
  1007. package/packages/core/web/commands/web-surface-core.mjs +2603 -0
  1008. package/packages/core/web/commands/web-surface-production-release-pr.mjs +126 -0
  1009. package/packages/core/web/commands/web-surface.mjs +294 -0
  1010. package/packages/core/web/controller-actions.js +45 -0
  1011. package/packages/core/web/controller.js +145 -0
  1012. package/packages/core/web/deployment/apply-action.js +31 -0
  1013. package/packages/core/web/deployment/apply-evidence.js +134 -0
  1014. package/packages/core/web/deployment/apply.js +118 -0
  1015. package/packages/core/web/deployment/cloudfront-wait.js +88 -0
  1016. package/packages/core/web/deployment/plan-files.js +41 -0
  1017. package/packages/core/web/deployment/planning-action.js +28 -0
  1018. package/packages/core/web/deployment/planning.js +126 -0
  1019. package/packages/core/web/deployment/report-action.js +74 -0
  1020. package/packages/core/web/deployment/summary.js +44 -0
  1021. package/packages/core/web/preview-feedback-action.js +26 -0
  1022. package/packages/core/web/preview-feedback.js +40 -0
  1023. package/packages/core/web/production-decision-action.js +42 -0
  1024. package/packages/core/web/production-decision.js +85 -0
  1025. package/packages/core/web/production-intent-action.js +14 -0
  1026. package/packages/core/web/production-intent.js +167 -0
  1027. package/packages/core/web/publication-admission-action.js +92 -0
  1028. package/packages/core/web/publication-admission.js +183 -0
  1029. package/packages/core/web/publication-capability-action.js +22 -0
  1030. package/packages/core/web/publication-capability.js +73 -0
  1031. package/packages/core/web/readme-badges.js +891 -0
  1032. package/packages/core/web/release-feedback.js +414 -0
  1033. package/packages/core/web/release-pr-action.js +47 -0
  1034. package/packages/core/web/release-pr-handoff.js +176 -0
  1035. package/packages/core/web/release-pr-provider.js +295 -0
  1036. package/packages/core/web/release-pr-summary.js +42 -0
  1037. package/packages/core/web/release-pr-transaction.js +158 -0
  1038. package/packages/core/web/release-review-action.js +21 -0
  1039. package/packages/core/web/release-review.js +130 -0
  1040. package/packages/core/web/web-surface-publication-candidate.js +162 -0
  1041. package/packages/core/workflow/admission/actions.js +56 -0
  1042. package/packages/core/workflow/admission/recovery.js +47 -0
  1043. package/packages/core/workflow/admission/review.js +188 -0
  1044. package/packages/core/workflow/admission/transactions.js +60 -0
  1045. package/packages/core/workflow/cli/main.mjs +131 -0
  1046. package/packages/core/workflow/cli/process.mjs +16 -0
  1047. package/packages/core/workflow/commands/buildchain-cli-help.mjs +318 -0
  1048. package/packages/core/workflow/commands/universal-workflow-backflow.mjs +26 -0
  1049. package/packages/core/workflow/commands/universal-workflow-engine.mjs +73 -0
  1050. package/packages/core/workflow/dogfood/actions.js +62 -0
  1051. package/packages/core/workflow/dogfood/readiness.js +74 -0
  1052. package/packages/core/workflow/dogfood/transactions.js +90 -0
  1053. package/packages/core/workflow/engine/action.js +42 -0
  1054. package/packages/core/workflow/engine/conformance.js +93 -0
  1055. package/packages/core/workflow/engine/execution.js +77 -0
  1056. package/packages/core/workflow/engine/identity.js +34 -0
  1057. package/packages/core/workflow/engine/provider-context.js +16 -0
  1058. package/packages/core/workflow/engine/release-environment.js +57 -0
  1059. package/packages/core/workflow/engine/release-evidence.js +39 -0
  1060. package/packages/core/workflow/engine/release-observation.js +97 -0
  1061. package/packages/core/workflow/engine/release-promotion.js +227 -0
  1062. package/packages/core/workflow/event-trust.js +25 -0
  1063. package/packages/core/workflow/installation.js +33 -0
  1064. package/packages/core/workflow/request-rejection.js +3 -0
  1065. package/packages/core/workflow/settlement/actions.js +34 -0
  1066. package/packages/core/workflow/settlement/backflow.js +187 -0
  1067. package/packages/core/workflow/universal-self-dogfood.js +163 -0
  1068. package/packages/core/workflow/universal-workflow-bootstrap.js +586 -0
  1069. package/packages/core/workflow/workflow-taxonomy.mjs +351 -0
  1070. package/scripts/bridge-evidence.mjs +9 -2
  1071. package/scripts/build-domain-wasm.mjs +15 -3
  1072. package/scripts/build-standalone-binary.mjs +1 -375
  1073. package/scripts/check-action-bundles.mjs +14 -25
  1074. package/scripts/check-ci-lane-change-budget.mjs +3 -3
  1075. package/scripts/check-code-layout.mjs +386 -0
  1076. package/scripts/check-core-mechanism-inventory.mjs +17 -16
  1077. package/scripts/check-dev-delivery-actions.mjs +35 -0
  1078. package/scripts/check-floating-consumer-policy-contract.mjs +33 -59
  1079. package/scripts/check-implementation-naming.mjs +2 -23
  1080. package/scripts/check-internal-architecture.mjs +3 -3
  1081. package/scripts/check-inventory.mjs +160 -318
  1082. package/scripts/check-javascript-syntax.mjs +1 -1
  1083. package/scripts/check-maintainability.mjs +25 -21
  1084. package/scripts/check-project-cut-merge-queue-admission.mjs +1 -1
  1085. package/scripts/check-public-dogfood-contract.mjs +166 -43
  1086. package/scripts/check-release-tail-contract.mjs +62 -71
  1087. package/scripts/check-release-topology.mjs +101 -77
  1088. package/scripts/check-runtime-semantic-closure.mjs +5 -8
  1089. package/scripts/check-source-bindings.mjs +54 -0
  1090. package/scripts/check-universal-workflow-bootstrap.mjs +136 -124
  1091. package/scripts/check-workflow-taxonomy.mjs +1 -1
  1092. package/scripts/check-workflows.sh +11 -0
  1093. package/scripts/generate-bootstrap-admission.mjs +32 -0
  1094. package/scripts/generate-bootstrap-recovery.mjs +94 -0
  1095. package/scripts/generate-buildchain-kfd-witnesses.mjs +3 -3
  1096. package/scripts/generate-channel-promotion-workflow.mjs +39 -518
  1097. package/scripts/generate-next-development-guidance.mjs +1 -1
  1098. package/scripts/generate-public-reference.mjs +2 -2
  1099. package/scripts/generate-site-bundle.mjs +42 -43
  1100. package/scripts/generate-tail-reseal-fixture.mjs +108 -0
  1101. package/scripts/generate-workflow-taxonomy.mjs +2 -2
  1102. package/scripts/inventory/binary.mjs +36 -0
  1103. package/scripts/inventory/promotion.mjs +72 -0
  1104. package/scripts/maintainability-domain-metrics.mjs +1 -1
  1105. package/scripts/maintainability-metrics.mjs +37 -37
  1106. package/scripts/maintainability-public-surface.mjs +19 -95
  1107. package/scripts/next-development-self-dogfood-harness.mjs +2 -2
  1108. package/scripts/next-development-self-dogfood.mjs +2 -2
  1109. package/scripts/platform-stage-checkpoint-rehearsal.mjs +33 -201
  1110. package/scripts/public-reference.mjs +0 -187
  1111. package/scripts/publication-rehearsal-fixture.mjs +1 -1
  1112. package/scripts/release-train-self-dogfood.mjs +9 -14
  1113. package/scripts/site-action-audit.mjs +16 -0
  1114. package/scripts/site-capability-metadata.mjs +3 -7
  1115. package/scripts/source-metric-lineage.mjs +17 -0
  1116. package/scripts/stage-capsule-resume-rehearsal.mjs +19 -55
  1117. package/scripts/tail-reseal-macos-rehearsal.mjs +1 -109
  1118. package/scripts/tsup-action.config.mjs +21 -0
  1119. package/scripts/verify-golden-path.mjs +1 -1
  1120. package/scripts/warrant-shadow-plan.mjs +49 -243
  1121. package/scripts/workflow-action-graph.mjs +149 -0
  1122. package/templates/bootstrap-recovery/actions/build/source/admit/action.yml +17 -0
  1123. package/templates/bootstrap-recovery/actions/build/source/admit/dist/index.js +63 -0
  1124. package/templates/bootstrap-recovery/actions/runtime/dependencies/install/action.yml +18 -0
  1125. package/templates/bootstrap-recovery/actions/runtime/dependencies/install/dist/index.js +63 -0
  1126. package/templates/bootstrap-recovery/actions/runtime/environment/prepare/action.yml +21 -0
  1127. package/templates/bootstrap-recovery/actions/workflow/admission/inspect/action.yml +27 -0
  1128. package/templates/bootstrap-recovery/actions/workflow/admission/inspect/dist/index.js +64 -0
  1129. package/templates/bootstrap-recovery/actions/workflow/admission/review/action.yml +15 -0
  1130. package/templates/bootstrap-recovery/actions/workflow/admission/review/dist/index.js +65 -0
  1131. package/templates/bootstrap-recovery/actions/workflow/recovery/admit/action.yml +47 -0
  1132. package/templates/bootstrap-recovery/actions/workflow/recovery/execute/action.yml +48 -0
  1133. package/templates/bootstrap-recovery/actions/workflow/recovery/settle/action.yml +54 -0
  1134. package/templates/bootstrap-recovery/actions/workflow/settlement/seal/action.yml +17 -0
  1135. package/templates/bootstrap-recovery/actions/workflow/settlement/seal/dist/index.js +65 -0
  1136. package/templates/bootstrap-recovery/manifest.json +68 -0
  1137. package/templates/bootstrap-recovery/package.json +9 -0
  1138. package/templates/native-dev-delivery.yml +28 -41
  1139. package/templates/universal-buildchain-bootstrap-recovery.yml +46 -213
  1140. package/templates/universal-buildchain-bootstrap.yml +1 -1
  1141. package/actions/github-artifact-attestation/README.md +0 -10
  1142. package/actions/promote-buildchain-ref/README.md +0 -549
  1143. package/actions/report-buildchain-issue/README.md +0 -107
  1144. package/actions/run-lifecycle/README.md +0 -71
  1145. package/actions/validate-config/README.md +0 -52
  1146. package/architecture/implementation-naming.json +0 -1273
  1147. package/bin/internal/adopter-delivery-cli.mjs +0 -70
  1148. package/bin/internal/cli-options.mjs +0 -79
  1149. package/bin/internal/compatibility-facts-cli.mjs +0 -101
  1150. package/bin/internal/trust-release-cli.mjs +0 -19
  1151. package/bin/internal/trust-release-command-handlers.mjs +0 -14
  1152. package/bin/internal/trust-release-inspection-handlers.mjs +0 -175
  1153. package/bin/internal/trust-release-release-handlers.mjs +0 -332
  1154. package/bin/internal/trust-release-verification-handlers.mjs +0 -306
  1155. package/contracts/fixtures/v4-adopter-delivery-v1/archive-template.json +0 -19
  1156. package/contracts/fixtures/v4-adopter-delivery-v1/bootstrap-positive.json +0 -93
  1157. package/packages/compatibility/adopter-delivery.js +0 -16
  1158. package/packages/compatibility/cross-platform-adopter-qualification.js +0 -12
  1159. package/packages/compatibility/floating-consumer-policy.js +0 -14
  1160. package/packages/compatibility/publication-qualification.js +0 -11
  1161. package/packages/compatibility/publication-rehearsal.js +0 -18
  1162. package/packages/compatibility/runtime-ref-resume-authority.js +0 -13
  1163. package/packages/compatibility/tail-reseal-receipt.js +0 -7
  1164. package/packages/compatibility/tail-reseal.js +0 -11
  1165. package/packages/core/adopter-delivery-parity.js +0 -219
  1166. package/packages/core/adopter-delivery.js +0 -359
  1167. package/packages/core/anchored-version-material.js +0 -281
  1168. package/packages/core/artifact-passport.js +0 -847
  1169. package/packages/core/artifact-verification-envelope.js +0 -500
  1170. package/packages/core/build-facts.js +0 -575
  1171. package/packages/core/buildchain-compatibility-authority.js +0 -336
  1172. package/packages/core/buildchain-compatibility-fact.js +0 -394
  1173. package/packages/core/buildchain-compatibility-facts.json +0 -217
  1174. package/packages/core/buildchain-compatibility-proof.js +0 -566
  1175. package/packages/core/buildchain-config.js +0 -1887
  1176. package/packages/core/buildchain-contract.js +0 -1048
  1177. package/packages/core/buildchain-delivery-bootstrap.js +0 -240
  1178. package/packages/core/buildchain-delivery-infrastructure.js +0 -164
  1179. package/packages/core/buildchain-delivery-self-dogfood.js +0 -395
  1180. package/packages/core/buildchain-domain.wasm +0 -0
  1181. package/packages/core/buildchain-kfd-claims.js +0 -733
  1182. package/packages/core/buildchain-publication-authority.js +0 -118
  1183. package/packages/core/canonical-contracts.js +0 -239
  1184. package/packages/core/ci-lane-change-budget.js +0 -260
  1185. package/packages/core/controller-evidence.js +0 -553
  1186. package/packages/core/cross-platform-adopter-qualification.js +0 -343
  1187. package/packages/core/delivery-warrant-fixture-runner.js +0 -375
  1188. package/packages/core/delivery-warrant-read-candidate.js +0 -286
  1189. package/packages/core/delivery-warrant-semantic-diff-gate.js +0 -351
  1190. package/packages/core/delivery-warrant-shadow-adapter.js +0 -447
  1191. package/packages/core/dev-delivery-authority-candidate.js +0 -270
  1192. package/packages/core/dev-delivery-authority-landing.js +0 -461
  1193. package/packages/core/dev-delivery-authority-state.js +0 -583
  1194. package/packages/core/dev-delivery-candidate-identity.js +0 -169
  1195. package/packages/core/dev-delivery-contract-surface.js +0 -76
  1196. package/packages/core/dev-delivery-native-proof.js +0 -566
  1197. package/packages/core/dev-delivery-proof.js +0 -286
  1198. package/packages/core/dev-delivery-warrant-legacy-recovery.js +0 -248
  1199. package/packages/core/dev-delivery-warrant-native-compatibility.js +0 -33
  1200. package/packages/core/dev-delivery-warrant-state.js +0 -599
  1201. package/packages/core/dev-delivery-warrant.js +0 -598
  1202. package/packages/core/diagnostics.js +0 -1904
  1203. package/packages/core/domain-wasm-artifact.js +0 -7
  1204. package/packages/core/floating-consumer-evidence.js +0 -338
  1205. package/packages/core/floating-consumer-policy.js +0 -571
  1206. package/packages/core/github-artifact-attestation.js +0 -642
  1207. package/packages/core/github-governance-authority.js +0 -1369
  1208. package/packages/core/homebrew.js +0 -414
  1209. package/packages/core/kfd-agent-hub.js +0 -496
  1210. package/packages/core/kfd.js +0 -966
  1211. package/packages/core/kfd2-product-claims.js +0 -454
  1212. package/packages/core/kfd3-surface-register.js +0 -924
  1213. package/packages/core/legacy-kfd-adopter-driver.js +0 -167
  1214. package/packages/core/next-development-projection.js +0 -310
  1215. package/packages/core/next-development-transition.js +0 -737
  1216. package/packages/core/oci-compose-qualification.js +0 -143
  1217. package/packages/core/oci-publication-bundle.js +0 -281
  1218. package/packages/core/package-manager.js +0 -323
  1219. package/packages/core/paper-agent-entry.js +0 -396
  1220. package/packages/core/paper-fleet.js +0 -313
  1221. package/packages/core/paper-npm-bootstrap.js +0 -492
  1222. package/packages/core/paper-repository.js +0 -214
  1223. package/packages/core/paper-runtime-channels.js +0 -348
  1224. package/packages/core/paper-scaffold-content.js +0 -574
  1225. package/packages/core/paper.js +0 -2478
  1226. package/packages/core/partial-mutation-recovery-qualification.js +0 -18
  1227. package/packages/core/platform-stage-checkpoints.js +0 -471
  1228. package/packages/core/product-publication.js +0 -59
  1229. package/packages/core/protected-publication-source.js +0 -91
  1230. package/packages/core/provider-operation-journal.js +0 -62
  1231. package/packages/core/provider-readback-idempotency.js +0 -309
  1232. package/packages/core/public-export-compatibility.js +0 -33
  1233. package/packages/core/public-surface-audit.js +0 -273
  1234. package/packages/core/public-surface-cli.js +0 -128
  1235. package/packages/core/publication-artifact-candidate.js +0 -128
  1236. package/packages/core/publication-artifact.js +0 -641
  1237. package/packages/core/publication-authority.js +0 -1163
  1238. package/packages/core/publication-development.js +0 -72
  1239. package/packages/core/publication-package.js +0 -252
  1240. package/packages/core/publication-rehearsal-capsule.js +0 -468
  1241. package/packages/core/publication-rehearsal-projection.js +0 -104
  1242. package/packages/core/publication-rehearsal-runtime.js +0 -190
  1243. package/packages/core/publication-rehearsal.js +0 -481
  1244. package/packages/core/publication-reproducibility.js +0 -947
  1245. package/packages/core/published-delivery-authority.js +0 -266
  1246. package/packages/core/readme-badges.js +0 -893
  1247. package/packages/core/release-activation-shadow.js +0 -32
  1248. package/packages/core/release-blocker-priority.js +0 -192
  1249. package/packages/core/release-candidate-recovery.js +0 -595
  1250. package/packages/core/release-candidate.js +0 -591
  1251. package/packages/core/release-invocation.js +0 -64
  1252. package/packages/core/release-line-bootstrap.js +0 -297
  1253. package/packages/core/release-line-dry-run.js +0 -303
  1254. package/packages/core/release-passport-contract.js +0 -479
  1255. package/packages/core/release-passport.js +0 -2884
  1256. package/packages/core/release-tail-compatibility.js +0 -60
  1257. package/packages/core/release-tail-provider-adapters.js +0 -461
  1258. package/packages/core/release-tail-provider-plane.js +0 -248
  1259. package/packages/core/runtime-selector-persistence.js +0 -228
  1260. package/packages/core/stable-publication-fence.js +0 -28
  1261. package/packages/core/stage-capsule-local-store.js +0 -428
  1262. package/packages/core/stage-capsule-qualification-campaign.js +0 -511
  1263. package/packages/core/stage-capsule-qualification.js +0 -455
  1264. package/packages/core/stage-capsule-resume-planner.js +0 -397
  1265. package/packages/core/stage-capsule-store.js +0 -404
  1266. package/packages/core/stage-capsule.js +0 -319
  1267. package/packages/core/tail-reseal-github.js +0 -178
  1268. package/packages/core/tail-reseal-receipt.js +0 -225
  1269. package/packages/core/tail-reseal.js +0 -594
  1270. package/packages/core/universal-workflow-bootstrap.js +0 -586
  1271. package/packages/core/web-surface-publication-candidate.js +0 -162
  1272. package/packages/core/workflow-yaml-contract.js +0 -342
  1273. package/scripts/aggregate-build-summary.mjs +0 -187
  1274. package/scripts/aggregate-diagnostics-summary.mjs +0 -54
  1275. package/scripts/anchored-version-material.mjs +0 -42
  1276. package/scripts/architecture.mjs +0 -610
  1277. package/scripts/artifact-relay-s3.mjs +0 -539
  1278. package/scripts/artifact-signing-controller-core.mjs +0 -525
  1279. package/scripts/artifact-signing-controller.mjs +0 -302
  1280. package/scripts/artifact-signing-delegation.mjs +0 -316
  1281. package/scripts/assemble-binary-release-admission.mjs +0 -213
  1282. package/scripts/assemble-publication-artifact-admission.mjs +0 -200
  1283. package/scripts/assemble-self-publication-admission.mjs +0 -201
  1284. package/scripts/assemble-web-surface-publication-admission.mjs +0 -204
  1285. package/scripts/audit-github-governance.mjs +0 -493
  1286. package/scripts/audit-publication-control-plane.mjs +0 -527
  1287. package/scripts/auditable-demo-bundle-verification.mjs +0 -148
  1288. package/scripts/auditable-demo-platform.mjs +0 -600
  1289. package/scripts/auditable-demo-presentation.mjs +0 -83
  1290. package/scripts/auditable-demo-renditions.mjs +0 -399
  1291. package/scripts/auditable-demo-transport-smoke.mjs +0 -176
  1292. package/scripts/auditable-demo.mjs +0 -1324
  1293. package/scripts/aws-codebuild-toolchain.mjs +0 -285
  1294. package/scripts/aws-macos-jit-controller-runtime.mjs +0 -82
  1295. package/scripts/aws-runner-burst-core.mjs +0 -248
  1296. package/scripts/aws-runner-burst.mjs +0 -79
  1297. package/scripts/aws-windows-jit-campaign.mjs +0 -202
  1298. package/scripts/aws-windows-jit-controller.mjs +0 -578
  1299. package/scripts/binary-publication-evidence.mjs +0 -133
  1300. package/scripts/bridge-bootstrap.mjs +0 -137
  1301. package/scripts/build-contract-core.mjs +0 -1216
  1302. package/scripts/buildchain-channel-router.mjs +0 -249
  1303. package/scripts/buildchain-cli-help.mjs +0 -321
  1304. package/scripts/buildchain-contract-lock.mjs +0 -184
  1305. package/scripts/buildchain-patrol.mjs +0 -280
  1306. package/scripts/compiler-cache-evidence.mjs +0 -304
  1307. package/scripts/consumer-policy.mjs +0 -231
  1308. package/scripts/controller-evidence.mjs +0 -208
  1309. package/scripts/copy-domain-wasm.mjs +0 -14
  1310. package/scripts/create-github-artifact-attestation-policy.mjs +0 -62
  1311. package/scripts/create-release-bundle.mjs +0 -167
  1312. package/scripts/cross-platform-adopter-qualification.mjs +0 -228
  1313. package/scripts/declarative-promotion-admission.mjs +0 -45
  1314. package/scripts/dev-alpha-candidate-patrol.mjs +0 -1197
  1315. package/scripts/dev-delivery-authority-command-adapters.mjs +0 -206
  1316. package/scripts/dev-delivery-authority-provider.mjs +0 -28
  1317. package/scripts/dev-delivery-authority.mjs +0 -490
  1318. package/scripts/dev-delivery-native-run.mjs +0 -177
  1319. package/scripts/dev-delivery-process-boundary.mjs +0 -260
  1320. package/scripts/dev-delivery-proof.mjs +0 -258
  1321. package/scripts/dev-delivery-provider-heartbeat.mjs +0 -215
  1322. package/scripts/dev-delivery-source-proof-replay.mjs +0 -153
  1323. package/scripts/dev-delivery-source-proof-reuse.mjs +0 -548
  1324. package/scripts/dev-delivery-two-phase-resume.mjs +0 -345
  1325. package/scripts/dev-delivery-two-phase.mjs +0 -573
  1326. package/scripts/dev-delivery-warrant-options.mjs +0 -298
  1327. package/scripts/dev-delivery-warrant-store.mjs +0 -316
  1328. package/scripts/dev-delivery-warrant-transition.mjs +0 -109
  1329. package/scripts/dev-delivery-warrant.mjs +0 -559
  1330. package/scripts/dev-merge-queue.mjs +0 -536
  1331. package/scripts/dev-pr-auto-merge.mjs +0 -1222
  1332. package/scripts/dev-pr-delivery-warrant.mjs +0 -467
  1333. package/scripts/dev-pr-prequeue-guard.mjs +0 -381
  1334. package/scripts/dev-qualification-patrol.mjs +0 -594
  1335. package/scripts/dispatch-artifact-signing-authority.mjs +0 -407
  1336. package/scripts/engineering-housekeeper-workflow.mjs +0 -401
  1337. package/scripts/ensure-github-release.mjs +0 -199
  1338. package/scripts/finalize-native-artifact-signing-result.mjs +0 -272
  1339. package/scripts/generate-channel-build-workflow.mjs +0 -69
  1340. package/scripts/generate-release-candidate-passport.mjs +0 -285
  1341. package/scripts/generate-universal-workflow-facades.mjs +0 -499
  1342. package/scripts/git-fetch-process-tree.mjs +0 -175
  1343. package/scripts/host-adapter.mjs +0 -182
  1344. package/scripts/implementation-references.mjs +0 -25
  1345. package/scripts/import-artifact-signing-results.mjs +0 -135
  1346. package/scripts/infra-contract-core.mjs +0 -1032
  1347. package/scripts/infra-contract.mjs +0 -345
  1348. package/scripts/init-repo.mjs +0 -518
  1349. package/scripts/inspect-artifact-signing-requests.mjs +0 -157
  1350. package/scripts/installer-publication.mjs +0 -361
  1351. package/scripts/lifecycle-substage-evidence.mjs +0 -274
  1352. package/scripts/locked-source-checkout.mjs +0 -595
  1353. package/scripts/materialize-artifact-signing-request.mjs +0 -66
  1354. package/scripts/merge-artifact-signing-results.mjs +0 -76
  1355. package/scripts/next-development-review.mjs +0 -331
  1356. package/scripts/next-development-transition.mjs +0 -47
  1357. package/scripts/npm-publish-dry-run.mjs +0 -182
  1358. package/scripts/npm-publish-transaction.mjs +0 -331
  1359. package/scripts/observed-evidence.mjs +0 -311
  1360. package/scripts/oci-compose-preview.mjs +0 -261
  1361. package/scripts/paper-agent-cli.mjs +0 -35
  1362. package/scripts/paper-work-fleet-cli.mjs +0 -594
  1363. package/scripts/paper.mjs +0 -644
  1364. package/scripts/product-publication-intent.mjs +0 -129
  1365. package/scripts/promotion-channel-router.mjs +0 -139
  1366. package/scripts/promotion-identity-resolver.mjs +0 -129
  1367. package/scripts/publication-artifact-candidate.mjs +0 -122
  1368. package/scripts/publication-artifact.mjs +0 -67
  1369. package/scripts/publication-candidate-kind.mjs +0 -93
  1370. package/scripts/publication-candidate-sealer.mjs +0 -119
  1371. package/scripts/publication-package.mjs +0 -38
  1372. package/scripts/publication-registry-hydrate.mjs +0 -216
  1373. package/scripts/publication-reproducibility.mjs +0 -62
  1374. package/scripts/publication-settlement.mjs +0 -217
  1375. package/scripts/publish-source-ref-resolver.mjs +0 -113
  1376. package/scripts/reconcile-github-governance.mjs +0 -689
  1377. package/scripts/reconcile-release-governance.mjs +0 -368
  1378. package/scripts/release-asset-client.mjs +0 -91
  1379. package/scripts/release-candidate-adapter.mjs +0 -41
  1380. package/scripts/release-candidate-anchor-provenance.mjs +0 -99
  1381. package/scripts/release-candidate-resolver.mjs +0 -842
  1382. package/scripts/release-finalization-review.mjs +0 -53
  1383. package/scripts/release-line-dry-run.mjs +0 -53
  1384. package/scripts/release-line-policy.mjs +0 -231
  1385. package/scripts/release-propagation.mjs +0 -411
  1386. package/scripts/release-tail.mjs +0 -178
  1387. package/scripts/release-transaction.mjs +0 -212
  1388. package/scripts/resolve-artifact-coordinates.mjs +0 -174
  1389. package/scripts/resolve-artifact-transfer-mode.mjs +0 -126
  1390. package/scripts/resolve-build-configuration.mjs +0 -105
  1391. package/scripts/resolve-build-contract.mjs +0 -96
  1392. package/scripts/resolve-publish-gate.mjs +0 -33
  1393. package/scripts/resolve-publish-source.mjs +0 -99
  1394. package/scripts/resume-from-candidate-run.mjs +0 -1117
  1395. package/scripts/route-offline-runners.mjs +0 -237
  1396. package/scripts/run-candidate-body-prefix-renderer.mjs +0 -187
  1397. package/scripts/run-lifecycle-core.mjs +0 -850
  1398. package/scripts/run-lifecycle.mjs +0 -56
  1399. package/scripts/runtime-ref-core.mjs +0 -171
  1400. package/scripts/seal-artifact-signing-requests.mjs +0 -431
  1401. package/scripts/seal-macos-credential-input.mjs +0 -135
  1402. package/scripts/shifu-gate-profile.mjs +0 -374
  1403. package/scripts/sign-detached-artifact-requests.mjs +0 -237
  1404. package/scripts/source-verification-evidence.mjs +0 -344
  1405. package/scripts/stable-candidate-patrol.mjs +0 -527
  1406. package/scripts/stable-candidate-policy.mjs +0 -25
  1407. package/scripts/stable-candidate-qualification.mjs +0 -358
  1408. package/scripts/stable-release-gate.mjs +0 -351
  1409. package/scripts/stage-capsule-qualification.mjs +0 -528
  1410. package/scripts/tail-reseal.mjs +0 -416
  1411. package/scripts/universal-facade-maintainability.mjs +0 -91
  1412. package/scripts/universal-workflow-backflow.mjs +0 -212
  1413. package/scripts/universal-workflow-engine.mjs +0 -620
  1414. package/scripts/universal-workflow-self-dogfood.mjs +0 -212
  1415. package/scripts/validate-package-manager-contract.mjs +0 -24
  1416. package/scripts/verify-artifact-signing-results.mjs +0 -124
  1417. package/scripts/verify-publish-channel-ref.mjs +0 -125
  1418. package/scripts/verify-publish-source-lock.mjs +0 -37
  1419. package/scripts/verify-release-pr.mjs +0 -34
  1420. package/scripts/verify-version-state-delta.mjs +0 -175
  1421. package/scripts/verify-web-surface-publication-capability.mjs +0 -78
  1422. package/scripts/web-surface-core.mjs +0 -2603
  1423. package/scripts/web-surface-production-decision.mjs +0 -158
  1424. package/scripts/web-surface-production-release-pr.mjs +0 -712
  1425. package/scripts/web-surface-release-feedback.mjs +0 -358
  1426. package/scripts/web-surface-release-pr-review.mjs +0 -187
  1427. package/scripts/web-surface.mjs +0 -460
  1428. package/scripts/workflow-call-contract.mjs +0 -133
  1429. package/scripts/workflow-friction-report.mjs +0 -375
  1430. package/scripts/workflow-taxonomy.mjs +0 -507
  1431. /package/actions/{macos-credential-island → build/credential/macos-island}/README.md +0 -0
  1432. /package/actions/{release-candidate-promote → release/promotion/candidate}/README.md +0 -0
  1433. /package/actions/{release-tail → release/tail/settle}/README.md +0 -0
  1434. /package/packages/core/{adopter-delivery-gate.js → adoption/adopter-delivery-gate.js} +0 -0
  1435. /package/packages/core/{adopter-delivery-json.js → adoption/adopter-delivery-json.js} +0 -0
  1436. /package/packages/core/{adopter-delivery-passport.js → adoption/adopter-delivery-passport.js} +0 -0
  1437. /package/packages/core/{adopter-delivery-vectors.js → adoption/adopter-delivery-vectors.js} +0 -0
  1438. /package/packages/core/{adopter-delivery-vectors.json → adoption/adopter-delivery-vectors.json} +0 -0
  1439. /package/packages/core/{buildchain-agent-manuals.js → adoption/buildchain-agent-manuals.js} +0 -0
  1440. /package/packages/core/{kfd-adopter-category-driver.js → adoption/kfd-adopter-category-driver.js} +0 -0
  1441. /package/packages/core/{kfd-adopter-manifest.js → adoption/kfd-adopter-manifest.js} +0 -0
  1442. /package/packages/core/{kfd-gate.js → adoption/kfd-gate.js} +0 -0
  1443. /package/packages/core/{kfd-product-gates.js → adoption/kfd-product-gates.js} +0 -0
  1444. /package/packages/core/{artifact-signing-result.js → build/artifact-signing-result.js} +0 -0
  1445. /package/packages/core/{artifact-signing.js → build/artifact-signing.js} +0 -0
  1446. /package/packages/core/{build-configuration.js → build/build-configuration.js} +0 -0
  1447. /package/{scripts → packages/core/build/commands}/resolve-artifact-signing-upload-route.mjs +0 -0
  1448. /package/packages/core/{detached-artifact-signature.js → build/detached-artifact-signature.js} +0 -0
  1449. /package/{scripts/gate-profile-core.mjs → packages/core/build/gate/contracts.js} +0 -0
  1450. /package/packages/core/{portable-dev-cache.js → build/portable-dev-cache.js} +0 -0
  1451. /package/packages/core/{buildchain-channel-identity.js → consumer/buildchain-channel-identity.js} +0 -0
  1452. /package/packages/core/{floating-consumer-release-passport.js → consumer/floating-consumer-release-passport.js} +0 -0
  1453. /package/packages/core/{runtime-ref-resume-authority.js → consumer/runtime-ref-resume-authority.js} +0 -0
  1454. /package/packages/core/{buildchain-layout.js → contracts/buildchain-layout.js} +0 -0
  1455. /package/{bin/internal → packages/core/contracts}/command-registry.mjs +0 -0
  1456. /package/packages/core/{kungfu-temporal-fact.js → contracts/kungfu-temporal-fact.js} +0 -0
  1457. /package/packages/core/{surface-manifest.js → contracts/surface-manifest.js} +0 -0
  1458. /package/packages/core/{workflow-call-contract.js → contracts/workflow-call-contract.js} +0 -0
  1459. /package/{scripts → packages/core/dev-delivery/commands}/project-cut-merge-queue-admission.mjs +0 -0
  1460. /package/packages/core/{dev-delivery-authority-evidence.js → dev-delivery/dev-delivery-authority-evidence.js} +0 -0
  1461. /package/packages/core/{dev-delivery-authority-observation.js → dev-delivery/dev-delivery-authority-observation.js} +0 -0
  1462. /package/packages/core/{dev-delivery-authority-qualification.js → dev-delivery/dev-delivery-authority-qualification.js} +0 -0
  1463. /package/packages/core/{dev-delivery-authority-settlement.js → dev-delivery/dev-delivery-authority-settlement.js} +0 -0
  1464. /package/packages/core/{dev-delivery-common.js → dev-delivery/dev-delivery-common.js} +0 -0
  1465. /package/packages/core/{dev-delivery-execution-failure.js → dev-delivery/dev-delivery-execution-failure.js} +0 -0
  1466. /package/packages/core/{dev-delivery-execution-transfer.js → dev-delivery/dev-delivery-execution-transfer.js} +0 -0
  1467. /package/packages/core/{dev-delivery-landing-admission-core.js → dev-delivery/dev-delivery-landing-admission-core.js} +0 -0
  1468. /package/packages/core/{dev-delivery-landing-readback.js → dev-delivery/dev-delivery-landing-readback.js} +0 -0
  1469. /package/packages/core/{dev-delivery-landing-terminal-evidence.js → dev-delivery/dev-delivery-landing-terminal-evidence.js} +0 -0
  1470. /package/packages/core/{dev-delivery-landing-testing-port.js → dev-delivery/dev-delivery-landing-testing-port.js} +0 -0
  1471. /package/packages/core/{dev-delivery-native-execution.js → dev-delivery/dev-delivery-native-execution.js} +0 -0
  1472. /package/packages/core/{dev-delivery-process-boundary.js → dev-delivery/dev-delivery-process-boundary.js} +0 -0
  1473. /package/packages/core/{dev-delivery-provider-attempt.js → dev-delivery/dev-delivery-provider-attempt.js} +0 -0
  1474. /package/packages/core/{dev-delivery-provider-heartbeat.js → dev-delivery/dev-delivery-provider-heartbeat.js} +0 -0
  1475. /package/packages/core/{dev-delivery-warrant-cancellation.js → dev-delivery/dev-delivery-warrant-cancellation.js} +0 -0
  1476. /package/packages/core/{dev-delivery-warrant-qualification.js → dev-delivery/dev-delivery-warrant-qualification.js} +0 -0
  1477. /package/packages/core/{dev-delivery-warrant-settlement.js → dev-delivery/dev-delivery-warrant-settlement.js} +0 -0
  1478. /package/packages/core/{dev-delivery-writer-protocol-transition.js → dev-delivery/dev-delivery-writer-protocol-transition.js} +0 -0
  1479. /package/packages/core/{engineering-housekeeper-github-client.js → governance/engineering-housekeeper-github-client.js} +0 -0
  1480. /package/packages/core/{engineering-housekeeper-github.js → governance/engineering-housekeeper-github.js} +0 -0
  1481. /package/packages/core/{engineering-housekeeper.js → governance/engineering-housekeeper.js} +0 -0
  1482. /package/packages/core/{issue-reporting.js → governance/issue-reporting.js} +0 -0
  1483. /package/packages/core/{cache-evidence.js → observability/cache-evidence.js} +0 -0
  1484. /package/packages/core/{candidate-timeline.js → observability/candidate-timeline.js} +0 -0
  1485. /package/packages/core/{logging.js → observability/logging.js} +0 -0
  1486. /package/packages/core/{paper-work.js → paper/paper-work.js} +0 -0
  1487. /package/{scripts → packages/core/providers/commands}/aws-macos-jit-controller-core.mjs +0 -0
  1488. /package/{scripts → packages/core/providers/commands}/aws-macos-jit-controller.mjs +0 -0
  1489. /package/{scripts → packages/core/providers/commands}/aws-macos-jit-core.mjs +0 -0
  1490. /package/{scripts → packages/core/providers/commands}/aws-macos-jit-job-controller.mjs +0 -0
  1491. /package/{scripts → packages/core/providers/commands}/aws-macos-jit.mjs +0 -0
  1492. /package/{scripts → packages/core/providers/commands}/aws-windows-jit-campaign-core.mjs +0 -0
  1493. /package/{scripts → packages/core/providers/commands}/aws-windows-jit-controller-core.mjs +0 -0
  1494. /package/{scripts → packages/core/providers/commands}/aws-windows-jit-core.mjs +0 -0
  1495. /package/{scripts → packages/core/providers/commands}/aws-windows-jit.mjs +0 -0
  1496. /package/{scripts → packages/core/providers/commands}/github-output.mjs +0 -0
  1497. /package/packages/core/{oci-publication-graph.js → publication/oci-publication-graph.js} +0 -0
  1498. /package/packages/core/{publication-control-plane-audit.js → publication/publication-control-plane-audit.js} +0 -0
  1499. /package/packages/core/{publication-qualification.js → publication/publication-qualification.js} +0 -0
  1500. /package/packages/core/{publication-rehearsal-provider-bindings.js → publication/publication-rehearsal-provider-bindings.js} +0 -0
  1501. /package/packages/core/{publication-sealed-bundle.js → publication/publication-sealed-bundle.js} +0 -0
  1502. /package/packages/core/{channel-candidate.js → release/channel-candidate.js} +0 -0
  1503. /package/packages/core/{channel-promotion-baseline.js → release/channel-promotion-baseline.js} +0 -0
  1504. /package/{scripts → packages/core/release/commands}/promotion-routing-evidence.mjs +0 -0
  1505. /package/packages/core/{dev-alpha-active-release-train.js → release/dev-alpha-active-release-train.js} +0 -0
  1506. /package/packages/core/{dev-alpha-candidate-selection.js → release/dev-alpha-candidate-selection.js} +0 -0
  1507. /package/packages/core/{next-development-candidate-reservation.js → release/next-development-candidate-reservation.js} +0 -0
  1508. /package/packages/core/{next-development-controller.js → release/next-development-controller.js} +0 -0
  1509. /package/packages/core/{publish-transaction.js → release/publish-transaction.js} +0 -0
  1510. /package/packages/core/{release-activation-transaction.js → release/release-activation-transaction.js} +0 -0
  1511. /package/packages/core/{release-propagation-agent-entry.js → release/release-propagation-agent-entry.js} +0 -0
  1512. /package/packages/core/{release-propagation-capture.js → release/release-propagation-capture.js} +0 -0
  1513. /package/packages/core/{release-propagation-common.js → release/release-propagation-common.js} +0 -0
  1514. /package/packages/core/{release-propagation-execution-profile.js → release/release-propagation-execution-profile.js} +0 -0
  1515. /package/packages/core/{release-propagation-pickup.js → release/release-propagation-pickup.js} +0 -0
  1516. /package/packages/core/{release-propagation-push.js → release/release-propagation-push.js} +0 -0
  1517. /package/packages/core/{release-propagation-release.js → release/release-propagation-release.js} +0 -0
  1518. /package/packages/core/{release-propagation-stage-evidence.js → release/release-propagation-stage-evidence.js} +0 -0
  1519. /package/packages/core/{release-propagation-work-capture.js → release/release-propagation-work-capture.js} +0 -0
  1520. /package/packages/core/{release-propagation-work-constants.js → release/release-propagation-work-constants.js} +0 -0
  1521. /package/packages/core/{release-propagation-work-control.js → release/release-propagation-work-control.js} +0 -0
  1522. /package/packages/core/{release-propagation-work-transitions.js → release/release-propagation-work-transitions.js} +0 -0
  1523. /package/packages/core/{release-propagation-work.js → release/release-propagation-work.js} +0 -0
  1524. /package/packages/core/{release-propagation.js → release/release-propagation.js} +0 -0
  1525. /package/packages/core/{release-tail-product-capabilities.js → release/release-tail-product-capabilities.js} +0 -0
  1526. /package/packages/core/{release-train.js → release/release-train.js} +0 -0
  1527. /package/packages/core/{self-dogfood-version.js → release/self-dogfood-version.js} +0 -0
  1528. /package/packages/core/{stable-candidate-ledger.js → release/stable-candidate-ledger.js} +0 -0
  1529. /package/packages/core/{stable-release-gate.js → release/stable-release-gate.js} +0 -0
  1530. /package/packages/core/{tail-reseal-contract.js → release/tail-reseal-contract.js} +0 -0
  1531. /package/packages/core/{domain-wasm.js → runtime/domain-wasm.js} +0 -0
  1532. /package/packages/core/{spawn-command.js → runtime/spawn-command.js} +0 -0
  1533. /package/packages/core/{badges.js → web/badges.js} +0 -0
  1534. /package/{scripts → packages/core/web/commands}/web-surface-cloudfront-rewrite.mjs +0 -0
  1535. /package/{scripts → packages/core/web/commands}/web-surface-immutable-object.mjs +0 -0
  1536. /package/{scripts → packages/core/web/commands}/web-surface-routing.mjs +0 -0
@@ -1,2603 +0,0 @@
1
- import crypto from "node:crypto";
2
- import { spawnSync } from "node:child_process";
3
- import dns from "node:dns/promises";
4
- import fs from "node:fs";
5
- import os from "node:os";
6
- import path from "node:path";
7
- import { setTimeout as sleep } from "node:timers/promises";
8
- import { fileURLToPath } from "node:url";
9
- import { loadBuildchainConfig, validateBuildchainConfig } from "../packages/core/buildchain-config.js";
10
- import { createSurfaceTimestampPolicy } from "../packages/core/surface-manifest.js";
11
- import { validateInstallerPublication, verifyInstallerPublicReadback } from "./installer-publication.mjs";
12
- import {
13
- classifyPreviewAlias,
14
- resolveChannelUrl,
15
- resolvePathOnlyUrl,
16
- resolveSurfaceUrl,
17
- manifestPrefixFor,
18
- objectPrefixFor,
19
- normalizeSurfacePath,
20
- surfaceDeployConfig,
21
- surfaceObjectPrefixFor,
22
- normalizeS3Key,
23
- joinS3Key,
24
- joinUrlPath,
25
- urlWithPath,
26
- s3Uri,
27
- cdnPath,
28
- cdnWildcardPath,
29
- viewerWildcardPath,
30
- surfaceArtifactPrefix,
31
- surfaceArtifactRootFor,
32
- syncStaticArtifactArgs,
33
- mutableCacheControlArgs,
34
- } from "./web-surface-routing.mjs";
35
-
36
- const moduleDir = path.dirname(fileURLToPath(import.meta.url));
37
-
38
- const DEFAULT_RETENTION = Object.freeze({
39
- preview: {
40
- pr_days: 14,
41
- sha_days: 90,
42
- },
43
- staging: {
44
- days: 90,
45
- keep_deploys: 10,
46
- },
47
- production: {
48
- days: 365,
49
- },
50
- });
51
-
52
- function assertWebSurfaceConfig(loadedConfig) {
53
- if (loadedConfig?.config?.project?.type !== "web-surface") {
54
- throw new Error('buildchain.toml project.type must be "web-surface"');
55
- }
56
- return loadedConfig.config;
57
- }
58
-
59
- function assertSha(value, label) {
60
- const sha = String(value || "").trim();
61
- if (!/^[0-9a-f]{40}$/i.test(sha)) {
62
- throw new Error(`${label} must be a 40-character Git SHA`);
63
- }
64
- return sha.toLowerCase();
65
- }
66
-
67
- function assertHash(value, label) {
68
- const hash = String(value || "").trim();
69
- if (!/^[0-9a-f]{64}$/i.test(hash)) {
70
- throw new Error(`${label} must be a 64-character SHA-256 hash`);
71
- }
72
- return hash.toLowerCase();
73
- }
74
-
75
- function toPosix(value) {
76
- return String(value || "").split(path.sep).join("/");
77
- }
78
-
79
- function listFiles(root, rel) {
80
- const target = path.isAbsolute(rel) ? rel : path.join(root, rel);
81
- if (!fs.existsSync(target)) {
82
- throw new Error(`artifact path does not exist: ${rel}`);
83
- }
84
- const stat = fs.statSync(target);
85
- if (stat.isFile()) {
86
- return [target];
87
- }
88
- return fs
89
- .readdirSync(target, { withFileTypes: true })
90
- .flatMap((entry) => listFiles(root, path.join(target, entry.name)));
91
- }
92
-
93
- function sha256File(filePath) {
94
- const hash = crypto.createHash("sha256");
95
- hash.update(fs.readFileSync(filePath));
96
- return hash.digest("hex");
97
- }
98
-
99
- function addDays(iso, days) {
100
- if (days === undefined || days === null) {
101
- return "";
102
- }
103
- const date = new Date(iso);
104
- date.setUTCDate(date.getUTCDate() + Number(days));
105
- return date.toISOString();
106
- }
107
-
108
- function retentionConfig(config, channel) {
109
- return {
110
- ...(DEFAULT_RETENTION[channel] || {}),
111
- ...(config.retention?.[channel] || {}),
112
- };
113
- }
114
-
115
-
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
-
126
-
127
-
128
-
129
-
130
-
131
-
132
-
133
-
134
-
135
-
136
-
137
-
138
-
139
-
140
-
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
157
- const PUBLICATION_ARCHIVE_POLICY_CONTRACT = "kungfu-buildchain-publication-archive-policy";
158
- const OBSERVED_EVIDENCE_OWNERSHIP_CONTRACT = "kungfu-buildchain-observed-evidence-ownership";
159
- const PUBLICATION_FAST_PATH_CONTRACT = "kungfu-buildchain-publication-package-pin-fast-path";
160
-
161
- function immutablePrefix(value, label) {
162
- const raw = String(value || "").trim().replaceAll("\\", "/");
163
- if (!raw || raw.split("/").includes("..")) {
164
- throw new Error(`invalid ${label}: ${value}`);
165
- }
166
- const normalized = normalizeS3Key(raw);
167
- if (!normalized || normalized.split("/").length < 2) {
168
- throw new Error(`${label} must identify a versioned path below an immutable root: ${value}`);
169
- }
170
- return normalized;
171
- }
172
-
173
- function publicationFastPathScope({ artifactRoot, bindings }) {
174
- const manifestFile = path.join(artifactRoot, "manifest.json");
175
- if (!fs.existsSync(manifestFile)) return null;
176
- let manifest;
177
- try {
178
- manifest = JSON.parse(fs.readFileSync(manifestFile, "utf8"));
179
- } catch (error) {
180
- throw new Error(`invalid web-surface artifact manifest: ${error.message}`);
181
- }
182
- const raw = manifest?.publicationFastPath;
183
- if (raw === undefined || raw === null) return null;
184
- if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
185
- throw new Error("publicationFastPath must be an object");
186
- }
187
- if (raw.contract !== PUBLICATION_FAST_PATH_CONTRACT || raw.mode !== "package-pin-only") {
188
- throw new Error("publicationFastPath contract or mode is unsupported");
189
- }
190
- const targetSurface = String(raw.targetSurface || "").trim();
191
- const binding = bindings.find((entry) => entry.surface === targetSurface);
192
- if (!binding) {
193
- throw new Error(`publicationFastPath target surface is not declared: ${targetSurface}`);
194
- }
195
- const qualificationRoot = String(raw.qualificationRoot || "").trim();
196
- if (!/^sha256:[a-f0-9]{64}$/.test(qualificationRoot)) {
197
- throw new Error("publicationFastPath qualificationRoot must be an exact SHA-256 root");
198
- }
199
- const surfaceRoot = surfaceArtifactRootFor({ artifactRoot, binding });
200
- const immutablePrefixes = [...new Set((raw.immutablePrefixes || []).map((entry) =>
201
- immutablePrefix(entry, "publicationFastPath immutable prefix"),
202
- ))].sort();
203
- if (immutablePrefixes.length === 0) {
204
- throw new Error("publicationFastPath must declare immutablePrefixes");
205
- }
206
- const mutableFiles = [...new Set((raw.mutableFiles || []).map((entry) => {
207
- const normalized = normalizeS3Key(entry);
208
- const candidate = path.join(surfaceRoot, normalized);
209
- if (
210
- !normalized
211
- || String(entry).includes("..")
212
- || !fs.statSync(candidate, { throwIfNoEntry: false })?.isFile()
213
- ) {
214
- throw new Error(`invalid or missing publicationFastPath mutable file: ${entry}`);
215
- }
216
- return normalized;
217
- }))].sort();
218
- if (mutableFiles.length === 0) {
219
- throw new Error("publicationFastPath must declare mutableFiles");
220
- }
221
- if (mutableFiles.some((file) =>
222
- immutablePrefixes.some((prefix) => file === prefix || file.startsWith(`${prefix}/`)))) {
223
- throw new Error("publicationFastPath mutable files cannot overlap immutable prefixes");
224
- }
225
- for (const prefix of immutablePrefixes) {
226
- if (!fs.statSync(path.join(surfaceRoot, prefix), { throwIfNoEntry: false })?.isDirectory()) {
227
- throw new Error(`publicationFastPath immutable prefix does not exist: ${prefix}`);
228
- }
229
- }
230
- const invalidationPaths = [...new Set((raw.invalidationPaths || []).map((entry) => {
231
- const value = String(entry || "").trim();
232
- if (!value.startsWith("/") || value.includes("..")) {
233
- throw new Error(`invalid publicationFastPath invalidation path: ${entry}`);
234
- }
235
- return value;
236
- }))].sort();
237
- if (invalidationPaths.length === 0) {
238
- throw new Error("publicationFastPath must declare invalidationPaths");
239
- }
240
- return {
241
- contract: PUBLICATION_FAST_PATH_CONTRACT,
242
- mode: "package-pin-only",
243
- targetSurface,
244
- qualificationRoot,
245
- immutablePrefixes,
246
- mutableFiles,
247
- invalidationPaths,
248
- };
249
- }
250
-
251
- function applyPublicationFastPathScope(bindings, { cwd, artifactPath }) {
252
- const artifactRoot = path.resolve(cwd, artifactPath);
253
- const scope = publicationFastPathScope({ artifactRoot, bindings });
254
- if (!scope) {
255
- return { bindings, scope: null };
256
- }
257
- return {
258
- bindings: bindings
259
- .filter((binding) => binding.surface === scope.targetSurface)
260
- .map((binding) => ({ ...binding, publicationFastPath: scope })),
261
- scope,
262
- };
263
- }
264
-
265
- function publicationImmutablePolicy({ artifactRoot, binding }) {
266
- const surfaceRoot = surfaceArtifactRootFor({ artifactRoot, binding });
267
- const manifestFile = path.join(surfaceRoot, "manifest.json");
268
- if (!fs.existsSync(manifestFile)) return null;
269
- let manifest;
270
- try {
271
- manifest = JSON.parse(fs.readFileSync(manifestFile, "utf8"));
272
- } catch (error) {
273
- throw new Error(`invalid publication archive manifest ${toPosix(path.relative(artifactRoot, manifestFile))}: ${error.message}`);
274
- }
275
- if (manifest?.archivePolicy?.contract !== PUBLICATION_ARCHIVE_POLICY_CONTRACT) return null;
276
- const declaredVersions = (manifest.publications || []).flatMap((publication) =>
277
- (publication.versions || []).map((version) => ({
278
- prefix: immutablePrefix(
279
- version.immutablePath,
280
- `publication ${publication.id || "unknown"} immutablePath`,
281
- ),
282
- materialized: Object.hasOwn(version, "immutableIndex"),
283
- })),
284
- );
285
- const declaredPrefixes = [...new Set(declaredVersions.map((entry) => entry.prefix))].sort();
286
- if (declaredPrefixes.length === 0) {
287
- throw new Error("publication archive policy must declare at least one immutable version prefix");
288
- }
289
- const hasMaterializationEnvelope = declaredVersions.some((entry) => entry.materialized);
290
- const materializedPrefixes = [...new Set(
291
- (hasMaterializationEnvelope
292
- ? declaredVersions.filter((entry) => entry.materialized)
293
- : declaredVersions
294
- ).map((entry) => entry.prefix),
295
- )].sort();
296
- for (const prefix of materializedPrefixes) {
297
- if (!fs.existsSync(path.join(surfaceRoot, prefix))) {
298
- throw new Error(`materialized immutable publication prefix does not exist in artifact: ${prefix}`);
299
- }
300
- }
301
- const preservedRoots = declaredPrefixes;
302
- const uploadRoots = binding.publicationFastPath?.immutablePrefixes || materializedPrefixes;
303
- if (binding.publicationFastPath) {
304
- for (const prefix of uploadRoots) {
305
- if (!declaredPrefixes.includes(prefix)) {
306
- throw new Error(`publicationFastPath immutable prefix is not declared by the archive manifest: ${prefix}`);
307
- }
308
- }
309
- }
310
- const files = uploadRoots
311
- .flatMap((root) => listFiles(surfaceRoot, root))
312
- .map((filePath) => ({
313
- path: toPosix(path.relative(surfaceRoot, filePath)),
314
- size: fs.statSync(filePath).size,
315
- sha256: sha256File(filePath),
316
- }))
317
- .sort((left, right) => left.path.localeCompare(right.path));
318
- return {
319
- contract: "kungfu-buildchain-web-surface-immutable-publication",
320
- sourceContract: manifest.contract || "",
321
- archivePolicyContract: PUBLICATION_ARCHIVE_POLICY_CONTRACT,
322
- manifestPath: toPosix(path.relative(artifactRoot, manifestFile)),
323
- preservedRoots,
324
- declaredPrefixes,
325
- materializedPrefixes,
326
- uploadRoots,
327
- files,
328
- fastPath: binding.publicationFastPath || undefined,
329
- };
330
- }
331
-
332
- function observedEvidenceOwnershipPolicy({ artifactRoot, binding }) {
333
- const surfaceRoot = surfaceArtifactRootFor({ artifactRoot, binding });
334
- const policyFile = path.join(surfaceRoot, ".buildchain", "observed-evidence-ownership.json");
335
- if (!fs.existsSync(policyFile)) return null;
336
- let policy;
337
- try {
338
- policy = JSON.parse(fs.readFileSync(policyFile, "utf8"));
339
- } catch (error) {
340
- throw new Error(`invalid observed evidence ownership policy: ${error.message}`);
341
- }
342
- if (policy?.schemaVersion !== 1 || policy?.contract !== OBSERVED_EVIDENCE_OWNERSHIP_CONTRACT) {
343
- throw new Error(`observed evidence ownership policy must be ${OBSERVED_EVIDENCE_OWNERSHIP_CONTRACT} schemaVersion 1`);
344
- }
345
- const paths = [...new Set(policy.paths || [])].map((entry) => String(entry).replaceAll("\\", "/").replace(/^\/+/, ""));
346
- if (paths.length === 0 || paths.some((entry) => !entry || entry.split("/").includes("..") || entry === "*")) {
347
- throw new Error("observed evidence ownership policy requires bounded relative paths");
348
- }
349
- return {
350
- contract: OBSERVED_EVIDENCE_OWNERSHIP_CONTRACT,
351
- policyPath: toPosix(path.relative(artifactRoot, policyFile)),
352
- paths: paths.sort(),
353
- };
354
- }
355
-
356
- function withImmutablePublicationPolicies(bindings, { cwd, artifactPath }) {
357
- const artifactRoot = path.resolve(cwd, artifactPath);
358
- const withOwnPolicies = bindings.map((binding) => {
359
- const immutablePublication = publicationImmutablePolicy({ artifactRoot, binding });
360
- const observedEvidenceOwnership = observedEvidenceOwnershipPolicy({ artifactRoot, binding });
361
- if (!immutablePublication && !observedEvidenceOwnership) return binding;
362
- return { ...binding, ...(immutablePublication ? { immutablePublication } : {}), ...(observedEvidenceOwnership ? { observedEvidenceOwnership } : {}) };
363
- });
364
- const protectedRoots = withOwnPolicies.flatMap((binding) =>
365
- (binding.immutablePublication?.preservedRoots || []).map((root) => ({
366
- owner: binding.surface,
367
- path: joinS3Key(binding.artifactPathPrefix, root),
368
- })),
369
- );
370
- const withDeleteExcludes = withOwnPolicies.map((binding) => {
371
- const bindingPrefix = normalizeS3Key(binding.artifactPathPrefix);
372
- const mutableDeleteExcludes = [...new Set([
373
- ...protectedRoots
374
- .map((protectedRoot) => {
375
- if (!bindingPrefix) return `${protectedRoot.path}/*`;
376
- if (protectedRoot.path === bindingPrefix) return "*";
377
- if (!protectedRoot.path.startsWith(`${bindingPrefix}/`)) return "";
378
- return `${protectedRoot.path.slice(bindingPrefix.length + 1)}/*`;
379
- })
380
- .filter(Boolean),
381
- ...(binding.observedEvidenceOwnership?.paths || []),
382
- ])].sort();
383
- return mutableDeleteExcludes.length > 0
384
- ? { ...binding, mutableDeleteExcludes }
385
- : binding;
386
- });
387
- return withDeleteExcludes.map((binding) => {
388
- if (!binding.immutablePublication) return binding;
389
- const ownedPaths = protectedRoots
390
- .filter((protectedRoot) => protectedRoot.owner === binding.surface)
391
- .map((protectedRoot) => protectedRoot.path);
392
- const coveringBindings = withDeleteExcludes
393
- .map((candidate) => {
394
- const candidatePrefix = normalizeS3Key(candidate.artifactPathPrefix);
395
- const excludes = ownedPaths
396
- .map((ownedPath) => {
397
- if (!candidatePrefix) return `${ownedPath}/*`;
398
- if (ownedPath === candidatePrefix) return "*";
399
- if (!ownedPath.startsWith(`${candidatePrefix}/`)) return "";
400
- return `${ownedPath.slice(candidatePrefix.length + 1)}/*`;
401
- })
402
- .filter(Boolean)
403
- .sort();
404
- return excludes.length > 0
405
- ? { surface: candidate.surface, mutableDeleteExcludes: excludes }
406
- : null;
407
- })
408
- .filter(Boolean)
409
- .sort((left, right) => left.surface.localeCompare(right.surface));
410
- return {
411
- ...binding,
412
- immutablePublication: {
413
- ...binding.immutablePublication,
414
- coveringBindings,
415
- },
416
- };
417
- });
418
- }
419
-
420
- function pathUnderPreservedRoot(relativePath, preservedRoots = []) {
421
- const normalized = normalizeS3Key(relativePath);
422
- return preservedRoots.some((root) => normalized === root || normalized.startsWith(`${root}/`));
423
- }
424
-
425
- function pathExcludedFromMutableDelete(relativePath, patterns = []) {
426
- if (patterns.includes("*")) return true;
427
- return pathUnderPreservedRoot(
428
- relativePath,
429
- patterns.map((pattern) => pattern.replace(/\/\*$/, "")),
430
- );
431
- }
432
-
433
- function directoryIndexAliasKeys({ objectPrefix, relativeIndexPath }) {
434
- const normalizedPrefix = normalizeS3Key(objectPrefix);
435
- if (!normalizedPrefix) {
436
- return [];
437
- }
438
- const normalizedIndexPath = normalizeS3Key(relativeIndexPath);
439
- if (!normalizedIndexPath.endsWith("index.html")) {
440
- return [];
441
- }
442
- const directory = normalizeS3Key(normalizedIndexPath.slice(0, -"index.html".length));
443
- const aliasBase = joinS3Key(normalizedPrefix, directory);
444
- return [...new Set([aliasBase, `${aliasBase}/`].filter(Boolean))];
445
- }
446
-
447
- function directoryIndexAliasOperations({ surfaceArtifactRoot, bucket, binding }) {
448
- if (binding.directoryIndexResolution === false || !bucket || !binding.objectPrefix || !fs.existsSync(surfaceArtifactRoot)) {
449
- return [];
450
- }
451
- return listFiles(surfaceArtifactRoot, ".")
452
- .filter((filePath) => path.basename(filePath) === (binding.directoryIndex || "index.html"))
453
- .filter((filePath) => !pathExcludedFromMutableDelete(
454
- toPosix(path.relative(surfaceArtifactRoot, filePath)),
455
- binding.mutableDeleteExcludes || [],
456
- ))
457
- .flatMap((filePath) => {
458
- const relativeIndexPath = toPosix(path.relative(surfaceArtifactRoot, filePath));
459
- return directoryIndexAliasKeys({ objectPrefix: binding.objectPrefix, relativeIndexPath }).map((key) => ({
460
- action: "write-directory-index-alias",
461
- surface: binding.surface,
462
- command: "aws",
463
- args: [
464
- "s3api",
465
- "put-object",
466
- "--bucket",
467
- bucket,
468
- "--key",
469
- key,
470
- "--body",
471
- filePath,
472
- "--content-type",
473
- "text/html",
474
- ...(binding.cacheControl?.mutable
475
- ? ["--cache-control", binding.cacheControl.mutable]
476
- : []),
477
- ],
478
- routing: {
479
- ...(binding.routing || {}),
480
- directoryIndexAlias: key,
481
- directoryIndexSource: relativeIndexPath,
482
- },
483
- }));
484
- });
485
- }
486
-
487
- function cloudFrontDirectoryIndexFunctionName(distributionId = "") {
488
- const suffix = String(distributionId || "")
489
- .replace(/[^0-9A-Za-z-]/g, "-")
490
- .slice(0, 48);
491
- return `buildchain-web-surface-index-${suffix || "distribution"}`;
492
- }
493
-
494
- function directoryIndexRewriteMode(binding) {
495
- return binding.directoryIndexRewrite === "external" ? "external" : "buildchain";
496
- }
497
-
498
- function directoryIndexRoutingStrategy(binding) {
499
- return directoryIndexRewriteMode(binding) === "external"
500
- ? "external-viewer-request-function"
501
- : "cloudfront-function";
502
- }
503
-
504
- function cloudFrontDirectoryIndexRewriteOperations(bindings) {
505
- const seen = new Set();
506
- const helper = path.join(moduleDir, "web-surface-cloudfront-rewrite.mjs");
507
- return bindings
508
- .filter((binding) => directoryIndexRewriteMode(binding) === "buildchain")
509
- .map((binding) => binding.distributionId || "")
510
- .filter(Boolean)
511
- .filter((distributionId) => {
512
- if (seen.has(distributionId)) {
513
- return false;
514
- }
515
- seen.add(distributionId);
516
- return true;
517
- })
518
- .map((distributionId) => ({
519
- action: "ensure-cloudfront-directory-index-rewrite",
520
- surface: "__distribution__",
521
- command: "node",
522
- args: [
523
- helper,
524
- "--distribution-id",
525
- distributionId,
526
- "--function-name",
527
- cloudFrontDirectoryIndexFunctionName(distributionId),
528
- ],
529
- routing: {
530
- contract: "kungfu-buildchain-web-surface-directory-index-rewrite",
531
- strategy: "cloudfront-function",
532
- managedBy: "buildchain",
533
- distributionId,
534
- functionName: cloudFrontDirectoryIndexFunctionName(distributionId),
535
- requestRewrite: "viewer request paths ending in / are rewritten to /index.html",
536
- },
537
- }));
538
- }
539
-
540
- function defaultCommandRunner({ command, args, stdin = "" }) {
541
- const result = spawnSync(command, args, {
542
- encoding: "utf8",
543
- input: stdin,
544
- });
545
- if (result.error) {
546
- throw result.error;
547
- }
548
- if (result.status !== 0) {
549
- const stderr = String(result.stderr || "").trim();
550
- throw new Error(`${command} ${args.join(" ")} failed with exit code ${result.status}${stderr ? `: ${stderr}` : ""}`);
551
- }
552
- return {
553
- exitCode: result.status,
554
- stdout: String(result.stdout || ""),
555
- stderr: String(result.stderr || ""),
556
- };
557
- }
558
-
559
- function runAdapterOperation({ operation, dryRun, commandRunner }) {
560
- if (dryRun) {
561
- return {
562
- ...operation,
563
- status: "planned",
564
- executed: false,
565
- exitCode: null,
566
- stdout: "",
567
- stderr: "",
568
- };
569
- }
570
- try {
571
- const commandResult = commandRunner(operation);
572
- const exitCode = commandResult?.exitCode ?? 0;
573
- return {
574
- ...operation,
575
- status: exitCode === 0 ? "applied" : "failed",
576
- executed: true,
577
- exitCode,
578
- stdout: commandResult?.stdout || "",
579
- stderr: commandResult?.stderr || "",
580
- };
581
- } catch (error) {
582
- return {
583
- ...operation,
584
- status: "failed",
585
- executed: true,
586
- exitCode: null,
587
- stdout: "",
588
- stderr: String(error.message || error),
589
- };
590
- }
591
- }
592
-
593
- function runAdapterOperations({ operations, dryRun, commandRunner }) {
594
- const results = [];
595
- for (const operation of operations) {
596
- const result = runAdapterOperation({ operation, dryRun, commandRunner });
597
- results.push(result);
598
- if (result.status === "failed") {
599
- break;
600
- }
601
- }
602
- return results;
603
- }
604
-
605
- function appliedStatus({ dryRun, operations, noOp = false }) {
606
- if (noOp) {
607
- return "no-op";
608
- }
609
- if (operations.some((operation) => operation.status === "failed")) {
610
- return "failed";
611
- }
612
- return dryRun ? "planned" : "applied";
613
- }
614
-
615
- function isPlaceholderValue(value) {
616
- const normalized = String(value || "").trim().toLowerCase();
617
- return (
618
- normalized === "" ||
619
- normalized === "pending" ||
620
- normalized.startsWith("pending-") ||
621
- normalized.startsWith("pending_") ||
622
- normalized.includes("placeholder") ||
623
- normalized.includes("example.")
624
- );
625
- }
626
-
627
- function assertConcreteAwsDeployConfig({ deployConfig, channel, operation }) {
628
- const bucket = deployConfig.bucket || deployConfig.target || "";
629
- const distribution = deployConfig.cloudfront_distribution || deployConfig.distribution || "";
630
- if (isPlaceholderValue(bucket)) {
631
- throw new Error(`web-surface ${operation} apply requires concrete deploy.${channel}.bucket or deploy.${channel}.target`);
632
- }
633
- if (isPlaceholderValue(distribution)) {
634
- throw new Error(
635
- `web-surface ${operation} apply requires concrete deploy.${channel}.cloudfront_distribution or deploy.${channel}.distribution`,
636
- );
637
- }
638
- }
639
-
640
- function urlHost(value = "") {
641
- try {
642
- return new URL(value).hostname.toLowerCase();
643
- } catch {
644
- return "";
645
- }
646
- }
647
-
648
- function wildcardHostMatches(alias = "", host = "") {
649
- const normalizedAlias = String(alias || "").toLowerCase();
650
- const normalizedHost = String(host || "").toLowerCase();
651
- if (!normalizedAlias.startsWith("*.")) return false;
652
- const suffix = normalizedAlias.slice(1);
653
- return normalizedHost.endsWith(suffix) && normalizedHost.slice(0, -suffix.length).indexOf(".") === -1;
654
- }
655
-
656
- function aliasMatchesHost(aliases = [], host = "") {
657
- const normalizedHost = String(host || "").toLowerCase();
658
- return aliases.some((alias) => {
659
- const normalizedAlias = String(alias || "").toLowerCase();
660
- return normalizedAlias === normalizedHost || wildcardHostMatches(normalizedAlias, normalizedHost);
661
- });
662
- }
663
-
664
- function parseCloudFrontAliases(stdout = "") {
665
- if (!stdout) return [];
666
- try {
667
- const parsed = JSON.parse(stdout);
668
- const aliases = parsed?.Distribution?.DistributionConfig?.Aliases?.Items ||
669
- parsed?.DistributionConfig?.Aliases?.Items ||
670
- parsed?.Aliases?.Items ||
671
- parsed?.Aliases ||
672
- [];
673
- return Array.isArray(aliases) ? aliases : [];
674
- } catch {
675
- return [];
676
- }
677
- }
678
-
679
- async function defaultDnsResolver(host) {
680
- try {
681
- const answers = await dns.resolve(host);
682
- return answers.map((address) => ({ type: "A", value: address }));
683
- } catch (error) {
684
- if (error?.code === "ENODATA" || error?.code === "ENOTFOUND") {
685
- const answers = await dns.resolve6(host);
686
- return answers.map((address) => ({ type: "AAAA", value: address }));
687
- }
688
- throw error;
689
- }
690
- }
691
-
692
- function preflightCheck({ name, status = "pass", details = {}, message = "" }) {
693
- return { name, status, message, details };
694
- }
695
-
696
- function preflightStatus(checks) {
697
- return checks.some((check) => check.status === "fail") ? "failed" : "passed";
698
- }
699
-
700
- function deployManifestKey(deployConfig, manifest) {
701
- return joinS3Key(manifestPrefixFor(deployConfig), `${manifest.alias || manifest.channel}.json`);
702
- }
703
-
704
- function deploySurfaceManifestKey(deployConfig, binding) {
705
- const suffix = binding.surface === "default"
706
- ? `${binding.alias || binding.channel}.json`
707
- : `${binding.alias || binding.channel}/${binding.surface}.json`;
708
- return joinS3Key(manifestPrefixFor(deployConfig), suffix);
709
- }
710
-
711
- function assertDeployPlan(plan) {
712
- if (plan?.contract !== "kungfu-buildchain-web-surface-deploy-plan") {
713
- throw new Error("web-surface deploy apply requires a deploy plan");
714
- }
715
- if (!plan.manifest) {
716
- throw new Error("web-surface deploy plan is missing manifest");
717
- }
718
- if (!plan.artifact?.hash) {
719
- throw new Error("web-surface deploy plan is missing artifact hash");
720
- }
721
- if (plan.manifest.artifactHash !== plan.artifact.hash) {
722
- throw new Error("web-surface deploy plan artifact hash does not match manifest");
723
- }
724
- return plan;
725
- }
726
-
727
- function verifyDeployPlanArtifact({ cwd, plan }) {
728
- const artifactPath = plan.artifact.path || ".";
729
- const actual = createWebSurfaceArtifactHash({ cwd, artifactPath });
730
- if (actual.artifactHash !== plan.artifact.hash) {
731
- throw new Error(
732
- `web-surface deploy plan artifact hash mismatch: expected ${plan.artifact.hash}, got ${actual.artifactHash}`,
733
- );
734
- }
735
- return {
736
- ...plan,
737
- artifact: {
738
- ...plan.artifact,
739
- path: artifactPath,
740
- files: actual.files,
741
- },
742
- };
743
- }
744
-
745
- function assertCleanupPlan(plan) {
746
- if (plan?.contract !== "kungfu-buildchain-web-surface-cleanup-plan") {
747
- throw new Error("web-surface cleanup apply requires a cleanup plan");
748
- }
749
- if (!Array.isArray(plan.entries)) {
750
- throw new Error("web-surface cleanup plan is missing entries");
751
- }
752
- return plan;
753
- }
754
-
755
- function retentionFor({ config, channelName, alias, deployedAt }) {
756
- if (channelName === "preview") {
757
- const classified = classifyPreviewAlias(alias);
758
- const days = retentionConfig(config, "preview")[classified.retentionKey];
759
- return {
760
- aliasKind: classified.kind,
761
- mutableAlias: classified.mutable,
762
- retentionClass: classified.retentionClass,
763
- expiresAt: addDays(deployedAt, days),
764
- retentionDays: days,
765
- };
766
- }
767
- if (channelName === "staging") {
768
- const retention = retentionConfig(config, "staging");
769
- return {
770
- aliasKind: "",
771
- mutableAlias: true,
772
- retentionClass: "staging-protected",
773
- expiresAt: addDays(deployedAt, retention.days),
774
- retentionDays: retention.days,
775
- keepDeploys: retention.keep_deploys,
776
- };
777
- }
778
- const retention = retentionConfig(config, "production");
779
- return {
780
- aliasKind: "",
781
- mutableAlias: false,
782
- retentionClass: "production-canonical",
783
- expiresAt: addDays(deployedAt, retention.days),
784
- retentionDays: retention.days,
785
- };
786
- }
787
-
788
- function configuredSurfaces(config) {
789
- if (config.surfaces && Object.keys(config.surfaces).length > 0) {
790
- return Object.values(config.surfaces);
791
- }
792
- return [{
793
- name: "default",
794
- path: "/",
795
- pathOnly: false,
796
- canonical: true,
797
- }];
798
- }
799
-
800
- function resolveSurfaceBindings({ config, channelName, alias, deployConfig }) {
801
- const channel = config.channels?.[channelName];
802
- if (!channel) {
803
- throw new Error(`unknown web-surface channel: ${channelName}`);
804
- }
805
- return configuredSurfaces(config).map((surface) => {
806
- const effectiveDeploy = surfaceDeployConfig(deployConfig, surface.name);
807
- const url = surface.name === "default" && !config.surfaces
808
- ? resolveChannelUrl(channel, alias)
809
- : resolveSurfaceUrl({ surface, channel, channelName, alias });
810
- const objectPrefix = surface.name === "default" && !config.surfaces
811
- ? objectPrefixFor(deployConfig, alias || channelName)
812
- : surfaceObjectPrefixFor({ deployConfig, surface, alias: alias || channelName });
813
- const bucket = effectiveDeploy.bucket || effectiveDeploy.target || "";
814
- const distributionId = effectiveDeploy.cloudfront_distribution || effectiveDeploy.distribution || "";
815
- return {
816
- surface: surface.name,
817
- channel: channelName,
818
- alias,
819
- url,
820
- sourcePath: normalizeSurfacePath(surface.path),
821
- artifactPathPrefix: surfaceArtifactPrefix({ sourcePath: surface.path }),
822
- viewerPathPrefix: "/",
823
- directoryIndex: "index.html",
824
- directoryIndexResolution: true,
825
- directoryIndexRewrite: effectiveDeploy.directoryIndexRewrite || "buildchain",
826
- healthStrategy: effectiveDeploy.healthStrategy || "",
827
- cacheControl: effectiveDeploy.cacheControl || undefined,
828
- canonicalUrl: surface.productionUrl || (channelName === "production" ? url : ""),
829
- pathOnly: Boolean(surface.pathOnly),
830
- bucket,
831
- distributionId,
832
- originPath: effectiveDeploy.origin_path || effectiveDeploy.originPath || "",
833
- objectPrefix,
834
- manifestKey: "",
835
- noindex: channel.noindex,
836
- accessControl: channel.accessControl,
837
- };
838
- }).map((binding) => ({
839
- ...binding,
840
- manifestKey: deploySurfaceManifestKey(deployConfig, binding),
841
- }));
842
- }
843
-
844
- function relativeArtifactPath({ artifactPath, filePath }) {
845
- const normalizedArtifact = normalizeS3Key(artifactPath);
846
- const normalizedFile = normalizeS3Key(filePath);
847
- if (!normalizedArtifact) {
848
- return normalizedFile;
849
- }
850
- return normalizedFile === normalizedArtifact
851
- ? ""
852
- : normalizedFile.startsWith(`${normalizedArtifact}/`)
853
- ? normalizedFile.slice(normalizedArtifact.length + 1)
854
- : normalizedFile;
855
- }
856
-
857
- function requestPathFromArtifactPath({ binding, artifactPath, filePath }) {
858
- const relative = relativeArtifactPath({ artifactPath, filePath });
859
- const prefix = normalizeS3Key(binding.artifactPathPrefix || surfaceArtifactPrefix(binding));
860
- if (prefix && relative !== prefix && !relative.startsWith(`${prefix}/`)) {
861
- return "";
862
- }
863
- const surfaceRelative = prefix
864
- ? relative.slice(prefix.length).replace(/^\/+/, "")
865
- : relative;
866
- if (!surfaceRelative || surfaceRelative === "index.html") {
867
- return "/";
868
- }
869
- if (surfaceRelative.endsWith("/index.html")) {
870
- const directoryPath = normalizeS3Key(surfaceRelative.slice(0, -"index.html".length));
871
- return directoryPath ? `/${directoryPath}/` : "/";
872
- }
873
- return joinUrlPath(surfaceRelative);
874
- }
875
-
876
- function smokeUrlsForBinding({ binding, artifactPath, files }) {
877
- const rootUrl = urlWithPath(binding.url, "/");
878
- const candidates = (files || [])
879
- .map((file) => requestPathFromArtifactPath({ binding, artifactPath, filePath: file.path }))
880
- .filter(Boolean)
881
- .filter((requestPath) => requestPath !== "/")
882
- .filter((requestPath) => requestPath.endsWith("/") || requestPath.endsWith(".html"))
883
- .sort();
884
- const nestedPath = candidates[0] || "";
885
- return [
886
- {
887
- kind: "root",
888
- requestPath: "/",
889
- url: rootUrl,
890
- required: true,
891
- },
892
- ...(nestedPath
893
- ? [{
894
- kind: "nested",
895
- requestPath: nestedPath,
896
- url: urlWithPath(binding.url, nestedPath),
897
- required: true,
898
- }]
899
- : []),
900
- ];
901
- }
902
-
903
- function withSurfaceRoutingEvidence(bindings, { artifactPath, files }) {
904
- return bindings.map((binding) => {
905
- const directoryIndexRewrite = directoryIndexRewriteMode(binding);
906
- return {
907
- ...binding,
908
- directoryIndexRewrite,
909
- artifactPathPrefix: normalizeS3Key(binding.artifactPathPrefix || surfaceArtifactPrefix(binding)),
910
- viewerPathPrefix: binding.viewerPathPrefix || "/",
911
- directoryIndex: binding.directoryIndex || "index.html",
912
- directoryIndexResolution: binding.directoryIndexResolution !== false,
913
- routing: {
914
- contract: "kungfu-buildchain-web-surface-path-prefix-rewrite",
915
- viewerPathPrefix: binding.viewerPathPrefix || "/",
916
- artifactPathPrefix: normalizeS3Key(binding.artifactPathPrefix || surfaceArtifactPrefix(binding)),
917
- objectPrefix: binding.objectPrefix,
918
- directoryIndex: binding.directoryIndex || "index.html",
919
- directoryIndexResolution: binding.directoryIndexResolution !== false,
920
- directoryIndexRewrite,
921
- directoryIndexManagedBy: directoryIndexRewrite === "external" ? "external" : "buildchain",
922
- directoryIndexStrategy: directoryIndexRoutingStrategy(binding),
923
- },
924
- smokeUrls: smokeUrlsForBinding({ binding, artifactPath, files }),
925
- };
926
- });
927
- }
928
-
929
- export function validateWebSurfaceProject(cwd = process.cwd()) {
930
- const summary = validateBuildchainConfig(cwd, {
931
- requireConfig: true,
932
- });
933
- if (summary.project?.type !== "web-surface") {
934
- throw new Error('buildchain.toml project.type must be "web-surface"');
935
- }
936
- return summary;
937
- }
938
-
939
- export function createWebSurfaceArtifactHash({ cwd = process.cwd(), artifactPath = "" } = {}) {
940
- const root = path.resolve(cwd);
941
- const files = listFiles(root, artifactPath || ".")
942
- .sort()
943
- .map((filePath) => {
944
- const stat = fs.statSync(filePath);
945
- const relative = toPosix(path.relative(root, filePath));
946
- return {
947
- path: relative,
948
- size: stat.size,
949
- sha256: sha256File(filePath),
950
- };
951
- });
952
- const digest = crypto.createHash("sha256");
953
- for (const file of files) {
954
- digest.update(`${file.path}\0${file.size}\0${file.sha256}\n`);
955
- }
956
- return {
957
- artifactHash: digest.digest("hex"),
958
- files,
959
- };
960
- }
961
-
962
- function installerPublicationEvidence(artifactRoot) {
963
- const manifestPath = path.join(artifactRoot, "installer-publication.json");
964
- if (!fs.existsSync(manifestPath)) return null;
965
- let publication;
966
- try {
967
- publication = JSON.parse(fs.readFileSync(manifestPath, "utf8"));
968
- } catch (error) {
969
- throw new Error(`invalid installer publication manifest: ${error.message}`);
970
- }
971
- return validateInstallerPublication({ publication, artifactRoot });
972
- }
973
-
974
- export function createWebSurfaceDeploymentManifest({
975
- cwd = process.cwd(),
976
- channel = "preview",
977
- alias = "",
978
- sourceSha = "",
979
- artifactHash = "",
980
- deployedAt = new Date().toISOString(),
981
- deploymentId = "",
982
- runtimeId = "",
983
- configFingerprint = "",
984
- healthCheck = "",
985
- migrationState = "",
986
- rollbackPointer = "",
987
- rollbackLimitations = "",
988
- } = {}) {
989
- const loadedConfig = loadBuildchainConfig(cwd);
990
- const config = assertWebSurfaceConfig(loadedConfig);
991
- const channelConfig = config.channels?.[channel];
992
- if (!channelConfig) {
993
- throw new Error(`unknown web-surface channel: ${channel}`);
994
- }
995
- const deployConfig = config.deploy?.[channel];
996
- if (!deployConfig) {
997
- throw new Error(`missing deploy.${channel}`);
998
- }
999
- const retention = retentionFor({ config, channelName: channel, alias, deployedAt });
1000
- const surfaceBindings = resolveSurfaceBindings({
1001
- config,
1002
- channelName: channel,
1003
- alias,
1004
- deployConfig,
1005
- });
1006
- const primaryBinding = surfaceBindings[0];
1007
- const timestampPolicy = createSurfaceTimestampPolicy({
1008
- generatedAt: deployedAt,
1009
- publishedAt: deployedAt,
1010
- sourceRevision: sourceSha,
1011
- timestampPolicy: "ci-injected",
1012
- deterministicInputs: [
1013
- "web-surface artifact content",
1014
- "buildchain.toml web-surface channels/deploy/surfaces",
1015
- "sourceSha",
1016
- "artifactHash",
1017
- "deployment channel",
1018
- "deployment alias",
1019
- ],
1020
- timestampFields: ["generatedAt", "publishedAt", "deployedAt"],
1021
- timestampFieldsParticipateInArtifactDigest: false,
1022
- artifactDigestScope: "web-surface artifactHash excludes deployment manifest timestamps",
1023
- });
1024
- return {
1025
- schemaVersion: 1,
1026
- contract: "kungfu-buildchain-web-surface-deployment",
1027
- ...timestampPolicy,
1028
- site: config.project.site || config.project.name || "",
1029
- channel,
1030
- alias,
1031
- url: primaryBinding.url,
1032
- sourceSha: assertSha(sourceSha, "sourceSha"),
1033
- artifactHash: assertHash(artifactHash, "artifactHash"),
1034
- deployTarget: deployConfig.target || deployConfig.bucket || deployConfig.environment || deployConfig.service || "",
1035
- adapter: deployConfig.adapter,
1036
- deploymentId,
1037
- deployedAt,
1038
- retentionClass: retention.retentionClass,
1039
- expiresAt: retention.expiresAt,
1040
- mutableAlias: retention.mutableAlias,
1041
- accessControl: channelConfig.accessControl,
1042
- edgeAuth: channelConfig.edgeAuth,
1043
- noindex: channelConfig.noindex,
1044
- promotable: channelConfig.promotable,
1045
- canonical: channelConfig.canonical,
1046
- runtimeId,
1047
- configFingerprint,
1048
- secretRefs: [
1049
- ...new Set([
1050
- ...(deployConfig.secretRefs || []),
1051
- ...(config.security?.[channel]?.secretRefs || []),
1052
- ]),
1053
- ],
1054
- healthCheck,
1055
- migrationState,
1056
- rollbackPointer,
1057
- rollbackLimitations,
1058
- surfaceBindings,
1059
- };
1060
- }
1061
-
1062
- export function planWebSurfaceDeploy({
1063
- cwd = process.cwd(),
1064
- channel = "preview",
1065
- alias = "",
1066
- sourceSha = "",
1067
- artifactHash = "",
1068
- artifactPath = "",
1069
- runtimeId = "",
1070
- configFingerprint = "",
1071
- rollbackPointer = "",
1072
- rollbackLimitations = "",
1073
- dryRun = true,
1074
- deployedAt = new Date().toISOString(),
1075
- } = {}) {
1076
- if (!dryRun) {
1077
- throw new Error("web-surface deploy currently supports dry-run planning only");
1078
- }
1079
- const loadedConfig = loadBuildchainConfig(cwd);
1080
- const config = assertWebSurfaceConfig(loadedConfig);
1081
- const deployConfig = config.deploy?.[channel];
1082
- if (!deployConfig) {
1083
- throw new Error(`missing deploy.${channel}`);
1084
- }
1085
- const resolvedArtifact = artifactHash
1086
- ? { artifactHash: assertHash(artifactHash, "artifactHash"), files: [] }
1087
- : createWebSurfaceArtifactHash({
1088
- cwd,
1089
- artifactPath: artifactPath || deployConfig.artifactPath || ".",
1090
- });
1091
- const manifest = createWebSurfaceDeploymentManifest({
1092
- cwd,
1093
- channel,
1094
- alias,
1095
- sourceSha,
1096
- artifactHash: resolvedArtifact.artifactHash,
1097
- runtimeId,
1098
- configFingerprint,
1099
- rollbackPointer,
1100
- rollbackLimitations,
1101
- deployedAt,
1102
- });
1103
- const installerEvidence = installerPublicationEvidence(
1104
- path.resolve(cwd, artifactPath || deployConfig.artifactPath || "."),
1105
- );
1106
- if (installerEvidence) {
1107
- manifest.installerPublicationEvidence = installerEvidence;
1108
- }
1109
- const scoped = applyPublicationFastPathScope(manifest.surfaceBindings, {
1110
- cwd,
1111
- artifactPath: artifactPath || deployConfig.artifactPath || ".",
1112
- });
1113
- const surfaceBindings = withImmutablePublicationPolicies(withSurfaceRoutingEvidence(scoped.bindings, {
1114
- artifactPath: artifactPath || deployConfig.artifactPath || ".",
1115
- files: resolvedArtifact.files,
1116
- }), {
1117
- cwd,
1118
- artifactPath: artifactPath || deployConfig.artifactPath || ".",
1119
- });
1120
- if (installerEvidence) {
1121
- const preserved = surfaceBindings.some((binding) =>
1122
- binding.immutablePublication?.declaredPrefixes?.includes(installerEvidence.immutablePath));
1123
- if (!preserved) {
1124
- throw new Error(
1125
- `installer immutable path is not covered by append-only publication policy: ${installerEvidence.immutablePath}`,
1126
- );
1127
- }
1128
- }
1129
- manifest.surfaceBindings = surfaceBindings;
1130
- if (scoped.scope) {
1131
- manifest.publicationFastPath = scoped.scope;
1132
- manifest.url = surfaceBindings[0].url;
1133
- }
1134
- return {
1135
- schemaVersion: 1,
1136
- contract: "kungfu-buildchain-web-surface-deploy-plan",
1137
- dryRun: true,
1138
- adapter: deployConfig.adapter,
1139
- channel,
1140
- alias,
1141
- url: manifest.url,
1142
- urls: Object.fromEntries(surfaceBindings.map((binding) => [binding.surface, binding.url])),
1143
- artifact: {
1144
- path: artifactPath || deployConfig.artifactPath || ".",
1145
- hash: resolvedArtifact.artifactHash,
1146
- files: resolvedArtifact.files,
1147
- },
1148
- manifest,
1149
- surfaceBindings,
1150
- publicationFastPath: scoped.scope || undefined,
1151
- steps: planAdapterSteps(deployConfig.adapter, deployConfig, manifest),
1152
- };
1153
- }
1154
-
1155
- export function verifyWebSurfaceArtifactChannelFacts({ cwd = process.cwd(), plan } = {}) {
1156
- const resolvedPlan = assertDeployPlan(plan);
1157
- const artifactRoot = path.resolve(cwd, resolvedPlan.artifact.path);
1158
- const expectedHosts = new Set((resolvedPlan.manifest?.surfaceBindings || []).map((binding) => {
1159
- try { return new URL(binding.url).host; } catch { return ""; }
1160
- }).filter(Boolean));
1161
- const observed = [];
1162
- const scopedPrefix = normalizeS3Key(
1163
- resolvedPlan.publicationFastPath
1164
- ? resolvedPlan.surfaceBindings?.[0]?.artifactPathPrefix || ""
1165
- : "",
1166
- );
1167
- for (const filePath of listFiles(artifactRoot, artifactRoot)
1168
- .filter((entry) => entry.endsWith(".json"))
1169
- .filter((entry) => {
1170
- if (!scopedPrefix) return true;
1171
- const relative = normalizeS3Key(path.relative(artifactRoot, entry));
1172
- return relative === scopedPrefix || relative.startsWith(`${scopedPrefix}/`);
1173
- })) {
1174
- let value;
1175
- try { value = JSON.parse(fs.readFileSync(filePath, "utf8")); } catch { continue; }
1176
- if (!value || typeof value !== "object" || Array.isArray(value) || !String(value.contract || "").includes("manifest")) continue;
1177
- const facts = [];
1178
- if (typeof value.canonicalHost === "string" && value.canonicalHost.trim()) facts.push({ field: "canonicalHost", host: value.canonicalHost.trim() });
1179
- if (Array.isArray(value.pages)) {
1180
- for (const [index, page] of value.pages.entries()) {
1181
- if (typeof page?.host === "string" && page.host.trim()) facts.push({ field: `pages[${index}].host`, host: page.host.trim() });
1182
- }
1183
- }
1184
- for (const fact of facts) observed.push({ path: toPosix(path.relative(cwd, filePath)), ...fact });
1185
- }
1186
- const mismatches = observed.filter((fact) => !expectedHosts.has(fact.host));
1187
- if (mismatches.length > 0) {
1188
- throw new Error(`web-surface artifact channel facts mismatch for ${resolvedPlan.channel}: ${mismatches.map((fact) => `${fact.path}#${fact.field}=${fact.host}`).join(", ")}`);
1189
- }
1190
- return { channel: resolvedPlan.channel, expectedHosts: [...expectedHosts].sort(), observed };
1191
- }
1192
-
1193
- export function applyWebSurfaceDeploy({
1194
- cwd = process.cwd(),
1195
- channel = "preview",
1196
- alias = "",
1197
- sourceSha = "",
1198
- artifactHash = "",
1199
- artifactPath = "",
1200
- plan = null,
1201
- dryRun = true,
1202
- actor = "",
1203
- runId = "",
1204
- appliedAt = new Date().toISOString(),
1205
- commandRunner = defaultCommandRunner,
1206
- } = {}) {
1207
- const resolvedPlan = plan
1208
- ? verifyDeployPlanArtifact({ cwd, plan: assertDeployPlan(plan) })
1209
- : planWebSurfaceDeploy({
1210
- cwd,
1211
- channel,
1212
- alias,
1213
- sourceSha,
1214
- artifactHash,
1215
- artifactPath,
1216
- dryRun: true,
1217
- deployedAt: appliedAt,
1218
- });
1219
- verifyWebSurfaceArtifactChannelFacts({ cwd, plan: resolvedPlan });
1220
- const loadedConfig = loadBuildchainConfig(cwd);
1221
- const config = assertWebSurfaceConfig(loadedConfig);
1222
- const deployConfig = config.deploy?.[resolvedPlan.channel];
1223
- if (!deployConfig) {
1224
- throw new Error(`missing deploy.${resolvedPlan.channel}`);
1225
- }
1226
- if (resolvedPlan.adapter !== "aws-s3-cloudfront") {
1227
- throw new Error(`web-surface deploy apply does not support adapter: ${resolvedPlan.adapter}`);
1228
- }
1229
- const bucket = deployConfig.bucket || deployConfig.target || "";
1230
- const artifactRoot = path.resolve(cwd, resolvedPlan.artifact.path);
1231
- const bindings = withImmutablePublicationPolicies(withSurfaceRoutingEvidence(resolvedPlan.manifest.surfaceBindings || [], {
1232
- artifactPath: resolvedPlan.artifact.path,
1233
- files: resolvedPlan.artifact.files || [],
1234
- }), {
1235
- cwd,
1236
- artifactPath: resolvedPlan.artifact.path,
1237
- });
1238
- resolvedPlan.manifest.surfaceBindings = bindings;
1239
- if (!dryRun) {
1240
- for (const binding of bindings) {
1241
- assertConcreteAwsDeployConfig({
1242
- deployConfig: surfaceDeployConfig(deployConfig, binding.surface),
1243
- channel: `${resolvedPlan.channel}.surfaces.${binding.surface}`,
1244
- operation: "deploy",
1245
- });
1246
- }
1247
- }
1248
- const bindingOperations = bindings.flatMap((binding) => deployBindingOperations({
1249
- artifactRoot,
1250
- deployConfig,
1251
- manifest: resolvedPlan.manifest,
1252
- binding,
1253
- }));
1254
- const operations = [
1255
- ...bindingOperations.filter((operation) => operation.action === "verify-immutable-artifact-before-upload"),
1256
- ...bindingOperations.filter((operation) => operation.action === "sync-immutable-artifact"),
1257
- ...bindingOperations.filter((operation) => operation.action === "verify-immutable-artifact-after-upload"),
1258
- ...cloudFrontDirectoryIndexRewriteOperations(bindings.filter((binding) => !binding.publicationFastPath)),
1259
- ...bindingOperations.filter((operation) => ![
1260
- "verify-immutable-artifact-before-upload",
1261
- "sync-immutable-artifact",
1262
- "verify-immutable-artifact-after-upload",
1263
- ].includes(operation.action)),
1264
- ];
1265
- const primaryBinding = bindings[0] || {};
1266
- const objectPrefix = primaryBinding.objectPrefix || objectPrefixFor(deployConfig, resolvedPlan.manifest.alias || resolvedPlan.manifest.channel);
1267
- const manifestKey = primaryBinding.manifestKey || deployManifestKey(deployConfig, resolvedPlan.manifest);
1268
- const invalidationPaths = bindings.flatMap((binding) =>
1269
- binding.publicationFastPath
1270
- ? [...binding.publicationFastPath.invalidationPaths, cdnPath(binding.manifestKey)]
1271
- : [viewerWildcardPath(binding), cdnPath(binding.manifestKey)]);
1272
- const operationResults = runAdapterOperations({ operations, dryRun, commandRunner });
1273
- const immutablePreservation = bindings
1274
- .filter((binding) => binding.immutablePublication)
1275
- .map((binding) => {
1276
- const relevant = operationResults.filter((operation) =>
1277
- operation.surface === binding.surface &&
1278
- [
1279
- "verify-immutable-artifact-before-upload",
1280
- "sync-immutable-artifact",
1281
- "verify-immutable-artifact-after-upload",
1282
- "sync-static-artifact",
1283
- "sync-publication-fast-path",
1284
- ].includes(operation.action),
1285
- );
1286
- const expectedOperationCount = (binding.immutablePublication.files.length * 2) +
1287
- binding.immutablePublication.uploadRoots.length +
1288
- (binding.publicationFastPath ? binding.publicationFastPath.mutableFiles.length : 1);
1289
- const complete = relevant.length === expectedOperationCount;
1290
- return {
1291
- surface: binding.surface,
1292
- manifestPath: binding.immutablePublication.manifestPath,
1293
- preservedRoots: binding.immutablePublication.preservedRoots,
1294
- declaredPrefixes: binding.immutablePublication.declaredPrefixes,
1295
- fileCount: binding.immutablePublication.files.length,
1296
- mutableDeleteExcludes: binding.mutableDeleteExcludes || [],
1297
- coveringBindings: binding.immutablePublication.coveringBindings,
1298
- status: !complete || relevant.some((operation) => operation.status === "failed")
1299
- ? "failed"
1300
- : dryRun ? "planned" : "applied",
1301
- };
1302
- });
1303
- return {
1304
- schemaVersion: 1,
1305
- contract: "kungfu-buildchain-web-surface-deploy-apply",
1306
- dryRun,
1307
- applyMode: dryRun ? "dry-run" : "apply",
1308
- status: appliedStatus({ dryRun, operations: operationResults }),
1309
- actor,
1310
- runId,
1311
- appliedAt,
1312
- channel: resolvedPlan.channel,
1313
- alias: resolvedPlan.alias,
1314
- url: resolvedPlan.url,
1315
- urls: resolvedPlan.urls || Object.fromEntries(bindings.map((binding) => [binding.surface, binding.url])),
1316
- sourceSha: resolvedPlan.manifest.sourceSha,
1317
- artifactHash: resolvedPlan.artifact.hash,
1318
- adapter: resolvedPlan.adapter,
1319
- target: bucket,
1320
- objectPrefix,
1321
- manifestKey,
1322
- invalidationPaths,
1323
- publicationFastPath: resolvedPlan.publicationFastPath || resolvedPlan.manifest.publicationFastPath,
1324
- manifest: resolvedPlan.manifest,
1325
- surfaceBindings: bindings,
1326
- immutablePreservation,
1327
- operations: operationResults,
1328
- };
1329
- }
1330
-
1331
- export async function preflightWebSurfaceProduction({
1332
- cwd = process.cwd(),
1333
- plan = null,
1334
- execute = false,
1335
- commandRunner = defaultCommandRunner,
1336
- dnsResolver = defaultDnsResolver,
1337
- checkedAt = new Date().toISOString(),
1338
- } = {}) {
1339
- const resolvedPlan = plan ? assertDeployPlan(plan) : planWebSurfaceDeploy({
1340
- cwd,
1341
- channel: "production",
1342
- sourceSha: "0".repeat(40),
1343
- artifactHash: "0".repeat(64),
1344
- dryRun: true,
1345
- deployedAt: checkedAt,
1346
- });
1347
- if (resolvedPlan.channel !== "production") {
1348
- throw new Error("web-surface production preflight requires a production deploy plan");
1349
- }
1350
- const loadedConfig = loadBuildchainConfig(cwd);
1351
- const config = assertWebSurfaceConfig(loadedConfig);
1352
- const channel = config.channels?.production || {};
1353
- const deployConfig = config.deploy?.production;
1354
- if (!deployConfig) {
1355
- throw new Error("missing deploy.production");
1356
- }
1357
- const checks = [];
1358
- const configuredProductionBindings = resolveSurfaceBindings({
1359
- config,
1360
- channelName: "production",
1361
- alias: "",
1362
- deployConfig,
1363
- });
1364
- const bindings = resolvedPlan.manifest?.surfaceBindings || resolveSurfaceBindings({
1365
- config,
1366
- channelName: "production",
1367
- alias: "",
1368
- deployConfig,
1369
- });
1370
-
1371
- checks.push(preflightCheck({
1372
- name: "production-channel",
1373
- status: channel.canonical === true && channel.noindex === false ? "pass" : "fail",
1374
- details: {
1375
- canonical: channel.canonical,
1376
- noindex: channel.noindex,
1377
- },
1378
- message: channel.canonical === true && channel.noindex === false
1379
- ? "production channel is canonical and indexable"
1380
- : "channels.production must be canonical=true and noindex=false",
1381
- }));
1382
-
1383
- const configuredSurfaceNames = configuredProductionBindings.map((binding) => binding.surface).sort();
1384
- const plannedSurfaceNames = bindings.map((binding) => binding.surface).sort();
1385
- const missingSurfaces = configuredSurfaceNames.filter((surface) => !plannedSurfaceNames.includes(surface));
1386
- const extraSurfaces = plannedSurfaceNames.filter((surface) => !configuredSurfaceNames.includes(surface));
1387
- checks.push(preflightCheck({
1388
- name: "production-surface-set",
1389
- status: missingSurfaces.length === 0 && extraSurfaces.length === 0 ? "pass" : "fail",
1390
- details: {
1391
- configured: configuredSurfaceNames,
1392
- planned: plannedSurfaceNames,
1393
- missing: missingSurfaces,
1394
- extra: extraSurfaces,
1395
- },
1396
- message: missingSurfaces.length === 0 && extraSurfaces.length === 0
1397
- ? "production plan covers every configured surface"
1398
- : `production plan surface mismatch: missing=${missingSurfaces.join(",") || "-"} extra=${extraSurfaces.join(",") || "-"}`,
1399
- }));
1400
-
1401
- const concreteFailures = [];
1402
- for (const binding of bindings) {
1403
- const effectiveDeploy = surfaceDeployConfig(deployConfig, binding.surface);
1404
- try {
1405
- assertConcreteAwsDeployConfig({
1406
- deployConfig: effectiveDeploy,
1407
- channel: `production.surfaces.${binding.surface}`,
1408
- operation: "deploy",
1409
- });
1410
- } catch (error) {
1411
- concreteFailures.push(String(error.message || error));
1412
- }
1413
- }
1414
- checks.push(preflightCheck({
1415
- name: "production-targets",
1416
- status: concreteFailures.length === 0 ? "pass" : "fail",
1417
- details: {
1418
- bindings: bindings.map((binding) => ({
1419
- surface: binding.surface,
1420
- bucket: binding.bucket,
1421
- distributionId: binding.distributionId,
1422
- objectPrefix: binding.objectPrefix,
1423
- manifestKey: binding.manifestKey,
1424
- })),
1425
- failures: concreteFailures,
1426
- },
1427
- message: concreteFailures.length === 0
1428
- ? "production bucket and CloudFront distribution values are concrete"
1429
- : concreteFailures.join("; "),
1430
- }));
1431
-
1432
- const hosts = bindings.map((binding) => ({
1433
- surface: binding.surface,
1434
- url: binding.url,
1435
- host: urlHost(binding.url),
1436
- distributionId: binding.distributionId,
1437
- }));
1438
- const invalidHosts = hosts.filter((entry) => !entry.host || !entry.url.startsWith("https://"));
1439
- checks.push(preflightCheck({
1440
- name: "production-surface-hosts",
1441
- status: invalidHosts.length === 0 ? "pass" : "fail",
1442
- details: { hosts, invalidHosts },
1443
- message: invalidHosts.length === 0
1444
- ? "all production surfaces declare HTTPS hosts"
1445
- : `invalid production surface hosts: ${invalidHosts.map((entry) => entry.surface).join(", ")}`,
1446
- }));
1447
-
1448
- const awsResults = [];
1449
- if (execute) {
1450
- const checkedBuckets = new Set();
1451
- for (const binding of bindings) {
1452
- const effectiveDeploy = surfaceDeployConfig(deployConfig, binding.surface);
1453
- const bucket = binding.bucket || effectiveDeploy.bucket || effectiveDeploy.target || "";
1454
- if (bucket && !checkedBuckets.has(bucket)) {
1455
- checkedBuckets.add(bucket);
1456
- const operation = {
1457
- action: "preflight-head-bucket",
1458
- surface: binding.surface,
1459
- command: "aws",
1460
- args: ["s3api", "head-bucket", "--bucket", bucket],
1461
- };
1462
- awsResults.push(runAdapterOperation({ operation, dryRun: false, commandRunner }));
1463
- }
1464
- }
1465
-
1466
- const checkedDistributions = new Set();
1467
- for (const binding of bindings) {
1468
- const distributionId = binding.distributionId || "";
1469
- if (distributionId && !checkedDistributions.has(distributionId)) {
1470
- checkedDistributions.add(distributionId);
1471
- const operation = {
1472
- action: "preflight-get-distribution",
1473
- surface: binding.surface,
1474
- command: "aws",
1475
- args: ["cloudfront", "get-distribution", "--id", distributionId, "--output", "json"],
1476
- };
1477
- awsResults.push(runAdapterOperation({ operation, dryRun: false, commandRunner }));
1478
- }
1479
- }
1480
- }
1481
-
1482
- const failedAws = awsResults.filter((result) => result.status === "failed");
1483
- checks.push(preflightCheck({
1484
- name: "production-aws-access",
1485
- status: !execute || failedAws.length === 0 ? "pass" : "fail",
1486
- details: {
1487
- execute,
1488
- operations: awsResults.map((result) => ({
1489
- action: result.action,
1490
- surface: result.surface,
1491
- status: result.status,
1492
- stderr: result.stderr,
1493
- })),
1494
- },
1495
- message: !execute
1496
- ? "AWS access check planned but not executed"
1497
- : failedAws.length === 0
1498
- ? "production role can inspect buckets and CloudFront distributions"
1499
- : `production AWS access failed: ${failedAws.map((result) => `${result.action}:${result.surface}`).join(", ")}`,
1500
- }));
1501
-
1502
- const aliasChecks = [];
1503
- if (execute) {
1504
- const aliasesByDistribution = new Map();
1505
- for (const result of awsResults.filter((entry) => entry.action === "preflight-get-distribution" && entry.status !== "failed")) {
1506
- const aliases = parseCloudFrontAliases(result.stdout);
1507
- aliasesByDistribution.set(result.args[result.args.indexOf("--id") + 1], aliases);
1508
- }
1509
- for (const host of hosts) {
1510
- const aliases = aliasesByDistribution.get(host.distributionId) || [];
1511
- aliasChecks.push({
1512
- ...host,
1513
- aliases,
1514
- matched: aliasMatchesHost(aliases, host.host),
1515
- });
1516
- }
1517
- }
1518
- const missingAliases = aliasChecks.filter((entry) => !entry.matched);
1519
- checks.push(preflightCheck({
1520
- name: "production-cloudfront-aliases",
1521
- status: !execute || missingAliases.length === 0 ? "pass" : "fail",
1522
- details: {
1523
- execute,
1524
- aliases: aliasChecks,
1525
- },
1526
- message: !execute
1527
- ? "CloudFront alias check planned but not executed"
1528
- : missingAliases.length === 0
1529
- ? "production CloudFront aliases cover every surface host"
1530
- : `missing CloudFront aliases: ${missingAliases.map((entry) => entry.host).join(", ")}`,
1531
- }));
1532
-
1533
- const dnsChecks = [];
1534
- if (execute) {
1535
- for (const host of hosts) {
1536
- try {
1537
- const answers = await dnsResolver(host.host);
1538
- dnsChecks.push({ ...host, status: "pass", answers });
1539
- } catch (error) {
1540
- dnsChecks.push({ ...host, status: "fail", error: String(error.message || error) });
1541
- }
1542
- }
1543
- }
1544
- const failedDns = dnsChecks.filter((entry) => entry.status === "fail");
1545
- checks.push(preflightCheck({
1546
- name: "production-dns",
1547
- status: !execute || failedDns.length === 0 ? "pass" : "fail",
1548
- details: {
1549
- execute,
1550
- hosts: dnsChecks,
1551
- },
1552
- message: !execute
1553
- ? "DNS check planned but not executed"
1554
- : failedDns.length === 0
1555
- ? "production DNS resolves for every surface host"
1556
- : `production DNS failed: ${failedDns.map((entry) => entry.host).join(", ")}`,
1557
- }));
1558
-
1559
- return {
1560
- schemaVersion: 1,
1561
- contract: "kungfu-buildchain-web-surface-production-preflight",
1562
- checkedAt,
1563
- execute,
1564
- channel: "production",
1565
- status: preflightStatus(checks),
1566
- url: resolvedPlan.url,
1567
- urls: resolvedPlan.urls,
1568
- sourceSha: resolvedPlan.manifest.sourceSha,
1569
- artifactHash: resolvedPlan.artifact.hash,
1570
- surfaceBindings: bindings,
1571
- checks,
1572
- };
1573
- }
1574
-
1575
- function healthStatus(checks) {
1576
- return checks.some((check) => check.status === "fail") ? "failed" : "passed";
1577
- }
1578
-
1579
- function noindexHeader(headers) {
1580
- const value = headers?.get?.("x-robots-tag") || "";
1581
- return String(value).toLowerCase().includes("noindex");
1582
- }
1583
-
1584
- function noindexMeta(html = "") {
1585
- const source = String(html || "").toLowerCase();
1586
- return /<meta\s+[^>]*name=["']robots["'][^>]*content=["'][^"']*noindex/.test(source) ||
1587
- /<meta\s+[^>]*content=["'][^"']*noindex[^"']*["'][^>]*name=["']robots["']/.test(source);
1588
- }
1589
-
1590
- function htmlLikeResponse(response, url = "") {
1591
- const contentType = response.headers?.get?.("content-type") || "";
1592
- return String(contentType).toLowerCase().includes("text/html") || /\/$|\.html(?:$|[?#])/.test(String(url || ""));
1593
- }
1594
-
1595
- function operationEvidenceStatus(operation, { plannedEvidence = false } = {}) {
1596
- if (plannedEvidence && operation.status === undefined) {
1597
- return true;
1598
- }
1599
- return operation.status === "applied" || operation.status === "planned";
1600
- }
1601
-
1602
- function managedNetworkHealthEvidence({ target, result, plan }) {
1603
- const requiredActions = [
1604
- target.publicationFastPath
1605
- ? "sync-publication-fast-path"
1606
- : "sync-static-artifact",
1607
- "write-deployment-manifest",
1608
- ];
1609
- const operationSource = Array.isArray(result?.operations) && result.operations.length > 0
1610
- ? "apply-result"
1611
- : "deploy-plan";
1612
- const operations = operationSource === "apply-result"
1613
- ? result.operations
1614
- : (Array.isArray(plan?.steps) ? plan.steps : []);
1615
- const surfaceOperations = operations.filter((operation) => operation.surface === target.surface);
1616
- const presentActions = new Set(
1617
- surfaceOperations
1618
- .filter((operation) => operationEvidenceStatus(operation, { plannedEvidence: operationSource === "deploy-plan" }))
1619
- .map((operation) => operation.action),
1620
- );
1621
- const missingActions = requiredActions.filter((action) => !presentActions.has(action));
1622
- const missingFields = [];
1623
- if (!target.manifestKey) missingFields.push("manifestKey");
1624
- if (!target.bucket) missingFields.push("bucket");
1625
- if (target.objectPrefix === undefined || target.objectPrefix === null) missingFields.push("objectPrefix");
1626
- return {
1627
- source: operationSource,
1628
- actions: [...presentActions].sort(),
1629
- requiredActions,
1630
- missingActions,
1631
- missingFields,
1632
- status: missingActions.length === 0 && missingFields.length === 0 ? "pass" : "fail",
1633
- };
1634
- }
1635
-
1636
- function managedNetworkTargetObjectKey(target) {
1637
- const requestPath = String(target.requestPath || "/");
1638
- let relative = requestPath.replace(/^\/+/, "");
1639
- if (!relative) {
1640
- relative = "index.html";
1641
- } else if (requestPath.endsWith("/")) {
1642
- relative = `${relative.replace(/\/+$/, "")}/index.html`;
1643
- }
1644
- return joinS3Key(target.objectPrefix, relative);
1645
- }
1646
-
1647
- function managedNetworkHeadObject({ target, kind, key, commandRunner }) {
1648
- return runAdapterOperation({
1649
- operation: {
1650
- action: `health-head-${kind}`,
1651
- surface: target.surface,
1652
- command: "aws",
1653
- args: ["s3api", "head-object", "--bucket", target.bucket, "--key", key],
1654
- },
1655
- dryRun: false,
1656
- commandRunner,
1657
- });
1658
- }
1659
-
1660
- function managedNetworkS3HealthCheck({ target, evidence, commandRunner }) {
1661
- const objectKey = managedNetworkTargetObjectKey(target);
1662
- const headResults = [
1663
- managedNetworkHeadObject({ target, kind: "manifest", key: target.manifestKey, commandRunner }),
1664
- managedNetworkHeadObject({ target, kind: "object", key: objectKey, commandRunner }),
1665
- ];
1666
- const failed = headResults.filter((operation) => operation.status === "failed");
1667
- return {
1668
- surface: target.surface,
1669
- kind: target.kind,
1670
- requestPath: target.requestPath,
1671
- url: target.url,
1672
- accessControl: target.accessControl || "",
1673
- healthStrategy: "s3-object",
1674
- status: evidence.status === "pass" && failed.length === 0 ? "pass" : "fail",
1675
- httpStatus: null,
1676
- finalUrl: "",
1677
- noindexHeader: false,
1678
- manifestKey: target.manifestKey || "",
1679
- bucket: target.bucket || "",
1680
- objectPrefix: target.objectPrefix || "",
1681
- objectKey,
1682
- evidence,
1683
- s3Checks: headResults.map((operation) => ({
1684
- action: operation.action,
1685
- bucket: target.bucket,
1686
- key: operation.args?.[operation.args.indexOf("--key") + 1] || "",
1687
- status: operation.status,
1688
- exitCode: operation.exitCode,
1689
- stderr: operation.stderr || "",
1690
- })),
1691
- message: evidence.status === "pass" && failed.length === 0
1692
- ? "surface health verified from S3 manifest and object head checks; direct public fetch skipped"
1693
- : `S3 object health failed: ${failed.map((operation) => `${operation.action}:${operation.stderr || operation.exitCode}`).join("; ") || "missing deployment evidence"}`,
1694
- };
1695
- }
1696
-
1697
- function managedNetworkHealthCheck({ target, result, plan, commandRunner, verifyS3Objects = true }) {
1698
- const evidence = managedNetworkHealthEvidence({ target, result, plan });
1699
- if (verifyS3Objects && result?.status === "applied" && evidence.status === "pass") {
1700
- return managedNetworkS3HealthCheck({ target, evidence, commandRunner });
1701
- }
1702
- return {
1703
- surface: target.surface,
1704
- kind: target.kind,
1705
- requestPath: target.requestPath,
1706
- url: target.url,
1707
- accessControl: target.accessControl || "",
1708
- healthStrategy: "deployment-evidence",
1709
- status: evidence.status,
1710
- httpStatus: null,
1711
- finalUrl: "",
1712
- noindexHeader: false,
1713
- manifestKey: target.manifestKey || "",
1714
- bucket: target.bucket || "",
1715
- objectPrefix: target.objectPrefix || "",
1716
- evidence,
1717
- message: evidence.status === "pass"
1718
- ? "managed-network surface health verified from deployment manifest and S3 object sync evidence; direct public fetch skipped"
1719
- : `managed-network surface health requires manifest and S3 object evidence; missing actions=${evidence.missingActions.join(",") || "none"}, missing fields=${evidence.missingFields.join(",") || "none"}`,
1720
- };
1721
- }
1722
-
1723
- async function fetchWithRetry(url, {
1724
- fetchImpl,
1725
- attempts = 3,
1726
- intervalMs = 5000,
1727
- shouldRetry = () => false,
1728
- } = {}) {
1729
- const maxAttempts = Math.max(1, Number(attempts) || 1);
1730
- let lastError = null;
1731
- for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
1732
- try {
1733
- const response = await fetchImpl(url, { redirect: "follow" });
1734
- if (attempt >= maxAttempts || !shouldRetry(response)) {
1735
- return { response, attempts: attempt };
1736
- }
1737
- } catch (error) {
1738
- lastError = error;
1739
- if (attempt >= maxAttempts) {
1740
- throw Object.assign(error, { attempts: attempt });
1741
- }
1742
- }
1743
- if (intervalMs > 0) {
1744
- await sleep(intervalMs);
1745
- }
1746
- }
1747
- throw Object.assign(lastError || new Error("web-surface fetch retry exhausted"), { attempts: maxAttempts });
1748
- }
1749
-
1750
- function retryableHealthResponse(response) {
1751
- return response.status === 403 || response.status === 404 || response.status >= 500;
1752
- }
1753
-
1754
- const DEFAULT_HEALTH_HTTP_RETRY_ATTEMPTS = 12;
1755
- const DEFAULT_HEALTH_HTTP_RETRY_INTERVAL_MS = 10000;
1756
-
1757
- export async function checkWebSurfaceHealth({
1758
- result = null,
1759
- plan = null,
1760
- cwd = process.cwd(),
1761
- fetchImpl = fetch,
1762
- checkedAt = new Date().toISOString(),
1763
- allowedStatuses = [200],
1764
- allowedManagedNetworkRunner = false,
1765
- managedNetworkS3ObjectVerification = true,
1766
- commandRunner = defaultCommandRunner,
1767
- httpRetryAttempts = Number(process.env.BUILDCHAIN_WEB_SURFACE_HEALTH_HTTP_RETRY_ATTEMPTS || DEFAULT_HEALTH_HTTP_RETRY_ATTEMPTS),
1768
- httpRetryIntervalMs = Number(process.env.BUILDCHAIN_WEB_SURFACE_HEALTH_HTTP_RETRY_INTERVAL_MS || DEFAULT_HEALTH_HTTP_RETRY_INTERVAL_MS),
1769
- } = {}) {
1770
- const loadedConfig = loadBuildchainConfig(cwd);
1771
- const config = assertWebSurfaceConfig(loadedConfig);
1772
- const manifest = result?.manifest || plan?.manifest;
1773
- const channel = result?.channel || plan?.channel || manifest?.channel || "production";
1774
- const urls = result?.urls || plan?.urls || (manifest?.surfaceBindings
1775
- ? Object.fromEntries(manifest.surfaceBindings.map((binding) => [binding.surface, binding.url]))
1776
- : {});
1777
- const bindings = manifest?.surfaceBindings || [];
1778
- const checks = [];
1779
- if (Object.keys(urls).length === 0) {
1780
- checks.push({
1781
- surface: "__urls__",
1782
- url: "",
1783
- status: "fail",
1784
- httpStatus: 0,
1785
- finalUrl: "",
1786
- noindexHeader: false,
1787
- message: "web-surface health check requires at least one surface URL from an apply result or deploy plan",
1788
- });
1789
- }
1790
-
1791
- const smokeTargets = bindings.length > 0
1792
- ? bindings.flatMap((binding) => {
1793
- const smokeUrls = Array.isArray(binding.smokeUrls) && binding.smokeUrls.length > 0
1794
- ? binding.smokeUrls
1795
- : [{ kind: "root", requestPath: "/", url: binding.url || urls[binding.surface] || "", required: true }];
1796
- return smokeUrls.map((smoke) => ({
1797
- surface: binding.surface,
1798
- kind: smoke.kind || "root",
1799
- requestPath: smoke.requestPath || "",
1800
- url: smoke.url || "",
1801
- required: smoke.required !== false,
1802
- missing: Boolean(smoke.missing),
1803
- message: smoke.message || "",
1804
- accessControl: binding.accessControl || config.channels?.[channel]?.accessControl || "",
1805
- healthStrategy: binding.healthStrategy || "",
1806
- manifestKey: binding.manifestKey || "",
1807
- bucket: binding.bucket || "",
1808
- objectPrefix: binding.objectPrefix || "",
1809
- publicationFastPath: binding.publicationFastPath || null,
1810
- }));
1811
- })
1812
- : Object.entries(urls).map(([surface, url]) => ({
1813
- surface,
1814
- kind: "root",
1815
- requestPath: "/",
1816
- url,
1817
- required: true,
1818
- accessControl: config.channels?.[channel]?.accessControl || "",
1819
- healthStrategy: "",
1820
- }));
1821
-
1822
- for (const target of smokeTargets) {
1823
- const { surface, url } = target;
1824
- if (!url || target.missing) {
1825
- checks.push({
1826
- surface,
1827
- kind: target.kind,
1828
- requestPath: target.requestPath,
1829
- url: url || "",
1830
- status: "fail",
1831
- httpStatus: 0,
1832
- finalUrl: "",
1833
- noindexHeader: false,
1834
- message: target.message || "web-surface smoke URL is missing",
1835
- });
1836
- continue;
1837
- }
1838
- if (target.healthStrategy === "s3-object") {
1839
- checks.push(managedNetworkHealthCheck({
1840
- target,
1841
- result,
1842
- plan,
1843
- commandRunner,
1844
- verifyS3Objects: managedNetworkS3ObjectVerification,
1845
- }));
1846
- continue;
1847
- }
1848
- if (target.accessControl === "managed-network" && !allowedManagedNetworkRunner) {
1849
- checks.push(managedNetworkHealthCheck({
1850
- target,
1851
- result,
1852
- plan,
1853
- commandRunner,
1854
- verifyS3Objects: managedNetworkS3ObjectVerification,
1855
- }));
1856
- continue;
1857
- }
1858
- try {
1859
- const { response, attempts } = await fetchWithRetry(url, {
1860
- fetchImpl,
1861
- attempts: httpRetryAttempts,
1862
- intervalMs: httpRetryIntervalMs,
1863
- shouldRetry: retryableHealthResponse,
1864
- });
1865
- const expectedNoindex = Boolean(config.channels?.[channel]?.noindex);
1866
- const headerNoindex = noindexHeader(response.headers);
1867
- const body = htmlLikeResponse(response, url) && typeof response.text === "function"
1868
- ? await response.text()
1869
- : "";
1870
- const metaNoindex = noindexMeta(body);
1871
- const noindex = headerNoindex || metaNoindex;
1872
- const statusOk = allowedStatuses.includes(response.status);
1873
- const noindexOk = channel !== "production" || expectedNoindex || !noindex;
1874
- checks.push({
1875
- surface,
1876
- kind: target.kind,
1877
- requestPath: target.requestPath,
1878
- url,
1879
- accessControl: target.accessControl || "",
1880
- healthStrategy: "http",
1881
- status: statusOk && noindexOk ? "pass" : "fail",
1882
- httpStatus: response.status,
1883
- attempts,
1884
- finalUrl: response.url || url,
1885
- noindexHeader: noindex,
1886
- noindexHeaderValue: headerNoindex,
1887
- noindexMeta: metaNoindex,
1888
- message: statusOk && noindexOk
1889
- ? "surface is reachable"
1890
- : `surface health failed: http=${response.status}, noindex=${noindex}`,
1891
- });
1892
- } catch (error) {
1893
- checks.push({
1894
- surface,
1895
- kind: target.kind,
1896
- requestPath: target.requestPath,
1897
- url,
1898
- status: "fail",
1899
- httpStatus: 0,
1900
- attempts: error.attempts || 1,
1901
- finalUrl: "",
1902
- noindexHeader: false,
1903
- message: String(error.message || error),
1904
- });
1905
- }
1906
- }
1907
-
1908
- const immutableBindings = bindings.filter((binding) => binding.immutablePublication);
1909
- if (immutableBindings.length > 0) {
1910
- const operationSource = Array.isArray(result?.operations) && result.operations.length > 0
1911
- ? result.operations
1912
- : (Array.isArray(plan?.steps) ? plan.steps : []);
1913
- const preservationBindings = immutableBindings.map((binding) => {
1914
- const requiredActions = [
1915
- "verify-immutable-artifact-before-upload",
1916
- "sync-immutable-artifact",
1917
- "verify-immutable-artifact-after-upload",
1918
- binding.publicationFastPath
1919
- ? "sync-publication-fast-path"
1920
- : "sync-static-artifact",
1921
- ];
1922
- const actions = new Set(operationSource
1923
- .filter((operation) => operation.surface === binding.surface)
1924
- .filter((operation) => operationEvidenceStatus(operation, { plannedEvidence: !result }))
1925
- .map((operation) => operation.action));
1926
- const missingActions = requiredActions.filter((action) => !actions.has(action));
1927
- const coveringBindings = binding.publicationFastPath
1928
- ? []
1929
- : (binding.immutablePublication.coveringBindings || []).map((covering) => {
1930
- const sync = operationSource.find((operation) =>
1931
- operation.surface === covering.surface &&
1932
- operation.action === "sync-static-artifact" &&
1933
- operationEvidenceStatus(operation, { plannedEvidence: !result }),
1934
- );
1935
- const actualExcludes = sync?.preservation?.mutableDeleteExcludes || sync?.deleteExcludes || [];
1936
- return {
1937
- ...covering,
1938
- status: sync && covering.mutableDeleteExcludes.every((pattern) => actualExcludes.includes(pattern))
1939
- ? "pass"
1940
- : "fail",
1941
- };
1942
- });
1943
- return {
1944
- surface: binding.surface,
1945
- manifestPath: binding.immutablePublication.manifestPath,
1946
- preservedRoots: binding.immutablePublication.preservedRoots,
1947
- declaredPrefixes: binding.immutablePublication.declaredPrefixes,
1948
- fileCount: binding.immutablePublication.files.length,
1949
- mutableDeleteExcludes: binding.mutableDeleteExcludes || [],
1950
- coveringBindings,
1951
- actions: [...actions].sort(),
1952
- requiredActions,
1953
- missingActions,
1954
- status: missingActions.length === 0 && coveringBindings.every((covering) => covering.status === "pass")
1955
- ? "pass"
1956
- : "fail",
1957
- };
1958
- });
1959
- checks.push({
1960
- surface: "__immutable__",
1961
- url: "",
1962
- status: preservationBindings.every((binding) => binding.status === "pass") ? "pass" : "fail",
1963
- bindings: preservationBindings,
1964
- message: preservationBindings.every((binding) => binding.status === "pass")
1965
- ? "immutable publication roots were excluded from mutable deletion and verified around no-overwrite upload"
1966
- : "immutable publication preservation evidence is incomplete",
1967
- });
1968
- }
1969
-
1970
- const installerPublication = manifest?.installerPublicationEvidence;
1971
- const managedInstallerSurface =
1972
- config.channels?.[channel]?.accessControl === "managed-network" &&
1973
- !allowedManagedNetworkRunner;
1974
- if (installerPublication && !managedInstallerSurface) {
1975
- try {
1976
- const publicBase = new URL(urls.hub || manifest?.url || Object.values(urls)[0]);
1977
- const projected = {
1978
- ...installerPublication,
1979
- assets: installerPublication.assets.map((asset) => ({
1980
- ...asset,
1981
- friendlyUrl: new URL(new URL(asset.friendlyUrl).pathname, publicBase).href,
1982
- immutableUrl: new URL(new URL(asset.immutableUrl).pathname, publicBase).href,
1983
- })),
1984
- };
1985
- const evidence = await verifyInstallerPublicReadback({
1986
- publication: projected,
1987
- fetchImpl,
1988
- });
1989
- checks.push({
1990
- surface: "__installer__",
1991
- url: publicBase.href,
1992
- status: "pass",
1993
- evidence,
1994
- message: "friendly and immutable installer routes match signed publication bytes and cache policy",
1995
- });
1996
- } catch (error) {
1997
- checks.push({
1998
- surface: "__installer__",
1999
- url: urls.hub || manifest?.url || "",
2000
- status: "fail",
2001
- message: String(error.message || error),
2002
- });
2003
- }
2004
- }
2005
-
2006
- const manifestChecks = bindings.map((binding) => ({
2007
- surface: binding.surface,
2008
- manifestKey: binding.manifestKey,
2009
- bucket: binding.bucket,
2010
- distributionId: binding.distributionId,
2011
- status: binding.manifestKey ? "pass" : "fail",
2012
- }));
2013
- checks.push({
2014
- surface: "__manifest__",
2015
- url: "",
2016
- status: manifestChecks.length > 0 && manifestChecks.every((entry) => entry.status === "pass") ? "pass" : "fail",
2017
- manifests: manifestChecks,
2018
- message: "deployment manifest pointers are recorded for every surface",
2019
- });
2020
-
2021
- return {
2022
- schemaVersion: 1,
2023
- contract: "kungfu-buildchain-web-surface-health-check",
2024
- checkedAt,
2025
- channel,
2026
- status: healthStatus(checks),
2027
- sourceSha: manifest?.sourceSha || result?.sourceSha || "",
2028
- artifactHash: manifest?.artifactHash || result?.artifactHash || "",
2029
- urls,
2030
- checks,
2031
- };
2032
- }
2033
-
2034
- function deployBindingOperations({ artifactRoot, deployConfig, manifest, binding }) {
2035
- const effectiveDeploy = surfaceDeployConfig(deployConfig, binding.surface);
2036
- const bucket = binding.bucket || effectiveDeploy.bucket || effectiveDeploy.target || "";
2037
- const distribution = binding.distributionId || effectiveDeploy.cloudfront_distribution || effectiveDeploy.distribution || "";
2038
- const surfaceArtifactRoot = surfaceArtifactRootFor({ artifactRoot, binding });
2039
- const immutable = binding.immutablePublication;
2040
- const installer = manifest.installerPublicationEvidence;
2041
- const installerRoot = installer?.immutablePath || "";
2042
- const ownsArtifactRoot = normalizeS3Key(
2043
- binding.artifactPathPrefix || surfaceArtifactPrefix(binding),
2044
- ) === "";
2045
- const ownsInstallerAssets = installer?.assets?.every((asset) =>
2046
- fs.existsSync(path.join(surfaceArtifactRoot, asset.friendly.path)));
2047
- const installerBinding =
2048
- installer &&
2049
- ownsArtifactRoot &&
2050
- ownsInstallerAssets &&
2051
- immutable?.declaredPrefixes?.includes(installer.immutablePath)
2052
- ? installer
2053
- : null;
2054
- const immutableVerifier = path.join(moduleDir, "web-surface-immutable-object.mjs");
2055
- const verifyImmutable = (phase) => (immutable?.files || []).map((file) => ({
2056
- action: `verify-immutable-artifact-${phase}`,
2057
- surface: binding.surface,
2058
- command: "node",
2059
- args: [
2060
- immutableVerifier,
2061
- "--bucket",
2062
- bucket,
2063
- "--key",
2064
- joinS3Key(binding.objectPrefix, file.path),
2065
- "--sha256",
2066
- file.sha256,
2067
- ],
2068
- immutable: {
2069
- phase,
2070
- path: file.path,
2071
- sha256: file.sha256,
2072
- },
2073
- }));
2074
- const syncImmutable = (immutable?.uploadRoots || immutable?.preservedRoots || []).map((root) => {
2075
- const isInstallerRoot = Boolean(installerBinding && root === installerRoot);
2076
- const immutableMetadataArgs = isInstallerRoot
2077
- ? [
2078
- "--content-type",
2079
- "application/octet-stream",
2080
- "--cache-control",
2081
- "public,max-age=31536000,immutable",
2082
- ]
2083
- : binding.cacheControl?.immutable
2084
- ? ["--cache-control", binding.cacheControl.immutable]
2085
- : [];
2086
- return {
2087
- action: "sync-immutable-artifact",
2088
- surface: binding.surface,
2089
- command: "aws",
2090
- args: [
2091
- "s3",
2092
- "sync",
2093
- path.join(surfaceArtifactRoot, root),
2094
- s3Uri(bucket, joinS3Key(binding.objectPrefix, root)),
2095
- "--no-overwrite",
2096
- "--checksum-algorithm",
2097
- "SHA256",
2098
- ...immutableMetadataArgs,
2099
- ],
2100
- immutable: {
2101
- preservedRoot: root,
2102
- overwrite: false,
2103
- cacheControl: isInstallerRoot
2104
- ? "public,max-age=31536000,immutable"
2105
- : binding.cacheControl?.immutable,
2106
- },
2107
- };
2108
- });
2109
- const publishFriendlyInstallers = (installerBinding?.assets || []).map((asset) => ({
2110
- action: "publish-friendly-installer",
2111
- surface: binding.surface,
2112
- command: "aws",
2113
- args: [
2114
- "s3",
2115
- "cp",
2116
- path.join(surfaceArtifactRoot, asset.friendly.path),
2117
- s3Uri(bucket, joinS3Key(binding.objectPrefix, asset.friendly.path)),
2118
- "--content-type",
2119
- asset.contentType,
2120
- "--cache-control",
2121
- "public,max-age=300,must-revalidate",
2122
- ],
2123
- installer: {
2124
- name: asset.name,
2125
- digest: asset.digest,
2126
- cacheControl: "public,max-age=300,must-revalidate",
2127
- },
2128
- }));
2129
- const fastPathMutable = (binding.publicationFastPath?.mutableFiles || []).map((file) => ({
2130
- action: "sync-publication-fast-path",
2131
- surface: binding.surface,
2132
- command: "aws",
2133
- args: [
2134
- "s3",
2135
- "cp",
2136
- path.join(surfaceArtifactRoot, file),
2137
- s3Uri(bucket, joinS3Key(binding.objectPrefix, file)),
2138
- "--checksum-algorithm",
2139
- "SHA256",
2140
- ],
2141
- publicationFastPath: {
2142
- qualificationRoot: binding.publicationFastPath.qualificationRoot,
2143
- path: file,
2144
- overwriteBoundary: "declared-mutable-file-only",
2145
- },
2146
- }));
2147
- const mutableSync = binding.publicationFastPath
2148
- ? fastPathMutable
2149
- : [
2150
- {
2151
- action: "sync-static-artifact",
2152
- surface: binding.surface,
2153
- command: "aws",
2154
- args: syncStaticArtifactArgs({
2155
- artifactRoot: surfaceArtifactRoot,
2156
- bucket,
2157
- objectPrefix: binding.objectPrefix,
2158
- deleteExcludes: binding.mutableDeleteExcludes || [],
2159
- cacheControl: binding.cacheControl?.default || "",
2160
- }),
2161
- routing: binding.routing,
2162
- preservation: binding.mutableDeleteExcludes?.length > 0
2163
- ? {
2164
- contract: "kungfu-buildchain-web-surface-immutable-delete-exclusion",
2165
- mutableDeleteExcludes: binding.mutableDeleteExcludes,
2166
- }
2167
- : undefined,
2168
- },
2169
- ...(binding.cacheControl?.mutable
2170
- ? [{
2171
- action: "apply-mutable-cache-control",
2172
- surface: binding.surface,
2173
- command: "aws",
2174
- args: mutableCacheControlArgs({
2175
- artifactRoot: surfaceArtifactRoot,
2176
- bucket,
2177
- objectPrefix: binding.objectPrefix,
2178
- cacheControl: binding.cacheControl.mutable,
2179
- excludePatterns: binding.mutableDeleteExcludes || [],
2180
- }),
2181
- cacheControl: binding.cacheControl.mutable,
2182
- patterns: ["*.html", "*.json", "*.xml"],
2183
- excludes: binding.mutableDeleteExcludes || [],
2184
- }]
2185
- : []),
2186
- ];
2187
- const operations = [
2188
- ...verifyImmutable("before-upload"),
2189
- ...syncImmutable,
2190
- ...verifyImmutable("after-upload"),
2191
- ...mutableSync,
2192
- ...publishFriendlyInstallers,
2193
- ...(binding.publicationFastPath
2194
- ? []
2195
- : directoryIndexAliasOperations({ surfaceArtifactRoot, bucket, binding })),
2196
- {
2197
- action: "write-deployment-manifest",
2198
- surface: binding.surface,
2199
- command: "aws",
2200
- args: [
2201
- "s3",
2202
- "cp",
2203
- "-",
2204
- s3Uri(bucket, binding.manifestKey),
2205
- "--content-type",
2206
- "application/json",
2207
- ...(binding.cacheControl?.mutable
2208
- ? ["--cache-control", binding.cacheControl.mutable]
2209
- : []),
2210
- ],
2211
- stdin: `${JSON.stringify({
2212
- ...manifest,
2213
- surface: binding.surface,
2214
- url: binding.url,
2215
- surfaceBinding: binding,
2216
- }, null, 2)}\n`,
2217
- },
2218
- ];
2219
- if (distribution) {
2220
- const invalidationPaths = binding.publicationFastPath?.invalidationPaths
2221
- || [viewerWildcardPath(binding)];
2222
- operations.push({
2223
- action: "invalidate-cdn",
2224
- surface: binding.surface,
2225
- command: "aws",
2226
- args: [
2227
- "cloudfront",
2228
- "create-invalidation",
2229
- "--distribution-id",
2230
- distribution,
2231
- "--paths",
2232
- ...invalidationPaths,
2233
- cdnPath(binding.manifestKey),
2234
- ],
2235
- });
2236
- }
2237
- return operations;
2238
- }
2239
-
2240
- function planAdapterSteps(adapter, deployConfig, manifest) {
2241
- if (adapter === "aws-s3-cloudfront") {
2242
- const bindingSteps = manifest.surfaceBindings.flatMap((binding) => [
2243
- ...(binding.immutablePublication
2244
- ? [
2245
- {
2246
- action: "verify-immutable-artifact-before-upload",
2247
- surface: binding.surface,
2248
- fileCount: binding.immutablePublication.files.length,
2249
- },
2250
- {
2251
- action: "sync-immutable-artifact",
2252
- surface: binding.surface,
2253
- roots: binding.immutablePublication.uploadRoots,
2254
- overwrite: false,
2255
- },
2256
- {
2257
- action: "verify-immutable-artifact-after-upload",
2258
- surface: binding.surface,
2259
- fileCount: binding.immutablePublication.files.length,
2260
- },
2261
- ]
2262
- : []),
2263
- ...(binding.publicationFastPath
2264
- ? binding.publicationFastPath.mutableFiles.map((file) => ({
2265
- action: "sync-publication-fast-path",
2266
- surface: binding.surface,
2267
- target: binding.bucket,
2268
- path: file,
2269
- qualificationRoot: binding.publicationFastPath.qualificationRoot,
2270
- }))
2271
- : [{
2272
- action: "sync-static-artifact",
2273
- surface: binding.surface,
2274
- target: binding.bucket,
2275
- prefix: binding.objectPrefix,
2276
- deleteExcludes: binding.mutableDeleteExcludes || [],
2277
- cacheControl: binding.cacheControl || undefined,
2278
- },
2279
- ...(binding.cacheControl?.mutable
2280
- ? [{
2281
- action: "apply-mutable-cache-control",
2282
- surface: binding.surface,
2283
- cacheControl: binding.cacheControl.mutable,
2284
- patterns: ["*.html", "*.json", "*.xml"],
2285
- excludes: binding.mutableDeleteExcludes || [],
2286
- }]
2287
- : []),
2288
- ]),
2289
- {
2290
- action: "write-deployment-manifest",
2291
- surface: binding.surface,
2292
- target: manifestPrefixFor(deployConfig),
2293
- key: binding.manifestKey,
2294
- },
2295
- {
2296
- action: "invalidate-cdn",
2297
- surface: binding.surface,
2298
- distribution: binding.distributionId,
2299
- paths: binding.publicationFastPath?.invalidationPaths,
2300
- },
2301
- ]);
2302
- return [
2303
- ...bindingSteps.filter((step) => step.action === "verify-immutable-artifact-before-upload"),
2304
- ...bindingSteps.filter((step) => step.action === "sync-immutable-artifact"),
2305
- ...bindingSteps.filter((step) => step.action === "verify-immutable-artifact-after-upload"),
2306
- ...cloudFrontDirectoryIndexRewriteOperations(
2307
- (manifest.surfaceBindings || []).filter((binding) => !binding.publicationFastPath),
2308
- ).map((operation) => ({
2309
- action: operation.action,
2310
- distribution: operation.routing.distributionId,
2311
- functionName: operation.routing.functionName,
2312
- strategy: operation.routing.strategy,
2313
- })),
2314
- ...bindingSteps.filter((step) => ![
2315
- "verify-immutable-artifact-before-upload",
2316
- "sync-immutable-artifact",
2317
- "verify-immutable-artifact-after-upload",
2318
- ].includes(step.action)),
2319
- ];
2320
- }
2321
- return [
2322
- {
2323
- action: "prepare-dynamic-environment",
2324
- target: manifest.deployTarget,
2325
- },
2326
- {
2327
- action: "write-deployment-manifest",
2328
- target: manifestPrefixFor(deployConfig),
2329
- },
2330
- ];
2331
- }
2332
-
2333
- export function planWebSurfaceCleanup({
2334
- cwd = process.cwd(),
2335
- aliases = [],
2336
- channel = "preview",
2337
- now = new Date().toISOString(),
2338
- event = "manual",
2339
- sourceSha = "",
2340
- pullNumber = "",
2341
- actor = "",
2342
- runId = "",
2343
- dryRun = true,
2344
- } = {}) {
2345
- const loadedConfig = loadBuildchainConfig(cwd);
2346
- const config = assertWebSurfaceConfig(loadedConfig);
2347
- if (channel !== "preview") {
2348
- throw new Error("web-surface cleanup currently supports preview aliases only");
2349
- }
2350
- const deployConfig = config.deploy?.[channel];
2351
- if (!deployConfig) {
2352
- throw new Error(`missing deploy.${channel}`);
2353
- }
2354
- const requestedAliases = [...aliases];
2355
- if (requestedAliases.length === 0 && pullNumber) {
2356
- requestedAliases.push(`pr-${pullNumber}`);
2357
- }
2358
- const manifestPrefix = manifestPrefixFor(deployConfig);
2359
- const bindingsByAlias = new Map(requestedAliases.map((alias) => [
2360
- alias,
2361
- resolveSurfaceBindings({ config, channelName: channel, alias, deployConfig }),
2362
- ]));
2363
- return {
2364
- schemaVersion: 1,
2365
- contract: "kungfu-buildchain-web-surface-cleanup-plan",
2366
- dryRun,
2367
- applyMode: dryRun ? "dry-run" : "apply",
2368
- event,
2369
- channel,
2370
- now,
2371
- sourceSha: sourceSha ? assertSha(sourceSha, "sourceSha") : "",
2372
- pullNumber: pullNumber ? String(pullNumber) : "",
2373
- actor,
2374
- runId,
2375
- status: requestedAliases.length === 0 ? "no-op" : "planned",
2376
- adapter: deployConfig.adapter,
2377
- target: deployConfig.bucket || deployConfig.target || "",
2378
- manifestPrefix,
2379
- secretRefs: [...new Set([...(deployConfig.secretRefs || [])])],
2380
- entries: requestedAliases.map((alias) => {
2381
- const classified = classifyPreviewAlias(alias);
2382
- const retention = retentionConfig(config, "preview");
2383
- const surfaceBindings = bindingsByAlias.get(alias) || [];
2384
- const primaryBinding = surfaceBindings[0] || {};
2385
- const objectPrefix = primaryBinding.objectPrefix || objectPrefixFor(deployConfig, alias);
2386
- return {
2387
- alias,
2388
- aliasKind: classified.kind,
2389
- mutableAlias: classified.mutable,
2390
- retentionClass: classified.retentionClass,
2391
- retentionDays: retention[classified.retentionKey],
2392
- action: "delete-preview-alias",
2393
- objectPrefix,
2394
- manifestKey: primaryBinding.manifestKey || `${manifestPrefix.replace(/\/$/, "")}/${alias}.json`,
2395
- surfaceBindings,
2396
- steps: cleanupAdapterSteps(deployConfig.adapter, deployConfig, {
2397
- alias,
2398
- objectPrefix,
2399
- manifestPrefix,
2400
- surfaceBindings,
2401
- }),
2402
- };
2403
- }),
2404
- };
2405
- }
2406
-
2407
- export function applyWebSurfaceCleanup({
2408
- cwd = process.cwd(),
2409
- aliases = [],
2410
- channel = "preview",
2411
- now = new Date().toISOString(),
2412
- event = "manual",
2413
- sourceSha = "",
2414
- pullNumber = "",
2415
- actor = "",
2416
- runId = "",
2417
- plan = null,
2418
- dryRun = true,
2419
- commandRunner = defaultCommandRunner,
2420
- } = {}) {
2421
- const cleanup = plan
2422
- ? assertCleanupPlan(plan)
2423
- : planWebSurfaceCleanup({
2424
- cwd,
2425
- aliases,
2426
- channel,
2427
- now,
2428
- event,
2429
- sourceSha,
2430
- pullNumber,
2431
- actor,
2432
- runId,
2433
- dryRun,
2434
- });
2435
- const loadedConfig = loadBuildchainConfig(cwd);
2436
- const config = assertWebSurfaceConfig(loadedConfig);
2437
- const deployConfig = config.deploy?.[cleanup.channel];
2438
- if (!deployConfig) {
2439
- throw new Error(`missing deploy.${cleanup.channel}`);
2440
- }
2441
- if (cleanup.adapter !== "aws-s3-cloudfront") {
2442
- throw new Error(`web-surface cleanup apply does not support adapter: ${cleanup.adapter}`);
2443
- }
2444
- if (!dryRun) {
2445
- for (const entry of cleanup.entries) {
2446
- const bindings = entry.surfaceBindings?.length
2447
- ? entry.surfaceBindings
2448
- : [{
2449
- surface: "default",
2450
- }];
2451
- for (const binding of bindings) {
2452
- assertConcreteAwsDeployConfig({
2453
- deployConfig: surfaceDeployConfig(deployConfig, binding.surface),
2454
- channel: `${cleanup.channel}.surfaces.${binding.surface}`,
2455
- operation: "cleanup",
2456
- });
2457
- }
2458
- }
2459
- }
2460
- const bucket = deployConfig.bucket || deployConfig.target || "";
2461
- const operations = cleanup.entries.flatMap((entry) => cleanupEntryOperations({ deployConfig, entry, bucket }));
2462
- const operationResults = runAdapterOperations({ operations, dryRun, commandRunner });
2463
- return {
2464
- schemaVersion: 1,
2465
- contract: "kungfu-buildchain-web-surface-cleanup-apply",
2466
- dryRun,
2467
- applyMode: dryRun ? "dry-run" : "apply",
2468
- status: appliedStatus({ dryRun, operations: operationResults, noOp: cleanup.status === "no-op" }),
2469
- event,
2470
- channel,
2471
- now,
2472
- sourceSha: cleanup.sourceSha,
2473
- pullNumber: cleanup.pullNumber,
2474
- actor,
2475
- runId,
2476
- adapter: cleanup.adapter,
2477
- target: bucket,
2478
- manifestPrefix: cleanup.manifestPrefix,
2479
- entries: cleanup.entries,
2480
- operations: operationResults,
2481
- };
2482
- }
2483
-
2484
- function cleanupEntryOperations({ deployConfig, entry, bucket }) {
2485
- const bindings = entry.surfaceBindings?.length
2486
- ? entry.surfaceBindings
2487
- : [{
2488
- surface: "default",
2489
- objectPrefix: entry.objectPrefix,
2490
- manifestKey: entry.manifestKey,
2491
- bucket,
2492
- distributionId: deployConfig.cloudfront_distribution || deployConfig.distribution || "",
2493
- }];
2494
- return bindings.flatMap((binding) => {
2495
- const effectiveDeploy = surfaceDeployConfig(deployConfig, binding.surface);
2496
- const bindingBucket = binding.bucket || effectiveDeploy.bucket || effectiveDeploy.target || bucket;
2497
- const distribution = binding.distributionId || effectiveDeploy.cloudfront_distribution || effectiveDeploy.distribution || "";
2498
- const entryOperations = [
2499
- {
2500
- action: "delete-static-prefix",
2501
- alias: entry.alias,
2502
- surface: binding.surface,
2503
- command: "aws",
2504
- args: ["s3", "rm", s3Uri(bindingBucket, binding.objectPrefix), "--recursive"],
2505
- },
2506
- {
2507
- action: "delete-deployment-manifest",
2508
- alias: entry.alias,
2509
- surface: binding.surface,
2510
- command: "aws",
2511
- args: ["s3", "rm", s3Uri(bindingBucket, binding.manifestKey)],
2512
- },
2513
- ];
2514
- if (distribution) {
2515
- entryOperations.push({
2516
- action: "invalidate-cdn",
2517
- alias: entry.alias,
2518
- surface: binding.surface,
2519
- command: "aws",
2520
- args: [
2521
- "cloudfront",
2522
- "create-invalidation",
2523
- "--distribution-id",
2524
- distribution,
2525
- "--paths",
2526
- viewerWildcardPath(binding),
2527
- cdnPath(binding.manifestKey),
2528
- ],
2529
- });
2530
- }
2531
- return entryOperations;
2532
- });
2533
- }
2534
-
2535
- function cleanupAdapterSteps(adapter, deployConfig, entry) {
2536
- if (adapter === "aws-s3-cloudfront") {
2537
- const bindings = entry.surfaceBindings?.length
2538
- ? entry.surfaceBindings
2539
- : [{
2540
- surface: "default",
2541
- objectPrefix: entry.objectPrefix,
2542
- manifestKey: `${entry.manifestPrefix.replace(/\/$/, "")}/${entry.alias}.json`,
2543
- bucket: deployConfig.bucket || deployConfig.target || "",
2544
- distributionId: deployConfig.cloudfront_distribution || deployConfig.distribution || "",
2545
- }];
2546
- return bindings.flatMap((binding) => [
2547
- {
2548
- action: "delete-static-prefix",
2549
- surface: binding.surface,
2550
- target: binding.bucket,
2551
- prefix: binding.objectPrefix,
2552
- },
2553
- {
2554
- action: "delete-deployment-manifest",
2555
- surface: binding.surface,
2556
- target: entry.manifestPrefix,
2557
- key: binding.manifestKey,
2558
- },
2559
- {
2560
- action: "invalidate-cdn",
2561
- surface: binding.surface,
2562
- distribution: binding.distributionId,
2563
- },
2564
- ]);
2565
- }
2566
- return [
2567
- {
2568
- action: "delete-preview-environment",
2569
- target: deployConfig.environment || deployConfig.service || deployConfig.target || "",
2570
- alias: entry.alias,
2571
- },
2572
- {
2573
- action: "delete-deployment-manifest",
2574
- target: entry.manifestPrefix,
2575
- key: `${entry.manifestPrefix.replace(/\/$/, "")}/${entry.alias}.json`,
2576
- },
2577
- ];
2578
- }
2579
-
2580
- export function defaultWebSurfaceAlias({ channel = "preview", sourceSha = "", pullNumber = "" } = {}) {
2581
- if (channel !== "preview") {
2582
- return "";
2583
- }
2584
- if (pullNumber) {
2585
- return `pr-${pullNumber}`;
2586
- }
2587
- const sha = assertSha(sourceSha, "sourceSha");
2588
- return `sha-${sha.slice(0, 12)}`;
2589
- }
2590
-
2591
- export function localWebSurfaceContext() {
2592
- return {
2593
- sourceSha: process.env.BUILDCHAIN_SOURCE_SHA || process.env.GITHUB_SHA || "",
2594
- sourceRef: process.env.BUILDCHAIN_SOURCE_REF || process.env.GITHUB_REF || "",
2595
- repository: process.env.GITHUB_REPOSITORY || "",
2596
- runId: process.env.GITHUB_RUN_ID || "",
2597
- runAttempt: process.env.GITHUB_RUN_ATTEMPT || "",
2598
- runner: {
2599
- os: process.env.RUNNER_OS || os.platform(),
2600
- arch: process.env.RUNNER_ARCH || os.arch(),
2601
- },
2602
- };
2603
- }