From 67082cc15eb11c517a7f52c603ecb1b367f4c179 Mon Sep 17 00:00:00 2001 From: DongHyeonka Date: Thu, 5 Nov 2026 22:20:55 +0900 Subject: [PATCH] =?UTF-8?q?fix(ci):=20gate=20=EB=AA=A8=EC=96=91=20?= =?UTF-8?q?=EA=B8=B0=EC=A4=80=EC=84=A0=EC=9D=B4=20FE-GATE-013=EC=9D=98=20?= =?UTF-8?q?=EB=9F=AC=EB=84=88=20=EC=9A=94=EA=B5=AC=EB=8F=84=20=EB=B3=B8?= =?UTF-8?q?=EB=8B=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1105/12-01 수정이 gate 정의에 `hostRequirements`(러너가 갖춰야 할 것)를 더했지만, 기준선의 gate 모양 해시(`canonicalGateShapeSha256`)에서는 뺐다. 그래서 누가 이 요구를 지우거나 바꿔도 `contract-baseline.json`이 알아차리지 못하고 `check:ci`가 통과한다. 요구가 사라지면 workflow 주석도 사라져, user namespace가 없는 러너에서 같은 원인 불명 실패가 다시 난다. 러너 요구를 gate 모양에 넣는다. 요구를 선언한 gate만 이 키를 갖게 해 다른 gate의 해시는 그대로다. 기준선을 한 번 다시 기록했다(owner DongHyeonka, reason에 1105/12-01). 버린 대안: 그대로 빼 두기(지우기를 리뷰가 못 본다), 모든 gate에 빈 목록을 넣기(모든 해시가 바뀌고 효과는 같다). 위험·한계: 앞으로 `hostRequirements`를 바꾸려면 기준선 재기록 (`update:ci-contract-baseline`, owner·reason 필수)이 필요하다. 의도한 비용이다. 검증: desktop batch. `tests/unit/ci-workflow-generation.test.ts`의 새 "rejects runner requirement drift through the semantic-shape digest"가 수정 전 코드·기준선에서 실패하고 수정 뒤 통과한다. `check:ci` 통과. Refs: 1105/12-01 --- config/ci/contract-baseline.json | 4 ++-- scripts/contracts/ci-gates.ts | 9 +++++++-- tests/unit/ci-workflow-generation.test.ts | 22 ++++++++++++++++++++++ 3 files changed, 31 insertions(+), 4 deletions(-) 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) => {