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:
@@ -0,0 +1,93 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { mkdtemp, readdir, rm, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
import { afterAll, describe, expect, it } from "vitest";
|
||||
|
||||
import { inspectAppBuildInput } from "../../scripts/check-app-build-input.ts";
|
||||
import { renderContextIndex, renderFeatureIndex } from "../../scripts/generate-product-feature-index.ts";
|
||||
import { APP_A, writeFilesystemTopology } from "../scale/filesystem-topology.ts";
|
||||
|
||||
/**
|
||||
* Deployable-app isolation regression gate: the build input of one app must
|
||||
* never contain another app's features, whether through the generated index
|
||||
* or through the production bundle.
|
||||
*/
|
||||
const GENERATOR = path.resolve("scripts/generate-product-feature-index.ts");
|
||||
const roots: string[] = [];
|
||||
|
||||
afterAll(async () => {
|
||||
await Promise.all(roots.map((root) => rm(root, { recursive: true, force: true })));
|
||||
});
|
||||
|
||||
async function multiAppRepo() {
|
||||
const root = await mkdtemp(path.join(tmpdir(), "app-build-input-"));
|
||||
roots.push(root);
|
||||
await writeFilesystemTopology(root, { globalFeatures: 1_100 });
|
||||
const run = spawnSync(process.execPath, [GENERATOR, `--root=${root}`, `--app=${APP_A.id}`], {
|
||||
encoding: "utf8",
|
||||
});
|
||||
if (run.status !== 0) throw new Error(run.stderr);
|
||||
return root;
|
||||
}
|
||||
|
||||
async function inventory(root: string, modules: readonly string[]) {
|
||||
const file = path.join(root, "inventory.json");
|
||||
await writeFile(file, JSON.stringify({ schemaVersion: 1, chunks: [{ fileName: "a.js", modules }] }));
|
||||
return file;
|
||||
}
|
||||
|
||||
describe("app build input isolation gate", () => {
|
||||
it("accepts the production generator's output and an app-local bundle", async () => {
|
||||
const root = await multiAppRepo();
|
||||
const bundle = await inventory(root, [
|
||||
"src/features/app-a-ctx0-f0/feature-module.ts",
|
||||
"src/features/app-a-ctx1-f49/presentation/page.ts",
|
||||
"src/platform/traffic/request-budget.ts",
|
||||
]);
|
||||
const report = await inspectAppBuildInput(root, { bundleInventory: bundle });
|
||||
expect(report.violations).toEqual([]);
|
||||
expect(report.appId).toBe(APP_A.id);
|
||||
expect(report.generatedFeatureImports).toHaveLength(APP_A.contexts * APP_A.featuresPerContext);
|
||||
expect(report.bundle.checked).toBe(true);
|
||||
});
|
||||
|
||||
it("rejects a generator regression that imports every discovered feature", async () => {
|
||||
const root = await multiAppRepo();
|
||||
const everyFeature = (await readdir(path.join(root, "src/features"))).map((directory) => ({
|
||||
id: directory,
|
||||
importPath: `../features/${directory}/feature-module.ts`,
|
||||
directory,
|
||||
contextId: directory.replace(/-f\d+$/u, ""),
|
||||
contextRoutePath: "x/*",
|
||||
contextMaxFeatures: 200,
|
||||
}));
|
||||
await writeFile(path.join(root, "src/.generated/product-feature-index.ts"), renderFeatureIndex(everyFeature));
|
||||
await writeFile(path.join(root, "src/.generated/product-context-index.ts"), renderContextIndex(everyFeature));
|
||||
|
||||
const report = await inspectAppBuildInput(root, { bundleInventory: null });
|
||||
expect(report.violations.length).toBeGreaterThan(0);
|
||||
expect(report.violations.join("\n")).toMatch(/imports feature "other-0-ctx0-f0" not owned by app app-a/);
|
||||
expect(report.violations.join("\n")).toMatch(/declares context "other-0-ctx0" not owned/);
|
||||
});
|
||||
|
||||
it("rejects a production bundle that contains another app's feature", async () => {
|
||||
const root = await multiAppRepo();
|
||||
const bundle = await inventory(root, [
|
||||
"src/features/app-a-ctx0-f0/feature-module.ts",
|
||||
"src/features/other-0-ctx3-f7/feature-module.ts",
|
||||
]);
|
||||
const report = await inspectAppBuildInput(root, { bundleInventory: bundle });
|
||||
expect(report.violations).toEqual([
|
||||
'production bundle contains feature "other-0-ctx3-f7" not owned by app app-a',
|
||||
]);
|
||||
});
|
||||
|
||||
it("holds for this repository's generated indexes", async () => {
|
||||
// The bundle side is gated after a fresh build (check:app-build-input:bundle).
|
||||
const report = await inspectAppBuildInput(path.resolve("."), { bundleInventory: null });
|
||||
expect(report.violations).toEqual([]);
|
||||
expect(report.generatedFeatureImports).toEqual(report.ownedFeatureDirectories);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { defineDeployableAppModule } from "../../src/apps/deployable-app-module.ts";
|
||||
import { defineBoundedContextModule } from "../../src/contexts/bounded-context-module.ts";
|
||||
import { createAppRouteModules } from "../../src/platform/routing/context-route-module.ts";
|
||||
|
||||
const MAX_CONTEXTS_PER_APP = 20;
|
||||
|
||||
describe("context executable lazy loading", () => {
|
||||
it("does no context route composition at boot and loads only the entered context", async () => {
|
||||
const loadCounts = Array.from({ length: MAX_CONTEXTS_PER_APP }, () => 0);
|
||||
const contexts = loadCounts.map((_, index) =>
|
||||
defineBoundedContextModule({
|
||||
id: `context-${index}`,
|
||||
features: [],
|
||||
budget: { maxFeatures: 200 },
|
||||
route: {
|
||||
path: `context-${index}/*`,
|
||||
loadRoutes: async () => {
|
||||
loadCounts[index] += 1;
|
||||
return Object.freeze([]);
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
const app = defineDeployableAppModule({
|
||||
id: "scale-app",
|
||||
contexts,
|
||||
budget: { maxContexts: MAX_CONTEXTS_PER_APP },
|
||||
});
|
||||
|
||||
const routeModules = createAppRouteModules(app);
|
||||
|
||||
expect(routeModules).toHaveLength(MAX_CONTEXTS_PER_APP);
|
||||
expect(loadCounts.every((count) => count === 0)).toBe(true);
|
||||
|
||||
await routeModules[7]!.loadRoutes();
|
||||
|
||||
expect(loadCounts[7]).toBe(1);
|
||||
expect(loadCounts.filter((count) => count !== 0)).toEqual([1]);
|
||||
|
||||
await routeModules[7]!.loadRoutes();
|
||||
expect(loadCounts[7]).toBe(1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { defineFeatureModule } from "../../src/features/feature-module.ts";
|
||||
import { defineBoundedContextModule } from "../../src/contexts/bounded-context-module.ts";
|
||||
import { defineDeployableAppModule } from "../../src/apps/deployable-app-module.ts";
|
||||
|
||||
const feature = defineFeatureModule({ id:"f", contracts:{featureId:"f"}, routes:{}, adapters:[], runtimes:[], messages:{}, contractContributions:[] });
|
||||
describe("module hierarchy", () => {
|
||||
it("exposes only direct children and freezes copied arrays", () => {
|
||||
const features = [feature];
|
||||
const context = defineBoundedContextModule({ id:"commerce", features, budget:{maxFeatures:200} });
|
||||
features.length = 0;
|
||||
const contexts = [context];
|
||||
const app = defineDeployableAppModule({ id:"customer", contexts, budget:{maxContexts:20} });
|
||||
contexts.length = 0;
|
||||
expect(context.features).toEqual([feature]);
|
||||
expect(app.contexts).toEqual([context]);
|
||||
expect("features" in app).toBe(false);
|
||||
expect(Object.isFrozen(app.contexts)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,114 @@
|
||||
import { readFile, readdir } from "node:fs/promises";
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
/**
|
||||
* Spec §17 / §24 / §50. Observability boundary gates:
|
||||
* - feature (and every non-adapter) code never imports a vendor telemetry SDK,
|
||||
* - no global union of every feature error or telemetry payload exists,
|
||||
* - the dependency rule that enforces the first point stays configured.
|
||||
*/
|
||||
|
||||
const ROOT = path.resolve(".");
|
||||
|
||||
async function productionSources(directory = path.join(ROOT, "src")): Promise<string[]> {
|
||||
const files: string[] = [];
|
||||
for (const entry of await readdir(directory, { withFileTypes: true })) {
|
||||
const target = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) files.push(...(await productionSources(target)));
|
||||
else if (/\.tsx?$/u.test(entry.name) && !/\.d\.ts$/u.test(entry.name)) {
|
||||
files.push(target);
|
||||
}
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
async function readProductionSources(): Promise<string> {
|
||||
const files = await productionSources();
|
||||
const sources = await Promise.all(files.map((file) => readFile(file, "utf8")));
|
||||
return sources.join("\n");
|
||||
}
|
||||
|
||||
type DependencyRule = Readonly<{
|
||||
name: string;
|
||||
from: Readonly<{ path?: string; pathNot?: string }>;
|
||||
to: Readonly<{ path?: string }>;
|
||||
}>;
|
||||
|
||||
async function dependencyRules(): Promise<readonly DependencyRule[]> {
|
||||
const config = JSON.parse(
|
||||
await readFile(path.join(ROOT, ".dependency-cruiser.json"), "utf8"),
|
||||
) as { forbidden: DependencyRule[] };
|
||||
return config.forbidden;
|
||||
}
|
||||
|
||||
const VENDOR_SDKS = [
|
||||
"@sentry/browser",
|
||||
"@sentry/react",
|
||||
"@datadog/browser-rum",
|
||||
"@datadog/browser-logs",
|
||||
"@opentelemetry/api",
|
||||
"@newrelic/browser-agent",
|
||||
"logrocket",
|
||||
"posthog-js",
|
||||
];
|
||||
|
||||
describe("observability boundaries", () => {
|
||||
it("configures a rule that rejects vendor SDK imports outside adapters", async () => {
|
||||
const rule = (await dependencyRules()).find(
|
||||
({ name }) => name === "observability-vendors-live-behind-adapters",
|
||||
);
|
||||
expect(rule).toBeDefined();
|
||||
const from = new RegExp(rule?.from.path ?? "$^", "u");
|
||||
const fromNot = new RegExp(rule?.from.pathNot ?? "$^", "u");
|
||||
const to = new RegExp(rule?.to.path ?? "$^", "u");
|
||||
|
||||
const applies = (source: string, target: string) =>
|
||||
from.test(source) && !fromNot.test(source) && to.test(target);
|
||||
|
||||
for (const vendor of VENDOR_SDKS) {
|
||||
expect(applies("src/features/catalog/application/x.ts", vendor), vendor).toBe(true);
|
||||
expect(applies("src/platform/telemetry/x.ts", vendor), vendor).toBe(true);
|
||||
expect(applies("src/adapters/telemetry/vendor-transport.ts", vendor), vendor).toBe(false);
|
||||
}
|
||||
expect(applies("src/features/a/x.ts", "react")).toBe(false);
|
||||
expect(applies("src/features/a/x.ts", "@sentry-like/other")).toBe(false);
|
||||
});
|
||||
|
||||
it("finds no vendor telemetry SDK import in production sources outside adapters", async () => {
|
||||
const offenders: string[] = [];
|
||||
const vendorImport =
|
||||
/from\s+["'](@sentry|@datadog|@opentelemetry|@newrelic|newrelic|logrocket|posthog-js|mixpanel-browser|@amplitude|@bugsnag)(\/[^"']*)?["']/u;
|
||||
for (const file of await productionSources()) {
|
||||
const relative = path.relative(ROOT, file).split(path.sep).join("/");
|
||||
if (relative.startsWith("src/adapters/")) continue;
|
||||
if (vendorImport.test(await readFile(file, "utf8"))) offenders.push(relative);
|
||||
}
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
|
||||
it("does not define installed/global unions of all feature errors or telemetry payloads", async () => {
|
||||
const source = await readProductionSources();
|
||||
expect(source).not.toMatch(
|
||||
/AllFeatureErrors|GlobalFeatureErrors|GlobalApplicationError|InstalledFeatureErrors|AllTelemetryEvents|AllFeatureTelemetry/u,
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps the platform kernel independent of concrete product modules", async () => {
|
||||
const rule = (await dependencyRules()).find(
|
||||
({ name }) => name === "platform-kernel-is-product-neutral",
|
||||
);
|
||||
expect(rule).toBeDefined();
|
||||
const offenders: string[] = [];
|
||||
for (const file of await productionSources(path.join(ROOT, "src/platform"))) {
|
||||
const relative = path.relative(ROOT, file).split(path.sep).join("/");
|
||||
if (relative.startsWith("src/platform/routing/")) continue;
|
||||
const source = await readFile(file, "utf8");
|
||||
if (/from\s+["']\.\.\/\.\.\/(features|contexts|apps|adapters|bootstrap|presentation|application)\//u.test(source)) {
|
||||
offenders.push(relative);
|
||||
}
|
||||
}
|
||||
expect(offenders).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
findRequestFanout,
|
||||
scanRequestFanout,
|
||||
} from "../../scripts/check-request-fanout.ts";
|
||||
|
||||
describe("no per-row transport loop (frontend N+1 source gate)", () => {
|
||||
it("finds no per-row dispatch in feature code or application use cases", async () => {
|
||||
const result = await scanRequestFanout(path.resolve("."));
|
||||
expect(result.files).toBeGreaterThan(0);
|
||||
expect(result.violations).toEqual([]);
|
||||
});
|
||||
|
||||
it("rejects every forbidden fixture and accepts the bulk-read fixture", async () => {
|
||||
const root = path.resolve(".");
|
||||
const forbidden = await scanRequestFanout(root, ["tests/fixtures/architecture/request-fanout/forbidden"]);
|
||||
const allowed = await scanRequestFanout(root, ["tests/fixtures/architecture/request-fanout/allowed"]);
|
||||
expect(new Set(forbidden.violations.map((violation) => violation.file)).size).toBe(forbidden.files);
|
||||
expect(forbidden.files).toBe(3);
|
||||
expect(allowed.violations).toEqual([]);
|
||||
});
|
||||
|
||||
it("names the dispatch and the repeating construct", async () => {
|
||||
const violations = await findRequestFanout(
|
||||
"inline.ts",
|
||||
"export const load = (api: { get(id: string): Promise<unknown> }, ids: string[]) =>\n Promise.all(ids.map((id) => api.get(id)));\n",
|
||||
);
|
||||
expect(violations).toEqual([
|
||||
{ file: "inline.ts", line: 2, call: "api.get()", context: ".map() callback" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("honours an explicit reviewed exception on the call line", async () => {
|
||||
const violations = await findRequestFanout(
|
||||
"reviewed.ts",
|
||||
"export async function f(http: { execute(): Promise<void> }) {\n for (let i = 0; i < 2; i += 1) await http.execute(); // fanout-reviewed: bounded 2-step handshake\n}\n",
|
||||
);
|
||||
expect(violations).toEqual([]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,116 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { defineDeployableAppModule } from "../../src/apps/deployable-app-module.ts";
|
||||
import { defineBoundedContextModule } from "../../src/contexts/bounded-context-module.ts";
|
||||
import { defineFeatureModule } from "../../src/features/feature-module.ts";
|
||||
import { planTopologyCapacity } from "../../src/platform/cardinality/topology-capacity.ts";
|
||||
|
||||
const MAX_FEATURES_PER_CONTEXT = 200;
|
||||
const MAX_CONTEXTS_PER_APP = 20;
|
||||
|
||||
function fakeFeature(id: string) {
|
||||
return defineFeatureModule({
|
||||
id,
|
||||
contracts: { featureId: id },
|
||||
routes: {},
|
||||
adapters: [],
|
||||
runtimes: [],
|
||||
messages: {},
|
||||
contractContributions: [],
|
||||
});
|
||||
}
|
||||
|
||||
describe("topology cardinality", () => {
|
||||
it("accepts direct children at the configured ceilings", () => {
|
||||
const features = Array.from({ length: MAX_FEATURES_PER_CONTEXT }, (_, index) =>
|
||||
fakeFeature(`feature-${index}`),
|
||||
);
|
||||
const contexts = Array.from({ length: MAX_CONTEXTS_PER_APP }, (_, index) =>
|
||||
defineBoundedContextModule({
|
||||
id: `context-${index}`,
|
||||
features,
|
||||
budget: { maxFeatures: MAX_FEATURES_PER_CONTEXT },
|
||||
}),
|
||||
);
|
||||
|
||||
expect(() =>
|
||||
defineDeployableAppModule({
|
||||
id: "scale-ceiling-app",
|
||||
contexts,
|
||||
budget: { maxContexts: MAX_CONTEXTS_PER_APP },
|
||||
}),
|
||||
).not.toThrow();
|
||||
});
|
||||
|
||||
it("rejects a context above its feature budget", () => {
|
||||
expect(() =>
|
||||
defineBoundedContextModule({
|
||||
id: "commerce",
|
||||
features: Array.from({ length: 201 }, (_, index) => fakeFeature(`f${index}`)),
|
||||
budget: { maxFeatures: MAX_FEATURES_PER_CONTEXT },
|
||||
}),
|
||||
).toThrow(/commerce.*201.*200/);
|
||||
});
|
||||
|
||||
it("rejects duplicate direct child ids", () => {
|
||||
const context = defineBoundedContextModule({
|
||||
id: "commerce",
|
||||
features: [],
|
||||
budget: { maxFeatures: MAX_FEATURES_PER_CONTEXT },
|
||||
});
|
||||
|
||||
expect(() =>
|
||||
defineDeployableAppModule({
|
||||
id: "customer",
|
||||
contexts: [context, context],
|
||||
budget: { maxContexts: MAX_CONTEXTS_PER_APP },
|
||||
}),
|
||||
).toThrow(/Duplicate.*commerce/);
|
||||
});
|
||||
});
|
||||
|
||||
describe("extreme-scale topology capacity", () => {
|
||||
const cases = [
|
||||
{ featureCount: 100, expectedContexts: 1, expectedApps: 1 },
|
||||
{ featureCount: 1_000, expectedContexts: 5, expectedApps: 1 },
|
||||
{ featureCount: 10_000, expectedContexts: 50, expectedApps: 3 },
|
||||
{ featureCount: 100_000, expectedContexts: 500, expectedApps: 25 },
|
||||
{ featureCount: 1_000_000, expectedContexts: 5_000, expectedApps: 250 },
|
||||
] as const;
|
||||
|
||||
it.each(cases)(
|
||||
"partitions $featureCount features without exceeding direct-child budgets",
|
||||
({ featureCount, expectedContexts, expectedApps }) => {
|
||||
const plan = planTopologyCapacity({
|
||||
featureCount,
|
||||
maxFeaturesPerContext: MAX_FEATURES_PER_CONTEXT,
|
||||
maxContextsPerApp: MAX_CONTEXTS_PER_APP,
|
||||
});
|
||||
|
||||
expect(plan.contextCount).toBe(expectedContexts);
|
||||
expect(plan.appCount).toBe(expectedApps);
|
||||
expect(plan.maxFeaturesInAnyContext).toBeLessThanOrEqual(MAX_FEATURES_PER_CONTEXT);
|
||||
expect(plan.maxContextsInAnyApp).toBeLessThanOrEqual(MAX_CONTEXTS_PER_APP);
|
||||
expect(plan.totalFeatureCapacity).toBeGreaterThanOrEqual(featureCount);
|
||||
expect(plan.totalFeatureCapacity - featureCount).toBeLessThan(
|
||||
MAX_FEATURES_PER_CONTEXT * MAX_CONTEXTS_PER_APP,
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
it("keeps a zero-feature product as one deployable app with no contexts", () => {
|
||||
expect(
|
||||
planTopologyCapacity({
|
||||
featureCount: 0,
|
||||
maxFeaturesPerContext: MAX_FEATURES_PER_CONTEXT,
|
||||
maxContextsPerApp: MAX_CONTEXTS_PER_APP,
|
||||
}),
|
||||
).toMatchObject({
|
||||
featureCount: 0,
|
||||
contextCount: 0,
|
||||
appCount: 1,
|
||||
maxFeaturesInAnyContext: 0,
|
||||
maxContextsInAnyApp: 0,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user