@kungfu-tech/buildchain 4.0.1-alpha.2 → 4.0.1-alpha.21

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 (203) hide show
  1. package/actions/release-tail/README.md +8 -0
  2. package/architecture/ci-lane-change-budget.json +187 -0
  3. package/architecture/decisions/0002-next-development-transition.md +101 -0
  4. package/architecture/decisions/0003-two-phase-delivery-warrant.md +152 -0
  5. package/architecture/internal-capabilities.json +211 -8
  6. package/architecture/maintainability-policy.json +113 -28
  7. package/architecture/release-tail-contract-inventory.json +5 -2
  8. package/architecture/v3-core-mechanism-inventory.json +91 -0
  9. package/architecture/v4-adopter-delivery-parity.json +32 -5
  10. package/architecture/v4-capability-state-machine-manifest.json +73 -0
  11. package/architecture/v4-compatibility-facts-parity.json +77 -0
  12. package/architecture/v4-delivery-authority-parity.json +250 -0
  13. package/architecture/v4-delivery-warrant-shadow-fixtures.json +41 -9
  14. package/architecture/v4-floating-consumer-policy.json +6 -0
  15. package/architecture/v4-next-development-parity.json +192 -0
  16. package/architecture/v4-publication-rehearsal-parity.json +84 -0
  17. package/architecture/v4-release-train-parity.json +1 -0
  18. package/architecture/v4-tail-reseal-parity.json +150 -0
  19. package/bin/buildchain.mjs +32 -3
  20. package/bin/internal/adopter-delivery-cli.mjs +70 -0
  21. package/bin/internal/command-registry.mjs +3 -0
  22. package/bin/internal/compatibility-facts-cli.mjs +101 -0
  23. package/contracts/dev-delivery-authority-v2.schema.json +662 -0
  24. package/contracts/fixtures/next-development-transition-v1/anchored-manual-waiting.json +47 -0
  25. package/contracts/fixtures/next-development-transition-v1/semver-auto-planned.json +47 -0
  26. package/contracts/fixtures/next-development-transition-v1/version-model-cases.json +40 -0
  27. package/contracts/fixtures/v4-adopter-delivery-v1/archive-template.json +19 -0
  28. package/contracts/fixtures/v4-adopter-delivery-v1/bootstrap-positive.json +93 -0
  29. package/contracts/fixtures/v4-adopter-delivery-v1/gate-positive.json +29 -0
  30. package/contracts/fixtures/v4-adopter-delivery-v1/gate-unknown-selector.json +26 -0
  31. package/contracts/fixtures/v4-adopter-delivery-v1/offline-vectors.json +50 -0
  32. package/contracts/fixtures/v4-compatibility-facts-v1/shared.json +1129 -0
  33. package/contracts/fixtures/v4-floating-consumer-policy-v1/cases.json +7 -1
  34. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/artifacts/product.bin +1 -0
  35. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/config/buildchain.toml +5 -0
  36. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/documents/release-activation.json +1 -0
  37. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/documents/signed-channel.json +1 -0
  38. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/evidence/qualification.json +1 -0
  39. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/manifests/candidate.json +5 -0
  40. package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/manifests/release-passport.json +1 -0
  41. package/contracts/fixtures/v4-publication-rehearsal-v1/capsule.json +707 -0
  42. package/contracts/fixtures/v4-publication-rehearsal-v1/offline-vectors.json +27 -0
  43. package/contracts/fixtures/v4-tail-reseal-v1/valid.json +229 -0
  44. package/contracts/next-development-request-v1.schema.json +66 -0
  45. package/contracts/next-development-transition-v1.schema.json +292 -0
  46. package/contracts/v4-adopter-delivery-v1.schema.json +81 -0
  47. package/contracts/v4-compatibility-facts-v1.schema.json +230 -0
  48. package/contracts/v4-floating-consumer-policy-receipt-v1.schema.json +4 -2
  49. package/contracts/v4-publication-rehearsal-capsule-v1.schema.json +233 -0
  50. package/contracts/v4-tail-reseal-v1.schema.json +276 -0
  51. package/dist/site/agent-index.json +5 -0
  52. package/dist/site/artifact-schemas.json +10 -0
  53. package/dist/site/buildchain-contract.json +1475 -27
  54. package/dist/site/buildchain-site.json +627 -31
  55. package/dist/site/capability-registry.json +17 -14
  56. package/dist/site/cli-registry.json +205 -3
  57. package/dist/site/kfd-claims.json +490 -16
  58. package/dist/site/kfd-upstream-aggregate.json +1 -1
  59. package/dist/site/manual-registry.json +52 -6
  60. package/dist/site/node-api-registry.json +14736 -8851
  61. package/dist/site/page-registry.json +593 -21
  62. package/dist/site/public-surface-audit.json +837 -48
  63. package/dist/site/publication-authority-registry.json +44 -8
  64. package/dist/site/publication-registry.json +4 -4
  65. package/dist/site/release-provenance.json +24 -0
  66. package/dist/site/schemas/dev-delivery-authority-v2.schema.json +662 -0
  67. package/dist/site/schemas/release-tail-capabilities-v1.schema.json +199 -0
  68. package/dist/site/schemas/v4-adopter-delivery-v1.schema.json +81 -0
  69. package/dist/site/schemas/v4-compatibility-facts-v1.schema.json +230 -0
  70. package/dist/site/schemas/v4-publication-rehearsal-capsule-v1.schema.json +233 -0
  71. package/dist/site/site-manifest.json +34 -10
  72. package/dist/site/workflow-registry.json +160 -10
  73. package/docs/MAP.md +8 -2
  74. package/docs/cli-reference.md +404 -13
  75. package/docs/cli.md +8 -0
  76. package/docs/dev-alpha-candidate-patrol.md +8 -0
  77. package/docs/dev-delivery-qualification-landing-adr.md +251 -0
  78. package/docs/dev-delivery-warrant.md +351 -38
  79. package/docs/next-development-transition.md +118 -0
  80. package/docs/node-api-reference.md +646 -293
  81. package/docs/release-tail-provider-plane.md +30 -0
  82. package/docs/v4-adopter-delivery.md +133 -0
  83. package/docs/v4-compatibility-facts.md +91 -0
  84. package/docs/v4-publication-rehearsal.md +130 -0
  85. package/docs/v4-tail-reseal.md +73 -0
  86. package/docs/versioning.md +4 -3
  87. package/package.json +34 -6
  88. package/packages/core/adopter-delivery-passport.js +259 -0
  89. package/packages/core/adopter-delivery-vectors.js +158 -0
  90. package/packages/core/adopter-delivery-vectors.json +77 -0
  91. package/packages/core/buildchain-agent-manuals.js +3 -0
  92. package/packages/core/buildchain-compatibility-authority.js +336 -0
  93. package/packages/core/buildchain-compatibility-fact.js +394 -0
  94. package/packages/core/buildchain-compatibility-facts.json +217 -0
  95. package/packages/core/buildchain-compatibility-proof.js +566 -0
  96. package/packages/core/buildchain-config.js +84 -0
  97. package/packages/core/buildchain-contract.js +96 -143
  98. package/packages/core/buildchain-delivery-bootstrap.js +240 -0
  99. package/packages/core/buildchain-delivery-infrastructure.js +164 -0
  100. package/packages/core/buildchain-delivery-self-dogfood.js +395 -0
  101. package/packages/core/buildchain-publication-authority.js +1 -0
  102. package/packages/core/channel-candidate.js +8 -0
  103. package/packages/core/channel-promotion-baseline.js +55 -0
  104. package/packages/core/ci-lane-change-budget.js +247 -0
  105. package/packages/core/dev-alpha-candidate-selection.js +10 -2
  106. package/packages/core/dev-delivery-authority-candidate.js +270 -0
  107. package/packages/core/dev-delivery-authority-evidence.js +146 -0
  108. package/packages/core/dev-delivery-authority-landing.js +461 -0
  109. package/packages/core/dev-delivery-authority-observation.js +48 -0
  110. package/packages/core/dev-delivery-authority-qualification.js +591 -0
  111. package/packages/core/dev-delivery-authority-settlement.js +213 -0
  112. package/packages/core/dev-delivery-authority-state.js +583 -0
  113. package/packages/core/dev-delivery-candidate-identity.js +13 -0
  114. package/packages/core/dev-delivery-contract-surface.js +76 -0
  115. package/packages/core/dev-delivery-execution-failure.js +133 -0
  116. package/packages/core/dev-delivery-execution-transfer.js +592 -0
  117. package/packages/core/dev-delivery-landing-admission-core.js +119 -0
  118. package/packages/core/dev-delivery-landing-readback.js +598 -0
  119. package/packages/core/dev-delivery-landing-terminal-evidence.js +271 -0
  120. package/packages/core/dev-delivery-landing-testing-port.js +6 -0
  121. package/packages/core/dev-delivery-native-execution.js +110 -0
  122. package/packages/core/dev-delivery-native-proof.js +562 -0
  123. package/packages/core/dev-delivery-process-boundary.js +563 -0
  124. package/packages/core/dev-delivery-provider-attempt.js +127 -0
  125. package/packages/core/dev-delivery-provider-heartbeat.js +382 -0
  126. package/packages/core/dev-delivery-warrant-cancellation.js +1 -0
  127. package/packages/core/dev-delivery-warrant-qualification.js +145 -0
  128. package/packages/core/dev-delivery-warrant-settlement.js +237 -36
  129. package/packages/core/dev-delivery-warrant-state.js +587 -0
  130. package/packages/core/dev-delivery-warrant.js +328 -370
  131. package/packages/core/github-governance-authority.js +1 -0
  132. package/packages/core/index.js +5 -0
  133. package/packages/core/kungfu-temporal-fact.js +557 -0
  134. package/packages/core/legacy-kfd-adopter-driver.js +167 -0
  135. package/packages/core/next-development-candidate-reservation.js +186 -0
  136. package/packages/core/next-development-controller.js +728 -0
  137. package/packages/core/next-development-projection.js +287 -0
  138. package/packages/core/next-development-transition.js +738 -0
  139. package/packages/core/paper-agent-entry.js +11 -5
  140. package/packages/core/paper.js +16 -5
  141. package/packages/core/published-delivery-authority.js +266 -0
  142. package/packages/core/release-candidate-recovery.js +70 -15
  143. package/packages/core/release-candidate.js +2 -2
  144. package/packages/core/release-passport.js +36 -9
  145. package/packages/core/v4-adopter-delivery-parity.js +3 -3
  146. package/packages/core/v4-adopter-delivery.js +359 -0
  147. package/packages/core/v4-canonical-contracts.js +5 -0
  148. package/packages/core/v4-delivery-warrant-read-candidate.js +10 -3
  149. package/packages/core/v4-floating-consumer-evidence.js +18 -4
  150. package/packages/core/v4-floating-consumer-policy.js +143 -20
  151. package/packages/core/v4-floating-consumer-release-passport.js +32 -5
  152. package/packages/core/v4-publication-rehearsal-capsule.js +468 -0
  153. package/packages/core/v4-publication-rehearsal-provider-bindings.js +212 -0
  154. package/packages/core/v4-publication-rehearsal.js +481 -0
  155. package/packages/core/v4-tail-reseal-contract.js +26 -0
  156. package/packages/core/v4-tail-reseal-github.js +178 -0
  157. package/packages/core/v4-tail-reseal-receipt.js +225 -0
  158. package/packages/core/v4-tail-reseal.js +594 -0
  159. package/packages/core/workflow-yaml-contract.js +24 -2
  160. package/scripts/buildchain-cli-help.mjs +41 -2
  161. package/scripts/check-ci-lane-change-budget.mjs +100 -0
  162. package/scripts/check-inventory.mjs +14 -3
  163. package/scripts/check-v4-floating-consumer-policy-contract.mjs +23 -4
  164. package/scripts/dev-alpha-candidate-patrol.mjs +22 -1
  165. package/scripts/dev-delivery-authority-command-adapters.mjs +206 -0
  166. package/scripts/dev-delivery-authority-provider.mjs +28 -0
  167. package/scripts/dev-delivery-authority.mjs +490 -0
  168. package/scripts/dev-delivery-native-run.mjs +177 -0
  169. package/scripts/dev-delivery-process-boundary.mjs +260 -0
  170. package/scripts/dev-delivery-proof.mjs +67 -2
  171. package/scripts/dev-delivery-provider-heartbeat.mjs +215 -0
  172. package/scripts/dev-delivery-source-proof-replay.mjs +153 -0
  173. package/scripts/dev-delivery-source-proof-reuse.mjs +13 -97
  174. package/scripts/dev-delivery-two-phase-resume.mjs +345 -0
  175. package/scripts/dev-delivery-two-phase.mjs +573 -0
  176. package/scripts/dev-delivery-warrant-options.mjs +266 -0
  177. package/scripts/dev-delivery-warrant-store.mjs +231 -0
  178. package/scripts/dev-delivery-warrant.mjs +232 -194
  179. package/scripts/dev-pr-auto-merge.mjs +1 -1
  180. package/scripts/dev-pr-delivery-warrant.mjs +11 -0
  181. package/scripts/dev-qualification-patrol.mjs +9 -9
  182. package/scripts/dispatch-artifact-signing-authority.mjs +1 -1
  183. package/scripts/generate-channel-promotion-workflow.mjs +2 -2
  184. package/scripts/generate-next-development-guidance.mjs +49 -0
  185. package/scripts/generate-release-candidate-passport.mjs +152 -0
  186. package/scripts/generate-site-bundle.mjs +69 -4
  187. package/scripts/init-repo.mjs +22 -4
  188. package/scripts/next-development-self-dogfood-harness.mjs +460 -0
  189. package/scripts/next-development-self-dogfood.mjs +597 -0
  190. package/scripts/next-development-transition.mjs +47 -0
  191. package/scripts/npm-publish-transaction.mjs +2 -2
  192. package/scripts/promotion-channel-router.mjs +4 -4
  193. package/scripts/release-candidate-anchor-provenance.mjs +99 -0
  194. package/scripts/release-tail.mjs +51 -3
  195. package/scripts/release-train-self-dogfood.mjs +94 -92
  196. package/scripts/resume-from-candidate-run.mjs +557 -30
  197. package/scripts/site-capability-metadata.mjs +41 -0
  198. package/scripts/stable-candidate-qualification.mjs +9 -10
  199. package/scripts/v4-consumer-policy.mjs +5 -5
  200. package/scripts/v4-publication-rehearsal-fixture.mjs +144 -0
  201. package/scripts/v4-tail-reseal-macos-rehearsal.mjs +134 -0
  202. package/scripts/v4-tail-reseal.mjs +416 -0
  203. package/templates/native-dev-delivery.yml +143 -0
@@ -0,0 +1,394 @@
1
+ import {
2
+ devDeliveryClone as clone,
3
+ devDeliveryContentRoot as contentRoot,
4
+ devDeliveryExactRoot as exactRoot,
5
+ devDeliveryExactSha as exactSha,
6
+ devDeliveryProtectedBase as protectedBase,
7
+ devDeliveryRepository as repository,
8
+ devDeliveryText as text,
9
+ } from "./dev-delivery-common.js";
10
+ import compatibilityFactSource from "./buildchain-compatibility-facts.json" with { type: "json" };
11
+ import {
12
+ KUNGFU_FACT_ROOT_PROTOCOL,
13
+ KUNGFU_TEMPORAL_BUNDLE_SCHEMA,
14
+ createKungfuTemporalEntry,
15
+ } from "./kungfu-temporal-fact.js";
16
+
17
+ export const BUILDCHAIN_COMPATIBILITY_PROOF_SCHEMA =
18
+ "kungfu.buildchain.compatibility-proof/v1";
19
+ export const BUILDCHAIN_COMPATIBILITY_PROOF_REGISTRY_SCHEMA =
20
+ "kungfu.buildchain.compatibility-proof-registry/v1";
21
+ export const BUILDCHAIN_COMPATIBILITY_FACT_SCHEMA =
22
+ "kungfu.buildchain.compatibility-fact/v1";
23
+ export const BUILDCHAIN_COMPATIBILITY_FACT_REGISTRY_SCHEMA =
24
+ "kungfu.buildchain.compatibility-fact-registry/v1";
25
+ export const BUILDCHAIN_COMPATIBILITY_RELEASE_EVIDENCE_SCHEMA =
26
+ "kungfu.buildchain.compatibility-fact-release-evidence/v1";
27
+
28
+ const BUILDCHAIN_CONTRACT = "kungfu-buildchain-runtime-contract-world";
29
+ const COMPATIBILITY_PREDICATE = "compatible-breaking-digest";
30
+ const COMPATIBILITY_OPERATION = "accept-contract-lock";
31
+ const COMPATIBILITY_DIRECTION = "source-to-target";
32
+ const COMPATIBILITY_PREDICATE_ID =
33
+ "kungfu.buildchain.compatibility:accept-contract-lock/v1";
34
+ const CURRENT_AUTHORITY = compatibilityFactSource.authority;
35
+ const CURRENT_PROOF_CUT = compatibilityFactSource.registryCut;
36
+
37
+ function exactText(value, label) {
38
+ const normalized = text(value);
39
+ if (!normalized) throw new Error(`${label} must not be empty`);
40
+ return normalized;
41
+ }
42
+
43
+ function majorLines(values) {
44
+ const normalized = [
45
+ ...new Set((values || []).map((value) => exactText(value, "majorLine"))),
46
+ ].sort();
47
+ if (
48
+ normalized.length === 0 ||
49
+ normalized.some((value) => !/^v\d+$/.test(value))
50
+ ) {
51
+ throw new Error("scope.majorLines must contain version-major identifiers");
52
+ }
53
+ return normalized;
54
+ }
55
+
56
+ function normalizeEvidence(value = {}) {
57
+ return {
58
+ kind: exactText(value.kind, "evidence.kind"),
59
+ pullRequest: exactText(value.pullRequest, "evidence.pullRequest"),
60
+ protectedBase: protectedBase(value.protectedBase),
61
+ sourceCommit: exactSha(value.sourceCommit, "evidence.sourceCommit"),
62
+ mergeCommit: exactSha(value.mergeCommit, "evidence.mergeCommit"),
63
+ contractDigest: exactRoot(value.contractDigest, "evidence.contractDigest"),
64
+ compatibilityDigest: exactRoot(
65
+ value.compatibilityDigest,
66
+ "evidence.compatibilityDigest",
67
+ ),
68
+ };
69
+ }
70
+
71
+ function normalizeAuthority(value = {}) {
72
+ return {
73
+ kind: exactText(value.kind, "authority.kind"),
74
+ repository: repository(value.repository),
75
+ protectedBase: protectedBase(value.protectedBase),
76
+ };
77
+ }
78
+
79
+ function normalizeCut(value = {}) {
80
+ return {
81
+ kind: exactText(value.kind, "cut.kind"),
82
+ repository: repository(value.repository),
83
+ protectedBase: protectedBase(value.protectedBase),
84
+ commit: exactSha(value.commit, "cut.commit"),
85
+ };
86
+ }
87
+
88
+ export function createBuildchainCompatibilityProof(input = {}) {
89
+ const surfaceId = exactText(input.surfaceId, "surfaceId");
90
+ const surfaceKind = exactText(input.surfaceKind, "surfaceKind");
91
+ const sourceBreakingDigest = exactRoot(
92
+ input.sourceBreakingDigest,
93
+ "sourceBreakingDigest",
94
+ );
95
+ const targetBreakingDigest = exactRoot(
96
+ input.targetBreakingDigest,
97
+ "targetBreakingDigest",
98
+ );
99
+ if (sourceBreakingDigest === targetBreakingDigest) {
100
+ throw new Error("compatibility proof source and target must differ");
101
+ }
102
+ const scope = {
103
+ contract: BUILDCHAIN_CONTRACT,
104
+ surfaceId,
105
+ surfaceKind,
106
+ majorLines: majorLines(input.scope?.majorLines || ["v2", "v3"]),
107
+ operation: COMPATIBILITY_OPERATION,
108
+ };
109
+ const evidence = normalizeEvidence(input.evidence);
110
+ const authority = normalizeAuthority(input.authority || CURRENT_AUTHORITY);
111
+ const cut = normalizeCut(input.cut || CURRENT_PROOF_CUT);
112
+ const body = {
113
+ schema: BUILDCHAIN_COMPATIBILITY_PROOF_SCHEMA,
114
+ proofId: exactText(input.proofId, "proofId"),
115
+ predicate: COMPATIBILITY_PREDICATE,
116
+ direction: COMPATIBILITY_DIRECTION,
117
+ operation: COMPATIBILITY_OPERATION,
118
+ source: {
119
+ contract: BUILDCHAIN_CONTRACT,
120
+ surfaceId,
121
+ surfaceKind,
122
+ breakingDigest: sourceBreakingDigest,
123
+ },
124
+ target: {
125
+ contract: BUILDCHAIN_CONTRACT,
126
+ surfaceId,
127
+ surfaceKind,
128
+ breakingDigest: targetBreakingDigest,
129
+ },
130
+ scope,
131
+ scopeRoot: contentRoot(scope),
132
+ evidence,
133
+ evidenceRoot: contentRoot(evidence),
134
+ authority,
135
+ authorityRoot: contentRoot(authority),
136
+ cut,
137
+ cutRoot: contentRoot(cut),
138
+ };
139
+ return { ...body, proofRoot: contentRoot(body) };
140
+ }
141
+
142
+ export function verifyBuildchainCompatibilityProof(proofInput, expected = {}) {
143
+ try {
144
+ const proof = clone(proofInput || {});
145
+ if (proof.schema !== BUILDCHAIN_COMPATIBILITY_PROOF_SCHEMA)
146
+ return { ok: false, reason: "unsupported-schema" };
147
+ const normalized = createBuildchainCompatibilityProof({
148
+ ...proof,
149
+ proofId: proof.proofId,
150
+ surfaceId: proof.source?.surfaceId,
151
+ surfaceKind: proof.source?.surfaceKind,
152
+ sourceBreakingDigest: proof.source?.breakingDigest,
153
+ targetBreakingDigest: proof.target?.breakingDigest,
154
+ scope: proof.scope,
155
+ });
156
+ if (normalized.proofRoot !== proof.proofRoot)
157
+ return { ok: false, reason: "proof-root-drift" };
158
+ if (JSON.stringify(normalized) !== JSON.stringify(proof))
159
+ return { ok: false, reason: "non-canonical-proof" };
160
+ for (const [field, value] of Object.entries(expected)) {
161
+ if (value !== undefined && normalized[field] !== value)
162
+ return { ok: false, reason: `${field}-mismatch` };
163
+ }
164
+ return {
165
+ ok: true,
166
+ reason: "exact-compatibility-proof",
167
+ proofRoot: normalized.proofRoot,
168
+ proof: normalized,
169
+ };
170
+ } catch (error) {
171
+ return { ok: false, reason: "invalid-proof", error: error.message };
172
+ }
173
+ }
174
+
175
+ function factInputFromProof(proof) {
176
+ return {
177
+ proofId: proof.proofId,
178
+ surfaceId: proof.source.surfaceId,
179
+ surfaceKind: proof.source.surfaceKind,
180
+ sourceBreakingDigest: proof.source.breakingDigest,
181
+ targetBreakingDigest: proof.target.breakingDigest,
182
+ scope: proof.scope,
183
+ evidence: proof.evidence,
184
+ authority: proof.authority,
185
+ cut: proof.cut,
186
+ };
187
+ }
188
+
189
+ export function createBuildchainCompatibilityFact(input = {}) {
190
+ const proof = createBuildchainCompatibilityProof(input);
191
+ const predicate = {
192
+ schema: "kungfu.fact.temporal-predicate/v1",
193
+ predicateId: COMPATIBILITY_PREDICATE_ID,
194
+ operations: [COMPATIBILITY_OPERATION],
195
+ direction: COMPATIBILITY_DIRECTION,
196
+ pathPolicy: "explicit-bounded",
197
+ cyclePolicy: "forbid",
198
+ authorityRoot: proof.authorityRoot,
199
+ };
200
+ const predicateEntry = createKungfuTemporalEntry(predicate);
201
+ const relation = {
202
+ schema: "kungfu.fact.temporal-relation/v1",
203
+ relationId: `buildchain:compatibility:${proof.proofId}`,
204
+ predicateRoot: predicateEntry.root,
205
+ sourceRoot: contentRoot(proof.source),
206
+ targetRoot: contentRoot(proof.target),
207
+ validFromCutRoot: proof.cutRoot,
208
+ scopeRoot: proof.scopeRoot,
209
+ authorityRoot: proof.authorityRoot,
210
+ admissionRoots: [proof.evidenceRoot],
211
+ };
212
+ const relationEntry = createKungfuTemporalEntry(relation);
213
+ return {
214
+ schema: BUILDCHAIN_COMPATIBILITY_FACT_SCHEMA,
215
+ factId: proof.proofId,
216
+ factRoot: relationEntry.root,
217
+ sourceRoot: relation.sourceRoot,
218
+ targetRoot: relation.targetRoot,
219
+ predicate: predicateEntry,
220
+ relation: relationEntry,
221
+ proof,
222
+ };
223
+ }
224
+
225
+ export function verifyBuildchainCompatibilityFact(factInput) {
226
+ try {
227
+ const fact = clone(factInput || {});
228
+ if (fact.schema !== BUILDCHAIN_COMPATIBILITY_FACT_SCHEMA)
229
+ return { ok: false, reason: "unsupported-schema" };
230
+ const normalized = createBuildchainCompatibilityFact(
231
+ factInputFromProof(fact.proof),
232
+ );
233
+ if (normalized.factRoot !== fact.factRoot)
234
+ return { ok: false, reason: "fact-root-drift" };
235
+ if (JSON.stringify(normalized) !== JSON.stringify(fact))
236
+ return { ok: false, reason: "non-canonical-fact" };
237
+ return {
238
+ ok: true,
239
+ reason: "exact-cut-bound-compatibility-fact",
240
+ fact: normalized,
241
+ factRoot: normalized.factRoot,
242
+ };
243
+ } catch (error) {
244
+ return { ok: false, reason: "invalid-fact", error: error.message };
245
+ }
246
+ }
247
+
248
+ export function createBuildchainCompatibilityFactRegistry({
249
+ factInputs = compatibilityFactSource.facts.map((entry) => ({
250
+ ...entry,
251
+ authority: compatibilityFactSource.authority,
252
+ })),
253
+ registryCut = compatibilityFactSource.registryCut,
254
+ supersessions = compatibilityFactSource.supersessions,
255
+ revocations = compatibilityFactSource.revocations,
256
+ } = {}) {
257
+ if (
258
+ compatibilityFactSource.schema !==
259
+ "kungfu.buildchain.compatibility-fact-source/v1"
260
+ ) {
261
+ throw new Error("compatibility Fact source schema is unsupported");
262
+ }
263
+ if (compatibilityFactSource.rootProtocol !== KUNGFU_FACT_ROOT_PROTOCOL) {
264
+ throw new Error("compatibility Fact source root protocol mismatch");
265
+ }
266
+ const facts = factInputs
267
+ .map(createBuildchainCompatibilityFact)
268
+ .sort((left, right) => left.factRoot.localeCompare(right.factRoot));
269
+ if (new Set(facts.map((fact) => fact.factId)).size !== facts.length)
270
+ throw new Error("duplicate compatibility Fact id");
271
+ if (new Set(facts.map((fact) => fact.factRoot)).size !== facts.length)
272
+ throw new Error("duplicate compatibility Fact root");
273
+ for (const fact of facts) {
274
+ const verification = verifyBuildchainCompatibilityFact(fact);
275
+ if (!verification.ok)
276
+ throw new Error(`invalid compatibility Fact: ${verification.reason}`);
277
+ }
278
+ const predicates = [
279
+ ...new Map(
280
+ facts.map((fact) => [fact.predicate.root, fact.predicate]),
281
+ ).values(),
282
+ ].sort((left, right) => left.root.localeCompare(right.root));
283
+ const relationEntries = facts
284
+ .map((fact) => fact.relation)
285
+ .sort((left, right) => left.root.localeCompare(right.root));
286
+ const leafCuts = new Map();
287
+ for (const fact of facts) {
288
+ const cutRoot = fact.proof.cutRoot;
289
+ const current = leafCuts.get(cutRoot) || {
290
+ root: cutRoot,
291
+ parentCutRoots: [],
292
+ activeRelationRoots: [],
293
+ declarationRoots: predicates.map((entry) => entry.root),
294
+ };
295
+ current.activeRelationRoots.push(fact.factRoot);
296
+ current.activeRelationRoots.sort();
297
+ leafCuts.set(cutRoot, current);
298
+ }
299
+ const currentCut = normalizeCut(registryCut);
300
+ const currentCutRoot = contentRoot(currentCut);
301
+ const cuts = [...leafCuts.values()].sort((left, right) =>
302
+ left.root.localeCompare(right.root),
303
+ );
304
+ if (leafCuts.has(currentCutRoot)) {
305
+ const cut = leafCuts.get(currentCutRoot);
306
+ cut.activeRelationRoots = facts.map((fact) => fact.factRoot).sort();
307
+ } else {
308
+ cuts.push({
309
+ root: currentCutRoot,
310
+ parentCutRoots: [...leafCuts.keys()].sort(),
311
+ activeRelationRoots: facts.map((fact) => fact.factRoot).sort(),
312
+ declarationRoots: predicates.map((entry) => entry.root),
313
+ });
314
+ }
315
+ const supersessionEntries = (supersessions || [])
316
+ .map(createKungfuTemporalEntry)
317
+ .sort((left, right) => left.root.localeCompare(right.root));
318
+ const revocationEntries = (revocations || [])
319
+ .map(createKungfuTemporalEntry)
320
+ .sort((left, right) => left.root.localeCompare(right.root));
321
+ const temporalBundle = {
322
+ schema: KUNGFU_TEMPORAL_BUNDLE_SCHEMA,
323
+ cuts,
324
+ predicates,
325
+ relations: relationEntries,
326
+ supersessions: supersessionEntries,
327
+ revocations: revocationEntries,
328
+ authorityProofs: [],
329
+ provenanceObjects: [],
330
+ };
331
+ const identity = {
332
+ schema: BUILDCHAIN_COMPATIBILITY_FACT_REGISTRY_SCHEMA,
333
+ rootProtocol: KUNGFU_FACT_ROOT_PROTOCOL,
334
+ currentCutRoot,
335
+ predicateRoots: predicates.map((entry) => entry.root),
336
+ factRoots: facts.map((fact) => fact.factRoot),
337
+ supersessionRoots: supersessionEntries.map((entry) => entry.root),
338
+ revocationRoots: revocationEntries.map((entry) => entry.root),
339
+ legacyProofRoots: facts.map((fact) => fact.proof.proofRoot).sort(),
340
+ temporalBundleRoot: contentRoot(temporalBundle),
341
+ };
342
+ return {
343
+ ...identity,
344
+ facts,
345
+ legacyProofs: facts
346
+ .map((fact) => fact.proof)
347
+ .sort((left, right) => left.proofRoot.localeCompare(right.proofRoot)),
348
+ currentCut,
349
+ temporalBundle,
350
+ registryRoot: contentRoot(identity),
351
+ };
352
+ }
353
+
354
+ export function createHistoricalBuildchainCompatibilityFacts() {
355
+ return createBuildchainCompatibilityFactRegistry().facts;
356
+ }
357
+
358
+ export function createHistoricalBuildchainCompatibilityProofs() {
359
+ return createBuildchainCompatibilityFactRegistry().legacyProofs;
360
+ }
361
+
362
+ export function verifyBuildchainCompatibilityFactRegistry(registryInput) {
363
+ try {
364
+ const registry = clone(registryInput || {});
365
+ if (registry.schema !== BUILDCHAIN_COMPATIBILITY_FACT_REGISTRY_SCHEMA) {
366
+ return { ok: false, reason: "unsupported-schema" };
367
+ }
368
+ const normalized = createBuildchainCompatibilityFactRegistry({
369
+ factInputs: (registry.legacyProofs || []).map(factInputFromProof),
370
+ registryCut: registry.currentCut,
371
+ supersessions: (registry.temporalBundle?.supersessions || []).map(
372
+ (entry) => entry.record,
373
+ ),
374
+ revocations: (registry.temporalBundle?.revocations || []).map(
375
+ (entry) => entry.record,
376
+ ),
377
+ });
378
+ if (normalized.registryRoot !== registry.registryRoot) {
379
+ return { ok: false, reason: "registry-root-drift" };
380
+ }
381
+ if (JSON.stringify(normalized) !== JSON.stringify(registry)) {
382
+ return { ok: false, reason: "non-canonical-registry" };
383
+ }
384
+ return {
385
+ ok: true,
386
+ reason: "exact-append-only-compatibility-Fact-registry",
387
+ registryRoot: normalized.registryRoot,
388
+ currentCutRoot: normalized.currentCutRoot,
389
+ factCount: normalized.facts.length,
390
+ };
391
+ } catch (error) {
392
+ return { ok: false, reason: "invalid-registry", error: error.message };
393
+ }
394
+ }
@@ -0,0 +1,217 @@
1
+ {
2
+ "schema": "kungfu.buildchain.compatibility-fact-source/v1",
3
+ "rootProtocol": "kungfu.fact-root.canonical/v2",
4
+ "authority": {
5
+ "kind": "protected-base-contract-authority",
6
+ "repository": "kungfu-systems/buildchain",
7
+ "protectedBase": "dev/v3/v3.0"
8
+ },
9
+ "registryCut": {
10
+ "kind": "protected-git-cut",
11
+ "repository": "kungfu-systems/buildchain",
12
+ "protectedBase": "dev/v3/v3.0",
13
+ "commit": "888e87fec88cad41d225c32615e80a87744d4b6d"
14
+ },
15
+ "facts": [
16
+ {
17
+ "proofId": "release-candidate-promote-acd401-to-e60642",
18
+ "surfaceId": "release-candidate-promote",
19
+ "surfaceKind": "workflow",
20
+ "sourceBreakingDigest": "sha256:acd401cfc46450115a3763fd4b679d85f185e8757ebd52510d6262e1533df4cf",
21
+ "targetBreakingDigest": "sha256:e60642aa298933d2c103284794921a6c340a50aa91ee528b06e58892a2a006bf",
22
+ "evidence": {
23
+ "kind": "protected-pull-request-contract-acceptance",
24
+ "pullRequest": "https://github.com/kungfu-systems/buildchain/pull/2342",
25
+ "protectedBase": "dev/v3/v3.0",
26
+ "sourceCommit": "8870db287a9ee5fb95eebbbe907b1649d84d5b7f",
27
+ "mergeCommit": "30b605adea1ed33dcf0bbb4cc7b666b64a6ccd18",
28
+ "contractDigest": "sha256:9c07dbdb9aa8390569cd07ace044af45e6751b91ffe8fcc0cb69a77388b0f72b",
29
+ "compatibilityDigest": "sha256:80cfdf1786019217c439810f1a80d2866bf8f7ef35a6fa569e1a687fb2bf4cbe"
30
+ },
31
+ "cut": {
32
+ "kind": "protected-git-cut",
33
+ "repository": "kungfu-systems/buildchain",
34
+ "protectedBase": "dev/v3/v3.0",
35
+ "commit": "ff0f9006be1c8f63be40e67789e0cfd28fd69d46"
36
+ }
37
+ },
38
+ {
39
+ "proofId": "advanced-release-candidate-promote-aa30f2-to-9db8dd",
40
+ "surfaceId": "advanced-release-candidate-promote",
41
+ "surfaceKind": "workflow",
42
+ "sourceBreakingDigest": "sha256:aa30f22e3af0a89841310bdbdc900844dd95a66974db173fa140a71bbd7e82c0",
43
+ "targetBreakingDigest": "sha256:9db8dd07152855d03ff30f9c571438593c689d3e8139fa45431d000f548242f5",
44
+ "evidence": {
45
+ "kind": "protected-pull-request-contract-acceptance",
46
+ "pullRequest": "https://github.com/kungfu-systems/buildchain/pull/2342",
47
+ "protectedBase": "dev/v3/v3.0",
48
+ "sourceCommit": "8870db287a9ee5fb95eebbbe907b1649d84d5b7f",
49
+ "mergeCommit": "30b605adea1ed33dcf0bbb4cc7b666b64a6ccd18",
50
+ "contractDigest": "sha256:9c07dbdb9aa8390569cd07ace044af45e6751b91ffe8fcc0cb69a77388b0f72b",
51
+ "compatibilityDigest": "sha256:80cfdf1786019217c439810f1a80d2866bf8f7ef35a6fa569e1a687fb2bf4cbe"
52
+ },
53
+ "cut": {
54
+ "kind": "protected-git-cut",
55
+ "repository": "kungfu-systems/buildchain",
56
+ "protectedBase": "dev/v3/v3.0",
57
+ "commit": "ff0f9006be1c8f63be40e67789e0cfd28fd69d46"
58
+ }
59
+ },
60
+ {
61
+ "proofId": "promote-buildchain-ref-action-a59f09-to-6147c0",
62
+ "surfaceId": "promote-buildchain-ref-action",
63
+ "surfaceKind": "action",
64
+ "sourceBreakingDigest": "sha256:a59f0910e6df842e7699139472e5dd69ac2fdd7f7213bf2cb346d1d622556874",
65
+ "targetBreakingDigest": "sha256:6147c0a8d5c36bfaa6021871574e1fc28192a3f1b8cfdae4d24ef3059ac1ebda",
66
+ "evidence": {
67
+ "kind": "protected-pull-request-contract-acceptance",
68
+ "pullRequest": "https://github.com/kungfu-systems/buildchain/pull/1556",
69
+ "protectedBase": "dev/v2/v2.14",
70
+ "sourceCommit": "f8e2c5d28ef34d711892589331b7e018095a96d7",
71
+ "mergeCommit": "6e0c29be1489f686a9a3792b46bfaa4466828393",
72
+ "contractDigest": "sha256:f6dbf5147d9ad3b8c49ba6630cd52b8c7853ead7c921d7e1210a393aebf97d1f",
73
+ "compatibilityDigest": "sha256:cdf588422ec6b460bd6f631400efa6e361a045e052c8967d6c50fadd7aa4dd90"
74
+ },
75
+ "cut": {
76
+ "kind": "protected-git-cut",
77
+ "repository": "kungfu-systems/buildchain",
78
+ "protectedBase": "dev/v3/v3.0",
79
+ "commit": "ff0f9006be1c8f63be40e67789e0cfd28fd69d46"
80
+ }
81
+ },
82
+ {
83
+ "proofId": "build-lifecycle-e264a7-to-6b8d38",
84
+ "surfaceId": "controller:build-lifecycle",
85
+ "surfaceKind": "controller",
86
+ "sourceBreakingDigest": "sha256:e264a79f9f399038c2fcfd21e4168c68c2e1485ee5c651c02242a02b622ac2be",
87
+ "targetBreakingDigest": "sha256:6b8d38e92b2c67b5bc83fae0a3fd95bfa47582fbc176e6cdeebe7630a57534cb",
88
+ "evidence": {
89
+ "kind": "protected-pull-request-contract-acceptance",
90
+ "pullRequest": "https://github.com/kungfu-systems/buildchain/pull/2058",
91
+ "protectedBase": "dev/v3/v3.0",
92
+ "sourceCommit": "c9a86bd1ac17b4fae54b0410498830edad80d831",
93
+ "mergeCommit": "3991801a7a7d6fe5e31b9a670dfde7ea59e61253",
94
+ "contractDigest": "sha256:da72850bbd3088f0e9eb20c17382557e0dfb7e68bf4469d352ed870ee8a334e8",
95
+ "compatibilityDigest": "sha256:32a651504c57829085dc8863f0e41dee98eb60708ff6dec958c9c7e4b1010102"
96
+ },
97
+ "cut": {
98
+ "kind": "protected-git-cut",
99
+ "repository": "kungfu-systems/buildchain",
100
+ "protectedBase": "dev/v3/v3.0",
101
+ "commit": "ff0f9006be1c8f63be40e67789e0cfd28fd69d46"
102
+ }
103
+ },
104
+ {
105
+ "proofId": "build-lifecycle-307459-to-6b8d38",
106
+ "surfaceId": "controller:build-lifecycle",
107
+ "surfaceKind": "controller",
108
+ "sourceBreakingDigest": "sha256:30745921541e9b0f70475bb2178c2559f6aef248f6680670ccd44d8c5a69a6b1",
109
+ "targetBreakingDigest": "sha256:6b8d38e92b2c67b5bc83fae0a3fd95bfa47582fbc176e6cdeebe7630a57534cb",
110
+ "evidence": {
111
+ "kind": "protected-pull-request-contract-acceptance",
112
+ "pullRequest": "https://github.com/kungfu-systems/buildchain/pull/2058",
113
+ "protectedBase": "dev/v3/v3.0",
114
+ "sourceCommit": "c9a86bd1ac17b4fae54b0410498830edad80d831",
115
+ "mergeCommit": "3991801a7a7d6fe5e31b9a670dfde7ea59e61253",
116
+ "contractDigest": "sha256:da72850bbd3088f0e9eb20c17382557e0dfb7e68bf4469d352ed870ee8a334e8",
117
+ "compatibilityDigest": "sha256:32a651504c57829085dc8863f0e41dee98eb60708ff6dec958c9c7e4b1010102"
118
+ },
119
+ "cut": {
120
+ "kind": "protected-git-cut",
121
+ "repository": "kungfu-systems/buildchain",
122
+ "protectedBase": "dev/v3/v3.0",
123
+ "commit": "ff0f9006be1c8f63be40e67789e0cfd28fd69d46"
124
+ }
125
+ },
126
+ {
127
+ "proofId": "build-channel-router-d40dd0-to-30549a",
128
+ "surfaceId": "controller:build-channel-router",
129
+ "surfaceKind": "controller",
130
+ "sourceBreakingDigest": "sha256:d40dd05d7e07473d4b2dc1b62fbb0ed6f06449b4d3a7c44a2e8014313e3c0273",
131
+ "targetBreakingDigest": "sha256:30549aa26cd1e1dd81f10fe3529d3c6e3f8438a6efa0100c47ebae4d2f3d71df",
132
+ "evidence": {
133
+ "kind": "protected-pull-request-contract-acceptance",
134
+ "pullRequest": "https://github.com/kungfu-systems/buildchain/pull/2549",
135
+ "protectedBase": "dev/v3/v3.0",
136
+ "sourceCommit": "0d87b772265066f5e6157e1ba6a2ba1021fb5225",
137
+ "mergeCommit": "34fad9d3a94c450d75c0d06fd6ed00470c992ff7",
138
+ "contractDigest": "sha256:2584ba36ab54cd5e9bab9e34dfc08d87a55dc57de1be7641492bf7ceb1366350",
139
+ "compatibilityDigest": "sha256:80f65cc191b1f771475184edf8a1bf9c10dd69bb58060aa09313d0e1e57f508a"
140
+ },
141
+ "cut": {
142
+ "kind": "protected-git-cut",
143
+ "repository": "kungfu-systems/buildchain",
144
+ "protectedBase": "dev/v3/v3.0",
145
+ "commit": "34fad9d3a94c450d75c0d06fd6ed00470c992ff7"
146
+ }
147
+ },
148
+ {
149
+ "proofId": "reusable-build-a6a353-to-dfbedd",
150
+ "surfaceId": "reusable-build",
151
+ "surfaceKind": "workflow",
152
+ "sourceBreakingDigest": "sha256:a6a35370d6b0d0f46e1b2712dcc01961fe53c2febde95409a27a485c10a36650",
153
+ "targetBreakingDigest": "sha256:dfbedd543ae0c067982b5c8c02d98dd2f7f7df88752be97fb330da6b0ba30faa",
154
+ "evidence": {
155
+ "kind": "protected-pull-request-contract-acceptance",
156
+ "pullRequest": "https://github.com/kungfu-systems/buildchain/pull/2089",
157
+ "protectedBase": "dev/v3/v3.0",
158
+ "sourceCommit": "1a6cb874bc6f1611f3eef607e711d3532798e9e7",
159
+ "mergeCommit": "71a75f21159b994241ec7cb2c50f7a150c5d440b",
160
+ "contractDigest": "sha256:7c2a7c132a2b2722f70f148b81048147047d4d2c46cf33f7cd2dc158aec092e0",
161
+ "compatibilityDigest": "sha256:61af7d0871220bc0909008bdc571905ad500cccf853e7841bc5d462a34b2d436"
162
+ },
163
+ "cut": {
164
+ "kind": "protected-git-cut",
165
+ "repository": "kungfu-systems/buildchain",
166
+ "protectedBase": "dev/v3/v3.0",
167
+ "commit": "71a75f21159b994241ec7cb2c50f7a150c5d440b"
168
+ }
169
+ },
170
+ {
171
+ "proofId": "web-surface-da569f-to-27f0cb",
172
+ "surfaceId": "web-surface",
173
+ "surfaceKind": "workflow",
174
+ "sourceBreakingDigest": "sha256:da569f90374e878948e3d5160ed9929338ce0572473ca8ee54867b0fe1aaeace",
175
+ "targetBreakingDigest": "sha256:27f0cb9c7d97288850d215be8696b323471c41fd1cdf3a2ff3ebf21f62541960",
176
+ "evidence": {
177
+ "kind": "protected-pull-request-contract-acceptance",
178
+ "pullRequest": "https://github.com/kungfu-systems/buildchain/pull/2089",
179
+ "protectedBase": "dev/v3/v3.0",
180
+ "sourceCommit": "1a6cb874bc6f1611f3eef607e711d3532798e9e7",
181
+ "mergeCommit": "71a75f21159b994241ec7cb2c50f7a150c5d440b",
182
+ "contractDigest": "sha256:7c2a7c132a2b2722f70f148b81048147047d4d2c46cf33f7cd2dc158aec092e0",
183
+ "compatibilityDigest": "sha256:61af7d0871220bc0909008bdc571905ad500cccf853e7841bc5d462a34b2d436"
184
+ },
185
+ "cut": {
186
+ "kind": "protected-git-cut",
187
+ "repository": "kungfu-systems/buildchain",
188
+ "protectedBase": "dev/v3/v3.0",
189
+ "commit": "71a75f21159b994241ec7cb2c50f7a150c5d440b"
190
+ }
191
+ },
192
+ {
193
+ "proofId": "release-propagation-d7a1f1-to-b873ce",
194
+ "surfaceId": "controller:release-propagation",
195
+ "surfaceKind": "controller",
196
+ "sourceBreakingDigest": "sha256:d7a1f15990ce8bd13149474888232c7d4451dd2a49bebf4d4ce1336695da430e",
197
+ "targetBreakingDigest": "sha256:b873ceb65618972bea615afcb9c616c138ce834b3246ec7237ef87c1618d68bd",
198
+ "evidence": {
199
+ "kind": "protected-pull-request-contract-acceptance",
200
+ "pullRequest": "https://github.com/kungfu-systems/buildchain/pull/2143",
201
+ "protectedBase": "dev/v3/v3.0",
202
+ "sourceCommit": "b63aff4dd63ad6017b8f48e1c690f595a9c832a2",
203
+ "mergeCommit": "487ee09ca4832ffd15607db00060df4c0839fbae",
204
+ "contractDigest": "sha256:00c37f8a663387831ba4d066056d0b21d4f3c5f3ea5b0cf84456af332cf8d87e",
205
+ "compatibilityDigest": "sha256:3bbcaf835844260ed98414d3bd176667245d12131e13fc748e4c2fae12399691"
206
+ },
207
+ "cut": {
208
+ "kind": "protected-git-cut",
209
+ "repository": "kungfu-systems/buildchain",
210
+ "protectedBase": "dev/v3/v3.0",
211
+ "commit": "487ee09ca4832ffd15607db00060df4c0839fbae"
212
+ }
213
+ }
214
+ ],
215
+ "supersessions": [],
216
+ "revocations": []
217
+ }