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 at 8210d48.

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 at
8210d48 first 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:
DongHyeonka
2026-11-12 08:28:54 +09:00
parent 585c62431a
commit c80320dfc7
738 changed files with 55027 additions and 13567 deletions
@@ -0,0 +1,246 @@
import { rm } from "node:fs/promises";
import { afterEach, describe, expect, it } from "vitest";
import {
generateAppIndexes,
renderContextIndex,
renderFeatureIndex,
selectAppIndexes,
type TopologyDeclarationSource,
} from "../../scripts/generate-product-feature-index.ts";
describe("feature index generator", () => {
it("is deterministic by normalized id", () => {
const first = renderFeatureIndex([
{ id: "zeta", importPath: "../features/zeta/feature-module.ts" },
{ id: "alpha", importPath: "../features/alpha/feature-module.ts" },
]);
const second = renderFeatureIndex([
{ id: "alpha", importPath: "../features/alpha/feature-module.ts" },
{ id: "zeta", importPath: "../features/zeta/feature-module.ts" },
]);
expect(first).toBe(second);
expect(first.indexOf("alpha")).toBeLessThan(first.indexOf("zeta"));
});
it("emits a base feature module fallback for an empty product", () => {
const rendered = renderFeatureIndex([]);
expect(rendered).toContain(
'import type { FeatureModule } from "../features/feature-module.ts";',
);
expect(rendered).toContain("type GeneratedProductFeatureModule =");
expect(rendered).toContain(
"[GeneratedProductFeatureModule] extends [never]",
);
expect(rendered).toContain("? FeatureModule");
});
it("groups feature route executables behind one lazy context loader", () => {
const rendered = renderContextIndex([
{
id: "catalog-search",
importPath: "../features/catalog-search/feature-module.ts",
directory: "catalog-search",
contextId: "catalog",
contextRoutePath: "catalog/*",
contextMaxFeatures: 200,
},
{
id: "catalog-detail",
importPath: "../features/catalog-detail/feature-module.ts",
directory: "catalog-detail",
contextId: "catalog",
contextRoutePath: "catalog/*",
contextMaxFeatures: 200,
},
]);
expect(rendered.match(/defineBoundedContextModule\(\{/gu)).toHaveLength(1);
expect(rendered).toContain(
'import("../features/catalog-search/context-routes.ts")',
);
expect(rendered).toContain(
'import("../features/catalog-detail/context-routes.ts")',
);
expect(rendered).not.toContain(
'from "../features/catalog-search/context-routes.ts"',
);
expect(rendered).not.toContain(
'from "../features/catalog-detail/context-routes.ts"',
);
});
it("emits no context loader for an empty product", () => {
expect(renderContextIndex([])).toBe(
"// Generated by scripts/generate-product-feature-index.ts. Do not edit by hand.\n" +
"export const PRODUCT_CONTEXT_MODULES = Object.freeze([] as const);\n",
);
});
});
describe("app-scoped selection from ownership declarations", () => {
// 00-03. The fake repositories used to stay in /tmp.
const temporaryRoots: string[] = [];
afterEach(async () => {
await Promise.all(
temporaryRoots.splice(0).map((root) => rm(root, { recursive: true, force: true })),
);
});
async function repo(files: Record<string, string>) {
const { mkdtemp, mkdir, writeFile } = await import("node:fs/promises");
const { tmpdir } = await import("node:os");
const path = await import("node:path");
const root = await mkdtemp(path.join(tmpdir(), "generator-"));
temporaryRoots.push(root);
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);
}
return root;
}
const app = (id: string, max = 20) =>
`export const APP_MODULE_ID = "${id}";\nexport const APP_MAX_CONTEXTS = ${max};\n`;
const context = (id: string, appId: string, max = 200) =>
`export const CONTEXT_MODULE_ID = "${id}";\nexport const CONTEXT_APP_ID = "${appId}";\n` +
`export const CONTEXT_ROUTE_PATH = "${id}/*";\nexport const CONTEXT_MAX_FEATURES = ${max};\n`;
const feature = (id: string, contextId: string) =>
`export const FEATURE_MODULE_ID = "${id}";\nexport const FEATURE_CONTEXT_ID = "${contextId}";\n`;
it("rejects a feature owned by an undeclared context", async () => {
const root = await repo({
"src/apps/a/app-module.ts": app("a"),
"src/features/f/feature-module.ts": feature("f", "missing"),
});
await expect(generateAppIndexes(root, "a")).rejects.toThrow(/undeclared context missing/);
});
it("rejects a context owned by an undeclared app", async () => {
const root = await repo({
"src/apps/a/app-module.ts": app("a"),
"src/contexts/c/context-module.ts": context("c", "ghost"),
});
await expect(generateAppIndexes(root, "a")).rejects.toThrow(/undeclared app ghost/);
});
it("enforces the context feature budget and the app context budget", async () => {
const overFeatures = await repo({
"src/apps/a/app-module.ts": app("a"),
"src/contexts/c/context-module.ts": context("c", "a", 1),
"src/features/f1/feature-module.ts": feature("f1", "c"),
"src/features/f2/feature-module.ts": feature("f2", "c"),
});
await expect(generateAppIndexes(overFeatures, "a")).rejects.toThrow(/c feature cardinality 2 exceeds budget 1/);
const overContexts = await repo({
"src/apps/a/app-module.ts": app("a", 1),
"src/contexts/c1/context-module.ts": context("c1", "a"),
"src/contexts/c2/context-module.ts": context("c2", "a"),
"src/features/f1/feature-module.ts": feature("f1", "c1"),
"src/features/f2/feature-module.ts": feature("f2", "c2"),
});
await expect(generateAppIndexes(overContexts, "a")).rejects.toThrow(/App a context cardinality 2 exceeds budget 1/);
});
it("refuses a feature directory without a declaration or NOT_INSTALLED marker (09-07)", async () => {
const files = {
"src/apps/a/app-module.ts": app("a"),
"src/contexts/c/context-module.ts": context("c", "a"),
"src/features/f/feature-module.ts": feature("f", "c"),
// A misspelt declaration file used to drop the feature without a word.
"src/features/typo/feature-modul.ts": feature("typo", "c"),
};
await expect(generateAppIndexes(await repo(files), "a")).rejects.toThrow(
/src\/features\/typo has no feature-module\.ts/u,
);
const marked = await repo({
...files,
"src/features/typo/NOT_INSTALLED": "Composed only by tests.\n",
});
const selected = await generateAppIndexes(marked, "a");
expect(selected.entries.map((entry) => entry.id)).toEqual(["f"]);
});
it("skips contexts without features and never imports another app's features", async () => {
const root = await repo({
"src/apps/a/app-module.ts": app("a"),
"src/apps/b/app-module.ts": app("b"),
"src/contexts/empty/context-module.ts": context("empty", "a"),
"src/contexts/ca/context-module.ts": context("ca", "a"),
"src/contexts/cb/context-module.ts": context("cb", "b"),
"src/features/fa/feature-module.ts": feature("fa", "ca"),
"src/features/fb/feature-module.ts": feature("fb", "cb"),
});
const selected = await generateAppIndexes(root, "a");
expect(selected.entries.map((entry) => entry.id)).toEqual(["fa"]);
expect(selected.contextIndex).not.toContain("empty");
expect(selected.featureIndex).not.toContain("features/fb/");
expect(selected.appIndex).toContain('id: "a"');
});
});
describe("build-time product selection (09-02)", () => {
const source: TopologyDeclarationSource = Object.freeze({
appIds: () => ["a"],
app: (appId: string) =>
appId === "a" ? Object.freeze({ id: "a", maxContexts: 20 }) : undefined,
contextsOf: () => [
Object.freeze({ id: "c", appId: "a", routePath: "c/*", maxFeatures: 200 }),
],
featuresOf: () => [
Object.freeze({ id: "f1", contextId: "c", directory: "f1" }),
Object.freeze({ id: "f2", contextId: "c", directory: "f2" }),
],
});
const declared =
'DECLARED_PRODUCT_FEATURE_IDS: readonly string[] = Object.freeze(["f1", "f2"])';
it("keeps every declared feature when nothing is selected", () => {
for (const selection of [undefined, "", " "]) {
const selected = selectAppIndexes(source, "a", selection);
expect(selected.entries.map((entry) => entry.id)).toEqual(["f1", "f2"]);
expect(selected.featureIndex).toBe(selectAppIndexes(source, "a").featureIndex);
expect(selected.featureIndex).toContain(declared);
}
});
it("imports only the selected features and still declares the rest", () => {
const selected = selectAppIndexes(source, "a", "f2");
expect(selected.entries.map((entry) => entry.id)).toEqual(["f2"]);
expect(selected.featureIndex).not.toContain("features/f1/");
expect(selected.contextIndex).not.toContain("features/f1/");
expect(selected.contextIndex).toContain("features/f2/context-routes.ts");
expect(selected.featureIndex).toContain(declared);
});
it("imports nothing for an explicit none", () => {
const selected = selectAppIndexes(source, "a", "none");
expect(selected.entries).toEqual([]);
expect(selected.featureIndex).not.toMatch(/features\/f[12]\//u);
expect(selected.contextIndex).toBe(renderContextIndex([]));
expect(selected.featureIndex).toContain(declared);
});
it("fails generation on an id the app does not declare", () => {
expect(() => selectAppIndexes(source, "a", "f1,f3")).toThrow(
/VITE_PRODUCT_FEATURES names features this build does not contain: f3/u,
);
});
it("fails the generator command, the first build step, on a misspelt id", async () => {
const { spawnSync } = await import("node:child_process");
const run = spawnSync(
process.execPath,
["scripts/generate-product-feature-index.ts", "--check"],
{
encoding: "utf8",
env: { ...process.env, VITE_PRODUCT_FEATURES: "reference-featrue" },
},
);
expect(run.status).not.toBe(0);
expect(run.stderr).toMatch(/does not contain: reference-featrue/u);
});
});
@@ -0,0 +1,81 @@
import { describe, expect, it } from "vitest";
import { mkdtemp, mkdir, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import {
EXTREME_SCALE_GATES,
satisfiesEngine,
sourceDigest,
vitestCounts,
} from "../../scripts/verify-extreme-scale.ts";
describe("extreme-scale verification runner", () => {
it.each([
["v24.11.0", true],
["24.14.0", true],
["v22.23.2", false],
["24.10.9", false],
["25.0.0", false],
])("checks %s against the repository engine range (%s)", (version, supported) => {
expect(satisfiesEngine(version, ">=24.11.0 <25.0.0")).toBe(supported);
});
it("runs every scale gate and builds before the browser soak tier", () => {
for (const gate of [
"check:types:app",
"check:types:test",
"check:feature-index",
"check:architecture",
"check:app-build-input",
"check:app-build-input:bundle",
"check:request-fanout",
"test:extreme-scale:focused",
"check:topology",
"check:traffic",
"check:observability",
"check:release-coherence",
"check:scale:pr",
"check:scale:main",
"check:scale:nightly",
"check:scale:release",
"check:scale:baseline",
]) {
expect(EXTREME_SCALE_GATES).toContain(gate);
}
expect(EXTREME_SCALE_GATES.indexOf("build")).toBeLessThan(
EXTREME_SCALE_GATES.indexOf("check:scale:nightly"),
);
expect(EXTREME_SCALE_GATES.indexOf("build")).toBeLessThan(
EXTREME_SCALE_GATES.indexOf("check:app-build-input:bundle"),
);
});
});
describe("evidence helpers", () => {
it("sums vitest test counts from coloured multi-run logs", () => {
const esc = String.fromCharCode(27);
const log =
`${esc}[2m Tests ${esc}[22m ${esc}[1m${esc}[32m68 passed${esc}[39m (68)\n` +
" Test Files 3 passed (3)\n" +
" Tests 1 failed | 10 passed | 2 skipped (13)\n";
expect(vitestCounts(log)).toEqual({ passed: 78, failed: 1, skipped: 2, files: 3 });
});
it("changes the source digest when any source file changes", async () => {
const root = await mkdtemp(path.join(tmpdir(), "digest-"));
try {
await mkdir(path.join(root, "src"), { recursive: true });
await writeFile(path.join(root, "src/a.ts"), "export const a = 1;\n");
await writeFile(path.join(root, "package.json"), "{}\n");
const first = await sourceDigest(root);
expect(await sourceDigest(root)).toEqual(first);
await writeFile(path.join(root, "src/a.ts"), "export const a = 2;\n");
expect((await sourceDigest(root)).digest).not.toBe(first.digest);
expect(first.files).toBe(2);
} finally {
await rm(root, { recursive: true, force: true });
}
});
});