@kungfu-tech/buildchain 4.0.0 → 4.0.1-alpha.10
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 +13 -5
- package/actions/promote-buildchain-ref/README.md +11 -6
- package/actions/release-tail/README.md +8 -0
- package/architecture/ci-lane-change-budget.json +187 -0
- package/architecture/decisions/0002-next-development-transition.md +101 -0
- package/architecture/decisions/0003-two-phase-delivery-warrant.md +152 -0
- package/architecture/internal-capabilities.json +219 -7
- package/architecture/maintainability-policy.json +246 -29
- package/architecture/release-tail-contract-inventory.json +5 -2
- package/architecture/v3-core-mechanism-inventory.json +91 -0
- package/architecture/v4-adopter-delivery-parity.json +32 -5
- package/architecture/v4-capability-state-machine-manifest.json +73 -0
- package/architecture/v4-compatibility-facts-parity.json +77 -0
- package/architecture/v4-delivery-authority-parity.json +250 -0
- package/architecture/v4-delivery-warrant-shadow-fixtures.json +41 -9
- package/architecture/v4-floating-consumer-policy.json +81 -0
- package/architecture/v4-floating-consumer-policy.md +32 -0
- package/architecture/v4-next-development-parity.json +192 -0
- package/architecture/v4-publication-rehearsal-parity.json +84 -0
- package/architecture/v4-release-train-parity.json +1 -0
- package/architecture/v4-runtime-ref-resume-authority.json +64 -0
- package/architecture/v4-stage-capsule-qualification.json +2 -2
- package/architecture/v4-tail-reseal-parity.json +150 -0
- package/bin/buildchain.mjs +32 -3
- package/bin/internal/adopter-delivery-cli.mjs +70 -0
- package/bin/internal/command-registry.mjs +3 -0
- package/bin/internal/compatibility-facts-cli.mjs +101 -0
- package/bin/internal/trust-release-release-handlers.mjs +5 -0
- package/contracts/dev-delivery-authority-v2.schema.json +662 -0
- package/contracts/fixtures/next-development-transition-v1/anchored-manual-waiting.json +47 -0
- package/contracts/fixtures/next-development-transition-v1/semver-auto-planned.json +47 -0
- package/contracts/fixtures/next-development-transition-v1/version-model-cases.json +40 -0
- package/contracts/fixtures/v4-adopter-delivery-v1/archive-template.json +19 -0
- package/contracts/fixtures/v4-adopter-delivery-v1/bootstrap-positive.json +93 -0
- package/contracts/fixtures/v4-adopter-delivery-v1/gate-positive.json +29 -0
- package/contracts/fixtures/v4-adopter-delivery-v1/gate-unknown-selector.json +26 -0
- package/contracts/fixtures/v4-adopter-delivery-v1/offline-vectors.json +50 -0
- package/contracts/fixtures/v4-compatibility-facts-v1/shared.json +1129 -0
- package/contracts/fixtures/v4-floating-consumer-policy-v1/cases.json +59 -0
- package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/artifacts/product.bin +1 -0
- package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/config/buildchain.toml +5 -0
- package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/documents/release-activation.json +1 -0
- package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/documents/signed-channel.json +1 -0
- package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/evidence/qualification.json +1 -0
- package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/manifests/candidate.json +5 -0
- package/contracts/fixtures/v4-publication-rehearsal-v1/candidate/manifests/release-passport.json +1 -0
- package/contracts/fixtures/v4-publication-rehearsal-v1/capsule.json +707 -0
- package/contracts/fixtures/v4-publication-rehearsal-v1/offline-vectors.json +27 -0
- package/contracts/fixtures/v4-runtime-ref-resume-authority-v1/scenario.json +15 -0
- package/contracts/fixtures/v4-tail-reseal-v1/valid.json +229 -0
- package/contracts/next-development-request-v1.schema.json +66 -0
- package/contracts/next-development-transition-v1.schema.json +292 -0
- package/contracts/v4-adopter-delivery-v1.schema.json +81 -0
- package/contracts/v4-compatibility-facts-v1.schema.json +230 -0
- package/contracts/v4-floating-consumer-policy-receipt-v1.schema.json +107 -0
- package/contracts/v4-publication-rehearsal-capsule-v1.schema.json +233 -0
- package/contracts/v4-runtime-ref-resume-authority-v1.schema.json +235 -0
- package/contracts/v4-tail-reseal-v1.schema.json +276 -0
- package/dist/site/agent-index.json +5 -0
- package/dist/site/artifact-schemas.json +10 -0
- package/dist/site/buildchain-contract.json +1562 -44
- package/dist/site/buildchain-site.json +684 -42
- package/dist/site/capability-registry.json +17 -14
- package/dist/site/cli-registry.json +205 -3
- package/dist/site/controller-registry.json +62 -6
- package/dist/site/kfd-claims.json +551 -22
- package/dist/site/kfd-upstream-aggregate.json +1 -1
- package/dist/site/manual-registry.json +55 -9
- package/dist/site/node-api-registry.json +15247 -8690
- package/dist/site/page-registry.json +647 -29
- package/dist/site/public-surface-audit.json +876 -55
- package/dist/site/publication-authority-registry.json +44 -8
- package/dist/site/publication-registry.json +4 -4
- package/dist/site/release-provenance.json +26 -0
- package/dist/site/schemas/dev-delivery-authority-v2.schema.json +662 -0
- package/dist/site/schemas/release-tail-capabilities-v1.schema.json +199 -0
- package/dist/site/schemas/v4-adopter-delivery-v1.schema.json +81 -0
- package/dist/site/schemas/v4-compatibility-facts-v1.schema.json +230 -0
- package/dist/site/schemas/v4-publication-rehearsal-capsule-v1.schema.json +233 -0
- package/dist/site/site-manifest.json +37 -13
- package/dist/site/workflow-registry.json +200 -22
- package/docs/MAP.md +10 -2
- package/docs/cli-reference.md +404 -13
- package/docs/cli.md +8 -0
- package/docs/dev-alpha-candidate-patrol.md +8 -0
- package/docs/dev-delivery-qualification-landing-adr.md +251 -0
- package/docs/dev-delivery-warrant.md +361 -30
- package/docs/lifecycle-protocol.md +41 -0
- package/docs/next-development-transition.md +118 -0
- package/docs/node-api-reference.md +748 -322
- package/docs/release-tail-provider-plane.md +30 -0
- package/docs/reusable-build-surface.md +41 -0
- package/docs/runtime-train-validation.md +10 -0
- package/docs/v4-adopter-delivery.md +133 -0
- package/docs/v4-compatibility-facts.md +91 -0
- package/docs/v4-publication-rehearsal.md +130 -0
- package/docs/v4-runtime-ref-resume-authority.md +69 -0
- package/docs/v4-tail-reseal.md +73 -0
- package/docs/versioning.md +4 -2
- package/package.json +36 -6
- package/packages/core/adopter-delivery-passport.js +259 -0
- package/packages/core/adopter-delivery-vectors.js +158 -0
- package/packages/core/adopter-delivery-vectors.json +77 -0
- package/packages/core/artifact-signing.js +61 -0
- package/packages/core/buildchain-agent-manuals.js +3 -0
- package/packages/core/buildchain-compatibility-authority.js +336 -0
- package/packages/core/buildchain-compatibility-fact.js +394 -0
- package/packages/core/buildchain-compatibility-facts.json +217 -0
- package/packages/core/buildchain-compatibility-proof.js +566 -0
- package/packages/core/buildchain-config.js +150 -1
- package/packages/core/buildchain-contract.js +96 -143
- package/packages/core/buildchain-delivery-bootstrap.js +240 -0
- package/packages/core/buildchain-delivery-infrastructure.js +164 -0
- package/packages/core/buildchain-delivery-self-dogfood.js +395 -0
- package/packages/core/buildchain-publication-authority.js +1 -0
- package/packages/core/channel-candidate.js +8 -0
- package/packages/core/channel-promotion-baseline.js +55 -0
- package/packages/core/ci-lane-change-budget.js +247 -0
- package/packages/core/dev-alpha-candidate-selection.js +10 -2
- package/packages/core/dev-delivery-authority-candidate.js +270 -0
- package/packages/core/dev-delivery-authority-evidence.js +146 -0
- package/packages/core/dev-delivery-authority-landing.js +461 -0
- package/packages/core/dev-delivery-authority-observation.js +48 -0
- package/packages/core/dev-delivery-authority-qualification.js +591 -0
- package/packages/core/dev-delivery-authority-settlement.js +213 -0
- package/packages/core/dev-delivery-authority-state.js +583 -0
- package/packages/core/dev-delivery-candidate-identity.js +13 -0
- package/packages/core/dev-delivery-contract-surface.js +76 -0
- package/packages/core/dev-delivery-execution-failure.js +133 -0
- package/packages/core/dev-delivery-execution-transfer.js +592 -0
- package/packages/core/dev-delivery-landing-admission-core.js +119 -0
- package/packages/core/dev-delivery-landing-readback.js +598 -0
- package/packages/core/dev-delivery-landing-terminal-evidence.js +271 -0
- package/packages/core/dev-delivery-landing-testing-port.js +6 -0
- package/packages/core/dev-delivery-native-execution.js +110 -0
- package/packages/core/dev-delivery-native-proof.js +562 -0
- package/packages/core/dev-delivery-process-boundary.js +563 -0
- package/packages/core/dev-delivery-proof.js +37 -3
- package/packages/core/dev-delivery-provider-attempt.js +127 -0
- package/packages/core/dev-delivery-provider-heartbeat.js +382 -0
- package/packages/core/dev-delivery-warrant-cancellation.js +1 -0
- package/packages/core/dev-delivery-warrant-qualification.js +145 -0
- package/packages/core/dev-delivery-warrant-settlement.js +237 -36
- package/packages/core/dev-delivery-warrant-state.js +587 -0
- package/packages/core/dev-delivery-warrant.js +328 -370
- package/packages/core/github-governance-authority.js +1 -0
- package/packages/core/index.js +7 -0
- package/packages/core/kungfu-temporal-fact.js +557 -0
- package/packages/core/legacy-kfd-adopter-driver.js +167 -0
- package/packages/core/next-development-candidate-reservation.js +186 -0
- package/packages/core/next-development-controller.js +728 -0
- package/packages/core/next-development-projection.js +287 -0
- package/packages/core/next-development-transition.js +738 -0
- package/packages/core/paper-agent-entry.js +11 -5
- package/packages/core/paper.js +16 -5
- package/packages/core/publication-authority.js +5 -5
- package/packages/core/published-delivery-authority.js +266 -0
- package/packages/core/release-candidate-recovery.js +66 -11
- package/packages/core/release-candidate.js +79 -19
- package/packages/core/release-passport.js +271 -38
- package/packages/core/v4-adopter-delivery-parity.js +3 -3
- package/packages/core/v4-adopter-delivery.js +359 -0
- package/packages/core/v4-canonical-contracts.js +5 -0
- package/packages/core/v4-delivery-warrant-read-candidate.js +10 -3
- package/packages/core/v4-floating-consumer-evidence.js +338 -0
- package/packages/core/v4-floating-consumer-policy.js +569 -0
- package/packages/core/v4-floating-consumer-release-passport.js +153 -0
- package/packages/core/v4-publication-rehearsal-capsule.js +468 -0
- package/packages/core/v4-publication-rehearsal-provider-bindings.js +212 -0
- package/packages/core/v4-publication-rehearsal.js +481 -0
- package/packages/core/v4-runtime-ref-resume-authority.js +625 -0
- package/packages/core/v4-runtime-selector-persistence.js +228 -0
- package/packages/core/v4-tail-reseal-contract.js +26 -0
- package/packages/core/v4-tail-reseal-github.js +178 -0
- package/packages/core/v4-tail-reseal-receipt.js +225 -0
- package/packages/core/v4-tail-reseal.js +594 -0
- package/packages/core/workflow-yaml-contract.js +72 -2
- package/scripts/audit-publication-control-plane.mjs +31 -31
- package/scripts/buildchain-cli-help.mjs +41 -2
- package/scripts/check-ci-lane-change-budget.mjs +100 -0
- package/scripts/check-inventory.mjs +14 -3
- package/scripts/check-v4-floating-consumer-policy-contract.mjs +217 -0
- package/scripts/check-v4-public-dogfood-contract.mjs +6 -11
- package/scripts/dev-alpha-candidate-patrol.mjs +22 -1
- package/scripts/dev-delivery-authority-command-adapters.mjs +206 -0
- package/scripts/dev-delivery-authority-provider.mjs +28 -0
- package/scripts/dev-delivery-authority.mjs +490 -0
- package/scripts/dev-delivery-native-run.mjs +177 -0
- package/scripts/dev-delivery-process-boundary.mjs +260 -0
- package/scripts/dev-delivery-proof.mjs +67 -2
- package/scripts/dev-delivery-provider-heartbeat.mjs +215 -0
- package/scripts/dev-delivery-source-proof-replay.mjs +153 -0
- package/scripts/dev-delivery-source-proof-reuse.mjs +547 -0
- package/scripts/dev-delivery-two-phase-resume.mjs +345 -0
- package/scripts/dev-delivery-two-phase.mjs +573 -0
- package/scripts/dev-delivery-warrant-options.mjs +266 -0
- package/scripts/dev-delivery-warrant-store.mjs +231 -0
- package/scripts/dev-delivery-warrant.mjs +232 -194
- package/scripts/dev-pr-auto-merge.mjs +37 -48
- package/scripts/dev-pr-delivery-warrant.mjs +216 -2
- package/scripts/dev-pr-prequeue-guard.mjs +399 -0
- package/scripts/dev-qualification-patrol.mjs +9 -9
- package/scripts/dispatch-artifact-signing-authority.mjs +1 -1
- package/scripts/ensure-github-release.mjs +3 -3
- package/scripts/generate-channel-build-workflow.mjs +3 -0
- package/scripts/generate-channel-promotion-workflow.mjs +114 -14
- package/scripts/generate-next-development-guidance.mjs +49 -0
- package/scripts/generate-release-candidate-passport.mjs +192 -32
- package/scripts/generate-site-bundle.mjs +69 -4
- package/scripts/init-repo.mjs +26 -4
- package/scripts/inspect-artifact-signing-requests.mjs +6 -0
- package/scripts/next-development-self-dogfood-harness.mjs +460 -0
- package/scripts/next-development-self-dogfood.mjs +597 -0
- package/scripts/next-development-transition.mjs +47 -0
- package/scripts/npm-publish-transaction.mjs +103 -91
- package/scripts/promotion-channel-router.mjs +4 -4
- package/scripts/release-candidate-anchor-provenance.mjs +99 -0
- package/scripts/release-tail.mjs +51 -3
- package/scripts/release-train-self-dogfood.mjs +94 -92
- package/scripts/resume-from-candidate-run.mjs +565 -41
- package/scripts/seal-artifact-signing-requests.mjs +6 -0
- package/scripts/site-capability-metadata.mjs +43 -0
- package/scripts/stable-candidate-qualification.mjs +9 -10
- package/scripts/v4-consumer-policy.mjs +231 -0
- package/scripts/v4-publication-rehearsal-fixture.mjs +144 -0
- package/scripts/v4-tail-reseal-macos-rehearsal.mjs +134 -0
- package/scripts/v4-tail-reseal.mjs +416 -0
- package/templates/native-dev-delivery.yml +143 -0
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
candidateFromDecision,
|
|
21
21
|
selectLatestQualifiedSource,
|
|
22
22
|
} from "../packages/core/dev-alpha-candidate-selection.js";
|
|
23
|
+
import { readGitHubNextDevelopmentVersionReservation } from "../packages/core/next-development-candidate-reservation.js";
|
|
23
24
|
|
|
24
25
|
export { reconcileActiveReleaseTrain, selectLatestQualifiedSource };
|
|
25
26
|
|
|
@@ -617,6 +618,7 @@ export async function runDevAlphaCandidatePatrol(
|
|
|
617
618
|
comparison,
|
|
618
619
|
workflowEvidence,
|
|
619
620
|
skippedNewerCommitCount,
|
|
621
|
+
versionReservation,
|
|
620
622
|
qualificationError,
|
|
621
623
|
} = await resolvePatrolSourceInputs({
|
|
622
624
|
client,
|
|
@@ -646,6 +648,7 @@ export async function runDevAlphaCandidatePatrol(
|
|
|
646
648
|
observedSourceHeadSha,
|
|
647
649
|
skippedNewerCommitCount,
|
|
648
650
|
...(targetBaseline ? { targetBaseline } : {}),
|
|
651
|
+
...(versionReservation ? { versionReservation } : {}),
|
|
649
652
|
},
|
|
650
653
|
workflowEvidence,
|
|
651
654
|
requiredWorkflowPaths,
|
|
@@ -992,6 +995,20 @@ export function createGitHubChannelCandidateClient({
|
|
|
992
995
|
targetBranch,
|
|
993
996
|
parseCandidate: managedCandidateFromPullRequest,
|
|
994
997
|
}),
|
|
998
|
+
async readNextDevelopmentVersionReservation({
|
|
999
|
+
reservationSha,
|
|
1000
|
+
candidateSha,
|
|
1001
|
+
targetVersion,
|
|
1002
|
+
}) {
|
|
1003
|
+
return readGitHubNextDevelopmentVersionReservation({
|
|
1004
|
+
api,
|
|
1005
|
+
owner,
|
|
1006
|
+
repo,
|
|
1007
|
+
reservationSha,
|
|
1008
|
+
candidateSha,
|
|
1009
|
+
targetVersion,
|
|
1010
|
+
});
|
|
1011
|
+
},
|
|
995
1012
|
async listCompletedWorkflowRuns(workflowPathValue, sourceBranch) {
|
|
996
1013
|
const runs = [];
|
|
997
1014
|
for (let page = 1; page <= 10; page += 1) {
|
|
@@ -1015,7 +1032,11 @@ export function createGitHubChannelCandidateClient({
|
|
|
1015
1032
|
for (const commit of rows) {
|
|
1016
1033
|
const commitSha = text(commit.sha);
|
|
1017
1034
|
if (commitSha === targetSha) return commits;
|
|
1018
|
-
commits.push(
|
|
1035
|
+
commits.push({
|
|
1036
|
+
sha: commitSha,
|
|
1037
|
+
message: text(commit.commit?.message),
|
|
1038
|
+
parents: (commit.parents || []).map((parent) => text(parent.sha)),
|
|
1039
|
+
});
|
|
1019
1040
|
}
|
|
1020
1041
|
if (rows.length < 100) return commits;
|
|
1021
1042
|
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import {
|
|
4
|
+
acquireDevDeliveryLandingWarrant,
|
|
5
|
+
acquireDevDeliveryQualificationLease,
|
|
6
|
+
admitDevDeliveryMergeGroup,
|
|
7
|
+
completeDevDeliveryQualification,
|
|
8
|
+
heartbeatDevDeliveryLandingWarrantWithGitHubProvider,
|
|
9
|
+
heartbeatDevDeliveryQualificationLease,
|
|
10
|
+
migrateDevDeliveryAuthorityState,
|
|
11
|
+
observeDevDeliveryAuthorityState,
|
|
12
|
+
recoverDevDeliveryAuthority,
|
|
13
|
+
submitDevDeliveryAuthorityCandidate,
|
|
14
|
+
} from "../packages/core/dev-delivery-authority-landing.js";
|
|
15
|
+
import { createNativeCommandContract } from "../packages/core/dev-delivery-warrant.js";
|
|
16
|
+
import { settleDevDeliveryAuthorityWithProvider } from "./dev-delivery-authority-provider.mjs";
|
|
17
|
+
|
|
18
|
+
function identity(options) {
|
|
19
|
+
return {
|
|
20
|
+
candidateId: options.candidateId,
|
|
21
|
+
token: options.authorityToken,
|
|
22
|
+
generation: options.authorityGeneration,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function rootedList(value) {
|
|
27
|
+
if (Array.isArray(value)) return value;
|
|
28
|
+
let parsed;
|
|
29
|
+
try {
|
|
30
|
+
parsed = JSON.parse(value || "[]");
|
|
31
|
+
} catch (cause) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`qualification domains must be a JSON array: ${cause.message}`,
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
if (!Array.isArray(parsed))
|
|
37
|
+
throw new Error("qualification domains must be a JSON array");
|
|
38
|
+
return parsed;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function migrateAuthority(state, options) {
|
|
42
|
+
if (!options.migrationSource?.exists) {
|
|
43
|
+
throw new Error("migrate requires the live v1 authority state ref");
|
|
44
|
+
}
|
|
45
|
+
return migrateDevDeliveryAuthorityState(options.migrationSource.queue, {
|
|
46
|
+
now: options.now,
|
|
47
|
+
policy: options.authorityPolicy,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function submitCandidate(state, options) {
|
|
52
|
+
const nativeCommandContract = options.environmentRoot
|
|
53
|
+
? options.nativeCommandContract ||
|
|
54
|
+
createNativeCommandContract(options.nativeCommand)
|
|
55
|
+
: undefined;
|
|
56
|
+
if (
|
|
57
|
+
options.nativeCommandRoot &&
|
|
58
|
+
nativeCommandContract?.commandRoot !== options.nativeCommandRoot
|
|
59
|
+
) {
|
|
60
|
+
throw new Error(
|
|
61
|
+
"native command contract root does not match native-command",
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
return submitDevDeliveryAuthorityCandidate(
|
|
65
|
+
state,
|
|
66
|
+
{
|
|
67
|
+
pullRequestNumber: options.pullRequestNumber,
|
|
68
|
+
sourceHead: options.sourceHead,
|
|
69
|
+
assignmentRoot: options.assignmentRoot,
|
|
70
|
+
initiativeRoot: options.initiativeRoot,
|
|
71
|
+
sourceIdentityRoot: options.sourceIdentityRoot,
|
|
72
|
+
sourcePatchRoot: options.sourcePatchRoot,
|
|
73
|
+
sourceProofRoot: options.sourceProofRoot,
|
|
74
|
+
planRoot: options.planRoot,
|
|
75
|
+
closureRoot: options.closureRoot,
|
|
76
|
+
dependencyRoot: options.dependencyRoot,
|
|
77
|
+
toolchainRoot: options.toolchainRoot,
|
|
78
|
+
environmentRoot: options.environmentRoot,
|
|
79
|
+
nativeCommandContract,
|
|
80
|
+
affectedPaths: rootedList(options.affectedPaths),
|
|
81
|
+
shardEvidenceRoots: rootedList(options.shardEvidenceRoots),
|
|
82
|
+
deliveryClass: options.deliveryClass,
|
|
83
|
+
qualificationDomains: rootedList(options.qualificationDomains),
|
|
84
|
+
},
|
|
85
|
+
{ now: options.now },
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
const commandAdapters = {
|
|
90
|
+
migrate: migrateAuthority,
|
|
91
|
+
submit: submitCandidate,
|
|
92
|
+
"lease-qualification": (state, options) =>
|
|
93
|
+
acquireDevDeliveryQualificationLease(state, {
|
|
94
|
+
now: options.now,
|
|
95
|
+
leaseSeconds: options.leaseSeconds,
|
|
96
|
+
}),
|
|
97
|
+
"complete-qualification": (state, options) =>
|
|
98
|
+
completeDevDeliveryQualification(state, identity(options), {
|
|
99
|
+
sourceProof: options.sourceProof,
|
|
100
|
+
nativeProof: options.nativeProof,
|
|
101
|
+
qualificationContract: options.qualificationContract,
|
|
102
|
+
now: options.now,
|
|
103
|
+
}),
|
|
104
|
+
"heartbeat-qualification": (state, options) =>
|
|
105
|
+
heartbeatDevDeliveryQualificationLease(state, identity(options), {
|
|
106
|
+
now: options.now,
|
|
107
|
+
leaseSeconds: options.leaseSeconds,
|
|
108
|
+
}),
|
|
109
|
+
"lease-landing": (state, options) =>
|
|
110
|
+
acquireDevDeliveryLandingWarrant(state, {
|
|
111
|
+
now: options.now,
|
|
112
|
+
leaseSeconds: options.leaseSeconds,
|
|
113
|
+
}),
|
|
114
|
+
"heartbeat-landing": (state, options) =>
|
|
115
|
+
heartbeatDevDeliveryLandingWarrantWithGitHubProvider(
|
|
116
|
+
state,
|
|
117
|
+
identity(options),
|
|
118
|
+
{
|
|
119
|
+
providerAttempt: options.providerAttempt,
|
|
120
|
+
token: options.token || process.env.GITHUB_TOKEN,
|
|
121
|
+
apiUrl:
|
|
122
|
+
options.apiUrl ||
|
|
123
|
+
process.env.GITHUB_API_URL ||
|
|
124
|
+
"https://api.github.com",
|
|
125
|
+
now: options.now,
|
|
126
|
+
leaseSeconds: options.leaseSeconds,
|
|
127
|
+
},
|
|
128
|
+
),
|
|
129
|
+
recover: (state, options) =>
|
|
130
|
+
recoverDevDeliveryAuthority(state, { now: options.now }),
|
|
131
|
+
"admit-merge-group": (state, options) =>
|
|
132
|
+
admitDevDeliveryMergeGroup(state, identity(options), {
|
|
133
|
+
mergeGroupHead: options.mergeGroupHead,
|
|
134
|
+
providerRunId: options.providerRunId,
|
|
135
|
+
providerRunAttempt: options.providerRunAttempt,
|
|
136
|
+
token: options.token || process.env.GITHUB_TOKEN,
|
|
137
|
+
apiUrl:
|
|
138
|
+
options.apiUrl ||
|
|
139
|
+
process.env.GITHUB_API_URL ||
|
|
140
|
+
"https://api.github.com",
|
|
141
|
+
now: options.now,
|
|
142
|
+
}),
|
|
143
|
+
settle: settleDevDeliveryAuthorityWithProvider,
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
function readCommandDocuments(options) {
|
|
147
|
+
for (const [field, file] of [
|
|
148
|
+
["sourceProof", options.sourceProofPath],
|
|
149
|
+
["nativeProof", options.nativeProofPath],
|
|
150
|
+
["qualificationContract", options.qualificationContractPath],
|
|
151
|
+
["providerAttempt", options.providerAttemptPath],
|
|
152
|
+
]) {
|
|
153
|
+
if (file)
|
|
154
|
+
options[field] = JSON.parse(fs.readFileSync(path.resolve(file), "utf8"));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export async function runDevDeliveryAuthorityCommandAdapter(loaded, options) {
|
|
159
|
+
const loadedV2 =
|
|
160
|
+
loaded.exists &&
|
|
161
|
+
loaded.queue?.contract === "kungfu-buildchain-dev-delivery-authority" &&
|
|
162
|
+
Number(loaded.queue?.schemaVersion) === 2;
|
|
163
|
+
if (options.command === "migrate" && loadedV2) {
|
|
164
|
+
throw new Error("migration target state ref already exists");
|
|
165
|
+
}
|
|
166
|
+
if (options.command !== "migrate" && !loadedV2) {
|
|
167
|
+
throw new Error(
|
|
168
|
+
"v2 authority state is missing; explicitly migrate the exact current v1 state before mutation",
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
if (
|
|
172
|
+
options.expectedOldStateRoot &&
|
|
173
|
+
loaded.queue.stateRoot !== options.expectedOldStateRoot
|
|
174
|
+
) {
|
|
175
|
+
throw new Error(
|
|
176
|
+
`expected-old state drift: ${loaded.queue.stateRoot} != ${options.expectedOldStateRoot}`,
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
if (options.command === "observe") {
|
|
180
|
+
return {
|
|
181
|
+
result: {
|
|
182
|
+
schema: "kungfu.buildchain.dev-delivery-authority-command-result/v1",
|
|
183
|
+
ok: true,
|
|
184
|
+
mode: "observe",
|
|
185
|
+
stateRef: options.stateRef,
|
|
186
|
+
stateCommit: loaded.commitSha,
|
|
187
|
+
observation: observeDevDeliveryAuthorityState(loaded.queue, {
|
|
188
|
+
now: options.now,
|
|
189
|
+
}),
|
|
190
|
+
},
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
readCommandDocuments(options);
|
|
194
|
+
if (options.command === "heartbeat-landing" && !options.providerAttempt) {
|
|
195
|
+
throw new Error(
|
|
196
|
+
"heartbeat-landing requires --provider-attempt with the exact persisted admitted attempt",
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
const adapter = commandAdapters[options.command];
|
|
200
|
+
if (!adapter) {
|
|
201
|
+
throw new Error(
|
|
202
|
+
`unsupported dev authority command ${options.command || "<empty>"}`,
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
return { changed: await adapter(loaded.queue, options) };
|
|
206
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { settleDevDeliveryAuthorityCandidateWithGitHubProvider } from "../packages/core/dev-delivery-authority-landing.js";
|
|
2
|
+
|
|
3
|
+
export function settleDevDeliveryAuthorityWithProvider(state, options) {
|
|
4
|
+
return settleDevDeliveryAuthorityCandidateWithGitHubProvider(
|
|
5
|
+
state,
|
|
6
|
+
{
|
|
7
|
+
pullRequestNumber: options.pullRequestNumber,
|
|
8
|
+
sourceHead: options.sourceHead,
|
|
9
|
+
outcome: options.outcome,
|
|
10
|
+
evidenceRoot: options.evidenceRoot,
|
|
11
|
+
reason: options.reason,
|
|
12
|
+
authorityToken: options.authorityToken,
|
|
13
|
+
authorityGeneration: options.authorityGeneration,
|
|
14
|
+
transferRoot: options.transferRoot,
|
|
15
|
+
finalizerBoundaryRoot: options.finalizerBoundaryRoot,
|
|
16
|
+
nativeJobId: options.nativeJobId,
|
|
17
|
+
sealJobId: options.sealJobId,
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
now: options.now,
|
|
21
|
+
token: options.token || process.env.GITHUB_TOKEN,
|
|
22
|
+
apiUrl:
|
|
23
|
+
options.apiUrl ||
|
|
24
|
+
process.env.GITHUB_API_URL ||
|
|
25
|
+
"https://api.github.com",
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
}
|