ci(release): drill the downloaded promoted archive in the production stage (13-03)

FE-GATE-021..025 rebuilt from source and drilled that build, so the drilled
bytes were not the promoted release. production_gate now downloads the
promoted-release artifact, extracts it against immutable_build's digest and
runs each drill with --release-root; the CI contract rejects a rebuild.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
donghyeon-ka
2026-09-27 14:25:53 +09:00
co-authored by Claude Opus 5.5
parent 15a946fc46
commit fa3de53106
7 changed files with 185 additions and 24 deletions
+9 -1
View File
@@ -368,12 +368,13 @@ jobs:
production_gate:
name: "${{ matrix.gate }} / ${{ matrix.name }}"
needs: promotion
needs: [immutable_build, promotion]
if: ${{ gitea.event_name == 'workflow_dispatch' && (inputs.stage == 'production' || inputs.stage == 'field') }}
runs-on: ubuntu-latest
timeout-minutes: 45
env:
HOSTING_BASE_URL: "${{ vars.HOSTING_BASE_URL }}"
CANDIDATE_ARCHIVE_SHA256: "${{ needs.immutable_build.outputs.archive_sha256 }}"
strategy:
fail-fast: false
matrix:
@@ -395,6 +396,13 @@ jobs:
run: |
corepack enable
corepack pnpm install --frozen-lockfile --ignore-scripts
- name: Download promoted release
uses: https://github.com/ChristopherHX/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7
with:
name: "promoted-release-${{ gitea.run_id }}-${{ gitea.run_attempt }}"
path: .release/promoted
- name: Verify and extract the candidate through one inode-bound operation
run: node scripts/verify-ci-candidate-archive.ts --archive ".release/promoted/release-candidate.tar.gz" --extract-to ".release/promoted-release"
- name: Run blocking gate
run: corepack pnpm ci:gate -- ${{ matrix.gate }}
- name: Upload production gate evidence
+3 -3
View File
@@ -1,11 +1,11 @@
{
"schemaVersion": 1,
"owner": "frontend-platform",
"reason": "12-04: check:request-fanout and check:app-build-input run in FE-GATE-010, check:app-build-input:bundle in FE-GATE-012",
"reason": "13-03: production_gate downloads the promoted archive and FE-GATE-021..025 drill it with --release-root instead of rebuilding",
"gates": 27,
"commands": 98,
"commandReferences": 108,
"commandReferences": 103,
"artifacts": 109,
"stages": 5,
"gateShapeSha256": "6cfdfb5afbf77b6a722e2f9992c1d2d0ee6c5655cb5f1ae490f71d54074db7b4"
"gateShapeSha256": "630e801239de5d175fd1049b2527851dabe06f139ba8ff6a98de7f09f7a257c2"
}
+30 -10
View File
@@ -486,7 +486,9 @@
"script": "drill:runbook",
"args": [
"--",
"FE-RB-005"
"FE-RB-005",
"--release-root",
".release/promoted-release"
],
"expect": "pass"
},
@@ -530,7 +532,9 @@
"script": "drill:runbook",
"args": [
"--",
"FE-RB-001"
"FE-RB-001",
"--release-root",
".release/promoted-release"
],
"expect": "pass"
},
@@ -539,7 +543,9 @@
"script": "drill:runbook",
"args": [
"--",
"FE-RB-002"
"FE-RB-002",
"--release-root",
".release/promoted-release"
],
"expect": "pass"
},
@@ -548,7 +554,9 @@
"script": "drill:runbook",
"args": [
"--",
"FE-RB-003"
"FE-RB-003",
"--release-root",
".release/promoted-release"
],
"expect": "pass"
},
@@ -557,7 +565,9 @@
"script": "drill:runbook",
"args": [
"--",
"FE-RB-004"
"FE-RB-004",
"--release-root",
".release/promoted-release"
],
"expect": "pass"
},
@@ -2097,7 +2107,6 @@
"id": "FE-GATE-021",
"name": "runbook-boot-config",
"commandIds": [
"build",
"drill-runbook-2"
],
"logArtifactId": "artifact-artifacts-quality-gates-FE-GATE-021-txt",
@@ -2110,7 +2119,6 @@
"id": "FE-GATE-022",
"name": "runbook-chunk-mismatch",
"commandIds": [
"build",
"drill-runbook-3"
],
"logArtifactId": "artifact-artifacts-quality-gates-FE-GATE-022-txt",
@@ -2123,7 +2131,6 @@
"id": "FE-GATE-023",
"name": "runbook-api-degradation",
"commandIds": [
"build",
"drill-runbook-4"
],
"logArtifactId": "artifact-artifacts-quality-gates-FE-GATE-023-txt",
@@ -2136,7 +2143,6 @@
"id": "FE-GATE-024",
"name": "runbook-telemetry",
"commandIds": [
"build",
"drill-runbook-5"
],
"logArtifactId": "artifact-artifacts-quality-gates-FE-GATE-024-txt",
@@ -2149,7 +2155,6 @@
"id": "FE-GATE-025",
"name": "runbook-release-rollback",
"commandIds": [
"build",
"drill-runbook"
],
"logArtifactId": "artifact-artifacts-quality-gates-FE-GATE-025-txt",
@@ -2765,6 +2770,7 @@
"displayName": "${{ matrix.gate }} / ${{ matrix.name }}",
"kind": "gate-matrix",
"needs": [
"immutable_build",
"promotion"
],
"condition": "production",
@@ -2782,6 +2788,10 @@
{
"name": "HOSTING_BASE_URL",
"value": "${{ vars.HOSTING_BASE_URL }}"
},
{
"name": "CANDIDATE_ARCHIVE_SHA256",
"value": "${{ needs.immutable_build.outputs.archive_sha256 }}"
}
],
"steps": [
@@ -2794,6 +2804,16 @@
{
"kind": "frozen-install"
},
{
"kind": "download",
"transferId": "promoted-release",
"path": ".release/promoted"
},
{
"kind": "extract",
"archivePath": ".release/promoted/release-candidate.tar.gz",
"targetRoot": ".release/promoted-release"
},
{
"kind": "run-gate"
},
+10 -2
View File
@@ -316,8 +316,16 @@ stored inside the record.
A runbook drill (`drill:runbook`, FE-GATE-021..025) records each verdict as
`PASS`, `FAIL` or `UNVERIFIED` (`scripts/drill-runbook.ts`, record schema in
`scripts/contracts/release-artifacts.ts`). `PASS`/`FAIL` means the drill checked
it against the local `dist/` build; it reads no `public/` placeholder, so a
missing build fails. Browser boot, live API traffic, smoke after a provider
it against a built `dist/`; it reads no `public/` placeholder, so a missing build
fails. In CI the production stage does not rebuild: `production_gate` downloads
the `promoted-release` artifact of the promotion job, extracts its
`release-candidate.tar.gz` to `.release/promoted-release` after checking it
against the `archive_sha256` of `immutable_build`
(`scripts/verify-ci-candidate-archive.ts`), and each drill command passes
`--release-root .release/promoted-release` (`config/ci/gates.json`). The CI
contract rejects a production drill gate that builds or omits the release root
(`scripts/contracts/ci-gates.ts`, 13-03). Run locally without `--release-root`,
a drill checks the local build. Browser boot, live API traffic, smoke after a provider
switch, and anything the runbook marks as needing provider verification are
`UNVERIFIED`. One `FAIL` makes the drill `FAIL` (exit 1). Otherwise any
`UNVERIFIED` makes it `UNVERIFIED` (exit 3), and the gate is not `PASS`. So
+41 -4
View File
@@ -899,7 +899,7 @@ function validateContractSemantics(
vulnerability_provider: ["provider", ["immutable_build"], "always"],
provenance_provider: ["provider", ["immutable_build"], "always"],
promotion: ["promotion", ["immutable_build", "vulnerability_provider", "provenance_provider"], "needs-success"],
production_gate: ["gate-matrix", ["promotion"], "production"],
production_gate: ["gate-matrix", ["immutable_build", "promotion"], "production"],
field_gate: ["gate-single", ["production_gate"], "field"],
documentation_gate: ["gate-single", [], "documentation"],
};
@@ -916,7 +916,7 @@ function validateContractSemantics(
vulnerability_provider: ["checkout", "setup-node", "frozen-install", "download", "run-provider", "validate-provider-evidence", "upload"],
provenance_provider: ["checkout", "setup-node", "frozen-install", "download", "run-provider", "validate-provider-evidence", "upload"],
promotion: ["checkout", "setup-node", "frozen-install", "download", "download", "download", "verify-promotion", "upload", "cleanup-promotion"],
production_gate: ["checkout", "setup-node", "frozen-install", "run-gate", "upload"],
production_gate: ["checkout", "setup-node", "frozen-install", "download", "extract", "run-gate", "upload"],
field_gate: ["checkout", "setup-node", "frozen-install", "run-gate", "upload"],
documentation_gate: ["checkout", "setup-node", "frozen-install", "run-gate", "upload"],
};
@@ -976,7 +976,12 @@ function validateContractSemantics(
],
// 13-05: FE-GATE-019 probes the promoted release after the provider has
// deployed it, so the live base URL belongs to the production stage.
production_gate: [{ name: "HOSTING_BASE_URL", value: "${{ vars.HOSTING_BASE_URL }}" }],
// 13-03: the drills extract the promoted archive and check it against the
// digest immutable_build recorded.
production_gate: [
{ name: "HOSTING_BASE_URL", value: "${{ vars.HOSTING_BASE_URL }}" },
{ name: "CANDIDATE_ARCHIVE_SHA256", value: "${{ needs.immutable_build.outputs.archive_sha256 }}" },
],
field_gate: [
{ name: "FIELD_WEB_VITALS_INPUT", value: "${{ vars.FIELD_WEB_VITALS_INPUT }}" },
{ name: "MIN_ELIGIBLE_SAMPLES", value: "${{ vars.MIN_ELIGIBLE_SAMPLES }}" },
@@ -1171,6 +1176,38 @@ function validateCanonicalStepFields(
) {
issue("promotion download fields and finalizer/cleanup step identities must remain linked");
}
// 13-03: the production stage drills the promoted archive it downloads. It
// used to rebuild from source, so the drilled bytes were not the release.
const production = contract.jobs.find(({ id }) => id === "production_gate");
const promotedDownload = production?.steps.find(
(step) => step.kind === "download" && step.transferId === "promoted-release",
);
const promotedExtract = production?.steps.find(({ kind }) => kind === "extract");
if (
!production ||
promotedDownload?.kind !== "download" ||
promotedExtract?.kind !== "extract" ||
promotedExtract.archivePath !== `${promotedDownload.path}/release-candidate.tar.gz`
) {
issue("production_gate must download the promoted release and extract its release-candidate.tar.gz");
} else {
for (const gateId of production.gateIds) {
const commands = (contract.gates.find(({ id }) => id === gateId)?.commandIds ?? [])
.map((commandId) => contract.commands.find(({ id }) => id === commandId));
if (!commands.some((command) => command?.script === "drill:runbook")) continue;
if (commands.some((command) => command?.script !== "drill:runbook")) {
issue(`production drill gate must drill the promoted archive only, without rebuilding: ${gateId}`);
}
for (const command of commands) {
const args = command?.args ?? [];
const releaseRoot = args.indexOf("--release-root");
if (releaseRoot < 0 || args[releaseRoot + 1] !== promotedExtract.targetRoot) {
issue(`production drill must pass --release-root ${promotedExtract.targetRoot} (the promoted archive): ${command?.id ?? gateId}`);
}
}
}
}
}
function validateJobStepKinds(
@@ -1178,7 +1215,7 @@ function validateJobStepKinds(
issue: (message: string, path?: PropertyKey[]) => void,
): void {
const allowed: Readonly<Record<z.infer<typeof jobSchema>["kind"], ReadonlySet<string>>> = {
"gate-matrix": new Set(["checkout", "setup-node", "frozen-install", "browser-install", "run-gate", "upload"]),
"gate-matrix": new Set(["checkout", "setup-node", "frozen-install", "browser-install", "download", "extract", "run-gate", "upload"]),
"gate-single": new Set(["checkout", "setup-node", "frozen-install", "run-gate", "upload"]),
immutable: new Set(["checkout", "setup-node", "frozen-install", "run-gate", "archive-candidate", "upload"]),
provider: new Set(["checkout", "setup-node", "frozen-install", "download", "extract", "run-provider", "validate-provider-evidence", "upload"]),
@@ -371,12 +371,13 @@ jobs:
production_gate:
name: "\${{ matrix.gate }} / \${{ matrix.name }}"
needs: promotion
needs: [immutable_build, promotion]
if: \${{ gitea.event_name == 'workflow_dispatch' && (inputs.stage == 'production' || inputs.stage == 'field') }}
runs-on: ubuntu-latest
timeout-minutes: 45
env:
HOSTING_BASE_URL: "\${{ vars.HOSTING_BASE_URL }}"
CANDIDATE_ARCHIVE_SHA256: "\${{ needs.immutable_build.outputs.archive_sha256 }}"
strategy:
fail-fast: false
matrix:
@@ -398,6 +399,13 @@ jobs:
run: |
corepack enable
corepack pnpm install --frozen-lockfile --ignore-scripts
- name: Download promoted release
uses: https://github.com/ChristopherHX/gitea-download-artifact@75635f32b4c1c41c4b3d64e8f85210112ed4c9c7
with:
name: "promoted-release-\${{ gitea.run_id }}-\${{ gitea.run_attempt }}"
path: .release/promoted
- name: Verify and extract the candidate through one inode-bound operation
run: node scripts/verify-ci-candidate-archive.ts --archive ".release/promoted/release-candidate.tar.gz" --extract-to ".release/promoted-release"
- name: Run blocking gate
run: corepack pnpm ci:gate -- \${{ matrix.gate }}
- name: Upload production gate evidence
+83 -3
View File
@@ -195,7 +195,7 @@ describe("CI gate contract", () => {
);
expect(contract.jobs).toHaveLength(9);
expect(contract.commands).toHaveLength(98);
expect(contract.gates.reduce((total, gate) => total + gate.commandIds.length, 0)).toBe(108);
expect(contract.gates.reduce((total, gate) => total + gate.commandIds.length, 0)).toBe(103);
expect(contract.commands.filter(({ expect }) => expect === "fail")).toHaveLength(30);
expect(contract.gates.reduce((total, gate) => total + gate.evidenceArtifactIds.length, 0)).toBe(87);
expect(contract.artifacts).toHaveLength(109);
@@ -241,6 +241,83 @@ describe("CI gate contract", () => {
});
});
it("drills the downloaded promoted archive in the production stage without rebuilding (13-03)", async () => {
const contract = await loadCiGateContract(process.cwd());
const index = indexCiGateContract(contract);
const productionGate = contract.jobs.find(({ id }) => id === "production_gate");
const kinds = productionGate?.steps.map(({ kind }) => kind) ?? [];
const download = productionGate?.steps.find((step) => step.kind === "download");
const extract = productionGate?.steps.find((step) => step.kind === "extract");
expect(download).toEqual({
kind: "download",
transferId: "promoted-release",
path: ".release/promoted",
});
expect(extract).toEqual({
kind: "extract",
archivePath: ".release/promoted/release-candidate.tar.gz",
targetRoot: ".release/promoted-release",
});
expect(kinds.indexOf("download")).toBeLessThan(kinds.indexOf("extract"));
expect(kinds.indexOf("extract")).toBeLessThan(kinds.indexOf("run-gate"));
// The extract step checks the archive against the digest immutable_build
// recorded, so the drilled bytes are the promoted candidate.
expect(productionGate?.needs).toContain("immutable_build");
expect(productionGate?.environment).toContainEqual({
name: "CANDIDATE_ARCHIVE_SHA256",
value: "${{ needs.immutable_build.outputs.archive_sha256 }}",
});
for (const gateId of ["FE-GATE-021", "FE-GATE-022", "FE-GATE-023", "FE-GATE-024", "FE-GATE-025"]) {
const commands = index.gates.get(gateId)?.commandIds.map((id) => index.commands.get(id)!) ?? [];
expect(commands.map(({ script }) => script), gateId).toEqual(["drill:runbook"]);
const args = commands[0]?.args ?? [];
expect(args[args.indexOf("--release-root") + 1], gateId).toBe(".release/promoted-release");
}
const workflow = renderCiWorkflow(contract);
const productionJob = workflow.slice(
workflow.indexOf(" production_gate:\n"),
workflow.indexOf(" field_gate:\n"),
);
const downloadAt = productionJob.indexOf("- name: Download promoted release");
const extractAt = productionJob.indexOf(
'--archive ".release/promoted/release-candidate.tar.gz" --extract-to ".release/promoted-release"',
);
expect(downloadAt).toBeGreaterThan(0);
expect(extractAt).toBeGreaterThan(downloadAt);
expect(productionJob.indexOf("Run blocking gate")).toBeGreaterThan(extractAt);
});
it.each([
[
"a drill without --release-root",
(contract: Record<string, any>) => {
const drill = contract.commands.find((command: Record<string, any>) => command.id === "drill-runbook");
drill.args = ["--", "FE-RB-005"];
},
],
[
"a drill gate that rebuilds from source",
(contract: Record<string, any>) => {
const gate = contract.gates.find((candidate: Record<string, any>) => candidate.id === "FE-GATE-025");
gate.commandIds = ["build", ...gate.commandIds];
},
],
[
"a production stage without the promoted archive",
(contract: Record<string, any>) => {
const job = contract.jobs.find((candidate: Record<string, any>) => candidate.id === "production_gate");
job.steps = job.steps.filter((step: Record<string, any>) => !["download", "extract"].includes(step.kind));
},
],
])("rejects %s in the production stage (13-03)", async (_name, mutate) => {
const contract = JSON.parse(
JSON.stringify(await loadCiGateContract(process.cwd())),
) as Record<string, any>;
mutate(contract);
expect(() => parseCiGateContract(contract)).toThrow(/promoted/iu);
});
it("keeps the action registry recursively immutable and resolves only known actions", () => {
expect(Object.isFrozen(CI_ACTION_REGISTRY)).toBe(true);
expect(Object.values(CI_ACTION_REGISTRY).every((action) => Object.isFrozen(action))).toBe(true);
@@ -1406,7 +1483,10 @@ describe("CI workflow generation", () => {
).toHaveLength(9);
expect(first).not.toMatch(/corepack pnpm install --frozen-lockfile$/mu);
expect(first).toContain("verify-ci-candidate-archive.ts --archive");
expect(first).not.toContain("--extract-to");
// Providers and promotion read the archive without extracting it; only the
// production drills extract the promoted archive (13-03).
expect(first.match(/--extract-to/gu)).toHaveLength(1);
expect(first.indexOf("--extract-to")).toBeGreaterThan(first.indexOf(" production_gate:\n"));
expect(first).not.toMatch(/\btar\s+[^\n]*--extract/u);
expect(first).toContain("node scripts/stage-verified-promotion.ts");
expect(first).toContain("outputs:\n invocation_nonce: ${{ steps.supervise_vulnerability.outputs.invocation_nonce }}");
@@ -1436,7 +1516,7 @@ describe("CI workflow generation", () => {
'if [ -n "$PROMOTION_STAGING_ROOT" ] && [ -n "$PROMOTION_CLEANUP_TOKEN" ] && [ -n "$PROMOTION_RUNNER_TEMP_DEV" ] && [ -n "$PROMOTION_RUNNER_TEMP_INO" ] && [ -n "$PROMOTION_STAGING_DEV" ] && [ -n "$PROMOTION_STAGING_INO" ]; then',
);
const actionUses = [...first.matchAll(/^\s+-?\s*uses: (.+)$/gmu)].map((match) => match[1]);
expect(actionUses).toHaveLength(32);
expect(actionUses).toHaveLength(33);
expect(new Set(actionUses)).toEqual(
new Set([
"https://github.com/actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5",