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)
186 lines
7.9 KiB
TypeScript
186 lines
7.9 KiB
TypeScript
import { mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
|
|
import { afterEach, describe, expect, it } from "vitest";
|
|
|
|
import { loadCiGateContract } from "../../scripts/contracts/ci-gates.ts";
|
|
import {
|
|
assertNoRuntimeImports,
|
|
pruneRemovalFixtureCiContract,
|
|
removeRuntimeDependentTests,
|
|
renderRemovalJunit,
|
|
runtimeImportGraph,
|
|
} from "../../scripts/lib/removal-fixture.ts";
|
|
|
|
const temporaryRoots: string[] = [];
|
|
|
|
afterEach(async () => {
|
|
await Promise.all(
|
|
temporaryRoots.splice(0).map((root) => rm(root, { recursive: true, force: true })),
|
|
);
|
|
});
|
|
|
|
it("rejects an empty scanned module universe", async () => {
|
|
const root = await mkdtemp(path.join(tmpdir(), "removal-fixture-empty-modules-"));
|
|
temporaryRoots.push(root);
|
|
|
|
await expect(runtimeImportGraph(root, ["src/runtime"])).rejects.toThrow(
|
|
/scanned module universe is empty/i,
|
|
);
|
|
});
|
|
|
|
it("rejects a runtime removal scan that discovers no dependent tests", async () => {
|
|
const root = await mkdtemp(path.join(tmpdir(), "removal-fixture-zero-dependent-tests-"));
|
|
temporaryRoots.push(root);
|
|
await mkdir(path.join(root, "src/runtime"), { recursive: true });
|
|
await mkdir(path.join(root, "tests"), { recursive: true });
|
|
await writeFile(path.join(root, "src/runtime/index.ts"), "export const runtime = true;\n");
|
|
await writeFile(path.join(root, "tests/unrelated.test.ts"), "export const unrelated = true;\n");
|
|
|
|
await expect(removeRuntimeDependentTests(root, ["src/runtime"])).rejects.toThrow(
|
|
/no runtime-dependent tests discovered/i,
|
|
);
|
|
});
|
|
|
|
it("allows zero runtime imports after the runtime has been removed", async () => {
|
|
const root = await mkdtemp(path.join(tmpdir(), "removal-fixture-post-removal-"));
|
|
temporaryRoots.push(root);
|
|
await mkdir(path.join(root, "tests"), { recursive: true });
|
|
await writeFile(path.join(root, "tests/unrelated.test.ts"), "export const unrelated = true;\n");
|
|
|
|
await expect(
|
|
assertNoRuntimeImports(root, ["src/runtime"], "fixture runtime"),
|
|
).resolves.toBeUndefined();
|
|
});
|
|
|
|
async function copyCiContract(prefix: string): Promise<string> {
|
|
const root = await mkdtemp(path.join(tmpdir(), prefix));
|
|
temporaryRoots.push(root);
|
|
await mkdir(path.join(root, "config/ci"), { recursive: true });
|
|
for (const file of ["config/ci/gates.json", "config/ci/contract-baseline.json", "package.json"]) {
|
|
await writeFile(path.join(root, file), await readFile(file));
|
|
}
|
|
return root;
|
|
}
|
|
|
|
// D-13: a removal takes the same step a downstream project takes — it records
|
|
// the reduced contract as the new baseline — and then loads canonically.
|
|
it("prunes removed command and evidence references and re-baselines the contract", async () => {
|
|
const root = await copyCiContract("removal-fixture-contract-");
|
|
|
|
await pruneRemovalFixtureCiContract({
|
|
root,
|
|
removedScripts: new Set(["test:reference-feature"]),
|
|
removedEvidencePathFragments: ["reference-feature.xml"],
|
|
});
|
|
|
|
const contract = await loadCiGateContract(root);
|
|
expect(contract.commands.some(({ script }) => script === "test:reference-feature")).toBe(false);
|
|
expect(contract.artifacts.some(({ path }) => path.includes("reference-feature.xml"))).toBe(false);
|
|
expect(contract.gates.some(({ commandIds }) => commandIds.includes("test-reference-feature"))).toBe(false);
|
|
expect(contract.gates.some(({ evidenceArtifactIds }) =>
|
|
evidenceArtifactIds.includes("artifact-artifacts-tests-reference-feature-xml")
|
|
)).toBe(false);
|
|
const baseline = JSON.parse(
|
|
await readFile(path.join(root, "config/ci/contract-baseline.json"), "utf8"),
|
|
) as Record<string, unknown>;
|
|
expect(baseline).toMatchObject({ commands: contract.commands.length, owner: "removal-fixture" });
|
|
const packageDocument = JSON.parse(await readFile(path.join(root, "package.json"), "utf8")) as {
|
|
scripts: Record<string, string>;
|
|
};
|
|
expect(packageDocument.scripts["check:ci"]).not.toMatch(/reduced/u);
|
|
});
|
|
|
|
it("rejects a contract that no longer matches its committed baseline", async () => {
|
|
const root = await copyCiContract("removal-fixture-baseline-drift-");
|
|
const baselinePath = path.join(root, "config/ci/contract-baseline.json");
|
|
const baseline = JSON.parse(await readFile(baselinePath, "utf8")) as Record<string, number>;
|
|
await writeFile(baselinePath, JSON.stringify({ ...baseline, commands: baseline.commands! + 1 }));
|
|
|
|
await expect(loadCiGateContract(root)).rejects.toThrow(
|
|
/contract-baseline\.json[\s\S]*commands[\s\S]*update:ci-contract-baseline/u,
|
|
);
|
|
});
|
|
|
|
it("rejects pruning that leaves a reduced gate without commands", async () => {
|
|
const root = await copyCiContract("removal-fixture-empty-gate-");
|
|
|
|
await expect(pruneRemovalFixtureCiContract({
|
|
root,
|
|
removedScripts: new Set(["test:runtime-schema"]),
|
|
removedEvidencePathFragments: ["runtime-schema.xml"],
|
|
})).rejects.toThrow(/commandIds|too small|at least 1/i);
|
|
});
|
|
|
|
describe("release evidence fixture copy", () => {
|
|
it("keeps the release evidence and leaves the regenerated trees behind", async () => {
|
|
const { copyReleaseEvidenceTree, RELEASE_EVIDENCE_REGENERATED_TREES } =
|
|
await import("../../scripts/lib/removal-fixture.ts");
|
|
const { RELEASE_CANDIDATE_EVIDENCE_PATHS } = await import(
|
|
"../../scripts/lib/release-candidate.ts"
|
|
);
|
|
const { access, readdir } = await import("node:fs/promises");
|
|
|
|
// The source is a fake checkout, not process.cwd(): release evidence is
|
|
// git-ignored, so a fresh clone has none of it and the copy would be
|
|
// checked against nothing.
|
|
const source = await mkdtemp(path.join(tmpdir(), "release-evidence-source-"));
|
|
const target = await mkdtemp(path.join(tmpdir(), "release-evidence-target-"));
|
|
temporaryRoots.push(source, target);
|
|
const evidencePaths = RELEASE_CANDIDATE_EVIDENCE_PATHS.filter((evidence) =>
|
|
evidence.startsWith("artifacts/")
|
|
);
|
|
expect(evidencePaths.length).toBeGreaterThan(0);
|
|
for (const relative of [
|
|
...evidencePaths,
|
|
...RELEASE_EVIDENCE_REGENERATED_TREES.map((tree) => `${tree}/trace.zip`),
|
|
]) {
|
|
await mkdir(path.dirname(path.join(source, relative)), { recursive: true });
|
|
await writeFile(path.join(source, relative), "{}\n");
|
|
}
|
|
|
|
await copyReleaseEvidenceTree(source, target);
|
|
|
|
// Every release artifact has to survive the copy; a fixture missing one
|
|
// cannot build a candidate at all, and every provider suite then fails
|
|
// while constructing its own fixture.
|
|
for (const evidence of evidencePaths) {
|
|
await expect(access(path.join(target, evidence)), evidence).resolves.toBeUndefined();
|
|
}
|
|
// The regenerated trees are why this is a filter and not a plain copy: they
|
|
// are tens of megabytes of traces and coverage HTML. They still exist,
|
|
// because the repository inventory expects the directories.
|
|
for (const tree of RELEASE_EVIDENCE_REGENERATED_TREES) {
|
|
await expect(readdir(path.join(target, tree)), tree).resolves.toEqual([]);
|
|
}
|
|
});
|
|
});
|
|
|
|
describe("removal JUnit report (14-08)", () => {
|
|
it("counts every failure and gives each check its own cause", () => {
|
|
const xml = renderRemovalJunit("reference-feature-removal", [
|
|
{ name: "typecheck", passed: false, failure: "corepack pnpm check:types exited 2" },
|
|
{ name: "architecture", passed: true },
|
|
{ name: "build", passed: false, failure: "corepack pnpm build exited 1" },
|
|
{
|
|
name: "fixture-id-residue",
|
|
passed: false,
|
|
failure: "residue: tests/a.test.ts, tests/<b>&c.ts",
|
|
},
|
|
]);
|
|
expect(xml).toContain('tests="4" failures="3"');
|
|
expect(xml).toContain(
|
|
'<testcase name="typecheck"><failure message="corepack pnpm check:types exited 2" /></testcase>',
|
|
);
|
|
expect(xml).toContain('<testcase name="architecture"></testcase>');
|
|
expect(xml).toContain(
|
|
'<failure message="corepack pnpm build exited 1" />',
|
|
);
|
|
expect(xml).toContain(
|
|
'message="residue: tests/a.test.ts, tests/<b>&c.ts"',
|
|
);
|
|
expect(xml.match(/residue:/gu)).toHaveLength(1);
|
|
});
|
|
});
|