diff --git a/config/ci/contract-baseline.json b/config/ci/contract-baseline.json index 8b63dfd9..b05954bf 100644 --- a/config/ci/contract-baseline.json +++ b/config/ci/contract-baseline.json @@ -1,11 +1,11 @@ { "schemaVersion": 1, "owner": "DongHyeonka", - "reason": "1103/13-03: FE-GATE-027 also runs scan:dependency-advisories, a non-blocking release-stage advisory signal", + "reason": "1105/12-01: FE-GATE-013 hostRequirements are part of the reviewed gate shape", "gates": 27, "commands": 100, "commandReferences": 104, "artifacts": 110, "stages": 5, - "gateShapeSha256": "6225494d6447a2065d921a34597a744d180a7a68e601119e32f8fc42e18eb1c1" + "gateShapeSha256": "7bebafe65d528be6a59d4bb70edd2cad99455b2b49087e4a46b83d77bfd163de" } diff --git a/scripts/contracts/ci-gates.ts b/scripts/contracts/ci-gates.ts index ae02aedb..3189b159 100644 --- a/scripts/contracts/ci-gates.ts +++ b/scripts/contracts/ci-gates.ts @@ -295,8 +295,9 @@ const gateSchema = z * 1105/12-01. What the runner host must provide for the gate to pass, one * line each. The workflow shows them as comments beside the job's * `runs-on`; a line cannot hold a line break, so it cannot leave the - * comment. They describe the runner, not the gate's commands or evidence, - * so the reviewed gate shape (canonicalGateShapeSha256) leaves them out. + * comment. They are part of the reviewed gate shape + * (canonicalGateShapeSha256): dropping or changing one needs a new + * contract baseline, like any other change to what a gate demands. */ hostRequirements: z.array(nonEmpty.max(512)).min(1).max(8).optional(), }) @@ -504,6 +505,7 @@ function canonicalGateShapeSha256(gates: CiGateContract["gates"]): string { evidenceArtifactIds, retentionClassId, requiresEnvironment, + hostRequirements, }) => ({ id, name, @@ -512,6 +514,9 @@ function canonicalGateShapeSha256(gates: CiGateContract["gates"]): string { evidenceArtifactIds, retentionClassId, requiresEnvironment: requiresEnvironment ?? [], + // Only gates that declare runner requirements carry the key, so the + // digest of every other gate stays what it was. + ...(hostRequirements === undefined ? {} : { hostRequirements }), }), ); return createHash("sha256").update(JSON.stringify(normalized)).digest("hex"); diff --git a/tests/unit/ci-workflow-generation.test.ts b/tests/unit/ci-workflow-generation.test.ts index f5ad6f8a..0368ce8d 100644 --- a/tests/unit/ci-workflow-generation.test.ts +++ b/tests/unit/ci-workflow-generation.test.ts @@ -579,6 +579,28 @@ describe("CI gate contract", () => { await expect(loadCiGateContract(root)).rejects.toThrow(/gateShapeSha256: baseline/i); }); + it("rejects runner requirement drift through the semantic-shape digest (1105/12-01)", async () => { + const root = await mkdtemp(path.join(tmpdir(), "ci-contract-host-shape-")); + temporaryRoots.push(root); + await mkdir(path.join(root, "config/ci"), { recursive: true }); + const contract = JSON.parse( + JSON.stringify(await loadCiGateContract(process.cwd())), + ) as Record; + const gate = contract.gates.find( + (candidate: Record) => candidate.id === "FE-GATE-013", + ); + expect(gate.hostRequirements?.length).toBeGreaterThan(0); + gate.hostRequirements = gate.hostRequirements.slice(1); + await writeFile(path.join(root, "config/ci/gates.json"), `${JSON.stringify(contract)}\n`); + await writeFile(path.join(root, "package.json"), await readFile("package.json")); + await writeFile( + path.join(root, "config/ci/contract-baseline.json"), + await readFile("config/ci/contract-baseline.json"), + ); + + await expect(loadCiGateContract(root)).rejects.toThrow(/gateShapeSha256: baseline/i); + }); + it.each(["check:artifact-schemas", "check:ci-workflow"])( "rejects a missing nested check:ci dependency: %s", async (removedScript) => {