@kungfu-tech/buildchain 3.0.9-alpha.1 → 3.0.9-alpha.11

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 (105) hide show
  1. package/actions/promote-buildchain-ref/README.md +4 -0
  2. package/bin/buildchain.mjs +9 -1
  3. package/bin/internal/trust-release-release-handlers.mjs +1 -0
  4. package/contracts/dev-delivery-authority-v2.schema.json +253 -0
  5. package/contracts/fixtures/next-development-transition-v1/anchored-manual-waiting.json +47 -0
  6. package/contracts/fixtures/next-development-transition-v1/semver-auto-planned.json +47 -0
  7. package/contracts/fixtures/next-development-transition-v1/version-model-cases.json +40 -0
  8. package/contracts/next-development-request-v1.schema.json +66 -0
  9. package/contracts/next-development-transition-v1.schema.json +292 -0
  10. package/dist/site/agent-index.json +1 -0
  11. package/dist/site/artifact-schemas.json +2 -0
  12. package/dist/site/buildchain-contract.json +92 -27
  13. package/dist/site/buildchain-site.json +351 -38
  14. package/dist/site/capability-registry.json +7 -6
  15. package/dist/site/cli-registry.json +43 -3
  16. package/dist/site/controller-registry.json +6 -2
  17. package/dist/site/kfd-claims.json +223 -12
  18. package/dist/site/kfd-upstream-aggregate.json +9 -9
  19. package/dist/site/manual-registry.json +23 -7
  20. package/dist/site/node-api-registry.json +7926 -4533
  21. package/dist/site/page-registry.json +332 -27
  22. package/dist/site/public-surface-audit.json +359 -11
  23. package/dist/site/publication-registry.json +4 -4
  24. package/dist/site/release-passport-check-manifest.json +1 -0
  25. package/dist/site/release-provenance.json +14 -0
  26. package/dist/site/schemas/dev-delivery-authority-v2.schema.json +442 -0
  27. package/dist/site/schemas/release-passport-v1.schema.json +3 -0
  28. package/dist/site/site-manifest.json +19 -11
  29. package/dist/site/workflow-registry.json +21 -10
  30. package/docs/MAP.md +5 -2
  31. package/docs/adopter-delivery-gate.md +106 -0
  32. package/docs/aws-us-elastic-runner-burst-plane.md +30 -3
  33. package/docs/cli-reference.md +202 -15
  34. package/docs/dev-alpha-candidate-patrol.md +8 -0
  35. package/docs/dev-delivery-qualification-landing-adr.md +137 -0
  36. package/docs/dev-delivery-warrant.md +149 -22
  37. package/docs/kfd-support.md +7 -2
  38. package/docs/next-development-transition.md +119 -0
  39. package/docs/node-api-reference.md +402 -204
  40. package/docs/release-governance.md +10 -7
  41. package/docs/release-passport.md +18 -2
  42. package/docs/versioning.md +4 -1
  43. package/package.json +23 -6
  44. package/packages/core/README.md +25 -0
  45. package/packages/core/adopter-delivery-gate.js +576 -0
  46. package/packages/core/adopter-delivery-json.js +66 -0
  47. package/packages/core/adopter-delivery-passport.js +259 -0
  48. package/packages/core/adopter-delivery-vectors.js +158 -0
  49. package/packages/core/adopter-delivery-vectors.json +77 -0
  50. package/packages/core/artifact-verification-envelope.js +5 -5
  51. package/packages/core/buildchain-agent-manuals.js +1 -0
  52. package/packages/core/buildchain-channel-identity.js +2 -3
  53. package/packages/core/buildchain-compatibility-proof.js +22 -0
  54. package/packages/core/buildchain-delivery-bootstrap.js +240 -0
  55. package/packages/core/buildchain-delivery-infrastructure.js +164 -0
  56. package/packages/core/buildchain-delivery-self-dogfood.js +395 -0
  57. package/packages/core/channel-candidate.js +8 -0
  58. package/packages/core/channel-promotion-baseline.js +52 -0
  59. package/packages/core/dev-alpha-candidate-selection.js +10 -2
  60. package/packages/core/dev-delivery-authority.js +996 -0
  61. package/packages/core/dev-delivery-native-proof.js +418 -0
  62. package/packages/core/dev-delivery-warrant-settlement.js +67 -20
  63. package/packages/core/dev-delivery-warrant.js +129 -46
  64. package/packages/core/kfd-adopter-category-driver.js +167 -0
  65. package/packages/core/kfd-adopter-manifest.js +49 -50
  66. package/packages/core/legacy-kfd-adopter-driver.js +167 -0
  67. package/packages/core/next-development-candidate-reservation.js +186 -0
  68. package/packages/core/next-development-controller.js +726 -0
  69. package/packages/core/next-development-projection.js +288 -0
  70. package/packages/core/next-development-transition.js +738 -0
  71. package/packages/core/paper-agent-entry.js +7 -4
  72. package/packages/core/paper.js +14 -7
  73. package/packages/core/published-delivery-authority.js +247 -0
  74. package/packages/core/release-passport-contract.js +10 -6
  75. package/packages/core/release-passport.js +37 -13
  76. package/scripts/aws-macos-jit-controller-core.mjs +239 -4
  77. package/scripts/aws-macos-jit-controller.mjs +198 -2
  78. package/scripts/aws-macos-jit-instance-rehydrate.mjs +260 -0
  79. package/scripts/aws-macos-jit-source-rebind.mjs +235 -14
  80. package/scripts/aws-macos-jit.mjs +12 -0
  81. package/scripts/buildchain-cli-help.mjs +10 -2
  82. package/scripts/check-internal-architecture.mjs +1 -0
  83. package/scripts/check-inventory.mjs +12 -1
  84. package/scripts/dev-alpha-candidate-patrol.mjs +22 -1
  85. package/scripts/dev-delivery-authority.mjs +368 -0
  86. package/scripts/dev-delivery-native-run.mjs +235 -0
  87. package/scripts/dev-delivery-proof.mjs +64 -2
  88. package/scripts/dev-delivery-two-phase-resume.mjs +90 -0
  89. package/scripts/dev-delivery-two-phase.mjs +577 -0
  90. package/scripts/dev-delivery-warrant.mjs +48 -6
  91. package/scripts/dev-pr-delivery-warrant.mjs +19 -14
  92. package/scripts/generate-buildchain-kfd-witnesses.mjs +2 -2
  93. package/scripts/generate-channel-build-workflow.mjs +4 -0
  94. package/scripts/generate-next-development-guidance.mjs +49 -0
  95. package/scripts/generate-site-bundle.mjs +8 -3
  96. package/scripts/init-repo.mjs +135 -62
  97. package/scripts/next-development-self-dogfood-harness.mjs +409 -0
  98. package/scripts/next-development-self-dogfood.mjs +532 -0
  99. package/scripts/next-development-transition.mjs +47 -0
  100. package/scripts/release-candidate-tail-reseal.mjs +426 -0
  101. package/scripts/seal-artifact-signing-requests.mjs +7 -4
  102. package/scripts/site-capability-metadata.mjs +25 -1
  103. package/scripts/stable-candidate-qualification.mjs +7 -7
  104. package/scripts/workflow-call-contract.mjs +1 -1
  105. package/templates/native-dev-delivery.yml +86 -0
@@ -1,4 +1,5 @@
1
1
  import fs from "node:fs";
2
+ import { defaultDevDeliveryStateRef, GitHubDevDeliveryStore } from "./dev-delivery-warrant.mjs";
2
3
 
3
4
  const ROOT_PATTERN = /^sha256:[0-9a-f]{64}$/;
4
5
  const SHA_PATTERN = /^[0-9a-f]{40}$/;
@@ -34,6 +35,11 @@ function exactActiveReadback(result) {
34
35
  const warrant = result.observation.activeWarrant;
35
36
  const candidate = result.observation.activeCandidate;
36
37
  requireMatch(warrant?.schema === "kungfu.buildchain.dev-delivery-warrant/v1", "delivery-warrant-missing");
38
+ requireMatch((warrant.phase || "qualified") === "qualified", "delivery-warrant-not-qualified");
39
+ if (warrant.phase === "qualified") {
40
+ requireMatch(ROOT_PATTERN.test(String(warrant.nativeProofRoot || "")), "delivery-warrant-native-proof-missing");
41
+ requireMatch(ROOT_PATTERN.test(String(warrant.nativeProofReuseRoot || "")), "delivery-warrant-native-reuse-missing");
42
+ }
37
43
  requireMatch(candidate?.candidateId === warrant.candidateId, "delivery-warrant-candidate-readback-missing");
38
44
  requireMatch(!result.warrant || JSON.stringify(result.warrant) === JSON.stringify(warrant), "delivery-warrant-readback-mismatch");
39
45
  return { warrant, candidate };
@@ -117,19 +123,18 @@ export function readDeliveryWarrantResult(options, pullRequest) {
117
123
  }
118
124
 
119
125
  export async function readCurrentDeliveryQueueState(client, repository, targetBranch) {
120
- if (typeof client.getDevDeliveryQueueState === "function") {
121
- return client.getDevDeliveryQueueState(targetBranch);
122
- }
123
- const stateRef = `buildchain/dev-delivery-warrant/${targetBranch.replaceAll("/", "-")}`;
124
- const query = new URLSearchParams({ ref: stateRef });
125
- const { data } = await client.request(
126
- "GET",
127
- `/repos/${repository.owner}/${repository.repo}/contents/queue.json?${query}`,
128
- );
129
- if (data?.type !== "file" || data?.encoding !== "base64" || !data?.content) {
130
- mismatch("delivery-warrant-current-readback-invalid");
131
- }
132
- return JSON.parse(Buffer.from(String(data.content).replace(/\s+/g, ""), "base64").toString("utf8"));
126
+ if (typeof client.getDevDeliveryQueueState === "function") return client.getDevDeliveryQueueState(targetBranch);
127
+ const store = new GitHubDevDeliveryStore({
128
+ repository: `${repository.owner}/${repository.repo}`,
129
+ token: client.token,
130
+ apiUrl: client.apiUrl,
131
+ fetchImpl: client.fetch,
132
+ });
133
+ const { queue } = await store.read({
134
+ stateRef: defaultDevDeliveryStateRef(targetBranch),
135
+ protectedBase: targetBranch,
136
+ });
137
+ return queue;
133
138
  }
134
139
 
135
140
  export async function verifyCurrentDeliveryWarrant(client, options, pullRequest, warrant) {
@@ -147,7 +152,7 @@ export async function verifyCurrentDeliveryWarrant(client, options, pullRequest,
147
152
  requireMatch(Number(active?.generation) === Number(warrant.generation), "delivery-warrant-current-generation-mismatch");
148
153
  requireMatch(Number(active?.pullRequestNumber) === Number(pullRequest.number), "delivery-warrant-current-pr-mismatch");
149
154
  requireMatch(String(active?.sourceHead || "").toLowerCase() === options.expectedHeadSha, "delivery-warrant-current-head-mismatch");
150
- requireMatch(["selected", "proving", "waiting", "blocked"].includes(candidate?.status), "delivery-warrant-current-candidate-not-selected");
155
+ requireMatch(["selected", "proving", "waiting", "blocked", "qualified"].includes(candidate?.status), "delivery-warrant-current-candidate-not-selected");
151
156
  requireMatch(candidate?.sourceHead === active.sourceHead, "delivery-warrant-current-candidate-head-mismatch");
152
157
  }
153
158
 
@@ -85,7 +85,7 @@ export async function generateBuildchainKfdAdopterRelease({ cwd = process.cwd(),
85
85
  const packageArtifactRoot = installedKfdPackageArtifactRoot(), gates = [];
86
86
  for (const standard of ["kfd-4", "kfd-5", "kfd-7"]) gates.push(await generateProductGate(root, outDir, standard, sourceSha, checkedAt));
87
87
  const sourceRoot = kfdProductGateDigest({ repository: REPOSITORY, sourceSha, files: [...new Set(Object.values(evidenceSources))].sort().map((sourcePath) => ({ path: sourcePath, sha256: fileDigest(path.join(root, sourcePath)) })) });
88
- let manifest = initAdopterManifest({ manifestId: "buildchain-v3-full-cut", adopterId: REPOSITORY, artifactKind: "git-commit", artifactCoordinate: `${REPOSITORY}@${sourceSha}`, artifactRoot: sourceRoot, scope: "Buildchain v3 release and protected delivery authority", packageArtifactRoot, verifiedAt: checkedAt, maxAgeSeconds: 86400 });
88
+ let manifest = initAdopterManifest({ manifestId: "buildchain-v3-full-cut", adopterId: REPOSITORY, artifactKind: "git-commit", artifactCoordinate: `${REPOSITORY}@${sourceSha}`, artifactRoot: sourceRoot, scope: "Buildchain v3 release and protected delivery authority", packageArtifactRoot, verifiedAt: checkedAt, maxAgeSeconds: 86400, packageRoot: kfdRoot });
89
89
  const gateById = new Map(gates.map((gate) => [gate.standard.toUpperCase(), gate]));
90
90
  for (const id of ["KFD-1", "KFD-2", "KFD-3", "KFD-4", "KFD-5", "KFD-7"]) {
91
91
  const row = manifest.decisions.find((entry) => entry.id === id);
@@ -95,7 +95,7 @@ export async function generateBuildchainKfdAdopterRelease({ cwd = process.cwd(),
95
95
  }
96
96
  const kfd6 = manifest.decisions.find((entry) => entry.id === "KFD-6");
97
97
  kfd6.state = "unsupported"; kfd6.usage = "unused"; kfd6.gaps = ["Buildchain does not claim KFD-6 support in this cut."];
98
- manifest = addAdopterWitness(manifest, { decisionId: "KFD-10", profileId: "kfd-warrant-evidence", witnessCoordinate: `git+https://github.com/${REPOSITORY}@${sourceSha}#${evidenceSources["KFD-10"]}`, witnessRoot: fileDigest(path.join(root, evidenceSources["KFD-10"])), packageArtifactRoot, verifiedAt: checkedAt, maxAgeSeconds: 86400 });
98
+ manifest = addAdopterWitness(manifest, { decisionId: "KFD-10", profileId: "kfd-warrant-evidence", witnessCoordinate: `git+https://github.com/${REPOSITORY}@${sourceSha}#${evidenceSources["KFD-10"]}`, witnessRoot: fileDigest(path.join(root, evidenceSources["KFD-10"])), packageArtifactRoot, verifiedAt: checkedAt, maxAgeSeconds: 86400, packageRoot: kfdRoot });
99
99
  const manifestPath = writeJson(outDir, "kfd-adopter-manifest.json", manifest).filePath, manifestGate = createKfdAdopterManifestGate({ manifest, packageArtifactRoot, gateResults: gates, authorityPath: "kfd-adopter-manifest.json", expectedSourceSha: sourceSha, checkedAt });
100
100
  if (!validateKfdAdopterManifestGate(manifestGate, { expectedSourceSha: sourceSha, checkedAt }).valid) throw new Error(`generated adopter manifest gate failed: ${JSON.stringify(manifestGate.issues)}`);
101
101
  const gatePath = writeJson(outDir, "kfd-adopter-manifest-gate.json", manifestGate).filePath, support = createKfdLegacySupportMatrixProjection({ manifest, manifestGate });
@@ -46,6 +46,10 @@ function routerInputs(inputBlock) {
46
46
 
47
47
  function routerOutputs(outputBlock) {
48
48
  const forwarded = outputBlock
49
+ .replace(
50
+ /^ value: \$\{\{ jobs\.[^.]+\.outputs\.([a-z0-9-]+) \|\| jobs\.[^.]+\.outputs\.\1 \}\}$/gm,
51
+ " value: ${{ jobs.alpha.outputs.$1 || jobs.stable.outputs.$1 }}",
52
+ )
49
53
  .replace(/^ value: \$\{\{ jobs\.[^.]+\.outputs\.([^ }]+) \}\}$/gm, " value: ${{ jobs.alpha.outputs.$1 || jobs.stable.outputs.$1 }}")
50
54
  .replaceAll("build-lifecycle", "build-channel-router")
51
55
  .replace("value: ${{ jobs.alpha.outputs.controller-plan-artifact || jobs.stable.outputs.controller-plan-artifact }}", "value: ${{ jobs.controller-plan.outputs.controller-plan-artifact }}")
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { pathToFileURL } from "node:url";
6
+
7
+ import { nextDevelopmentManual } from "../packages/core/next-development-projection.js";
8
+
9
+ export const NEXT_DEVELOPMENT_MANUAL_PATH =
10
+ "docs/next-development-transition.md";
11
+
12
+ export function generateNextDevelopmentGuidance({
13
+ cwd = process.cwd(),
14
+ check = false,
15
+ } = {}) {
16
+ const target = path.resolve(cwd, NEXT_DEVELOPMENT_MANUAL_PATH);
17
+ const expected = nextDevelopmentManual();
18
+ const current = fs.existsSync(target) ? fs.readFileSync(target, "utf8") : "";
19
+ if (check) {
20
+ if (current !== expected) {
21
+ throw new Error(
22
+ `${NEXT_DEVELOPMENT_MANUAL_PATH} drifted from its contract source`,
23
+ );
24
+ }
25
+ return { ok: true, changed: false, path: NEXT_DEVELOPMENT_MANUAL_PATH };
26
+ }
27
+ fs.mkdirSync(path.dirname(target), { recursive: true });
28
+ if (current !== expected) fs.writeFileSync(target, expected);
29
+ return {
30
+ ok: true,
31
+ changed: current !== expected,
32
+ path: NEXT_DEVELOPMENT_MANUAL_PATH,
33
+ };
34
+ }
35
+
36
+ if (
37
+ process.argv[1] &&
38
+ import.meta.url === pathToFileURL(process.argv[1]).href
39
+ ) {
40
+ try {
41
+ const result = generateNextDevelopmentGuidance({
42
+ check: process.argv.includes("--check"),
43
+ });
44
+ process.stdout.write(`${JSON.stringify(result)}\n`);
45
+ } catch (error) {
46
+ process.stderr.write(`next-development guidance: ${error.message}\n`);
47
+ process.exitCode = 1;
48
+ }
49
+ }
@@ -368,6 +368,7 @@ const manualMetaById = new Map(Object.entries({
368
368
  "release-activation-transaction": { capabilityGroup: "release-passport-trust", audience: ["release-operator", "agent"], maturity: "preview", order: 125 },
369
369
  "release-candidate": { capabilityGroup: "reusable-build", audience: ["release-operator", "consumer"], maturity: "stable", order: 130 },
370
370
  "release-train": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer", "agent"], maturity: "preview", order: 132 },
371
+ "next-development-transition": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer", "agent"], maturity: "preview", order: 133 },
371
372
  "stable-candidate-patrol": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer"], maturity: "preview", order: 135 },
372
373
  "dev-qualification-patrol": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer", "agent"], maturity: "preview", order: 136 },
373
374
  "dev-alpha-candidate-patrol": { capabilityGroup: "governance-versioning", audience: ["release-operator", "consumer", "agent"], maturity: "preview", order: 137 },
@@ -733,6 +734,7 @@ function buildSiteBundle() {
733
734
  "docs/reusable-build-surface.md",
734
735
  "docs/release-candidate.md",
735
736
  "docs/release-train.md",
737
+ "docs/next-development-transition.md",
736
738
  "docs/stable-candidate-patrol.md",
737
739
  "docs/dev-qualification-patrol.md",
738
740
  "docs/dev-alpha-candidate-patrol.md",
@@ -929,7 +931,7 @@ function buildSiteBundle() {
929
931
  "schemas/release-tail-capabilities-v1.schema.json",
930
932
  "schemas/release-tail-provider-bindings-v1.schema.json",
931
933
  "schemas/kfd-agent-hub-adoption.schema.json",
932
- "schemas/kfd-product-gate-input-v1.schema.json",
934
+ "schemas/kfd-product-gate-input-v1.schema.json", "schemas/dev-delivery-authority-v2.schema.json",
933
935
  "kfd-support.json",
934
936
  "artifact-evidence.json",
935
937
  "product-mechanism.json",
@@ -966,7 +968,7 @@ function buildSiteBundle() {
966
968
  "schemas/release-tail-capabilities-v1.schema.json",
967
969
  "schemas/release-tail-provider-bindings-v1.schema.json",
968
970
  "schemas/kfd-agent-hub-adoption.schema.json",
969
- "schemas/kfd-product-gate-input-v1.schema.json",
971
+ "schemas/kfd-product-gate-input-v1.schema.json", "schemas/dev-delivery-authority-v2.schema.json",
970
972
  "buildchain-contract.json",
971
973
  "kfd-claims.json",
972
974
  "product-mechanism.json",
@@ -1099,7 +1101,7 @@ function buildSiteBundle() {
1099
1101
  "schemas/release-tail-capabilities-v1.schema.json",
1100
1102
  "schemas/release-tail-provider-bindings-v1.schema.json",
1101
1103
  "schemas/kfd-agent-hub-adoption.schema.json",
1102
- "schemas/kfd-product-gate-input-v1.schema.json",
1104
+ "schemas/kfd-product-gate-input-v1.schema.json", "schemas/dev-delivery-authority-v2.schema.json",
1103
1105
  "buildchain-contract.json",
1104
1106
  "kfd-upstream-aggregate.json",
1105
1107
  "kfd-claims.json",
@@ -1283,6 +1285,9 @@ function buildSiteBundle() {
1283
1285
  ),
1284
1286
  "schemas/kfd-agent-hub-adoption.schema.json": KFD_AGENT_HUB_ADOPTION_SCHEMA,
1285
1287
  "schemas/kfd-product-gate-input-v1.schema.json": KFD_PRODUCT_GATE_INPUT_SCHEMA,
1288
+ "schemas/dev-delivery-authority-v2.schema.json": readJson(
1289
+ "contracts/dev-delivery-authority-v2.schema.json",
1290
+ ),
1286
1291
  "badge-endpoint-registry.json": badgeEndpointRegistry,
1287
1292
  "publication-registry.json": publicationRegistry,
1288
1293
  "buildchain-contract.json": createBuildchainContractWorld({ root, controllerRegistry }),
@@ -3,21 +3,35 @@ 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 { detectPackageManager, assertPackageManager } from "../packages/core/package-manager.js";
6
+ import {
7
+ detectPackageManager,
8
+ assertPackageManager,
9
+ } from "../packages/core/package-manager.js";
7
10
  import {
8
11
  PUBLICATION_REHEARSAL_WORKFLOW_PATH,
9
12
  appendPublicationRehearsalToml,
10
13
  mergePublicationRehearsalAgentInstructions,
11
14
  publicationRehearsalWorkflow,
12
15
  } from "../packages/core/publication-rehearsal-projection.js";
13
-
14
- const BUILDCHAIN_WORKFLOW_REF = "kungfu-systems/buildchain/.github/workflows/.build.yml@v3";
15
- const DEFAULT_PUBLICATION_LATEX_IMAGE = "ghcr.io/kungfu-systems/build-images/latex-pdf-builder";
16
- const DEFAULT_PUBLICATION_LATEX_DIGEST = "sha256:c20f3809e96836c1c78e97c76939d12f1de3fed0ea9b7c40c43332ec2ea480f8";
17
- const DEFAULT_PUBLICATION_LATEX_COMMAND = "latexmk -pdf -outdir=_build paper/main.tex";
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";
18
30
 
19
31
  function posixPath(value) {
20
- return String(value || "").split(path.sep).join("/");
32
+ return String(value || "")
33
+ .split(path.sep)
34
+ .join("/");
21
35
  }
22
36
 
23
37
  function repoName(cwd) {
@@ -282,34 +296,42 @@ command = "make check"
282
296
  }
283
297
 
284
298
  function infraContractDesiredJson(cwd) {
285
- return `${JSON.stringify({
286
- service: repoName(cwd),
287
- environment: "staging",
288
- resources: [
289
- {
290
- kind: "static-site",
291
- name: repoName(cwd),
292
- desiredState: {
293
- hostname: "staging.example.com",
294
- accessControl: "managed-network",
295
- owner: "platform",
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
+ },
296
312
  },
297
- },
298
- ],
299
- }, null, 2)}\n`;
313
+ ],
314
+ },
315
+ null,
316
+ 2,
317
+ )}\n`;
300
318
  }
301
319
 
302
320
  function infraContractOutputsJson(cwd) {
303
- return `${JSON.stringify({
304
- service: repoName(cwd),
305
- environment: "staging",
306
- observedMode: "manual-observed",
307
- outputs: {
308
- hostname: "staging.example.com",
309
- distributionId: "observed-distribution-id",
310
- bucket: "observed-bucket-name",
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
+ },
311
331
  },
312
- }, null, 2)}\n`;
332
+ null,
333
+ 2,
334
+ )}\n`;
313
335
  }
314
336
 
315
337
  function workflowArtifactPaths(type) {
@@ -333,7 +355,7 @@ function workflowArtifactPaths(type) {
333
355
  }
334
356
 
335
357
  function publicationWorkflowYaml() {
336
- return `name: Build
358
+ return `${nextDevelopmentWorkflowHeader()}name: Build
337
359
 
338
360
  on:
339
361
  workflow_dispatch:
@@ -365,7 +387,7 @@ jobs:
365
387
  }
366
388
 
367
389
  function workflowYaml({ type, runnerPreset, artifactName }) {
368
- return `name: Build
390
+ return `${nextDevelopmentWorkflowHeader()}name: Build
369
391
 
370
392
  on:
371
393
  workflow_dispatch:
@@ -398,9 +420,17 @@ jobs:
398
420
  `;
399
421
  }
400
422
 
423
+ function devDeliveryWorkflowYaml() {
424
+ return fs.readFileSync(
425
+ new URL("../templates/native-dev-delivery.yml", import.meta.url),
426
+ "utf8",
427
+ );
428
+ }
401
429
  function writeIfAllowed(filePath, content, { force }) {
402
430
  if (fs.existsSync(filePath) && !force) {
403
- throw new Error(`${posixPath(filePath)} already exists; pass --force to overwrite`);
431
+ throw new Error(
432
+ `${posixPath(filePath)} already exists; pass --force to overwrite`,
433
+ );
404
434
  }
405
435
  fs.mkdirSync(path.dirname(filePath), { recursive: true });
406
436
  fs.writeFileSync(filePath, content);
@@ -408,7 +438,9 @@ function writeIfAllowed(filePath, content, { force }) {
408
438
  }
409
439
 
410
440
  function writeManagedAgentEntry(filePath, current) {
411
- const content = mergePublicationRehearsalAgentInstructions(current);
441
+ const content = mergeNextDevelopmentAgentInstructions(
442
+ mergePublicationRehearsalAgentInstructions(current),
443
+ );
412
444
  fs.mkdirSync(path.dirname(filePath), { recursive: true });
413
445
  fs.writeFileSync(filePath, content);
414
446
  return filePath;
@@ -424,27 +456,33 @@ export function initBuildchainRepo({
424
456
  } = {}) {
425
457
  const resolvedCwd = path.resolve(cwd);
426
458
  const manager = detectOrDefaultPackageManager(resolvedCwd, packageManager);
427
- const toml = appendPublicationRehearsalToml((() => {
428
- if (type === "package") {
429
- return packageToml(resolvedCwd, manager);
430
- }
431
- if (type === "native") {
432
- return nativeToml(resolvedCwd);
433
- }
434
- if (type === "web-surface") {
435
- return webSurfaceToml(resolvedCwd);
436
- }
437
- if (type === "infra-contract") {
438
- return infraContractToml(resolvedCwd);
439
- }
440
- if (type === "publication-artifact") {
441
- return publicationArtifactToml(resolvedCwd);
442
- }
443
- if (type === "anchored-package") {
444
- return anchoredPackageToml(resolvedCwd, manager);
445
- }
446
- throw new Error("init --type must be one of package, native, web-surface, infra-contract, publication-artifact, or anchored-package");
447
- })());
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
+ );
448
486
 
449
487
  const agentsPath = path.join(resolvedCwd, "AGENTS.md");
450
488
  const currentAgents = fs.existsSync(agentsPath)
@@ -452,7 +490,9 @@ export function initBuildchainRepo({
452
490
  : "";
453
491
 
454
492
  const written = [
455
- writeIfAllowed(path.join(resolvedCwd, BUILDCHAIN_CONFIG_PATH), toml, { force }),
493
+ writeIfAllowed(path.join(resolvedCwd, BUILDCHAIN_CONFIG_PATH), toml, {
494
+ force,
495
+ }),
456
496
  writeIfAllowed(
457
497
  path.join(resolvedCwd, ".github", "workflows", "build.yml"),
458
498
  type === "publication-artifact"
@@ -472,14 +512,41 @@ export function initBuildchainRepo({
472
512
  writeManagedAgentEntry(agentsPath, currentAgents),
473
513
  ];
474
514
 
475
- if (type === "anchored-package" && !fs.existsSync(path.join(resolvedCwd, "release.json"))) {
476
- written.push(writeIfAllowed(path.join(resolvedCwd, "release.json"), "{\n \"upstream\": \"\",\n \"version\": \"0.0.0\"\n}\n", { force }));
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
+ );
477
536
  }
478
537
 
479
538
  if (type === "infra-contract") {
480
539
  written.push(
481
- writeIfAllowed(path.join(resolvedCwd, "infra", "desired.json"), infraContractDesiredJson(resolvedCwd), { force }),
482
- writeIfAllowed(path.join(resolvedCwd, "infra", "outputs.json"), infraContractOutputsJson(resolvedCwd), { force }),
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
+ ),
483
550
  );
484
551
  }
485
552
 
@@ -489,7 +556,9 @@ export function initBuildchainRepo({
489
556
  cwd: resolvedCwd,
490
557
  packageManager: manager,
491
558
  workflowRef: BUILDCHAIN_WORKFLOW_REF,
492
- written: written.map((filePath) => posixPath(path.relative(resolvedCwd, filePath))),
559
+ written: written.map((filePath) =>
560
+ posixPath(path.relative(resolvedCwd, filePath)),
561
+ ),
493
562
  };
494
563
  }
495
564
 
@@ -501,7 +570,11 @@ function readArg(name, fallback = "") {
501
570
  return process.argv[index + 1] || "";
502
571
  }
503
572
 
504
- if (!process.env.BUILDCHAIN_EMBEDDED_ENTRYPOINT && process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
573
+ if (
574
+ !process.env.BUILDCHAIN_EMBEDDED_ENTRYPOINT &&
575
+ process.argv[1] &&
576
+ import.meta.url === pathToFileURL(process.argv[1]).href
577
+ ) {
505
578
  try {
506
579
  const result = initBuildchainRepo({
507
580
  cwd: readArg("cwd", process.cwd()),