@kungfu-tech/buildchain 3.0.3-alpha.0 → 3.0.3-alpha.2

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 (115) hide show
  1. package/AGENTS.md +1 -1
  2. package/CONTRIBUTING.md +1 -1
  3. package/README.md +32 -1
  4. package/actions/promote-buildchain-ref/README.md +90 -19
  5. package/actions/report-buildchain-issue/README.md +19 -1
  6. package/actions/run-lifecycle/README.md +5 -0
  7. package/actions/validate-config/README.md +19 -1
  8. package/bin/buildchain.mjs +41 -241
  9. package/bin/internal/command-registry.mjs +82 -0
  10. package/bin/internal/trust-release-cli.mjs +1 -0
  11. package/contracts/auditable-demo-media-profiles-v1.json +116 -1
  12. package/contracts/buildchain-v2-residuals-v1.json +0 -45
  13. package/contracts/evidence/auditable-demo-responsive-web-delivery-v1.json +143 -0
  14. package/contracts/evidence/auditable-demo-web-delivery-v1.json +7 -3
  15. package/contracts/fixtures/auditable-demo-responsive-web-delivery-v1/complete-transcript.txt +2 -0
  16. package/contracts/fixtures/auditable-demo-responsive-web-delivery-v1/public-projection.json +16 -0
  17. package/contracts/fixtures/auditable-demo-responsive-web-delivery-v1/scene.json +12 -0
  18. package/dist/site/buildchain-contract.json +161 -42
  19. package/dist/site/buildchain-site.json +180 -84
  20. package/dist/site/capability-registry.json +6 -6
  21. package/dist/site/cli-registry.json +932 -98
  22. package/dist/site/controller-registry.json +97 -5
  23. package/dist/site/kfd-claims.json +316 -23
  24. package/dist/site/kfd-upstream-aggregate.json +1 -1
  25. package/dist/site/manual-registry.json +20 -20
  26. package/dist/site/node-api-registry.json +371 -56
  27. package/dist/site/page-registry.json +155 -59
  28. package/dist/site/public-surface-audit.json +286 -24
  29. package/dist/site/publication-registry.json +4 -4
  30. package/dist/site/release-provenance.json +3 -0
  31. package/dist/site/site-manifest.json +24 -24
  32. package/dist/site/workflow-registry.json +570 -79
  33. package/docs/MAP.md +22 -4
  34. package/docs/auditable-demo.md +35 -12
  35. package/docs/aws-us-elastic-runner-burst-plane.md +381 -0
  36. package/docs/cli.md +143 -12
  37. package/docs/consumer-issue-reporting.md +19 -1
  38. package/docs/github-governance-authority.md +2 -2
  39. package/docs/lifecycle-protocol.md +20 -2
  40. package/docs/migration-inventory.md +24 -5
  41. package/docs/ownership.md +19 -1
  42. package/docs/publication-artifacts.md +185 -18
  43. package/docs/publication-authority.md +4 -4
  44. package/docs/publish-transaction.md +78 -31
  45. package/docs/release-candidate.md +24 -0
  46. package/docs/release-flow.md +50 -32
  47. package/docs/release-governance.md +31 -31
  48. package/docs/release-passport.md +4 -0
  49. package/docs/release-propagation.md +57 -12
  50. package/docs/reusable-build-surface.md +95 -27
  51. package/docs/runtime-train-validation.md +20 -2
  52. package/docs/stable-candidate-patrol.md +6 -6
  53. package/docs/toolkit-observability.md +22 -0
  54. package/docs/versioning.md +6 -4
  55. package/docs/web-surface-deployments.md +62 -0
  56. package/package.json +7 -5
  57. package/packages/core/README.md +61 -4
  58. package/packages/core/buildchain-contract.js +8 -4
  59. package/packages/core/cache-evidence.js +1 -0
  60. package/packages/core/diagnostics.js +105 -30
  61. package/packages/core/github-governance-authority.js +10 -25
  62. package/packages/core/index.js +40 -0
  63. package/packages/core/paper-fleet.js +260 -0
  64. package/packages/core/paper-repository.js +210 -0
  65. package/packages/core/paper-work.js +365 -0
  66. package/packages/core/paper.js +3180 -0
  67. package/packages/core/public-surface-audit.js +26 -75
  68. package/packages/core/public-surface-cli.js +117 -0
  69. package/packages/core/publication-artifact.js +1 -6
  70. package/packages/core/publication-authority.js +1 -0
  71. package/packages/core/publication-reproducibility.js +947 -0
  72. package/packages/core/publication-sealed-bundle.js +190 -0
  73. package/packages/core/publish-transaction.js +147 -17
  74. package/packages/core/release-candidate.js +234 -0
  75. package/packages/core/release-passport.js +483 -201
  76. package/packages/core/release-propagation.js +175 -1
  77. package/scripts/auditable-demo.mjs +119 -5
  78. package/scripts/aws-codebuild-toolchain.mjs +285 -0
  79. package/scripts/aws-macos-jit-core.mjs +378 -0
  80. package/scripts/aws-macos-jit.mjs +123 -0
  81. package/scripts/aws-runner-burst-core.mjs +248 -0
  82. package/scripts/aws-runner-burst.mjs +79 -0
  83. package/scripts/aws-windows-jit-core.mjs +374 -0
  84. package/scripts/aws-windows-jit.mjs +121 -0
  85. package/scripts/build-contract-core.mjs +69 -6
  86. package/scripts/build-standalone-binary.mjs +23 -0
  87. package/scripts/buildchain-cli-help.mjs +256 -0
  88. package/scripts/buildchain-contract-lock.mjs +1 -1
  89. package/scripts/check-internal-architecture.mjs +69 -2
  90. package/scripts/check-inventory.mjs +69 -2
  91. package/scripts/check-javascript-syntax.mjs +31 -0
  92. package/scripts/check-maintainability.mjs +371 -0
  93. package/scripts/compiler-cache-evidence.mjs +221 -0
  94. package/scripts/dev-alpha-candidate-patrol.mjs +268 -43
  95. package/scripts/finalize-native-artifact-signing-result.mjs +75 -4
  96. package/scripts/generate-channel-promotion-workflow.mjs +3 -12
  97. package/scripts/generate-release-candidate-passport.mjs +4 -0
  98. package/scripts/generate-site-bundle.mjs +68 -188
  99. package/scripts/import-artifact-signing-results.mjs +64 -5
  100. package/scripts/inspect-artifact-signing-requests.mjs +7 -0
  101. package/scripts/maintainability-metrics.mjs +339 -0
  102. package/scripts/npm-publish-transaction.mjs +57 -6
  103. package/scripts/paper-work-fleet-cli.mjs +563 -0
  104. package/scripts/paper.mjs +631 -0
  105. package/scripts/promotion-channel-router.mjs +16 -4
  106. package/scripts/publication-reproducibility.mjs +62 -0
  107. package/scripts/release-propagation.mjs +39 -0
  108. package/scripts/resolve-build-contract.mjs +6 -0
  109. package/scripts/route-offline-runners.mjs +236 -0
  110. package/scripts/run-lifecycle-core.mjs +62 -1
  111. package/scripts/runtime-ref-core.mjs +23 -2
  112. package/scripts/seal-artifact-signing-requests.mjs +13 -6
  113. package/scripts/site-capability-metadata.mjs +202 -0
  114. package/scripts/stable-candidate-qualification.mjs +42 -0
  115. package/scripts/web-surface-core.mjs +272 -86
package/docs/cli.md CHANGED
@@ -1,3 +1,21 @@
1
+ ---
2
+ status: active
3
+ period: ongoing
4
+ theme: buildchain-cli
5
+ doc_type: technical-reference
6
+ source_level: local-files
7
+ confidence: high
8
+ sensitivity: public
9
+ evidence_grade: A
10
+ review_state: unreviewed
11
+ last_reviewed: 2026-07-31
12
+ ai_provenance:
13
+ model_family: GPT-5
14
+ product: Codex
15
+ generated_at: 2026-07-31
16
+ invisible_context: not asserted
17
+ ---
18
+
1
19
  # Buildchain CLI, npm Package, and Toolkit API
2
20
 
3
21
  Buildchain is published as the public npm package
@@ -76,6 +94,8 @@ import { collectReadmeBadgeFacts } from "@kungfu-tech/buildchain/readme-badges";
76
94
  import { verifyReleasePassport } from "@kungfu-tech/buildchain/release-passport";
77
95
  import { verifyGitHubArtifactAttestationEvidence } from "@kungfu-tech/buildchain/github-artifact-attestation";
78
96
  import { createReleasePropagationPlan } from "@kungfu-tech/buildchain/release-propagation";
97
+ import { verifyPublicationReproducibility } from "@kungfu-tech/buildchain/publication-reproducibility";
98
+ import { collectPaperStatus } from "@kungfu-tech/buildchain/paper";
79
99
  import { planReleaseLineBootstrap } from "@kungfu-tech/buildchain/release-line-bootstrap";
80
100
  import { collectPublicSurfaceReverseAudit } from "@kungfu-tech/buildchain/public-surface-audit";
81
101
  import { createBuildchainLayoutDiscovery } from "@kungfu-tech/buildchain/buildchain-layout";
@@ -101,6 +121,94 @@ with the exact signer/source policy and then verifies the retained bundle,
101
121
  predicate, platform manifest, Passport, and Buildchain evidence locally. See
102
122
  [`github-artifact-attestation.md`](github-artifact-attestation.md).
103
123
 
124
+ ### Governed paper lifecycle
125
+
126
+ `buildchain paper` is the unified operator surface for one paper repository or
127
+ a discovered fleet. Every subcommand returns a versioned JSON contract with
128
+ `--json`:
129
+
130
+ ```bash
131
+ buildchain paper scaffold --package @kungfu-tech/paper-example \
132
+ --repository kungfu-systems/paper-example
133
+ buildchain paper migrate --json
134
+ buildchain paper work start golden-path --json
135
+ buildchain paper work submit --json
136
+ buildchain paper fleet audit --root ../papers --json
137
+ buildchain paper fleet update --root ../paper-worktrees --json
138
+ buildchain paper preflight --offline --json
139
+ buildchain paper bootstrap npm --json
140
+ buildchain paper build --json
141
+ buildchain paper alpha --json
142
+ buildchain paper status --json
143
+ buildchain paper resume --json
144
+ ```
145
+
146
+ The safety and authority boundary is explicit:
147
+
148
+ - `scaffold` plans a 14-file, no-overwrite repository shape by default; add
149
+ `--write` to create only missing files.
150
+ - `migrate` plans the Buildchain-owned authority, workflow, contract lock,
151
+ version pin, and package control changes needed by an existing paper
152
+ repository. It pins an exact v3 dependency and adds pnpm-backed paper scripts.
153
+ Add `--write` only after reviewing exact old and new digests; paper content
154
+ and publication configuration are never rewritten. Refresh
155
+ `pnpm-lock.yaml` with `pnpm install --lockfile-only` after a write.
156
+ - `work start` derives the protected development branch from the configured
157
+ publication semver line and creates a safe local work branch only when the
158
+ worktree is clean, the sole `origin` is the canonical `kungfu-systems`
159
+ repository, and local HEAD equals the exact remotely observed development
160
+ SHA. It never fetches or merges silently.
161
+ - `work submit` accepts only an allowed non-protected work branch that contains
162
+ the exact remote development commit. It rejects divergent remote work,
163
+ wrong-base pull requests, dirty trees, forks, and ambiguous remotes; execution
164
+ uses a normal non-force push and opens or reuses a PR to the derived
165
+ development branch.
166
+ - `fleet audit` discovers `paper-*` repositories from a root and emits one
167
+ deterministic audit root over exact runtime, dependency, lockfile, workflow,
168
+ authority, and repository observations. `fleet update` reuses the migration
169
+ contract for every discovered repository, remains dry-run by default, and
170
+ refuses protected or non-work branches.
171
+ - The scaffolded `.buildchain/paper/provisioning-authority.json` binds both
172
+ caller workflow byte digests, their exact reusable-workflow SHA, the runtime
173
+ SHA, contract-lock bytes, npm registry and trusted-publisher coordinates, and
174
+ the repository Actions/generated-write policy under one digest. A floating
175
+ Buildchain ref cannot change release policy after that authority is accepted.
176
+ - `preflight` separates local readiness from readiness for external mutation.
177
+ `--offline` skips live GitHub and npm observations without treating them as
178
+ local failures. Live readiness requires default workflow permissions `read`,
179
+ Actions pull-request approval disabled, and GitHub App or equivalent narrow
180
+ generated-write credential metadata.
181
+ - `bootstrap npm` always performs npm pack and publish dry-runs first. A real
182
+ public bootstrap requires both `--execute` and
183
+ `--confirm-public-package <exact-name>`, uses only the official npm registry,
184
+ fixes the bootstrap version at `0.0.0-bootstrap.0`, and returns only npm URLs
185
+ observed from command output. Success requires public package readback and
186
+ the exact repository/workflow/environment trusted-publisher binding. For
187
+ GitHub, the npm coordinate is the workflow filename (`paper-release.yml`),
188
+ not its `.github/workflows/` repository path.
189
+ - `build` plans the two-clean-build reproducibility proof. Add `--execute` to
190
+ create and verify the sealed publication bundle.
191
+ - `alpha` plans or opens the protected Alpha pull request; it never merges,
192
+ publishes, or advances a floating ref.
193
+ - `status` reports only evidence found in the repository or external
194
+ observations. It never infers a later lifecycle state from an earlier one.
195
+ - `resume` plans or dispatches the repository's thin release workflow; the
196
+ protected workflow remains the release authority.
197
+
198
+ The ordered evidence states are `scaffolded`, `governed`, `admitted`,
199
+ `bootstrapped`, `trust-bound`, `content-ready`, `artifact-sealed`,
200
+ `package-published`, `alpha-complete`, `staging-visible`, and
201
+ `production-visible`. A state can be `satisfied`, `not-reached`, `blocked`, or
202
+ `unknown`; consumers must not collapse those distinctions.
203
+
204
+ The corresponding Node surface is
205
+ `@kungfu-tech/buildchain/paper`. Planning and status functions are read-only;
206
+ `writePaperScaffold()`, `writePaperMigration()`, and
207
+ `writePaperFleetUpdate()` are the bounded local writers. Work plans expose
208
+ separate rechecking executors for local branch creation and normal push, and
209
+ `executePaperNpmBootstrap()` preserves the same confirmation boundary used by
210
+ the CLI.
211
+
104
212
  `buildchain layout` is the stable machine question for repository layout. Tools
105
213
  such as Shifu should call it instead of copying `.buildchain/` path constants:
106
214
 
@@ -249,9 +357,9 @@ branch action, and initial version before any GitHub mutation happens:
249
357
 
250
358
  ```bash
251
359
  buildchain release line open \
252
- --major 2 \
253
- --minor 10 \
254
- --source-ref release/v2/v2.9 \
360
+ --major 3 \
361
+ --minor 1 \
362
+ --source-ref release/v3/v3.0 \
255
363
  --json
256
364
  ```
257
365
 
@@ -264,9 +372,9 @@ reconciliation succeeds, and opens the first dev-to-alpha channel PR:
264
372
 
265
373
  ```bash
266
374
  buildchain release line open \
267
- --major 2 \
268
- --minor 10 \
269
- --source-ref release/v2/v2.9 \
375
+ --major 3 \
376
+ --minor 1 \
377
+ --source-ref release/v3/v3.0 \
270
378
  --write \
271
379
  --json
272
380
  ```
@@ -284,7 +392,9 @@ import {
284
392
  assertPublicSurfaceReverseAudit,
285
393
  } from "@kungfu-tech/buildchain/public-surface-audit";
286
394
 
287
- assertPublicSurfaceReverseAudit(collectPublicSurfaceReverseAudit({ root: process.cwd() }));
395
+ assertPublicSurfaceReverseAudit(
396
+ collectPublicSurfaceReverseAudit({ root: process.cwd() }),
397
+ );
288
398
  ```
289
399
 
290
400
  `buildchain kfd` is the product-facing KFD namespace. Schema commands expose the
@@ -398,7 +508,10 @@ The event protocol is JSONL and is also available from the SDK:
398
508
  ```js
399
509
  import { createBuildchainLogger } from "@kungfu-tech/buildchain/logging";
400
510
 
401
- const logger = createBuildchainLogger({ source: "user", component: "native-build" });
511
+ const logger = createBuildchainLogger({
512
+ source: "user",
513
+ component: "native-build",
514
+ });
402
515
  logger.mark("configure.ready", { phase: "configure" });
403
516
  ```
404
517
 
@@ -530,6 +643,24 @@ buildchain publication-artifact manifest \
530
643
  --json
531
644
  ```
532
645
 
646
+ Run the fail-closed clean-room gate before Alpha or release admission:
647
+
648
+ ```bash
649
+ buildchain publication-artifact reproducibility \
650
+ --source-sha "$(git rev-parse HEAD)" \
651
+ --promote \
652
+ --json
653
+ ```
654
+
655
+ The command checks two independent clones of the exact commit, isolates caches,
656
+ derives `SOURCE_DATE_EPOCH` from Git, and compares every declared artifact,
657
+ source bundle, publication evidence file, npm package file, and actual npm
658
+ tarball. It writes
659
+ `.buildchain/publication/reproducibility-receipt.json`. Only a byte-identical
660
+ build using the digest-pinned `latex-docker` toolchain is qualifying.
661
+ `--allow-unpinned-toolchain` exists for local diagnostics and never changes the
662
+ receipt's `qualifying` field.
663
+
533
664
  Generate the Buildchain-owned npm paper package contents from declared
534
665
  publication facts:
535
666
 
@@ -629,7 +760,7 @@ buildchain collect github-release \
629
760
  --kfd-2-claim-json .buildchain/kfd/kfd-2/release-claims.json \
630
761
  --kfd-3-prebuild-witness-json .buildchain/kfd/kfd-3/collaboration-interface.prebuild.json \
631
762
  --kfd-3-artifact-verify-cmd "kungfu agent verify --json" \
632
- --release-extra-json '{"channel":"release","targetRef":"release/v2/v2.3"}' \
763
+ --release-extra-json '{"channel":"release","targetRef":"release/v3/v3.0"}' \
633
764
  --output-dir .buildchain/release-passport
634
765
  ```
635
766
 
@@ -880,9 +1011,9 @@ Buildchain's own npm package is published from
880
1011
  `.github/workflows/buildchain-ref-promotion.yml`, inside the same publish
881
1012
  transaction that promotes release refs:
882
1013
 
883
- - `v2.0.13-alpha.0` publishes to npm with dist-tag `alpha`.
884
- - `v2.0.13` publishes to npm with dist-tag `latest`.
885
- - moving refs such as `v2`, `v2.0`, and `v2.0-alpha` do not match the publish
1014
+ - `v3.0.3-alpha.0` publishes to npm with dist-tag `alpha`.
1015
+ - `v3.0.2` publishes to npm with dist-tag `latest`.
1016
+ - moving refs such as `v3`, `v3.0`, and `v3.0-alpha` do not match the publish
886
1017
  workflow and do not publish.
887
1018
 
888
1019
  The promotion workflow uses npm Trusted Publishing through GitHub Actions OIDC.
@@ -1,3 +1,21 @@
1
+ ---
2
+ status: active
3
+ period: ongoing
4
+ theme: buildchain-consumer-issue-reporting
5
+ doc_type: technical-reference
6
+ source_level: local-files
7
+ confidence: high
8
+ sensitivity: public
9
+ evidence_grade: A
10
+ review_state: unreviewed
11
+ last_reviewed: 2026-07-31
12
+ ai_provenance:
13
+ model_family: GPT-5
14
+ product: Codex
15
+ generated_at: 2026-07-31
16
+ invisible_context: not asserted
17
+ ---
18
+
1
19
  # Consumer Issue Reporting
2
20
 
3
21
  Buildchain ships a first-class issue reporting surface for consumer workflows.
@@ -73,7 +91,7 @@ const result = await reportBuildchainIssue({
73
91
  token: process.env.BUILDCHAIN_ISSUE_TOKEN,
74
92
  summary: "Native artifact manifest is incomplete",
75
93
  failureCode: "native-manifest-incomplete",
76
- buildchainRef: "v2",
94
+ buildchainRef: "v3",
77
95
  diagnosticsPath: ".buildchain/artifacts/diagnostics.json",
78
96
  });
79
97
  ```
@@ -8,7 +8,7 @@ confidence: high
8
8
  sensitivity: public
9
9
  evidence_grade: B
10
10
  review_state: unreviewed
11
- last_reviewed: 2026-07-30
11
+ last_reviewed: 2026-07-31
12
12
  ai_provenance:
13
13
  model_family: GPT-5
14
14
  product: Codex
@@ -234,7 +234,7 @@ branch; unrelated rules and conditions are preserved in place.
234
234
  ```bash
235
235
  buildchain github-governance ruleset-policy-plan \
236
236
  --repository kungfu-systems/buildchain \
237
- --branch alpha/v2/v2.14 \
237
+ --branch alpha/v3/v3.0 \
238
238
  --ruleset-id 19518955 \
239
239
  --snapshot-output ruleset-rollback.json \
240
240
  --plan-output ruleset-rollout.json
@@ -1,6 +1,24 @@
1
+ ---
2
+ status: active
3
+ period: ongoing
4
+ theme: buildchain-lifecycle-protocol
5
+ doc_type: technical-reference
6
+ source_level: local-files
7
+ confidence: high
8
+ sensitivity: public
9
+ evidence_grade: A
10
+ review_state: unreviewed
11
+ last_reviewed: 2026-07-31
12
+ ai_provenance:
13
+ model_family: GPT-5
14
+ product: Codex
15
+ generated_at: 2026-07-31
16
+ invisible_context: not asserted
17
+ ---
18
+
1
19
  # Lifecycle Protocol
2
20
 
3
- Buildchain uses `.buildchain/buildchain.toml` as the v2 repository configuration format.
21
+ Buildchain uses `.buildchain/buildchain.toml` as the v3 repository configuration format.
4
22
  The file is optional for simple JavaScript repositories, but it is the preferred
5
23
  way to describe release version state and lifecycle commands when a project is
6
24
  not a plain pnpm, npm, or yarn workspace.
@@ -10,7 +28,7 @@ For compatibility, Buildchain still reads a legacy root `buildchain.toml` when
10
28
  `.buildchain/` layout so all Buildchain-owned local state lives under one
11
29
  directory.
12
30
 
13
- Only TOML is supported in v2. YAML, JSON, and JavaScript config files are not
31
+ Only TOML is supported in v3. YAML, JSON, and JavaScript config files are not
14
32
  loaded.
15
33
 
16
34
  ## Minimal File
@@ -1,9 +1,28 @@
1
+ ---
2
+ status: historical
3
+ period: 2026-07
4
+ theme: buildchain-v2-migration-inventory
5
+ doc_type: migration-inventory
6
+ source_level: local-files
7
+ confidence: high
8
+ sensitivity: public
9
+ evidence_grade: A
10
+ review_state: unreviewed
11
+ last_reviewed: 2026-07-31
12
+ ai_provenance:
13
+ model_family: GPT-5
14
+ product: Codex
15
+ generated_at: 2026-07-31
16
+ invisible_context: not asserted
17
+ ---
18
+
1
19
  # Buildchain v2 Migration Inventory
2
20
 
3
- This inventory records the buildchain v2 action surface. Buildchain v2 is the
4
- monorepo source of truth for active Kungfu repository workflows, the active
5
- reusable build workflow, and the three GitHub Actions that are still part of
6
- Buildchain's reusable contract.
21
+ This historical inventory records the Buildchain v2 consolidation boundary.
22
+ Buildchain v3 is now the active monorepo source of truth for Kungfu repository
23
+ workflows, reusable build workflows, and Buildchain-native actions. The v2
24
+ names below preserve the migration decisions that v3 inherited; they are not a
25
+ current runtime baseline.
7
26
  Standalone `workflows` and `action-*` repositories are historical rollback
8
27
  anchors, not active Buildchain migration targets.
9
28
 
@@ -111,7 +130,7 @@ older standalone action repository.
111
130
  | `actions/run-lifecycle` | lifecycle command execution and deterministic artifact manifest generation |
112
131
  | `actions/validate-config` | `buildchain.toml` version-state and lifecycle preflight without executing lifecycle commands |
113
132
 
114
- ## Stable v2 Refs
133
+ ## Current v3 Refs
115
134
 
116
135
  - Actions: `kungfu-systems/buildchain/actions/<name>@v3`
117
136
  - Reusable workflows: `kungfu-systems/buildchain/.github/workflows/<workflow>.yml@v3`
package/docs/ownership.md CHANGED
@@ -1,8 +1,26 @@
1
+ ---
2
+ status: active
3
+ period: ongoing
4
+ theme: buildchain-ownership-and-migration
5
+ doc_type: technical-reference
6
+ source_level: local-files
7
+ confidence: high
8
+ sensitivity: public
9
+ evidence_grade: A
10
+ review_state: unreviewed
11
+ last_reviewed: 2026-07-31
12
+ ai_provenance:
13
+ model_family: GPT-5
14
+ product: Codex
15
+ generated_at: 2026-07-31
16
+ invisible_context: not asserted
17
+ ---
18
+
1
19
  # Ownership And Migration Rules
2
20
 
3
21
  ## Source Of Truth
4
22
 
5
- Buildchain v2 workflow and action design lands in this repository. Standalone
23
+ Buildchain v3 workflow and action design lands in this repository. Standalone
6
24
  `workflows` and `action-*` repositories are historical rollback anchors.
7
25
  Buildchain only ships the native action surface required for config validation,
8
26
  lifecycle execution, and release ref promotion.
@@ -106,6 +106,37 @@ for compatibility, but the passport records it as lower trust because
106
106
  Buildchain can record the command boundary without proving the compiler or
107
107
  LaTeX distribution digest.
108
108
 
109
+ ## Reproducibility Gate
110
+
111
+ Alpha and release admission require
112
+ `.buildchain/publication/reproducibility-receipt.json`. Buildchain creates the
113
+ receipt by cloning the exact checked-out Git commit into two independent local
114
+ repositories, assigning each build a separate home and npm cache, and deriving
115
+ `SOURCE_DATE_EPOCH` from the source commit. A pinned `latex-docker` build runs
116
+ with UTC, `C.UTF-8`, no build-time network, and the exact image digest declared
117
+ in `[publication.toolchain]`.
118
+
119
+ Each clean build independently creates the PDF set, source bundle, publication
120
+ manifest and passport, append-only registry, synthesized npm package directory,
121
+ and an actual npm tarball. After qualification, Buildchain copies the first
122
+ qualifying tarball into the promoted publication candidate instead of deleting
123
+ it with the temporary clean build. The receipt compares exact bytes and records:
124
+
125
+ - source repository, commit, tree, and `SOURCE_DATE_EPOCH`;
126
+ - toolchain image, digest, command, and toolchain identity root;
127
+ - every artifact and evidence path with byte size and SHA-256;
128
+ - npm tarball SHA-256, SHA-1 shasum, and `sha512` integrity;
129
+ - per-build output-set roots and the first differing field or artifact.
130
+
131
+ The gate is fail-closed. A build-only `custom-command` run can diagnose byte
132
+ drift and promote its byte-identical local output with
133
+ `--allow-unpinned-toolchain`, but it is never a qualifying publication receipt.
134
+ Any workflow that prepares a publishable paper package accepts only a
135
+ digest-pinned toolchain and promotes the first clean build into the publication
136
+ candidate only after both builds are byte-identical. The receipt remains
137
+ outside the npm tarball to avoid a circular digest; it binds the tarball bytes
138
+ from the surrounding sealed publication evidence.
139
+
109
140
  `publish.kind = "npm-paper-package"` declares that Buildchain, not the consumer
110
141
  repository, owns the standard paper npm package shape and release transaction
111
142
  mechanics. `publish.package` is the public npm package that contains the PDF,
@@ -134,14 +165,18 @@ The build-only workflow:
134
165
  any paper build runs;
135
166
  - resolves the declared publication toolchain from `[publication.toolchain]` or
136
167
  workflow inputs;
168
+ - hydrates authenticated registry history before building so both clean
169
+ candidates include the same append-only history;
137
170
  - for `latex-docker`, pulls the pinned build-images LaTeX builder digest and
138
- runs the declared command in the container;
171
+ runs two independent clean builds with the reproducibility policy above;
139
172
  - for `custom-command`, runs the declared command and records the lower-trust
140
- boundary in the passport;
173
+ boundary in the passport, but refuses publication qualification;
141
174
  - runs the verify command;
142
175
  - creates a source bundle from `publication.source_paths`;
143
176
  - writes `.buildchain/publication/publication-artifact.json`;
144
177
  - writes `.buildchain/publication/publication-artifact-passport.json`;
178
+ - writes a qualifying
179
+ `.buildchain/publication/reproducibility-receipt.json`;
145
180
  - when `[publication.archive]` is configured, writes
146
181
  `.buildchain/publication/publication-registry.json` and verifies same-version
147
182
  immutability;
@@ -174,36 +209,36 @@ on:
174
209
  - alpha/v1/v1.0
175
210
  - release/v1/v1.0
176
211
  workflow_dispatch:
177
- inputs:
178
- buildchain-ref:
179
- description: "Temporary Buildchain runtime ref"
180
- required: false
181
- default: ""
182
212
 
183
213
  jobs:
184
214
  paper-release:
185
- uses: kungfu-systems/buildchain/.github/workflows/paper-release-sealed.yml@v3
215
+ uses: kungfu-systems/buildchain/.github/workflows/paper-release-sealed.yml@<exact-buildchain-sha>
186
216
  permissions:
187
217
  actions: read
188
218
  checks: write
189
- contents: write
219
+ contents: read
190
220
  id-token: write
191
221
  issues: write
192
222
  with:
193
- buildchain-ref: ${{ inputs.buildchain-ref || '' }}
223
+ buildchain-ref: <exact-buildchain-sha>
194
224
  publisher-workflow-path: .github/workflows/paper-release.yml
195
225
  toolchain-type: config
196
226
  verify-command: make check
197
227
  artifact-paths: _build/paper-name.pdf
198
228
  buildchain-contract-lock-path: .buildchain/contract-lock.json
199
229
  secrets:
200
- BUILDCHAIN_PROMOTION_TOKEN: ${{ secrets.BUILDCHAIN_PROMOTION_TOKEN }}
230
+ BUILDCHAIN_GENERATED_WRITE_APP_CLIENT_ID: ${{ secrets.BUILDCHAIN_GENERATED_WRITE_APP_CLIENT_ID }}
231
+ BUILDCHAIN_GENERATED_WRITE_APP_PRIVATE_KEY: ${{ secrets.BUILDCHAIN_GENERATED_WRITE_APP_PRIVATE_KEY }}
232
+ BUILDCHAIN_GENERATED_WRITE_TOKEN: ${{ secrets.BUILDCHAIN_GENERATED_WRITE_TOKEN }}
201
233
  ```
202
234
 
203
- The sealed preset does not use a long-lived token for npm publication. It may
204
- accept an optional `BUILDCHAIN_PROMOTION_TOKEN` only for machine-generated
205
- version-state updates on protected channel branches; npm publication remains
206
- bound to GitHub OIDC trusted publishing. The preset builds and packages the
235
+ The sealed preset does not use a long-lived token for npm publication. It
236
+ prefers a repository-scoped GitHub App installation token for generated
237
+ repository writes and accepts `BUILDCHAIN_GENERATED_WRITE_TOKEN` as an
238
+ equivalent narrow compatibility authority. The deprecated
239
+ `BUILDCHAIN_PROMOTION_TOKEN` name remains accepted for existing consumers, but
240
+ there is no `github.token` fallback for generated writes. npm publication
241
+ remains bound to GitHub OIDC trusted publishing. The preset builds and packages the
207
242
  paper in a read-only job, then a credential-free authority job downloads that
208
243
  exact candidate, audits the external control plane, and seals a capability over
209
244
  the source tree, Buildchain runtime, controller receipt, PDF, and npm package
@@ -214,8 +249,9 @@ workflow named by `publisher-workflow-path`.
214
249
 
215
250
  The preset:
216
251
 
217
- - resolves the floating Buildchain runtime once and binds the exact SHA into the
218
- publication candidate and authority capability;
252
+ - uses the exact Buildchain SHA admitted by the provisioning authority and
253
+ binds it into the caller bytes, contract lock, publication candidate, and
254
+ authority capability;
219
255
  - builds the PDF through the declared pinned LaTeX Docker toolchain or custom
220
256
  command in a read-only job;
221
257
  - verifies the paper repository;
@@ -229,7 +265,13 @@ The preset:
229
265
  channel commit and requires `promote-buildchain-ref` to verify that lock
230
266
  before any publish side effect;
231
267
  - verifies the complete candidate again after authority and publishes the
232
- package through npm Trusted Publishing without rebuilding it;
268
+ package through npm Trusted Publishing without rebuilding or repacking it;
269
+ - writes a typed sealed-bundle manifest that binds the candidate root, exact
270
+ npm tarball, every GitHub Release asset, durable storage path, and resume
271
+ command;
272
+ - persists the complete binary bundle to the transaction's durable release-state
273
+ ref before npm receives credentials, allowing an empty runner to restore and
274
+ verify the same bytes after interruption;
233
275
  - writes Buildchain release/passport evidence; and
234
276
  - creates or updates the exact-version GitHub Release by default, uploading
235
277
  every file declared by `publication.primary_artifact` and
@@ -239,6 +281,17 @@ Consumers can opt out of the GitHub Release with `github-release: false`, but
239
281
  the default is on so downstream release propagation can observe
240
282
  `release.published` without hand-written `gh release` steps.
241
283
 
284
+ The transaction exposes a stable publication progression:
285
+
286
+ ```text
287
+ prepared -> sealed -> package-published -> alpha-complete
288
+ ```
289
+
290
+ Stable publication ends at `release-complete`. If a run stops after npm but
291
+ before GitHub Release completion, the next run starts from
292
+ `package-published`, restores the sealed PDF and companion assets, and finishes
293
+ the release without invoking the paper build or `npm pack` again.
294
+
242
295
  Declared publication artifacts are resolved from the generated publication
243
296
  manifest rather than repeated in consumer workflow YAML. Publication fails
244
297
  before upload if a declared artifact is missing or if its basename would
@@ -256,12 +309,119 @@ Buildchain rather than forking the mechanics into each paper repository.
256
309
 
257
310
  ## CLI And Node API
258
311
 
312
+ ### Unified paper operator surface
313
+
314
+ The `buildchain paper` command family assembles the existing publication
315
+ primitives into a resumable operator flow:
316
+
317
+ ```text
318
+ scaffold/new or migrate/existing -> preflight -> bootstrap npm -> build -> alpha -> status -> resume
319
+ ```
320
+
321
+ Each command emits a typed JSON envelope with `--json`. Dry-run is the default
322
+ for every external mutation. `scaffold --write` is limited to no-overwrite
323
+ local file creation. `migrate --write` is limited to the Buildchain-owned
324
+ contract lock, version pin, thin workflows, and provisioning authority; paper
325
+ content and publication configuration are preserved. `bootstrap npm --execute`, `alpha --execute`, and
326
+ `resume --execute` cross external authority boundaries and therefore require
327
+ explicit execution.
328
+
329
+ The evidence model is intentionally non-inferential:
330
+
331
+ | State | Required evidence |
332
+ | -------------------- | -------------------------------------------------------- |
333
+ | `scaffolded` | Complete managed scaffold inventory |
334
+ | `governed` | Compatible Buildchain contract lock |
335
+ | `admitted` | Repository admission receipt |
336
+ | `bootstrapped` | Successful public npm bootstrap receipt or registry fact |
337
+ | `trust-bound` | Trusted publisher binding receipt |
338
+ | `content-ready` | Declared source paths present |
339
+ | `artifact-sealed` | Verified sealed publication bundle |
340
+ | `package-published` | Exact package version visible in npm |
341
+ | `alpha-complete` | Protected Alpha PR completion evidence |
342
+ | `staging-visible` | Staging route evidence |
343
+ | `production-visible` | Production route evidence |
344
+
345
+ `paper status` reports `satisfied`, `not-reached`, `blocked`, or `unknown` for
346
+ each state. It does not promote a state merely because a prior state is
347
+ complete. This makes a later `paper resume` safe: the command dispatches the
348
+ thin repository release workflow, while the workflow re-verifies durable
349
+ evidence and remains the publication authority.
350
+
351
+ Operationally, responsibility remains split:
352
+
353
+ - the paper repository owns content, declared metadata, and its thin
354
+ build/release workflow;
355
+ - Buildchain owns scaffold shape, evidence contracts, reproducibility, sealed
356
+ bundle mechanics, npm transaction mechanics, and resumption planning;
357
+ - GitHub branch protection and trusted publishing own authority transitions;
358
+ - the papers site consumes publication evidence and owns reader-facing
359
+ rendering.
360
+
361
+ Daily work begins and ends through the repository-pinned v3 CLI:
362
+
363
+ ```sh
364
+ pnpm paper:work:start -- golden-path
365
+ # edit, test, and commit paper source
366
+ pnpm paper:work:submit
367
+ ```
368
+
369
+ The start plan derives `dev/vN/vN.M` from `publication.version` and requires
370
+ local HEAD to equal the exact canonical remote development SHA. The submit plan
371
+ allows only a non-protected work branch containing that SHA, a clean committed
372
+ tree, a normal fast-forward push, and a pull request back to the same derived
373
+ development branch. Neither command force-pushes, guesses a fork target, or
374
+ silently fetches and merges stale state.
375
+
376
+ Maintainers can inspect a sibling fleet without per-repository command copies:
377
+
378
+ ```sh
379
+ buildchain paper fleet audit --root /path/to/papers --json
380
+ buildchain paper fleet update --root /path/to/isolated-paper-worktrees --json
381
+ ```
382
+
383
+ Fleet update is dry-run first and accepts only isolated work branches. Its
384
+ typed plan carries exact-old and expected-new digests for the same owned
385
+ surfaces as `paper migrate`; `--write` also refreshes each pnpm lockfile. It
386
+ never rewrites paper content or publication configuration.
387
+
388
+ Run a local readiness check without network observations:
389
+
390
+ ```sh
391
+ buildchain paper preflight --offline --json
392
+ buildchain paper status --json
393
+ ```
394
+
395
+ Before real npm bootstrap, first inspect the default dry-run result:
396
+
397
+ ```sh
398
+ buildchain paper bootstrap npm --json
399
+ ```
400
+
401
+ Only after reviewing the package, repository, workflow, and dry-run evidence:
402
+
403
+ ```sh
404
+ buildchain paper bootstrap npm \
405
+ --execute \
406
+ --confirm-public-package @kungfu-tech/paper-example \
407
+ --json
408
+ ```
409
+
259
410
  Generate the publication manifest locally or in CI:
260
411
 
261
412
  ```sh
262
413
  buildchain publication-artifact manifest --source-sha "$(git rev-parse HEAD)" --json
263
414
  ```
264
415
 
416
+ Prove the complete candidate from two clean builds:
417
+
418
+ ```sh
419
+ buildchain publication-artifact reproducibility \
420
+ --source-sha "$(git rev-parse HEAD)" \
421
+ --promote \
422
+ --json
423
+ ```
424
+
265
425
  Generate the npm package contents after the manifest exists:
266
426
 
267
427
  ```sh
@@ -280,6 +440,13 @@ import {
280
440
  collectPublicationPackageFacts,
281
441
  preparePublicationNpmPackage,
282
442
  } from "@kungfu-tech/buildchain/publication-package";
443
+
444
+ import { verifyPublicationReproducibility } from "@kungfu-tech/buildchain/publication-reproducibility";
445
+
446
+ import {
447
+ createPublicationSealedBundle,
448
+ verifyPublicationSealedBundle,
449
+ } from "@kungfu-tech/buildchain/publication-sealed-bundle";
283
450
  ```
284
451
 
285
452
  `writePublicationArtifact()` is the single implementation used by the CLI and