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,332 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { createHash } from "node:crypto";
|
||||
import { existsSync } from "node:fs";
|
||||
import { mkdir, readdir, readFile, stat, writeFile } from "node:fs/promises";
|
||||
import { arch, platform, userInfo } from "node:os";
|
||||
import path from "node:path";
|
||||
|
||||
/**
|
||||
* Executable evidence for the extreme-scale acceptance matrix.
|
||||
*
|
||||
* Runs every gate the acceptance rows cite, in order, under the *current*
|
||||
* Node, and writes one machine-readable record:
|
||||
* artifacts/quality/extreme-scale-gates.json
|
||||
* artifacts/quality/extreme-scale-gates/<gate>.log
|
||||
*
|
||||
* On an unsupported Node the gates are not run at all and the record says
|
||||
* `not-executed`; it is never reported as a failure of the code or as a pass.
|
||||
* In an environment whose default Node is too old, put a supported binary
|
||||
* first on PATH (for example a repository-local `.tmp/node24/bin`).
|
||||
*/
|
||||
export const EXTREME_SCALE_GATES = Object.freeze([
|
||||
"check:feature-index",
|
||||
"check:types:app",
|
||||
"check:types:test",
|
||||
"check:types",
|
||||
"lint",
|
||||
"check:architecture",
|
||||
"check:app-build-input",
|
||||
"check:request-fanout",
|
||||
"check:registries",
|
||||
"check:diagnostics",
|
||||
"test:extreme-scale:focused",
|
||||
"check:topology",
|
||||
"check:traffic",
|
||||
"check:observability",
|
||||
"check:release-coherence",
|
||||
"test:platform",
|
||||
"test:reference-feature",
|
||||
"check:scale:pr",
|
||||
"check:scale:main",
|
||||
"check:scale:baseline",
|
||||
// The soak needs a build of the current source, never a stale dist/.
|
||||
"build",
|
||||
// The production bundle closure of the built app contains only its features.
|
||||
"check:app-build-input:bundle",
|
||||
"check:scale:nightly",
|
||||
"check:scale:release",
|
||||
] as const);
|
||||
|
||||
/** Inputs whose content defines "the current code" for this evidence. */
|
||||
const SOURCE_ROOTS = Object.freeze(["src", "scripts", "tests", "config", ".storybook", "recipes"]);
|
||||
const SOURCE_FILES = Object.freeze([
|
||||
"package.json",
|
||||
"pnpm-lock.yaml",
|
||||
".dependency-cruiser.json",
|
||||
"eslint.config.ts",
|
||||
"vite.config.ts",
|
||||
"vitest.config.ts",
|
||||
"tsconfig.json",
|
||||
"tsconfig.app.json",
|
||||
"tsconfig.test.json",
|
||||
"tsconfig.node.json",
|
||||
]);
|
||||
|
||||
async function listFiles(directory: string): Promise<string[]> {
|
||||
const found: string[] = [];
|
||||
let entries;
|
||||
try {
|
||||
entries = await readdir(directory, { withFileTypes: true });
|
||||
} catch {
|
||||
return found;
|
||||
}
|
||||
for (const entry of entries) {
|
||||
const target = path.join(directory, entry.name);
|
||||
if (entry.isDirectory()) found.push(...(await listFiles(target)));
|
||||
else if (entry.isFile()) found.push(target);
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
||||
/** sha256 over every source input (path + content), in a stable order. */
|
||||
export async function sourceDigest(root: string): Promise<Readonly<{ digest: string; files: number }>> {
|
||||
const files = [
|
||||
...(await Promise.all(SOURCE_ROOTS.map((entry) => listFiles(path.join(root, entry))))).flat(),
|
||||
...SOURCE_FILES.map((file) => path.join(root, file)).filter((file) => existsSync(file)),
|
||||
]
|
||||
.map((file) => path.relative(root, file))
|
||||
.sort();
|
||||
const hash = createHash("sha256");
|
||||
for (const file of files) {
|
||||
hash.update(file).update("\0").update(await readFile(path.join(root, file))).update("\0");
|
||||
}
|
||||
return { digest: hash.digest("hex"), files: files.length };
|
||||
}
|
||||
|
||||
/** Sums vitest `Tests N passed` / `N failed` lines from a gate log. */
|
||||
export function vitestCounts(log: string): Readonly<{ passed: number; failed: number; skipped: number; files: number }> {
|
||||
const escape = String.fromCharCode(27);
|
||||
const plain = log.split(escape).map((part, index) => (index === 0 ? part : part.replace(/^\[[0-9;]*m/u, ""))).join("");
|
||||
let passed = 0;
|
||||
let failed = 0;
|
||||
let skipped = 0;
|
||||
let files = 0;
|
||||
for (const line of plain.split("\n")) {
|
||||
const tests = /^\s*Tests\s+(.*)$/u.exec(line);
|
||||
if (tests) {
|
||||
passed += Number(/(\d+) passed/u.exec(tests[1] as string)?.[1] ?? 0);
|
||||
failed += Number(/(\d+) failed/u.exec(tests[1] as string)?.[1] ?? 0);
|
||||
skipped += Number(/(\d+) skipped/u.exec(tests[1] as string)?.[1] ?? 0);
|
||||
}
|
||||
const fileLine = /^\s*Test Files\s+.*?(\d+) passed/u.exec(line);
|
||||
if (fileLine) files += Number(fileLine[1]);
|
||||
}
|
||||
return { passed, failed, skipped, files };
|
||||
}
|
||||
|
||||
type Version = readonly [number, number, number];
|
||||
|
||||
function parseVersion(value: string): Version {
|
||||
const [major = 0, minor = 0, patch = 0] = value.replace(/^v/u, "").split(".").map(Number);
|
||||
return [major, minor, patch];
|
||||
}
|
||||
|
||||
function compare(left: Version, right: Version): number {
|
||||
for (let index = 0; index < 3; index += 1) {
|
||||
const difference = (left[index] ?? 0) - (right[index] ?? 0);
|
||||
if (difference !== 0) return difference;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Supports the `>=a.b.c <x.y.z` form this repository declares. */
|
||||
export function satisfiesEngine(version: string, range: string): boolean {
|
||||
const current = parseVersion(version);
|
||||
for (const clause of range.trim().split(/\s+/u)) {
|
||||
const match = /^(>=|<=|>|<|=)?(\d+(?:\.\d+){0,2})$/u.exec(clause);
|
||||
if (!match) return false;
|
||||
const order = compare(current, parseVersion(match[2] as string));
|
||||
const operator = match[1] ?? "=";
|
||||
const ok =
|
||||
operator === ">=" ? order >= 0
|
||||
: operator === "<=" ? order <= 0
|
||||
: operator === ">" ? order > 0
|
||||
: operator === "<" ? order < 0
|
||||
: order === 0;
|
||||
if (!ok) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
async function main(): Promise<void> {
|
||||
const root = process.cwd();
|
||||
const pkg = JSON.parse(await readFile(path.join(root, "package.json"), "utf8")) as {
|
||||
engines?: { node?: string };
|
||||
};
|
||||
const engine = pkg.engines?.node ?? "";
|
||||
const directory = path.join(root, "artifacts/quality/extreme-scale-gates");
|
||||
const artifact = path.join(root, "artifacts/quality/extreme-scale-gates.json");
|
||||
await mkdir(directory, { recursive: true });
|
||||
const startedAt = new Date();
|
||||
const pnpmVersion =
|
||||
spawnSync("corepack", ["pnpm", "--version"], { cwd: root, encoding: "utf8" }).stdout?.trim() ?? "";
|
||||
const identity = {
|
||||
node: process.version,
|
||||
nodeMajor: Number(process.versions.node.split(".")[0]),
|
||||
pnpm: pnpmVersion,
|
||||
engine,
|
||||
platform: platform(),
|
||||
arch: arch(),
|
||||
user: (() => {
|
||||
try {
|
||||
return userInfo().username;
|
||||
} catch {
|
||||
return "unknown";
|
||||
}
|
||||
})(),
|
||||
};
|
||||
|
||||
if (!satisfiesEngine(process.version, engine)) {
|
||||
await writeFile(
|
||||
artifact,
|
||||
`${JSON.stringify(
|
||||
{
|
||||
schemaVersion: 1,
|
||||
generatedAt: new Date().toISOString(),
|
||||
...identity,
|
||||
status: "not-executed",
|
||||
reason: `Node ${process.version} does not satisfy engines.node "${engine}"`,
|
||||
gates: [],
|
||||
},
|
||||
null,
|
||||
2,
|
||||
)}\n`,
|
||||
);
|
||||
process.stderr.write(
|
||||
`not executed: Node ${process.version} does not satisfy "${engine}". Put a supported node first on PATH.\n`,
|
||||
);
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
const browsers = path.join(root, ".tmp/ms-playwright");
|
||||
const env = {
|
||||
...process.env,
|
||||
pnpm_config_verify_deps_before_run: "false",
|
||||
...(process.env["PLAYWRIGHT_BROWSERS_PATH"] === undefined && existsSync(browsers)
|
||||
? { PLAYWRIGHT_BROWSERS_PATH: browsers }
|
||||
: {}),
|
||||
};
|
||||
const only = process.argv.find((argument) => argument.startsWith("--only="))?.slice(7).split(",");
|
||||
const gates = only ? EXTREME_SCALE_GATES.filter((gate) => only.includes(gate)) : EXTREME_SCALE_GATES;
|
||||
const sourceBefore = await sourceDigest(root);
|
||||
const results: {
|
||||
gate: string;
|
||||
status: "passed" | "failed";
|
||||
exitCode: number | null;
|
||||
durationMs: number;
|
||||
tests: ReturnType<typeof vitestCounts>;
|
||||
log: string;
|
||||
}[] = [];
|
||||
for (const gate of gates) {
|
||||
const gateStartedAt = Date.now();
|
||||
const run = spawnSync("corepack", ["pnpm", "run", gate], {
|
||||
cwd: root,
|
||||
env,
|
||||
encoding: "utf8",
|
||||
maxBuffer: 256 * 1024 * 1024,
|
||||
});
|
||||
const log = path.join(directory, `${gate.replaceAll(":", "-")}.log`);
|
||||
await writeFile(log, `${run.stdout ?? ""}${run.stderr ?? ""}`);
|
||||
const status = run.status === 0 ? "passed" : "failed";
|
||||
const tests = vitestCounts(`${run.stdout ?? ""}${run.stderr ?? ""}`);
|
||||
results.push({
|
||||
gate,
|
||||
status,
|
||||
exitCode: run.status,
|
||||
durationMs: Date.now() - gateStartedAt,
|
||||
tests,
|
||||
log: path.relative(root, log),
|
||||
});
|
||||
process.stdout.write(
|
||||
`${status.toUpperCase()} ${gate} (${Date.now() - gateStartedAt}ms${tests.passed + tests.failed > 0 ? `, ${tests.passed} tests passed, ${tests.failed} failed` : ""})\n`,
|
||||
);
|
||||
}
|
||||
const sourceAfter = await sourceDigest(root);
|
||||
|
||||
const readJson = async (relative: string) => {
|
||||
const file = path.join(root, relative);
|
||||
if (!existsSync(file)) return null;
|
||||
const fresh = (await stat(file)).mtimeMs >= startedAt.getTime();
|
||||
return { fresh, value: JSON.parse(await readFile(file, "utf8")) as Record<string, unknown> };
|
||||
};
|
||||
// Machine-readable artifacts the acceptance depends on must be produced by
|
||||
// this run, on this Node, and say passed. An old PASS is not evidence.
|
||||
const evidenceChecks: { artifact: string; check: string; passed: boolean }[] = [];
|
||||
const expect = (artifact: string, check: string, passed: boolean) =>
|
||||
evidenceChecks.push({ artifact, check, passed });
|
||||
const ran = new Set(gates);
|
||||
for (const tier of ["nightly", "release"] as const) {
|
||||
if (!ran.has(`check:scale:${tier}`)) continue;
|
||||
const relative = `artifacts/scale/${tier}/summary.json`;
|
||||
const summary = await readJson(relative);
|
||||
expect(relative, "regenerated during this run", summary?.fresh === true);
|
||||
expect(relative, "status passed with no skipped step", summary?.value["status"] === "passed" && Array.isArray(summary.value["skipped"]) && summary.value["skipped"].length === 0);
|
||||
const environment = summary?.value["environment"] as { nodeMajor?: number } | undefined;
|
||||
expect(relative, `environment.nodeMajor == ${identity.nodeMajor}`, environment?.nodeMajor === identity.nodeMajor);
|
||||
}
|
||||
const soakRecord = ran.has("check:scale:nightly")
|
||||
? await readJson("artifacts/scale/nightly/browser-soak.json")
|
||||
: null;
|
||||
if (ran.has("check:scale:nightly")) {
|
||||
expect("artifacts/scale/nightly/browser-soak.json", "regenerated during this run", soakRecord?.fresh === true);
|
||||
expect("artifacts/scale/nightly/browser-soak.json", "status passed (not skipped)", soakRecord?.value["status"] === "passed");
|
||||
}
|
||||
if (ran.has("check:scale:baseline")) {
|
||||
const comparison = await readJson("artifacts/scale/baseline-comparison.json");
|
||||
expect("artifacts/scale/baseline-comparison.json", "regenerated during this run", comparison?.fresh === true);
|
||||
expect("artifacts/scale/baseline-comparison.json", "status passed on all axes (timing compatible)", comparison?.value["status"] === "passed");
|
||||
}
|
||||
if (ran.has("check:app-build-input:bundle")) {
|
||||
const inventory = await readJson("artifacts/quality/vite-module-inventory.json");
|
||||
expect(
|
||||
"artifacts/quality/vite-module-inventory.json",
|
||||
"produced by this run's build (bundle isolation checked on current code)",
|
||||
inventory?.fresh === true,
|
||||
);
|
||||
}
|
||||
expect("source tree", "unchanged while the gates ran", sourceBefore.digest === sourceAfter.digest);
|
||||
const soak = soakRecord?.value ?? null;
|
||||
const status =
|
||||
results.every((result) => result.status === "passed") && evidenceChecks.every((check) => check.passed)
|
||||
? "passed"
|
||||
: "failed";
|
||||
await writeFile(
|
||||
artifact,
|
||||
`${JSON.stringify(
|
||||
{
|
||||
schemaVersion: 1,
|
||||
generatedAt: new Date().toISOString(),
|
||||
startedAt: startedAt.toISOString(),
|
||||
...identity,
|
||||
source: { digest: sourceAfter.digest, files: sourceAfter.files },
|
||||
status,
|
||||
gates: results,
|
||||
totals: {
|
||||
gates: results.length,
|
||||
passedGates: results.filter((result) => result.status === "passed").length,
|
||||
testsPassed: results.reduce((sum, result) => sum + result.tests.passed, 0),
|
||||
testsFailed: results.reduce((sum, result) => sum + result.tests.failed, 0),
|
||||
},
|
||||
evidenceChecks,
|
||||
browserSoak: soak
|
||||
? {
|
||||
status: soak["status"],
|
||||
classification: soak["classification"],
|
||||
samples: Array.isArray(soak["samples"]) ? soak["samples"].length : 0,
|
||||
summary: soak["summary"],
|
||||
browser: soak["browser"],
|
||||
build: soak["build"],
|
||||
}
|
||||
: null,
|
||||
},
|
||||
null,
|
||||
2,
|
||||
)}\n`,
|
||||
);
|
||||
process.stdout.write(`extreme-scale gates: ${status.toUpperCase()} on Node ${process.version} (${path.relative(root, artifact)})\n`);
|
||||
if (status !== "passed") process.exitCode = 1;
|
||||
}
|
||||
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
await main();
|
||||
}
|
||||
Reference in New Issue
Block a user