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)
182 lines
6.2 KiB
TypeScript
182 lines
6.2 KiB
TypeScript
import { spawnSync } from "node:child_process";
|
|
import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
|
|
import { afterAll, describe, expect, it } from "vitest";
|
|
|
|
import { linkFixtureNodeModules } from "../../scripts/lib/fixture-node-modules.ts";
|
|
|
|
/**
|
|
* 09-01. The central composers (`src/features/installed-*`) are typed from the
|
|
* generated feature index, so the repository's own typecheck only ever sees
|
|
* the features it ships. This installs two more into a copy of `src`, in a
|
|
* context of their own so the check survives the sample's removal: one with a
|
|
* route, a runtime and both locales but no adapter, and one shaped differently
|
|
* on every composed axis (an adapter that needs telemetry, no routes, no
|
|
* runtime, one locale). It regenerates the index
|
|
* with the production generator and runs the app typecheck over the copy.
|
|
*/
|
|
const SECOND_FEATURE_MODULE = `import { defineFeatureAdapterContribution } from "../feature-adapter-contribution.ts";
|
|
import { defineFeatureModule } from "../feature-module.ts";
|
|
|
|
type SecondFeatureInput = Readonly<{ ping(): string }>;
|
|
|
|
declare module "../../application/ports/in/application-api.ts" {
|
|
interface ApplicationFeatureInputs {
|
|
"second-feature": SecondFeatureInput;
|
|
}
|
|
}
|
|
|
|
export const FEATURE_MODULE_ID = "second-feature";
|
|
export const FEATURE_CONTEXT_ID = "two-feature-context";
|
|
|
|
export const FEATURE_MODULE = defineFeatureModule({
|
|
id: FEATURE_MODULE_ID,
|
|
contracts: {
|
|
featureId: FEATURE_MODULE_ID,
|
|
routes: {},
|
|
routeRuntimeContracts: {},
|
|
apiOperations: {},
|
|
// Frozen empty arrays type as \`readonly never[]\`, not \`readonly []\`.
|
|
invalidation: {
|
|
topics: Object.freeze([]),
|
|
namespaces: Object.freeze([]),
|
|
edges: Object.freeze([]),
|
|
},
|
|
topicVersions: Object.freeze([]),
|
|
schemas: {},
|
|
runtimeSchemas: {},
|
|
mappers: {},
|
|
},
|
|
routes: {},
|
|
adapters: [
|
|
defineFeatureAdapterContribution({
|
|
featureId: FEATURE_MODULE_ID,
|
|
needs: ["telemetry"] as const,
|
|
createInput: () =>
|
|
Object.freeze({
|
|
featureId: FEATURE_MODULE_ID,
|
|
input: Object.freeze({ ping: () => "pong" }),
|
|
}),
|
|
}),
|
|
],
|
|
runtimes: [],
|
|
messages: { "en-US": { "secondFeature.title": "Second feature" } },
|
|
contractContributions: [],
|
|
} as const);
|
|
`;
|
|
|
|
const SECOND_FEATURE_ROUTES = `import type { RouteObject } from "react-router-dom";
|
|
|
|
export const FEATURE_CONTEXT_ROUTES: readonly RouteObject[] = Object.freeze([]);
|
|
`;
|
|
|
|
const ROUTED_FEATURE_MODULE = `import { defineFeatureModule } from "../feature-module.ts";
|
|
|
|
export const FEATURE_MODULE_ID = "routed-feature";
|
|
export const FEATURE_CONTEXT_ID = "two-feature-context";
|
|
|
|
const ROUTES = {
|
|
ROUTED_ITEMS: {
|
|
routeId: "ROUTED_ITEMS",
|
|
path: "/two-feature/items",
|
|
paramsSchema: null,
|
|
searchSchema: null,
|
|
access: "public",
|
|
loadingSurface: "routed-items",
|
|
errorSurface: "feature-boundary",
|
|
chunkId: "route-routed-items",
|
|
title: "route.ROUTED_ITEMS.title",
|
|
navigationLabel: null,
|
|
navigationOrder: null,
|
|
},
|
|
} as const;
|
|
|
|
const MESSAGES = {
|
|
"route.ROUTED_ITEMS.title": "Routed items",
|
|
"route.ROUTED_ITEMS.navigation": "Routed items",
|
|
} as const;
|
|
|
|
export const FEATURE_MODULE = defineFeatureModule({
|
|
id: FEATURE_MODULE_ID,
|
|
contracts: {
|
|
featureId: FEATURE_MODULE_ID,
|
|
routes: ROUTES,
|
|
routeRuntimeContracts: {
|
|
ROUTED_ITEMS: {
|
|
routeId: "ROUTED_ITEMS",
|
|
moduleId: "routed-items-page",
|
|
paramsCodec: "none",
|
|
searchCodec: "none",
|
|
},
|
|
},
|
|
apiOperations: {},
|
|
invalidation: { topics: [], namespaces: [], edges: [] },
|
|
topicVersions: [],
|
|
schemas: {},
|
|
runtimeSchemas: {},
|
|
mappers: {},
|
|
},
|
|
routes: ROUTES,
|
|
adapters: [],
|
|
runtimes: [{ featureId: FEATURE_MODULE_ID, routeCodecs: {}, routeRuntime: {} }],
|
|
messages: { "ko-KR": MESSAGES, "en-US": MESSAGES },
|
|
contractContributions: [],
|
|
} as const);
|
|
`;
|
|
|
|
const CONTEXT_MODULE = `export const CONTEXT_MODULE_ID = "two-feature-context";
|
|
export const CONTEXT_APP_ID = "template-app";
|
|
export const CONTEXT_ROUTE_PATH = "two-feature/*";
|
|
export const CONTEXT_MAX_FEATURES = 2;
|
|
`;
|
|
|
|
const roots: string[] = [];
|
|
|
|
afterAll(async () => {
|
|
await Promise.all(roots.map((root) => rm(root, { recursive: true, force: true })));
|
|
});
|
|
|
|
describe("installing a second feature (09-01)", () => {
|
|
it("keeps the app typecheck green with two differently shaped features", async () => {
|
|
const root = await mkdtemp(path.join(tmpdir(), "two-feature-install-"));
|
|
roots.push(root);
|
|
await cp(path.resolve("src"), path.join(root, "src"), { recursive: true });
|
|
for (const config of ["tsconfig.base.json", "tsconfig.app.json"]) {
|
|
await cp(path.resolve(config), path.join(root, config));
|
|
}
|
|
await linkFixtureNodeModules(root);
|
|
const files: Readonly<Record<string, string>> = {
|
|
"src/contexts/two-feature-context/context-module.ts": CONTEXT_MODULE,
|
|
"src/features/routed-feature/feature-module.ts": ROUTED_FEATURE_MODULE,
|
|
"src/features/routed-feature/context-routes.ts": SECOND_FEATURE_ROUTES,
|
|
"src/features/second-feature/feature-module.ts": SECOND_FEATURE_MODULE,
|
|
"src/features/second-feature/context-routes.ts": SECOND_FEATURE_ROUTES,
|
|
};
|
|
for (const [file, content] of Object.entries(files)) {
|
|
await mkdir(path.dirname(path.join(root, file)), { recursive: true });
|
|
await writeFile(path.join(root, file), content);
|
|
}
|
|
|
|
const generated = spawnSync(
|
|
process.execPath,
|
|
[path.resolve("scripts/generate-product-feature-index.ts"), `--root=${root}`],
|
|
{ encoding: "utf8" },
|
|
);
|
|
expect(generated.stderr).toBe("");
|
|
expect(generated.status).toBe(0);
|
|
const index = await readFile(path.join(root, "src/.generated/product-feature-index.ts"), "utf8");
|
|
expect(index).toContain("../features/second-feature/feature-module.ts");
|
|
expect(index).toContain("../features/routed-feature/feature-module.ts");
|
|
|
|
const typecheck = spawnSync(
|
|
path.resolve("node_modules/.bin/tsc"),
|
|
["--project", path.join(root, "tsconfig.app.json")],
|
|
{ encoding: "utf8" },
|
|
);
|
|
expect(typecheck.stdout + typecheck.stderr).toBe("");
|
|
expect(typecheck.status).toBe(0);
|
|
}, 60_000);
|
|
});
|