@kungfu-tech/buildchain 4.1.3-alpha.9 → 4.1.4-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 +11 -13
- package/CONTRIBUTING.md +32 -9
- package/README.md +56 -140
- package/actions/release/promotion/ref/README.md +1 -1
- package/architecture/action-taxonomy.json +1 -1
- package/architecture/agent-change-map.md +32 -45
- package/architecture/build-orchestration.json +1 -1
- package/architecture/capability-state-machine-manifest.json +5 -5
- package/architecture/ci-lane-change-budget.json +92 -92
- package/architecture/code-layout.json +2 -12
- package/architecture/core-mechanisms.json +38 -39
- package/architecture/cross-platform-adopter-qualification.json +1 -1
- package/architecture/dev-delivery-orchestration.json +2 -2
- package/architecture/floating-consumer-policy.json +3 -3
- package/architecture/internal-capabilities.json +27 -28
- package/architecture/maintainability-debt.json +60 -94
- package/architecture/maintainability-policy.json +7 -13
- package/architecture/minimal-consumer-migration.json +43 -5014
- package/architecture/platform-stage-checkpoints.json +1 -1
- package/architecture/release-tail-contract.json +2 -2
- package/architecture/release-topology.json +33 -25
- package/architecture/stage-capsule-qualification.json +1 -1
- package/architecture/universal-workflow-bootstrap.json +60 -60
- package/architecture/universal-workflow-capability-policy.json +3 -3
- package/architecture/universal-workflow-fault-campaign.json +7 -7
- package/architecture/workflow-taxonomy.json +59 -60
- package/contracts/fixtures/v4-tail-reseal-v1/valid.json +1 -1
- package/dist/site/buildchain-contract.json +138 -66
- package/dist/site/buildchain-site.json +257 -331
- package/dist/site/capability-registry.json +4 -4
- package/dist/site/cli-registry.json +6 -142
- package/dist/site/controller-registry.json +19 -19
- package/dist/site/kfd-claims.json +481 -529
- package/dist/site/kfd-upstream-aggregate.json +1 -1
- package/dist/site/manual-registry.json +22 -22
- package/dist/site/node-api-registry.json +82 -339
- package/dist/site/page-registry.json +229 -304
- package/dist/site/public-surface-audit.json +544 -754
- package/dist/site/publication-authority-registry.json +316 -316
- package/dist/site/publication-registry.json +1 -1
- package/dist/site/site-manifest.json +23 -23
- package/dist/site/workflow-registry.json +1071 -1027
- package/docs/MAP.md +28 -20
- package/docs/auditable-demo.md +17 -49
- package/docs/bootstrap-recovery.md +46 -37
- package/docs/cli-reference.md +2 -46
- package/docs/cli.md +97 -186
- package/docs/code-organization.md +7 -5
- package/docs/dev-alpha-candidate-patrol.md +19 -42
- package/docs/dev-delivery-orchestration.md +15 -11
- package/docs/dev-delivery-qualification-landing-adr.md +10 -9
- package/docs/dev-delivery-warrant.md +17 -16
- package/docs/dev-qualification-patrol.md +25 -20
- package/docs/getting-started.md +80 -139
- package/docs/github-artifact-attestation.md +31 -81
- package/docs/install.md +66 -30
- package/docs/lifecycle-protocol.md +19 -57
- package/docs/migration-inventory.md +17 -45
- package/docs/next-development-transition.md +13 -13
- package/docs/node-api-reference.md +122 -138
- package/docs/oci-publication.md +13 -10
- package/docs/publication-artifacts.md +128 -486
- package/docs/publication-authority.md +15 -45
- package/docs/publish-transaction.md +13 -11
- package/docs/release-candidate.md +126 -355
- package/docs/release-discussions.md +36 -67
- package/docs/release-flow.md +80 -339
- package/docs/release-governance.md +114 -962
- package/docs/release-promotion-request.md +45 -43
- package/docs/release-propagation.md +13 -27
- package/docs/release-tail-provider-plane.md +38 -65
- package/docs/reusable-build-surface.md +78 -196
- package/docs/runtime-train-validation.md +8 -6
- package/docs/stable-candidate-patrol.md +13 -66
- package/docs/v4-adopter-delivery.md +15 -15
- package/docs/v4-declarative-release-tail-migration.md +19 -17
- package/docs/v4-production-release.md +11 -6
- package/docs/v4-publication-rehearsal.md +12 -27
- package/docs/v4-stage-capsule.md +14 -20
- package/docs/v4-tail-reseal.md +34 -20
- package/docs/web-surface-deployments.md +26 -264
- package/docs/workflow-catalog.md +31 -31
- package/docs/workflow-path-migration.md +10 -4
- package/package.json +5 -4
- package/packages/core/adoption/buildchain-kfd-claims.js +7 -7
- package/packages/core/adoption/cli/output.mjs +1 -9
- package/packages/core/adoption/cli/product-gate.mjs +1 -15
- package/packages/core/adoption/cli/project.mjs +9 -10
- package/packages/core/adoption/cli/standards.mjs +1 -14
- package/packages/core/adoption/cli/support.mjs +0 -2
- package/packages/core/adoption/cli/surface-register.mjs +0 -2
- package/packages/core/adoption/commands/init-repo.mjs +77 -485
- package/packages/core/adoption/consumer-init.js +279 -0
- package/packages/core/adoption/qualification/admission.js +1 -1
- package/packages/core/build/cli/cache.mjs +0 -2
- package/packages/core/build/cli/facts.mjs +0 -3
- package/packages/core/build/cli/homebrew.mjs +0 -4
- package/packages/core/build/cli/lifecycle.mjs +0 -3
- package/packages/core/build/github-artifact-attestation.js +2 -2
- package/packages/core/build/platform-stage-checkpoints.js +1 -1
- package/packages/core/build/signing/dispatch.js +1 -1
- package/packages/core/consumer/buildchain-config.js +9 -0
- package/packages/core/consumer/contract/inspection.js +351 -9
- package/packages/core/consumer/contract/javascript-syntax.js +439 -0
- package/packages/core/consumer/contract/javascript-values.js +61 -0
- package/packages/core/consumer/contract/javascript.js +555 -0
- package/packages/core/consumer/contract/local-validation.js +84 -0
- package/packages/core/contracts/buildchain-contract.js +39 -8
- package/packages/core/contracts/cli/introspection.mjs +1 -9
- package/packages/core/contracts/public-surface-cli.js +0 -1
- package/packages/core/dev-delivery/dev-delivery-contract-surface.js +2 -2
- package/packages/core/governance/buildchain-publication-authority.js +24 -24
- package/packages/core/governance/cli/doctor.mjs +58 -42
- package/packages/core/governance/commands/architecture.mjs +6 -1
- package/packages/core/governance/commands/audit-publication-control-plane.mjs +1 -1
- package/packages/core/governance/commands/workflow-friction-report.mjs +1 -1
- package/packages/core/governance/github-governance-authority.js +2 -2
- package/packages/core/governance/publication/collection.js +1 -1
- package/packages/core/index.js +1 -3
- package/packages/core/observability/cli/candidate.mjs +0 -2
- package/packages/core/observability/cli/context.mjs +0 -5
- package/packages/core/observability/cli/diagnostics.mjs +0 -7
- package/packages/core/observability/cli/events.mjs +2 -10
- package/packages/core/paper/commands/paper-work-fleet-cli.mjs +1 -1
- package/packages/core/paper/commands/paper.mjs +33 -422
- package/packages/core/paper/consumer-status.js +72 -0
- package/packages/core/paper/operations/identity.js +0 -3
- package/packages/core/paper/operations/migration.js +460 -0
- package/packages/core/paper/operations/preflight-checks.js +8 -68
- package/packages/core/paper/operations/scaffold.js +16 -326
- package/packages/core/paper/operations/status.js +27 -53
- package/packages/core/paper/paper-agent-entry.js +36 -147
- package/packages/core/paper/paper-fleet.js +24 -39
- package/packages/core/paper/paper-repository.js +16 -0
- package/packages/core/paper/paper-runtime-channels.js +1 -1
- package/packages/core/paper/paper-scaffold-content.js +153 -162
- package/packages/core/paper/paper-work.js +3 -10
- package/packages/core/paper/paper.js +43 -5
- package/packages/core/providers/github/artifact-attestation.js +1 -1
- package/packages/core/providers/github/pipeline-context-artifacts.js +172 -0
- package/packages/core/providers/github/pipeline-release-evidence.js +17 -98
- package/packages/core/providers/github/pipeline-stable-baseline.js +86 -0
- package/packages/core/providers/github/pipeline-stable-source.js +22 -4
- package/packages/core/providers/github/release-evidence-assets.js +97 -0
- package/packages/core/publication/authority/control-plane.js +2 -2
- package/packages/core/publication/authority/seal.js +1 -1
- package/packages/core/publication/cli/dispatch.mjs +1 -12
- package/packages/core/publication/pipeline/actions.js +16 -9
- package/packages/core/publication/pipeline/apply.js +17 -9
- package/packages/core/publication/pipeline/context.js +29 -0
- package/packages/core/publication/pipeline/journal.js +13 -1
- package/packages/core/publication/pipeline/prepare.js +15 -6
- package/packages/core/publication/pipeline/recovery-import.js +1 -1
- package/packages/core/publication/pipeline/recovery-materials.js +63 -1
- package/packages/core/publication/pipeline/recovery-prepare.js +21 -9
- package/packages/core/publication/pipeline/stable-entry.js +12 -3
- package/packages/core/publication/pipeline/stable-products.js +21 -19
- package/packages/core/publication/pipeline/version-actions.js +15 -6
- package/packages/core/publication/publication-rehearsal-projection.js +0 -9
- package/packages/core/release/cli/dispatch.mjs +1 -4
- package/packages/core/release/cli/inspection-handlers.mjs +1 -33
- package/packages/core/release/cli/release-handlers.mjs +2 -19
- package/packages/core/release/cli/verification-handlers.mjs +4 -25
- package/packages/core/release/next-development-projection.js +13 -13
- package/packages/core/release/passport/locations.js +13 -8
- package/packages/core/release/release-passport.js +70 -5
- package/packages/core/web/cli/badges.mjs +0 -4
- package/packages/core/web/publication-admission.js +1 -1
- package/packages/core/web/publication-capability.js +1 -1
- package/packages/core/web/readme-badges.js +1 -1
- package/packages/core/workflow/cli/main.mjs +1 -4
- package/packages/core/workflow/cli/process.mjs +1 -1
- package/packages/core/workflow/commands/buildchain-cli-help.mjs +2 -8
- package/packages/core/workflow/engine/conformance.js +1 -1
- package/packages/core/workflow/pipeline/build.js +21 -1
- package/packages/core/workflow/pipeline/delivery-observation.js +6 -2
- package/packages/core/workflow/workflow-taxonomy.mjs +61 -17
- package/scripts/check-code-layout.mjs +2 -0
- package/scripts/check-core-mechanism-inventory.mjs +29 -13
- package/scripts/check-floating-consumer-policy-contract.mjs +3 -3
- package/scripts/check-inventory.mjs +27 -27
- package/scripts/check-maintainability.mjs +28 -5
- package/scripts/check-public-dogfood-contract.mjs +3 -3
- package/scripts/check-release-topology.mjs +1 -1
- package/scripts/check-self-consumer-contract.mjs +7 -7
- package/scripts/check-universal-workflow-bootstrap.mjs +1 -1
- package/scripts/generate-channel-promotion-workflow.mjs +1 -1
- package/scripts/generate-minimal-consumer-contract.mjs +21 -1
- package/scripts/generate-site-bundle.mjs +2 -1
- package/scripts/generate-tail-reseal-fixture.mjs +3 -3
- package/scripts/inventory/promotion.mjs +1 -1
- package/scripts/next-development-self-dogfood-harness.mjs +1 -1
- package/scripts/next-development-self-dogfood.mjs +4 -4
- package/scripts/site-capability-metadata.mjs +2 -6
- package/scripts/source-metric-lineage.mjs +62 -7
- package/scripts/verify-golden-path.mjs +31 -35
- package/templates/native-dev-delivery.yml +1 -1
- package/templates/universal-buildchain-bootstrap.yml +1 -1
- package/packages/core/paper/operations/bootstrap.js +0 -75
- package/packages/core/paper/operations/plans.js +0 -213
- package/packages/core/paper/operations/provisioning.js +0 -113
- package/packages/core/paper/operations/scaffold-config.js +0 -77
- package/packages/core/paper/operations/scaffold-workflows.js +0 -116
- package/packages/core/paper/operations/workspace.js +0 -60
- package/packages/core/paper/paper-npm-bootstrap.js +0 -492
|
@@ -2,407 +2,28 @@
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { pathToFileURL } from "node:url";
|
|
5
|
-
import { BUILDCHAIN_CONFIG_PATH } from "../../contracts/buildchain-layout.js";
|
|
6
|
-
import { detectPackageManager, assertPackageManager } from "../../build/package-manager.js";
|
|
7
5
|
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} from "../../
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return assertPackageManager(requested);
|
|
29
|
-
}
|
|
30
|
-
try {
|
|
31
|
-
return detectPackageManager(cwd).name;
|
|
32
|
-
} catch {
|
|
33
|
-
return "pnpm";
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function packageLifecycle(manager) {
|
|
38
|
-
if (manager === "npm") {
|
|
39
|
-
return {
|
|
40
|
-
install: "npm ci",
|
|
41
|
-
build: "npm run build",
|
|
42
|
-
verify: "npm run check",
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (manager === "yarn") {
|
|
46
|
-
return {
|
|
47
|
-
install: "corepack yarn install --immutable",
|
|
48
|
-
build: "corepack yarn run build",
|
|
49
|
-
verify: "corepack yarn run check",
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
install: "corepack pnpm install --frozen-lockfile",
|
|
54
|
-
build: "corepack pnpm run build",
|
|
55
|
-
verify: "corepack pnpm run check",
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function packageToml(cwd, manager) {
|
|
60
|
-
const lifecycle = packageLifecycle(manager);
|
|
61
|
-
const hasPackageJson = fs.existsSync(path.join(cwd, "package.json"));
|
|
62
|
-
const versionFiles = hasPackageJson
|
|
63
|
-
? `
|
|
64
|
-
[[version.files]]
|
|
65
|
-
type = "json"
|
|
66
|
-
path = "package.json"
|
|
67
|
-
key = "version"
|
|
68
|
-
`
|
|
69
|
-
: "";
|
|
70
|
-
return `schema = 1
|
|
71
|
-
|
|
72
|
-
[project]
|
|
73
|
-
type = "package"
|
|
74
|
-
name = "${repoName(cwd)}"
|
|
75
|
-
|
|
76
|
-
[version]
|
|
77
|
-
required = ${hasPackageJson ? "true" : "false"}
|
|
78
|
-
strategy = "semver"
|
|
79
|
-
next = "auto"
|
|
80
|
-
${versionFiles}
|
|
81
|
-
[lifecycle.install]
|
|
82
|
-
command = "${lifecycle.install}"
|
|
83
|
-
|
|
84
|
-
[lifecycle.build]
|
|
85
|
-
command = "${lifecycle.build}"
|
|
86
|
-
|
|
87
|
-
[lifecycle.verify]
|
|
88
|
-
command = "${lifecycle.verify}"
|
|
89
|
-
`;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function nativeToml(cwd) {
|
|
93
|
-
return `schema = 1
|
|
94
|
-
|
|
95
|
-
[project]
|
|
96
|
-
type = "package"
|
|
97
|
-
name = "${repoName(cwd)}"
|
|
98
|
-
|
|
99
|
-
[version]
|
|
100
|
-
required = false
|
|
101
|
-
strategy = "semver"
|
|
102
|
-
next = "auto"
|
|
103
|
-
|
|
104
|
-
[[version.files]]
|
|
105
|
-
type = "regex"
|
|
106
|
-
path = "CMakeLists.txt"
|
|
107
|
-
pattern = 'project\\([^)]* VERSION (?<version>[^ )]+)'
|
|
108
|
-
replacement = '\${version}'
|
|
109
|
-
|
|
110
|
-
[lifecycle.configure]
|
|
111
|
-
commands = [
|
|
112
|
-
"cmake -S . -B build -DCMAKE_BUILD_TYPE=Release",
|
|
113
|
-
]
|
|
114
|
-
|
|
115
|
-
[lifecycle.build]
|
|
116
|
-
commands = [
|
|
117
|
-
"cmake --build build --config Release",
|
|
118
|
-
]
|
|
119
|
-
|
|
120
|
-
[lifecycle.verify]
|
|
121
|
-
commands = [
|
|
122
|
-
"ctest --test-dir build --output-on-failure",
|
|
123
|
-
]
|
|
124
|
-
|
|
125
|
-
[diagnostics.native]
|
|
126
|
-
enabled = true
|
|
127
|
-
sample_process_tree = false
|
|
128
|
-
compiler_cache = "auto"
|
|
129
|
-
expected_tools = ["ccache", "sccache", "clang", "cl", "cmake", "ninja"]
|
|
130
|
-
artifact_dirs = ["build", "dist"]
|
|
131
|
-
`;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function anchoredPackageToml(cwd, manager) {
|
|
135
|
-
const lifecycle = packageLifecycle(manager);
|
|
136
|
-
return `schema = 1
|
|
137
|
-
|
|
138
|
-
[project]
|
|
139
|
-
type = "package"
|
|
140
|
-
name = "${repoName(cwd)}"
|
|
141
|
-
|
|
142
|
-
[version]
|
|
143
|
-
required = true
|
|
144
|
-
strategy = "anchored"
|
|
145
|
-
next = "manual"
|
|
146
|
-
manifest = "release.json"
|
|
147
|
-
|
|
148
|
-
[[version.files]]
|
|
149
|
-
type = "json"
|
|
150
|
-
path = "package.json"
|
|
151
|
-
key = "version"
|
|
152
|
-
|
|
153
|
-
[lifecycle.install]
|
|
154
|
-
command = "${lifecycle.install}"
|
|
155
|
-
|
|
156
|
-
[lifecycle.build]
|
|
157
|
-
command = "${lifecycle.build}"
|
|
158
|
-
|
|
159
|
-
[lifecycle.verify]
|
|
160
|
-
command = "${lifecycle.verify}"
|
|
161
|
-
`;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
function webSurfaceToml(cwd) {
|
|
165
|
-
const name = repoName(cwd);
|
|
166
|
-
return `schema = 1
|
|
167
|
-
|
|
168
|
-
[project]
|
|
169
|
-
type = "web-surface"
|
|
170
|
-
name = "${name}"
|
|
171
|
-
site = "${name}"
|
|
172
|
-
|
|
173
|
-
[channels.preview]
|
|
174
|
-
url_pattern = "https://{alias}.preview.example.com"
|
|
175
|
-
visibility = "ephemeral"
|
|
176
|
-
requires_auth = false
|
|
177
|
-
noindex = true
|
|
178
|
-
|
|
179
|
-
[channels.staging]
|
|
180
|
-
url = "https://staging.example.com"
|
|
181
|
-
visibility = "protected"
|
|
182
|
-
access_control = "managed-network"
|
|
183
|
-
edge_auth = "none"
|
|
184
|
-
noindex = true
|
|
185
|
-
promotable = true
|
|
186
|
-
|
|
187
|
-
[channels.production]
|
|
188
|
-
url = "https://example.com"
|
|
189
|
-
visibility = "public"
|
|
190
|
-
requires_auth = false
|
|
191
|
-
noindex = false
|
|
192
|
-
canonical = true
|
|
193
|
-
|
|
194
|
-
[deploy.preview]
|
|
195
|
-
adapter = "aws-s3-cloudfront"
|
|
196
|
-
artifact_path = "dist"
|
|
197
|
-
bucket_ref = "AWS_PREVIEW_BUCKET"
|
|
198
|
-
distribution_ref = "AWS_PREVIEW_DISTRIBUTION"
|
|
199
|
-
|
|
200
|
-
[deploy.staging]
|
|
201
|
-
adapter = "aws-s3-cloudfront"
|
|
202
|
-
artifact_path = "dist"
|
|
203
|
-
bucket_ref = "AWS_STAGING_BUCKET"
|
|
204
|
-
distribution_ref = "AWS_STAGING_DISTRIBUTION"
|
|
205
|
-
|
|
206
|
-
[deploy.production]
|
|
207
|
-
adapter = "aws-s3-cloudfront"
|
|
208
|
-
artifact_path = "dist"
|
|
209
|
-
bucket_ref = "AWS_PRODUCTION_BUCKET"
|
|
210
|
-
distribution_ref = "AWS_PRODUCTION_DISTRIBUTION"
|
|
211
|
-
|
|
212
|
-
[security.staging]
|
|
213
|
-
noindex = true
|
|
214
|
-
isolated_providers = true
|
|
215
|
-
|
|
216
|
-
[lifecycle.build]
|
|
217
|
-
command = "corepack pnpm run build"
|
|
218
|
-
|
|
219
|
-
[lifecycle.verify]
|
|
220
|
-
command = "corepack pnpm run check"
|
|
221
|
-
`;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function infraContractToml(cwd) {
|
|
225
|
-
const name = repoName(cwd);
|
|
226
|
-
return `schema = 1
|
|
227
|
-
|
|
228
|
-
[project]
|
|
229
|
-
type = "infra-contract"
|
|
230
|
-
name = "${name}"
|
|
231
|
-
|
|
232
|
-
[infra]
|
|
233
|
-
adapter = "manual-observed"
|
|
234
|
-
adoption_mode = "manual-observed"
|
|
235
|
-
apply = "disabled"
|
|
236
|
-
environment = "staging"
|
|
237
|
-
desired = ["infra/desired.json"]
|
|
238
|
-
contract = ["infra/outputs.json"]
|
|
239
|
-
|
|
240
|
-
[[consumers]]
|
|
241
|
-
repo = "kungfu-systems/site-example"
|
|
242
|
-
path = "infra/outputs.json"
|
|
243
|
-
source = "infra/outputs.json"
|
|
244
|
-
|
|
245
|
-
[lifecycle.verify]
|
|
246
|
-
command = "buildchain infra-contract --mode ci"
|
|
247
|
-
`;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
function publicationArtifactToml(cwd) {
|
|
251
|
-
const name = repoName(cwd);
|
|
252
|
-
return `schema = 1
|
|
253
|
-
|
|
254
|
-
[project]
|
|
255
|
-
type = "publication-artifact"
|
|
256
|
-
name = "${name}"
|
|
257
|
-
|
|
258
|
-
[publication]
|
|
259
|
-
kind = "paper"
|
|
260
|
-
title = "${name}"
|
|
261
|
-
primary_artifact = "_build/main.pdf"
|
|
262
|
-
artifact_paths = ["_build/main.pdf"]
|
|
263
|
-
metadata_paths = ["README.md", "docs/MAP.md"]
|
|
264
|
-
source_paths = ["paper", "README.md", "LICENSE", "Makefile"]
|
|
265
|
-
site_consumers = ["papers-site"]
|
|
266
|
-
manifest_path = ".buildchain/publication/publication-artifact.json"
|
|
267
|
-
source_bundle_path = ".buildchain/publication/source.tar.gz"
|
|
268
|
-
|
|
269
|
-
[publication.toolchain]
|
|
270
|
-
type = "latex-docker"
|
|
271
|
-
image = "${DEFAULT_PUBLICATION_LATEX_IMAGE}"
|
|
272
|
-
digest = "${DEFAULT_PUBLICATION_LATEX_DIGEST}"
|
|
273
|
-
command = "${DEFAULT_PUBLICATION_LATEX_COMMAND}"
|
|
274
|
-
|
|
275
|
-
[lifecycle.build]
|
|
276
|
-
command = "make pdf"
|
|
277
|
-
|
|
278
|
-
[lifecycle.verify]
|
|
279
|
-
command = "make check"
|
|
280
|
-
`;
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
function infraContractDesiredJson(cwd) {
|
|
284
|
-
return `${JSON.stringify({
|
|
285
|
-
service: repoName(cwd),
|
|
286
|
-
environment: "staging",
|
|
287
|
-
resources: [
|
|
288
|
-
{
|
|
289
|
-
kind: "static-site",
|
|
290
|
-
name: repoName(cwd),
|
|
291
|
-
desiredState: {
|
|
292
|
-
hostname: "staging.example.com",
|
|
293
|
-
accessControl: "managed-network",
|
|
294
|
-
owner: "platform",
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
],
|
|
298
|
-
}, null, 2)}\n`;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function infraContractOutputsJson(cwd) {
|
|
302
|
-
return `${JSON.stringify({
|
|
303
|
-
service: repoName(cwd),
|
|
304
|
-
environment: "staging",
|
|
305
|
-
observedMode: "manual-observed",
|
|
306
|
-
outputs: {
|
|
307
|
-
hostname: "staging.example.com",
|
|
308
|
-
distributionId: "observed-distribution-id",
|
|
309
|
-
bucket: "observed-bucket-name",
|
|
310
|
-
},
|
|
311
|
-
}, null, 2)}\n`;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
function workflowArtifactPaths(type) {
|
|
315
|
-
if (type === "infra-contract") {
|
|
316
|
-
return `.buildchain/infra-contract-validate.json
|
|
317
|
-
.buildchain/infra-contract-plan.json
|
|
318
|
-
.buildchain/buildchain.infra-contract.json
|
|
319
|
-
.buildchain/infra-contract-propagation.json
|
|
320
|
-
.buildchain/infra-contract-propagation-apply.json
|
|
321
|
-
.buildchain/infra-contract-evidence-bundle.json
|
|
322
|
-
.buildchain/infra-contract-evidence-verification.json`;
|
|
323
|
-
}
|
|
324
|
-
if (type === "publication-artifact") {
|
|
325
|
-
return `_build/main.pdf
|
|
326
|
-
.buildchain/publication/publication-artifact.json
|
|
327
|
-
.buildchain/publication/publication-artifact-passport.json
|
|
328
|
-
.buildchain/publication/source.tar.gz`;
|
|
329
|
-
}
|
|
330
|
-
return `dist
|
|
331
|
-
build/stage`;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
function publicationWorkflowYaml() {
|
|
335
|
-
return `${nextDevelopmentWorkflowHeader()}# Commit both .buildchain/contract-lock.json and .buildchain/alpha-contract-lock.json.
|
|
336
|
-
# Persist only @v4 or @v4-alpha; pass temporary train/SHA runtimes through workflow_dispatch.
|
|
337
|
-
name: Build
|
|
338
|
-
|
|
339
|
-
on:
|
|
340
|
-
workflow_dispatch:
|
|
341
|
-
inputs:
|
|
342
|
-
runtime-ref:
|
|
343
|
-
description: "Temporary Buildchain runtime ref for trusted manual validation"
|
|
344
|
-
required: false
|
|
345
|
-
default: ""
|
|
346
|
-
pull_request:
|
|
347
|
-
push:
|
|
348
|
-
branches:
|
|
349
|
-
- "dev/**"
|
|
350
|
-
- "alpha/**"
|
|
351
|
-
- "release/**"
|
|
352
|
-
|
|
353
|
-
permissions:
|
|
354
|
-
contents: read
|
|
355
|
-
issues: write
|
|
356
|
-
|
|
357
|
-
jobs:
|
|
358
|
-
publication:
|
|
359
|
-
uses: kungfu-systems/buildchain/.github/workflows/public-build-publication.yml@v4
|
|
360
|
-
with:
|
|
361
|
-
runtime-ref: \${{ inputs.runtime-ref || '' }}
|
|
362
|
-
toolchain-type: config
|
|
363
|
-
verify-command: make check
|
|
364
|
-
artifact-name: publication-artifact
|
|
365
|
-
`;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
function workflowYaml() {
|
|
369
|
-
return `${nextDevelopmentWorkflowHeader()}# Project build settings live only in .buildchain/buildchain.toml.
|
|
370
|
-
# Commit .buildchain/contract-lock.json and .buildchain/alpha-contract-lock.json.
|
|
371
|
-
# The called ref selects the runtime; architecture/platform-stage-checkpoints.json owns checkpoint projections.
|
|
372
|
-
name: Build
|
|
373
|
-
|
|
374
|
-
on:
|
|
375
|
-
workflow_dispatch:
|
|
376
|
-
pull_request:
|
|
377
|
-
push:
|
|
378
|
-
branches: ["dev/**", "alpha/**", "release/**"]
|
|
379
|
-
|
|
380
|
-
permissions:
|
|
381
|
-
actions: read
|
|
382
|
-
contents: read
|
|
383
|
-
issues: write
|
|
384
|
-
id-token: write
|
|
385
|
-
|
|
386
|
-
jobs:
|
|
387
|
-
build:
|
|
388
|
-
uses: ${BUILDCHAIN_WORKFLOW_REF}
|
|
389
|
-
`;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function writeIfAllowed(filePath, content, { force }) {
|
|
393
|
-
if (fs.existsSync(filePath) && !force) {
|
|
394
|
-
throw new Error(`${posixPath(filePath)} already exists; pass --force to overwrite`);
|
|
6
|
+
consumerAgentInstructions,
|
|
7
|
+
planConsumerInitialization,
|
|
8
|
+
} from "../consumer-init.js";
|
|
9
|
+
import { PIPELINE_ENTRY } from "../../consumer/contract/entries.js";
|
|
10
|
+
|
|
11
|
+
function assertWritable(cwd, relative, force) {
|
|
12
|
+
const parts = relative.split("/");
|
|
13
|
+
for (let index = 1; index <= parts.length; index++) {
|
|
14
|
+
const name = path.join(cwd, ...parts.slice(0, index));
|
|
15
|
+
const stat = fs.lstatSync(name, { throwIfNoEntry: false });
|
|
16
|
+
if (!stat) continue;
|
|
17
|
+
if (
|
|
18
|
+
stat.isSymbolicLink() ||
|
|
19
|
+
(index < parts.length ? !stat.isDirectory() : !stat.isFile())
|
|
20
|
+
)
|
|
21
|
+
throw new Error(
|
|
22
|
+
`${relative}: initialization requires regular files and directories`,
|
|
23
|
+
);
|
|
24
|
+
if (index === parts.length && !force)
|
|
25
|
+
throw new Error(`${relative} already exists; pass --force to overwrite`);
|
|
395
26
|
}
|
|
396
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
397
|
-
fs.writeFileSync(filePath, content);
|
|
398
|
-
return filePath;
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
function writeManagedAgentEntry(filePath, current) {
|
|
402
|
-
const content = mergeNextDevelopmentAgentInstructions(current);
|
|
403
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true });
|
|
404
|
-
fs.writeFileSync(filePath, content);
|
|
405
|
-
return filePath;
|
|
406
27
|
}
|
|
407
28
|
|
|
408
29
|
export function initBuildchainRepo({
|
|
@@ -413,104 +34,75 @@ export function initBuildchainRepo({
|
|
|
413
34
|
runnerPreset = "github-hosted",
|
|
414
35
|
artifactName = "",
|
|
415
36
|
} = {}) {
|
|
416
|
-
const resolvedCwd =
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
return packageToml(resolvedCwd, manager);
|
|
421
|
-
}
|
|
422
|
-
if (type === "native") {
|
|
423
|
-
return nativeToml(resolvedCwd);
|
|
424
|
-
}
|
|
425
|
-
if (type === "web-surface") {
|
|
426
|
-
return webSurfaceToml(resolvedCwd);
|
|
427
|
-
}
|
|
428
|
-
if (type === "infra-contract") {
|
|
429
|
-
return infraContractToml(resolvedCwd);
|
|
430
|
-
}
|
|
431
|
-
if (type === "publication-artifact") {
|
|
432
|
-
return publicationArtifactToml(resolvedCwd);
|
|
433
|
-
}
|
|
434
|
-
if (type === "anchored-package") {
|
|
435
|
-
return anchoredPackageToml(resolvedCwd, manager);
|
|
436
|
-
}
|
|
437
|
-
throw new Error("init --type must be one of package, native, web-surface, infra-contract, publication-artifact, or anchored-package");
|
|
438
|
-
})());
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
if (type !== "publication-artifact") {
|
|
442
|
-
const paths = workflowArtifactPaths(type).split("\n").map((entry) => entry.trim());
|
|
443
|
-
toml += `
|
|
444
|
-
[build]
|
|
445
|
-
environment = ${JSON.stringify(runnerPreset)}
|
|
446
|
-
|
|
447
|
-
[build.artifacts]
|
|
448
|
-
name = ${JSON.stringify(artifactName || repoName(resolvedCwd))}
|
|
449
|
-
paths = ${JSON.stringify(paths)}
|
|
450
|
-
`;
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
const agentsPath = path.join(resolvedCwd, "AGENTS.md");
|
|
454
|
-
const currentAgents = fs.existsSync(agentsPath)
|
|
455
|
-
? fs.readFileSync(agentsPath, "utf8")
|
|
456
|
-
: "";
|
|
457
|
-
|
|
458
|
-
const written = [
|
|
459
|
-
writeIfAllowed(path.join(resolvedCwd, BUILDCHAIN_CONFIG_PATH), toml, { force }),
|
|
460
|
-
writeIfAllowed(
|
|
461
|
-
path.join(resolvedCwd, ".github", "workflows", "build.yml"),
|
|
462
|
-
type === "publication-artifact"
|
|
463
|
-
? publicationWorkflowYaml()
|
|
464
|
-
: workflowYaml({
|
|
465
|
-
type,
|
|
466
|
-
runnerPreset,
|
|
467
|
-
artifactName,
|
|
468
|
-
}),
|
|
469
|
-
{ force },
|
|
470
|
-
),
|
|
471
|
-
writeManagedAgentEntry(agentsPath, currentAgents),
|
|
472
|
-
];
|
|
473
|
-
|
|
474
|
-
if (type === "anchored-package" && !fs.existsSync(path.join(resolvedCwd, "release.json"))) {
|
|
475
|
-
written.push(writeIfAllowed(path.join(resolvedCwd, "release.json"), "{\n \"upstream\": \"\",\n \"version\": \"0.0.0\"\n}\n", { force }));
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
if (type === "infra-contract") {
|
|
479
|
-
written.push(
|
|
480
|
-
writeIfAllowed(path.join(resolvedCwd, "infra", "desired.json"), infraContractDesiredJson(resolvedCwd), { force }),
|
|
481
|
-
writeIfAllowed(path.join(resolvedCwd, "infra", "outputs.json"), infraContractOutputsJson(resolvedCwd), { force }),
|
|
37
|
+
const resolvedCwd = fs.realpathSync(cwd);
|
|
38
|
+
if (runnerPreset !== "github-hosted")
|
|
39
|
+
throw new Error(
|
|
40
|
+
"schema-2 init uses platform declarations; runner presets are internal runtime policy",
|
|
482
41
|
);
|
|
42
|
+
const planned = planConsumerInitialization({
|
|
43
|
+
cwd: resolvedCwd,
|
|
44
|
+
type,
|
|
45
|
+
requestedManager: packageManager,
|
|
46
|
+
artifactName,
|
|
47
|
+
});
|
|
48
|
+
// Validate the entire write set first: a later conflict must not leave partial wiring.
|
|
49
|
+
for (const relative of Object.keys(planned.files))
|
|
50
|
+
assertWritable(resolvedCwd, relative, force);
|
|
51
|
+
const workflows = path.join(resolvedCwd, ".github/workflows");
|
|
52
|
+
if (fs.existsSync(workflows))
|
|
53
|
+
for (const file of fs.readdirSync(workflows))
|
|
54
|
+
if (
|
|
55
|
+
/\.ya?ml$/iu.test(file) &&
|
|
56
|
+
!Object.hasOwn(planned.files, `.github/workflows/${file}`)
|
|
57
|
+
)
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Existing workflow ${file} is outside the generated consumer pair; migrate its product commands before initialization`,
|
|
60
|
+
);
|
|
61
|
+
assertWritable(resolvedCwd, "AGENTS.md", true);
|
|
62
|
+
const agents = path.join(resolvedCwd, "AGENTS.md");
|
|
63
|
+
planned.files["AGENTS.md"] = consumerAgentInstructions(
|
|
64
|
+
fs.existsSync(agents) ? fs.readFileSync(agents, "utf8") : "",
|
|
65
|
+
);
|
|
66
|
+
for (const [relative, bytes] of Object.entries(planned.files)) {
|
|
67
|
+
const file = path.join(resolvedCwd, relative);
|
|
68
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
69
|
+
fs.writeFileSync(file, bytes);
|
|
483
70
|
}
|
|
484
|
-
|
|
485
71
|
return {
|
|
486
|
-
schemaVersion:
|
|
72
|
+
schemaVersion: 2,
|
|
487
73
|
type,
|
|
74
|
+
productType: planned.productType,
|
|
488
75
|
cwd: resolvedCwd,
|
|
489
|
-
packageManager: manager,
|
|
490
|
-
workflowRef:
|
|
491
|
-
written:
|
|
76
|
+
packageManager: planned.manager,
|
|
77
|
+
workflowRef: `kungfu-systems/buildchain/${PIPELINE_ENTRY}@v4`,
|
|
78
|
+
written: Object.keys(planned.files),
|
|
492
79
|
};
|
|
493
80
|
}
|
|
494
81
|
|
|
495
82
|
function readArg(name, fallback = "") {
|
|
496
83
|
const index = process.argv.indexOf(`--${name}`);
|
|
497
|
-
|
|
498
|
-
return fallback;
|
|
499
|
-
}
|
|
500
|
-
return process.argv[index + 1] || "";
|
|
84
|
+
return index === -1 ? fallback : process.argv[index + 1] || "";
|
|
501
85
|
}
|
|
502
|
-
|
|
503
|
-
|
|
86
|
+
if (
|
|
87
|
+
!process.env.BUILDCHAIN_EMBEDDED_ENTRYPOINT &&
|
|
88
|
+
process.argv[1] &&
|
|
89
|
+
import.meta.url === pathToFileURL(process.argv[1]).href
|
|
90
|
+
) {
|
|
504
91
|
try {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
92
|
+
console.log(
|
|
93
|
+
JSON.stringify(
|
|
94
|
+
initBuildchainRepo({
|
|
95
|
+
cwd: readArg("cwd", process.cwd()),
|
|
96
|
+
type: readArg("type", "package"),
|
|
97
|
+
force: process.argv.includes("--force"),
|
|
98
|
+
packageManager: readArg("package-manager"),
|
|
99
|
+
runnerPreset: readArg("runner-preset", "github-hosted"),
|
|
100
|
+
artifactName: readArg("artifact-name"),
|
|
101
|
+
}),
|
|
102
|
+
null,
|
|
103
|
+
2,
|
|
104
|
+
),
|
|
105
|
+
);
|
|
514
106
|
} catch (error) {
|
|
515
107
|
console.error(`init-repo: ${error.message}`);
|
|
516
108
|
process.exitCode = 1;
|