문제: 앞 커밋으로 `src` 검사는 이름 단위가 됐지만, 빌드한 `dist`는 여전히 기능 ID를 대소문자 무시 부분 문자열로 찾았다. desktop에서 `create:feature product-feature` 뒤 그 기능을 지우는 드릴을 돌리면 `src` 검사는 통과하고 `built-fixture-id-residue`가 템플릿 자기 청크 `platform-overview-page-*.js`(`data-product-feature` 속성)로 실패했다. 고친 것: 이름 단위 규칙을 `featureNamePattern`으로 꺼내 `src` 본문과 빌드 결과에 같이 쓴다. 위험·한계: 빌드 결과에서도 대소문자를 가린다. 기능 ID와 폴더는 소문자 kebab이라 놓치는 경우는 없다고 본다. 검증(desktop): feature-residue·feature-removal-argument 15개 통과, check:types·eslint rc=0(로그 /tmp/claude-gates/w2fe2-res3/). 고치기 전 드릴 실패는 /tmp/claude-gates/w2fe2-resx3/. Refs: 1105/16-04
584 lines
23 KiB
TypeScript
584 lines
23 KiB
TypeScript
import {
|
|
access,
|
|
mkdir,
|
|
readdir,
|
|
readFile,
|
|
rm,
|
|
writeFile,
|
|
} from "node:fs/promises";
|
|
import { spawnSync } from "node:child_process";
|
|
import path from "node:path";
|
|
import { fileURLToPath } from "node:url";
|
|
|
|
import { PLATFORM_ROUTE_REGISTRY } from "../src/contracts/routes.ts";
|
|
import { ROUTE_FEATURE_OWNER, routePath } from "../src/features/installed-feature-contracts.ts";
|
|
import { loadCiGateContract } from "./contracts/ci-gates.ts";
|
|
import { createFileSystemDeclarationSource } from "./generate-product-feature-index.ts";
|
|
import { featureNamePattern, productFeatureResidue } from "./lib/feature-residue.ts";
|
|
import { isProductionModulePath } from "./lib/risk-coverage.ts";
|
|
import {
|
|
createRemovalFixtureRoot,
|
|
filesBelow,
|
|
prepareRemovalFixture,
|
|
pruneRemovalFixtureCiContract,
|
|
pruneScriptOrchestration,
|
|
regenerateRemovalFixtureWorkflow,
|
|
REMOVAL_FIXTURE_COPY_TARGETS,
|
|
REMOVAL_FIXTURE_DOCUMENT_TARGETS,
|
|
renderRemovalJunit,
|
|
requireRemovalFixtureEnvironment,
|
|
runRemovalFixtureCheck,
|
|
runRemovalFixturePnpm,
|
|
sealRemovalFixtureRepository,
|
|
type RemovalCheck,
|
|
} from "./lib/removal-fixture.ts";
|
|
import { REMOVAL_DRILL_SUITES_OUTSIDE_COVERAGE } from "./lib/feature-scaffold-drill.ts";
|
|
import { REMOVABLE_TEMPLATE_FEATURES } from "./lib/removable-template-features.ts";
|
|
|
|
/**
|
|
* 09-07 (D-10). Removes one installed feature, `--feature=<id>`, from a copy
|
|
* of the repository and proves the rest still typechecks, tests, covers and
|
|
* builds. Every feature loses its directory, its tests/features directory,
|
|
* its context when no other feature is left in it, its runtime-profile
|
|
* override and its central policy rows. A sample that
|
|
* scripts/lib/removable-template-features.ts lists also loses its extra paths
|
|
* and package scripts, with the CI evidence only those scripts produce, and
|
|
* the copy then gets a feature from create:feature and runs the gates again.
|
|
*
|
|
* Without `--feature` (FE-GATE-020) each listed sample is removed in turn.
|
|
* The template lists none since its samples were deleted (2026-11-07): the
|
|
* run then reports the drill as skipped, not passed, and test:feature-scaffold
|
|
* removes a generated feature through `--feature`.
|
|
*/
|
|
const SAMPLE_REPORT = "artifacts/tests/sample-removal.xml";
|
|
const requestedFeature = process.argv
|
|
.find((argument) => argument.startsWith("--feature="))
|
|
?.slice("--feature=".length);
|
|
|
|
if (requestedFeature === undefined) {
|
|
const checks: RemovalCheck[] = REMOVABLE_TEMPLATE_FEATURES.map((sample) => {
|
|
const status = spawnSync(
|
|
process.execPath,
|
|
[fileURLToPath(import.meta.url), `--feature=${sample.featureId}`],
|
|
{ stdio: "inherit" },
|
|
).status;
|
|
return status === 0
|
|
? { name: sample.featureId, passed: true }
|
|
: {
|
|
name: sample.featureId,
|
|
passed: false,
|
|
failure: `test:sample-removal -- --feature=${sample.featureId} exited ${status ?? "on a signal"}`,
|
|
};
|
|
});
|
|
await mkdir("artifacts/tests", { recursive: true });
|
|
if (checks.length === 0) {
|
|
await writeFile(
|
|
SAMPLE_REPORT,
|
|
`<?xml version="1.0" encoding="UTF-8"?>\n` +
|
|
`<testsuite name="sample-removal" tests="1" failures="0" skipped="1">` +
|
|
`<testcase name="listed-samples"><skipped message="scripts/lib/removable-template-features.ts lists no sample" /></testcase>` +
|
|
`</testsuite>\n`,
|
|
);
|
|
process.stdout.write(
|
|
"sample removal: SKIP (scripts/lib/removable-template-features.ts lists no sample; " +
|
|
"test:feature-scaffold removes a generated feature with --feature)\n",
|
|
);
|
|
} else {
|
|
await writeFile(SAMPLE_REPORT, renderRemovalJunit("sample-removal", checks));
|
|
if (checks.some((check) => !check.passed)) process.exitCode = 1;
|
|
}
|
|
process.exit();
|
|
}
|
|
const featureId: string = requestedFeature;
|
|
|
|
type FeatureExtras = Readonly<{
|
|
paths: readonly string[];
|
|
ciScripts: readonly string[];
|
|
evidencePathFragments: readonly string[];
|
|
}>;
|
|
|
|
/** The CI evidence that only `scripts` produce: it goes with them. */
|
|
async function evidenceOnlyFrom(scripts: readonly string[]): Promise<string[]> {
|
|
if (scripts.length === 0) return [];
|
|
const contract = await loadCiGateContract(process.cwd());
|
|
const commandIds = new Set(
|
|
contract.commands.filter(({ script }) => scripts.includes(script)).map(({ id }) => id),
|
|
);
|
|
return contract.artifacts.flatMap((artifact) =>
|
|
artifact.production === "command-generated" &&
|
|
artifact.producerCommandIds.length > 0 &&
|
|
artifact.producerCommandIds.every((commandId) => commandIds.has(commandId))
|
|
? [artifact.path]
|
|
: [],
|
|
);
|
|
}
|
|
|
|
// The sample's own files and scripts outside its folders, which
|
|
// verify:documentation reads too.
|
|
const listedSample = REMOVABLE_TEMPLATE_FEATURES.find(
|
|
(feature) => feature.featureId === featureId,
|
|
);
|
|
const extras: FeatureExtras = Object.freeze({
|
|
paths: listedSample?.extraPaths ?? [],
|
|
ciScripts: listedSample?.scripts ?? [],
|
|
evidencePathFragments: await evidenceOnlyFrom(listedSample?.scripts ?? []),
|
|
});
|
|
|
|
function escapeRegExp(value: string): string {
|
|
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
|
}
|
|
|
|
async function locateFeature(id: string) {
|
|
const source = await createFileSystemDeclarationSource(process.cwd());
|
|
for (const appId of source.appIds()) {
|
|
for (const context of source.contextsOf(appId)) {
|
|
const features = source.featuresOf(context.id);
|
|
const feature = features.find((candidate) => candidate.id === id);
|
|
if (!feature) continue;
|
|
let contextDirectory: string | null = null;
|
|
for (const entry of await readdir("src/contexts", { withFileTypes: true })) {
|
|
if (!entry.isDirectory()) continue;
|
|
const declaration = await readFile(
|
|
path.join("src/contexts", entry.name, "context-module.ts"),
|
|
"utf8",
|
|
).catch(() => "");
|
|
if (
|
|
new RegExp(`CONTEXT_MODULE_ID\\s*=\\s*["']${escapeRegExp(context.id)}["']`, "u")
|
|
.test(declaration)
|
|
) {
|
|
contextDirectory = `src/contexts/${entry.name}`;
|
|
}
|
|
}
|
|
return Object.freeze({
|
|
directory: feature.directory,
|
|
// The context goes with its last feature.
|
|
contextDirectory: features.length === 1 ? contextDirectory : null,
|
|
});
|
|
}
|
|
}
|
|
throw new Error(`No installed feature declares FEATURE_MODULE_ID "${id}"`);
|
|
}
|
|
|
|
const located = await locateFeature(featureId);
|
|
// Captured from this repository before the copy loses them.
|
|
const featureRouteIds = Object.entries(ROUTE_FEATURE_OWNER)
|
|
.filter(([, owner]) => owner === featureId)
|
|
.map(([routeId]) => routeId);
|
|
// 0925 FOLLOW-UP 09-07. A spec that opens the feature by one of these paths is
|
|
// residue (scripts/lib/feature-residue.ts). A platform path the feature took
|
|
// over (its home) goes back to the platform with the removal.
|
|
const platformRoutePaths = new Set<string>(
|
|
Object.values(PLATFORM_ROUTE_REGISTRY).map((route) => route.path),
|
|
);
|
|
const featureRoutePaths = featureRouteIds
|
|
.map(routePath)
|
|
.filter((candidate) => !platformRoutePaths.has(candidate));
|
|
|
|
const fixtureRoot = await createRemovalFixtureRoot(`${featureId}-removal`);
|
|
const pnpmCli = requireRemovalFixtureEnvironment("npm_execpath");
|
|
const featureSource = `src/features/${located.directory}`;
|
|
const featureTests = `tests/features/${located.directory}`;
|
|
const isSample = listedSample !== undefined;
|
|
/**
|
|
* Platform tests that must survive the sample feature's removal. Asserting they
|
|
* are still present is what stops the removal fixture from "passing" by having
|
|
* quietly deleted the platform's own coverage along with the feature.
|
|
*/
|
|
const commonTestPaths = [
|
|
"tests/unit/external-contract-runtime.test.ts",
|
|
"tests/unit/http-execution-v3.test.ts",
|
|
// 1105/10-01. MAX_RETRY_ATTEMPTS and REQUEST_TIMEOUT_MS reach the executor
|
|
// (`createRuntimeContractHttpExecutor`), and a session being recovered waits
|
|
// on a session-required route. Before, only sample tests held these rules.
|
|
"tests/unit/runtime-adapters.test.ts",
|
|
"tests/unit/session-route-access.test.ts",
|
|
"tests/integration/http-execution-v3-observability.test.ts",
|
|
// 0929/10-02. HTTP scenario evidence (FE-GATE-007) and the feature API
|
|
// negative type fixtures (FE-GATE-003) run on the test contracts.
|
|
"tests/integration/http-scenario-catalog.test.ts",
|
|
"tests/mocks/scenarios/catalog.ts",
|
|
"tests/mocks/handlers/test-entities.ts",
|
|
// 16-02. Feature tests answer their own operations with it.
|
|
"tests/mocks/handlers/http-scenarios.ts",
|
|
"tests/fixtures/typecheck/fixture-feature-contract.ts",
|
|
"tests/fixtures/typecheck/invalid-feature-input.ts",
|
|
"tests/fixtures/typecheck/invalid-reference-operation.ts",
|
|
"tests/fixtures/typecheck/invalid-http-operation-input.ts",
|
|
"tests/fixtures/typecheck/invalid-http-wire-mapper.ts",
|
|
"tests/fixtures/typecheck/invalid-http-operation-id.ts",
|
|
"tests/fixtures/typecheck/invalid-http-route-id.ts",
|
|
"tests/fixtures/typecheck/invalid-feature-contribution-input.ts",
|
|
"tests/fixtures/typecheck/invalid-feature-capability-selection.ts",
|
|
];
|
|
const featureOwnedPaths = [
|
|
featureSource,
|
|
featureTests,
|
|
// The feature's bounded-context declaration when it was the last feature in
|
|
// it; the template app stays.
|
|
...(located.contextDirectory === null ? [] : [located.contextDirectory]),
|
|
...extras.paths,
|
|
];
|
|
|
|
type CoveragePolicy = {
|
|
repositoryBaseline: number;
|
|
generatedPaths: string[];
|
|
criticalModules: Array<{
|
|
path?: string;
|
|
minimum?: Record<string, number>;
|
|
}>;
|
|
highRiskPaths: string[];
|
|
waivers: Array<{ path?: string }>;
|
|
};
|
|
|
|
type EvidenceContribution = Readonly<{ owner?: string }>;
|
|
type EvidencePolicy = Record<
|
|
"scenarioCatalogs" | "sourceContracts",
|
|
unknown
|
|
>;
|
|
type GovernanceConsumer = Readonly<{ path?: string }>;
|
|
type GovernanceRegistry = Record<string, unknown> & {
|
|
consumers?: unknown;
|
|
consumerDirectories?: unknown;
|
|
};
|
|
type RemovalGovernance = { registries: GovernanceRegistry[] };
|
|
|
|
function runPnpm(script: string, extra: string[] = []): boolean {
|
|
return runRemovalFixturePnpm(fixtureRoot, pnpmCli, script, extra);
|
|
}
|
|
|
|
function check(name: string, script: string, extra: string[] = []): RemovalCheck {
|
|
return runRemovalFixtureCheck(name, fixtureRoot, pnpmCli, script, extra);
|
|
}
|
|
|
|
/** 14-08. A non-command check fails with its own findings, nothing else's. */
|
|
function outcome(name: string, findings: readonly string[], label: string): RemovalCheck {
|
|
return findings.length === 0
|
|
? { name, passed: true }
|
|
: { name, passed: false, failure: `${label}: ${findings.join(", ")}` };
|
|
}
|
|
|
|
try {
|
|
// 1103/14-04. The documents come too: removing a feature must leave them
|
|
// valid, and the fixture used to leave them out with the tests that read
|
|
// them, so a manual naming the sample's files passed here and then failed
|
|
// FE-GATE-017 in the product that removed it.
|
|
await prepareRemovalFixture(fixtureRoot, [
|
|
...REMOVAL_FIXTURE_COPY_TARGETS,
|
|
...REMOVAL_FIXTURE_DOCUMENT_TARGETS,
|
|
]);
|
|
// Fixture-only deletions: a project that removes the sample keeps these.
|
|
// verify:documentation runs in this fixture, so a current contract document
|
|
// must not name them as backtick paths (docs/manual/reference/patterns.md).
|
|
for (const excludedFixtureTest of [
|
|
"tests/unit/ci-workflow-generation.test.ts",
|
|
"tests/unit/__snapshots__/ci-workflow-generation.test.ts.snap",
|
|
"tests/unit/removal-fixture.test.ts",
|
|
"tests/unit/http-scenario-evidence.test.ts",
|
|
]) {
|
|
await rm(path.join(fixtureRoot, excludedFixtureTest), { force: true });
|
|
}
|
|
|
|
const coveragePolicyFile = path.join(
|
|
fixtureRoot,
|
|
"config/testing/risk-coverage.json",
|
|
);
|
|
const coveragePolicy = JSON.parse(
|
|
await readFile(coveragePolicyFile, "utf8"),
|
|
) as CoveragePolicy;
|
|
const generatedProductionModules = new Set(coveragePolicy.generatedPaths);
|
|
|
|
const removedProductionModuleCount = (
|
|
await filesBelow(path.join(fixtureRoot, featureSource))
|
|
)
|
|
.map((file) => path.relative(fixtureRoot, file).split(path.sep).join("/"))
|
|
.filter(
|
|
(file) =>
|
|
isProductionModulePath(file) && !generatedProductionModules.has(file),
|
|
).length;
|
|
|
|
for (const ownedPath of featureOwnedPaths) {
|
|
await rm(path.join(fixtureRoot, ownedPath), {
|
|
recursive: true,
|
|
force: true,
|
|
});
|
|
}
|
|
if (!runPnpm("generate:feature-index")) {
|
|
throw new Error("Feature topology indexes failed to regenerate after sample removal");
|
|
}
|
|
|
|
// Runtime profiles are product configuration. Once the feature is physically
|
|
// removed, its override key must disappear too or the built config still
|
|
// advertises a source capability that no longer exists. public/config.json
|
|
// is the local profile `dev` serves and has to stay equal to it (F-5).
|
|
for (const configPath of [
|
|
"config/runtime/local.json",
|
|
"config/runtime/development.json",
|
|
"config/runtime/staging.json",
|
|
"config/runtime/production.json",
|
|
"public/config.json",
|
|
]) {
|
|
const profilePath = path.join(fixtureRoot, configPath);
|
|
const runtimeConfig = JSON.parse(
|
|
await readFile(profilePath, "utf8"),
|
|
) as {
|
|
FEATURE_OVERRIDES?: Record<string, string>;
|
|
};
|
|
if (runtimeConfig.FEATURE_OVERRIDES) {
|
|
delete runtimeConfig.FEATURE_OVERRIDES[featureId];
|
|
}
|
|
await writeFile(
|
|
profilePath,
|
|
`${JSON.stringify(runtimeConfig, null, 2)}\n`,
|
|
);
|
|
}
|
|
|
|
const retainedCriticalModules = coveragePolicy.criticalModules.filter(
|
|
(modulePolicy) => !modulePolicy.path?.startsWith(`${featureSource}/`),
|
|
);
|
|
coveragePolicy.criticalModules = retainedCriticalModules;
|
|
coveragePolicy.highRiskPaths = coveragePolicy.highRiskPaths.filter(
|
|
(modulePath) => !modulePath.startsWith(`${featureSource}/`),
|
|
);
|
|
coveragePolicy.waivers = coveragePolicy.waivers.filter(
|
|
(waiver) => !waiver.path?.startsWith(`${featureSource}/`),
|
|
);
|
|
coveragePolicy.generatedPaths = coveragePolicy.generatedPaths.filter(
|
|
(modulePath) => !modulePath.startsWith(`${featureSource}/`),
|
|
);
|
|
coveragePolicy.repositoryBaseline -= removedProductionModuleCount;
|
|
if (coveragePolicy.repositoryBaseline <= 0) {
|
|
throw new Error(`${featureId} removal produced an invalid coverage baseline`);
|
|
}
|
|
await writeFile(
|
|
coveragePolicyFile,
|
|
`${JSON.stringify(coveragePolicy, null, 2)}\n`,
|
|
);
|
|
|
|
const evidencePolicyFile = path.join(
|
|
fixtureRoot,
|
|
"config/testing/test-evidence.json",
|
|
);
|
|
const evidencePolicy = JSON.parse(
|
|
await readFile(evidencePolicyFile, "utf8"),
|
|
) as EvidencePolicy;
|
|
for (const policyKey of ["scenarioCatalogs", "sourceContracts"] as const) {
|
|
const contributions = evidencePolicy[policyKey];
|
|
if (!Array.isArray(contributions)) {
|
|
throw new Error(`Test evidence policy is missing ${policyKey}`);
|
|
}
|
|
// A feature's own evidence goes with it. The sample has none since
|
|
// 0929/10-02: the HTTP scenario catalog is owned by the platform.
|
|
evidencePolicy[policyKey] = contributions.filter(
|
|
(candidate: unknown) =>
|
|
(candidate as EvidenceContribution).owner !== featureId,
|
|
);
|
|
}
|
|
await writeFile(
|
|
evidencePolicyFile,
|
|
`${JSON.stringify(evidencePolicy, null, 2)}\n`,
|
|
);
|
|
|
|
const governanceFile = path.join(
|
|
fixtureRoot,
|
|
"config/contracts/registry-governance.json",
|
|
);
|
|
const removalGovernance = JSON.parse(
|
|
await readFile(governanceFile, "utf8"),
|
|
) as RemovalGovernance;
|
|
removalGovernance.registries = removalGovernance.registries.map(
|
|
(registry) => ({
|
|
...registry,
|
|
...(Array.isArray(registry.consumers)
|
|
? {
|
|
consumers: registry.consumers.filter(
|
|
(candidate: unknown) => {
|
|
const consumer = candidate as GovernanceConsumer;
|
|
return !consumer.path?.includes(featureSource);
|
|
},
|
|
),
|
|
}
|
|
: {}),
|
|
...(Array.isArray(registry.consumerDirectories)
|
|
? {
|
|
consumerDirectories: registry.consumerDirectories.filter(
|
|
(directory: unknown) =>
|
|
typeof directory !== "string" ||
|
|
!directory.includes(featureSource),
|
|
),
|
|
}
|
|
: {}),
|
|
}),
|
|
);
|
|
await writeFile(
|
|
governanceFile,
|
|
`${JSON.stringify(removalGovernance, null, 2)}\n`,
|
|
);
|
|
|
|
const removedCiScripts = new Set(extras.ciScripts);
|
|
const fixturePackagePath = path.join(fixtureRoot, "package.json");
|
|
const fixturePackage = JSON.parse(await readFile(fixturePackagePath, "utf8")) as {
|
|
scripts: Record<string, string>;
|
|
};
|
|
pruneScriptOrchestration(fixturePackage.scripts, "test:all", removedCiScripts);
|
|
await writeFile(fixturePackagePath, `${JSON.stringify(fixturePackage, null, 2)}\n`);
|
|
await pruneRemovalFixtureCiContract({
|
|
root: fixtureRoot,
|
|
removedScripts: removedCiScripts,
|
|
removedEvidencePathFragments: extras.evidencePathFragments,
|
|
});
|
|
// D-13: removing the sample is a breaking registry change. The fixture
|
|
// records the new registry baseline the way a downstream project does, and
|
|
// the canonical check:registries then runs against it.
|
|
if (!runRemovalFixturePnpm(fixtureRoot, pnpmCli, "update:registry-baseline", [], {
|
|
REGISTRY_BASELINE_OWNER: "removal-fixture",
|
|
REGISTRY_BASELINE_REASON: `${featureId} removed`,
|
|
})) {
|
|
throw new Error("Registry baseline failed to update after sample removal");
|
|
}
|
|
// 1103 X2 #3. The dev server's manifest names the installed contract
|
|
// packages; the removed feature's is gone.
|
|
const devManifest = spawnSync(process.execPath, ["scripts/write-dev-release-manifest.ts"], {
|
|
cwd: fixtureRoot,
|
|
stdio: "inherit",
|
|
});
|
|
if (devManifest.status !== 0) {
|
|
throw new Error("public/release-manifest.json failed to update after the removal");
|
|
}
|
|
// 1103 X2 #2. config/scale/feature-shape-ceilings.json records the initial
|
|
// JavaScript of the features installed now, and test:unit compares a build
|
|
// with it. A product re-records it when it adds a feature; removing that
|
|
// feature changes it again, so the fixture re-records it as the product
|
|
// would.
|
|
const measurement = path.join(fixtureRoot, "scripts/scale/measure-feature-shape-growth.ts");
|
|
if (await access(measurement).then(() => true, () => false)) {
|
|
const measured = spawnSync(
|
|
process.execPath,
|
|
[measurement, "--initial-baseline", "--write"],
|
|
{ cwd: fixtureRoot, stdio: "inherit" },
|
|
);
|
|
if (measured.status !== 0) {
|
|
throw new Error("Initial JavaScript record failed to update after the removal");
|
|
}
|
|
}
|
|
await regenerateRemovalFixtureWorkflow(fixtureRoot);
|
|
|
|
// 1105/16-04. Template tests use example feature IDs as data; only what
|
|
// still points at the removed feature counts (scripts/lib/feature-residue.ts).
|
|
// 0925 FOLLOW-UP 09-07. The drill runs no Playwright spec; one that still
|
|
// opens the feature's URL is found here instead of in FE-GATE-008.
|
|
const residue = await productFeatureResidue(
|
|
fixtureRoot,
|
|
featureId,
|
|
located.directory,
|
|
featureRoutePaths,
|
|
);
|
|
// 1105/16-04. The same whole-name rule as `src`: the template's bundle
|
|
// holds `data-product-feature`, which a substring search counted.
|
|
const builtResiduePattern = featureNamePattern(featureId, located.directory);
|
|
|
|
const missingCommonTests: string[] = [];
|
|
for (const testPath of commonTestPaths) {
|
|
await access(path.join(fixtureRoot, testPath)).catch(() => {
|
|
missingCommonTests.push(testPath);
|
|
});
|
|
}
|
|
const gateChecks = (prefix: string): RemovalCheck[] => [
|
|
check(`${prefix}typecheck`, "check:types"),
|
|
// 1103/14-04 (FOLLOW-UP 09-07). Merge and documentation gates the drill
|
|
// did not run: the documents, lint, screen text and design tokens can
|
|
// name or use what the removal deleted.
|
|
check(`${prefix}lint`, "lint"),
|
|
check(`${prefix}documentation`, "verify:documentation"),
|
|
check(`${prefix}i18n`, "check:i18n"),
|
|
check(`${prefix}design-system`, "check:design-system"),
|
|
check(`${prefix}architecture`, "check:architecture"),
|
|
check(`${prefix}registries`, "check:registries"),
|
|
// test:all ran here before coverage and ran its files twice. coverage
|
|
// holds every test:all path but the optional recipes'
|
|
// (tests/unit/removal-drill-test-paths.test.ts), so those run on their own.
|
|
check(`${prefix}coverage`, "test:coverage"),
|
|
...REMOVAL_DRILL_SUITES_OUTSIDE_COVERAGE
|
|
.filter((script) => Object.hasOwn(fixturePackage.scripts, script))
|
|
.map((script) => check(`${prefix}${script.replace(/^test:/u, "")}`, script)),
|
|
check(`${prefix}test-evidence-source`, "check:test-evidence:source"),
|
|
check(`${prefix}ci-contract`, "check:ci"),
|
|
check(`${prefix}home-smoke`, "exec", [
|
|
"vitest",
|
|
"run",
|
|
"tests/component/router.test.tsx",
|
|
"--reporter=default",
|
|
]),
|
|
check(`${prefix}build`, "build"),
|
|
];
|
|
const checks: RemovalCheck[] = [
|
|
outcome("common-test-evidence", missingCommonTests, "platform tests missing"),
|
|
...gateChecks(""),
|
|
];
|
|
const builtResidue: string[] = [];
|
|
const buildSucceeded =
|
|
checks.find(({ name }) => name === "build")?.passed === true;
|
|
if (buildSucceeded) {
|
|
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 (builtResiduePattern.test(content)) {
|
|
builtResidue.push(path.relative(fixtureRoot, file));
|
|
}
|
|
}
|
|
}
|
|
const routeCatalog = await import(
|
|
`${new URL(
|
|
"../src/features/installed-feature-contracts.ts",
|
|
`file://${fixtureRoot}/scripts/`,
|
|
).href}?removed=${Date.now()}`
|
|
) as { ROUTE_REGISTRY: Readonly<Record<string, unknown>> };
|
|
const routeIds = new Set(Object.keys(routeCatalog.ROUTE_REGISTRY));
|
|
checks.push(
|
|
outcome(
|
|
"route-absent",
|
|
featureRouteIds.filter((routeId) => routeIds.has(routeId)),
|
|
"routes still registered",
|
|
),
|
|
outcome("fixture-id-residue", residue, "residue"),
|
|
outcome("built-fixture-id-residue", builtResidue, "built residue"),
|
|
);
|
|
|
|
// U7 (decision 4). The same copy, now without the listed sample, gets one
|
|
// feature from create:feature and runs the same gates again: the command
|
|
// and the feature it writes need nothing from the sample.
|
|
if (isSample) {
|
|
// 1103/09-06. With the write slice (NEVER), which needs nothing from
|
|
// the sample either.
|
|
const created = check("scaffold-create-feature", "create:feature", [
|
|
"scaffold-feature",
|
|
"--with-create",
|
|
]);
|
|
checks.push(created);
|
|
if (created.passed) {
|
|
sealRemovalFixtureRepository(fixtureRoot);
|
|
checks.push(...gateChecks("scaffold-"));
|
|
}
|
|
}
|
|
|
|
const failed = checks.filter((entry) => !entry.passed);
|
|
await mkdir("artifacts/tests", { recursive: true });
|
|
await writeFile(
|
|
`artifacts/tests/feature-removal-${featureId}.xml`,
|
|
renderRemovalJunit(`${featureId}-removal`, checks),
|
|
);
|
|
if (failed.length > 0) {
|
|
process.stderr.write(
|
|
`${featureId} removal failed:\n${failed
|
|
.map((entry) => ` ${entry.name}: ${entry.failure ?? "failed"}`)
|
|
.join("\n")}\n`,
|
|
);
|
|
process.exitCode = 1;
|
|
} else {
|
|
process.stdout.write(
|
|
`${featureId} removal: PASS (${checks.length} checks, no fixture IDs)\n`,
|
|
);
|
|
}
|
|
} finally {
|
|
await rm(fixtureRoot, { recursive: true, force: true });
|
|
}
|