@kungfu-tech/buildchain 3.0.6-alpha.0 → 3.0.6-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 (72) hide show
  1. package/README.md +4 -4
  2. package/actions/promote-buildchain-ref/README.md +8 -0
  3. package/bin/buildchain.mjs +13 -1
  4. package/contracts/auditable-demo-scenario-v1.schema.json +52 -0
  5. package/dist/site/buildchain-contract.json +47 -27
  6. package/dist/site/buildchain-site.json +165 -44
  7. package/dist/site/capability-registry.json +3 -3
  8. package/dist/site/cli-registry.json +40 -4
  9. package/dist/site/controller-registry.json +20 -4
  10. package/dist/site/kfd-claims.json +140 -19
  11. package/dist/site/kfd-upstream-aggregate.json +9 -9
  12. package/dist/site/manual-registry.json +9 -9
  13. package/dist/site/node-api-registry.json +1161 -180
  14. package/dist/site/page-registry.json +152 -31
  15. package/dist/site/public-surface-audit.json +386 -19
  16. package/dist/site/publication-authority-registry.json +61 -1
  17. package/dist/site/publication-registry.json +4 -4
  18. package/dist/site/release-provenance.json +1 -0
  19. package/dist/site/site-manifest.json +13 -13
  20. package/dist/site/workflow-registry.json +151 -13
  21. package/docs/MAP.md +2 -0
  22. package/docs/auditable-demo.md +58 -11
  23. package/docs/aws-us-elastic-runner-burst-plane.md +114 -80
  24. package/docs/cli-reference.md +154 -0
  25. package/docs/dev-alpha-candidate-patrol.md +13 -5
  26. package/docs/dev-delivery-warrant.md +158 -0
  27. package/docs/node-api-reference.md +54 -15
  28. package/docs/publication-authority.md +11 -0
  29. package/docs/release-candidate.md +19 -2
  30. package/docs/release-governance.md +60 -1
  31. package/docs/reusable-build-surface.md +11 -1
  32. package/docs/shifu-gate-profiles.md +12 -1
  33. package/docs/versioning.md +2 -0
  34. package/package.json +4 -2
  35. package/packages/core/buildchain-publication-authority.js +3 -1
  36. package/packages/core/channel-candidate.js +2 -21
  37. package/packages/core/channel-promotion-baseline.js +199 -0
  38. package/packages/core/dev-delivery-candidate-identity.js +94 -0
  39. package/packages/core/dev-delivery-common.js +73 -0
  40. package/packages/core/dev-delivery-proof.js +252 -0
  41. package/packages/core/dev-delivery-warrant-cancellation.js +94 -0
  42. package/packages/core/dev-delivery-warrant-settlement.js +73 -0
  43. package/packages/core/dev-delivery-warrant.js +591 -0
  44. package/scripts/auditable-demo-bundle-verification.mjs +148 -0
  45. package/scripts/auditable-demo-platform.mjs +86 -50
  46. package/scripts/auditable-demo-presentation.mjs +83 -0
  47. package/scripts/auditable-demo-renditions.mjs +264 -0
  48. package/scripts/auditable-demo.mjs +24 -30
  49. package/scripts/aws-windows-jit-campaign-core.mjs +7 -8
  50. package/scripts/aws-windows-jit-controller.mjs +1 -0
  51. package/scripts/aws-windows-jit-core.mjs +1 -1
  52. package/scripts/build-contract-core.mjs +58 -3
  53. package/scripts/buildchain-cli-help.mjs +8 -0
  54. package/scripts/buildchain-patrol.mjs +9 -0
  55. package/scripts/check-inventory.mjs +1 -0
  56. package/scripts/dev-alpha-candidate-patrol.mjs +45 -48
  57. package/scripts/dev-delivery-proof.mjs +193 -0
  58. package/scripts/dev-delivery-warrant.mjs +426 -0
  59. package/scripts/dev-pr-auto-merge.mjs +497 -55
  60. package/scripts/dev-pr-delivery-warrant.mjs +209 -0
  61. package/scripts/dispatch-artifact-signing-authority.mjs +2 -4
  62. package/scripts/gate-profile-core.mjs +24 -0
  63. package/scripts/generate-site-bundle.mjs +2 -2
  64. package/scripts/git-fetch-process-tree.mjs +142 -0
  65. package/scripts/lifecycle-substage-evidence.mjs +274 -0
  66. package/scripts/locked-source-checkout.mjs +6 -3
  67. package/scripts/resolve-artifact-transfer-mode.mjs +9 -0
  68. package/scripts/resolve-build-contract.mjs +7 -0
  69. package/scripts/route-offline-runners.mjs +1 -0
  70. package/scripts/run-lifecycle-core.mjs +9 -9
  71. package/scripts/shifu-gate-profile.mjs +10 -16
  72. package/scripts/site-capability-metadata.mjs +14 -0
@@ -0,0 +1,94 @@
1
+ import { devDeliveryClone as clone, devDeliveryContentRoot, devDeliveryExactRoot as exactRoot, devDeliveryExactSha as exactSha, devDeliveryPositiveInteger as positiveInteger, devDeliveryText as text, devDeliveryTimestamp as timestamp } from "./dev-delivery-common.js";
2
+
3
+ export const DEV_DELIVERY_CANCELLATION_RECEIPT_SCHEMA = "kungfu.buildchain.dev-delivery-cancellation-receipt/v1";
4
+
5
+ const TERMINAL_STATES = new Set(["merged", "terminal-failure", "dequeued", "cancelled"]);
6
+ const QUEUED_CANCELLATION_EVENTS = new Map([
7
+ ["closed", "cancelled"],
8
+ ["cancelled", "cancelled"],
9
+ ["dequeued", "dequeued"],
10
+ ]);
11
+
12
+ function cancellationReceipt(queue, candidate, identity, action, expectedOldStateRoot) {
13
+ return {
14
+ schema: DEV_DELIVERY_CANCELLATION_RECEIPT_SCHEMA,
15
+ action,
16
+ repository: queue.repository,
17
+ protectedBase: queue.protectedBase,
18
+ candidateId: candidate.candidateId,
19
+ pullRequestNumber: candidate.pullRequestNumber,
20
+ expectedSourceHead: identity.expectedSourceHead,
21
+ observedSourceHead: identity.observedSourceHead,
22
+ eventAction: identity.eventAction,
23
+ outcome: identity.outcome,
24
+ evidenceRoot: identity.evidenceRoot,
25
+ expectedOldStateRoot,
26
+ nextStateRoot: queue.stateRoot,
27
+ nextAction: "Select the next queued candidate, if any.",
28
+ };
29
+ }
30
+
31
+ function normalizeCancellation(input) {
32
+ const identity = {
33
+ candidateId: exactRoot(input?.candidateId, "candidateId"),
34
+ pullRequestNumber: positiveInteger(input?.pullRequestNumber, "pullRequestNumber"),
35
+ expectedSourceHead: exactSha(input?.expectedSourceHead, "expectedSourceHead"),
36
+ observedSourceHead: exactSha(input?.observedSourceHead, "observedSourceHead"),
37
+ eventAction: text(input?.eventAction).toLowerCase(),
38
+ outcome: text(input?.outcome).toLowerCase(),
39
+ evidenceRoot: exactRoot(input?.evidenceRoot, "evidenceRoot"),
40
+ reason: text(input?.reason),
41
+ };
42
+ const requiredOutcome = QUEUED_CANCELLATION_EVENTS.get(identity.eventAction);
43
+ if (!requiredOutcome) throw new Error(`eventAction must be one of ${[...QUEUED_CANCELLATION_EVENTS.keys()].join(", ")}`);
44
+ if (identity.outcome !== requiredOutcome) throw new Error(`eventAction ${identity.eventAction} requires outcome ${requiredOutcome}`);
45
+ return identity;
46
+ }
47
+
48
+ function terminalBinding(identity) {
49
+ return {
50
+ outcome: identity.outcome,
51
+ reason: identity.reason,
52
+ evidenceRoot: identity.evidenceRoot,
53
+ authority: "queued-candidate-cancellation",
54
+ expectedSourceHead: identity.expectedSourceHead,
55
+ observedSourceHead: identity.observedSourceHead,
56
+ eventAction: identity.eventAction,
57
+ };
58
+ }
59
+
60
+ export function createCancelQueuedDevDeliveryCandidate(normalizeDevDeliveryQueue) {
61
+ return function cancelQueuedDevDeliveryCandidate(queueInput, input, { now = new Date().toISOString() } = {}) {
62
+ const currentTime = timestamp(now, "now");
63
+ const identity = normalizeCancellation(input);
64
+ const before = normalizeDevDeliveryQueue(queueInput);
65
+ const candidate = before.candidates.find((entry) => entry.candidateId === identity.candidateId);
66
+ if (!candidate) throw new Error(`queued candidate ${identity.candidateId} does not exist`);
67
+ if (candidate.pullRequestNumber !== identity.pullRequestNumber) throw new Error("queued candidate PR mismatch");
68
+ if (candidate.sourceHead !== identity.expectedSourceHead) throw new Error("queued candidate recorded sourceHead mismatch");
69
+ if (before.activeWarrant?.candidateId === identity.candidateId) throw new Error("active candidate requires fenced Warrant closeout");
70
+
71
+ const terminal = terminalBinding(identity);
72
+ if (TERMINAL_STATES.has(candidate.status)) {
73
+ if (!Object.entries(terminal).every(([field, value]) => candidate.terminal?.[field] === value)) {
74
+ throw new Error("terminal candidate does not match the exact queued cancellation evidence");
75
+ }
76
+ const receipt = cancellationReceipt(before, candidate, identity, "duplicate-cancellation-noop", before.stateRoot);
77
+ return { queue: before, receipt, receiptRoot: devDeliveryContentRoot(receipt) };
78
+ }
79
+ if (candidate.status !== "queued") throw new Error(`candidate status ${candidate.status} requires fenced Warrant closeout`);
80
+
81
+ const queue = clone(before);
82
+ delete queue.stateRoot;
83
+ const queued = queue.candidates.find((entry) => entry.candidateId === identity.candidateId);
84
+ queued.status = identity.outcome;
85
+ queued.updatedAt = currentTime;
86
+ queued.terminal = { ...terminal, closedAt: currentTime };
87
+ queue.generation += 1;
88
+ queue.updatedAt = currentTime;
89
+ queue.stateRoot = devDeliveryContentRoot(queue);
90
+ const after = normalizeDevDeliveryQueue(queue);
91
+ const receipt = cancellationReceipt(after, queued, identity, "queued-candidate-cancelled", before.stateRoot);
92
+ return { queue: after, receipt, receiptRoot: devDeliveryContentRoot(receipt) };
93
+ };
94
+ }
@@ -0,0 +1,73 @@
1
+ import { devDeliveryContentRoot, devDeliveryExactRoot as exactRoot, devDeliveryExactSha as exactSha, devDeliveryPositiveInteger as positiveInteger, devDeliveryText as text } from "./dev-delivery-common.js";
2
+
3
+ export const DEV_DELIVERY_SETTLEMENT_RECEIPT_SCHEMA = "kungfu.buildchain.dev-delivery-settlement-receipt/v1";
4
+
5
+ function noopReceipt(queue, identity, candidate, action) {
6
+ return {
7
+ schema: DEV_DELIVERY_SETTLEMENT_RECEIPT_SCHEMA,
8
+ action,
9
+ applicable: action !== "terminal-event-not-applicable",
10
+ repository: queue.repository,
11
+ protectedBase: queue.protectedBase,
12
+ pullRequestNumber: identity.pullRequestNumber,
13
+ sourceHead: identity.sourceHead,
14
+ outcome: identity.outcome,
15
+ candidateId: candidate?.candidateId || null,
16
+ evidenceRoot: candidate?.terminal?.evidenceRoot || identity.evidenceRoot || null,
17
+ expectedOldStateRoot: queue.stateRoot,
18
+ nextStateRoot: queue.stateRoot,
19
+ nextAction: "No fenced delivery state remains for this terminal event.",
20
+ };
21
+ }
22
+
23
+ export function createDevDeliveryTerminalSettler({ normalizeQueue, closeWarrant, cancelQueued, terminalStates }) {
24
+ return function settleDevDeliveryTerminalEvent(queueInput, input, { now = new Date().toISOString() } = {}) {
25
+ const queue = normalizeQueue(queueInput);
26
+ const identity = {
27
+ pullRequestNumber: positiveInteger(input?.pullRequestNumber, "pullRequestNumber"),
28
+ sourceHead: exactSha(input?.sourceHead, "sourceHead"),
29
+ outcome: text(input?.outcome),
30
+ evidenceRoot: input?.evidenceRoot ? exactRoot(input.evidenceRoot, "evidenceRoot") : "",
31
+ reason: text(input?.reason),
32
+ eventAction: text(input?.eventAction).toLowerCase(),
33
+ };
34
+ if (!terminalStates.has(identity.outcome)) throw new Error(`outcome must be one of ${[...terminalStates].join(", ")}`);
35
+ const samePullRequest = queue.candidates.filter((entry) => entry.pullRequestNumber === identity.pullRequestNumber);
36
+ const candidate = samePullRequest.find((entry) => entry.sourceHead === identity.sourceHead) || null;
37
+ if (!candidate && samePullRequest.length > 0) throw new Error("terminal event sourceHead does not match the recorded candidate");
38
+
39
+ if (candidate && terminalStates.has(candidate.status)) {
40
+ if (candidate.status !== identity.outcome) throw new Error("terminal candidate outcome does not match the terminal event");
41
+ const receipt = noopReceipt(queue, identity, candidate, "duplicate-terminal-event-noop");
42
+ return { queue, receipt, receiptRoot: devDeliveryContentRoot(receipt) };
43
+ }
44
+
45
+ if (queue.activeWarrant) {
46
+ if (!candidate || queue.activeWarrant.candidateId !== candidate.candidateId) throw new Error("terminal event does not match the active Delivery Warrant");
47
+ if (!identity.evidenceRoot) throw new Error("active terminal settlement requires evidenceRoot");
48
+ return closeWarrant(queue, {
49
+ candidateId: candidate.candidateId,
50
+ fencingToken: exactRoot(input?.fencingToken, "fencingToken"),
51
+ generation: positiveInteger(input?.leaseGeneration, "leaseGeneration"),
52
+ }, { outcome: identity.outcome, evidenceRoot: identity.evidenceRoot, reason: identity.reason, now });
53
+ }
54
+
55
+ if (!candidate) {
56
+ const receipt = noopReceipt(queue, identity, null, "terminal-event-not-applicable");
57
+ return { queue, receipt, receiptRoot: devDeliveryContentRoot(receipt) };
58
+ }
59
+ if (candidate.status !== "queued") throw new Error(`candidate status ${candidate.status} requires an active Delivery Warrant`);
60
+ if (!["cancelled", "dequeued"].includes(identity.outcome)) throw new Error("queued candidate cannot settle as merged or terminal-failure");
61
+ if (!identity.evidenceRoot) throw new Error("queued terminal settlement requires evidenceRoot");
62
+ return cancelQueued(queue, {
63
+ candidateId: candidate.candidateId,
64
+ pullRequestNumber: identity.pullRequestNumber,
65
+ expectedSourceHead: identity.sourceHead,
66
+ observedSourceHead: identity.sourceHead,
67
+ eventAction: identity.eventAction || (identity.outcome === "dequeued" ? "dequeued" : "closed"),
68
+ outcome: identity.outcome,
69
+ evidenceRoot: identity.evidenceRoot,
70
+ reason: identity.reason,
71
+ }, { now });
72
+ };
73
+ }