@kungfu-tech/buildchain 4.0.2-alpha.0 → 4.0.2-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 (59) hide show
  1. package/architecture/agent-change-map.md +7 -4
  2. package/architecture/ci-lane-change-budget.json +76 -8
  3. package/architecture/internal-capabilities.json +2 -0
  4. package/architecture/maintainability-debt.json +52 -124
  5. package/architecture/maintainability-policy.json +15 -10
  6. package/architecture/release-tail-contract-inventory.json +4 -4
  7. package/architecture/v3-core-mechanism-inventory.json +1 -0
  8. package/architecture/v3-v4-live-capability-inventory.json +17 -17
  9. package/architecture/v4-delivery-warrant-shadow-fixtures.json +5 -5
  10. package/architecture/v4-release-invocation-fixtures.json +139 -0
  11. package/architecture/v4-release-topology.json +243 -0
  12. package/architecture/v4-runtime-semantic-closure.json +4 -1
  13. package/contracts/buildchain-v2-residuals-v1.json +0 -9
  14. package/contracts/fixtures/v4-tail-reseal-v1/valid.json +1 -1
  15. package/contracts/v4-release-invocation-v1.schema.json +134 -0
  16. package/dist/site/buildchain-contract.json +9 -9
  17. package/dist/site/buildchain-site.json +7 -7
  18. package/dist/site/kfd-claims.json +24 -5
  19. package/dist/site/kfd-upstream-aggregate.json +1 -1
  20. package/dist/site/manual-registry.json +1 -1
  21. package/dist/site/node-api-registry.json +90 -15
  22. package/dist/site/page-registry.json +2 -2
  23. package/dist/site/public-surface-audit.json +34 -9
  24. package/dist/site/publication-authority-registry.json +2 -3
  25. package/dist/site/publication-registry.json +4 -4
  26. package/dist/site/site-manifest.json +5 -5
  27. package/dist/site/workflow-registry.json +36 -11
  28. package/docs/node-api-reference.md +16 -13
  29. package/package.json +2 -2
  30. package/packages/core/dev-delivery-candidate-identity.js +45 -17
  31. package/packages/core/dev-delivery-execution-transfer.js +6 -7
  32. package/packages/core/dev-delivery-provider-heartbeat.js +22 -6
  33. package/packages/core/dev-delivery-warrant-legacy-recovery.js +4 -2
  34. package/packages/core/dev-delivery-warrant-native-compatibility.js +33 -0
  35. package/packages/core/dev-delivery-warrant-state.js +54 -54
  36. package/packages/core/dev-delivery-warrant.js +8 -0
  37. package/packages/core/dev-delivery-writer-protocol-transition.js +72 -0
  38. package/packages/core/v4-canonical-contracts.js +10 -0
  39. package/packages/core/v4-floating-consumer-policy.js +4 -1
  40. package/packages/core/v4-protected-publication-source.js +93 -0
  41. package/packages/core/v4-publication-qualification.js +1 -0
  42. package/packages/core/v4-release-invocation.js +425 -0
  43. package/scripts/audit-publication-control-plane.mjs +0 -1
  44. package/scripts/check-inventory.mjs +27 -59
  45. package/scripts/check-maintainability.mjs +13 -5
  46. package/scripts/check-v3-v4-capability-inventory.mjs +3 -61
  47. package/scripts/check-v4-floating-consumer-policy-contract.mjs +10 -20
  48. package/scripts/check-v4-release-topology.mjs +383 -0
  49. package/scripts/dev-delivery-warrant.mjs +26 -5
  50. package/scripts/generate-channel-promotion-workflow.mjs +14 -55
  51. package/scripts/release-candidate-resolver.mjs +17 -17
  52. package/scripts/resume-from-candidate-run.mjs +15 -16
  53. package/scripts/v3-v4-capability-catalog.mjs +107 -0
  54. package/scripts/v4-declarative-promotion-admission.mjs +4 -1
  55. package/scripts/v4-release-candidate-adapter.mjs +41 -0
  56. package/scripts/capture-package-release-propagation.mjs +0 -263
  57. package/scripts/publication-commit-evidence.mjs +0 -444
  58. package/scripts/publish-github-artifact-attestation-evidence.mjs +0 -201
  59. package/scripts/stage-github-artifact-attestation-inputs.mjs +0 -65
@@ -138,14 +138,21 @@ function terminal(jobInput) {
138
138
  function heartbeatEntry(result, previousStateRoot) {
139
139
  const warrant = selectedWarrant(result);
140
140
  const receipt = result.receipt;
141
+ const expectedOldStateRoot = receipt?.expectedOldStateRoot;
142
+ const recovery = result.concurrencyRecovery;
143
+ const rebased = expectedOldStateRoot !== previousStateRoot;
141
144
  if (
142
145
  receipt?.action !== "heartbeat" ||
143
- result.before?.stateRoot !== previousStateRoot ||
144
- receipt.expectedOldStateRoot !== previousStateRoot ||
146
+ result.before?.stateRoot !== expectedOldStateRoot ||
145
147
  result.after?.stateRoot !== receipt.nextStateRoot ||
146
148
  result.observation?.stateRoot !== receipt.nextStateRoot ||
147
149
  warrant?.fencingToken !== receipt.fencingToken ||
148
- warrant?.generation !== receipt.leaseGeneration
150
+ warrant?.generation !== receipt.leaseGeneration ||
151
+ (rebased &&
152
+ (recovery?.action !== "heartbeat-state-root-rebased" ||
153
+ recovery.requestedStateRoot !== previousStateRoot ||
154
+ recovery.observedStateRoot !== expectedOldStateRoot)) ||
155
+ (!rebased && recovery)
149
156
  ) {
150
157
  throw new Error(
151
158
  "durable provider heartbeat transition is not root-continuous",
@@ -155,8 +162,10 @@ function heartbeatEntry(result, previousStateRoot) {
155
162
  throw new Error("durable provider heartbeat receipt root drift");
156
163
  }
157
164
  return {
158
- expectedOldStateRoot: receipt.expectedOldStateRoot,
165
+ previousStateRoot,
166
+ expectedOldStateRoot,
159
167
  nextStateRoot: receipt.nextStateRoot,
168
+ concurrencyRecovery: recovery || null,
160
169
  receipt,
161
170
  receiptRoot: result.receiptRoot,
162
171
  heartbeatAt: timestamp(warrant.heartbeatAt, "durable heartbeatAt"),
@@ -274,13 +283,20 @@ function verifyHeartbeatContinuity(receipt, initial) {
274
283
  let previousRoot = initial.stateRoot;
275
284
  let previousTime = Date.parse(receipt.initialHeartbeatAt);
276
285
  for (const entry of receipt.heartbeats) {
286
+ const rebased = entry.expectedOldStateRoot !== previousRoot;
287
+ const recovery = entry.concurrencyRecovery;
277
288
  if (
278
- entry.expectedOldStateRoot !== previousRoot ||
289
+ entry.previousStateRoot !== previousRoot ||
279
290
  devDeliveryContentRoot(entry.receipt) !== entry.receiptRoot ||
280
291
  entry.receipt.expectedOldStateRoot !== entry.expectedOldStateRoot ||
281
292
  entry.receipt.nextStateRoot !== entry.nextStateRoot ||
282
293
  entry.receipt.fencingToken !== initial.fencingToken ||
283
- entry.receipt.leaseGeneration !== initial.generation
294
+ entry.receipt.leaseGeneration !== initial.generation ||
295
+ (rebased &&
296
+ (recovery?.action !== "heartbeat-state-root-rebased" ||
297
+ recovery.requestedStateRoot !== previousRoot ||
298
+ recovery.observedStateRoot !== entry.expectedOldStateRoot)) ||
299
+ (!rebased && recovery)
284
300
  ) {
285
301
  throw new Error("provider heartbeat root continuity mismatch");
286
302
  }
@@ -218,7 +218,8 @@ export function recoverLegacyTerminalDevDeliveryQueue(
218
218
  evidenceRoot: entry.evidenceRoot,
219
219
  });
220
220
  }
221
- queue.activeWarrant = null;
221
+ if (transitions.some((entry) => entry.activeWarrant))
222
+ queue.activeWarrant = null;
222
223
  queue.generation += 1;
223
224
  queue.updatedAt = currentTime;
224
225
  queue.stateRoot = devDeliveryContentRoot(queue);
@@ -236,7 +237,8 @@ export function recoverLegacyTerminalDevDeliveryQueue(
236
237
  nextStateRoot: after.stateRoot,
237
238
  requestRoot,
238
239
  transitions,
239
- nextAction: "Select the next strictly valid queued candidate, if any.",
240
+ nextAction:
241
+ "Continue the exact active Warrant, or select the next candidate.",
240
242
  };
241
243
  return {
242
244
  queue: after,
@@ -0,0 +1,33 @@
1
+ export function lacksExactNativeExecutionContract(
2
+ candidate,
3
+ allowLegacyV3Readback = false,
4
+ ) {
5
+ const native =
6
+ candidate.deliveryClass !== "non-native-fast" ||
7
+ candidate.environmentRoot ||
8
+ candidate.nativeCommandContract;
9
+ return Boolean(
10
+ native &&
11
+ (!candidate.environmentRoot ||
12
+ (!candidate.nativeCommandContract && !allowLegacyV3Readback)),
13
+ );
14
+ }
15
+
16
+ export function lacksLiveNativeProof(
17
+ candidate,
18
+ status,
19
+ { allowLegacyV3Readback = false, allowLegacyQueuedReadback = false } = {},
20
+ ) {
21
+ return (
22
+ lacksExactNativeExecutionContract(candidate, allowLegacyV3Readback) &&
23
+ !(status === "queued" && allowLegacyQueuedReadback) &&
24
+ !TERMINAL_STATES.has(status)
25
+ );
26
+ }
27
+ const TERMINAL_STATES = new Set([
28
+ "merged",
29
+ "terminal-failure",
30
+ "dequeued",
31
+ "cancelled",
32
+ "superseded",
33
+ ]);
@@ -12,6 +12,8 @@ import {
12
12
  import {
13
13
  chainedDevDeliveryAttemptInput,
14
14
  createDevDeliveryCandidateIdentity,
15
+ EXACT_DEV_DELIVERY_PROOF_FIELDS,
16
+ matchesExactDevDeliveryCandidate,
15
17
  validateDevDeliveryCandidateChain,
16
18
  } from "./dev-delivery-candidate-identity.js";
17
19
  import {
@@ -19,6 +21,10 @@ import {
19
21
  normalizeNativeCommandContract,
20
22
  validateActiveDevDeliveryWarrant,
21
23
  } from "./dev-delivery-native-proof.js";
24
+ import {
25
+ lacksExactNativeExecutionContract,
26
+ lacksLiveNativeProof,
27
+ } from "./dev-delivery-warrant-native-compatibility.js";
22
28
  import {
23
29
  normalizeProviderFailureAuthorityBinding,
24
30
  normalizeTerminalEvidenceCorrection,
@@ -34,6 +40,8 @@ export const DEV_DELIVERY_WARRANT_SCHEMA =
34
40
  "kungfu.buildchain.dev-delivery-warrant/v1";
35
41
  export const DEV_DELIVERY_SUBMISSION_RECEIPT_SCHEMA =
36
42
  "kungfu.buildchain.dev-delivery-submission-receipt/v1";
43
+ export const DEV_DELIVERY_MINIMUM_WRITER_PROTOCOL_ROOT =
44
+ "sha256:54a203cadf0b14d4e3c198a3cc3c177c42813aa1c0cca03e900df714b6ae5563";
37
45
  export const DEV_DELIVERY_SELECTION_RECEIPT_SCHEMA =
38
46
  "kungfu.buildchain.dev-delivery-selection-receipt/v1";
39
47
  export const DEV_DELIVERY_LEASE_RECEIPT_SCHEMA =
@@ -146,7 +154,7 @@ function exactRoots(values, label) {
146
154
  return [...new Set(values.map((value) => exactRoot(value, label)))].sort();
147
155
  }
148
156
  function normalizePolicy(policy = {}) {
149
- return {
157
+ const normalized = {
150
158
  agingSeconds: positiveInteger(
151
159
  policy.agingSeconds,
152
160
  "policy agingSeconds",
@@ -160,22 +168,17 @@ function normalizePolicy(policy = {}) {
160
168
  ),
161
169
  emergencyPolicy: text(policy.emergencyPolicy || "reviewed-explicit-only"),
162
170
  };
171
+ if (Object.hasOwn(policy, "minimumWriterProtocolRoot")) {
172
+ const root = exactRoot(
173
+ policy.minimumWriterProtocolRoot,
174
+ "policy minimumWriterProtocolRoot",
175
+ );
176
+ if (root !== DEV_DELIVERY_MINIMUM_WRITER_PROTOCOL_ROOT)
177
+ throw new Error("unsupported dev delivery minimum writer protocol");
178
+ normalized.minimumWriterProtocolRoot = root;
179
+ }
180
+ return normalized;
163
181
  }
164
-
165
- function lacksLiveNativeProof(candidate, status, allowLegacyV3Readback) {
166
- const { environmentRoot, nativeCommandContract } = candidate;
167
- const native =
168
- candidate.deliveryClass !== "non-native-fast" ||
169
- environmentRoot ||
170
- nativeCommandContract;
171
- return (
172
- native &&
173
- (!environmentRoot ||
174
- (!nativeCommandContract && allowLegacyV3Readback !== true)) &&
175
- !TERMINAL_STATES.has(status)
176
- );
177
- }
178
-
179
182
  function normalizeCandidate(input, expected) {
180
183
  const identity = createDevDeliveryCandidateIdentity(
181
184
  input,
@@ -274,7 +277,12 @@ function normalizeCandidate(input, expected) {
274
277
  "candidate shardEvidenceRoots",
275
278
  );
276
279
  }
277
- if (lacksLiveNativeProof(candidate, status, expected.allowLegacyV3Readback))
280
+ if (
281
+ lacksLiveNativeProof(candidate, status, {
282
+ allowLegacyV3Readback: expected.allowLegacyV3Readback,
283
+ allowLegacyQueuedReadback: expected.allowLegacyQueuedNativeReadback,
284
+ })
285
+ )
278
286
  throw new Error("live native candidate requires exact native proof");
279
287
  if (Object.hasOwn(input, "releaseBlockerPriority"))
280
288
  candidate.releaseBlockerPriority = normalizeReleaseBlockerPriorityClaim(
@@ -308,7 +316,10 @@ export function createDevDeliveryQueue({
308
316
  protectedBase: protectedBase(protectedBaseInput),
309
317
  generation: 0,
310
318
  fencingCounter: 0,
311
- policy: normalizePolicy(policy),
319
+ policy: {
320
+ ...normalizePolicy(policy),
321
+ minimumWriterProtocolRoot: DEV_DELIVERY_MINIMUM_WRITER_PROTOCOL_ROOT,
322
+ },
312
323
  activeWarrant: null,
313
324
  candidates: [],
314
325
  updatedAt: timestamp(now, "now"),
@@ -344,16 +355,19 @@ export function normalizeDevDeliveryQueue(input, expected = {}) {
344
355
  "queue fencingCounter",
345
356
  );
346
357
  queue.policy = normalizePolicy(queue.policy);
358
+ const hasExecutionReceipt = !!queue.activeWarrant?.nativeExecutionReceiptRoot;
359
+ const hasQualificationReceipt =
360
+ !!queue.activeWarrant?.qualificationReceiptRoot;
347
361
  const allowLegacyV3Readback =
348
362
  expected.allowLegacyV3Readback === true &&
349
- !(queue.candidates || []).some(
350
- (candidate) => candidate?.nativeCommandContract,
351
- ) &&
352
- !queue.activeWarrant?.nativeCommandContract &&
353
- !queue.activeWarrant?.nativeExecutionReceiptRoot &&
354
- !queue.activeWarrant?.qualificationReceiptRoot;
363
+ hasExecutionReceipt === hasQualificationReceipt;
364
+ const candidateExpected = {
365
+ ...queue,
366
+ allowLegacyV3Readback,
367
+ allowLegacyQueuedNativeReadback: true,
368
+ };
355
369
  queue.candidates = (queue.candidates || []).map((candidate) =>
356
- normalizeCandidate(candidate, { ...queue, allowLegacyV3Readback }),
370
+ normalizeCandidate(candidate, candidateExpected),
357
371
  );
358
372
  validateDevDeliveryCandidateChain(queue.candidates, TERMINAL_STATES);
359
373
  queue.updatedAt = timestamp(queue.updatedAt, "queue updatedAt");
@@ -380,6 +394,8 @@ export function transitionDevDeliveryQueue(queueInput, mutate, nowInput) {
380
394
  delete queue.stateRoot;
381
395
  const now = timestamp(nowInput, "now");
382
396
  const result = mutate(queue, before, now);
397
+ if (result.preserveState)
398
+ return { before, after: before, expectedOldStateRoot, result };
383
399
  queue.generation += 1;
384
400
  queue.updatedAt = now;
385
401
  const after = withQueueRoot(queue);
@@ -478,34 +494,14 @@ export function submitDevDeliveryCandidate(
478
494
  `candidate ${attemptedCandidate.candidateId} is terminal and cannot be resubmitted`,
479
495
  );
480
496
  }
481
- const exactProofFields = [
482
- "sourcePatchRoot",
483
- "sourceProofRoot",
484
- "planRoot",
485
- "closureRoot",
486
- "dependencyRoot",
487
- "toolchainRoot",
488
- "environmentRoot",
489
- "sourceWorkflowRunId",
490
- ];
491
- const exactProofMatches =
492
- exactProofFields.every(
493
- (field) => existing[field] === attemptedCandidate[field],
494
- ) &&
495
- JSON.stringify(existing.affectedPaths || []) ===
496
- JSON.stringify(attemptedCandidate.affectedPaths || []) &&
497
- JSON.stringify(existing.shardEvidenceRoots || []) ===
498
- JSON.stringify(attemptedCandidate.shardEvidenceRoots || []) &&
499
- existing.nativeCommandContract?.commandRoot ===
500
- attemptedCandidate.nativeCommandContract?.commandRoot &&
501
- existing.releaseBlockerPriority?.claimRoot ===
502
- attemptedCandidate.releaseBlockerPriority?.claimRoot;
503
- if (
504
- existing.sourceHead === attemptedCandidate.sourceHead &&
505
- exactProofMatches
506
- ) {
507
- action = "duplicate-noop";
497
+ if (matchesExactDevDeliveryCandidate(existing, attemptedCandidate)) {
498
+ action =
499
+ before.activeWarrant?.candidateId === existing.candidateId
500
+ ? "active-warrant-noop"
501
+ : "duplicate-noop";
508
502
  selected = existing;
503
+ if (action === "active-warrant-noop")
504
+ return { candidate: selected, action, preserveState: true };
509
505
  } else {
510
506
  if (before.activeWarrant?.candidateId === existing.candidateId) {
511
507
  throw new Error(
@@ -515,7 +511,7 @@ export function submitDevDeliveryCandidate(
515
511
  const headChanged =
516
512
  existing.sourceHead !== attemptedCandidate.sourceHead;
517
513
  existing.sourceHead = attemptedCandidate.sourceHead;
518
- for (const field of exactProofFields)
514
+ for (const field of EXACT_DEV_DELIVERY_PROOF_FIELDS)
519
515
  existing[field] = attemptedCandidate[field];
520
516
  if (attemptedCandidate.nativeCommandContract)
521
517
  existing.nativeCommandContract =
@@ -585,7 +581,11 @@ export function rankDevDeliveryCandidates(
585
581
  });
586
582
  const currentTime = timestamp(now, "now");
587
583
  return queue.candidates
588
- .filter((candidate) => candidate.status === "queued")
584
+ .filter(
585
+ (candidate) =>
586
+ candidate.status === "queued" &&
587
+ !lacksExactNativeExecutionContract(candidate),
588
+ )
589
589
  .map((candidate) => ({
590
590
  candidate,
591
591
  priority: effectivePriority(candidate, queue.policy, currentTime),
@@ -29,6 +29,7 @@ import {
29
29
  DEV_DELIVERY_QUEUE_CONTRACT,
30
30
  DEV_DELIVERY_SELECTION_RECEIPT_SCHEMA,
31
31
  DEV_DELIVERY_SUBMISSION_RECEIPT_SCHEMA,
32
+ DEV_DELIVERY_MINIMUM_WRITER_PROTOCOL_ROOT,
32
33
  DEV_DELIVERY_WARRANT_SCHEMA,
33
34
  TERMINAL_STATES,
34
35
  createDevDeliveryQueue,
@@ -38,6 +39,10 @@ import {
38
39
  submitDevDeliveryCandidate,
39
40
  transitionDevDeliveryQueue as transition,
40
41
  } from "./dev-delivery-warrant-state.js";
42
+ import {
43
+ DEV_DELIVERY_WRITER_PROTOCOL_FENCE_RECEIPT_SCHEMA,
44
+ fenceDevDeliveryWriterProtocol,
45
+ } from "./dev-delivery-writer-protocol-transition.js";
41
46
 
42
47
  export { devDeliveryContentRoot } from "./dev-delivery-common.js";
43
48
  export {
@@ -85,8 +90,11 @@ export {
85
90
  DEV_DELIVERY_QUEUE_CONTRACT,
86
91
  DEV_DELIVERY_SELECTION_RECEIPT_SCHEMA,
87
92
  DEV_DELIVERY_SUBMISSION_RECEIPT_SCHEMA,
93
+ DEV_DELIVERY_MINIMUM_WRITER_PROTOCOL_ROOT,
94
+ DEV_DELIVERY_WRITER_PROTOCOL_FENCE_RECEIPT_SCHEMA,
88
95
  DEV_DELIVERY_WARRANT_SCHEMA,
89
96
  createDevDeliveryQueue,
97
+ fenceDevDeliveryWriterProtocol,
90
98
  normalizeDevDeliveryQueue,
91
99
  rankDevDeliveryCandidates,
92
100
  submitDevDeliveryCandidate,
@@ -0,0 +1,72 @@
1
+ import { devDeliveryContentRoot } from "./dev-delivery-common.js";
2
+ import {
3
+ DEV_DELIVERY_MINIMUM_WRITER_PROTOCOL_ROOT,
4
+ TERMINAL_STATES,
5
+ transitionDevDeliveryQueue,
6
+ } from "./dev-delivery-warrant-state.js";
7
+
8
+ export const DEV_DELIVERY_WRITER_PROTOCOL = Object.freeze({
9
+ schema: "kungfu.buildchain.dev-delivery-writer-protocol/v1",
10
+ requiredCandidateCapabilities: [
11
+ "environment-root-v1",
12
+ "native-command-contract-v1",
13
+ ],
14
+ });
15
+ export const DEV_DELIVERY_WRITER_PROTOCOL_FENCE_RECEIPT_SCHEMA =
16
+ "kungfu.buildchain.dev-delivery-writer-protocol-fence-receipt/v1";
17
+ if (
18
+ devDeliveryContentRoot(DEV_DELIVERY_WRITER_PROTOCOL) !==
19
+ DEV_DELIVERY_MINIMUM_WRITER_PROTOCOL_ROOT
20
+ ) {
21
+ throw new Error("dev delivery writer protocol root drift");
22
+ }
23
+
24
+ export function fenceDevDeliveryWriterProtocol(
25
+ queueInput,
26
+ { now = new Date().toISOString() } = {},
27
+ ) {
28
+ const transaction = transitionDevDeliveryQueue(
29
+ queueInput,
30
+ (queue) => {
31
+ if (
32
+ queue.policy.minimumWriterProtocolRoot ===
33
+ DEV_DELIVERY_MINIMUM_WRITER_PROTOCOL_ROOT
34
+ ) {
35
+ return {
36
+ action: "minimum-writer-protocol-already-fenced",
37
+ preserveState: true,
38
+ };
39
+ }
40
+ if (
41
+ queue.activeWarrant ||
42
+ queue.candidates.some(
43
+ (candidate) => !TERMINAL_STATES.has(candidate.status),
44
+ )
45
+ ) {
46
+ throw new Error(
47
+ "minimum writer protocol can be fenced only while the queue is idle",
48
+ );
49
+ }
50
+ queue.policy.minimumWriterProtocolRoot =
51
+ DEV_DELIVERY_MINIMUM_WRITER_PROTOCOL_ROOT;
52
+ return { action: "minimum-writer-protocol-fenced" };
53
+ },
54
+ now,
55
+ );
56
+ const receipt = {
57
+ schema: DEV_DELIVERY_WRITER_PROTOCOL_FENCE_RECEIPT_SCHEMA,
58
+ action: transaction.result.action,
59
+ repository: transaction.after.repository,
60
+ protectedBase: transaction.after.protectedBase,
61
+ minimumWriterProtocolRoot: DEV_DELIVERY_MINIMUM_WRITER_PROTOCOL_ROOT,
62
+ expectedOldStateRoot: transaction.expectedOldStateRoot,
63
+ nextStateRoot: transaction.after.stateRoot,
64
+ nextAction:
65
+ "Use only a Buildchain runtime that preserves the rooted minimum writer protocol.",
66
+ };
67
+ return {
68
+ queue: transaction.after,
69
+ receipt,
70
+ receiptRoot: devDeliveryContentRoot(receipt),
71
+ };
72
+ }
@@ -61,6 +61,16 @@ const ROOT_DOMAINS = new Set([
61
61
  "tail-reseal-artifact-files",
62
62
  "tail-reseal-receipt",
63
63
  "release-candidate-passport",
64
+ "release-invocation-publisher",
65
+ "release-invocation-runtime",
66
+ "release-invocation-candidate",
67
+ "release-invocation-target",
68
+ "release-invocation-authority",
69
+ "release-invocation-provider",
70
+ "release-invocation-parent",
71
+ "release-invocation",
72
+ "release-transaction",
73
+ "release-receipt",
64
74
  ]);
65
75
  const FAULT_CLASSES = new Set([
66
76
  "validation",
@@ -302,8 +302,11 @@ function classifyBuildchainUses(records, failures, { repository } = {}) {
302
302
  parsed.selector === ALPHA_RECOVERY_BOOTSTRAP.selector;
303
303
  const protectedBootstrap =
304
304
  repository === BUILDCHAIN_REPOSITORY && bootstrapShape;
305
+ const unauthorizedBootstrap =
306
+ repository !== BUILDCHAIN_REPOSITORY && bootstrapShape;
305
307
  const channel =
306
- CHANNELS[parsed.selector] || (protectedBootstrap ? "alpha" : "");
308
+ !unauthorizedBootstrap &&
309
+ (CHANNELS[parsed.selector] || (protectedBootstrap ? "alpha" : ""));
307
310
  uses.push({
308
311
  ...record,
309
312
  ...parsed,
@@ -0,0 +1,93 @@
1
+ import { v4ContentRoot } from "./v4-canonical-contracts.js";
2
+
3
+ const SHA_PATTERN = /^[0-9a-f]{40}$/u;
4
+
5
+ function exactSha(value, label) {
6
+ const normalized = String(value || "").toLowerCase();
7
+ if (!SHA_PATTERN.test(normalized)) {
8
+ throw new Error(`${label} must be an exact Git SHA`);
9
+ }
10
+ return normalized;
11
+ }
12
+
13
+ function exactParents(value, label) {
14
+ if (!Array.isArray(value)) {
15
+ throw new Error(`${label} must be an ordered Git parent list`);
16
+ }
17
+ return value.map((entry, index) => exactSha(entry, `${label}[${index}]`));
18
+ }
19
+
20
+ export function bindV4ProtectedPublicationSource({
21
+ repository,
22
+ protectedCommit,
23
+ candidateCommit,
24
+ pullRequest,
25
+ } = {}) {
26
+ if (!/^[^/\s]+\/[^/\s]+$/u.test(String(repository || ""))) {
27
+ throw new Error("protected publication source requires owner/repository");
28
+ }
29
+ const protectedSource = {
30
+ sha: exactSha(protectedCommit?.sha, "protected source SHA"),
31
+ tree: exactSha(protectedCommit?.tree, "protected source tree"),
32
+ parents: exactParents(protectedCommit?.parents, "protected source parents"),
33
+ };
34
+ const candidateSource = {
35
+ sha: exactSha(candidateCommit?.sha, "candidate source SHA"),
36
+ tree: exactSha(candidateCommit?.tree, "candidate source tree"),
37
+ parents: exactParents(candidateCommit?.parents, "candidate source parents"),
38
+ };
39
+ if (protectedSource.tree !== candidateSource.tree) {
40
+ throw new Error(
41
+ "protected publication source tree does not match the qualified candidate tree",
42
+ );
43
+ }
44
+
45
+ let mode = "exact-commit";
46
+ let pullRequestNumber = null;
47
+ if (protectedSource.sha !== candidateSource.sha) {
48
+ mode = "merge-equivalent";
49
+ const sameParents =
50
+ protectedSource.parents.length === candidateSource.parents.length &&
51
+ protectedSource.parents.every(
52
+ (parent, index) => parent === candidateSource.parents[index],
53
+ );
54
+ if (!sameParents) {
55
+ throw new Error(
56
+ "protected publication source is not parent-equivalent to the qualified merge candidate",
57
+ );
58
+ }
59
+ pullRequestNumber = Number(pullRequest?.number || 0);
60
+ const pullRequestHead = exactSha(
61
+ pullRequest?.headSha,
62
+ "publication pull request head SHA",
63
+ );
64
+ const pullRequestMerge = exactSha(
65
+ pullRequest?.mergeSha,
66
+ "publication pull request merge SHA",
67
+ );
68
+ if (
69
+ !Number.isSafeInteger(pullRequestNumber) ||
70
+ pullRequestNumber <= 0 ||
71
+ pullRequest?.merged !== true ||
72
+ pullRequestMerge !== protectedSource.sha ||
73
+ !candidateSource.parents.includes(pullRequestHead)
74
+ ) {
75
+ throw new Error(
76
+ "protected publication source does not match the merged pull request and qualified merge candidate",
77
+ );
78
+ }
79
+ }
80
+
81
+ const binding = {
82
+ schema: "kungfu.buildchain.v4-protected-publication-source/v1",
83
+ repository,
84
+ mode,
85
+ protectedSource,
86
+ candidateSource,
87
+ pullRequestNumber,
88
+ };
89
+ return {
90
+ ...binding,
91
+ bindingRoot: v4ContentRoot("candidate-identity", binding),
92
+ };
93
+ }
@@ -207,6 +207,7 @@ export function validateV4PublicationQualificationReceipt(
207
207
  export function assertV4DeclarativePromotionInputs(inputs) {
208
208
  const forbidden = Object.entries(inputs || {}).filter(
209
209
  ([name, value]) =>
210
+ name !== "dry-run" &&
210
211
  /(command|cmd|script|shell|run)$/iu.test(name) &&
211
212
  String(value || "").trim() !== "",
212
213
  );