문제
capability 제거 드릴의 fixture도 test:unit을 돈다. 앞 커밋들이 더한 가드
테스트 두 개가 그 안에서 실패했다.
- removal-fixture.test.ts: 문서 테스트 파일과 드릴 스크립트를 이름으로 읽는데,
fixture는 문서 테스트를 지우고(02-06) 드릴은 자기 스크립트를 지운다.
browser-file-storage·realtime 드릴이 이 두 건으로 `test` 검사에서 실패했다.
- feature-scaffold-drill: 제거 드릴이 자기 capability 명령을 계약에서 빼면,
scaffold 드릴 제외 목록의 그 스크립트가 "merge 단계에 없음"으로 실패한다.
고른 방법
- 문서 테스트는 "문서가 있는 곳에만 있다"를 단언한다(저장소: 둘 다 있음,
capability fixture: 둘 다 없음).
- 드릴 목록은 scripts/test-*.ts 중 removal-fixture.ts를 import하는 파일로 찾고,
sample·scaffold 드릴이 그 안에 있는지 확인한다.
- 제외 목록이 낡았다는 판정은 계약에 있으나 merge 단계 밖인 명령에만 한다.
계약에서 아예 빠진 명령(제거 드릴이 정리한 capability)은 낡은 것이 아니다.
위험·한계
- 계약에서 지운 스크립트의 제외 항목이 저장소에 남아도 이 검사는 알리지
않는다. 남아도 아무 명령을 숨기지 않는다.
검증
- 수정 전 snapshot(0edc3fc)에서 test:browser-file-storage-removal,
test:realtime-removal 모두 이 두 테스트로 exit 1(ENOENT).
- 수정 뒤 removal-fixture·feature-scaffold-drill 18건 통과, eslint·tsc 통과.
Refs: docs/reviews/2026-11-03-maturity-review/02-adapters-browser-files-cache.md 02-06
Refs: docs/reviews/2026-11-03-maturity-review/12-guardrails-ci.md 12-02
88 lines
4.3 KiB
TypeScript
88 lines
4.3 KiB
TypeScript
import { readFile } from "node:fs/promises";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import { loadCiGateContract } from "../../scripts/contracts/ci-gates.ts";
|
|
import {
|
|
SCAFFOLD_DRILL_EXCLUDED_SCRIPTS,
|
|
scaffoldDrillCommands,
|
|
} from "../../scripts/lib/feature-scaffold-drill.ts";
|
|
|
|
// 1103/12-02. The scaffold drill claimed "every merge gate" and ran 15
|
|
// hand-picked commands of the 88 in the merge stage.
|
|
describe("feature scaffold drill commands", () => {
|
|
it("are the merge stage minus the named exclusions, each command once", async () => {
|
|
const contract = await loadCiGateContract(process.cwd());
|
|
const merge = contract.stages.find(({ id }) => id === "merge")!;
|
|
const mergeCommandIds = new Set(
|
|
merge.gateIds.flatMap((gateId) => contract.gates.find(({ id }) => id === gateId)!.commandIds),
|
|
);
|
|
const commands = scaffoldDrillCommands(contract);
|
|
const runCommandIds = commands.map(({ name }) => name.split(":").slice(1).join(":"));
|
|
expect(new Set(runCommandIds).size).toBe(runCommandIds.length);
|
|
for (const commandId of mergeCommandIds) {
|
|
const command = contract.commands.find(({ id }) => id === commandId)!;
|
|
expect(
|
|
runCommandIds.includes(commandId) || Object.hasOwn(SCAFFOLD_DRILL_EXCLUDED_SCRIPTS, command.script),
|
|
commandId,
|
|
).toBe(true);
|
|
}
|
|
expect(commands.map(({ script }) => script)).toEqual(expect.arrayContaining([
|
|
"check:types", "lint", "test:unit", "test:coverage", "build", "check:bundle",
|
|
"test:contract", "test:runtime-schema", "check:request-fanout", "build:release-candidate",
|
|
]));
|
|
for (const reason of Object.values(SCAFFOLD_DRILL_EXCLUDED_SCRIPTS)) {
|
|
expect(reason.length).toBeGreaterThan(10);
|
|
}
|
|
});
|
|
|
|
it("keeps a negative fixture's registered exit and diagnostic", async () => {
|
|
const contract = await loadCiGateContract(process.cwd());
|
|
expect(scaffoldDrillCommands(contract).find(({ script }) => script === "check:types:fixture"))
|
|
.toMatchObject({ expectation: { kind: "fail", expectedExitCode: 1, expectedDiagnosticId: "error TS2322:" } });
|
|
});
|
|
|
|
it("runs a command added to the merge stage without an edit to the drill", async () => {
|
|
const contract = structuredClone(await loadCiGateContract(process.cwd()));
|
|
contract.commands.push({ id: "check-probe", script: "check:probe", expect: "pass" } as never);
|
|
contract.gates.find(({ id }) => id === "FE-GATE-010")!.commandIds.push("check-probe");
|
|
expect(scaffoldDrillCommands(contract).map(({ name }) => name)).toContain("FE-GATE-010:check-probe");
|
|
});
|
|
|
|
it("refuses an exclusion for a command the contract runs outside the merge stage", async () => {
|
|
const contract = await loadCiGateContract(process.cwd());
|
|
const merge = new Set(contract.stages.find(({ id }) => id === "merge")!.gateIds);
|
|
const mergeCommandIds = new Set(
|
|
contract.gates.filter(({ id }) => merge.has(id)).flatMap(({ commandIds }) => commandIds),
|
|
);
|
|
const mergeScripts = new Set(
|
|
contract.commands.filter(({ id }) => mergeCommandIds.has(id)).map(({ script }) => script),
|
|
);
|
|
const outside = contract.commands.find(({ script }) => !mergeScripts.has(script))!;
|
|
expect(() => scaffoldDrillCommands(contract, {
|
|
...SCAFFOLD_DRILL_EXCLUDED_SCRIPTS,
|
|
[outside.script]: "not in the merge stage",
|
|
})).toThrow(`outside the merge stage: ${outside.script}`);
|
|
});
|
|
|
|
// A removal drill prunes its capability's commands from the contract, and
|
|
// this file runs inside that fixture too.
|
|
it("accepts an exclusion whose command the contract no longer has", async () => {
|
|
const contract = structuredClone(await loadCiGateContract(process.cwd()));
|
|
const removed = contract.commands.find(({ script }) =>
|
|
Object.hasOwn(SCAFFOLD_DRILL_EXCLUDED_SCRIPTS, script)
|
|
)!;
|
|
contract.commands = contract.commands.filter(({ id }) => id !== removed.id);
|
|
for (const gate of contract.gates) {
|
|
gate.commandIds = gate.commandIds.filter((id) => id !== removed.id);
|
|
}
|
|
expect(() => scaffoldDrillCommands(contract)).not.toThrow();
|
|
});
|
|
|
|
it("is what test:feature-scaffold runs", async () => {
|
|
const drill = await readFile("scripts/test-feature-scaffold.ts", "utf8");
|
|
expect(drill).toContain("scaffoldDrillCommands(");
|
|
expect(drill).toContain("loadCiGateContract(fixtureRoot)");
|
|
});
|
|
});
|