@kungfu-tech/buildchain 3.0.9-alpha.9 → 4.0.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 (262) hide show
  1. package/AGENTS.md +39 -0
  2. package/README.md +17 -13
  3. package/actions/promote-buildchain-ref/README.md +0 -10
  4. package/actions/release-tail/README.md +6 -10
  5. package/architecture/internal-capabilities.json +502 -0
  6. package/architecture/maintainability-baseline.json +59 -0
  7. package/architecture/maintainability-policy.json +1384 -0
  8. package/architecture/release-tail-contract-inventory.json +587 -0
  9. package/architecture/v3-core-mechanism-inventory.json +1043 -0
  10. package/architecture/v3-core-mechanism-inventory.md +67 -0
  11. package/architecture/v4-adopter-delivery-parity.json +47 -0
  12. package/architecture/v4-architecture-constitution.md +210 -0
  13. package/architecture/v4-bootstrap-authority.json +56 -0
  14. package/architecture/v4-canonical-contract-fixtures.json +105 -0
  15. package/architecture/v4-capability-state-machine-manifest.json +480 -0
  16. package/architecture/v4-capability-state-machine-manifest.schema.json +202 -0
  17. package/architecture/v4-delivery-warrant-shadow-bootstrap-plan.json +830 -0
  18. package/architecture/v4-delivery-warrant-shadow-bootstrap-plan.md +223 -0
  19. package/architecture/v4-delivery-warrant-shadow-bootstrap-plan.schema.json +318 -0
  20. package/architecture/v4-delivery-warrant-shadow-fixtures.json +227 -0
  21. package/architecture/v4-delivery-warrant-shadow-fixtures.schema.json +67 -0
  22. package/architecture/v4-exception-ledger.json +5 -0
  23. package/architecture/v4-exception-ledger.schema.json +56 -0
  24. package/architecture/v4-partial-mutation-recovery-qualification.json +65 -0
  25. package/architecture/v4-platform-stage-checkpoints.json +97 -0
  26. package/architecture/v4-provider-operation-journal-contract.json +113 -0
  27. package/architecture/v4-release-activation-shadow-domain.json +61 -0
  28. package/architecture/v4-release-train-parity.json +68 -0
  29. package/architecture/v4-rust-libnode-bridge-evaluation.json +107 -0
  30. package/architecture/v4-rust-libnode-bridge-spike.md +85 -0
  31. package/architecture/v4-stable-publication-fence.json +66 -0
  32. package/architecture/v4-stage-capsule-contract.json +90 -0
  33. package/architecture/v4-stage-capsule-qualification.json +99 -0
  34. package/architecture/v4-stage-capsule-resume-planner.json +52 -0
  35. package/architecture/v4-stage-capsule-store-contract.json +72 -0
  36. package/bin/buildchain.mjs +15 -10
  37. package/contracts/auditable-demo-scenario-v1.schema.json +1 -1
  38. package/contracts/buildchain-v2-residuals-v1.json +2 -2
  39. package/contracts/fixtures/v4-delivery-warrant-trace-v1/golden.json +158 -0
  40. package/contracts/fixtures/v4-delivery-warrant-trace-v1/property.json +380 -0
  41. package/contracts/fixtures/v4-delivery-warrant-trace-v1/replay.json +163 -0
  42. package/contracts/fixtures/v4-partial-mutation-recovery-v1/shared.json +155 -0
  43. package/contracts/fixtures/v4-provider-operation-journal-v1/shared.json +457 -0
  44. package/contracts/fixtures/v4-provider-readback-idempotency-v1/shared.json +682 -0
  45. package/contracts/fixtures/v4-release-activation-shadow-v1/shared.json +53 -0
  46. package/contracts/fixtures/v4-stable-publication-fence-v1/shared.json +56 -0
  47. package/contracts/fixtures/v4-stage-capsule-resume-v1/late-platform-failure.json +176 -0
  48. package/contracts/fixtures/v4-stage-capsule-store-v1/shared.json +132 -0
  49. package/contracts/fixtures/v4-stage-capsule-v1/shared.json +111 -0
  50. package/contracts/v4-canonical-contracts-v1.schema.json +182 -0
  51. package/contracts/v4-delivery-warrant-semantic-diff-report-v1.schema.json +284 -0
  52. package/contracts/v4-delivery-warrant-trace-v1.schema.json +215 -0
  53. package/contracts/v4-host-contract-v1.schema.json +135 -0
  54. package/contracts/v4-partial-mutation-recovery-v1.schema.json +168 -0
  55. package/contracts/v4-provider-operation-journal-v1.schema.json +381 -0
  56. package/contracts/v4-release-activation-shadow-v1.schema.json +186 -0
  57. package/contracts/v4-stable-publication-fence-v1.schema.json +125 -0
  58. package/contracts/v4-stage-capsule-resume-v1.schema.json +225 -0
  59. package/contracts/v4-stage-capsule-store-v1.schema.json +154 -0
  60. package/contracts/v4-stage-capsule-v1.schema.json +178 -0
  61. package/crates/buildchain-v4-bridge/Cargo.lock +213 -0
  62. package/crates/buildchain-v4-bridge/Cargo.toml +12 -0
  63. package/crates/buildchain-v4-bridge/src/main.rs +495 -0
  64. package/dist/site/agent-index.json +0 -4
  65. package/dist/site/artifact-schemas.json +0 -8
  66. package/dist/site/buildchain-contract.json +103 -397
  67. package/dist/site/buildchain-site.json +302 -386
  68. package/dist/site/capability-registry.json +9 -11
  69. package/dist/site/cli-registry.json +8 -53
  70. package/dist/site/controller-registry.json +48 -8
  71. package/dist/site/kfd-claims.json +129 -167
  72. package/dist/site/kfd-upstream-aggregate.json +9 -9
  73. package/dist/site/manual-registry.json +18 -49
  74. package/dist/site/node-api-registry.json +4345 -7345
  75. package/dist/site/page-registry.json +278 -346
  76. package/dist/site/public-surface-audit.json +85 -404
  77. package/dist/site/publication-authority-registry.json +11 -1
  78. package/dist/site/publication-registry.json +4 -4
  79. package/dist/site/release-provenance.json +3 -9
  80. package/dist/site/schemas/kfd-support-projection-v1.schema.json +106 -0
  81. package/dist/site/site-manifest.json +22 -38
  82. package/dist/site/workflow-registry.json +78 -35
  83. package/docs/MAP.md +8 -5
  84. package/docs/auditable-demo.md +2 -2
  85. package/docs/aws-us-elastic-runner-burst-plane.md +7 -59
  86. package/docs/cli-reference.md +15 -213
  87. package/docs/cli.md +14 -14
  88. package/docs/dev-alpha-candidate-patrol.md +3 -11
  89. package/docs/dev-delivery-warrant.md +29 -194
  90. package/docs/engineering-housekeeper.md +12 -4
  91. package/docs/getting-started.md +1 -1
  92. package/docs/install.md +5 -5
  93. package/docs/kfd-support.md +2 -7
  94. package/docs/lifecycle-protocol.md +2 -4
  95. package/docs/node-api-reference.md +414 -554
  96. package/docs/release-flow.md +31 -31
  97. package/docs/release-governance.md +16 -28
  98. package/docs/release-passport.md +2 -15
  99. package/docs/release-tail-contract.md +13 -6
  100. package/docs/release-tail-provider-plane.md +13 -19
  101. package/docs/release-train.md +4 -4
  102. package/docs/reusable-build-surface.md +14 -27
  103. package/docs/site-bundle-contract.md +1 -5
  104. package/docs/stable-candidate-patrol.md +7 -7
  105. package/docs/v4-canonical-contracts.md +92 -0
  106. package/docs/v4-delivery-warrant-read-candidate.md +73 -0
  107. package/docs/v4-delivery-warrant-semantic-diff.md +75 -0
  108. package/docs/v4-production-release.md +63 -0
  109. package/docs/v4-stage-capsule.md +193 -0
  110. package/docs/versioning.md +3 -5
  111. package/package.json +19 -19
  112. package/packages/core/adopter-delivery-gate.js +576 -0
  113. package/packages/core/adopter-delivery-json.js +66 -0
  114. package/packages/core/artifact-signing.js +0 -61
  115. package/packages/core/artifact-verification-envelope.js +5 -5
  116. package/packages/core/build-facts.js +12 -4
  117. package/packages/core/buildchain-agent-manuals.js +0 -2
  118. package/packages/core/buildchain-channel-identity.js +3 -2
  119. package/packages/core/buildchain-config.js +4 -69
  120. package/packages/core/buildchain-contract.js +232 -46
  121. package/packages/core/buildchain-kfd-claims.js +1 -1
  122. package/packages/core/channel-candidate.js +0 -8
  123. package/packages/core/channel-promotion-baseline.js +0 -52
  124. package/packages/core/controller-evidence.js +3 -4
  125. package/packages/core/dev-alpha-candidate-selection.js +2 -10
  126. package/packages/core/dev-delivery-warrant-cancellation.js +0 -1
  127. package/packages/core/dev-delivery-warrant-settlement.js +20 -67
  128. package/packages/core/dev-delivery-warrant.js +50 -138
  129. package/packages/core/diagnostics.js +3 -8
  130. package/packages/core/github-governance-authority.js +3 -1
  131. package/packages/core/kfd-adopter-category-driver.js +167 -0
  132. package/packages/core/kfd-adopter-manifest.js +47 -46
  133. package/packages/core/kfd-gate.js +15 -45
  134. package/packages/core/paper-agent-entry.js +7 -16
  135. package/packages/core/paper-fleet.js +2 -2
  136. package/packages/core/paper-repository.js +2 -3
  137. package/packages/core/paper-scaffold-content.js +2 -23
  138. package/packages/core/paper.js +11 -43
  139. package/packages/core/publication-reproducibility.js +4 -4
  140. package/packages/core/release-line-bootstrap.js +21 -8
  141. package/packages/core/release-passport-contract.js +5 -5
  142. package/packages/core/release-passport.js +20 -131
  143. package/packages/core/self-dogfood-version.js +48 -35
  144. package/packages/core/spawn-command.js +232 -8
  145. package/packages/core/v4-adopter-delivery-parity.js +219 -0
  146. package/packages/core/v4-canonical-contracts.js +284 -0
  147. package/packages/core/v4-delivery-warrant-fixture-runner.js +371 -0
  148. package/packages/core/v4-delivery-warrant-read-candidate.js +279 -0
  149. package/packages/core/v4-delivery-warrant-semantic-diff-gate.js +352 -0
  150. package/packages/core/v4-delivery-warrant-shadow-adapter.js +447 -0
  151. package/packages/core/v4-partial-mutation-recovery-qualification.js +395 -0
  152. package/packages/core/v4-platform-stage-checkpoints.js +471 -0
  153. package/packages/core/v4-provider-operation-journal.js +531 -0
  154. package/packages/core/v4-provider-readback-idempotency.js +394 -0
  155. package/packages/core/v4-release-activation-shadow.js +519 -0
  156. package/packages/core/v4-stable-publication-fence.js +357 -0
  157. package/packages/core/v4-stage-capsule-local-store.js +426 -0
  158. package/packages/core/v4-stage-capsule-qualification-campaign.js +512 -0
  159. package/packages/core/v4-stage-capsule-qualification.js +456 -0
  160. package/packages/core/v4-stage-capsule-resume-planner.js +397 -0
  161. package/packages/core/v4-stage-capsule-store.js +401 -0
  162. package/packages/core/v4-stage-capsule.js +319 -0
  163. package/scripts/assemble-self-publication-admission.mjs +1 -1
  164. package/scripts/audit-publication-control-plane.mjs +5 -5
  165. package/scripts/auditable-demo-bundle-verification.mjs +3 -2
  166. package/scripts/auditable-demo-platform.mjs +2 -2
  167. package/scripts/auditable-demo-renditions.mjs +1 -1
  168. package/scripts/auditable-demo.mjs +2 -2
  169. package/scripts/aws-macos-jit-controller-core.mjs +13 -346
  170. package/scripts/aws-macos-jit-controller-runtime.mjs +2 -210
  171. package/scripts/aws-macos-jit-controller.mjs +37 -275
  172. package/scripts/aws-macos-jit-core.mjs +3 -41
  173. package/scripts/aws-macos-jit.mjs +0 -12
  174. package/scripts/aws-windows-jit-campaign.mjs +2 -2
  175. package/scripts/aws-windows-jit-controller-core.mjs +1 -1
  176. package/scripts/aws-windows-jit-controller.mjs +3 -3
  177. package/scripts/build-contract-core.mjs +3 -8
  178. package/scripts/build-standalone-binary.mjs +3 -14
  179. package/scripts/buildchain-channel-router.mjs +4 -0
  180. package/scripts/buildchain-cli-help.mjs +7 -16
  181. package/scripts/buildchain-contract-lock.mjs +0 -6
  182. package/scripts/check-action-bundles.mjs +3 -4
  183. package/scripts/check-internal-architecture.mjs +7 -6
  184. package/scripts/check-inventory.mjs +30 -25
  185. package/scripts/check-v4-public-dogfood-contract.mjs +270 -0
  186. package/scripts/create-release-bundle.mjs +8 -4
  187. package/scripts/dev-alpha-candidate-patrol.mjs +1 -22
  188. package/scripts/dev-delivery-proof.mjs +2 -64
  189. package/scripts/dev-delivery-warrant.mjs +61 -86
  190. package/scripts/dev-pr-auto-merge.mjs +4 -30
  191. package/scripts/dev-pr-delivery-warrant.mjs +0 -55
  192. package/scripts/dispatch-artifact-signing-authority.mjs +7 -4
  193. package/scripts/generate-buildchain-kfd-witnesses.mjs +94 -88
  194. package/scripts/generate-channel-build-workflow.mjs +54 -24
  195. package/scripts/generate-channel-promotion-workflow.mjs +15 -6
  196. package/scripts/generate-site-bundle.mjs +8 -27
  197. package/scripts/git-fetch-process-tree.mjs +34 -1
  198. package/scripts/init-repo.mjs +64 -159
  199. package/scripts/inspect-artifact-signing-requests.mjs +0 -6
  200. package/scripts/locked-source-checkout.mjs +3 -4
  201. package/scripts/maintainability-metrics.mjs +8 -2
  202. package/scripts/npm-publish-dry-run.mjs +2 -2
  203. package/scripts/npm-publish-transaction.mjs +2 -2
  204. package/scripts/publication-commit-evidence.mjs +23 -69
  205. package/scripts/release-candidate-resolver.mjs +11 -17
  206. package/scripts/release-tail.mjs +3 -49
  207. package/scripts/resume-from-candidate-run.mjs +9 -123
  208. package/scripts/run-lifecycle-core.mjs +12 -13
  209. package/scripts/seal-artifact-signing-requests.mjs +17 -21
  210. package/scripts/site-capability-metadata.mjs +3 -20
  211. package/scripts/stable-candidate-qualification.mjs +10 -10
  212. package/scripts/v4-architecture.mjs +12 -2
  213. package/scripts/v4-bridge-bootstrap.mjs +141 -0
  214. package/scripts/v4-bridge-evidence.mjs +141 -0
  215. package/scripts/v4-host-adapter.mjs +182 -0
  216. package/scripts/v4-platform-stage-checkpoint-rehearsal.mjs +207 -0
  217. package/scripts/v4-stage-capsule-qualification.mjs +528 -0
  218. package/scripts/v4-stage-capsule-resume-rehearsal.mjs +57 -0
  219. package/scripts/v4-warrant-shadow-plan.mjs +601 -0
  220. package/scripts/verify-golden-path.mjs +5 -5
  221. package/scripts/web-surface-cloudfront-rewrite.mjs +15 -15
  222. package/scripts/web-surface-core.mjs +2 -8
  223. package/scripts/workflow-call-contract.mjs +5 -184
  224. package/contracts/dev-delivery-authority-v2.schema.json +0 -253
  225. package/contracts/fixtures/kfd-adopter-release-v1/kfd-4-perspective.json +0 -16
  226. package/contracts/fixtures/kfd-adopter-release-v1/kfd-4-replay.json +0 -57
  227. package/contracts/fixtures/next-development-transition-v1/anchored-manual-waiting.json +0 -47
  228. package/contracts/fixtures/next-development-transition-v1/semver-auto-planned.json +0 -47
  229. package/contracts/fixtures/next-development-transition-v1/version-model-cases.json +0 -40
  230. package/contracts/next-development-request-v1.schema.json +0 -66
  231. package/contracts/next-development-transition-v1.schema.json +0 -292
  232. package/contracts/publication-rehearsal-capsule-v1.schema.json +0 -173
  233. package/dist/site/schemas/dev-delivery-authority-v2.schema.json +0 -442
  234. package/dist/site/schemas/publication-rehearsal-capsule-v1.schema.json +0 -269
  235. package/dist/site/schemas/release-tail-capabilities-v1.schema.json +0 -353
  236. package/dist/site/schemas/release-tail-provider-bindings-v1.schema.json +0 -94
  237. package/docs/dev-delivery-qualification-landing-adr.md +0 -137
  238. package/docs/next-development-transition.md +0 -119
  239. package/docs/publication-rehearsal.md +0 -94
  240. package/packages/core/buildchain-compatibility-proof.js +0 -631
  241. package/packages/core/dev-delivery-authority.js +0 -996
  242. package/packages/core/dev-delivery-native-proof.js +0 -418
  243. package/packages/core/dev-delivery-warrant-shadow.js +0 -502
  244. package/packages/core/next-development-candidate-reservation.js +0 -186
  245. package/packages/core/next-development-controller.js +0 -726
  246. package/packages/core/next-development-projection.js +0 -288
  247. package/packages/core/next-development-transition.js +0 -738
  248. package/packages/core/publication-rehearsal-projection.js +0 -173
  249. package/packages/core/publication-rehearsal-runtime.js +0 -921
  250. package/scripts/aws-macos-jit-instance-rehydrate.mjs +0 -260
  251. package/scripts/aws-macos-jit-source-rebind.mjs +0 -724
  252. package/scripts/dev-delivery-authority.mjs +0 -368
  253. package/scripts/dev-delivery-native-run.mjs +0 -235
  254. package/scripts/dev-delivery-two-phase-resume.mjs +0 -90
  255. package/scripts/dev-delivery-two-phase.mjs +0 -577
  256. package/scripts/generate-next-development-guidance.mjs +0 -49
  257. package/scripts/materialize-self-release-candidate-version.mjs +0 -137
  258. package/scripts/next-development-self-dogfood-harness.mjs +0 -409
  259. package/scripts/next-development-self-dogfood.mjs +0 -532
  260. package/scripts/next-development-transition.mjs +0 -47
  261. package/scripts/release-candidate-tail-reseal.mjs +0 -426
  262. package/templates/native-dev-delivery.yml +0 -86
@@ -3,35 +3,15 @@ import fs from "node:fs";
3
3
  import path from "node:path";
4
4
  import { pathToFileURL } from "node:url";
5
5
  import { BUILDCHAIN_CONFIG_PATH } from "../packages/core/buildchain-layout.js";
6
- import {
7
- detectPackageManager,
8
- assertPackageManager,
9
- } from "../packages/core/package-manager.js";
10
- import {
11
- PUBLICATION_REHEARSAL_WORKFLOW_PATH,
12
- appendPublicationRehearsalToml,
13
- mergePublicationRehearsalAgentInstructions,
14
- publicationRehearsalWorkflow,
15
- } from "../packages/core/publication-rehearsal-projection.js";
16
- import {
17
- appendNextDevelopmentToml,
18
- mergeNextDevelopmentAgentInstructions,
19
- nextDevelopmentWorkflowHeader,
20
- } from "../packages/core/next-development-projection.js";
21
-
22
- const BUILDCHAIN_WORKFLOW_REF =
23
- "kungfu-systems/buildchain/.github/workflows/.build.yml@v3";
24
- const DEFAULT_PUBLICATION_LATEX_IMAGE =
25
- "ghcr.io/kungfu-systems/build-images/latex-pdf-builder";
26
- const DEFAULT_PUBLICATION_LATEX_DIGEST =
27
- "sha256:c20f3809e96836c1c78e97c76939d12f1de3fed0ea9b7c40c43332ec2ea480f8";
28
- const DEFAULT_PUBLICATION_LATEX_COMMAND =
29
- "latexmk -pdf -outdir=_build paper/main.tex";
6
+ import { detectPackageManager, assertPackageManager } from "../packages/core/package-manager.js";
7
+
8
+ const BUILDCHAIN_WORKFLOW_REF = "kungfu-systems/buildchain/.github/workflows/.build.yml@v4";
9
+ const DEFAULT_PUBLICATION_LATEX_IMAGE = "ghcr.io/kungfu-systems/build-images/latex-pdf-builder";
10
+ const DEFAULT_PUBLICATION_LATEX_DIGEST = "sha256:c20f3809e96836c1c78e97c76939d12f1de3fed0ea9b7c40c43332ec2ea480f8";
11
+ const DEFAULT_PUBLICATION_LATEX_COMMAND = "latexmk -pdf -outdir=_build paper/main.tex";
30
12
 
31
13
  function posixPath(value) {
32
- return String(value || "")
33
- .split(path.sep)
34
- .join("/");
14
+ return String(value || "").split(path.sep).join("/");
35
15
  }
36
16
 
37
17
  function repoName(cwd) {
@@ -296,42 +276,34 @@ command = "make check"
296
276
  }
297
277
 
298
278
  function infraContractDesiredJson(cwd) {
299
- return `${JSON.stringify(
300
- {
301
- service: repoName(cwd),
302
- environment: "staging",
303
- resources: [
304
- {
305
- kind: "static-site",
306
- name: repoName(cwd),
307
- desiredState: {
308
- hostname: "staging.example.com",
309
- accessControl: "managed-network",
310
- owner: "platform",
311
- },
279
+ return `${JSON.stringify({
280
+ service: repoName(cwd),
281
+ environment: "staging",
282
+ resources: [
283
+ {
284
+ kind: "static-site",
285
+ name: repoName(cwd),
286
+ desiredState: {
287
+ hostname: "staging.example.com",
288
+ accessControl: "managed-network",
289
+ owner: "platform",
312
290
  },
313
- ],
314
- },
315
- null,
316
- 2,
317
- )}\n`;
291
+ },
292
+ ],
293
+ }, null, 2)}\n`;
318
294
  }
319
295
 
320
296
  function infraContractOutputsJson(cwd) {
321
- return `${JSON.stringify(
322
- {
323
- service: repoName(cwd),
324
- environment: "staging",
325
- observedMode: "manual-observed",
326
- outputs: {
327
- hostname: "staging.example.com",
328
- distributionId: "observed-distribution-id",
329
- bucket: "observed-bucket-name",
330
- },
297
+ return `${JSON.stringify({
298
+ service: repoName(cwd),
299
+ environment: "staging",
300
+ observedMode: "manual-observed",
301
+ outputs: {
302
+ hostname: "staging.example.com",
303
+ distributionId: "observed-distribution-id",
304
+ bucket: "observed-bucket-name",
331
305
  },
332
- null,
333
- 2,
334
- )}\n`;
306
+ }, null, 2)}\n`;
335
307
  }
336
308
 
337
309
  function workflowArtifactPaths(type) {
@@ -355,7 +327,7 @@ function workflowArtifactPaths(type) {
355
327
  }
356
328
 
357
329
  function publicationWorkflowYaml() {
358
- return `${nextDevelopmentWorkflowHeader()}name: Build
330
+ return `name: Build
359
331
 
360
332
  on:
361
333
  workflow_dispatch:
@@ -377,7 +349,7 @@ permissions:
377
349
 
378
350
  jobs:
379
351
  publication:
380
- uses: kungfu-systems/buildchain/.github/workflows/publication-artifact.yml@v3
352
+ uses: kungfu-systems/buildchain/.github/workflows/publication-artifact.yml@v4
381
353
  with:
382
354
  buildchain-ref: \${{ inputs.buildchain-ref || '' }}
383
355
  toolchain-type: config
@@ -387,7 +359,9 @@ jobs:
387
359
  }
388
360
 
389
361
  function workflowYaml({ type, runnerPreset, artifactName }) {
390
- return `${nextDevelopmentWorkflowHeader()}name: Build
362
+ return `# Buildchain v4 lifecycle checkpoints are governed by architecture/v4-platform-stage-checkpoints.json.
363
+ # Do not add undeclared runner-only inputs, outputs, environment, or provider effects.
364
+ name: Build
391
365
 
392
366
  on:
393
367
  workflow_dispatch:
@@ -420,32 +394,15 @@ jobs:
420
394
  `;
421
395
  }
422
396
 
423
- function devDeliveryWorkflowYaml() {
424
- return fs.readFileSync(
425
- new URL("../templates/native-dev-delivery.yml", import.meta.url),
426
- "utf8",
427
- );
428
- }
429
397
  function writeIfAllowed(filePath, content, { force }) {
430
398
  if (fs.existsSync(filePath) && !force) {
431
- throw new Error(
432
- `${posixPath(filePath)} already exists; pass --force to overwrite`,
433
- );
399
+ throw new Error(`${posixPath(filePath)} already exists; pass --force to overwrite`);
434
400
  }
435
401
  fs.mkdirSync(path.dirname(filePath), { recursive: true });
436
402
  fs.writeFileSync(filePath, content);
437
403
  return filePath;
438
404
  }
439
405
 
440
- function writeManagedAgentEntry(filePath, current) {
441
- const content = mergeNextDevelopmentAgentInstructions(
442
- mergePublicationRehearsalAgentInstructions(current),
443
- );
444
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
445
- fs.writeFileSync(filePath, content);
446
- return filePath;
447
- }
448
-
449
406
  export function initBuildchainRepo({
450
407
  cwd = process.cwd(),
451
408
  type = "package",
@@ -456,43 +413,30 @@ export function initBuildchainRepo({
456
413
  } = {}) {
457
414
  const resolvedCwd = path.resolve(cwd);
458
415
  const manager = detectOrDefaultPackageManager(resolvedCwd, packageManager);
459
- const toml = appendNextDevelopmentToml(
460
- appendPublicationRehearsalToml(
461
- (() => {
462
- if (type === "package") {
463
- return packageToml(resolvedCwd, manager);
464
- }
465
- if (type === "native") {
466
- return nativeToml(resolvedCwd);
467
- }
468
- if (type === "web-surface") {
469
- return webSurfaceToml(resolvedCwd);
470
- }
471
- if (type === "infra-contract") {
472
- return infraContractToml(resolvedCwd);
473
- }
474
- if (type === "publication-artifact") {
475
- return publicationArtifactToml(resolvedCwd);
476
- }
477
- if (type === "anchored-package") {
478
- return anchoredPackageToml(resolvedCwd, manager);
479
- }
480
- throw new Error(
481
- "init --type must be one of package, native, web-surface, infra-contract, publication-artifact, or anchored-package",
482
- );
483
- })(),
484
- ),
485
- );
486
-
487
- const agentsPath = path.join(resolvedCwd, "AGENTS.md");
488
- const currentAgents = fs.existsSync(agentsPath)
489
- ? fs.readFileSync(agentsPath, "utf8")
490
- : "";
416
+ const toml = (() => {
417
+ if (type === "package") {
418
+ return packageToml(resolvedCwd, manager);
419
+ }
420
+ if (type === "native") {
421
+ return nativeToml(resolvedCwd);
422
+ }
423
+ if (type === "web-surface") {
424
+ return webSurfaceToml(resolvedCwd);
425
+ }
426
+ if (type === "infra-contract") {
427
+ return infraContractToml(resolvedCwd);
428
+ }
429
+ if (type === "publication-artifact") {
430
+ return publicationArtifactToml(resolvedCwd);
431
+ }
432
+ if (type === "anchored-package") {
433
+ return anchoredPackageToml(resolvedCwd, manager);
434
+ }
435
+ throw new Error("init --type must be one of package, native, web-surface, infra-contract, publication-artifact, or anchored-package");
436
+ })();
491
437
 
492
438
  const written = [
493
- writeIfAllowed(path.join(resolvedCwd, BUILDCHAIN_CONFIG_PATH), toml, {
494
- force,
495
- }),
439
+ writeIfAllowed(path.join(resolvedCwd, BUILDCHAIN_CONFIG_PATH), toml, { force }),
496
440
  writeIfAllowed(
497
441
  path.join(resolvedCwd, ".github", "workflows", "build.yml"),
498
442
  type === "publication-artifact"
@@ -504,49 +448,16 @@ export function initBuildchainRepo({
504
448
  }),
505
449
  { force },
506
450
  ),
507
- writeIfAllowed(
508
- path.join(resolvedCwd, PUBLICATION_REHEARSAL_WORKFLOW_PATH),
509
- publicationRehearsalWorkflow("v3"),
510
- { force },
511
- ),
512
- writeManagedAgentEntry(agentsPath, currentAgents),
513
451
  ];
514
452
 
515
- if (type === "native") {
516
- written.push(
517
- writeIfAllowed(
518
- path.join(resolvedCwd, ".github", "workflows", "dev-delivery.yml"),
519
- devDeliveryWorkflowYaml(),
520
- { force },
521
- ),
522
- );
523
- }
524
-
525
- if (
526
- type === "anchored-package" &&
527
- !fs.existsSync(path.join(resolvedCwd, "release.json"))
528
- ) {
529
- written.push(
530
- writeIfAllowed(
531
- path.join(resolvedCwd, "release.json"),
532
- '{\n "upstream": "",\n "version": "0.0.0"\n}\n',
533
- { force },
534
- ),
535
- );
453
+ if (type === "anchored-package" && !fs.existsSync(path.join(resolvedCwd, "release.json"))) {
454
+ written.push(writeIfAllowed(path.join(resolvedCwd, "release.json"), "{\n \"upstream\": \"\",\n \"version\": \"0.0.0\"\n}\n", { force }));
536
455
  }
537
456
 
538
457
  if (type === "infra-contract") {
539
458
  written.push(
540
- writeIfAllowed(
541
- path.join(resolvedCwd, "infra", "desired.json"),
542
- infraContractDesiredJson(resolvedCwd),
543
- { force },
544
- ),
545
- writeIfAllowed(
546
- path.join(resolvedCwd, "infra", "outputs.json"),
547
- infraContractOutputsJson(resolvedCwd),
548
- { force },
549
- ),
459
+ writeIfAllowed(path.join(resolvedCwd, "infra", "desired.json"), infraContractDesiredJson(resolvedCwd), { force }),
460
+ writeIfAllowed(path.join(resolvedCwd, "infra", "outputs.json"), infraContractOutputsJson(resolvedCwd), { force }),
550
461
  );
551
462
  }
552
463
 
@@ -556,9 +467,7 @@ export function initBuildchainRepo({
556
467
  cwd: resolvedCwd,
557
468
  packageManager: manager,
558
469
  workflowRef: BUILDCHAIN_WORKFLOW_REF,
559
- written: written.map((filePath) =>
560
- posixPath(path.relative(resolvedCwd, filePath)),
561
- ),
470
+ written: written.map((filePath) => posixPath(path.relative(resolvedCwd, filePath))),
562
471
  };
563
472
  }
564
473
 
@@ -570,11 +479,7 @@ function readArg(name, fallback = "") {
570
479
  return process.argv[index + 1] || "";
571
480
  }
572
481
 
573
- if (
574
- !process.env.BUILDCHAIN_EMBEDDED_ENTRYPOINT &&
575
- process.argv[1] &&
576
- import.meta.url === pathToFileURL(process.argv[1]).href
577
- ) {
482
+ if (!process.env.BUILDCHAIN_EMBEDDED_ENTRYPOINT && process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
578
483
  try {
579
484
  const result = initBuildchainRepo({
580
485
  cwd: readArg("cwd", process.cwd()),
@@ -82,10 +82,6 @@ export function inspectArtifactSigningRequests({
82
82
  if (seen.has(key))
83
83
  throw new Error(`duplicate artifact signing request: ${key}`);
84
84
  seen.add(key);
85
- const {
86
- entitlementsProfile = "none",
87
- entitlementsPaths = [],
88
- } = request.signature;
89
85
  const item = {
90
86
  id: request.artifact.id,
91
87
  slug: safeId(request.artifact.id),
@@ -108,8 +104,6 @@ export function inspectArtifactSigningRequests({
108
104
  sourceSha: request.source.sha,
109
105
  sourceTreeSha: request.source.treeSha,
110
106
  transportFormat: request.artifact.transport?.format || "",
111
- entitlementsProfile,
112
- entitlementsPaths: entitlementsPaths.join(","),
113
107
  };
114
108
  if (request.signature.profile === "detached-signature-v1")
115
109
  matrices.detached.push(item);
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { execFileSync } from "node:child_process";
3
2
  import crypto from "node:crypto";
4
3
  import fs from "node:fs";
5
4
  import path from "node:path";
@@ -113,12 +112,12 @@ function ensureCheckoutTarget(targetPath, workspace) {
113
112
  function git(args, { cwd, env = {}, timeoutMs = 60000, stdio = ["ignore", "pipe", "pipe"] } = {}) {
114
113
  try {
115
114
  const commandEnv = { ...process.env, ...env };
116
- const output = args[0] === "fetch" ? runGitFetchSync({ args, cwd, env: commandEnv, timeoutMs, stdio }) : execFileSync("git", args, {
115
+ const output = runGitFetchSync({
116
+ args,
117
117
  cwd,
118
118
  env: commandEnv,
119
- encoding: "utf8",
119
+ timeoutMs,
120
120
  stdio,
121
- timeout: timeoutMs,
122
121
  });
123
122
  return output ? String(output).trim() : "";
124
123
  } catch (error) {
@@ -11,6 +11,7 @@ import {
11
11
  } from "./check-internal-architecture.mjs";
12
12
 
13
13
  const JS_EXTENSIONS = new Set([".js", ".mjs", ".cjs"]);
14
+ const HAND_MAINTAINED_EXTENSIONS = new Set([...JS_EXTENSIONS, ".rs"]);
14
15
  const GENERATED_PATTERN = /^actions\/[^/]+\/dist\/.*\.js$/u;
15
16
 
16
17
  function gitText(root, args, encoding = "utf8") {
@@ -50,7 +51,7 @@ function isGeneratedFile(file) {
50
51
 
51
52
  function isHandMaintainedSource(file) {
52
53
  return (
53
- JS_EXTENSIONS.has(path.extname(file)) &&
54
+ HAND_MAINTAINED_EXTENSIONS.has(path.extname(file)) &&
54
55
  !isTestFile(file) &&
55
56
  !isGeneratedFile(file)
56
57
  );
@@ -260,7 +261,12 @@ function collectMaintainabilityMetrics({
260
261
  const sourceMetrics = Object.fromEntries(
261
262
  sourceFiles.map((file) => {
262
263
  const source = readTrackedFile(root, file, revision);
263
- return [file, analyzeJavaScript(file, source)];
264
+ return [
265
+ file,
266
+ JS_EXTENSIONS.has(path.extname(file))
267
+ ? analyzeJavaScript(file, source)
268
+ : { lines: lineCount(source), complexity: 0, functions: [] },
269
+ ];
264
270
  }),
265
271
  );
266
272
  const sumLines = (entries) =>
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { spawnSync } from "node:child_process";
3
2
  import fs from "node:fs";
4
3
  import path from "node:path";
5
4
  import { pathToFileURL } from "node:url";
5
+ import { spawnSyncCommand } from "../packages/core/spawn-command.js";
6
6
 
7
7
  const EXACT_TAG_PATTERN = /^v\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
8
8
 
@@ -27,7 +27,7 @@ function hasFlag(argv, name) {
27
27
  }
28
28
 
29
29
  function runCommand({ cwd, cmd, args }) {
30
- const result = spawnSync(cmd, args, {
30
+ const result = spawnSyncCommand(cmd, args, {
31
31
  cwd,
32
32
  env: process.env,
33
33
  encoding: "utf8",
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
- import { spawnSync } from "node:child_process";
3
2
  import crypto from "node:crypto";
4
3
  import fs from "node:fs";
5
4
  import path from "node:path";
6
5
  import { pathToFileURL } from "node:url";
6
+ import { spawnSyncCommand } from "../packages/core/spawn-command.js";
7
7
 
8
8
  const EXACT_TAG_PATTERN = /^v\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;
9
9
 
@@ -24,7 +24,7 @@ function readEnv(name, fallback = "") {
24
24
  }
25
25
 
26
26
  function runNpm({ cwd, args, allowFailure = false }) {
27
- const result = spawnSync("npm", args, {
27
+ const result = spawnSyncCommand("npm", args, {
28
28
  cwd,
29
29
  env: process.env,
30
30
  encoding: "utf8",
@@ -7,12 +7,6 @@ import { pathToFileURL } from "node:url";
7
7
 
8
8
  const SCHEMA = "kungfu-buildchain-publication-commit-evidence/v1";
9
9
  const INSTALLER_BUNDLE_SCHEMA = "kungfu.installer-publication-bundle/v1";
10
- const RELEASE_REDIRECT_STATUSES = new Set([301, 302, 303, 307, 308]);
11
- const RELEASE_REDIRECT_HOSTS = new Set([
12
- "github.com",
13
- "release-assets.githubusercontent.com",
14
- "objects.githubusercontent.com",
15
- ]);
16
10
 
17
11
  function requiredString(value, label) {
18
12
  if (typeof value !== "string" || value.trim() === "") {
@@ -110,7 +104,7 @@ function validateInstallerBundle(evidence, expected) {
110
104
  }
111
105
  if (
112
106
  exactSha(bundle.sourceCommit, "installerBundle.sourceCommit") !==
113
- expected.candidateSourceSha ||
107
+ expected.sourceSha ||
114
108
  !["alpha", "stable"].includes(bundle.channel)
115
109
  ) {
116
110
  throw new Error("installer bundle release identity mismatch");
@@ -234,7 +228,6 @@ function validateInstallerBundle(evidence, expected) {
234
228
  return {
235
229
  schema: bundle.schema,
236
230
  bundleRoot,
237
- sourceCommit: bundle.sourceCommit,
238
231
  manifestDigest: bundle.manifestDigest,
239
232
  channel: bundle.channel,
240
233
  channelPayloadRoot: bundle.channelPayloadRoot,
@@ -245,9 +238,10 @@ function validateInstallerBundle(evidence, expected) {
245
238
  assets: bundle.assets,
246
239
  };
247
240
  }
241
+
248
242
  export function validatePublicationCommitEvidence(
249
243
  evidence,
250
- { version, sourceSha, candidateSourceSha, releaseSha, releaseTag } = {},
244
+ { version, sourceSha, releaseSha, releaseTag } = {},
251
245
  ) {
252
246
  if (!evidence || typeof evidence !== "object" || Array.isArray(evidence)) {
253
247
  throw new Error("publication commit evidence must be an object");
@@ -270,17 +264,6 @@ export function validatePublicationCommitEvidence(
270
264
  throw new Error(`publication commit evidence ${field} mismatch`);
271
265
  }
272
266
  }
273
- expected.candidateSourceSha = exactSha(
274
- candidateSourceSha ?? identity.candidateSourceSha ?? expected.sourceSha,
275
- "expected candidateSourceSha",
276
- );
277
- if (
278
- identity.candidateSourceSha !== undefined &&
279
- exactSha(identity.candidateSourceSha, "identity.candidateSourceSha") !==
280
- expected.candidateSourceSha
281
- ) {
282
- throw new Error("publication commit evidence candidateSourceSha mismatch");
283
- }
284
267
  const publicUrl = publicHttps(evidence.publication?.url, "publication.url");
285
268
  const payloadRoot = sha256Root(
286
269
  evidence.publication?.payloadRoot,
@@ -330,47 +313,15 @@ export async function verifyInstallerBundleReadback(
330
313
  if (typeof fetchImpl !== "function") {
331
314
  throw new Error("installer bundle read-back requires fetch");
332
315
  }
333
- const fetchReleaseReadback = async (url, label) => {
334
- let current = url;
335
- for (let hop = 0; hop <= 3; hop += 1) {
336
- const response = await fetchImpl(current, {
337
- redirect: "manual",
338
- cache: "no-store",
339
- });
340
- if (response.status === 200) return response;
341
- if (!RELEASE_REDIRECT_STATUSES.has(response.status)) {
342
- throw new Error(`${label} failed: HTTP ${response.status}`);
343
- }
344
- if (hop === 3) {
345
- throw new Error(`${label} exceeded the bounded redirect limit`);
346
- }
347
- const location = response.headers?.get?.("location");
348
- if (!location) {
349
- throw new Error(`${label} redirect omitted Location`);
350
- }
351
- const redirect = new URL(location, current);
352
- if (
353
- redirect.protocol !== "https:" ||
354
- redirect.username ||
355
- redirect.password ||
356
- !RELEASE_REDIRECT_HOSTS.has(redirect.hostname) ||
357
- (redirect.hostname === "github.com" &&
358
- !redirect.pathname.startsWith(
359
- "/kungfu-systems/kungfu/releases/download/",
360
- ))
361
- ) {
362
- throw new Error(
363
- `${label} redirected outside trusted GitHub release storage`,
364
- );
365
- }
366
- current = redirect.href;
367
- }
368
- throw new Error(`${label} failed without a terminal response`);
369
- };
370
- const manifestResponse = await fetchReleaseReadback(
371
- result.publicUrl,
372
- "installer bundle manifest read-back",
373
- );
316
+ const manifestResponse = await fetchImpl(result.publicUrl, {
317
+ redirect: "manual",
318
+ cache: "no-store",
319
+ });
320
+ if (manifestResponse.status !== 200) {
321
+ throw new Error(
322
+ `installer bundle manifest read-back failed: HTTP ${manifestResponse.status}`,
323
+ );
324
+ }
374
325
  const manifestBytes = Buffer.from(await manifestResponse.arrayBuffer());
375
326
  if (digest(manifestBytes) !== bundle.manifestDigest) {
376
327
  throw new Error("installer bundle manifest digest mismatch");
@@ -385,7 +336,7 @@ export async function verifyInstallerBundleReadback(
385
336
  semanticRoot(unsigned) !== bundle.bundleRoot ||
386
337
  manifest.package?.name !== "@kungfu-tech/site" ||
387
338
  typeof manifest.package?.version !== "string" ||
388
- manifest.identity?.sourceCommit !== result.identity.candidateSourceSha ||
339
+ manifest.identity?.sourceCommit !== result.identity.sourceSha ||
389
340
  manifest.identity?.releaseSha !== result.identity.releaseSha ||
390
341
  manifest.identity?.releaseTag !== result.identity.releaseTag ||
391
342
  manifest.identity?.version !== result.identity.version ||
@@ -414,10 +365,15 @@ export async function verifyInstallerBundleReadback(
414
365
  for (const asset of bundle.assets) {
415
366
  let observation = byUrl.get(asset.releaseUrl);
416
367
  if (!observation) {
417
- const response = await fetchReleaseReadback(
418
- asset.releaseUrl,
419
- "installer bundle asset read-back",
420
- );
368
+ const response = await fetchImpl(asset.releaseUrl, {
369
+ redirect: "manual",
370
+ cache: "no-store",
371
+ });
372
+ if (response.status !== 200) {
373
+ throw new Error(
374
+ `installer bundle asset read-back failed: HTTP ${response.status}`,
375
+ );
376
+ }
421
377
  const bytes = Buffer.from(await response.arrayBuffer());
422
378
  observation = {
423
379
  releaseUrl: asset.releaseUrl,
@@ -438,7 +394,7 @@ export async function verifyInstallerBundleReadback(
438
394
  schema: "kungfu-buildchain-installer-publication-bundle-seal/v1",
439
395
  bundleRoot: bundle.bundleRoot,
440
396
  manifestDigest: bundle.manifestDigest,
441
- sourceCommit: result.identity.candidateSourceSha,
397
+ sourceCommit: result.identity.sourceSha,
442
398
  releaseTag: result.identity.releaseTag,
443
399
  releasePassport: bundle.releasePassport,
444
400
  observations,
@@ -453,8 +409,6 @@ async function main(args) {
453
409
  if (value === "--evidence") options.evidence = args[++index];
454
410
  else if (value === "--version") options.version = args[++index];
455
411
  else if (value === "--source-sha") options.sourceSha = args[++index];
456
- else if (value === "--candidate-source-sha")
457
- options.candidateSourceSha = args[++index];
458
412
  else if (value === "--release-sha") options.releaseSha = args[++index];
459
413
  else if (value === "--release-tag") options.releaseTag = args[++index];
460
414
  else throw new Error(`unknown argument: ${value}`);
@@ -291,7 +291,7 @@ function readNpmPackageJsonFromTarball(tarballPath) {
291
291
  const errors = [];
292
292
  for (const candidate of candidates) {
293
293
  try {
294
- return JSON.parse(execFileSync("tar", ["-xOf", tarballPath, candidate], { encoding: "utf8" }));
294
+ return JSON.parse(execFileSync("tar", ["-xOf", path.basename(tarballPath), candidate], { cwd: path.dirname(tarballPath), encoding: "utf8" }));
295
295
  } catch (error) {
296
296
  errors.push(error.stderr?.toString?.().trim() || error.message);
297
297
  }
@@ -351,22 +351,16 @@ export function generatePublishRequiredArtifacts({
351
351
  const files = Array.isArray(manifest.files) ? manifest.files : [];
352
352
  return files
353
353
  .filter((file) => file?.sha256)
354
- .map((file) => {
355
- const name = String(file.path || file.name || manifest.artifactName || platform)
356
- .replaceAll("\\", "/")
357
- .replace(/^\.\//, "");
358
- return {
359
- ...(platform ? { group: platform } : {}),
360
- kind,
361
- name,
362
- ref,
363
- digest: String(file.sha256).startsWith("sha256:")
364
- ? String(file.sha256)
365
- : `sha256:${file.sha256}`,
366
- role: "platform",
367
- platform,
368
- };
369
- });
354
+ .map((file) => ({
355
+ kind,
356
+ name: packageNameFromArtifactPath(file.path || file.name || manifest.artifactName || platform),
357
+ ref,
358
+ digest: String(file.sha256).startsWith("sha256:")
359
+ ? String(file.sha256)
360
+ : `sha256:${file.sha256}`,
361
+ role: "platform",
362
+ platform,
363
+ }));
370
364
  });
371
365
  }
372
366