FE-GATE-020 proves a capability can be removed by rebuilding the whole project without it. The fixture it built could not get that far, and the failures all came from the fixture rather than from anything about removability. It was not a repository. The supply-chain inventory is defined as the tracked file set, so it asks `git ls-files` what the project contains; with no repository to ask, generation failed and took every provider suite down with it. It is now initialised on preparation and committed after the removal — not before, or the index would still list the files the removal deleted. It had no `.gitignore`, so once it did have a repository, every generated artifact and every linked module landed in the index and the inventory refused the fixture for tracked and generated paths colliding. It carries the ignore rules now, and therefore records the same tracked set as the repository it was copied from. Each removal script kept its own copy-target list and they had drifted: the reference-feature fixture omitted `playwright.capabilities.config.ts`, which the inventory requires. There is one list now. It also gained the install and workspace identity — `.npmrc`, the lockfile, the workspace file — without which the fixture is a different project, and the release evidence a candidate is assembled from, without which no candidate can be built at all. A tracked root the removal deletes is no longer required of the result: the optional-recipe fixture deletes `recipes/`, and the inventory policy demanded it back. Roots that are gone are pruned from the fixture's policy. Two smaller causes. A platform integration file asserted the reference feature's own route ids, so removing the feature left it importing a deleted module — typecheck, the test run, coverage and the residue scan all failed on that one misplaced assertion, which now lives in the feature's test tree. And the canonical exact-count authority was re-imposed on a contract the fixture deliberately reduces, failing the fixture for the reduction it exists to prove; `CI_CONTRACT_MODE` already marked those runs and is now honoured by default. The reference-feature fixture goes from failing before its first assertion to 1,612 passing with one failure, and that one is the live process-tree observation test already red on the main tree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
108 lines
3.4 KiB
TypeScript
108 lines
3.4 KiB
TypeScript
import {
|
|
mkdir,
|
|
readFile,
|
|
rm,
|
|
writeFile,
|
|
} from "node:fs/promises";
|
|
import path from "node:path";
|
|
|
|
import {
|
|
filesBelow,
|
|
prepareRemovalFixture,
|
|
pruneRemovalFixtureCiContract,
|
|
pruneScriptOrchestration,
|
|
regenerateRemovalFixtureWorkflow,
|
|
requireRemovalFixtureEnvironment,
|
|
runRemovalFixturePnpm,
|
|
} from "./lib/removal-fixture.ts";
|
|
|
|
const fixtureRoot = path.resolve(".tmp/optional-recipe-removal");
|
|
const pnpmCli = requireRemovalFixtureEnvironment("npm_execpath");
|
|
|
|
function runPnpm(script: string): boolean {
|
|
return runRemovalFixturePnpm(fixtureRoot, pnpmCli, script);
|
|
}
|
|
|
|
await prepareRemovalFixture(fixtureRoot);
|
|
for (const rootOnlyTest of [
|
|
"tests/unit/ci-workflow-generation.test.ts",
|
|
"tests/unit/__snapshots__/ci-workflow-generation.test.ts.snap",
|
|
]) {
|
|
await rm(path.join(fixtureRoot, rootOnlyTest), { force: true });
|
|
}
|
|
await rm(path.join(fixtureRoot, "recipes"), { recursive: true, force: true });
|
|
await rm(path.join(fixtureRoot, "tests/recipes"), {
|
|
recursive: true,
|
|
force: true,
|
|
});
|
|
|
|
const removedCiScripts = new Set([
|
|
"check:types:recipes",
|
|
"test:recipes",
|
|
"check:optional-recipes",
|
|
"check:optional-recipes:source",
|
|
"check:optional-recipe-fixtures",
|
|
"test:optional-recipe-removal",
|
|
]);
|
|
const fixturePackagePath = path.join(fixtureRoot, "package.json");
|
|
const fixturePackage = JSON.parse(await readFile(fixturePackagePath, "utf8")) as {
|
|
scripts: Record<string, string>;
|
|
};
|
|
pruneScriptOrchestration(fixturePackage.scripts, "check:types", removedCiScripts);
|
|
pruneScriptOrchestration(fixturePackage.scripts, "test:all", removedCiScripts);
|
|
await writeFile(fixturePackagePath, `${JSON.stringify(fixturePackage, null, 2)}\n`);
|
|
await pruneRemovalFixtureCiContract({
|
|
root: fixtureRoot,
|
|
removedScripts: removedCiScripts,
|
|
removedEvidencePathFragments: [
|
|
"optional-recipes",
|
|
"optional-recipe-fixtures",
|
|
"optional-recipe-removal",
|
|
],
|
|
});
|
|
await regenerateRemovalFixtureWorkflow(fixtureRoot);
|
|
|
|
const checks: Array<[string, boolean]> = [
|
|
["typecheck", runPnpm("check:types")],
|
|
["architecture", runPnpm("check:architecture")],
|
|
["test", runPnpm("test:all")],
|
|
["build", runPnpm("build")],
|
|
["ci-contract", runPnpm("check:ci")],
|
|
];
|
|
const residue: string[] = [];
|
|
for (const file of await filesBelow(path.join(fixtureRoot, "dist"))) {
|
|
if (!/\.(?:js|css|html|json)$/.test(file)) continue;
|
|
const content = await readFile(file, "utf8");
|
|
if (content.includes("frontend-optional-recipe-must-not-reach-production")) {
|
|
residue.push(path.relative(fixtureRoot, file));
|
|
}
|
|
}
|
|
checks.push(["bundle-residue", residue.length === 0]);
|
|
const passed = checks.every(([, result]) => result);
|
|
await mkdir("artifacts/tests", { recursive: true });
|
|
await writeFile(
|
|
"artifacts/tests/optional-recipe-removal.xml",
|
|
`<?xml version="1.0" encoding="UTF-8"?>\n` +
|
|
`<testsuite name="optional-recipe-removal" tests="${checks.length}" failures="${passed ? 0 : 1}">` +
|
|
checks
|
|
.map(
|
|
([name, result]) =>
|
|
`<testcase name="${name}">${result ? "" : `<failure>${residue.join(", ")}</failure>`}</testcase>`,
|
|
)
|
|
.join("") +
|
|
`</testsuite>\n`,
|
|
);
|
|
await rm(fixtureRoot, { recursive: true, force: true });
|
|
if (!passed) {
|
|
process.stderr.write(
|
|
`Optional recipe removal failed: ${checks
|
|
.filter(([, result]) => !result)
|
|
.map(([name]) => name)
|
|
.join(", ")}\n`,
|
|
);
|
|
process.exit(1);
|
|
}
|
|
process.stdout.write(
|
|
`Optional recipe removal: PASS (${checks.length} base checks)\n`,
|
|
);
|