@kungfu-tech/buildchain 4.0.2 → 4.0.3-alpha.0
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/AGENTS.md +4 -4
- package/CONTRIBUTING.md +34 -0
- package/README.md +1 -1
- package/architecture/agent-change-map.md +154 -147
- package/architecture/{v4-architecture-constitution.md → architecture-constitution.md} +11 -11
- package/architecture/{v3-core-mechanism-inventory.md → baseline-core-mechanism-inventory.md} +1 -1
- package/architecture/{v4-bootstrap-authority.json → bootstrap-authority.json} +3 -3
- package/architecture/{v3-v4-capability-closure.md → capability-parity-closure.md} +3 -3
- package/architecture/{v3-v4-live-capability-inventory.json → capability-parity-live-capability-inventory.json} +4 -4
- package/architecture/{v4-capability-state-machine-manifest.json → capability-state-machine-manifest.json} +2 -2
- package/architecture/{v4-capability-state-machine-manifest.schema.json → capability-state-machine-manifest.schema.json} +2 -2
- package/architecture/ci-lane-change-budget.json +18 -0
- package/architecture/{v4-cross-platform-adopter-qualification.json → cross-platform-adopter-qualification.json} +3 -3
- package/architecture/{v4-delivery-authority-parity.json → delivery-authority-parity.json} +16 -16
- package/architecture/{v4-delivery-warrant-shadow-bootstrap-plan.json → delivery-warrant-shadow-bootstrap-plan.json} +3 -3
- package/architecture/{v4-delivery-warrant-shadow-bootstrap-plan.md → delivery-warrant-shadow-bootstrap-plan.md} +7 -7
- package/architecture/{v4-floating-consumer-policy.md → floating-consumer-policy.md} +1 -1
- package/architecture/implementation-naming.json +1273 -0
- package/architecture/internal-capabilities.json +171 -169
- package/architecture/maintainability-debt.json +87 -82
- package/architecture/maintainability-policy.json +15 -15
- package/architecture/{v4-next-development-parity.json → next-development-parity.json} +8 -8
- package/architecture/{v4-partial-mutation-recovery-qualification.json → partial-mutation-recovery-qualification.json} +8 -8
- package/architecture/{v4-platform-stage-checkpoints.json → platform-stage-checkpoints.json} +2 -2
- package/architecture/{v4-provider-operation-journal-contract.json → provider-operation-journal-contract.json} +9 -9
- package/architecture/{v4-publication-rehearsal-parity.json → publication-rehearsal-parity.json} +4 -4
- package/architecture/{v4-release-activation-shadow-domain.json → release-activation-shadow-domain.json} +8 -8
- package/architecture/{v4-release-topology.json → release-topology.json} +112 -56
- package/architecture/{v4-release-train-parity.json → release-train-parity.json} +2 -2
- package/architecture/{v4-runtime-ref-resume-authority.json → runtime-ref-resume-authority.json} +1 -1
- package/architecture/{v4-runtime-semantic-closure.json → runtime-semantic-closure.json} +2 -2
- package/architecture/{v4-rust-libnode-bridge-evaluation.json → rust-libnode-bridge-evaluation.json} +3 -3
- package/architecture/{v4-rust-libnode-bridge-spike.md → rust-libnode-bridge-spike.md} +6 -6
- package/architecture/{v4-rust-wasm-production-authority.json → rust-wasm-production-authority.json} +11 -11
- package/architecture/{v4-stable-publication-fence.json → stable-publication-fence.json} +6 -6
- package/architecture/{v4-stage-capsule-contract.json → stage-capsule-contract.json} +1 -1
- package/architecture/{v4-stage-capsule-qualification.json → stage-capsule-qualification.json} +6 -6
- package/architecture/{v4-stage-capsule-resume-planner.json → stage-capsule-resume-planner.json} +2 -2
- package/architecture/{v4-stage-capsule-store-contract.json → stage-capsule-store-contract.json} +4 -4
- package/architecture/{v4-tail-reseal-parity.json → tail-reseal-parity.json} +28 -28
- package/architecture/{v4-universal-workflow-bootstrap.json → universal-workflow-bootstrap.json} +9 -4
- package/architecture/{v4-universal-workflow-fault-campaign.json → universal-workflow-fault-campaign.json} +8 -8
- package/architecture/{v4-universal-workflow-train-admission.json → universal-workflow-train-admission.json} +8 -8
- package/architecture/workflow-taxonomy.json +11 -0
- package/bin/buildchain.mjs +3 -3
- package/bin/internal/adopter-delivery-cli.mjs +9 -9
- package/contracts/fixtures/v4-tail-reseal-v1/valid.json +1 -1
- package/crates/{buildchain-v4-bridge → buildchain-host-bridge}/Cargo.lock +1 -1
- package/crates/{buildchain-v4-bridge → buildchain-host-bridge}/Cargo.toml +1 -1
- package/crates/{buildchain-v4-bridge → buildchain-host-bridge}/src/main.rs +3 -3
- package/dist/site/buildchain-contract.json +18 -18
- package/dist/site/buildchain-site.json +167 -71
- package/dist/site/capability-registry.json +5 -5
- package/dist/site/kfd-claims.json +226 -90
- package/dist/site/kfd-upstream-aggregate.json +1 -1
- package/dist/site/manual-registry.json +7 -7
- package/dist/site/node-api-registry.json +12929 -10491
- package/dist/site/page-registry.json +155 -59
- package/dist/site/public-surface-audit.json +65 -46
- package/dist/site/publication-authority-registry.json +27 -17
- package/dist/site/publication-registry.json +4 -4
- package/dist/site/release-provenance.json +18 -9
- package/dist/site/site-manifest.json +11 -11
- package/dist/site/workflow-registry.json +86 -52
- package/docs/MAP.md +4 -3
- package/docs/next-development-transition.md +24 -1
- package/docs/node-api-reference.md +435 -175
- package/docs/oci-publication.md +173 -0
- package/docs/publish-transaction.md +36 -3
- package/docs/release-flow.md +1 -1
- package/docs/reusable-build-surface.md +1 -1
- package/docs/v4-adopter-delivery.md +2 -2
- package/docs/v4-canonical-contracts.md +7 -7
- package/docs/v4-delivery-warrant-read-candidate.md +3 -3
- package/docs/v4-delivery-warrant-semantic-diff.md +3 -3
- package/docs/v4-production-release.md +8 -2
- package/docs/v4-publication-rehearsal.md +3 -3
- package/docs/v4-runtime-ref-resume-authority.md +2 -2
- package/docs/v4-rust-wasm-production-authority.md +6 -6
- package/docs/v4-stage-capsule.md +7 -7
- package/docs/v4-tail-reseal.md +1 -1
- package/docs/workflow-catalog.md +1 -0
- package/package.json +37 -26
- package/packages/compatibility/adopter-delivery.js +16 -0
- package/packages/compatibility/cross-platform-adopter-qualification.js +12 -0
- package/packages/compatibility/floating-consumer-policy.js +14 -0
- package/packages/compatibility/publication-qualification.js +11 -0
- package/packages/compatibility/publication-rehearsal.js +18 -0
- package/packages/compatibility/runtime-ref-resume-authority.js +13 -0
- package/packages/compatibility/tail-reseal-receipt.js +7 -0
- package/packages/compatibility/tail-reseal.js +11 -0
- package/packages/core/{v4-adopter-delivery-parity.js → adopter-delivery-parity.js} +12 -12
- package/packages/core/{v4-adopter-delivery.js → adopter-delivery.js} +24 -24
- package/packages/core/buildchain-contract.js +5 -5
- package/packages/core/buildchain-domain.wasm +0 -0
- package/packages/core/buildchain-publication-authority.js +1 -0
- package/packages/core/{v4-canonical-contracts.js → canonical-contracts.js} +32 -31
- package/packages/core/{v4-cross-platform-adopter-qualification.js → cross-platform-adopter-qualification.js} +19 -19
- package/packages/core/{v4-delivery-warrant-fixture-runner.js → delivery-warrant-fixture-runner.js} +36 -32
- package/packages/core/{v4-delivery-warrant-read-candidate.js → delivery-warrant-read-candidate.js} +40 -40
- package/packages/core/{v4-delivery-warrant-semantic-diff-gate.js → delivery-warrant-semantic-diff-gate.js} +58 -59
- package/packages/core/{v4-delivery-warrant-shadow-adapter.js → delivery-warrant-shadow-adapter.js} +15 -15
- package/packages/core/dev-delivery-execution-transfer.js +6 -6
- package/packages/core/dev-delivery-native-proof.js +12 -8
- package/packages/core/dev-delivery-warrant-legacy-recovery.js +1 -1
- package/packages/core/dev-delivery-warrant-native-compatibility.js +4 -4
- package/packages/core/dev-delivery-warrant-state.js +11 -11
- package/packages/core/dev-delivery-warrant.js +3 -3
- package/packages/core/domain-wasm-artifact.js +7 -0
- package/packages/core/{v4-domain-wasm.js → domain-wasm.js} +31 -31
- package/packages/core/{v4-floating-consumer-evidence.js → floating-consumer-evidence.js} +13 -13
- package/packages/core/{v4-floating-consumer-policy.js → floating-consumer-policy.js} +27 -29
- package/packages/core/{v4-floating-consumer-release-passport.js → floating-consumer-release-passport.js} +25 -25
- package/packages/core/index.js +4 -8
- package/packages/core/next-development-projection.js +24 -1
- package/packages/core/next-development-transition.js +5 -6
- package/packages/core/oci-compose-qualification.js +143 -0
- package/packages/core/oci-publication-bundle.js +281 -0
- package/packages/core/oci-publication-graph.js +206 -0
- package/packages/core/paper-runtime-channels.js +2 -2
- package/packages/core/paper.js +3 -3
- package/packages/core/partial-mutation-recovery-qualification.js +18 -0
- package/packages/core/{v4-platform-stage-checkpoints.js → platform-stage-checkpoints.js} +37 -37
- package/packages/core/{v4-product-publication.js → product-publication.js} +11 -9
- package/packages/core/{v4-protected-publication-source.js → protected-publication-source.js} +3 -3
- package/packages/core/provider-operation-journal.js +62 -0
- package/packages/core/{v4-provider-readback-idempotency.js → provider-readback-idempotency.js} +33 -33
- package/packages/core/public-export-compatibility.js +33 -0
- package/packages/core/publication-development.js +72 -0
- package/packages/core/{v4-publication-qualification.js → publication-qualification.js} +17 -17
- package/packages/core/{v4-publication-rehearsal-capsule.js → publication-rehearsal-capsule.js} +23 -23
- package/packages/core/publication-rehearsal-projection.js +2 -2
- package/packages/core/{v4-publication-rehearsal-provider-bindings.js → publication-rehearsal-provider-bindings.js} +4 -4
- package/packages/core/publication-rehearsal-runtime.js +21 -21
- package/packages/core/{v4-publication-rehearsal.js → publication-rehearsal.js} +33 -33
- package/packages/core/publication-sealed-bundle.js +78 -13
- package/packages/core/release-activation-shadow.js +32 -0
- package/packages/core/release-candidate.js +6 -6
- package/packages/core/{v4-release-invocation.js → release-invocation.js} +15 -15
- package/packages/core/release-passport.js +36 -36
- package/packages/core/release-tail-product-capabilities.js +9 -0
- package/packages/core/release-tail-provider-plane.js +10 -10
- package/packages/core/{v4-runtime-ref-resume-authority.js → runtime-ref-resume-authority.js} +36 -40
- package/packages/core/{v4-runtime-selector-persistence.js → runtime-selector-persistence.js} +7 -7
- package/packages/core/stable-publication-fence.js +28 -0
- package/packages/core/{v4-stage-capsule-local-store.js → stage-capsule-local-store.js} +56 -54
- package/packages/core/{v4-stage-capsule-qualification-campaign.js → stage-capsule-qualification-campaign.js} +37 -38
- package/packages/core/{v4-stage-capsule-qualification.js → stage-capsule-qualification.js} +28 -29
- package/packages/core/{v4-stage-capsule-resume-planner.js → stage-capsule-resume-planner.js} +29 -29
- package/packages/core/{v4-stage-capsule-store.js → stage-capsule-store.js} +59 -56
- package/packages/core/{v4-stage-capsule.js → stage-capsule.js} +45 -45
- package/packages/core/{v4-tail-reseal-contract.js → tail-reseal-contract.js} +6 -6
- package/packages/core/{v4-tail-reseal-github.js → tail-reseal-github.js} +12 -12
- package/packages/core/{v4-tail-reseal-receipt.js → tail-reseal-receipt.js} +22 -22
- package/packages/core/{v4-tail-reseal.js → tail-reseal.js} +29 -29
- package/packages/core/{v4-universal-workflow-bootstrap.js → universal-workflow-bootstrap.js} +23 -23
- package/scripts/{v4-architecture.mjs → architecture.mjs} +6 -6
- package/scripts/binary-publication-evidence.mjs +1 -1
- package/scripts/{v4-bridge-bootstrap.mjs → bridge-bootstrap.mjs} +14 -18
- package/scripts/{v4-bridge-evidence.mjs → bridge-evidence.mjs} +8 -8
- package/scripts/{build-v4-domain-wasm.mjs → build-domain-wasm.mjs} +6 -18
- package/scripts/{v3-v4-capability-catalog.mjs → capability-parity-catalog.mjs} +19 -19
- package/scripts/check-action-bundles.mjs +2 -2
- package/scripts/{check-v3-v4-capability-inventory.mjs → check-capability-parity-inventory.mjs} +42 -42
- package/scripts/check-core-mechanism-inventory.mjs +4 -1
- package/scripts/{check-v4-floating-consumer-policy-contract.mjs → check-floating-consumer-policy-contract.mjs} +8 -8
- package/scripts/check-implementation-naming.mjs +135 -0
- package/scripts/check-inventory.mjs +6 -5
- package/scripts/check-maintainability.mjs +9 -2
- package/scripts/{check-v4-public-dogfood-contract.mjs → check-public-dogfood-contract.mjs} +15 -15
- package/scripts/{check-v4-release-topology.mjs → check-release-topology.mjs} +53 -31
- package/scripts/{check-v4-runtime-semantic-closure.mjs → check-runtime-semantic-closure.mjs} +19 -16
- package/scripts/{check-v4-universal-workflow-bootstrap.mjs → check-universal-workflow-bootstrap.mjs} +14 -14
- package/scripts/{v4-consumer-policy.mjs → consumer-policy.mjs} +15 -15
- package/scripts/{copy-v4-domain-wasm.mjs → copy-domain-wasm.mjs} +3 -3
- package/scripts/{v4-cross-platform-adopter-qualification.mjs → cross-platform-adopter-qualification.mjs} +9 -9
- package/scripts/{v4-declarative-promotion-admission.mjs → declarative-promotion-admission.mjs} +4 -4
- package/scripts/dev-delivery-warrant-options.mjs +1 -1
- package/scripts/dev-delivery-warrant-store.mjs +29 -10
- package/scripts/dev-delivery-warrant.mjs +4 -4
- package/scripts/dev-pr-delivery-warrant.mjs +1 -1
- package/scripts/generate-channel-build-workflow.mjs +2 -2
- package/scripts/generate-channel-promotion-workflow.mjs +14 -31
- package/scripts/generate-release-candidate-passport.mjs +23 -23
- package/scripts/generate-site-bundle.mjs +17 -17
- package/scripts/{generate-v4-universal-workflow-facades.mjs → generate-universal-workflow-facades.mjs} +61 -21
- package/scripts/{v4-host-adapter.mjs → host-adapter.mjs} +1 -1
- package/scripts/implementation-references.mjs +25 -0
- package/scripts/init-repo.mjs +1 -1
- package/scripts/next-development-review.mjs +17 -11
- package/scripts/oci-compose-preview.mjs +261 -0
- package/scripts/{v4-platform-stage-checkpoint-rehearsal.mjs → platform-stage-checkpoint-rehearsal.mjs} +17 -17
- package/scripts/{v4-product-publication-intent.mjs → product-publication-intent.mjs} +16 -8
- package/scripts/publication-candidate-kind.mjs +93 -0
- package/scripts/publication-candidate-sealer.mjs +16 -1
- package/scripts/{v4-publication-rehearsal-fixture.mjs → publication-rehearsal-fixture.mjs} +5 -5
- package/scripts/{v4-publication-settlement.mjs → publication-settlement.mjs} +8 -8
- package/scripts/{v4-release-candidate-adapter.mjs → release-candidate-adapter.mjs} +4 -4
- package/scripts/release-candidate-resolver.mjs +15 -26
- package/scripts/release-tail.mjs +5 -5
- package/scripts/resume-from-candidate-run.mjs +35 -42
- package/scripts/site-capability-metadata.mjs +9 -0
- package/scripts/source-verification-evidence.mjs +7 -7
- package/scripts/{v4-stage-capsule-qualification.mjs → stage-capsule-qualification.mjs} +62 -62
- package/scripts/{v4-stage-capsule-resume-rehearsal.mjs → stage-capsule-resume-rehearsal.mjs} +6 -6
- package/scripts/{v4-tail-reseal-macos-rehearsal.mjs → tail-reseal-macos-rehearsal.mjs} +9 -9
- package/scripts/{v4-tail-reseal.mjs → tail-reseal.mjs} +19 -19
- package/scripts/universal-facade-maintainability.mjs +12 -3
- package/scripts/{v4-universal-workflow-backflow.mjs → universal-workflow-backflow.mjs} +10 -10
- package/scripts/{v4-universal-workflow-engine.mjs → universal-workflow-engine.mjs} +40 -38
- package/scripts/{v4-universal-workflow-self-dogfood.mjs → universal-workflow-self-dogfood.mjs} +12 -12
- package/scripts/verify-version-state-delta.mjs +4 -2
- package/scripts/{v4-warrant-shadow-plan.mjs → warrant-shadow-plan.mjs} +6 -6
- package/templates/universal-buildchain-bootstrap-recovery.yml +4 -4
- package/packages/core/buildchain-v4-domain.wasm +0 -0
- package/packages/core/v4-domain-wasm-artifact.js +0 -7
- package/packages/core/v4-partial-mutation-recovery-qualification.js +0 -18
- package/packages/core/v4-provider-operation-journal.js +0 -62
- package/packages/core/v4-release-activation-shadow.js +0 -32
- package/packages/core/v4-stable-publication-fence.js +0 -28
- /package/actions/{v4-release-candidate-promote → release-candidate-promote}/README.md +0 -0
- /package/architecture/{v4-adopter-delivery-parity.json → adopter-delivery-parity.json} +0 -0
- /package/architecture/{v3-core-mechanism-inventory.json → baseline-core-mechanism-inventory.json} +0 -0
- /package/architecture/{v4-canonical-contract-fixtures.json → canonical-contract-fixtures.json} +0 -0
- /package/architecture/{v4-compatibility-facts-parity.json → compatibility-facts-parity.json} +0 -0
- /package/architecture/{v4-delivery-warrant-shadow-bootstrap-plan.schema.json → delivery-warrant-shadow-bootstrap-plan.schema.json} +0 -0
- /package/architecture/{v4-delivery-warrant-shadow-fixtures.json → delivery-warrant-shadow-fixtures.json} +0 -0
- /package/architecture/{v4-delivery-warrant-shadow-fixtures.schema.json → delivery-warrant-shadow-fixtures.schema.json} +0 -0
- /package/architecture/{v4-exception-ledger.json → exception-ledger.json} +0 -0
- /package/architecture/{v4-exception-ledger.schema.json → exception-ledger.schema.json} +0 -0
- /package/architecture/{v4-floating-consumer-policy.json → floating-consumer-policy.json} +0 -0
- /package/architecture/{v4-publication-facade-patches.json → publication-facade-patches.json} +0 -0
- /package/architecture/{v4-release-invocation-fixtures.json → release-invocation-fixtures.json} +0 -0
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { domainContentRoot, validateRoot } from "./canonical-contracts.js";
|
|
2
2
|
import { validateReleaseCandidatePassport } from "./release-candidate.js";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
} from "./
|
|
4
|
+
TAIL_RESEAL_PLAN_CONTRACT,
|
|
5
|
+
TAIL_RESEAL_PLATFORMS,
|
|
6
|
+
TailResealFault,
|
|
7
|
+
normalizeTailResealRequest,
|
|
8
|
+
planTailReseal,
|
|
9
|
+
} from "./tail-reseal.js";
|
|
10
10
|
|
|
11
|
-
export const
|
|
11
|
+
export const TAIL_RESEAL_RECEIPT_CONTRACT =
|
|
12
12
|
"kungfu-buildchain-v4-tail-reseal-receipt/v1";
|
|
13
13
|
|
|
14
14
|
function fault(code, path, message) {
|
|
15
|
-
throw new
|
|
15
|
+
throw new TailResealFault(code, path, message);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
function root(value, path) {
|
|
19
19
|
try {
|
|
20
|
-
|
|
20
|
+
validateRoot(value, path);
|
|
21
21
|
} catch (error) {
|
|
22
22
|
fault("invalid-tail-reseal-root", path, error.message);
|
|
23
23
|
}
|
|
@@ -52,7 +52,7 @@ function positiveInteger(value, path) {
|
|
|
52
52
|
function validateReadbacks(readbacks, request) {
|
|
53
53
|
if (
|
|
54
54
|
!Array.isArray(readbacks) ||
|
|
55
|
-
readbacks.length !==
|
|
55
|
+
readbacks.length !== TAIL_RESEAL_PLATFORMS.length
|
|
56
56
|
)
|
|
57
57
|
fault(
|
|
58
58
|
"tail-reseal-readback-mismatch",
|
|
@@ -116,7 +116,7 @@ function validateReadbacks(readbacks, request) {
|
|
|
116
116
|
return normalized;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
export function
|
|
119
|
+
export function createTailResealReceipt({
|
|
120
120
|
request,
|
|
121
121
|
plan,
|
|
122
122
|
readbacks,
|
|
@@ -124,13 +124,13 @@ export function createV4TailResealReceipt({
|
|
|
124
124
|
protectedReadbackRoot,
|
|
125
125
|
currentRun,
|
|
126
126
|
} = {}) {
|
|
127
|
-
const normalized =
|
|
128
|
-
const expectedPlan =
|
|
127
|
+
const normalized = normalizeTailResealRequest(request);
|
|
128
|
+
const expectedPlan = planTailReseal(normalized);
|
|
129
129
|
const { planRoot: _planRoot, ...planBody } = plan || {};
|
|
130
130
|
if (
|
|
131
|
-
plan?.schema !==
|
|
131
|
+
plan?.schema !== TAIL_RESEAL_PLAN_CONTRACT ||
|
|
132
132
|
plan.planRoot !== expectedPlan.planRoot ||
|
|
133
|
-
|
|
133
|
+
domainContentRoot("tail-reseal-plan", planBody) !== expectedPlan.planRoot
|
|
134
134
|
)
|
|
135
135
|
fault(
|
|
136
136
|
"tail-reseal-plan-drift",
|
|
@@ -168,7 +168,7 @@ export function createV4TailResealReceipt({
|
|
|
168
168
|
positiveInteger(currentRun.id, "$/currentRun/id");
|
|
169
169
|
positiveInteger(currentRun.attempt, "$/currentRun/attempt");
|
|
170
170
|
const payload = {
|
|
171
|
-
schema:
|
|
171
|
+
schema: TAIL_RESEAL_RECEIPT_CONTRACT,
|
|
172
172
|
action: "reused-retained-tail",
|
|
173
173
|
repository: normalized.repository,
|
|
174
174
|
source: normalized.source,
|
|
@@ -186,22 +186,22 @@ export function createV4TailResealReceipt({
|
|
|
186
186
|
passport: {
|
|
187
187
|
contract: passport.contract,
|
|
188
188
|
candidateHash: passport.candidateHash,
|
|
189
|
-
passportRoot:
|
|
189
|
+
passportRoot: domainContentRoot("release-candidate-passport", passport),
|
|
190
190
|
},
|
|
191
191
|
protectedReadbackRoot,
|
|
192
192
|
currentRun,
|
|
193
193
|
};
|
|
194
194
|
return {
|
|
195
195
|
...payload,
|
|
196
|
-
receiptRoot:
|
|
196
|
+
receiptRoot: domainContentRoot("tail-reseal-receipt", payload),
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
export function
|
|
200
|
+
export function verifyTailResealReceipt({ receipt, request, passport } = {}) {
|
|
201
201
|
try {
|
|
202
|
-
const expected =
|
|
202
|
+
const expected = createTailResealReceipt({
|
|
203
203
|
request,
|
|
204
|
-
plan:
|
|
204
|
+
plan: planTailReseal(request),
|
|
205
205
|
readbacks: receipt.platformReadbacks,
|
|
206
206
|
passport,
|
|
207
207
|
protectedReadbackRoot: receipt.protectedReadbackRoot,
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
} from "./
|
|
2
|
+
domainContentRoot,
|
|
3
|
+
validateClock,
|
|
4
|
+
validateRoot,
|
|
5
|
+
} from "./canonical-contracts.js";
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "./
|
|
7
|
+
TAIL_RESEAL_PLAN_CONTRACT,
|
|
8
|
+
TAIL_RESEAL_PLATFORMS as PLATFORM_IDS,
|
|
9
|
+
TAIL_RESEAL_PLATFORM_RUNNERS as PLATFORM_RUNNERS,
|
|
10
|
+
TAIL_RESEAL_REQUEST_CONTRACT,
|
|
11
|
+
TAIL_RESEAL_REUSED_STAGE_KEYS as REUSED_STAGE_KEYS,
|
|
12
|
+
} from "./tail-reseal-contract.js";
|
|
13
13
|
|
|
14
14
|
export {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from "./
|
|
15
|
+
TAIL_RESEAL_PLAN_CONTRACT,
|
|
16
|
+
TAIL_RESEAL_REQUEST_CONTRACT,
|
|
17
|
+
} from "./tail-reseal-contract.js";
|
|
18
18
|
|
|
19
19
|
const SHA = /^[0-9a-f]{40}$/u;
|
|
20
20
|
const TOKEN = /^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u;
|
|
21
|
-
const
|
|
21
|
+
const DOMAIN_RUNTIME_REF = /^(?:v4-alpha|train\/v4\/v4\.0\/[A-Za-z0-9._/-]+)$/u;
|
|
22
22
|
|
|
23
|
-
export class
|
|
23
|
+
export class TailResealFault extends Error {
|
|
24
24
|
constructor(code, path, message) {
|
|
25
25
|
super(`${path}: ${message}`);
|
|
26
|
-
this.name = "
|
|
26
|
+
this.name = "TailResealFault";
|
|
27
27
|
this.code = code;
|
|
28
28
|
this.path = path;
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
function fault(code, path, message) {
|
|
33
|
-
throw new
|
|
33
|
+
throw new TailResealFault(code, path, message);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
function exactKeys(value, expected, path) {
|
|
@@ -84,7 +84,7 @@ function sha(value, path) {
|
|
|
84
84
|
|
|
85
85
|
function root(value, path) {
|
|
86
86
|
try {
|
|
87
|
-
|
|
87
|
+
validateRoot(value, path);
|
|
88
88
|
} catch (error) {
|
|
89
89
|
fault("invalid-tail-reseal-root", path, error.message);
|
|
90
90
|
}
|
|
@@ -93,7 +93,7 @@ function root(value, path) {
|
|
|
93
93
|
|
|
94
94
|
function clock(value, path) {
|
|
95
95
|
try {
|
|
96
|
-
|
|
96
|
+
validateClock(value, path);
|
|
97
97
|
} catch (error) {
|
|
98
98
|
fault("invalid-tail-reseal-clock", path, error.message);
|
|
99
99
|
}
|
|
@@ -183,7 +183,7 @@ function validateRuntime(value) {
|
|
|
183
183
|
"$/runtime/repository",
|
|
184
184
|
"official Buildchain runtime required",
|
|
185
185
|
);
|
|
186
|
-
if (!
|
|
186
|
+
if (!DOMAIN_RUNTIME_REF.test(value.ref))
|
|
187
187
|
fault(
|
|
188
188
|
"tail-reseal-runtime-mismatch",
|
|
189
189
|
"$/runtime/ref",
|
|
@@ -457,7 +457,7 @@ function validatePlatforms(values) {
|
|
|
457
457
|
);
|
|
458
458
|
}
|
|
459
459
|
|
|
460
|
-
export function
|
|
460
|
+
export function normalizeTailResealRequest(request) {
|
|
461
461
|
exactKeys(
|
|
462
462
|
request,
|
|
463
463
|
[
|
|
@@ -477,7 +477,7 @@ export function normalizeV4TailResealRequest(request) {
|
|
|
477
477
|
],
|
|
478
478
|
"$",
|
|
479
479
|
);
|
|
480
|
-
if (request.schema !==
|
|
480
|
+
if (request.schema !== TAIL_RESEAL_REQUEST_CONTRACT)
|
|
481
481
|
fault(
|
|
482
482
|
"unsupported-tail-reseal-version",
|
|
483
483
|
"$/schema",
|
|
@@ -516,10 +516,10 @@ export function normalizeV4TailResealRequest(request) {
|
|
|
516
516
|
return structuredClone(request);
|
|
517
517
|
}
|
|
518
518
|
|
|
519
|
-
export function
|
|
520
|
-
const normalized =
|
|
519
|
+
export function planTailReseal(request) {
|
|
520
|
+
const normalized = normalizeTailResealRequest(request);
|
|
521
521
|
const payload = {
|
|
522
|
-
schema:
|
|
522
|
+
schema: TAIL_RESEAL_PLAN_CONTRACT,
|
|
523
523
|
mode: "production",
|
|
524
524
|
productionAuthority: "v4",
|
|
525
525
|
evaluatedAt: normalized.evaluatedAt,
|
|
@@ -584,11 +584,11 @@ export function planV4TailReseal(request) {
|
|
|
584
584
|
};
|
|
585
585
|
return {
|
|
586
586
|
...payload,
|
|
587
|
-
planRoot:
|
|
587
|
+
planRoot: domainContentRoot("tail-reseal-plan", payload),
|
|
588
588
|
};
|
|
589
589
|
}
|
|
590
590
|
|
|
591
591
|
export {
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
} from "./
|
|
592
|
+
TAIL_RESEAL_PLATFORMS,
|
|
593
|
+
TAIL_RESEAL_REUSED_STAGE_KEYS,
|
|
594
|
+
} from "./tail-reseal-contract.js";
|
package/packages/core/{v4-universal-workflow-bootstrap.js → universal-workflow-bootstrap.js}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
|
|
3
|
-
export const
|
|
3
|
+
export const UNIVERSAL_WORKFLOW_REQUEST =
|
|
4
4
|
"kungfu-buildchain-v4-universal-workflow-request/v1";
|
|
5
|
-
export const
|
|
5
|
+
export const UNIVERSAL_WORKFLOW_ADMISSION_POLICY =
|
|
6
6
|
"kungfu-buildchain-v4-universal-workflow-admission-policy/v1";
|
|
7
|
-
export const
|
|
7
|
+
export const UNIVERSAL_WORKFLOW_ADMISSION =
|
|
8
8
|
"kungfu-buildchain-v4-universal-workflow-admission/v1";
|
|
9
|
-
export const
|
|
9
|
+
export const UNIVERSAL_WORKFLOW_TERMINAL_RECEIPT =
|
|
10
10
|
"kungfu-buildchain-v4-universal-workflow-terminal-receipt/v1";
|
|
11
11
|
const EXACT_SHA = /^[0-9a-f]{40}$/u;
|
|
12
12
|
const ROOT = /^sha256:[0-9a-f]{64}$/u;
|
|
@@ -166,13 +166,13 @@ function timestamp(value, label) {
|
|
|
166
166
|
return normalized;
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
-
export function
|
|
169
|
+
export function validateUniversalWorkflowRequest(value) {
|
|
170
170
|
exactKeys(
|
|
171
171
|
value,
|
|
172
172
|
["schema", "mode", "candidate", "consumer", "capability", "payload"],
|
|
173
173
|
"request",
|
|
174
174
|
);
|
|
175
|
-
if (value.schema !==
|
|
175
|
+
if (value.schema !== UNIVERSAL_WORKFLOW_REQUEST)
|
|
176
176
|
fail("unsupported-request-schema", "request schema is unsupported");
|
|
177
177
|
if (!MODES.has(value.mode))
|
|
178
178
|
fail("unsupported-mode", "request mode is unsupported");
|
|
@@ -266,17 +266,17 @@ export function validateV4UniversalWorkflowRequest(value) {
|
|
|
266
266
|
payload: canonical(value.payload),
|
|
267
267
|
};
|
|
268
268
|
}
|
|
269
|
-
export function
|
|
269
|
+
export function universalWorkflowRequestRoot(value) {
|
|
270
270
|
return documentRoot(
|
|
271
271
|
"universal-workflow-request",
|
|
272
|
-
|
|
272
|
+
validateUniversalWorkflowRequest(value),
|
|
273
273
|
);
|
|
274
274
|
}
|
|
275
|
-
export function
|
|
276
|
-
export function
|
|
277
|
-
export function
|
|
278
|
-
if (value.routeDecision !== "Resume") return ""; const
|
|
279
|
-
const states = Array.isArray(value.recoveryStates) ? value.recoveryStates : []; if (states.length) { const recovered = [...new Set(states.map(({ stateRef, stateCommit, exactTagRef }) => { const selected =
|
|
275
|
+
export function productStateVersion(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 selectFinalizedProductPublicationVersion(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 = productStateVersion(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
|
+
export function selectRecoveredProductPublicationVersion(value) {
|
|
278
|
+
if (value.routeDecision !== "Resume") return ""; const candidateVersion = nonEmpty(value.candidateVersion, "candidateVersion"), version = value.channel === "stable" ? candidateVersion.replace(/-alpha\.\d+$/u, "") : 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 = [...new Set(states.map(({ stateRef, stateCommit, exactTagRef }) => { const selected = productStateVersion(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
|
}
|
|
@@ -299,7 +299,7 @@ function validatePolicy(value) {
|
|
|
299
299
|
],
|
|
300
300
|
"policy",
|
|
301
301
|
);
|
|
302
|
-
if (value.schema !==
|
|
302
|
+
if (value.schema !== UNIVERSAL_WORKFLOW_ADMISSION_POLICY)
|
|
303
303
|
fail("unsupported-policy-schema", "policy schema is unsupported");
|
|
304
304
|
const consumerAdmission = nonEmpty(
|
|
305
305
|
value.consumerAdmission,
|
|
@@ -394,7 +394,7 @@ function reviewedRuntimeSha(request, policy, evidence, runtimeSha) {
|
|
|
394
394
|
return evidence.headSha;
|
|
395
395
|
}
|
|
396
396
|
|
|
397
|
-
export function
|
|
397
|
+
export function universalWorkflowAdmissionRoot(value) {
|
|
398
398
|
return documentRoot("universal-workflow-admission", validatePolicy(value));
|
|
399
399
|
}
|
|
400
400
|
|
|
@@ -409,7 +409,7 @@ function assertPermissionCeiling(requested, ceiling) {
|
|
|
409
409
|
}
|
|
410
410
|
}
|
|
411
411
|
|
|
412
|
-
export function
|
|
412
|
+
export function admitUniversalWorkflow({
|
|
413
413
|
request: requestValue,
|
|
414
414
|
policy: policyValue,
|
|
415
415
|
observedRefSha,
|
|
@@ -419,9 +419,9 @@ export function admitV4UniversalWorkflow({
|
|
|
419
419
|
reviewEvidence: reviewEvidenceValue,
|
|
420
420
|
now,
|
|
421
421
|
} = {}) {
|
|
422
|
-
const request =
|
|
422
|
+
const request = validateUniversalWorkflowRequest(requestValue);
|
|
423
423
|
const policy = validatePolicy(policyValue);
|
|
424
|
-
const admissionRoot =
|
|
424
|
+
const admissionRoot = universalWorkflowAdmissionRoot(policy);
|
|
425
425
|
if (request.candidate.admissionRoot !== admissionRoot)
|
|
426
426
|
fail("stale-admission", "request is not bound to the current admission");
|
|
427
427
|
if (policy.sourceRepository !== request.candidate.repository)
|
|
@@ -507,7 +507,7 @@ export function admitV4UniversalWorkflow({
|
|
|
507
507
|
"exact-head-checks-incomplete",
|
|
508
508
|
"candidate exact-head checks are not successful",
|
|
509
509
|
);
|
|
510
|
-
const requestRoot =
|
|
510
|
+
const requestRoot = universalWorkflowRequestRoot(request);
|
|
511
511
|
const discovery = {
|
|
512
512
|
repository: request.candidate.repository,
|
|
513
513
|
ref: request.candidate.discoveryRef,
|
|
@@ -516,7 +516,7 @@ export function admitV4UniversalWorkflow({
|
|
|
516
516
|
observedAt,
|
|
517
517
|
};
|
|
518
518
|
return {
|
|
519
|
-
schema:
|
|
519
|
+
schema: UNIVERSAL_WORKFLOW_ADMISSION,
|
|
520
520
|
status: "admitted",
|
|
521
521
|
requestRoot,
|
|
522
522
|
admissionRoot,
|
|
@@ -536,7 +536,7 @@ export function admitV4UniversalWorkflow({
|
|
|
536
536
|
};
|
|
537
537
|
}
|
|
538
538
|
|
|
539
|
-
export function
|
|
539
|
+
export function completeUniversalWorkflow({ admission, resultRoot, status }) {
|
|
540
540
|
exactKeys(
|
|
541
541
|
admission,
|
|
542
542
|
[
|
|
@@ -555,14 +555,14 @@ export function completeV4UniversalWorkflow({ admission, resultRoot, status }) {
|
|
|
555
555
|
"admission",
|
|
556
556
|
);
|
|
557
557
|
if (
|
|
558
|
-
admission.schema !==
|
|
558
|
+
admission.schema !== UNIVERSAL_WORKFLOW_ADMISSION ||
|
|
559
559
|
admission.status !== "admitted"
|
|
560
560
|
)
|
|
561
561
|
fail("invalid-admission", "terminal receipt requires an admitted request");
|
|
562
562
|
if (!new Set(["succeeded", "failed", "cancelled"]).has(status))
|
|
563
563
|
fail("invalid-terminal-status", "terminal status is unsupported");
|
|
564
564
|
const receipt = {
|
|
565
|
-
schema:
|
|
565
|
+
schema: UNIVERSAL_WORKFLOW_TERMINAL_RECEIPT,
|
|
566
566
|
status,
|
|
567
567
|
requestRoot: root(admission.requestRoot, "admission.requestRoot"),
|
|
568
568
|
admissionRoot: root(admission.admissionRoot, "admission.admissionRoot"),
|
|
@@ -5,12 +5,12 @@ import fs from "node:fs";
|
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
import { pathToFileURL } from "node:url";
|
|
7
7
|
|
|
8
|
-
const MANIFEST_PATH = "architecture/
|
|
8
|
+
const MANIFEST_PATH = "architecture/capability-state-machine-manifest.json";
|
|
9
9
|
const MANIFEST_SCHEMA_PATH =
|
|
10
|
-
"architecture/
|
|
11
|
-
const EXCEPTION_PATH = "architecture/
|
|
12
|
-
const EXCEPTION_SCHEMA_PATH = "architecture/
|
|
13
|
-
const BOOTSTRAP_PATH = "architecture/
|
|
10
|
+
"architecture/capability-state-machine-manifest.schema.json";
|
|
11
|
+
const EXCEPTION_PATH = "architecture/exception-ledger.json";
|
|
12
|
+
const EXCEPTION_SCHEMA_PATH = "architecture/exception-ledger.schema.json";
|
|
13
|
+
const BOOTSTRAP_PATH = "architecture/bootstrap-authority.json";
|
|
14
14
|
const BUDGET_DIMENSIONS = Object.freeze([
|
|
15
15
|
"authority",
|
|
16
16
|
"semanticState",
|
|
@@ -368,7 +368,7 @@ function loadArchitecture(root = process.cwd()) {
|
|
|
368
368
|
const bootstrap = readJson(root, BOOTSTRAP_PATH);
|
|
369
369
|
const inventory = readJson(
|
|
370
370
|
root,
|
|
371
|
-
"architecture/
|
|
371
|
+
"architecture/baseline-core-mechanism-inventory.json",
|
|
372
372
|
);
|
|
373
373
|
const schemaIssues = [];
|
|
374
374
|
validateSchemaDocuments(manifestSchema, exceptionSchema, schemaIssues);
|
|
@@ -5,7 +5,7 @@ import { pathToFileURL } from "node:url";
|
|
|
5
5
|
import {
|
|
6
6
|
SETTLEMENT_ASSET,
|
|
7
7
|
verifyPublicationSettlement,
|
|
8
|
-
} from "./
|
|
8
|
+
} from "./publication-settlement.mjs";
|
|
9
9
|
import { releaseAssetClient } from "./release-asset-client.mjs";
|
|
10
10
|
|
|
11
11
|
export async function readBinaryPublicationEvidence({
|
|
@@ -10,7 +10,7 @@ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
|
10
10
|
const manifestPath = path.join(
|
|
11
11
|
root,
|
|
12
12
|
"crates",
|
|
13
|
-
"buildchain-
|
|
13
|
+
"buildchain-host-bridge",
|
|
14
14
|
"Cargo.toml",
|
|
15
15
|
);
|
|
16
16
|
|
|
@@ -18,14 +18,14 @@ function bridgeBinary(profile = "debug", platform = process.platform) {
|
|
|
18
18
|
return path.join(
|
|
19
19
|
root,
|
|
20
20
|
"crates",
|
|
21
|
-
"buildchain-
|
|
21
|
+
"buildchain-host-bridge",
|
|
22
22
|
"target",
|
|
23
23
|
profile,
|
|
24
|
-
`buildchain-
|
|
24
|
+
`buildchain-host-bridge${platform === "win32" ? ".exe" : ""}`,
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
function
|
|
28
|
+
function createHostRequest({
|
|
29
29
|
command,
|
|
30
30
|
args = [],
|
|
31
31
|
input = Buffer.alloc(0),
|
|
@@ -45,7 +45,7 @@ function createV4HostRequest({
|
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
function
|
|
48
|
+
function buildBridge({ release = false } = {}) {
|
|
49
49
|
return spawnSync(
|
|
50
50
|
"cargo",
|
|
51
51
|
[
|
|
@@ -59,14 +59,14 @@ function buildV4Bridge({ release = false } = {}) {
|
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function
|
|
62
|
+
function runBridge(
|
|
63
63
|
request,
|
|
64
64
|
{ mode = "exchange", profile = "debug", env = {}, encoding = null } = {},
|
|
65
65
|
) {
|
|
66
66
|
const binary = bridgeBinary(profile);
|
|
67
67
|
if (!fs.existsSync(binary)) {
|
|
68
68
|
throw new Error(
|
|
69
|
-
`Buildchain v4 bridge is not built: ${path.relative(root, binary)}; run pnpm bridge:
|
|
69
|
+
`Buildchain v4 bridge is not built: ${path.relative(root, binary)}; run pnpm bridge:build`,
|
|
70
70
|
);
|
|
71
71
|
}
|
|
72
72
|
return spawnSync(binary, [mode], {
|
|
@@ -74,11 +74,7 @@ function runV4Bridge(
|
|
|
74
74
|
env: {
|
|
75
75
|
...process.env,
|
|
76
76
|
BUILDCHAIN_V4_HOST_COMMAND: process.execPath,
|
|
77
|
-
BUILDCHAIN_V4_HOST_SCRIPT: path.join(
|
|
78
|
-
root,
|
|
79
|
-
"scripts",
|
|
80
|
-
"v4-host-adapter.mjs",
|
|
81
|
-
),
|
|
77
|
+
BUILDCHAIN_V4_HOST_SCRIPT: path.join(root, "scripts", "host-adapter.mjs"),
|
|
82
78
|
...env,
|
|
83
79
|
},
|
|
84
80
|
input: JSON.stringify(request),
|
|
@@ -94,7 +90,7 @@ function parseRunArgs(args) {
|
|
|
94
90
|
const command = bridgeArgs[0];
|
|
95
91
|
if (!command) {
|
|
96
92
|
throw new Error(
|
|
97
|
-
"usage: node scripts/
|
|
93
|
+
"usage: node scripts/bridge-bootstrap.mjs <run|exchange> <command-id> -- [command-args...]",
|
|
98
94
|
);
|
|
99
95
|
}
|
|
100
96
|
return { command, commandArgs };
|
|
@@ -103,7 +99,7 @@ function parseRunArgs(args) {
|
|
|
103
99
|
function main(args = process.argv.slice(2)) {
|
|
104
100
|
const [mode = "", ...rest] = args;
|
|
105
101
|
if (mode === "build") {
|
|
106
|
-
const result =
|
|
102
|
+
const result = buildBridge({ release: rest.includes("--release") });
|
|
107
103
|
process.stdout.write(result.stdout || "");
|
|
108
104
|
process.stderr.write(result.stderr || "");
|
|
109
105
|
process.exitCode = result.status ?? 1;
|
|
@@ -111,13 +107,13 @@ function main(args = process.argv.slice(2)) {
|
|
|
111
107
|
}
|
|
112
108
|
if (!["run", "exchange"].includes(mode)) {
|
|
113
109
|
throw new Error(
|
|
114
|
-
"usage: node scripts/
|
|
110
|
+
"usage: node scripts/bridge-bootstrap.mjs <build|run|exchange> ...",
|
|
115
111
|
);
|
|
116
112
|
}
|
|
117
113
|
const { command, commandArgs } = parseRunArgs(rest);
|
|
118
114
|
const input = fs.readFileSync(0);
|
|
119
|
-
const request =
|
|
120
|
-
const result =
|
|
115
|
+
const request = createHostRequest({ command, args: commandArgs, input });
|
|
116
|
+
const result = runBridge(request, {
|
|
121
117
|
mode: mode === "run" ? "compat" : "exchange",
|
|
122
118
|
});
|
|
123
119
|
if (result.error) throw result.error;
|
|
@@ -138,4 +134,4 @@ if (
|
|
|
138
134
|
}
|
|
139
135
|
}
|
|
140
136
|
|
|
141
|
-
export { bridgeBinary,
|
|
137
|
+
export { bridgeBinary, buildBridge, createHostRequest, main, runBridge };
|
|
@@ -7,13 +7,13 @@ import { fileURLToPath, pathToFileURL } from "node:url";
|
|
|
7
7
|
|
|
8
8
|
import {
|
|
9
9
|
bridgeBinary,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from "./
|
|
10
|
+
buildBridge,
|
|
11
|
+
createHostRequest,
|
|
12
|
+
runBridge,
|
|
13
|
+
} from "./bridge-bootstrap.mjs";
|
|
14
14
|
|
|
15
15
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
16
|
-
const hostScript = path.join(root, "scripts", "
|
|
16
|
+
const hostScript = path.join(root, "scripts", "host-adapter.mjs");
|
|
17
17
|
|
|
18
18
|
function flag(args, name, fallback = "") {
|
|
19
19
|
const index = args.indexOf(`--${name}`);
|
|
@@ -51,10 +51,10 @@ function collectEvidence(args = process.argv.slice(2)) {
|
|
|
51
51
|
if (!Number.isInteger(iterations) || iterations < 3 || iterations > 50) {
|
|
52
52
|
throw new Error("--iterations must be between 3 and 50");
|
|
53
53
|
}
|
|
54
|
-
const build =
|
|
54
|
+
const build = buildBridge({ release: true });
|
|
55
55
|
if (build.status !== 0) throw new Error(build.stderr || build.stdout);
|
|
56
56
|
const binary = bridgeBinary("release");
|
|
57
|
-
const request =
|
|
57
|
+
const request = createHostRequest({
|
|
58
58
|
command: "architecture.list",
|
|
59
59
|
args: ["--json"],
|
|
60
60
|
});
|
|
@@ -71,7 +71,7 @@ function collectEvidence(args = process.argv.slice(2)) {
|
|
|
71
71
|
);
|
|
72
72
|
const bridge = timed(
|
|
73
73
|
() =>
|
|
74
|
-
|
|
74
|
+
runBridge(request, {
|
|
75
75
|
mode: "exchange",
|
|
76
76
|
profile: "release",
|
|
77
77
|
encoding: "utf8",
|
|
@@ -7,19 +7,9 @@ import { fileURLToPath } from "node:url";
|
|
|
7
7
|
import { spawnSyncCommand } from "../packages/core/spawn-command.js";
|
|
8
8
|
|
|
9
9
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
10
|
-
const crate = path.join(root, "crates", "buildchain-
|
|
11
|
-
const artifact = path.join(
|
|
12
|
-
|
|
13
|
-
"packages",
|
|
14
|
-
"core",
|
|
15
|
-
"buildchain-v4-domain.wasm",
|
|
16
|
-
);
|
|
17
|
-
const metadata = path.join(
|
|
18
|
-
root,
|
|
19
|
-
"packages",
|
|
20
|
-
"core",
|
|
21
|
-
"v4-domain-wasm-artifact.js",
|
|
22
|
-
);
|
|
10
|
+
const crate = path.join(root, "crates", "buildchain-domain-contracts");
|
|
11
|
+
const artifact = path.join(root, "packages", "core", "buildchain-domain.wasm");
|
|
12
|
+
const metadata = path.join(root, "packages", "core", "domain-wasm-artifact.js");
|
|
23
13
|
const check = process.argv.includes("--check");
|
|
24
14
|
const toolchain = process.env.BUILDCHAIN_RUST_WASM_TOOLCHAIN || "1.96.0";
|
|
25
15
|
const expectedRustc = "rustc 1.96.0 (ac68faa20 2026-05-25)";
|
|
@@ -103,7 +93,7 @@ for (const file of sourceInputs) {
|
|
|
103
93
|
}
|
|
104
94
|
const sourceSha256 = sourceHash.digest("hex");
|
|
105
95
|
const generatedMetadata = (artifactSha256) =>
|
|
106
|
-
`// Generated by scripts/build-
|
|
96
|
+
`// Generated by scripts/build-domain-wasm.mjs.\nexport const DOMAIN_WASM_ABI_VERSION = 1;\nexport const DOMAIN_WASM_RUSTC = ${JSON.stringify(expectedRustc)};\nexport const DOMAIN_WASM_SOURCE_SHA256 =\n ${JSON.stringify(sourceSha256)};\nexport const DOMAIN_WASM_SHA256 =\n ${JSON.stringify(artifactSha256)};\n`;
|
|
107
97
|
|
|
108
98
|
if (!canonicalBuildHost && !check) {
|
|
109
99
|
throw new Error(
|
|
@@ -128,9 +118,7 @@ if (!canonicalBuildHost) {
|
|
|
128
118
|
} else {
|
|
129
119
|
const buildEnvironment = rustBuildEnvironment();
|
|
130
120
|
|
|
131
|
-
const temporary = fs.mkdtempSync(
|
|
132
|
-
path.join(os.tmpdir(), "buildchain-v4-wasm-"),
|
|
133
|
-
);
|
|
121
|
+
const temporary = fs.mkdtempSync(path.join(os.tmpdir(), "buildchain-wasm-"));
|
|
134
122
|
try {
|
|
135
123
|
const build = spawnSyncCommand(
|
|
136
124
|
"cargo",
|
|
@@ -158,7 +146,7 @@ if (!canonicalBuildHost) {
|
|
|
158
146
|
temporary,
|
|
159
147
|
"wasm32-unknown-unknown",
|
|
160
148
|
"release",
|
|
161
|
-
"
|
|
149
|
+
"buildchain_domain_contracts.wasm",
|
|
162
150
|
);
|
|
163
151
|
const built = fs.readFileSync(builtPath);
|
|
164
152
|
const artifactSha256 = sha256(built);
|