@kungfu-tech/buildchain 3.0.4-alpha.2 → 3.0.4-alpha.4

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 (50) hide show
  1. package/bin/buildchain.mjs +126 -72
  2. package/bin/internal/trust-release-cli.mjs +15 -537
  3. package/bin/internal/trust-release-command-handlers.mjs +14 -0
  4. package/bin/internal/trust-release-inspection-handlers.mjs +175 -0
  5. package/bin/internal/trust-release-release-handlers.mjs +317 -0
  6. package/bin/internal/trust-release-verification-handlers.mjs +306 -0
  7. package/dist/site/buildchain-contract.json +35 -24
  8. package/dist/site/buildchain-site.json +22 -10
  9. package/dist/site/controller-registry.json +16 -3
  10. package/dist/site/kfd-claims.json +9 -7
  11. package/dist/site/kfd-upstream-aggregate.json +1 -1
  12. package/dist/site/manual-registry.json +2 -2
  13. package/dist/site/node-api-registry.json +7 -7
  14. package/dist/site/page-registry.json +9 -4
  15. package/dist/site/public-surface-audit.json +56 -8
  16. package/dist/site/publication-registry.json +4 -4
  17. package/dist/site/release-model.json +7 -0
  18. package/dist/site/site-manifest.json +6 -6
  19. package/dist/site/workflow-registry.json +13 -5
  20. package/docs/MAP.md +1 -1
  21. package/docs/release-propagation.md +166 -8
  22. package/package.json +1 -1
  23. package/packages/core/buildchain-kfd-claims.js +1 -1
  24. package/packages/core/controller-evidence.js +8 -1
  25. package/packages/core/index.js +1 -13
  26. package/packages/core/paper-agent-entry.js +10 -11
  27. package/packages/core/paper-npm-bootstrap.js +492 -0
  28. package/packages/core/paper.js +271 -669
  29. package/packages/core/public-surface-cli.js +12 -1
  30. package/packages/core/release-passport.js +67 -71
  31. package/packages/core/release-propagation-common.js +64 -0
  32. package/packages/core/release-propagation-execution-profile.js +59 -0
  33. package/packages/core/release-propagation-release.js +196 -0
  34. package/packages/core/release-propagation-stage-evidence.js +364 -0
  35. package/packages/core/release-propagation-work-capture.js +64 -0
  36. package/packages/core/release-propagation-work-constants.js +34 -0
  37. package/packages/core/release-propagation-work-control.js +203 -0
  38. package/packages/core/release-propagation-work-transitions.js +145 -0
  39. package/packages/core/release-propagation-work.js +517 -0
  40. package/packages/core/release-propagation.js +34 -158
  41. package/scripts/aws-windows-jit-controller-core.mjs +269 -0
  42. package/scripts/aws-windows-jit-controller.mjs +502 -0
  43. package/scripts/check-internal-architecture.mjs +178 -52
  44. package/scripts/check-maintainability.mjs +76 -17
  45. package/scripts/generate-site-bundle.mjs +16 -7
  46. package/scripts/maintainability-metrics.mjs +24 -4
  47. package/scripts/release-propagation.mjs +126 -0
  48. package/scripts/resolve-artifact-transfer-mode.mjs +117 -0
  49. package/scripts/web-surface-core.mjs +46 -207
  50. package/scripts/web-surface-routing.mjs +286 -0
@@ -67,10 +67,12 @@ The upstream release envelope is the post-finalization fact set:
67
67
  "channel": "alpha",
68
68
  "tag": "v1.4.0-alpha.3",
69
69
  "sourceSha": "1111111111111111111111111111111111111111",
70
+ "tagTargetSha": "1111111111111111111111111111111111111111",
70
71
  "package": {
71
72
  "name": "@kungfu-tech/kfd",
72
73
  "version": "1.4.0-alpha.3",
73
- "integrity": "sha512-..."
74
+ "integrity": "sha512-...",
75
+ "gitHead": "1111111111111111111111111111111111111111"
74
76
  },
75
77
  "releasePassport": {
76
78
  "url": "https://github.com/kungfu-systems/kfd/releases/download/v1.4.0-alpha.3/buildchain.release.json",
@@ -82,8 +84,10 @@ The upstream release envelope is the post-finalization fact set:
82
84
  }
83
85
  ```
84
86
 
85
- The package version and integrity must be exact. Downstream build logic should
86
- install that version directly, not resolve `alpha` or `latest` again.
87
+ The package version, integrity, and npm `gitHead` must be exact. The exact tag
88
+ must be `v<version>`, and `gitHead`, tag target, and `sourceSha` must describe
89
+ the same source commit before propagation is admitted. Downstream build logic
90
+ installs that version directly and never resolves `alpha` or `latest` again.
87
91
 
88
92
  Publication repositories can propagate immutable publication archive evidence
89
93
  without npm package facts. The upstream envelope then includes
@@ -95,6 +99,7 @@ without npm package facts. The upstream envelope then includes
95
99
  "channel": "alpha",
96
100
  "tag": "v0.1.0-alpha.1",
97
101
  "sourceSha": "4444444444444444444444444444444444444444",
102
+ "tagTargetSha": "4444444444444444444444444444444444444444",
98
103
  "releasePassport": {
99
104
  "url": "https://github.com/kungfu-systems/paper-observer-declared-timelines/releases/download/v0.1.0-alpha.1/buildchain.release.json",
100
105
  "sha256": "5555555555555555555555555555555555555555555555555555555555555555"
@@ -200,6 +205,157 @@ The receipt keeps four machine states separate:
200
205
 
201
206
  Package publication or alpha completion never implies either visibility state.
202
207
 
208
+ ## Agent-native work envelope
209
+
210
+ Setting `agent-work-mode: capture-only` makes a finalized release emit a
211
+ resumable delivery handoff without mutating the downstream repository. Passing
212
+ an exact `agent-work-context-json` instead emits an already-authorized unit.
213
+ Buildchain emits one
214
+ `kungfu-buildchain-release-propagation-work` v1 envelope per exact release and
215
+ downstream target. This is a Buildchain domain execution contract, not another
216
+ Work Control database or authority.
217
+
218
+ The envelope binds:
219
+
220
+ - the exact normalized upstream release and release-lock roots;
221
+ - the downstream repository, channel, base ref, expected base SHA, managed
222
+ branch, lock path, and propagation key;
223
+ - exact parent and child `kungfu.assignment-graph.work-ref/v1` values derived
224
+ from the immutable release and downstream plan;
225
+ - either a pending Family binding or one exact
226
+ `kungfu.work-control.initiative-family-state/v2` coordinate;
227
+ - capture-only or end-to-end execution authority, including an active typed
228
+ execution-Warrant reference for execution;
229
+ - explicit publish-to-production intent, deterministic commands, canonical
230
+ ordered stages, a recovery cursor, stage receipts, supersession policy, and
231
+ a content root.
232
+
233
+ The ordered stages are:
234
+
235
+ ```text
236
+ materialize -> verify-release -> push-branch -> pull-request -> preview
237
+ -> independent-review -> protected-merge -> staging -> production-release
238
+ -> production-deploy -> online-readback -> complete
239
+ ```
240
+
241
+ `pull-request` and `protected-merge` are intermediate states. Only exact online
242
+ readback followed by an accepted Work Control Decision can record `complete`.
243
+ Every state transition uses expected-old fencing against the current work
244
+ content root. An identical initial envelope has the same work id and root;
245
+ newer releases receive distinct propagation keys and must name an explicit
246
+ superseded work root when they replace unfinished work.
247
+
248
+ The context has this shape (roots abbreviated here only for readability):
249
+
250
+ ```json
251
+ {
252
+ "parentWorkRef": {
253
+ "schema": "kungfu.assignment-graph.work-ref/v1",
254
+ "workspace_identity_root": "sha256:<64 hex>",
255
+ "object_kind": "initiative",
256
+ "subject": "paper-publication",
257
+ "version_root": "sha256:<64 hex>",
258
+ "cut_root": "sha256:<64 hex>"
259
+ },
260
+ "childWorkRef": {
261
+ "schema": "kungfu.assignment-graph.work-ref/v1",
262
+ "workspace_identity_root": "sha256:<64 hex>",
263
+ "object_kind": "assignment",
264
+ "subject": "site-propagation",
265
+ "version_root": "sha256:<64 hex>",
266
+ "cut_root": "sha256:<64 hex>"
267
+ },
268
+ "familyState": {
269
+ "schema": "kungfu.work-control.initiative-family-state/v2",
270
+ "stateRoot": "sha256:<64 hex>",
271
+ "v1ProjectionRoot": "sha256:<64 hex>",
272
+ "typedBindingRoot": "sha256:<64 hex>",
273
+ "factWorld": "<owning fact world>",
274
+ "cutRoot": "sha256:<64 hex>"
275
+ },
276
+ "authority": {
277
+ "mode": "capture-only",
278
+ "publishToProduction": false,
279
+ "allowedActions": [],
280
+ "executionPrincipal": null,
281
+ "sourceControlPrincipal": null,
282
+ "executionWarrant": null
283
+ },
284
+ "supersedesWorkRoot": ""
285
+ }
286
+ ```
287
+
288
+ Automatic capture emits deterministic Buildchain-owned release and propagation
289
+ WorkRefs, leaves `workControl.bindingState` as `pending`, emits no Family State
290
+ or Warrant, and performs no downstream write. Claiming that unit supplies the
291
+ exact Family State v2 coordinate and active Warrant while preserving the work
292
+ identity. An executing input must carry an active Warrant at the same Family
293
+ State fact world and cut, explicit production intent, and the complete supported
294
+ action set. It also binds the acting Agent principal and the source-control
295
+ principal that authors the PR. Buildchain never invents external Work Control
296
+ authority.
297
+
298
+ A managed Paper opts into automatic capture with a thin, source-controlled
299
+ `.buildchain/release-propagation.json`. The sealed release workflow reads that
300
+ exact file from the released Paper SHA only after npm, tag, Passport, and
301
+ publication evidence agree. It emits one paused work artifact per declared
302
+ target; publication itself does not open a Site PR.
303
+
304
+ ```json
305
+ {
306
+ "schemaVersion": 1,
307
+ "contract": "kungfu-buildchain-paper-release-propagation",
308
+ "sourceNode": "paper-example",
309
+ "graph": {
310
+ "schemaVersion": 1,
311
+ "contract": "kungfu-buildchain-release-propagation-graph",
312
+ "nodes": [],
313
+ "edges": []
314
+ },
315
+ "targets": ["site-libkungfu-dev"]
316
+ }
317
+ ```
318
+
319
+ Each graph target owns an exact GitHub web-surface execution profile: workflow,
320
+ base and managed branch, lock path, consumer commands, production status URL,
321
+ and production artifact readback URLs. The sealed workflow rejects extra config
322
+ fields, unknown targets, or a target whose base revision cannot be resolved.
323
+
324
+ The reusable workflow keeps its prior behavior when `agent-work-mode` is
325
+ `legacy` (the default). Managed Paper callers set `capture-only`; an Agent later
326
+ claims the emitted artifact and resumes from its machine-readable `next_action`.
327
+
328
+ Agent entrypoints are machine-readable and restart-safe:
329
+
330
+ ```bash
331
+ buildchain release-propagation work create ... --output work.json --json
332
+ buildchain release-propagation work status --work work.json --json
333
+ buildchain release-propagation work resume --work work.json --json
334
+ buildchain release-propagation work claim ... --output successor.json --json
335
+ buildchain release-propagation work receipt ... --output receipt.json --json
336
+ buildchain release-propagation work record ... --output successor.json --json
337
+ buildchain release-propagation work repair ... --output successor.json --json
338
+ buildchain release-propagation work complete ... --output successor.json --json
339
+ ```
340
+
341
+ Known operational races (`stale-branch`, `expected-old-mismatch`,
342
+ `lockfile-drift`, `failed-check`, `interrupted-execution`, and `ci-delay`) return
343
+ a retryable repair action. Semantic ambiguity, missing credentials, policy
344
+ expansion, and unknown failures stop at `needs-decision`. Release-contract
345
+ mismatch, immutable-artifact conflict, and destructive recovery stop at a hard
346
+ safety gate. Evidence locators containing signed or credential parameters are
347
+ rejected.
348
+
349
+ Successful stage receipts are typed, not generic progress notes. In particular,
350
+ the pushed-branch receipt hashes the full expected-old branch reconciliation;
351
+ review binds an approved GitHub review and must come from an identity distinct
352
+ from both the acting Agent and PR author; production deployment carries release,
353
+ lock, deployed artifact, expected readback digest, and rollback coordinates; and
354
+ online readback must cover the exact execution-profile URLs with HTTP 200,
355
+ observed non-zero bytes, exact deployed Git revision, and matching release and
356
+ artifact digests. The final receipt binds the accepted Work Control Decision
357
+ root.
358
+
203
359
  ## Reusable Workflow
204
360
 
205
361
  Upstream repositories can call
@@ -257,11 +413,13 @@ can disable that step with `refresh-managed-readme-badges: false`.
257
413
  push, so consumers can use the same check as their PR workflow. Update,
258
414
  preparation, badge refresh, and verification failures all fail closed. The
259
415
  workflow stages the complete deterministic result, signs the propagation
260
- commit with DCO, and then opens or updates the PR. It does not publish the
261
- downstream release directly. The downstream repository keeps its normal
262
- Buildchain governance: the PR updates source-of-truth facts, then downstream
263
- alpha or release publication runs through its own protected channel. A
264
- byte-identical rerun is an explicit successful no-op.
416
+ commit with DCO, and then opens or updates the PR. With no agent work context,
417
+ the reusable workflow retains this backward-compatible PR boundary. With an
418
+ executing work context, it records materialization, verification, branch, and
419
+ PR receipts and returns `preview` as the next action; the authorized Agent then
420
+ continues through the downstream repository's normal protected review,
421
+ publication, deployment, and readback entrypoints. A byte-identical rerun is an
422
+ explicit successful no-op, never a synthetic completion.
265
423
 
266
424
  For unreleased runtime validation, keep the caller's reusable workflow reference
267
425
  on `@v3` and pass a temporary train ref through `buildchain-ref`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungfu-tech/buildchain",
3
- "version": "3.0.4-alpha.2",
3
+ "version": "3.0.4-alpha.4",
4
4
  "private": false,
5
5
  "description": "Buildchain Release Passport, release governance, CLI toolkit, and site facts.",
6
6
  "repository": "https://github.com/kungfu-systems/buildchain",
@@ -411,7 +411,7 @@ export function createBuildchainPublicClaimDefinitions() {
411
411
  },
412
412
  {
413
413
  id: "claim:buildchain-release-propagation",
414
- claim: "Buildchain can propagate upstream alpha or stable releases to downstream repositories while preserving release channels through exact release locks.",
414
+ claim: "Buildchain can propagate exact upstream releases as Family State v2 and WorkRef-bound, resumable downstream work that preserves protected review and completes only after production readback.",
415
415
  sourcePaths: [
416
416
  "packages/core/release-propagation.js",
417
417
  "scripts/release-propagation.mjs",
@@ -103,10 +103,16 @@ const CONTROLLER_SPECS = [
103
103
  id: "release-propagation",
104
104
  workflowId: "release-propagation",
105
105
  version: 1,
106
- capabilities: ["release-propagation-plan", "downstream-lock", "pull-request-handoff"],
106
+ capabilities: [
107
+ "release-propagation-plan",
108
+ "downstream-lock",
109
+ "agent-native-work-envelope",
110
+ "resumable-production-handoff",
111
+ ],
107
112
  stages: [
108
113
  "resolve-runtime",
109
114
  "plan",
115
+ "emit-work",
110
116
  "write-lock",
111
117
  "prepare-consumer",
112
118
  "refresh-badges",
@@ -119,6 +125,7 @@ const CONTROLLER_SPECS = [
119
125
  "refresh-badges",
120
126
  "verify-consumer",
121
127
  "open-pr",
128
+ "emit-work",
122
129
  ],
123
130
  evidence: ["propagation-plan", "propagation-lock", "controller-receipt"],
124
131
  },
@@ -590,19 +590,7 @@ export {
590
590
  writeKfd3SurfaceRegistry,
591
591
  } from "./kfd3-surface-register.js";
592
592
 
593
- export {
594
- RELEASE_PROPAGATION_GRAPH_CONTRACT,
595
- RELEASE_PROPAGATION_LOCK_CONTRACT,
596
- RELEASE_PROPAGATION_PLAN_CONTRACT,
597
- RELEASE_PROPAGATION_RECEIPT_CONTRACT,
598
- createReleasePropagationReceipt,
599
- createReleasePropagationLock,
600
- normalizeReleasePropagationGraph,
601
- planReleasePropagation,
602
- readReleasePropagationJson,
603
- resolvePropagationChannel,
604
- writeReleasePropagationLock,
605
- } from "./release-propagation.js";
593
+ export * from "./release-propagation.js";
606
594
 
607
595
  export {
608
596
  RELEASE_ACTIVATION_CONTRACT,
@@ -181,12 +181,8 @@ export function resolvePaperBuildchainSha(buildchainRoot, buildchainSha = "") {
181
181
  return GIT_SHA_PATTERN.test(observed) ? observed : "";
182
182
  }
183
183
 
184
- function expectedCiBranches(developmentRef) {
185
- return [
186
- developmentRef,
187
- developmentRef.replace(/^dev\//, "alpha/"),
188
- developmentRef.replace(/^dev\//, "release/"),
189
- ];
184
+ function expectedCiBranches(ref) {
185
+ return ["dev", "alpha", "release"].map((c) => ref.replace(/^dev/, c));
190
186
  }
191
187
 
192
188
  function ciContext({ env, developmentRef }) {
@@ -201,10 +197,13 @@ function ciContext({ env, developmentRef }) {
201
197
  env.GITHUB_REF_NAME || env.BUILDCHAIN_PAPER_REF_NAME || "",
202
198
  );
203
199
  const pullRequest = ["pull_request", "pull_request_target"].includes(event);
200
+ const channelBranches = expectedCiBranches(developmentRef);
201
+ const channelIndex = channelBranches.indexOf(targetBranch);
204
202
  const branchOk = pullRequest
205
- ? PAPER_WORK_BRANCH_PATTERN.test(sourceBranch) &&
206
- targetBranch === developmentRef
207
- : expectedCiBranches(developmentRef).includes(refName);
203
+ ? (PAPER_WORK_BRANCH_PATTERN.test(sourceBranch) &&
204
+ targetBranch === developmentRef) ||
205
+ (channelIndex > 0 && sourceBranch === channelBranches[channelIndex - 1])
206
+ : channelBranches.includes(refName);
208
207
  return {
209
208
  mode: "ci",
210
209
  event,
@@ -214,8 +213,8 @@ function ciContext({ env, developmentRef }) {
214
213
  pullRequest,
215
214
  ok: branchOk,
216
215
  message: pullRequest
217
- ? `Pull requests must use an allowed work branch and target ${developmentRef}.`
218
- : `Channel checks must run on ${expectedCiBranches(developmentRef).join(", ")}.`,
216
+ ? `Pull requests must target ${developmentRef} from an allowed work branch or promote adjacent protected channels.`
217
+ : `Channel checks must run on ${channelBranches.join(", ")}.`,
219
218
  };
220
219
  }
221
220