@kungfu-tech/buildchain 4.0.2-alpha.16 → 4.0.2-alpha.18

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kungfu-tech/buildchain",
3
- "version": "4.0.2-alpha.16",
3
+ "version": "4.0.2-alpha.18",
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",
@@ -10,11 +10,9 @@ const DESCRIPTORS = Object.freeze([
10
10
  [".github/workflows/.release-candidate-promote.yml", "product-publication", true, ["npm-publish", "github-release", "channel-ref"], "trusted-publishing", "none", "fixed", "caller-bound"],
11
11
  [".github/workflows/.publication-authority.yml", "evidence-publication"],
12
12
  [".github/workflows/.release-verify.yml", "governance-write"],
13
- [".github/workflows/.sam-release.yml", "retired-deny"],
14
13
  [".github/workflows/.sam-verify.yml", "retired-deny"],
15
14
  [".github/workflows/.sync-remote-git.yml", "governance-write"],
16
15
  [".github/workflows/.web-surface.yml", "product-publication", true, ["web-production"], "oidc", "consumer-defined", "caller-bound", "caller-bound"],
17
- [".github/workflows/.wheel-release.yml", "retired-deny"],
18
16
  [".github/workflows/.wheel-verify.yml", "retired-deny"],
19
17
  [".github/workflows/.binary-release-assets.yml", "product-publication", true, ["github-release"], "github-token", "buildchain-release-assets"],
20
18
  [".github/workflows/binary-distribution.yml", "evidence-publication"],
@@ -266,7 +266,6 @@ export function validateV4UniversalWorkflowRequest(value) {
266
266
  payload: canonical(value.payload),
267
267
  };
268
268
  }
269
-
270
269
  export function v4UniversalWorkflowRequestRoot(value) {
271
270
  return documentRoot(
272
271
  "universal-workflow-request",
@@ -274,9 +273,10 @@ export function v4UniversalWorkflowRequestRoot(value) {
274
273
  );
275
274
  }
276
275
  export function v4ProductStateVersion(value, requestedSha) { const sourceSha = exactSha(requestedSha, "requestedSha"), ref = nonEmpty(value?.ref, "productStateRef.ref"), prefix = `refs/heads/buildchain/v4-product-state/${sourceSha}-`; if (!ref.startsWith(prefix)) fail("recovery-state-mismatch", "release recovery product state does not bind the requested source"); const match = ref.slice(prefix.length).match(/^(\d+)-(\d+)-(\d+)(?:-alpha-(\d+))?$/u); if (!match) fail("invalid-recovery-version", "release recovery product state version is invalid"); return `${match[1]}.${match[2]}.${match[3]}${match[4] === undefined ? "" : `-alpha.${match[4]}`}`; }
276
+ export function selectV4FinalizedProductPublicationVersion(value) { const requestedSha = exactSha(value.requestedSha, "requestedSha"), requestedTree = exactSha(value.requestedTree, "requestedTree"), lane = nonEmpty(value.targetRef, "targetRef").match(/^(alpha|release)\/v(\d+)\/v(\d+)\.(\d+)$/u); if (!lane || lane[2] !== lane[3]) fail("invalid-finalization-lane", "product publication finalization target is not a release lane"); const expectedAlpha = lane[1] === "alpha", versions = []; for (const row of Array.isArray(value.recoveryStates) ? value.recoveryStates : []) { const stateRef = row?.stateRef, match = String(stateRef?.ref || "").match(/^refs\/heads\/buildchain\/v4-product-state\/([0-9a-f]{40})-(\d+)-(\d+)-(\d+)(?:-alpha-(\d+))?$/u); if (!match || match[2] !== lane[2] || match[3] !== lane[4]) continue; const stateTree = exactSha(row?.stateCommit?.tree?.sha, "productStateCommit.tree.sha"); if (stateTree !== requestedTree || !new Set(["ahead", "identical"]).has(row.headComparisonStatus)) continue; const sourceSha = exactSha(match[1], "productStateRef.sourceSha"), version = v4ProductStateVersion(stateRef, sourceSha), parsed = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?$/u); if ((parsed[4] !== undefined) !== expectedAlpha) continue; if (stateRef?.object?.type !== "commit" || exactSha(stateRef?.object?.sha, "productStateRef.object.sha") !== exactSha(row?.stateCommit?.sha, "productStateCommit.sha") || row.stateCommit.parents?.length !== 1 || exactSha(row.stateCommit.parents[0]?.sha, "productStateCommit.parents[0].sha") !== sourceSha) fail("finalization-state-mismatch", "product publication finalization state does not bind its source"); if (row.exactTagRef && (row.exactTagRef.ref !== `refs/tags/v${version}` || row.exactTagRef.object?.type !== "commit" || exactSha(row.exactTagRef.object?.sha, "exactTagRef.object.sha") !== sourceSha)) fail("finalization-tag-mismatch", "product publication finalization tag does not bind its source"); versions.push(version); } const selected = [...new Set(versions)].sort(); if (selected.length > 1) fail("finalization-state-ambiguous", `publication head ${requestedSha} matches multiple product versions`); return selected[0] || ""; }
277
277
  export function selectV4RecoveredProductPublicationVersion(value) {
278
278
  if (value.routeDecision !== "Resume") return ""; const version = nonEmpty(value.candidateVersion, "candidateVersion"), sourceSha = exactSha(value.requestedSha, "requestedSha"), candidate = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?$/u); if (!candidate) fail("invalid-recovery-version", "release recovery candidate version is invalid"); if (value.explicitResume) return version;
279
- const states = Array.isArray(value.recoveryStates) ? value.recoveryStates : []; if (states.length) { const recovered = states.map(({ stateRef, stateCommit, exactTagRef }) => { const selected = v4ProductStateVersion(stateRef, sourceSha), parsed = selected.match(/^(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?$/u), parents = stateCommit?.parents || []; if (stateRef?.object?.type !== "commit" || exactSha(stateRef?.object?.sha, "productStateRef.object.sha") !== exactSha(stateCommit?.sha, "productStateCommit.sha") || parents.length !== 1 || exactSha(parents[0]?.sha, "productStateCommit.parents[0].sha") !== sourceSha) fail("recovery-state-mismatch", "release recovery product state commit does not bind the requested source"); if (exactTagRef && (exactTagRef.ref !== `refs/tags/v${selected}` || exactTagRef.object?.type !== "commit" || exactSha(exactTagRef.object?.sha, "exactTagRef.object.sha") !== sourceSha)) fail("recovery-tag-mismatch", "release recovery exact tag does not bind the requested source"); if (parsed[1] !== candidate[1] || parsed[2] !== candidate[2] || parsed[3] !== candidate[3] || (parsed[4] === undefined) !== (candidate[4] === undefined)) fail("recovery-state-mismatch", "release recovery product state is outside the candidate release line"); return selected; }); recovered.sort((left, right) => Number(left.match(/(?:-alpha\.)?(\d+)$/u)[1]) - Number(right.match(/(?:-alpha\.)?(\d+)$/u)[1])); return recovered.at(-1); }
279
+ const states = Array.isArray(value.recoveryStates) ? value.recoveryStates : []; if (states.length) { const recovered = [...new Set(states.map(({ stateRef, stateCommit, exactTagRef }) => { const selected = v4ProductStateVersion(stateRef, sourceSha), parsed = selected.match(/^(\d+)\.(\d+)\.(\d+)(?:-alpha\.(\d+))?$/u), parents = stateCommit?.parents || []; if (stateRef?.object?.type !== "commit" || exactSha(stateRef?.object?.sha, "productStateRef.object.sha") !== exactSha(stateCommit?.sha, "productStateCommit.sha") || parents.length !== 1 || exactSha(parents[0]?.sha, "productStateCommit.parents[0].sha") !== sourceSha) fail("recovery-state-mismatch", "release recovery product state commit does not bind the requested source"); if (exactTagRef && (exactTagRef.ref !== `refs/tags/v${selected}` || exactTagRef.object?.type !== "commit" || exactSha(exactTagRef.object?.sha, "exactTagRef.object.sha") !== sourceSha)) fail("recovery-tag-mismatch", "release recovery exact tag does not bind the requested source"); if (parsed[1] !== candidate[1] || parsed[2] !== candidate[2] || parsed[3] !== candidate[3] || (parsed[4] === undefined) !== (candidate[4] === undefined)) fail("recovery-state-mismatch", "release recovery product state is outside the candidate release line"); return selected; }))]; if (recovered.length !== 1) fail("recovery-state-ambiguous", "release recovery requires one exact product publication state; provide an exact transaction identity"); return recovered[0]; }
280
280
  if (!value.exactTagRef) fail("recovery-tag-missing", "release recovery requires an exact partial-publication tag"); if (value.exactTagRef.ref !== `refs/tags/v${version}` || value.exactTagRef.object?.type !== "commit" || exactSha(value.exactTagRef.object?.sha, "exactTagRef.object.sha") !== sourceSha) fail("recovery-tag-mismatch", "release recovery exact tag does not bind the requested source");
281
281
  return version;
282
282
  }
@@ -1043,8 +1043,8 @@ for (const requiredSnippet of [
1043
1043
  "actions: write",
1044
1044
  "uses: kungfu-systems/buildchain/.github/workflows/.release-candidate-promote.yml@v4-alpha",
1045
1045
  "github.event.workflow_run.event == 'push'",
1046
- "!startsWith(github.event.workflow_run.display_title, 'chore(release): prepare v')",
1047
- "!startsWith(github.event.workflow_run.display_title, 'chore(release): release v')",
1046
+ "name: Classify generated product-state finalization",
1047
+ "selectV4FinalizedProductPublicationVersion",
1048
1048
  "resume-candidate-run-id:",
1049
1049
  "resume-expected-source-tree:",
1050
1050
  "resume-buildchain-runtime-ref:",
@@ -1056,12 +1056,19 @@ for (const requiredSnippet of [
1056
1056
  throw new Error(`buildchain ref promotion workflow missing npm transaction snippet: ${requiredSnippet}`);
1057
1057
  }
1058
1058
  }
1059
+ if (buildchainRefPromotionWorkflow.includes("workflow_run.display_title")) {
1060
+ throw new Error(
1061
+ "buildchain ref promotion must classify finalization from rooted product state, not a display title",
1062
+ );
1063
+ }
1059
1064
  const releaseCandidatePromoteWorkflow = fs.readFileSync(path.join(root, ".github/workflows/.release-candidate-promote.yml"), "utf8");
1060
1065
  for (const requiredSnippet of [
1061
1066
  "name: QUALIFY canonical v4 release invocation inputs",
1062
1067
  "name: APPLY one rooted provider transaction",
1063
1068
  "name: SETTLE terminal ReleaseReceipt projection",
1064
1069
  "uses: ./.buildchain/runtime/actions/v4-release-candidate-promote",
1070
+ "name: Resolve one exact product publication recovery",
1071
+ "selectV4RecoveredProductPublicationVersion",
1065
1072
  "publisher-workflow-sha:",
1066
1073
  "runtime-commit:",
1067
1074
  "runtime-tree:",
@@ -1101,31 +1108,15 @@ for (const workflowFile of fs.readdirSync(workflowDir).filter((entry) => entry.e
1101
1108
  }
1102
1109
  }
1103
1110
  for (const retiredWorkflow of [
1111
+ ".release-docker.yml",
1104
1112
  ".release-new-version.yml",
1105
1113
  ".release-elastic-beanstalk.yml",
1106
1114
  ".sam-release.yml",
1107
1115
  ".wheel-release.yml",
1116
+ "schedule-purge-artifacts.yml",
1108
1117
  ]) {
1109
- const retiredSource = fs.readFileSync(path.join(workflowDir, retiredWorkflow), "utf8");
1110
- for (const requiredSnippet of [
1111
- "release path is retired",
1112
- "release-candidate-promote.yml@v3",
1113
- "publish-gate source-lock enforcement",
1114
- ]) {
1115
- if (!retiredSource.includes(requiredSnippet)) {
1116
- throw new Error(`${retiredWorkflow} must fail closed and point callers at the source-locked release-candidate-promote model: ${requiredSnippet}`);
1117
- }
1118
- }
1119
- for (const forbiddenSnippet of [
1120
- "npm publish --access=public",
1121
- "actions/publish-prebuilt@v2",
1122
- "actions/bump-version@v2",
1123
- "beanstalk-deploy@",
1124
- "sam deploy",
1125
- ]) {
1126
- if (retiredSource.includes(forbiddenSnippet)) {
1127
- throw new Error(`${retiredWorkflow} must not keep retired publish side effects: ${forbiddenSnippet}`);
1128
- }
1118
+ if (fs.existsSync(path.join(workflowDir, retiredWorkflow))) {
1119
+ throw new Error(`${retiredWorkflow} is fully retired and must remain deleted`);
1129
1120
  }
1130
1121
  }
1131
1122
  const promoteBuildchainRefAction = fs.readFileSync(path.join(root, "actions/promote-buildchain-ref/action.yml"), "utf8");