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)
238 lines
8.6 KiB
TypeScript
238 lines
8.6 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
activeProductFeatureIds,
|
|
resolveProductFeatures,
|
|
selectCompiledProductFeatures,
|
|
} from "../../src/contracts/product-features.ts";
|
|
import { runtimeConfigV2ArtifactSchema } from "../../src/contracts/release-artifacts.ts";
|
|
import {
|
|
COMPILED_PRODUCT_FEATURE_IDS,
|
|
INSTALLED_PRODUCT_FEATURE_IDS,
|
|
} from "../../src/features/installed-product-manifest.ts";
|
|
import { PLATFORM_ROUTE_REGISTRY } from "../../src/contracts/routes.ts";
|
|
import {
|
|
ROUTE_FEATURE_OWNER,
|
|
ROUTE_REGISTRY,
|
|
} from "../../src/features/installed-feature-contracts.ts";
|
|
|
|
const COMPILED = Object.freeze([
|
|
Object.freeze({ featureId: "alpha-feature" }),
|
|
Object.freeze({ featureId: "billing" }),
|
|
]);
|
|
|
|
describe("build-time product selection", () => {
|
|
it("keeps everything when nothing is declared", () => {
|
|
for (const declared of [undefined, "", " "]) {
|
|
expect(
|
|
selectCompiledProductFeatures(COMPILED, declared).map((f) => f.featureId),
|
|
String(declared),
|
|
).toEqual(["alpha-feature", "billing"]);
|
|
}
|
|
});
|
|
|
|
it("narrows to the declared subset", () => {
|
|
expect(
|
|
selectCompiledProductFeatures(COMPILED, "billing").map((f) => f.featureId),
|
|
).toEqual(["billing"]);
|
|
expect(
|
|
selectCompiledProductFeatures(COMPILED, " billing , alpha-feature ").map(
|
|
(f) => f.featureId,
|
|
),
|
|
).toEqual(["alpha-feature", "billing"]);
|
|
});
|
|
|
|
it("selects nothing only when asked explicitly", () => {
|
|
// A blank value keeps everything on purpose: an unset CI variable expands
|
|
// to a blank string, and that must not be how a build ships no features.
|
|
expect(selectCompiledProductFeatures(COMPILED, "none")).toEqual([]);
|
|
expect(selectCompiledProductFeatures(COMPILED, " none ")).toEqual([]);
|
|
expect(selectCompiledProductFeatures(COMPILED, "").length).toBe(2);
|
|
// A value that parses to no names at all is a typo, not an instruction.
|
|
expect(() => selectCompiledProductFeatures(COMPILED, ",")).toThrow(
|
|
/names no feature/u,
|
|
);
|
|
});
|
|
|
|
it("refuses to name a feature this build does not contain", () => {
|
|
// The whole point of the direction rule: an environment value can subtract
|
|
// from the source tree and must never be able to add to it. Accepting an
|
|
// unknown id silently would let a deployment believe it had switched on
|
|
// something that is not in the bundle.
|
|
expect(() => selectCompiledProductFeatures(COMPILED, "analytics")).toThrow(
|
|
/does not contain: analytics/u,
|
|
);
|
|
expect(() =>
|
|
selectCompiledProductFeatures(COMPILED, "billing,analytics"),
|
|
).toThrow(/analytics/u);
|
|
});
|
|
|
|
it("refuses a duplicated feature id in the manifest", () => {
|
|
expect(() =>
|
|
selectCompiledProductFeatures(
|
|
[{ featureId: "a" }, { featureId: "a" }],
|
|
undefined,
|
|
),
|
|
).toThrow(/duplicate product feature id/u);
|
|
});
|
|
});
|
|
|
|
describe("runtime product feature resolution", () => {
|
|
it("reports active, disabled and not-installed distinctly", () => {
|
|
const statuses = resolveProductFeatures(
|
|
["alpha-feature", "billing"],
|
|
["alpha-feature"],
|
|
{ "alpha-feature": "DISABLED" },
|
|
);
|
|
expect(statuses).toEqual([
|
|
{ featureId: "alpha-feature", state: "DISABLED_BY_CONFIG" },
|
|
{ featureId: "billing", state: "NOT_INSTALLED" },
|
|
]);
|
|
expect(activeProductFeatureIds(statuses)).toEqual([]);
|
|
});
|
|
|
|
it("cannot switch on a feature the build left out", () => {
|
|
// `DEFAULT` on an uninstalled feature is not an instruction to install it.
|
|
const statuses = resolveProductFeatures(["billing"], [], {
|
|
billing: "DEFAULT",
|
|
});
|
|
expect(statuses).toEqual([{ featureId: "billing", state: "NOT_INSTALLED" }]);
|
|
expect(activeProductFeatureIds(statuses)).toEqual([]);
|
|
});
|
|
|
|
it("ignores an override naming a feature this build never declared", () => {
|
|
// A shared runtime document may cover several builds, so a stale key is
|
|
// inert rather than fatal.
|
|
const statuses = resolveProductFeatures(
|
|
["alpha-feature"],
|
|
["alpha-feature"],
|
|
{ analytics: "DISABLED" },
|
|
);
|
|
expect(activeProductFeatureIds(statuses)).toEqual(["alpha-feature"]);
|
|
});
|
|
|
|
it("leaves an installed feature active without an override", () => {
|
|
const statuses = resolveProductFeatures(
|
|
COMPILED_PRODUCT_FEATURE_IDS,
|
|
INSTALLED_PRODUCT_FEATURE_IDS,
|
|
);
|
|
expect(activeProductFeatureIds(statuses)).toEqual([
|
|
...INSTALLED_PRODUCT_FEATURE_IDS,
|
|
]);
|
|
});
|
|
});
|
|
|
|
describe("runtime config carries the switch", () => {
|
|
const base = {
|
|
APP_ENV: "local" as const,
|
|
API_BASE_URL: "http://localhost:8080/",
|
|
TELEMETRY_ENABLED: false,
|
|
AUTH_MODE: "demo" as const,
|
|
CONFIG_SCHEMA_VERSION: "2.0" as const,
|
|
RELEASE_MANIFEST_URL: "/release-manifest.json",
|
|
};
|
|
|
|
it("defaults to disabling nothing", () => {
|
|
const parsed = runtimeConfigV2ArtifactSchema.parse(base);
|
|
expect(parsed.FEATURE_OVERRIDES).toEqual({});
|
|
});
|
|
|
|
it("accepts only DEFAULT or DISABLED", () => {
|
|
expect(
|
|
runtimeConfigV2ArtifactSchema.parse({
|
|
...base,
|
|
FEATURE_OVERRIDES: { "alpha-feature": "DISABLED" },
|
|
}).FEATURE_OVERRIDES,
|
|
).toEqual({ "alpha-feature": "DISABLED" });
|
|
// There is no "ENABLED": the vocabulary itself is what makes the rule
|
|
// unbreakable, not a check somewhere downstream.
|
|
expect(
|
|
runtimeConfigV2ArtifactSchema.safeParse({
|
|
...base,
|
|
FEATURE_OVERRIDES: { "alpha-feature": "ENABLED" },
|
|
}).success,
|
|
).toBe(false);
|
|
});
|
|
|
|
it("refuses a malformed feature id", () => {
|
|
for (const featureId of ["Reference", "reference_feature", "", "-x"]) {
|
|
expect(
|
|
runtimeConfigV2ArtifactSchema.safeParse({
|
|
...base,
|
|
FEATURE_OVERRIDES: { [featureId]: "DISABLED" },
|
|
}).success,
|
|
featureId,
|
|
).toBe(false);
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("every installed registry consults the manifest", () => {
|
|
/**
|
|
* The manifest only means something if each registry actually asks it. A new
|
|
* registry that spreads a feature in directly would reintroduce exactly the
|
|
* coupling this file exists to remove, and nothing else would notice.
|
|
*/
|
|
it("gates every feature contribution on the selection", async () => {
|
|
const { readdir, readFile } = await import("node:fs/promises");
|
|
const nodePath = (await import("node:path")).default;
|
|
const root = "src/features";
|
|
const registries = (await readdir(root)).filter((entry) =>
|
|
/^installed-.*\.tsx?$/u.test(entry),
|
|
);
|
|
expect(registries.length).toBeGreaterThan(3);
|
|
const exempt = new Set([
|
|
// The manifest is the selection.
|
|
"installed-product-manifest.ts",
|
|
// Capabilities have their own §3.5 selection file and override vocabulary.
|
|
"installed-runtime-capabilities.ts",
|
|
// Message keys stay total on purpose; see the file for why.
|
|
"installed-feature-messages.ts",
|
|
]);
|
|
for (const registry of registries) {
|
|
if (exempt.has(registry)) continue;
|
|
const source = await readFile(nodePath.join(root, registry), "utf8");
|
|
const manifestImport = source.match(
|
|
/import\s*\{([\s\S]*?)\}\s*from\s*["']\.\/installed-product-manifest\.ts["']/u,
|
|
);
|
|
expect(
|
|
manifestImport,
|
|
`${registry} must import its selection from the product manifest`,
|
|
).not.toBeNull();
|
|
expect(
|
|
/\bINSTALLED_PRODUCT_FEATURE(?:S|_IDS|_MODULES)\b/u.test(
|
|
manifestImport?.[1] ?? "",
|
|
),
|
|
`${registry} must compose from a selected product-feature projection`,
|
|
).toBe(true);
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("route ownership", () => {
|
|
it("attributes no platform route to a feature", () => {
|
|
// Template merge. The template named its own example routes here. This
|
|
// product deleted them, so the invariant is asserted against the platform
|
|
// registry itself: whatever the shell owns, disabling a feature can never
|
|
// withdraw it.
|
|
for (const routeId of Object.keys(PLATFORM_ROUTE_REGISTRY)) {
|
|
expect(ROUTE_FEATURE_OWNER[routeId], routeId).toBeUndefined();
|
|
expect(Object.keys(ROUTE_REGISTRY)).toContain(routeId);
|
|
}
|
|
expect(ROUTE_FEATURE_OWNER["NOT_FOUND"]).toBeUndefined();
|
|
});
|
|
|
|
it("owns exactly routes that exist in the composed registry", () => {
|
|
// Template merge. `owned` is empty in this product: the only installed
|
|
// feature's screens were removed by the UI migration. The invariant still
|
|
// holds and starts asserting again the moment a feature route returns.
|
|
const owned = Object.keys(ROUTE_FEATURE_OWNER);
|
|
for (const routeId of owned) {
|
|
expect(Object.keys(ROUTE_REGISTRY), routeId).toContain(routeId);
|
|
}
|
|
expect(
|
|
owned.every((routeId) => ROUTE_FEATURE_OWNER[routeId] !== undefined),
|
|
).toBe(true);
|
|
});
|
|
});
|