@kungfu-tech/buildchain 4.1.3 → 4.1.4-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 (199) hide show
  1. package/AGENTS.md +11 -13
  2. package/CONTRIBUTING.md +32 -9
  3. package/README.md +56 -140
  4. package/actions/release/promotion/ref/README.md +1 -1
  5. package/architecture/action-taxonomy.json +1 -1
  6. package/architecture/agent-change-map.md +32 -45
  7. package/architecture/build-orchestration.json +1 -1
  8. package/architecture/capability-state-machine-manifest.json +5 -5
  9. package/architecture/ci-lane-change-budget.json +92 -92
  10. package/architecture/code-layout.json +2 -12
  11. package/architecture/core-mechanisms.json +38 -39
  12. package/architecture/cross-platform-adopter-qualification.json +1 -1
  13. package/architecture/dev-delivery-orchestration.json +2 -2
  14. package/architecture/floating-consumer-policy.json +3 -3
  15. package/architecture/internal-capabilities.json +27 -28
  16. package/architecture/maintainability-debt.json +60 -94
  17. package/architecture/maintainability-policy.json +7 -13
  18. package/architecture/minimal-consumer-migration.json +43 -5014
  19. package/architecture/platform-stage-checkpoints.json +1 -1
  20. package/architecture/release-tail-contract.json +2 -2
  21. package/architecture/release-topology.json +31 -25
  22. package/architecture/stage-capsule-qualification.json +1 -1
  23. package/architecture/universal-workflow-bootstrap.json +60 -60
  24. package/architecture/universal-workflow-capability-policy.json +3 -3
  25. package/architecture/universal-workflow-fault-campaign.json +7 -7
  26. package/architecture/workflow-taxonomy.json +59 -60
  27. package/contracts/fixtures/v4-tail-reseal-v1/valid.json +1 -1
  28. package/dist/site/buildchain-contract.json +138 -66
  29. package/dist/site/buildchain-site.json +257 -331
  30. package/dist/site/capability-registry.json +4 -4
  31. package/dist/site/cli-registry.json +6 -142
  32. package/dist/site/controller-registry.json +19 -19
  33. package/dist/site/kfd-claims.json +481 -529
  34. package/dist/site/kfd-upstream-aggregate.json +1 -1
  35. package/dist/site/manual-registry.json +22 -22
  36. package/dist/site/node-api-registry.json +82 -339
  37. package/dist/site/page-registry.json +229 -304
  38. package/dist/site/public-surface-audit.json +544 -754
  39. package/dist/site/publication-authority-registry.json +316 -316
  40. package/dist/site/publication-registry.json +1 -1
  41. package/dist/site/site-manifest.json +23 -23
  42. package/dist/site/workflow-registry.json +1071 -1027
  43. package/docs/MAP.md +28 -20
  44. package/docs/auditable-demo.md +17 -49
  45. package/docs/bootstrap-recovery.md +46 -37
  46. package/docs/cli-reference.md +2 -46
  47. package/docs/cli.md +97 -186
  48. package/docs/code-organization.md +7 -5
  49. package/docs/dev-alpha-candidate-patrol.md +19 -42
  50. package/docs/dev-delivery-orchestration.md +15 -11
  51. package/docs/dev-delivery-qualification-landing-adr.md +10 -9
  52. package/docs/dev-delivery-warrant.md +17 -16
  53. package/docs/dev-qualification-patrol.md +25 -20
  54. package/docs/getting-started.md +80 -139
  55. package/docs/github-artifact-attestation.md +31 -81
  56. package/docs/install.md +66 -30
  57. package/docs/lifecycle-protocol.md +19 -57
  58. package/docs/migration-inventory.md +17 -45
  59. package/docs/next-development-transition.md +13 -13
  60. package/docs/node-api-reference.md +122 -138
  61. package/docs/oci-publication.md +13 -10
  62. package/docs/publication-artifacts.md +128 -486
  63. package/docs/publication-authority.md +15 -45
  64. package/docs/publish-transaction.md +13 -11
  65. package/docs/release-candidate.md +126 -355
  66. package/docs/release-discussions.md +36 -67
  67. package/docs/release-flow.md +80 -339
  68. package/docs/release-governance.md +114 -962
  69. package/docs/release-promotion-request.md +45 -43
  70. package/docs/release-propagation.md +13 -27
  71. package/docs/release-tail-provider-plane.md +38 -65
  72. package/docs/reusable-build-surface.md +78 -196
  73. package/docs/runtime-train-validation.md +8 -6
  74. package/docs/stable-candidate-patrol.md +13 -66
  75. package/docs/v4-adopter-delivery.md +15 -15
  76. package/docs/v4-declarative-release-tail-migration.md +19 -17
  77. package/docs/v4-production-release.md +11 -6
  78. package/docs/v4-publication-rehearsal.md +12 -27
  79. package/docs/v4-stage-capsule.md +14 -20
  80. package/docs/v4-tail-reseal.md +34 -20
  81. package/docs/web-surface-deployments.md +26 -264
  82. package/docs/workflow-catalog.md +31 -31
  83. package/docs/workflow-path-migration.md +10 -4
  84. package/package.json +5 -4
  85. package/packages/core/adoption/buildchain-kfd-claims.js +7 -7
  86. package/packages/core/adoption/cli/output.mjs +1 -9
  87. package/packages/core/adoption/cli/product-gate.mjs +1 -15
  88. package/packages/core/adoption/cli/project.mjs +9 -10
  89. package/packages/core/adoption/cli/standards.mjs +1 -14
  90. package/packages/core/adoption/cli/support.mjs +0 -2
  91. package/packages/core/adoption/cli/surface-register.mjs +0 -2
  92. package/packages/core/adoption/commands/init-repo.mjs +77 -485
  93. package/packages/core/adoption/consumer-init.js +279 -0
  94. package/packages/core/adoption/qualification/admission.js +1 -1
  95. package/packages/core/build/cli/cache.mjs +0 -2
  96. package/packages/core/build/cli/facts.mjs +0 -3
  97. package/packages/core/build/cli/homebrew.mjs +0 -4
  98. package/packages/core/build/cli/lifecycle.mjs +0 -3
  99. package/packages/core/build/github-artifact-attestation.js +2 -2
  100. package/packages/core/build/platform-stage-checkpoints.js +1 -1
  101. package/packages/core/build/signing/dispatch.js +1 -1
  102. package/packages/core/consumer/buildchain-config.js +9 -0
  103. package/packages/core/consumer/contract/inspection.js +351 -9
  104. package/packages/core/consumer/contract/javascript-syntax.js +439 -0
  105. package/packages/core/consumer/contract/javascript-values.js +61 -0
  106. package/packages/core/consumer/contract/javascript.js +555 -0
  107. package/packages/core/consumer/contract/local-validation.js +84 -0
  108. package/packages/core/contracts/buildchain-contract.js +39 -8
  109. package/packages/core/contracts/cli/introspection.mjs +1 -9
  110. package/packages/core/contracts/public-surface-cli.js +0 -1
  111. package/packages/core/dev-delivery/dev-delivery-contract-surface.js +2 -2
  112. package/packages/core/governance/buildchain-publication-authority.js +24 -24
  113. package/packages/core/governance/cli/doctor.mjs +58 -42
  114. package/packages/core/governance/commands/architecture.mjs +6 -1
  115. package/packages/core/governance/commands/audit-publication-control-plane.mjs +1 -1
  116. package/packages/core/governance/commands/workflow-friction-report.mjs +1 -1
  117. package/packages/core/governance/github-governance-authority.js +2 -2
  118. package/packages/core/governance/publication/collection.js +1 -1
  119. package/packages/core/index.js +1 -3
  120. package/packages/core/observability/cli/candidate.mjs +0 -2
  121. package/packages/core/observability/cli/context.mjs +0 -5
  122. package/packages/core/observability/cli/diagnostics.mjs +0 -7
  123. package/packages/core/observability/cli/events.mjs +2 -10
  124. package/packages/core/paper/commands/paper-work-fleet-cli.mjs +1 -1
  125. package/packages/core/paper/commands/paper.mjs +33 -422
  126. package/packages/core/paper/consumer-status.js +72 -0
  127. package/packages/core/paper/operations/identity.js +0 -3
  128. package/packages/core/paper/operations/migration.js +460 -0
  129. package/packages/core/paper/operations/preflight-checks.js +8 -68
  130. package/packages/core/paper/operations/scaffold.js +16 -326
  131. package/packages/core/paper/operations/status.js +27 -53
  132. package/packages/core/paper/paper-agent-entry.js +36 -147
  133. package/packages/core/paper/paper-fleet.js +24 -39
  134. package/packages/core/paper/paper-repository.js +16 -0
  135. package/packages/core/paper/paper-runtime-channels.js +1 -1
  136. package/packages/core/paper/paper-scaffold-content.js +153 -162
  137. package/packages/core/paper/paper-work.js +3 -10
  138. package/packages/core/paper/paper.js +43 -5
  139. package/packages/core/providers/github/artifact-attestation.js +1 -1
  140. package/packages/core/providers/github/pipeline-context-artifacts.js +172 -0
  141. package/packages/core/publication/authority/control-plane.js +2 -2
  142. package/packages/core/publication/authority/seal.js +1 -1
  143. package/packages/core/publication/cli/dispatch.mjs +1 -12
  144. package/packages/core/publication/pipeline/actions.js +16 -9
  145. package/packages/core/publication/pipeline/apply.js +17 -9
  146. package/packages/core/publication/pipeline/context.js +29 -0
  147. package/packages/core/publication/pipeline/prepare.js +15 -6
  148. package/packages/core/publication/pipeline/recovery-materials.js +63 -1
  149. package/packages/core/publication/pipeline/recovery-prepare.js +21 -9
  150. package/packages/core/publication/pipeline/stable-entry.js +12 -7
  151. package/packages/core/publication/pipeline/stable-products.js +21 -19
  152. package/packages/core/publication/pipeline/version-actions.js +15 -6
  153. package/packages/core/publication/publication-rehearsal-projection.js +0 -9
  154. package/packages/core/release/cli/dispatch.mjs +1 -4
  155. package/packages/core/release/cli/inspection-handlers.mjs +1 -33
  156. package/packages/core/release/cli/release-handlers.mjs +2 -19
  157. package/packages/core/release/cli/verification-handlers.mjs +4 -25
  158. package/packages/core/release/next-development-projection.js +13 -13
  159. package/packages/core/release/passport/locations.js +13 -8
  160. package/packages/core/release/release-passport.js +70 -5
  161. package/packages/core/web/cli/badges.mjs +0 -4
  162. package/packages/core/web/publication-admission.js +1 -1
  163. package/packages/core/web/publication-capability.js +1 -1
  164. package/packages/core/web/readme-badges.js +1 -1
  165. package/packages/core/workflow/cli/main.mjs +1 -4
  166. package/packages/core/workflow/cli/process.mjs +1 -1
  167. package/packages/core/workflow/commands/buildchain-cli-help.mjs +2 -8
  168. package/packages/core/workflow/engine/conformance.js +1 -1
  169. package/packages/core/workflow/pipeline/build.js +21 -1
  170. package/packages/core/workflow/pipeline/delivery-observation.js +6 -2
  171. package/packages/core/workflow/workflow-taxonomy.mjs +61 -17
  172. package/scripts/check-code-layout.mjs +2 -0
  173. package/scripts/check-core-mechanism-inventory.mjs +29 -13
  174. package/scripts/check-floating-consumer-policy-contract.mjs +3 -3
  175. package/scripts/check-inventory.mjs +27 -27
  176. package/scripts/check-maintainability.mjs +28 -5
  177. package/scripts/check-public-dogfood-contract.mjs +3 -3
  178. package/scripts/check-release-topology.mjs +1 -1
  179. package/scripts/check-self-consumer-contract.mjs +7 -7
  180. package/scripts/check-universal-workflow-bootstrap.mjs +1 -1
  181. package/scripts/generate-channel-promotion-workflow.mjs +1 -1
  182. package/scripts/generate-minimal-consumer-contract.mjs +21 -1
  183. package/scripts/generate-site-bundle.mjs +2 -1
  184. package/scripts/generate-tail-reseal-fixture.mjs +3 -3
  185. package/scripts/inventory/promotion.mjs +1 -1
  186. package/scripts/next-development-self-dogfood-harness.mjs +1 -1
  187. package/scripts/next-development-self-dogfood.mjs +4 -4
  188. package/scripts/site-capability-metadata.mjs +2 -6
  189. package/scripts/source-metric-lineage.mjs +62 -7
  190. package/scripts/verify-golden-path.mjs +31 -35
  191. package/templates/native-dev-delivery.yml +1 -1
  192. package/templates/universal-buildchain-bootstrap.yml +1 -1
  193. package/packages/core/paper/operations/bootstrap.js +0 -75
  194. package/packages/core/paper/operations/plans.js +0 -213
  195. package/packages/core/paper/operations/provisioning.js +0 -113
  196. package/packages/core/paper/operations/scaffold-config.js +0 -77
  197. package/packages/core/paper/operations/scaffold-workflows.js +0 -116
  198. package/packages/core/paper/operations/workspace.js +0 -60
  199. package/packages/core/paper/paper-npm-bootstrap.js +0 -492
@@ -1,509 +1,151 @@
1
- # Publication Artifact Workflow
2
-
3
- Buildchain supports `project.type = "publication-artifact"` for repositories
4
- that produce auditable papers, reports, specifications, or similar publication
5
- packages. These repositories are artifact producers. They should not be forced
6
- to become `web-surface` repositories just because a downstream site later
7
- renders the paper.
8
-
9
- The split is:
10
-
11
- ```text
12
- paper repo = source, PDF, metadata, source bundle, publication manifest
13
- papers site = layout, navigation, public web surface, downstream rendering
14
- ```
15
-
16
- ## Configuration
17
-
18
- The paper repository owns `.buildchain/buildchain.toml`:
19
-
20
- ```toml
21
- schema = 1
22
-
23
- [project]
24
- type = "publication-artifact"
25
- name = "paper-observer-declared-timelines"
26
-
27
- [publication]
28
- kind = "paper"
29
- title = "Observer-Declared Timelines for Real-World Agent Work"
30
- version = "0.1.0"
31
- primary_artifact = "_build/main.pdf"
32
- artifact_paths = ["_build/main.pdf"]
33
- metadata_paths = ["README.md", "docs/MAP.md"]
34
- source_paths = ["paper", "README.md", "LICENSE", "Makefile"]
35
- site_consumers = ["papers.libkungfu.dev"]
36
- manifest_path = ".buildchain/publication/publication-artifact.json"
37
- source_bundle_path = ".buildchain/publication/source.tar.gz"
38
-
39
- [publication.archive]
40
- id = "observer-declared-timelines"
41
- canonical_url = "https://papers.libkungfu.dev/observer-declared-timelines/"
42
- latest_url = "https://papers.libkungfu.dev/observer-declared-timelines/latest/"
43
- latest_evidence_url = "https://papers.libkungfu.dev/observer-declared-timelines/latest/buildchain.release.json"
44
- immutable_base_url = "https://papers.libkungfu.dev/archive"
45
- registry_path = ".buildchain/publication/publication-registry.json"
46
-
47
- [publication.toolchain]
48
- type = "latex-docker"
49
- image = "ghcr.io/kungfu-systems/build-images/latex-pdf-builder"
50
- digest = "sha256:c20f3809e96836c1c78e97c76939d12f1de3fed0ea9b7c40c43332ec2ea480f8"
51
- command = "latexmk -pdf -outdir=_build paper/main.tex"
52
-
53
- [publish]
54
- kind = "npm-paper-package"
55
- package = "@kungfu-tech/paper-observer-declared-timelines"
56
- auth = "trusted-publishing"
57
-
58
- [lifecycle.build]
59
- command = "make pdf"
60
-
61
- [lifecycle.verify]
62
- command = "make check"
63
- ```
64
-
65
- `primary_artifact` is the human-facing publication output, usually a PDF.
66
- `source_paths` are archived into a source bundle. `metadata_paths` are hashed
67
- and recorded so a site can consume the paper facts without scraping prose.
68
-
69
- `publication.archive` turns the publication into an append-only public archive
70
- contract:
71
-
72
- - `canonical_url` is the stable human reader page.
73
- - `latest_url` and `latest_evidence_url` are movable aliases for the latest
74
- reader page and latest evidence.
75
- - `immutable_base_url` plus `id` and `publication.version` produce a versioned
76
- prefix such as
77
- `https://papers.libkungfu.dev/archive/observer-declared-timelines/v0.1.0/`.
78
- - `immutable_url_prefix` can be used instead when the repository already owns
79
- the full version prefix.
80
- - `registry_path` records every published version and its manifest, passport,
81
- source bundle, primary artifact, URLs, and SHA-256 digests.
82
-
83
- Immutable archive prefixes are append-only. Do not run site deployment commands
84
- with `sync --delete` or equivalent deletion semantics over those prefixes. A
85
- same-version republish is allowed only when the immutable digest is unchanged;
86
- if PDF, source bundle, route, metadata, or toolchain evidence changes for an
87
- existing version, Buildchain fails before the registry is rewritten.
88
-
89
- The Buildchain web-surface adapter consumes this boundary from a surface-local
90
- `manifest.json` whose `archivePolicy.contract` is
91
- `kungfu-buildchain-publication-archive-policy`. It excludes the derived archive
92
- root from every owning or parent `sync --delete`, verifies existing object
93
- digests, uploads only missing immutable files with `--no-overwrite`, and verifies
94
- them again before mutable site content is synchronized. A current package set
95
- does not need to rebuild or enumerate every historical version: the protected
96
- archive root remains outside deletion even when older versions disappear from
97
- the current artifact.
98
-
99
- `publication.toolchain` makes the source-to-PDF transformation part of the
100
- machine-readable contract. `latex-docker` is the preferred LaTeX profile. The
101
- Buildchain paper scaffold and reusable workflow default to
102
- `ghcr.io/kungfu-systems/build-images/latex-pdf-builder:v1.2.0`, pinned by the
103
- digest above. The workflow pulls the declared image by digest and runs the
104
- declared command in that pinned container. `custom-command` remains available
105
- for compatibility, but the passport records it as lower trust because
106
- Buildchain can record the command boundary without proving the compiler or
107
- LaTeX distribution digest.
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
-
140
- `publish.kind = "npm-paper-package"` declares that Buildchain, not the consumer
141
- repository, owns the standard paper npm package shape and release transaction
142
- mechanics. `publish.package` is the public npm package that contains the PDF,
143
- publication manifest, publication passport, optional archive registry, source
144
- bundle, and declared metadata files.
145
-
146
- ## Reusable Workflow
147
-
148
- Consumer repositories that only need to build and upload paper evidence can
149
- call the build-only wrapper directly:
150
-
151
- ```yaml
152
- jobs:
153
- publication:
154
- uses: kungfu-systems/buildchain/.github/workflows/public-build-publication.yml@v3
155
- with:
156
- toolchain-type: config
157
- verify-command: make check
158
- artifact-name: observer-declared-timelines
159
- contract-lock: .buildchain/contract-lock.json
160
- ```
161
-
162
- The build-only workflow:
163
-
164
- - resolves the Buildchain runtime and checks the floating contract lock before
165
- any paper build runs;
166
- - resolves the declared publication toolchain from `[publication.toolchain]` or
167
- workflow inputs;
168
- - hydrates authenticated registry history before building so both clean
169
- candidates include the same append-only history;
170
- - for `latex-docker`, pulls the pinned build-images LaTeX builder digest and
171
- runs two independent clean builds with the reproducibility policy above;
172
- - for `custom-command`, runs the declared command and records the lower-trust
173
- boundary in the passport, but refuses publication qualification;
174
- - runs the verify command;
175
- - creates a source bundle from `publication.source_paths`;
176
- - writes `.buildchain/publication/publication-artifact.json`;
177
- - writes `.buildchain/publication/publication-artifact-passport.json`;
178
- - writes a qualifying
179
- `.buildchain/publication/reproducibility-receipt.json`;
180
- - when `[publication.archive]` is configured, writes
181
- `.buildchain/publication/publication-registry.json` and verifies same-version
182
- immutability;
183
- - uploads one GitHub artifact containing the PDF, manifest, passport, optional
184
- registry, and source bundle.
185
-
186
- It does not publish npm packages, deploy web pages, or create GitHub Releases.
187
-
188
- The paper release preset additionally hydrates every prior published package
189
- registry from the npm registry before generating the current manifest. npm
190
- package integrity authenticates each downloaded source; Buildchain verifies the
191
- registry self-digest, merges immutable records, and fails if a cumulative
192
- registry drops an accepted version or changes immutable route/artifact facts.
193
- The synthesized package therefore carries complete history even on a clean
194
- runner. Its cumulative registry and file SHA-256 values are bound into the paper
195
- release build summary and release passport evidence.
196
-
197
- ## Paper Release Preset
198
-
199
- Paper repositories that publish a versioned npm package should use the
200
- Buildchain-managed release preset instead of copying npm transaction scripts or
201
- promotion YAML:
202
-
203
- ```yaml
204
- name: Paper Release
205
-
206
- on:
207
- push:
208
- branches:
209
- - alpha/v1/v1.0
210
- - release/v1/v1.0
211
- workflow_dispatch:
212
-
213
- jobs:
214
- paper-release:
215
- uses: kungfu-systems/buildchain/.github/workflows/public-release-paper.yml@v4
216
- permissions:
217
- actions: read
218
- checks: write
219
- contents: read
220
- id-token: write
221
- issues: write
222
- with:
223
- publisher-workflow-path: .github/workflows/public-release-paper.yml
224
- toolchain-type: config
225
- verify-command: make check
226
- artifact-paths: _build/paper-name.pdf
227
- contract-lock: .buildchain/contract-lock.json
228
- secrets:
229
- BUILDCHAIN_GENERATED_WRITE_APP_CLIENT_ID: ${{ secrets.BUILDCHAIN_GENERATED_WRITE_APP_CLIENT_ID }}
230
- BUILDCHAIN_GENERATED_WRITE_APP_PRIVATE_KEY: ${{ secrets.BUILDCHAIN_GENERATED_WRITE_APP_PRIVATE_KEY }}
231
- BUILDCHAIN_GENERATED_WRITE_TOKEN: ${{ secrets.BUILDCHAIN_GENERATED_WRITE_TOKEN }}
232
- ```
233
-
234
- The sealed preset does not use a long-lived token for npm publication. It
235
- prefers a repository-scoped GitHub App installation token for generated
236
- repository writes and accepts `BUILDCHAIN_GENERATED_WRITE_TOKEN` as an
237
- equivalent narrow compatibility authority. The deprecated
238
- `BUILDCHAIN_PROMOTION_TOKEN` name remains accepted for existing consumers, but
239
- there is no `github.token` fallback for generated writes. npm publication
240
- remains bound to GitHub OIDC trusted publishing. The preset builds and packages the
241
- paper in a read-only job, then a credential-free authority job downloads that
242
- exact candidate, audits the external control plane, and seals a capability over
243
- the source tree, Buildchain runtime, controller receipt, PDF, and npm package
244
- bytes. Only the final job receives write and OIDC permissions; it downloads the
245
- admitted candidate, recomputes the capability binding, and publishes without
246
- executing consumer build commands. npm binds the OIDC identity to the consumer
247
- workflow named by `publisher-workflow-path`.
248
-
249
- The preset:
250
-
251
- - uses the exact Buildchain SHA admitted by the provisioning authority and
252
- binds it into the caller bytes, contract lock, publication candidate, and
253
- authority capability;
254
- - builds the PDF through the declared pinned LaTeX Docker toolchain or custom
255
- command in a read-only job;
256
- - verifies the paper repository;
257
- - writes the publication manifest, publication passport, optional archive
258
- registry, and source bundle;
259
- - synthesizes an npm package from `[publication]` and `[publish]` declarations
260
- under `.buildchain/publication/npm-package`;
261
- - computes npm-style `sha512` integrity from `npm pack --dry-run` and passes
262
- it as `publish-required-artifacts-json`;
263
- - creates a `publish-gate/<alpha|release>/.../<version>` source lock for the
264
- channel commit and requires `promote-buildchain-ref` to verify that lock
265
- before any publish side effect;
266
- - verifies the complete candidate again after authority and publishes the
267
- package through npm Trusted Publishing without rebuilding or repacking it;
268
- - writes a typed sealed-bundle manifest that binds the candidate root, exact
269
- npm tarball, every GitHub Release asset, durable storage path, and resume
270
- command;
271
- - persists the complete binary bundle to the transaction's durable release-state
272
- ref before npm receives credentials, allowing an empty runner to restore and
273
- verify the same bytes after interruption;
274
- - writes Buildchain release/passport evidence; and
275
- - creates or updates the exact-version GitHub Release by default, uploading
276
- every file declared by `publication.primary_artifact` and
277
- `publication.artifact_paths` alongside the release evidence.
278
-
279
- Consumers can opt out of the GitHub Release with `github-release: false`, but
280
- the default is on so downstream release propagation can observe
281
- `release.published` without hand-written `gh release` steps.
282
-
283
- The transaction exposes a stable publication progression:
284
-
285
- ```text
286
- prepared -> sealed -> package-published -> alpha-complete
287
- ```
288
-
289
- Stable publication ends at `release-complete`. If a run stops after npm but
290
- before GitHub Release completion, the next run starts from
291
- `package-published`, restores the sealed PDF and companion assets, and finishes
292
- the release without invoking the paper build or `npm pack` again.
293
-
294
- Declared publication artifacts are resolved from the generated publication
295
- manifest rather than repeated in consumer workflow YAML. Publication fails
296
- before upload if a declared artifact is missing or if its basename would
297
- collide with another GitHub Release asset.
298
-
299
- For npm Trusted Publishing, register the consumer workflow file that calls this
300
- preset, for example `.github/workflows/public-release-paper.yml`, against the declared
301
- package in npm. The trusted publisher is the consumer repository and workflow
302
- file; the implementation still runs inside Buildchain's reusable workflow.
303
-
304
- Standard paper repositories should not carry local copies of
305
- `packages/core/publication/commands/npm-publish-transaction.mjs`, package-generation scripts, or
306
- promotion/ref-lock YAML. If the default package shape is insufficient, extend
307
- Buildchain rather than forking the mechanics into each paper repository.
308
-
309
- ## CLI And Node API
310
-
311
- ### Unified paper operator surface
312
-
313
- The `buildchain paper` command family assembles the existing publication
314
- primitives into a resumable operator flow:
315
-
316
- ```text
317
- scaffold/new or migrate/existing -> preflight -> bootstrap npm -> build -> alpha -> status -> resume
318
- ```
319
-
320
- Each command emits a typed JSON envelope with `--json`. Dry-run is the default
321
- for every external mutation. `scaffold --write` is limited to no-overwrite
322
- local file creation. `migrate --write` is limited to the Buildchain-owned
323
- contract lock, version pin, thin workflows, and provisioning authority; paper
324
- content and publication configuration are preserved. `bootstrap npm --execute`, `alpha --execute`, and
325
- `resume --execute` cross external authority boundaries and therefore require
326
- explicit execution.
327
-
328
- The evidence model is intentionally non-inferential:
329
-
330
- | State | Required evidence |
331
- | -------------------- | -------------------------------------------------------- |
332
- | `scaffolded` | Complete managed scaffold inventory |
333
- | `governed` | Compatible Buildchain contract lock |
334
- | `admitted` | Repository admission receipt |
335
- | `bootstrapped` | Successful public npm bootstrap receipt or registry fact |
336
- | `trust-bound` | Trusted publisher binding receipt |
337
- | `content-ready` | Declared source paths present |
338
- | `artifact-sealed` | Verified sealed publication bundle |
339
- | `package-published` | Exact package version visible in npm |
340
- | `alpha-complete` | Protected Alpha PR completion evidence |
341
- | `staging-visible` | Staging route evidence |
342
- | `production-visible` | Production route evidence |
343
-
344
- `paper status` reports `satisfied`, `not-reached`, `blocked`, or `unknown` for
345
- each state. It does not promote a state merely because a prior state is
346
- complete. This makes a later `paper resume` safe: the command dispatches the
347
- thin repository release workflow, while the workflow re-verifies durable
348
- evidence and remains the publication authority.
349
-
350
- Operationally, responsibility remains split:
351
-
352
- - the paper repository owns content, declared metadata, and its thin
353
- build/release workflow;
354
- - Buildchain owns scaffold shape, evidence contracts, reproducibility, sealed
355
- bundle mechanics, npm transaction mechanics, and resumption planning;
356
- - GitHub branch protection and trusted publishing own authority transitions;
357
- - the papers site consumes publication evidence and owns reader-facing
358
- rendering.
359
-
360
- Daily work begins and ends through the repository-pinned v3 CLI:
1
+ ---
2
+ status: draft
3
+ period: ongoing
4
+ theme: paper-consumer
5
+ doc_type: implementation-guide
6
+ source_level: local-files
7
+ confidence: high
8
+ sensitivity: public
9
+ evidence_grade: B
10
+ review_state: unreviewed
11
+ last_reviewed: 2026-09-20
12
+ ai_provenance:
13
+ model_family: GPT-6
14
+ product: Codex
15
+ generated_at: 2026-09-20
16
+ visible_context: Schema-2 product compiler, shared caller templates and Paper source scaffold.
17
+ invisible_context_boundary: No downstream repository migration or hosted Paper release is claimed.
18
+ ---
19
+
20
+ # Paper products
21
+
22
+ A Paper repository owns its source, build commands, verification commands and
23
+ PDF output. It uses the same two Buildchain caller files as npm and binary
24
+ products. The published pipeline owns delivery, publication and recovery.
25
+
26
+ ## Create or adopt a source tree
27
+
28
+ For an existing paper with working `make pdf` and `make check` commands:
361
29
 
362
30
  ```sh
363
- pnpm paper:work:start -- golden-path
364
- # edit, test, and commit paper source
365
- pnpm paper:work:submit
31
+ buildchain init --type paper
32
+ buildchain validate --require-lifecycle-stages build,verify
366
33
  ```
367
34
 
368
- The start plan derives `dev/vN/vN.M` from `publication.version` and requires
369
- local HEAD to equal the exact canonical remote development SHA. The submit plan
370
- allows only a non-protected work branch containing that SHA, a clean committed
371
- tree, a normal fast-forward push, and a pull request back to the same derived
372
- development branch. Neither command force-pushes, guesses a fork target, or
373
- silently fetches and merges stale state.
374
-
375
- Maintainers can inspect a sibling fleet without per-repository command copies:
35
+ To generate a new LaTeX source tree, inspect the plan and then write it:
376
36
 
377
37
  ```sh
378
- buildchain paper fleet audit --root /path/to/papers --json
379
- buildchain paper fleet update --root /path/to/isolated-paper-worktrees --json
38
+ buildchain paper scaffold --name paper-example --title "Example Paper" \
39
+ --repository example/paper-example --json
40
+ buildchain paper scaffold --name paper-example --title "Example Paper" \
41
+ --repository example/paper-example --write --json
380
42
  ```
381
43
 
382
- Fleet update is dry-run first and accepts only isolated work branches. Its
383
- typed plan carries exact-old and expected-new digests for the same owned
384
- surfaces as `paper migrate`; `--write` also refreshes each pnpm lockfile. It
385
- never rewrites paper content or publication configuration.
44
+ The scaffold contains the paper, bibliography, Makefile, license, product
45
+ manifest, documentation, schema-2 TOML and shared caller pair. It creates no
46
+ repository-side provisioning authority, agent-entry JSON or release controller.
47
+ Existing conflicting files, extra workflows and symlinked write parents stop
48
+ writing before another planned file is created. Repeating an unchanged plan is
49
+ idempotent.
386
50
 
387
- Run a local readiness check without network observations:
51
+ The new Makefile builds LaTeX in a digest-pinned container with networking
52
+ disabled for the build. Running it requires Docker and the referenced image.
53
+ `make check` checks the source files and Git whitespace; add product-specific
54
+ content and PDF checks there as needed. A single successful build is not a
55
+ proof of reproducibility across independent builds.
388
56
 
389
- ```sh
390
- buildchain paper preflight --offline --json
391
- buildchain paper status --json
392
- ```
57
+ ## Product configuration
393
58
 
394
- Before real npm bootstrap, first inspect the default dry-run result:
59
+ The generated `.buildchain/buildchain.toml` includes a Paper product:
395
60
 
396
- ```sh
397
- buildchain paper bootstrap npm --json
398
- ```
61
+ ```toml
62
+ [[products]]
63
+ id = "main"
64
+ type = "paper"
65
+ platforms = ["linux-x64"]
66
+ build = ["make pdf"]
67
+ verify = ["make check"]
399
68
 
400
- Only after reviewing the package, repository, workflow, and dry-run evidence:
69
+ [[products.artifacts]]
70
+ id = "main"
71
+ path = "_build/main.pdf"
72
+ kind = "pdf"
401
73
 
402
- ```sh
403
- buildchain paper bootstrap npm \
404
- --execute \
405
- --confirm-public-package @kungfu-tech/paper-example \
406
- --json
74
+ [[products.targets]]
75
+ provider = "github-release"
76
+ artifacts = ["main"]
407
77
  ```
408
78
 
409
- Generate the publication manifest locally or in CI:
410
-
411
- ```sh
412
- buildchain publication-artifact manifest --source-sha "$(git rev-parse HEAD)" --json
413
- ```
79
+ This is the product portion of the generated configuration. Keep its schema,
80
+ version, channels and protected-review policy sections as well. Product commands
81
+ may change with the source tree; the two caller files remain identical across
82
+ product types:
414
83
 
415
- Prove the complete candidate from two clean builds:
84
+ - `.github/workflows/buildchain.yml` calls the common normal pipeline.
85
+ - `.github/workflows/buildchain-recover.yml` calls exact-attempt recovery.
416
86
 
417
- ```sh
418
- buildchain publication-artifact reproducibility \
419
- --source-sha "$(git rev-parse HEAD)" \
420
- --promote \
421
- --json
422
- ```
87
+ The source package is private. Its `version` is the product version authority;
88
+ its description and optional homepage retain the paper's title and site URL.
89
+ `--package` optionally sets this source identity and does not add an npm target.
90
+ When adopting a source tree without a versioned package manifest, `init` creates
91
+ `release.json` as the version authority instead.
423
92
 
424
- Generate the npm package contents after the manifest exists:
93
+ ## Validate and publish
425
94
 
426
95
  ```sh
427
- buildchain publication-artifact npm-package --json
428
- ```
429
-
430
- Node API:
431
-
432
- ```js
433
- import {
434
- collectPublicationArtifact,
435
- writePublicationArtifact,
436
- } from "@kungfu-tech/buildchain/publication-artifact";
437
-
438
- import {
439
- collectPublicationPackageFacts,
440
- preparePublicationNpmPackage,
441
- } from "@kungfu-tech/buildchain/publication-package";
442
-
443
- import { verifyPublicationReproducibility } from "@kungfu-tech/buildchain/publication-reproducibility";
444
-
445
- import {
446
- createPublicationSealedBundle,
447
- verifyPublicationSealedBundle,
448
- } from "@kungfu-tech/buildchain/publication-sealed-bundle";
449
- ```
450
-
451
- `writePublicationArtifact()` is the single implementation used by the CLI and
452
- the reusable workflow. The generated manifest records:
453
-
454
- - publication title, kind, authors, and primary artifact;
455
- - artifact paths, byte sizes, and SHA-256 digests;
456
- - metadata paths and SHA-256 digests;
457
- - source SHA, tree SHA, source files, and source bundle digest;
458
- - publication toolchain type, image, digest, command, invocation mode, and trust
459
- classification;
460
- - timestamp and reproducibility policy;
461
- - downstream site-consumption hints;
462
- - optional archive routes for canonical, latest, latest evidence, immutable
463
- version prefix, and public artifact URLs.
464
-
465
- The companion publication artifact passport records the same source and
466
- artifact evidence plus an explicit responsibility split. Buildchain proves
467
- declared files and hashes; it does not peer-review paper claims.
468
-
469
- When archive config is present, the registry uses the
470
- `kungfu-buildchain-publication-artifact-registry` contract. A site repository
471
- can render latest pages and historical version indexes from that registry
472
- without rebuilding old PDFs from the latest npm package or paper source.
473
-
474
- ## Site Consumption
475
-
476
- A downstream papers site should treat the publication manifest as the single
477
- fact source for the artifact. The site owns rendering and navigation; it should
478
- not reinterpret the paper repository as a web deployment source.
479
- For registry-level routing, sites should first consume the package-owned
480
- Buildchain fact source:
481
-
482
- ```text
483
- node_modules/@kungfu-tech/buildchain/dist/site/publication-registry.json
484
- ```
485
-
486
- or the equivalent package export:
487
-
488
- ```js
489
- import registry from "@kungfu-tech/buildchain/site/publication-registry.json" with { type: "json" };
490
- ```
491
-
492
- That registry uses the `kungfu-buildchain-publication-release-registry`
493
- contract. It separates mutable canonical/latest reader routes from immutable
494
- version prefixes, publication artifacts, source bundles, and passport evidence
495
- so site repositories can render `/papers/**` without maintaining a parallel
496
- fixture truth source.
497
-
498
- For `paper-observer-declared-timelines`, the expected adoption path is:
499
-
500
- ```text
501
- paper repo builds PDF + manifest + source bundle
502
- paper repo updates publication-registry.json
503
- papers site consumes publication-artifact.json
504
- papers site consumes publication-registry.json for history
505
- site renders paper page and links the PDF/source bundle
96
+ make pdf
97
+ make check
98
+ buildchain validate --require-lifecycle-stages build,verify
99
+ buildchain paper preflight --json
100
+ buildchain paper status --json
506
101
  ```
507
102
 
508
- This mirrors web-surface governance without mixing producer and renderer
509
- responsibilities.
103
+ For schema-2 Paper repositories, preflight and status check local product policy
104
+ and exact caller bytes. They return `localOnly: true` and
105
+ `publication.status: "not-observed"`. They do not contact npm or GitHub accounts,
106
+ and their success does not prove hosted admission, a successful build or a
107
+ published release.
108
+
109
+ Open a PR on the configured protected channel route to request delivery or
110
+ publication. Supply the common repository permissions and tool-maintained
111
+ runtime locks required by the published entry. Recover a failed operation using
112
+ its exact attempt identifier in the shared recovery workflow. An optional
113
+ repaired runtime applies to that recovery; do not persist it in product callers.
114
+
115
+ ## Existing papers and downstream sites
116
+
117
+ The former schema-1 npm-paper scaffold used separate product workflows and
118
+ repository-side control records. It is no longer generated for new papers.
119
+ Moving an existing paper to this contract changes its publication target to PDF
120
+ assets in GitHub Releases. Review that target change and downstream consumption
121
+ before migrating an existing repository; `init --force` does not absorb old
122
+ workflows or silently convert their product behavior.
123
+
124
+ `buildchain paper migrate --json` plans the conversion from a clean committed
125
+ source. It retains declared build/verification commands, moves publication
126
+ metadata into `paper/publication-metadata.json`, and makes the private source
127
+ package's version authoritative. `--write` applies the reviewed changes and
128
+ removes only recognized legacy callers and digest-checked controller files.
129
+ Custom workflows, conflicting version authorities, extra configuration sections,
130
+ and unrepresentable lifecycle settings fail before writing. Runtime locks and
131
+ historical receipts remain byte-identical; channel-root overrides are retired.
132
+ A later source change invalidates the plan. Refresh the dependency lockfile if
133
+ the plan updates an optional local Buildchain CLI dependency.
134
+
135
+ Keep already published npm versions, original PDF bytes and retained publication
136
+ receipts as historical evidence. A new local configuration does not rewrite or
137
+ requalify those releases. Existing append-only archives retain their immutability
138
+ rules. Sites own rendering, navigation and archive import; they must consume the
139
+ actual selected release and its evidence rather than infer a new npm publication
140
+ from a Paper configuration or successful local check.
141
+
142
+ ## Retired Paper execution commands
143
+
144
+ The schema-2 Paper interface no longer exposes `paper bootstrap npm`,
145
+ `paper build`, `paper alpha`, or `paper resume`. These commands depended on
146
+ legacy publication configuration and separate workflow wiring. Use the product
147
+ build/verification commands declared in TOML, a legal channel PR to request
148
+ publication, and the generated recovery caller with an exact attempt. The
149
+ generic product reproducibility tools remain available; this change does not
150
+ rewrite published artifacts or historical receipts. Legacy status/preflight
151
+ readers direct users to the migration preview.