chore: sync the frontend template from ebea300 to af3d8e6
Carries 359 template commits, tag v0.2.0 plus one documentation commit: the generator-built feature index with its app, bounded-context and feature declarations, the src/platform kernel and scale tooling, the 2026-09-24 src review fixes, and the 2026-09-25 maturity review round with its CHANGELOG [보안]/[계약] rows. 691 of the 824 template paths are applied, 85 of them merged with product changes; 127 are not carried. Product identity is unchanged: name, version 0.1.0, routes, design and the TechLog domain. Three decisions worth naming. TechLog stays composed directly, as the last two syncs recorded; its directory carries a NOT_INSTALLED marker that says so, and every installed-* composer takes the template's projection with TechLog added on top. The reference sample is no longer installed: the template now installs a feature only through feature-module.ts and context-routes.ts, which load the screens this product deleted, so its three operations, six schemas and one topic leave the registries, recorded as registry change evidence. And AppRouter mounts the platform and TechLog routes only; the template's bounded-context route gateway waits for a generator-installed feature. Required fixes: readSubject on the BFF session owner (without it every HTTP Studio session would close as integration-failed), zod through the facade in nine TechLog files, noUnusedLocals, and public/config.json written out to match the local profile. Derived baselines were recomputed after reproducing both sides' values: CI contract 101 commands / 106 references / 141 artifacts, gate shape c9adcf85; registry approval 2dc6c3a3; the runtime config schema baseline equals the schema at8210d48. Verified here: types, lint, architecture, adapter inventory, CI contract, i18n, design system, diagnostics, browser security, dev release manifest, TechLog contract and build pass; 220 component, 155 integration, 15 contract, 418 TechLog, 43 reference-feature, 18 recipe and 46 release-coherence tests pass, and 2381 of 2383 unit tests. Reproduced at8210d48first and unchanged: check:registries (byte-identical), test:runtime-schema, verify:documentation. Brought by the template and escalated rather than suppressed: check:request-fanout on TechLog's cursor pagination, check:remediation-ledger (fails upstream too), the shared-chunk hash test, and the registry-dependent sample removal and second-feature tests. Playwright suites were not run. Full record, the five open questions and the follow-ups in docs/operations/template-sync-2026-09-29.md. (cherry picked from commit b2170cf265dea45dc9cc05d3c61e627e97f31cdb)
This commit is contained in:
+248
-294
@@ -1,32 +1,178 @@
|
||||
import {
|
||||
access,
|
||||
mkdir,
|
||||
mkdtemp,
|
||||
readdir,
|
||||
readFile,
|
||||
rm,
|
||||
writeFile,
|
||||
} from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
import { ROUTE_FEATURE_OWNER } from "../src/features/installed-feature-contracts.ts";
|
||||
import { createFileSystemDeclarationSource } from "./generate-product-feature-index.ts";
|
||||
import { isProductionModulePath } from "./lib/risk-coverage.ts";
|
||||
import {
|
||||
createRemovalFixtureRoot,
|
||||
filesBelow,
|
||||
prepareRemovalFixture,
|
||||
pruneRemovalFixtureCiContract,
|
||||
pruneScriptOrchestration,
|
||||
regenerateRemovalFixtureWorkflow,
|
||||
renderRemovalJunit,
|
||||
requireRemovalFixtureEnvironment,
|
||||
runRemovalFixtureCheck,
|
||||
runRemovalFixturePnpm,
|
||||
type RemovalCheck,
|
||||
} from "./lib/removal-fixture.ts";
|
||||
|
||||
const fixtureParent = path.resolve(".tmp");
|
||||
await mkdir(fixtureParent, { recursive: true });
|
||||
const fixtureRoot = await mkdtemp(
|
||||
path.join(fixtureParent, "reference-feature-removal-"),
|
||||
);
|
||||
/**
|
||||
* 09-07 (D-10). Removes one installed feature, `--feature=<id>` (default: the
|
||||
* reference sample), 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. The sample also
|
||||
* owns the extra paths and scripts listed in SAMPLE_EXTRAS.
|
||||
*/
|
||||
const featureId =
|
||||
process.argv.find((argument) => argument.startsWith("--feature="))
|
||||
?.slice("--feature=".length) ?? "reference-feature";
|
||||
|
||||
type FeatureExtras = Readonly<{
|
||||
paths: readonly string[];
|
||||
ciScripts: readonly string[];
|
||||
evidencePathFragments: readonly string[];
|
||||
residue: RegExp;
|
||||
}>;
|
||||
|
||||
const SAMPLE_EXTRAS: Readonly<Record<string, FeatureExtras>> = Object.freeze({
|
||||
"reference-feature": Object.freeze({
|
||||
paths: [
|
||||
"tests/integration/http-scenario-catalog.test.ts",
|
||||
"tests/component/product-feature-switch.test.tsx",
|
||||
// Template sync (ebea300). This TechLog test imports the sample feature's
|
||||
// contract contribution on purpose — it proves a 403 on *another*
|
||||
// feature's operation does not discard TechLog's CSRF token, which needs
|
||||
// a second feature to exist. With the sample gone the premise is gone,
|
||||
// so the test goes with it rather than being rewritten around a feature
|
||||
// that is not there.
|
||||
"tests/features/tech-log/studio-csrf-composition.test.ts",
|
||||
// Template sync (af3d8e6). The sample is not installed here (its
|
||||
// directory carries NOT_INSTALLED), so its bounded context owns no other
|
||||
// feature and goes with it, as upstream removes a context with its last
|
||||
// feature.
|
||||
"src/contexts/reference-context",
|
||||
"tests/e2e/reference-form.spec.ts",
|
||||
"tests/e2e/reference-route.spec.ts",
|
||||
"tests/e2e/reference-save.spec.ts",
|
||||
// 11-04: the growth measurement copies this sample feature.
|
||||
"tests/unit/feature-shape-growth.test.ts",
|
||||
"scripts/scale/measure-feature-shape-growth.ts",
|
||||
"config/scale/feature-shape-growth.json",
|
||||
"config/scale/feature-shape-ceilings.json",
|
||||
"tests/mocks",
|
||||
"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",
|
||||
"tests/fixtures/typecheck/tsconfig.feature-input.json",
|
||||
"tests/fixtures/typecheck/tsconfig.reference-operation.json",
|
||||
"tests/fixtures/typecheck/tsconfig.http-operation-input.json",
|
||||
"tests/fixtures/typecheck/tsconfig.http-wire-mapper.json",
|
||||
"tests/fixtures/typecheck/tsconfig.http-operation-id.json",
|
||||
"tests/fixtures/typecheck/tsconfig.http-route-id.json",
|
||||
"tests/fixtures/typecheck/tsconfig.feature-contribution-input.json",
|
||||
"tests/fixtures/typecheck/tsconfig.feature-capability-selection.json",
|
||||
],
|
||||
ciScripts: [
|
||||
"check:types:fixture:feature-input",
|
||||
"check:types:fixture:reference-operation",
|
||||
"check:types:fixture:http-operation-input",
|
||||
"check:types:fixture:http-wire-mapper",
|
||||
"check:types:fixture:http-operation-id",
|
||||
"check:types:fixture:http-route-id",
|
||||
"check:types:fixture:feature-contribution-input",
|
||||
"check:types:fixture:feature-capability-selection",
|
||||
"test:http-scenario-evidence",
|
||||
"test:reference-feature",
|
||||
],
|
||||
evidencePathFragments: [
|
||||
"reference-feature.xml",
|
||||
"http-scenario-executions",
|
||||
"http-scenario-evidence",
|
||||
],
|
||||
residue: /REFERENCE_RESOURCE|reference-feature|reference-resource/i,
|
||||
}),
|
||||
});
|
||||
|
||||
function escapeRegExp(value: string): string {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&");
|
||||
}
|
||||
|
||||
async function locateFeature(id: string) {
|
||||
// Template sync (af3d8e6). A feature directory marked NOT_INSTALLED is not
|
||||
// declared to the generator, so it has no context to look up; its directory
|
||||
// is still what removal deletes. This product's sample is in that state.
|
||||
const marker = await access(path.join("src/features", id, "NOT_INSTALLED")).then(
|
||||
() => true,
|
||||
() => false,
|
||||
);
|
||||
if (marker) {
|
||||
return Object.freeze({ directory: id, contextDirectory: null });
|
||||
}
|
||||
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);
|
||||
const extras: FeatureExtras = SAMPLE_EXTRAS[featureId] ?? Object.freeze({
|
||||
paths: [],
|
||||
ciScripts: [],
|
||||
evidencePathFragments: [],
|
||||
residue: new RegExp(
|
||||
`${escapeRegExp(featureId)}|${escapeRegExp(located.directory)}`,
|
||||
"i",
|
||||
),
|
||||
});
|
||||
// Captured from this repository before the copy loses them.
|
||||
const featureRouteIds = Object.entries(ROUTE_FEATURE_OWNER)
|
||||
.filter(([, owner]) => owner === featureId)
|
||||
.map(([routeId]) => routeId);
|
||||
|
||||
const fixtureRoot = await createRemovalFixtureRoot(`${featureId}-removal`);
|
||||
const pnpmCli = requireRemovalFixtureEnvironment("npm_execpath");
|
||||
const featureSource = "src/features/reference-feature";
|
||||
const featureTests = "tests/features/reference-feature";
|
||||
const featureSource = `src/features/${located.directory}`;
|
||||
const featureTests = `tests/features/${located.directory}`;
|
||||
const isSample = featureId in SAMPLE_EXTRAS;
|
||||
/**
|
||||
* 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
|
||||
@@ -41,165 +187,12 @@ const commonTestPaths = [
|
||||
const featureOwnedPaths = [
|
||||
featureSource,
|
||||
featureTests,
|
||||
"tests/integration/http-scenario-catalog.test.ts",
|
||||
"tests/features/tech-log/runtime-composition.test.ts",
|
||||
// Template sync (ebea300). The kill-switch test attributes a real route to a
|
||||
// real installed feature id; with the sample feature gone there is no
|
||||
// installed feature left to attribute to, so it goes with it.
|
||||
"tests/component/product-feature-switch.test.tsx",
|
||||
// Same sync. This TechLog test imports the sample feature's contract
|
||||
// contribution on purpose — it proves a 403 on *another* feature's operation
|
||||
// does not discard TechLog's CSRF token, which needs a second feature to
|
||||
// exist. With the sample feature gone the premise is gone, so the test goes
|
||||
// with it rather than being rewritten around a feature that is not there.
|
||||
"tests/features/tech-log/studio-csrf-composition.test.ts",
|
||||
"tests/e2e/reference-form.spec.ts",
|
||||
"tests/e2e/reference-route.spec.ts",
|
||||
"tests/mocks",
|
||||
"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",
|
||||
"tests/fixtures/typecheck/tsconfig.feature-input.json",
|
||||
"tests/fixtures/typecheck/tsconfig.reference-operation.json",
|
||||
"tests/fixtures/typecheck/tsconfig.http-operation-input.json",
|
||||
"tests/fixtures/typecheck/tsconfig.http-wire-mapper.json",
|
||||
"tests/fixtures/typecheck/tsconfig.http-operation-id.json",
|
||||
"tests/fixtures/typecheck/tsconfig.http-route-id.json",
|
||||
"tests/fixtures/typecheck/tsconfig.feature-contribution-input.json",
|
||||
"tests/fixtures/typecheck/tsconfig.feature-capability-selection.json",
|
||||
// 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,
|
||||
];
|
||||
|
||||
const emptyProductManifest = `export const COMPILED_PRODUCT_FEATURE_IDS: readonly string[] = Object.freeze([]);
|
||||
export const INSTALLED_PRODUCT_FEATURES: readonly never[] = Object.freeze([]);
|
||||
export const INSTALLED_PRODUCT_FEATURE_IDS: readonly string[] = Object.freeze([]);
|
||||
`;
|
||||
|
||||
const emptyContracts = `import type { RouteDefinition } from "../contracts/routes.ts";
|
||||
import { PLATFORM_SCHEMA_REGISTRY } from "../contracts/schema-registry.ts";
|
||||
import { INSTALLED_PRODUCT_FEATURES } from "./installed-product-manifest.ts";
|
||||
import {
|
||||
TECH_LOG_ROUTE_REGISTRY,
|
||||
TECH_LOG_ROUTE_RUNTIME_CONTRACT,
|
||||
TECH_LOG_ROUTE_SCHEMA_REGISTRY,
|
||||
} from "./tech-log/contracts/tech-log-route-contract.ts";
|
||||
|
||||
export const INSTALLED_FEATURE_CONTRACTS = INSTALLED_PRODUCT_FEATURES;
|
||||
export const ROUTE_REGISTRY = TECH_LOG_ROUTE_REGISTRY;
|
||||
export const ROUTE_RUNTIME_CONTRACT = TECH_LOG_ROUTE_RUNTIME_CONTRACT;
|
||||
export const API_OPERATIONS = Object.freeze({});
|
||||
export const INVALIDATION_REGISTRY = Object.freeze({
|
||||
topics: Object.freeze([]),
|
||||
namespaces: Object.freeze([]),
|
||||
edges: Object.freeze([]),
|
||||
});
|
||||
export const INVALIDATION_TOPIC_VERSIONS = Object.freeze([]);
|
||||
export const SCHEMA_REGISTRY = Object.freeze({
|
||||
...PLATFORM_SCHEMA_REGISTRY,
|
||||
...TECH_LOG_ROUTE_SCHEMA_REGISTRY,
|
||||
});
|
||||
export const ROUTE_FEATURE_OWNER: Readonly<Record<string, string>> = Object.freeze({});
|
||||
export const NAVIGATION_ROUTES = Object.freeze(
|
||||
Object.values(ROUTE_REGISTRY)
|
||||
.filter((definition) => definition.navigationOrder !== null)
|
||||
.sort(
|
||||
(left, right) =>
|
||||
left.navigationOrder! - right.navigationOrder!,
|
||||
),
|
||||
);
|
||||
export function getRoute(routeId: string): RouteDefinition {
|
||||
const registry = ROUTE_REGISTRY as Readonly<Record<string, RouteDefinition>>;
|
||||
const selected = registry[routeId];
|
||||
if (!selected) throw new Error(\`Unregistered route: \${routeId}\`);
|
||||
return selected;
|
||||
}
|
||||
export function routePath(routeId: string): string {
|
||||
return getRoute(routeId).path;
|
||||
}
|
||||
`;
|
||||
|
||||
const emptyRuntimes = `import { PLATFORM_ROUTE_CODECS } from "../presentation/routes/platform-route-codecs.ts";
|
||||
import { TECH_LOG_ROUTE_CODECS } from "./tech-log/presentation/tech-log-route-codecs.ts";
|
||||
import { TECH_LOG_ROUTE_RUNTIME } from "./tech-log/presentation/tech-log-route-runtime.tsx";
|
||||
|
||||
export const ROUTE_CODECS = Object.freeze({
|
||||
...PLATFORM_ROUTE_CODECS,
|
||||
...TECH_LOG_ROUTE_CODECS,
|
||||
});
|
||||
export const ROUTE_RUNTIME = TECH_LOG_ROUTE_RUNTIME;
|
||||
`;
|
||||
|
||||
const emptyAdapters = `import type { InstalledHttpOperationExecutor } from "../adapters/http/index.ts";
|
||||
import type { ApplicationFeatureInputs } from "../application/ports/in/application-api.ts";
|
||||
import {
|
||||
composeFeatureAdapterInputs,
|
||||
type InstalledFeatureInputs,
|
||||
} from "./feature-adapter-contribution.ts";
|
||||
import { INSTALLED_PRODUCT_FEATURE_IDS } from "./installed-product-manifest.ts";
|
||||
import {
|
||||
createTechLogFeatureInstalledInput,
|
||||
type TechLogInstallContext,
|
||||
} from "./tech-log/adapters/create-tech-log-feature-input.ts";
|
||||
import { TECH_LOG_FEATURE_ID } from "./tech-log/application/tech-log-feature-input.ts";
|
||||
|
||||
const COMPILED_FEATURE_ADAPTER_CONTRIBUTIONS = Object.freeze([] as const);
|
||||
|
||||
type ProductFeatureInputs = InstalledFeatureInputs &
|
||||
Readonly<Pick<ApplicationFeatureInputs, typeof TECH_LOG_FEATURE_ID>>;
|
||||
|
||||
export function createInstalledFeatureInputs(
|
||||
context: TechLogInstallContext &
|
||||
Readonly<{ http: InstalledHttpOperationExecutor }>,
|
||||
): ProductFeatureInputs {
|
||||
const techLog = createTechLogFeatureInstalledInput(context);
|
||||
return Object.freeze({
|
||||
...composeFeatureAdapterInputs(
|
||||
COMPILED_FEATURE_ADAPTER_CONTRIBUTIONS,
|
||||
INSTALLED_PRODUCT_FEATURE_IDS,
|
||||
context,
|
||||
),
|
||||
[techLog.featureId]: techLog.input,
|
||||
}) as ProductFeatureInputs;
|
||||
}
|
||||
`;
|
||||
|
||||
const emptyContractContributions = `import {
|
||||
composeContractContributions,
|
||||
type InstalledContractContribution,
|
||||
type InstalledContractPackageIdentity,
|
||||
} from "../contracts/external-contract-runtime.ts";
|
||||
import { INSTALLED_PRODUCT_FEATURE_IDS } from "./installed-product-manifest.ts";
|
||||
|
||||
const COMPILED_CONTRACT_CONTRIBUTIONS: readonly InstalledContractContribution[] =
|
||||
Object.freeze([]);
|
||||
|
||||
export const INSTALLED_CONTRACT_CONTRIBUTIONS: readonly InstalledContractContribution[] =
|
||||
Object.freeze(
|
||||
COMPILED_CONTRACT_CONTRIBUTIONS.filter((contribution) =>
|
||||
INSTALLED_PRODUCT_FEATURE_IDS.includes(contribution.featureId),
|
||||
),
|
||||
);
|
||||
|
||||
export const COMPOSED_CONTRACT_CONTRIBUTIONS = composeContractContributions(
|
||||
INSTALLED_CONTRACT_CONTRIBUTIONS,
|
||||
);
|
||||
|
||||
export const EXPECTED_CONTRACT_SET_PACKAGES: readonly InstalledContractPackageIdentity[] =
|
||||
COMPOSED_CONTRACT_CONTRIBUTIONS.externalPackages;
|
||||
`;
|
||||
|
||||
const emptyMessages = `import { TECH_LOG_MESSAGE_CATALOGS } from "./tech-log/contracts/tech-log-message-catalog.ts";
|
||||
|
||||
export const INSTALLED_MESSAGE_CATALOGS = Object.freeze({
|
||||
"ko-KR": TECH_LOG_MESSAGE_CATALOGS["ko-KR"],
|
||||
"en-US": TECH_LOG_MESSAGE_CATALOGS["en-US"],
|
||||
});
|
||||
`;
|
||||
|
||||
type CoveragePolicy = {
|
||||
repositoryBaseline: number;
|
||||
generatedPaths: string[];
|
||||
@@ -227,13 +220,21 @@ 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 {
|
||||
await prepareRemovalFixture(fixtureRoot);
|
||||
for (const excludedFixtureTest of [
|
||||
"tests/integration/security-followup-archive.test.ts",
|
||||
// Template sync (ebea300). `ci-artifact-contract` moved to
|
||||
// `tests/system/ci-runner/`, which `test:all` does not run, so it no longer
|
||||
// needs excluding — upstream dropped it from this list for the same reason.
|
||||
"tests/unit/ci-workflow-generation.test.ts",
|
||||
"tests/unit/__snapshots__/ci-workflow-generation.test.ts.snap",
|
||||
"tests/unit/removal-fixture.test.ts",
|
||||
@@ -267,52 +268,29 @@ try {
|
||||
force: true,
|
||||
});
|
||||
}
|
||||
await writeFile(
|
||||
path.join(fixtureRoot, "src/features/installed-product-manifest.ts"),
|
||||
emptyProductManifest,
|
||||
);
|
||||
await writeFile(
|
||||
path.join(fixtureRoot, "src/features/installed-feature-contracts.ts"),
|
||||
emptyContracts,
|
||||
);
|
||||
await writeFile(
|
||||
path.join(fixtureRoot, "src/features/installed-feature-runtimes.tsx"),
|
||||
emptyRuntimes,
|
||||
);
|
||||
await writeFile(
|
||||
path.join(fixtureRoot, "src/features/installed-feature-adapters.ts"),
|
||||
emptyAdapters,
|
||||
);
|
||||
await writeFile(
|
||||
path.join(fixtureRoot, "src/features/installed-feature-messages.ts"),
|
||||
emptyMessages,
|
||||
);
|
||||
await writeFile(
|
||||
path.join(fixtureRoot, "src/features/installed-contract-contributions.ts"),
|
||||
emptyContractContributions,
|
||||
);
|
||||
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.
|
||||
for (const profile of [
|
||||
"local",
|
||||
"development",
|
||||
"staging",
|
||||
"production",
|
||||
] as const) {
|
||||
const profilePath = path.join(
|
||||
fixtureRoot,
|
||||
"config/runtime",
|
||||
`${profile}.json`,
|
||||
);
|
||||
// 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["reference-feature"];
|
||||
delete runtimeConfig.FEATURE_OVERRIDES[featureId];
|
||||
}
|
||||
await writeFile(
|
||||
profilePath,
|
||||
@@ -324,6 +302,7 @@ try {
|
||||
(modulePolicy) => !modulePolicy.path?.startsWith(`${featureSource}/`),
|
||||
);
|
||||
if (
|
||||
isSample &&
|
||||
retainedCriticalModules.length === coveragePolicy.criticalModules.length
|
||||
) {
|
||||
throw new Error("Reference feature coverage policy is not registered");
|
||||
@@ -362,12 +341,12 @@ try {
|
||||
}
|
||||
evidencePolicy[policyKey] = contributions.filter((candidate: unknown) => {
|
||||
const contribution = candidate as EvidenceContribution;
|
||||
const retained = contribution.owner !== "reference-feature";
|
||||
const retained = contribution.owner !== featureId;
|
||||
if (!retained) removedEvidenceContributions += 1;
|
||||
return retained;
|
||||
});
|
||||
}
|
||||
if (removedEvidenceContributions === 0) {
|
||||
if (isSample && removedEvidenceContributions === 0) {
|
||||
throw new Error("Reference feature test evidence policy is not registered");
|
||||
}
|
||||
await writeFile(
|
||||
@@ -390,7 +369,7 @@ try {
|
||||
consumers: registry.consumers.filter(
|
||||
(candidate: unknown) => {
|
||||
const consumer = candidate as GovernanceConsumer;
|
||||
return !consumer.path?.includes("features/reference-feature");
|
||||
return !consumer.path?.includes(featureSource);
|
||||
},
|
||||
),
|
||||
}
|
||||
@@ -400,7 +379,7 @@ try {
|
||||
consumerDirectories: registry.consumerDirectories.filter(
|
||||
(directory: unknown) =>
|
||||
typeof directory !== "string" ||
|
||||
!directory.includes("features/reference-feature"),
|
||||
!directory.includes(featureSource),
|
||||
),
|
||||
}
|
||||
: {}),
|
||||
@@ -411,37 +390,31 @@ try {
|
||||
`${JSON.stringify(removalGovernance, null, 2)}\n`,
|
||||
);
|
||||
|
||||
const removedCiScripts = new Set([
|
||||
"check:types:fixture:feature-input",
|
||||
"check:types:fixture:reference-operation",
|
||||
"check:types:fixture:http-operation-input",
|
||||
"check:types:fixture:http-wire-mapper",
|
||||
"check:types:fixture:http-operation-id",
|
||||
"check:types:fixture:http-route-id",
|
||||
"check:types:fixture:feature-contribution-input",
|
||||
"check:types:fixture:feature-capability-selection",
|
||||
"test:http-scenario-evidence",
|
||||
"test:reference-feature",
|
||||
]);
|
||||
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);
|
||||
fixturePackage.scripts["test:coverage"] = fixturePackage.scripts["test:coverage"]
|
||||
.replace(" tests/features/reference-feature", "");
|
||||
delete fixturePackage.scripts["check:http-scenario-evidence"];
|
||||
delete fixturePackage.scripts["check:http-scenario-evidence:fixture"];
|
||||
if (isSample) {
|
||||
delete fixturePackage.scripts["check:http-scenario-evidence"];
|
||||
delete fixturePackage.scripts["check:http-scenario-evidence:fixture"];
|
||||
}
|
||||
await writeFile(fixturePackagePath, `${JSON.stringify(fixturePackage, null, 2)}\n`);
|
||||
await pruneRemovalFixtureCiContract({
|
||||
root: fixtureRoot,
|
||||
removedScripts: removedCiScripts,
|
||||
removedEvidencePathFragments: [
|
||||
"reference-feature.xml",
|
||||
"http-scenario-executions",
|
||||
"http-scenario-evidence",
|
||||
],
|
||||
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");
|
||||
}
|
||||
await regenerateRemovalFixtureWorkflow(fixtureRoot);
|
||||
|
||||
const residue: string[] = [];
|
||||
@@ -449,60 +422,43 @@ try {
|
||||
for (const file of await filesBelow(path.join(fixtureRoot, root))) {
|
||||
const relative = path.relative(fixtureRoot, file);
|
||||
const content = await readFile(file, "utf8");
|
||||
if (
|
||||
/REFERENCE_RESOURCE|reference-feature|reference-resource/i.test(
|
||||
`${relative}\n${content}`,
|
||||
)
|
||||
) {
|
||||
if (extras.residue.test(`${relative}\n${content}`)) {
|
||||
residue.push(relative);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const checks: Array<[string, boolean]> = [
|
||||
[
|
||||
"common-test-evidence",
|
||||
(
|
||||
await Promise.all(
|
||||
commonTestPaths.map(async (testPath) => {
|
||||
try {
|
||||
await access(path.join(fixtureRoot, testPath));
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}),
|
||||
)
|
||||
).every(Boolean),
|
||||
],
|
||||
["typecheck", runPnpm("check:types")],
|
||||
["architecture", runPnpm("check:architecture")],
|
||||
["registry-structure", runPnpm("check:registries:structure")],
|
||||
["unit-integration", runPnpm("test:all")],
|
||||
["coverage", runPnpm("test:coverage")],
|
||||
["test-evidence-source", runPnpm("check:test-evidence:source")],
|
||||
["ci-contract", runPnpm("check:ci")],
|
||||
[
|
||||
"home-smoke",
|
||||
runPnpm("exec", [
|
||||
"vitest",
|
||||
"run",
|
||||
"tests/component/router.test.tsx",
|
||||
"--reporter=default",
|
||||
]),
|
||||
],
|
||||
["build", runPnpm("build")],
|
||||
const missingCommonTests: string[] = [];
|
||||
for (const testPath of commonTestPaths) {
|
||||
await access(path.join(fixtureRoot, testPath)).catch(() => {
|
||||
missingCommonTests.push(testPath);
|
||||
});
|
||||
}
|
||||
const checks: RemovalCheck[] = [
|
||||
outcome("common-test-evidence", missingCommonTests, "platform tests missing"),
|
||||
check("typecheck", "check:types"),
|
||||
check("architecture", "check:architecture"),
|
||||
check("registries", "check:registries"),
|
||||
check("unit-integration", "test:all"),
|
||||
check("coverage", "test:coverage"),
|
||||
check("test-evidence-source", "check:test-evidence:source"),
|
||||
check("ci-contract", "check:ci"),
|
||||
check("home-smoke", "exec", [
|
||||
"vitest",
|
||||
"run",
|
||||
"tests/component/router.test.tsx",
|
||||
"--reporter=default",
|
||||
]),
|
||||
check("build", "build"),
|
||||
];
|
||||
const builtResidue: string[] = [];
|
||||
const buildSucceeded =
|
||||
checks.find(([name]) => name === "build")?.[1] === true;
|
||||
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 (
|
||||
/REFERENCE_RESOURCE|reference-feature|reference-resource/i.test(content)
|
||||
) {
|
||||
if (extras.residue.test(content)) {
|
||||
builtResidue.push(path.relative(fixtureRoot, file));
|
||||
}
|
||||
}
|
||||
@@ -513,37 +469,35 @@ try {
|
||||
`file://${fixtureRoot}/scripts/`,
|
||||
).href}?removed=${Date.now()}`
|
||||
) as { ROUTE_REGISTRY: Readonly<Record<string, unknown>> };
|
||||
const routeIds = Object.keys(routeCatalog.ROUTE_REGISTRY);
|
||||
const routeAbsent = routeIds.every((routeId) => !routeId.startsWith("REFERENCE_"));
|
||||
checks.push(["route-absent", routeAbsent]);
|
||||
checks.push(["fixture-id-residue", residue.length === 0]);
|
||||
checks.push(["built-fixture-id-residue", builtResidue.length === 0]);
|
||||
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"),
|
||||
);
|
||||
|
||||
const passed = checks.every(([, result]) => result);
|
||||
const failed = checks.filter((entry) => !entry.passed);
|
||||
await mkdir("artifacts/tests", { recursive: true });
|
||||
await writeFile(
|
||||
"artifacts/tests/sample-removal.xml",
|
||||
`<?xml version="1.0" encoding="UTF-8"?>\n` +
|
||||
`<testsuite name="reference-feature-removal" tests="${checks.length}" failures="${passed ? 0 : 1}">` +
|
||||
checks
|
||||
.map(
|
||||
([name, result]) =>
|
||||
`<testcase name="${name}">${result ? "" : `<failure>${[...residue, ...builtResidue].join(", ")}</failure>`}</testcase>`,
|
||||
)
|
||||
.join("") +
|
||||
`</testsuite>\n`,
|
||||
isSample
|
||||
? "artifacts/tests/sample-removal.xml"
|
||||
: `artifacts/tests/feature-removal-${featureId}.xml`,
|
||||
renderRemovalJunit(`${featureId}-removal`, checks),
|
||||
);
|
||||
if (!passed) {
|
||||
const failures = checks
|
||||
.filter(([, result]) => !result)
|
||||
.map(([name]) => name);
|
||||
if (failed.length > 0) {
|
||||
process.stderr.write(
|
||||
`Reference feature removal failed: ${failures.join(", ")}; residue: ${[...residue, ...builtResidue].join(", ")}\n`,
|
||||
`${featureId} removal failed:\n${failed
|
||||
.map((entry) => ` ${entry.name}: ${entry.failure ?? "failed"}`)
|
||||
.join("\n")}\n`,
|
||||
);
|
||||
process.exitCode = 1;
|
||||
} else {
|
||||
process.stdout.write(
|
||||
`Reference feature removal: PASS (${checks.length} checks, no fixture IDs)\n`,
|
||||
`${featureId} removal: PASS (${checks.length} checks, no fixture IDs)\n`,
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user