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)
174 lines
7.0 KiB
TypeScript
174 lines
7.0 KiB
TypeScript
import { readFile } from "node:fs/promises";
|
|
import path from "node:path";
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
approveBaseline,
|
|
compareToBaseline,
|
|
metricsDigest,
|
|
type ScaleBaseline,
|
|
type ScaleEnvironment,
|
|
type ScaleMetrics,
|
|
} from "../../scripts/scale/scale-baseline.ts";
|
|
import { COMPOSITION_WORKLOADS } from "../../scripts/scale/composition-workloads.ts";
|
|
import { BASELINE_PATH, LOCAL_TSC_SIZES } from "../../scripts/scale/check-scale-baseline.ts";
|
|
|
|
const ENVIRONMENT: ScaleEnvironment = {
|
|
nodeMajor: 24,
|
|
platform: "linux",
|
|
arch: "x64",
|
|
cpuModel: "Test CPU",
|
|
cpuCount: 8,
|
|
typescript: "7.0.2",
|
|
};
|
|
|
|
const METRICS: ScaleMetrics = {
|
|
timing: [
|
|
{ workload: "registry-composition", profile: "S1", cardinality: 1_000, medianMs: 0.5, minMs: 0.4 },
|
|
{ workload: "registry-composition", profile: "S2", cardinality: 10_000, medianMs: 5, minMs: 4 },
|
|
],
|
|
compiler: [{ fixture: "app", files: 800, types: 270_000, symbols: 770_000, instantiations: 690_000 }],
|
|
};
|
|
|
|
function baseline(metrics: ScaleMetrics = METRICS, environment = ENVIRONMENT): ScaleBaseline {
|
|
return approveBaseline(environment, metrics, {
|
|
owner: "frontend-platform",
|
|
reason: "test",
|
|
approvedAt: "2026-09-23T00:00:00.000Z",
|
|
});
|
|
}
|
|
|
|
function withTiming(minMs: number): ScaleMetrics {
|
|
return {
|
|
...METRICS,
|
|
timing: METRICS.timing.map((entry) =>
|
|
entry.profile === "S2" ? { ...entry, minMs, medianMs: minMs } : entry,
|
|
),
|
|
};
|
|
}
|
|
|
|
function withTypes(types: number): ScaleMetrics {
|
|
return { ...METRICS, compiler: [{ ...METRICS.compiler[0]!, types }] };
|
|
}
|
|
|
|
describe("relative regression gate against the stored baseline", () => {
|
|
it("passes an unchanged run on all three axes", () => {
|
|
const result = compareToBaseline(baseline(), ENVIRONMENT, METRICS);
|
|
expect(result.status).toBe("passed");
|
|
expect(result.passed).toBe(true);
|
|
expect(result.absolute.passed).toBe(true);
|
|
expect(result.growth.passed).toBe(true);
|
|
expect(result.compiler.length).toBe(4);
|
|
expect(result.timing.length).toBe(2);
|
|
});
|
|
|
|
it("fails a compiler-cost regression above 10% even when the growth shape is fine", () => {
|
|
expect(compareToBaseline(baseline(), ENVIRONMENT, withTypes(290_000)).passed).toBe(true);
|
|
const regressed = compareToBaseline(baseline(), ENVIRONMENT, withTypes(300_000));
|
|
expect(regressed.passed).toBe(false);
|
|
expect(regressed.failures.join("\n")).toMatch(/tsc:app:types 300000 exceeds 297000/);
|
|
});
|
|
|
|
it("fails a timing regression beyond 2.5x on a compatible machine", () => {
|
|
expect(compareToBaseline(baseline(), ENVIRONMENT, withTiming(9.9)).passed).toBe(true);
|
|
const regressed = compareToBaseline(baseline(), ENVIRONMENT, withTiming(12));
|
|
expect(regressed.passed).toBe(false);
|
|
expect(regressed.failures.join("\n")).toMatch(/time:registry-composition\/S2/);
|
|
});
|
|
|
|
it("never fails timing differences inside the absolute noise floor", () => {
|
|
const tiny: ScaleMetrics = {
|
|
...METRICS,
|
|
timing: [{ workload: "w", profile: "S0", cardinality: 100, medianMs: 0.02, minMs: 0.02 }],
|
|
};
|
|
const noisy: ScaleMetrics = { ...tiny, timing: [{ ...tiny.timing[0]!, minMs: 0.9 }] };
|
|
expect(compareToBaseline(baseline(tiny), ENVIRONMENT, noisy).passed).toBe(true);
|
|
});
|
|
|
|
it("reports timings from a different machine as incomplete, never as passed, but still gates compiler counts", () => {
|
|
const otherMachine = { ...ENVIRONMENT, cpuModel: "Other CPU" };
|
|
const slow = compareToBaseline(baseline(), otherMachine, withTiming(12));
|
|
expect(slow.status).toBe("incomplete");
|
|
expect(slow.passed).toBe(false);
|
|
expect(slow.compatibility.timing.ok).toBe(false);
|
|
expect(slow.timing).toEqual([]);
|
|
|
|
const heavier = compareToBaseline(baseline(), otherMachine, withTypes(400_000));
|
|
expect(heavier.status).toBe("failed");
|
|
});
|
|
|
|
it("enforces machine-agnostic absolute ceilings on every run", () => {
|
|
const tooSlow = compareToBaseline(baseline(), { ...ENVIRONMENT, cpuModel: "Other CPU" }, withTiming(151));
|
|
expect(tooSlow.status).toBe("failed");
|
|
expect(tooSlow.failures.join("\n")).toMatch(/ceiling:time:registry-composition\/S2 151 exceeds 150/);
|
|
const tooHeavy = compareToBaseline(baseline(), ENVIRONMENT, withTypes(600_001));
|
|
expect(tooHeavy.absolute.passed).toBe(false);
|
|
});
|
|
|
|
it("fails a super-linear growth shape even when relative and absolute limits hold", () => {
|
|
const quadratic: ScaleMetrics = {
|
|
...METRICS,
|
|
timing: [
|
|
{ workload: "registry-composition", profile: "S1", cardinality: 1_000, medianMs: 0.6, minMs: 0.6 },
|
|
{ workload: "registry-composition", profile: "S2", cardinality: 10_000, medianMs: 60, minMs: 60 },
|
|
],
|
|
};
|
|
const result = compareToBaseline(baseline(quadratic), ENVIRONMENT, quadratic);
|
|
expect(result.growth.passed).toBe(false);
|
|
expect(result.status).toBe("failed");
|
|
expect(result.failures.join("\n")).toMatch(/growth:time:registry-composition/);
|
|
});
|
|
|
|
it("requires re-approval when the compiler changes", () => {
|
|
const result = compareToBaseline(baseline(), { ...ENVIRONMENT, typescript: "7.1.0" }, METRICS);
|
|
expect(result.passed).toBe(false);
|
|
expect(result.compatibility.compiler.ok).toBe(false);
|
|
expect(result.failures.join("\n")).toMatch(/re-approve with update:scale-baseline/);
|
|
});
|
|
|
|
it("rejects a hand-edited baseline whose metrics no longer match the approved digest", () => {
|
|
const tampered: ScaleBaseline = {
|
|
...baseline(),
|
|
metrics: withTypes(900_000),
|
|
};
|
|
const result = compareToBaseline(tampered, ENVIRONMENT, METRICS);
|
|
expect(result.passed).toBe(false);
|
|
expect(result.compatibility.structural.reasons.join("\n")).toMatch(/digest/);
|
|
});
|
|
|
|
it("rejects a run measuring something the baseline does not cover", () => {
|
|
const extra: ScaleMetrics = {
|
|
...METRICS,
|
|
compiler: [...METRICS.compiler, { fixture: "local-9999", files: 1, types: 1, symbols: 1, instantiations: 1 }],
|
|
};
|
|
const result = compareToBaseline(baseline(), ENVIRONMENT, extra);
|
|
expect(result.passed).toBe(false);
|
|
expect(result.failures.join("\n")).toMatch(/no baseline for compiler fixture local-9999/);
|
|
});
|
|
});
|
|
|
|
describe("stored benchmark baseline", () => {
|
|
it("is approved, digest-consistent and covers every measured workload and fixture", async () => {
|
|
const stored = JSON.parse(
|
|
await readFile(path.resolve(BASELINE_PATH), "utf8"),
|
|
) as ScaleBaseline;
|
|
|
|
expect(stored.schemaVersion).toBe(1);
|
|
expect(stored.approval.owner).toBeTruthy();
|
|
expect(stored.approval.reason).toBeTruthy();
|
|
expect(metricsDigest(stored.metrics)).toBe(stored.approval.metricsDigest);
|
|
|
|
const timing = new Set(stored.metrics.timing.map((entry) => `${entry.workload}/${entry.profile}`));
|
|
for (const workload of COMPOSITION_WORKLOADS) {
|
|
for (const profile of ["S0", "S1", "S2"]) {
|
|
expect(timing.has(`${workload.name}/${profile}`), `${workload.name}/${profile}`).toBe(true);
|
|
}
|
|
}
|
|
const fixtures = new Set(stored.metrics.compiler.map((entry) => entry.fixture));
|
|
expect(fixtures).toEqual(
|
|
new Set(["app", ...LOCAL_TSC_SIZES.map((size) => `local-${size}`)]),
|
|
);
|
|
});
|
|
});
|