diff --git a/scripts/lib/removal-fixture.ts b/scripts/lib/removal-fixture.ts index fd39e717..ed3d2741 100644 --- a/scripts/lib/removal-fixture.ts +++ b/scripts/lib/removal-fixture.ts @@ -465,8 +465,14 @@ export async function pruneRemovalFixtureCiContract(options: Readonly<{ ]); // D-13: the reduced contract is a new baseline, recorded the way a project // that removes the capability records it; canonical check:ci then applies. + // 1103/16-02. A product feature owns no CI script; an empty list used to + // leave a trailing blank that the baseline schema refuses. await updateCiContractBaseline(options.root, { owner: "removal-fixture", - reason: `removal fixture pruned ${[...options.removedScripts].join(", ")}`, + reason: `removal fixture pruned ${ + options.removedScripts.size === 0 + ? "no CI scripts" + : [...options.removedScripts].join(", ") + }`, }); } diff --git a/tests/unit/removal-fixture.test.ts b/tests/unit/removal-fixture.test.ts index 001b11e0..b117687b 100644 --- a/tests/unit/removal-fixture.test.ts +++ b/tests/unit/removal-fixture.test.ts @@ -92,6 +92,25 @@ it("prunes removed command and evidence references and re-baselines the contract expect(packageDocument.scripts["check:ci"]).not.toMatch(/reduced/u); }); +// 1103/16-02. A product feature owns no CI script, so its removal prunes +// nothing. The baseline reason then ended in a blank ("removal fixture pruned +// ") and the baseline schema refused it before any gate ran. +it("re-baselines a removal that prunes no CI script", async () => { + const root = await copyCiContract("removal-fixture-no-scripts-"); + + await pruneRemovalFixtureCiContract({ + root, + removedScripts: new Set(), + removedEvidencePathFragments: [], + }); + + const baseline = JSON.parse( + await readFile(path.join(root, "config/ci/contract-baseline.json"), "utf8"), + ) as Record; + expect(baseline["reason"]).toBe("removal fixture pruned no CI scripts"); + await expect(loadCiGateContract(root)).resolves.toBeDefined(); +}); + it("rejects a contract that no longer matches its committed baseline", async () => { const root = await copyCiContract("removal-fixture-baseline-drift-"); const baselinePath = path.join(root, "config/ci/contract-baseline.json");