@kungfu-tech/buildchain 4.0.1-alpha.6 → 4.0.1-alpha.9
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/architecture/ci-lane-change-budget.json +187 -0
- package/architecture/maintainability-policy.json +13 -13
- package/architecture/v4-floating-consumer-policy.json +6 -0
- package/contracts/fixtures/v4-tail-reseal-v1/valid.json +1 -1
- package/contracts/v4-floating-consumer-policy-receipt-v1.schema.json +4 -2
- package/dist/site/buildchain-contract.json +9 -9
- package/dist/site/buildchain-site.json +19 -9
- package/dist/site/capability-registry.json +2 -2
- package/dist/site/kfd-claims.json +31 -5
- package/dist/site/kfd-upstream-aggregate.json +1 -1
- package/dist/site/manual-registry.json +1 -1
- package/dist/site/node-api-registry.json +154 -73
- package/dist/site/page-registry.json +14 -4
- package/dist/site/public-surface-audit.json +14 -3
- package/dist/site/publication-authority-registry.json +23 -5
- package/dist/site/publication-registry.json +4 -4
- package/dist/site/release-provenance.json +1 -0
- package/dist/site/site-manifest.json +5 -5
- package/dist/site/workflow-registry.json +25 -4
- package/docs/dev-delivery-warrant.md +22 -1
- package/docs/node-api-reference.md +161 -148
- package/package.json +3 -2
- package/packages/core/buildchain-publication-authority.js +1 -0
- package/packages/core/ci-lane-change-budget.js +247 -0
- package/packages/core/dev-delivery-native-proof.js +43 -27
- package/packages/core/dev-delivery-warrant-state.js +31 -8
- package/packages/core/dev-delivery-warrant.js +8 -3
- package/packages/core/github-governance-authority.js +1 -0
- package/packages/core/index.js +5 -0
- package/packages/core/release-candidate-recovery.js +66 -11
- package/packages/core/release-candidate.js +2 -2
- package/packages/core/release-passport.js +10 -1
- package/packages/core/v4-delivery-warrant-read-candidate.js +10 -3
- package/packages/core/v4-floating-consumer-evidence.js +18 -4
- package/packages/core/v4-floating-consumer-policy.js +138 -35
- package/packages/core/v4-floating-consumer-release-passport.js +30 -3
- package/packages/core/workflow-yaml-contract.js +24 -2
- package/scripts/check-ci-lane-change-budget.mjs +100 -0
- package/scripts/check-inventory.mjs +2 -2
- package/scripts/check-v4-floating-consumer-policy-contract.mjs +23 -4
- package/scripts/dev-delivery-warrant-store.mjs +10 -6
- package/scripts/dev-delivery-warrant.mjs +5 -1
- package/scripts/dev-pr-delivery-warrant.mjs +1 -0
- package/scripts/dev-qualification-patrol.mjs +9 -9
- package/scripts/generate-channel-promotion-workflow.mjs +2 -2
- package/scripts/promotion-channel-router.mjs +4 -4
- package/scripts/release-candidate-anchor-provenance.mjs +99 -0
- package/scripts/resume-from-candidate-run.mjs +11 -14
- package/scripts/site-capability-metadata.mjs +1 -0
- package/scripts/v4-consumer-policy.mjs +4 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kungfu-tech/buildchain",
|
|
3
|
-
"version": "4.0.1-alpha.
|
|
3
|
+
"version": "4.0.1-alpha.9",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Buildchain Release Passport, release governance, CLI toolkit, and site facts.",
|
|
6
6
|
"repository": "https://github.com/kungfu-systems/buildchain",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"./buildchain-contract": "./packages/core/buildchain-contract.js",
|
|
26
26
|
"./compatibility-fact-authority": "./packages/core/buildchain-compatibility-proof.js",
|
|
27
27
|
"./candidate-timeline": "./packages/core/candidate-timeline.js",
|
|
28
|
+
"./ci-lane-change-budget": "./packages/core/ci-lane-change-budget.js",
|
|
28
29
|
"./channel-candidate": "./packages/core/channel-candidate.js",
|
|
29
30
|
"./cache-evidence": "./packages/core/cache-evidence.js",
|
|
30
31
|
"./controller-evidence": "./packages/core/controller-evidence.js",
|
|
@@ -150,7 +151,7 @@
|
|
|
150
151
|
"scripts": {
|
|
151
152
|
"precheck:static": "prettier --check architecture/decisions/0003-two-phase-delivery-warrant.md architecture/v4-delivery-authority-parity.json contracts/dev-delivery-authority-v2.schema.json dist/site/schemas/dev-delivery-authority-v2.schema.json docs/dev-delivery-qualification-landing-adr.md packages/core/dev-delivery-authority-candidate.js packages/core/dev-delivery-authority-evidence.js packages/core/dev-delivery-authority-landing.js packages/core/dev-delivery-authority-observation.js packages/core/dev-delivery-authority-qualification.js packages/core/dev-delivery-authority-settlement.js packages/core/dev-delivery-authority-state.js packages/core/dev-delivery-execution-failure.js packages/core/dev-delivery-execution-transfer.js packages/core/dev-delivery-landing-readback.js packages/core/dev-delivery-landing-terminal-evidence.js packages/core/dev-delivery-landing-testing-port.js packages/core/dev-delivery-native-execution.js packages/core/dev-delivery-native-proof.js packages/core/dev-delivery-process-boundary.js packages/core/dev-delivery-warrant-qualification.js packages/core/dev-delivery-warrant-state.js scripts/dev-delivery-authority-command-adapters.mjs scripts/dev-delivery-authority-provider.mjs scripts/dev-delivery-authority.mjs scripts/dev-delivery-native-run.mjs scripts/dev-delivery-process-boundary.mjs scripts/dev-delivery-two-phase-resume.mjs scripts/dev-delivery-two-phase.mjs scripts/dev-delivery-warrant-options.mjs scripts/dev-delivery-warrant-store.mjs templates/native-dev-delivery.yml",
|
|
152
153
|
"operator:windows-jit": "bash scripts/aws-windows-jit-operator.sh",
|
|
153
|
-
"check": "pnpm run check:static && node scripts/check-v4-public-dogfood-contract.mjs && node scripts/check-v4-floating-consumer-policy-contract.mjs && pnpm run check:v4-bridge && pnpm run check:v4-contracts && node scripts/check-maintainability.mjs && node scripts/check-internal-architecture.mjs && node scripts/check-inventory.mjs && node scripts/check-core-mechanism-inventory.mjs && node scripts/check-release-tail-contract.mjs && node scripts/v4-publication-rehearsal-fixture.mjs --check && node scripts/v4-architecture.mjs validate && node scripts/v4-warrant-shadow-plan.mjs validate && pnpm run check:site && pnpm run check:workflows && pnpm run test:unit && pnpm run check:golden-path && node scripts/check-action-bundles.mjs",
|
|
154
|
+
"check": "pnpm run check:static && node scripts/check-ci-lane-change-budget.mjs && node scripts/check-v4-public-dogfood-contract.mjs && node scripts/check-v4-floating-consumer-policy-contract.mjs && pnpm run check:v4-bridge && pnpm run check:v4-contracts && node scripts/check-maintainability.mjs && node scripts/check-internal-architecture.mjs && node scripts/check-inventory.mjs && node scripts/check-core-mechanism-inventory.mjs && node scripts/check-release-tail-contract.mjs && node scripts/v4-publication-rehearsal-fixture.mjs --check && node scripts/v4-architecture.mjs validate && node scripts/v4-warrant-shadow-plan.mjs validate && pnpm run check:site && pnpm run check:workflows && pnpm run test:unit && pnpm run check:golden-path && node scripts/check-action-bundles.mjs",
|
|
154
155
|
"check:static": "node scripts/check-javascript-syntax.mjs && prettier --check architecture/*.json contracts/release-tail-provider-bindings-v1.schema.json contracts/v4-canonical-contracts-v1.schema.json contracts/v4-compatibility-facts-v1.schema.json contracts/v4-delivery-warrant-semantic-diff-report-v1.schema.json contracts/v4-delivery-warrant-trace-v1.schema.json contracts/v4-floating-consumer-policy-receipt-v1.schema.json contracts/v4-runtime-ref-resume-authority-v1.schema.json contracts/v4-tail-reseal-v1.schema.json contracts/v4-host-contract-v1.schema.json contracts/v4-provider-operation-journal-v1.schema.json contracts/v4-release-activation-shadow-v1.schema.json contracts/v4-stable-publication-fence-v1.schema.json contracts/v4-partial-mutation-recovery-v1.schema.json contracts/v4-stage-capsule-v1.schema.json contracts/v4-stage-capsule-store-v1.schema.json contracts/v4-stage-capsule-resume-v1.schema.json contracts/release-tail-capabilities-v1.schema.json contracts/fixtures/release-tail-capabilities-v1/*.json contracts/fixtures/v4-delivery-warrant-trace-v1/*.json contracts/fixtures/v4-floating-consumer-policy-v1/*.json contracts/fixtures/v4-runtime-ref-resume-authority-v1/*.json contracts/fixtures/v4-tail-reseal-v1/*.json contracts/fixtures/v4-compatibility-facts-v1/*.json contracts/fixtures/v4-provider-operation-journal-v1/*.json contracts/fixtures/v4-provider-readback-idempotency-v1/*.json contracts/fixtures/v4-release-activation-shadow-v1/*.json contracts/fixtures/v4-stable-publication-fence-v1/*.json contracts/fixtures/v4-partial-mutation-recovery-v1/*.json contracts/fixtures/v4-stage-capsule-v1/*.json contracts/fixtures/v4-stage-capsule-store-v1/*.json contracts/fixtures/v4-stage-capsule-resume-v1/*.json bin/internal/command-registry.mjs bin/internal/compatibility-facts-cli.mjs packages/core/v4-canonical-contracts.js packages/core/kungfu-temporal-fact.js packages/core/buildchain-compatibility-fact.js packages/core/buildchain-compatibility-authority.js packages/core/buildchain-compatibility-proof.js packages/core/v4-floating-consumer-evidence.js packages/core/v4-floating-consumer-policy.js packages/core/v4-floating-consumer-release-passport.js packages/core/v4-runtime-ref-resume-authority.js packages/core/v4-tail-reseal-contract.js packages/core/v4-tail-reseal-github.js packages/core/v4-tail-reseal-receipt.js packages/core/v4-tail-reseal.js packages/core/v4-runtime-selector-persistence.js packages/core/v4-provider-operation-journal.js packages/core/v4-provider-readback-idempotency.js packages/core/v4-release-activation-shadow.js packages/core/v4-stable-publication-fence.js packages/core/v4-partial-mutation-recovery-qualification.js packages/core/v4-stage-capsule.js packages/core/v4-stage-capsule-store.js packages/core/v4-stage-capsule-local-store.js packages/core/v4-platform-stage-checkpoints.js packages/core/v4-stage-capsule-resume-planner.js packages/core/v4-stage-capsule-qualification.js packages/core/v4-stage-capsule-qualification-campaign.js packages/core/v4-delivery-warrant-fixture-runner.js packages/core/v4-delivery-warrant-read-candidate.js packages/core/v4-delivery-warrant-semantic-diff-gate.js packages/core/v4-delivery-warrant-shadow-adapter.js scripts/authorize-promotion-runtime-override.cjs scripts/check-core-mechanism-inventory.mjs scripts/check-release-tail-contract.mjs scripts/check-javascript-syntax.mjs scripts/check-maintainability.mjs scripts/dev-pr-prequeue-guard.mjs scripts/check-v4-public-dogfood-contract.mjs scripts/maintainability-metrics.mjs scripts/public-reference.mjs scripts/site-reference-registry.mjs scripts/generate-public-reference.mjs scripts/v4-architecture.mjs scripts/v4-bridge-bootstrap.mjs scripts/v4-bridge-evidence.mjs scripts/v4-consumer-policy.mjs scripts/v4-host-adapter.mjs scripts/v4-platform-stage-checkpoint-rehearsal.mjs scripts/v4-stage-capsule-resume-rehearsal.mjs scripts/v4-stage-capsule-qualification.mjs scripts/v4-tail-reseal-macos-rehearsal.mjs scripts/v4-tail-reseal.mjs scripts/v4-warrant-shadow-plan.mjs scripts/verify-golden-path.mjs tests/authorize-promotion-runtime-override.test.mjs tests/command-registry.test.mjs tests/core-mechanism-inventory.test.mjs tests/release-tail-contract.test.mjs tests/maintainability.test.mjs tests/promotion-responsibilities.test.mjs tests/public-reference.test.mjs tests/v4-architecture.test.mjs tests/v4-bridge.test.mjs tests/v4-canonical-contracts.test.mjs tests/v4-delivery-warrant-fixture-runner.test.mjs tests/v4-delivery-warrant-read-candidate.test.mjs tests/v4-floating-consumer-policy.test.mjs tests/v4-runtime-ref-resume-authority.test.mjs tests/v4-tail-reseal.test.mjs tests/v4-tail-reseal-parity.test.mjs tests/v4-compatibility-facts.test.mjs tests/v4-platform-stage-checkpoints.test.mjs tests/v4-provider-operation-journal.test.mjs tests/v4-provider-readback-idempotency.test.mjs tests/v4-public-dogfood-contract.test.mjs tests/v4-release-activation-shadow.test.mjs tests/v4-stable-publication-fence.test.mjs tests/v4-partial-mutation-recovery-qualification.test.mjs tests/v4-stage-capsule.test.mjs tests/v4-stage-capsule-store.test.mjs tests/v4-stage-capsule-resume-planner.test.mjs tests/v4-stage-capsule-qualification.test.mjs tests/v4-warrant-shadow-plan.test.mjs",
|
|
155
156
|
"check:v4-bridge": "cargo fmt --manifest-path crates/buildchain-v4-bridge/Cargo.toml -- --check && cargo clippy --locked --manifest-path crates/buildchain-v4-bridge/Cargo.toml -- -D warnings && cargo test --locked --manifest-path crates/buildchain-v4-bridge/Cargo.toml",
|
|
156
157
|
"check:v4-contracts": "cargo fmt --manifest-path crates/buildchain-v4-contracts/Cargo.toml -- --check && cargo clippy --locked --manifest-path crates/buildchain-v4-contracts/Cargo.toml -- -D warnings && cargo test --locked --manifest-path crates/buildchain-v4-contracts/Cargo.toml && node --test tests/v4-canonical-contracts.test.mjs tests/v4-delivery-warrant-fixture-runner.test.mjs tests/v4-delivery-warrant-read-candidate.test.mjs tests/v4-floating-consumer-policy-contract.test.mjs tests/v4-floating-consumer-policy.test.mjs tests/v4-runtime-ref-resume-authority.test.mjs tests/v4-tail-reseal.test.mjs tests/v4-tail-reseal-parity.test.mjs tests/v4-compatibility-facts.test.mjs tests/v4-publication-rehearsal.test.mjs tests/v4-platform-stage-checkpoints.test.mjs tests/v4-provider-operation-journal.test.mjs tests/v4-provider-readback-idempotency.test.mjs tests/v4-public-dogfood-contract.test.mjs tests/v4-release-activation-shadow.test.mjs tests/v4-stable-publication-fence.test.mjs tests/v4-partial-mutation-recovery-qualification.test.mjs tests/v4-stage-capsule.test.mjs tests/v4-stage-capsule-store.test.mjs tests/v4-stage-capsule-resume-planner.test.mjs tests/v4-stage-capsule-qualification.test.mjs",
|
|
@@ -29,6 +29,7 @@ const DESCRIPTORS = Object.freeze([
|
|
|
29
29
|
[".github/workflows/buildchain-patrol-monthly.yml", "governance-write"],
|
|
30
30
|
[".github/workflows/buildchain-patrol-weekly.yml", "governance-write"],
|
|
31
31
|
[".github/workflows/buildchain-patrol.yml", "governance-write"],
|
|
32
|
+
[".github/workflows/buildchain-ref-promotion-recovery.yml", "governance-write"],
|
|
32
33
|
[".github/workflows/buildchain-ref-promotion.yml", "governance-write"],
|
|
33
34
|
[".github/workflows/buildchain-stable-candidate-patrol.yml", "governance-write"],
|
|
34
35
|
[".github/workflows/dev-qualification-patrol.yml", "governance-write"],
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { parseWorkflowDocument } from "./workflow-yaml-contract.js";
|
|
3
|
+
|
|
4
|
+
export const CI_LANE_CHANGE_BUDGET_CONTRACT =
|
|
5
|
+
"buildchain.ci-lane-change-budget/v1";
|
|
6
|
+
|
|
7
|
+
const AUTHORITY_CLASSES = new Set([
|
|
8
|
+
"merge-critical-required",
|
|
9
|
+
"merge-critical-admission",
|
|
10
|
+
"post-merge-advisory",
|
|
11
|
+
"diagnostic",
|
|
12
|
+
"evidence",
|
|
13
|
+
"release",
|
|
14
|
+
]);
|
|
15
|
+
const TRIGGER_CLASSES = new Set([
|
|
16
|
+
"merge-group",
|
|
17
|
+
"pull-request",
|
|
18
|
+
"push",
|
|
19
|
+
"scheduled",
|
|
20
|
+
"manual",
|
|
21
|
+
"reusable",
|
|
22
|
+
"release",
|
|
23
|
+
"mixed",
|
|
24
|
+
]);
|
|
25
|
+
const CONCURRENCY_MODES = new Set([
|
|
26
|
+
"none",
|
|
27
|
+
"ref-scoped",
|
|
28
|
+
"workflow-scoped",
|
|
29
|
+
"serialized",
|
|
30
|
+
]);
|
|
31
|
+
const CANCELLATION_BEHAVIORS = new Set([
|
|
32
|
+
"cancel-stale",
|
|
33
|
+
"finish-started",
|
|
34
|
+
"provider-default",
|
|
35
|
+
"not-applicable",
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
function canonical(value) {
|
|
39
|
+
if (Array.isArray(value)) return value.map(canonical);
|
|
40
|
+
if (value && typeof value === "object") {
|
|
41
|
+
return Object.fromEntries(
|
|
42
|
+
Object.keys(value)
|
|
43
|
+
.sort()
|
|
44
|
+
.map((key) => [key, canonical(value[key])]),
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function root(value) {
|
|
51
|
+
return `sha256:${crypto
|
|
52
|
+
.createHash("sha256")
|
|
53
|
+
.update(JSON.stringify(canonical(value)))
|
|
54
|
+
.digest("hex")}`;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function triggerClass(triggers) {
|
|
58
|
+
const classes = new Set();
|
|
59
|
+
for (const trigger of triggers) {
|
|
60
|
+
if (trigger === "merge_group") classes.add("merge-group");
|
|
61
|
+
else if (trigger.startsWith("pull_request")) classes.add("pull-request");
|
|
62
|
+
else if (trigger === "push") classes.add("push");
|
|
63
|
+
else if (trigger === "schedule") classes.add("scheduled");
|
|
64
|
+
else if (trigger === "workflow_dispatch") classes.add("manual");
|
|
65
|
+
else if (trigger === "workflow_call") classes.add("reusable");
|
|
66
|
+
else if (trigger === "release") classes.add("release");
|
|
67
|
+
else classes.add("mixed");
|
|
68
|
+
}
|
|
69
|
+
return classes.size === 1 ? [...classes][0] : "mixed";
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function diagnostic(code, laneId, message) {
|
|
73
|
+
return { code, laneId, message };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function validateDeclaration(declaration, observed) {
|
|
77
|
+
const laneId = String(declaration?.laneId || "");
|
|
78
|
+
const diagnostics = [];
|
|
79
|
+
if (!AUTHORITY_CLASSES.has(declaration?.authorityClass)) {
|
|
80
|
+
diagnostics.push(
|
|
81
|
+
diagnostic(
|
|
82
|
+
"invalid-authority-class",
|
|
83
|
+
laneId,
|
|
84
|
+
"authorityClass must identify the lane's merge or non-merge authority",
|
|
85
|
+
),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if (!TRIGGER_CLASSES.has(declaration?.triggerClass)) {
|
|
89
|
+
diagnostics.push(
|
|
90
|
+
diagnostic(
|
|
91
|
+
"invalid-trigger-class",
|
|
92
|
+
laneId,
|
|
93
|
+
"triggerClass must identify the workflow trigger class",
|
|
94
|
+
),
|
|
95
|
+
);
|
|
96
|
+
} else if (observed && declaration.triggerClass !== observed.triggerClass) {
|
|
97
|
+
diagnostics.push(
|
|
98
|
+
diagnostic(
|
|
99
|
+
"trigger-class-mismatch",
|
|
100
|
+
laneId,
|
|
101
|
+
`declared ${declaration.triggerClass}, observed ${observed.triggerClass}`,
|
|
102
|
+
),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
const concurrency = declaration?.concurrencyPolicy;
|
|
106
|
+
if (
|
|
107
|
+
!concurrency ||
|
|
108
|
+
!CONCURRENCY_MODES.has(concurrency.mode) ||
|
|
109
|
+
typeof concurrency.cancelInProgress !== "boolean"
|
|
110
|
+
) {
|
|
111
|
+
diagnostics.push(
|
|
112
|
+
diagnostic(
|
|
113
|
+
"invalid-concurrency-policy",
|
|
114
|
+
laneId,
|
|
115
|
+
"concurrencyPolicy requires a known mode and boolean cancelInProgress",
|
|
116
|
+
),
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
if (
|
|
120
|
+
!Number.isFinite(declaration?.expectedRunnerMinutes) ||
|
|
121
|
+
declaration.expectedRunnerMinutes <= 0
|
|
122
|
+
) {
|
|
123
|
+
diagnostics.push(
|
|
124
|
+
diagnostic(
|
|
125
|
+
"invalid-runner-budget",
|
|
126
|
+
laneId,
|
|
127
|
+
"expectedRunnerMinutes must be greater than zero",
|
|
128
|
+
),
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if (!CANCELLATION_BEHAVIORS.has(declaration?.cancellationBehavior)) {
|
|
132
|
+
diagnostics.push(
|
|
133
|
+
diagnostic(
|
|
134
|
+
"invalid-cancellation-behavior",
|
|
135
|
+
laneId,
|
|
136
|
+
"cancellationBehavior must describe how stale or started work settles",
|
|
137
|
+
),
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
const impact = declaration?.sloImpact;
|
|
141
|
+
if (
|
|
142
|
+
!impact ||
|
|
143
|
+
typeof impact.mergeCritical !== "boolean" ||
|
|
144
|
+
!String(impact.metric || "").trim() ||
|
|
145
|
+
!Number.isFinite(impact.expectedContributionSeconds) ||
|
|
146
|
+
impact.expectedContributionSeconds < 0 ||
|
|
147
|
+
!String(impact.rationale || "").trim()
|
|
148
|
+
) {
|
|
149
|
+
diagnostics.push(
|
|
150
|
+
diagnostic(
|
|
151
|
+
"invalid-slo-impact",
|
|
152
|
+
laneId,
|
|
153
|
+
"sloImpact requires mergeCritical, metric, expectedContributionSeconds, and rationale",
|
|
154
|
+
),
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
return diagnostics;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function collectLanes(workflows) {
|
|
161
|
+
const lanes = new Map();
|
|
162
|
+
for (const workflow of workflows) {
|
|
163
|
+
const workflowPath = String(workflow?.path || "").trim();
|
|
164
|
+
if (!workflowPath) throw new Error("workflow path is required");
|
|
165
|
+
const document = parseWorkflowDocument(workflow.text);
|
|
166
|
+
for (const job of document.jobs) {
|
|
167
|
+
const laneId = `${workflowPath}#${job.id}`;
|
|
168
|
+
if (lanes.has(laneId)) throw new Error(`duplicate CI lane: ${laneId}`);
|
|
169
|
+
lanes.set(laneId, {
|
|
170
|
+
laneId,
|
|
171
|
+
workflowPath,
|
|
172
|
+
jobId: job.id,
|
|
173
|
+
triggerClass: triggerClass(document.triggers),
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return lanes;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export function evaluateCiLaneChangeBudget({
|
|
181
|
+
policy,
|
|
182
|
+
workflows,
|
|
183
|
+
baselineWorkflows = null,
|
|
184
|
+
} = {}) {
|
|
185
|
+
if (policy?.schema !== CI_LANE_CHANGE_BUDGET_CONTRACT) {
|
|
186
|
+
throw new Error(`expected ${CI_LANE_CHANGE_BUDGET_CONTRACT}`);
|
|
187
|
+
}
|
|
188
|
+
if (!Array.isArray(workflows)) throw new Error("workflows must be an array");
|
|
189
|
+
const observed = collectLanes(workflows);
|
|
190
|
+
const baselineLaneIds = baselineWorkflows
|
|
191
|
+
? [...collectLanes(baselineWorkflows).keys()]
|
|
192
|
+
: policy.baseline?.lanes || [];
|
|
193
|
+
const baseline = new Set(baselineLaneIds);
|
|
194
|
+
if (baseline.size !== baselineLaneIds.length) {
|
|
195
|
+
throw new Error("baseline CI lanes must be unique");
|
|
196
|
+
}
|
|
197
|
+
const declarations = new Map();
|
|
198
|
+
const diagnostics = [];
|
|
199
|
+
for (const declaration of policy.declarations || []) {
|
|
200
|
+
const laneId = String(declaration?.laneId || "").trim();
|
|
201
|
+
if (!laneId) throw new Error("CI lane declaration laneId is required");
|
|
202
|
+
if (declarations.has(laneId))
|
|
203
|
+
throw new Error(`duplicate CI lane declaration: ${laneId}`);
|
|
204
|
+
declarations.set(laneId, declaration);
|
|
205
|
+
if (!observed.has(laneId)) {
|
|
206
|
+
diagnostics.push(
|
|
207
|
+
diagnostic(
|
|
208
|
+
"stale-declaration",
|
|
209
|
+
laneId,
|
|
210
|
+
"declared CI lane is absent from the current workflow cut",
|
|
211
|
+
),
|
|
212
|
+
);
|
|
213
|
+
}
|
|
214
|
+
diagnostics.push(
|
|
215
|
+
...validateDeclaration(declaration, observed.get(laneId) || null),
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
const newLanes = [...observed.keys()]
|
|
219
|
+
.filter((laneId) => !baseline.has(laneId))
|
|
220
|
+
.sort();
|
|
221
|
+
for (const laneId of newLanes) {
|
|
222
|
+
if (!declarations.has(laneId)) {
|
|
223
|
+
diagnostics.push(
|
|
224
|
+
diagnostic(
|
|
225
|
+
"undeclared-new-lane",
|
|
226
|
+
laneId,
|
|
227
|
+
"new CI lane must declare authority, trigger, concurrency, runner, cancellation, and SLO budgets",
|
|
228
|
+
),
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const result = {
|
|
233
|
+
schema: "buildchain.ci-lane-change-budget.evaluation/v1",
|
|
234
|
+
ok: diagnostics.length === 0,
|
|
235
|
+
observedLaneCount: observed.size,
|
|
236
|
+
baselineLaneCount: baseline.size,
|
|
237
|
+
newLaneCount: newLanes.length,
|
|
238
|
+
declaredLaneCount: declarations.size,
|
|
239
|
+
newLanes,
|
|
240
|
+
diagnostics: diagnostics.sort((left, right) =>
|
|
241
|
+
`${left.laneId}:${left.code}`.localeCompare(
|
|
242
|
+
`${right.laneId}:${right.code}`,
|
|
243
|
+
),
|
|
244
|
+
),
|
|
245
|
+
};
|
|
246
|
+
return { ...result, evaluationRoot: root(result) };
|
|
247
|
+
}
|
|
@@ -43,7 +43,39 @@ export const DEV_DELIVERY_QUALIFICATION_RECEIPT_SCHEMA =
|
|
|
43
43
|
export const NATIVE_PROOF_BASE_DELTA_SCHEMA =
|
|
44
44
|
"kungfu.buildchain.native-proof-base-delta/v1";
|
|
45
45
|
const NATIVE_QUALIFICATION_ROOT_SEMANTICS = "semantic-native-identity-v1";
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
function normalizeQualifiedWarrant(warrant, candidate, allowLegacyV3Readback) {
|
|
48
|
+
const qualifiedV3Readback =
|
|
49
|
+
allowLegacyV3Readback &&
|
|
50
|
+
!warrant.nativeCommandContract &&
|
|
51
|
+
!candidate.nativeCommandContract &&
|
|
52
|
+
!warrant.nativeExecutionReceiptRoot &&
|
|
53
|
+
!warrant.qualificationReceiptRoot;
|
|
54
|
+
warrant.nativeProofRoot = exactRoot(
|
|
55
|
+
warrant.nativeProofRoot,
|
|
56
|
+
"Warrant nativeProofRoot",
|
|
57
|
+
);
|
|
58
|
+
warrant.nativeProofReuseRoot = exactRoot(
|
|
59
|
+
warrant.nativeProofReuseRoot,
|
|
60
|
+
"Warrant nativeProofReuseRoot",
|
|
61
|
+
);
|
|
62
|
+
if (!qualifiedV3Readback) {
|
|
63
|
+
warrant.nativeExecutionReceiptRoot = exactRoot(
|
|
64
|
+
warrant.nativeExecutionReceiptRoot,
|
|
65
|
+
"Warrant nativeExecutionReceiptRoot",
|
|
66
|
+
);
|
|
67
|
+
warrant.qualificationReceiptRoot = exactRoot(
|
|
68
|
+
warrant.qualificationReceiptRoot,
|
|
69
|
+
"Warrant qualificationReceiptRoot",
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
warrant.qualifiedAt = timestamp(warrant.qualifiedAt, "Warrant qualifiedAt");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function validateActiveDevDeliveryWarrant(
|
|
76
|
+
queue,
|
|
77
|
+
{ allowLegacyV3Readback = false } = {},
|
|
78
|
+
) {
|
|
47
79
|
const warrant = queue.activeWarrant;
|
|
48
80
|
if (warrant.schema !== "kungfu.buildchain.dev-delivery-warrant/v1")
|
|
49
81
|
throw new Error("active Warrant schema is unsupported");
|
|
@@ -68,24 +100,17 @@ export function validateActiveDevDeliveryWarrant(queue) {
|
|
|
68
100
|
const phase = historicalPhaseLess ? "legacy-active" : warrant.phase;
|
|
69
101
|
if (!["legacy-active", "provisional", "qualified"].includes(phase))
|
|
70
102
|
throw new Error("active Warrant phase is unsupported");
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"Warrant
|
|
79
|
-
);
|
|
80
|
-
warrant.nativeExecutionReceiptRoot = exactRoot(
|
|
81
|
-
warrant.nativeExecutionReceiptRoot,
|
|
82
|
-
"Warrant nativeExecutionReceiptRoot",
|
|
83
|
-
);
|
|
84
|
-
warrant.qualificationReceiptRoot = exactRoot(
|
|
85
|
-
warrant.qualificationReceiptRoot,
|
|
86
|
-
"Warrant qualificationReceiptRoot",
|
|
103
|
+
const active = queue.candidates.filter((candidate) =>
|
|
104
|
+
["selected", "proving", "waiting", "blocked", "qualified"].includes(
|
|
105
|
+
candidate.status,
|
|
106
|
+
),
|
|
107
|
+
);
|
|
108
|
+
if (active.length !== 1 || active[0].candidateId !== warrant.candidateId)
|
|
109
|
+
throw new Error(
|
|
110
|
+
"exactly one active candidate must match the active Warrant",
|
|
87
111
|
);
|
|
88
|
-
|
|
112
|
+
if (warrant.phase === "qualified") {
|
|
113
|
+
normalizeQualifiedWarrant(warrant, active[0], allowLegacyV3Readback);
|
|
89
114
|
} else if (
|
|
90
115
|
warrant.phase === "provisional" &&
|
|
91
116
|
(warrant.nativeProofRoot ||
|
|
@@ -98,15 +123,6 @@ export function validateActiveDevDeliveryWarrant(queue) {
|
|
|
98
123
|
"provisional Warrant cannot carry qualified native evidence",
|
|
99
124
|
);
|
|
100
125
|
}
|
|
101
|
-
const active = queue.candidates.filter((candidate) =>
|
|
102
|
-
["selected", "proving", "waiting", "blocked", "qualified"].includes(
|
|
103
|
-
candidate.status,
|
|
104
|
-
),
|
|
105
|
-
);
|
|
106
|
-
if (active.length !== 1 || active[0].candidateId !== warrant.candidateId)
|
|
107
|
-
throw new Error(
|
|
108
|
-
"exactly one active candidate must match the active Warrant",
|
|
109
|
-
);
|
|
110
126
|
if (
|
|
111
127
|
historicalPhaseLess &&
|
|
112
128
|
(active[0].environmentRoot ||
|
|
@@ -51,8 +51,8 @@ export const TERMINAL_STATES = new Set([
|
|
|
51
51
|
"terminal-failure",
|
|
52
52
|
"dequeued",
|
|
53
53
|
"cancelled",
|
|
54
|
+
"superseded",
|
|
54
55
|
]);
|
|
55
|
-
|
|
56
56
|
export function issueDevDeliveryWarrant(
|
|
57
57
|
queue,
|
|
58
58
|
before,
|
|
@@ -158,6 +158,21 @@ function normalizePolicy(policy = {}) {
|
|
|
158
158
|
emergencyPolicy: text(policy.emergencyPolicy || "reviewed-explicit-only"),
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
+
|
|
162
|
+
function lacksLiveNativeProof(candidate, status, allowLegacyV3Readback) {
|
|
163
|
+
const { environmentRoot, nativeCommandContract } = candidate;
|
|
164
|
+
const native =
|
|
165
|
+
candidate.deliveryClass !== "non-native-fast" ||
|
|
166
|
+
environmentRoot ||
|
|
167
|
+
nativeCommandContract;
|
|
168
|
+
return (
|
|
169
|
+
native &&
|
|
170
|
+
(!environmentRoot ||
|
|
171
|
+
(!nativeCommandContract && allowLegacyV3Readback !== true)) &&
|
|
172
|
+
!TERMINAL_STATES.has(status)
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
161
176
|
function normalizeCandidate(input, expected) {
|
|
162
177
|
const identity = createDevDeliveryCandidateIdentity(
|
|
163
178
|
input,
|
|
@@ -246,9 +261,7 @@ function normalizeCandidate(input, expected) {
|
|
|
246
261
|
"candidate shardEvidenceRoots",
|
|
247
262
|
);
|
|
248
263
|
}
|
|
249
|
-
|
|
250
|
-
const native = candidate.deliveryClass !== "non-native-fast" || env || cmd;
|
|
251
|
-
if (native && (!env || !cmd) && !TERMINAL_STATES.has(status))
|
|
264
|
+
if (lacksLiveNativeProof(candidate, status, expected.allowLegacyV3Readback))
|
|
252
265
|
throw new Error("live native candidate requires exact native proof");
|
|
253
266
|
if (Object.hasOwn(input, "releaseBlockerPriority"))
|
|
254
267
|
candidate.releaseBlockerPriority = normalizeReleaseBlockerPriorityClaim(
|
|
@@ -318,13 +331,21 @@ export function normalizeDevDeliveryQueue(input, expected = {}) {
|
|
|
318
331
|
"queue fencingCounter",
|
|
319
332
|
);
|
|
320
333
|
queue.policy = normalizePolicy(queue.policy);
|
|
334
|
+
const allowLegacyV3Readback =
|
|
335
|
+
expected.allowLegacyV3Readback === true &&
|
|
336
|
+
!(queue.candidates || []).some(
|
|
337
|
+
(candidate) => candidate?.nativeCommandContract,
|
|
338
|
+
) &&
|
|
339
|
+
!queue.activeWarrant?.nativeCommandContract &&
|
|
340
|
+
!queue.activeWarrant?.nativeExecutionReceiptRoot &&
|
|
341
|
+
!queue.activeWarrant?.qualificationReceiptRoot;
|
|
321
342
|
queue.candidates = (queue.candidates || []).map((candidate) =>
|
|
322
|
-
normalizeCandidate(candidate, queue),
|
|
343
|
+
normalizeCandidate(candidate, { ...queue, allowLegacyV3Readback }),
|
|
323
344
|
);
|
|
324
345
|
validateDevDeliveryCandidateChain(queue.candidates, TERMINAL_STATES);
|
|
325
346
|
queue.updatedAt = timestamp(queue.updatedAt, "queue updatedAt");
|
|
326
347
|
if (queue.activeWarrant) {
|
|
327
|
-
validateActiveDevDeliveryWarrant(queue);
|
|
348
|
+
validateActiveDevDeliveryWarrant(queue, { allowLegacyV3Readback });
|
|
328
349
|
} else if (
|
|
329
350
|
queue.candidates.some((candidate) =>
|
|
330
351
|
["selected", "proving", "waiting", "blocked", "qualified"].includes(
|
|
@@ -544,9 +565,11 @@ function effectivePriority(candidate, policy, now) {
|
|
|
544
565
|
}
|
|
545
566
|
export function rankDevDeliveryCandidates(
|
|
546
567
|
queueInput,
|
|
547
|
-
{ now = new Date().toISOString() } = {},
|
|
568
|
+
{ now = new Date().toISOString(), allowLegacyV3Readback = false } = {},
|
|
548
569
|
) {
|
|
549
|
-
const queue = normalizeDevDeliveryQueue(queueInput
|
|
570
|
+
const queue = normalizeDevDeliveryQueue(queueInput, {
|
|
571
|
+
allowLegacyV3Readback,
|
|
572
|
+
});
|
|
550
573
|
const currentTime = timestamp(now, "now");
|
|
551
574
|
return queue.candidates
|
|
552
575
|
.filter((candidate) => candidate.status === "queued")
|
|
@@ -516,14 +516,19 @@ export const settleDevDeliveryTerminalEvent = createDevDeliveryTerminalSettler({
|
|
|
516
516
|
});
|
|
517
517
|
export function observeDevDeliveryQueue(
|
|
518
518
|
queueInput,
|
|
519
|
-
{ now = new Date().toISOString() } = {},
|
|
519
|
+
{ now = new Date().toISOString(), allowLegacyV3Readback = false } = {},
|
|
520
520
|
) {
|
|
521
|
-
const queue = normalizeDevDeliveryQueue(queueInput
|
|
521
|
+
const queue = normalizeDevDeliveryQueue(queueInput, {
|
|
522
|
+
allowLegacyV3Readback,
|
|
523
|
+
});
|
|
522
524
|
const currentTime = timestamp(now, "now");
|
|
523
525
|
const states = {};
|
|
524
526
|
for (const candidate of queue.candidates)
|
|
525
527
|
states[candidate.status] = (states[candidate.status] || 0) + 1;
|
|
526
|
-
const queued = rankDevDeliveryCandidates(queue, {
|
|
528
|
+
const queued = rankDevDeliveryCandidates(queue, {
|
|
529
|
+
now: currentTime,
|
|
530
|
+
allowLegacyV3Readback,
|
|
531
|
+
});
|
|
527
532
|
return {
|
|
528
533
|
schema: "kungfu.buildchain.dev-delivery-queue-observation/v1",
|
|
529
534
|
repository: queue.repository,
|
|
@@ -116,6 +116,7 @@ const PROTECTED_AUTHORITY_PATHS = Object.freeze([
|
|
|
116
116
|
".github/CODEOWNERS",
|
|
117
117
|
".github/workflows/.publication-authority.yml",
|
|
118
118
|
".github/workflows/.release-candidate-promote.yml",
|
|
119
|
+
".github/workflows/buildchain-ref-promotion-recovery.yml",
|
|
119
120
|
".github/workflows/buildchain-ref-promotion.yml",
|
|
120
121
|
".github/workflows/github-governance-audit.yml",
|
|
121
122
|
".github/workflows/paper-release-sealed.yml",
|
package/packages/core/index.js
CHANGED
|
@@ -139,6 +139,11 @@ export {
|
|
|
139
139
|
normalizeCandidateTimelineEvent,
|
|
140
140
|
} from "./candidate-timeline.js";
|
|
141
141
|
|
|
142
|
+
export {
|
|
143
|
+
CI_LANE_CHANGE_BUDGET_CONTRACT,
|
|
144
|
+
evaluateCiLaneChangeBudget,
|
|
145
|
+
} from "./ci-lane-change-budget.js";
|
|
146
|
+
|
|
142
147
|
export {
|
|
143
148
|
CHANNEL_CANDIDATE_DECISION_SCHEMA,
|
|
144
149
|
channelCandidateSourceLockRef,
|