fix: main에서 실패하던 typecheck·unit·registry 게이트를 고친다 #6

Merged
donghyeon.kang merged 6 commits from fix/main-gates into main 2026-11-12 04:28:28 +00:00
16 changed files with 238 additions and 33 deletions
+1 -1
View File
@@ -144,7 +144,7 @@
"script": "check:types:fixture:route-runtime",
"expect": "fail",
"expectedExitCode": 1,
"expectedDiagnosticId": "error TS2740:"
"expectedDiagnosticId": "error TS2741:"
},
{
"id": "check-types-fixture-page-action",
@@ -488,6 +488,54 @@
"compatibilityWindow": "The deployed release consumes only its same-release registry snapshot; the rows leave the registries, the bundle and the contract set in one release.",
"rollback": "Revert the template sync commit (rollback ref backup/main-before-template-af3d8e6), or reinstall the sample with its presentation, feature-module.ts and context-routes.ts.",
"owner": "tech-log-frontend"
},
{
"changeId": "FE-REG-ROUTE:TECH_LOG_RELEASES:navigationLabel:field-type-changed",
"versionBump": "The releases page leaves the primary navigation (navigationLabel \"변경 기록\" and navigationOrder 30 become null, 2026-09). The route, path /releases, title and chunk are unchanged.",
"migration": "Nothing to migrate: /releases still resolves and the public shell keeps its link to it (public-shell.tsx, publicSiteConfig.releasesPath); only the primary navigation entry is gone.",
"compatibilityWindow": "None needed. Bookmarks and links to /releases keep working; no route id or path changed.",
"rollback": "Restore navigationLabel \"변경 기록\" and navigationOrder 30 on TECH_LOG_RELEASES in src/features/tech-log/contracts/tech-log-route-contract.ts.",
"owner": "tech-log-frontend"
},
{
"changeId": "FE-REG-ROUTE:TECH_LOG_RELEASES:navigationOrder:field-type-changed",
"versionBump": "The releases page leaves the primary navigation (navigationLabel \"변경 기록\" and navigationOrder 30 become null, 2026-09). The route, path /releases, title and chunk are unchanged.",
"migration": "Nothing to migrate: /releases still resolves and the public shell keeps its link to it (public-shell.tsx, publicSiteConfig.releasesPath); only the primary navigation entry is gone.",
"compatibilityWindow": "None needed. Bookmarks and links to /releases keep working; no route id or path changed.",
"rollback": "Restore navigationLabel \"변경 기록\" and navigationOrder 30 on TECH_LOG_RELEASES in src/features/tech-log/contracts/tech-log-route-contract.ts.",
"owner": "tech-log-frontend"
},
{
"changeId": "FE-REG-ROUTE:TECH_LOG_STUDIO_DOCUMENTS:searchSchema:field-type-changed",
"versionBump": "TECH_LOG_STUDIO_DOCUMENTS reads its search, filter and page state from the URL through TechLogStudioDocumentsSearch (STRIP_UNKNOWN), 2026-09 UX review H1. Before, the list kept that state in memory and lost it on back navigation.",
"migration": "Old links without a query string open the list unfiltered on page 1, as before. Unknown keys are stripped, not rejected.",
"compatibilityWindow": "None needed: STRIP_UNKNOWN accepts every URL the previous contract accepted.",
"rollback": "Set searchSchema back to null on TECH_LOG_STUDIO_DOCUMENTS in tech-log-route-contract.ts, drop TechLogStudioDocumentsSearch from TECH_LOG_ROUTE_CODECS and the route runtime searchCodec back to none; the list then keeps its state in memory again.",
"owner": "tech-log-frontend"
},
{
"changeId": "FE-REG-ROUTE:TECH_LOG_STUDIO_PUBLICATIONS:searchSchema:field-type-changed",
"versionBump": "TECH_LOG_STUDIO_PUBLICATIONS reads its search, filter and page state from the URL through TechLogStudioPublicationsSearch (STRIP_UNKNOWN), 2026-09 UX review H1. Before, the list kept that state in memory and lost it on back navigation.",
"migration": "Old links without a query string open the list unfiltered on page 1, as before. Unknown keys are stripped, not rejected.",
"compatibilityWindow": "None needed: STRIP_UNKNOWN accepts every URL the previous contract accepted.",
"rollback": "Set searchSchema back to null on TECH_LOG_STUDIO_PUBLICATIONS in tech-log-route-contract.ts, drop TechLogStudioPublicationsSearch from TECH_LOG_ROUTE_CODECS and the route runtime searchCodec back to none; the list then keeps its state in memory again.",
"owner": "tech-log-frontend"
},
{
"changeId": "FE-REG-ROUTE-RUNTIME:TECH_LOG_STUDIO_DOCUMENTS:searchCodec:field-changed",
"versionBump": "TECH_LOG_STUDIO_DOCUMENTS reads its search, filter and page state from the URL through TechLogStudioDocumentsSearch (STRIP_UNKNOWN), 2026-09 UX review H1. Before, the list kept that state in memory and lost it on back navigation.",
"migration": "Old links without a query string open the list unfiltered on page 1, as before. Unknown keys are stripped, not rejected.",
"compatibilityWindow": "None needed: STRIP_UNKNOWN accepts every URL the previous contract accepted.",
"rollback": "Set searchSchema back to null on TECH_LOG_STUDIO_DOCUMENTS in tech-log-route-contract.ts, drop TechLogStudioDocumentsSearch from TECH_LOG_ROUTE_CODECS and the route runtime searchCodec back to none; the list then keeps its state in memory again.",
"owner": "tech-log-frontend"
},
{
"changeId": "FE-REG-ROUTE-RUNTIME:TECH_LOG_STUDIO_PUBLICATIONS:searchCodec:field-changed",
"versionBump": "TECH_LOG_STUDIO_PUBLICATIONS reads its search, filter and page state from the URL through TechLogStudioPublicationsSearch (STRIP_UNKNOWN), 2026-09 UX review H1. Before, the list kept that state in memory and lost it on back navigation.",
"migration": "Old links without a query string open the list unfiltered on page 1, as before. Unknown keys are stripped, not rejected.",
"compatibilityWindow": "None needed: STRIP_UNKNOWN accepts every URL the previous contract accepted.",
"rollback": "Set searchSchema back to null on TECH_LOG_STUDIO_PUBLICATIONS in tech-log-route-contract.ts, drop TechLogStudioPublicationsSearch from TECH_LOG_ROUTE_CODECS and the route runtime searchCodec back to none; the list then keeps its state in memory again.",
"owner": "tech-log-frontend"
}
]
}
+4 -1
View File
@@ -60,6 +60,7 @@
"ReferenceResourceParams",
"TechLogExploreKindParams",
"TechLogSlugParams",
"TechLogTopicVariantParams",
"TechLogVersionParams",
"TechLogDocumentIdParams",
"TechLogPublicationEventIdParams",
@@ -72,7 +73,9 @@
"TechLogExploreSearch",
"TechLogExploreKindSearch",
"TechLogSearchQuery",
"TechLogCaseStateSearch"
"TechLogCaseStateSearch",
"TechLogStudioDocumentsSearch",
"TechLogStudioPublicationsSearch"
],
"loadingSurface": [
"app-shell",
+5
View File
@@ -30,6 +30,11 @@ export default defineConfig({
"corepack pnpm dev --host 127.0.0.1 --port 4174",
url: "http://127.0.0.1:4174",
reuseExistingServer: false,
// Template af312dee. The dev server serves public/config.json, the local
// profile, whose BUILD_ID is local-build. CI sets VITE_BUILD_ID for the whole
// workflow; built into the dev bundle it makes every page a rolling-release
// mismatch that reloads once and then fails closed (CONFIG_BUILD_MISMATCH).
env: { VITE_BUILD_ID: "local-build", VITE_COMMIT_SHA: "local" },
},
projects: [
{
+5
View File
@@ -12,5 +12,10 @@ export default defineConfig({
command: "corepack pnpm dev --host 127.0.0.1",
url: "http://127.0.0.1:5173",
reuseExistingServer: true,
// Template af312dee. The dev server serves public/config.json, the local
// profile, whose BUILD_ID is local-build. CI sets VITE_BUILD_ID for the whole
// workflow; built into the dev bundle it makes every page a rolling-release
// mismatch that reloads once and then fails closed (CONFIG_BUILD_MISMATCH).
env: { VITE_BUILD_ID: "local-build", VITE_COMMIT_SHA: "local" },
},
});
+11 -6
View File
@@ -9,6 +9,10 @@ import type {
CiGateArtifactSchema,
} from "../contracts/ci-gates.ts";
import { ciContractReportSchema } from "./ci-contract-report.ts";
import {
COVERAGE_SUMMARY_METRICS,
COVERAGE_SUMMARY_OPTIONAL_METRICS,
} from "./coverage-summary-metrics.ts";
import {
architectureDependencyReportArtifactSchema,
automatedA11yArtifactSchema,
@@ -76,16 +80,17 @@ const coverageCounterSchema = z
context.addIssue({ code: "custom", path: ["pct"], message: "coverage pct is not exact" });
}
});
// 1103/12-09. The key list is shared with the risk coverage gate, which reads
// the same file; this schema used to refuse the `branchesTrue` the reporter
// always writes.
const coverageSummarySchema = z
.record(
z.string(),
z
.object({
lines: coverageCounterSchema,
statements: coverageCounterSchema,
functions: coverageCounterSchema,
branches: coverageCounterSchema,
})
.object(Object.fromEntries([
...COVERAGE_SUMMARY_METRICS.map((metric) => [metric, coverageCounterSchema]),
...COVERAGE_SUMMARY_OPTIONAL_METRICS.map((metric) => [metric, coverageCounterSchema.optional()]),
]))
.strict(),
)
.refine((value) => "total" in value, "coverage summary lacks total");
+24
View File
@@ -0,0 +1,24 @@
/**
* The keys of one entry in Vitest's `coverage-summary.json`. Two readers check
* that file: the CI evidence validator (ci-artifact-validator.ts) and the risk
* coverage gate (risk-coverage.ts). They kept separate lists, and the
* validator refused `branchesTrue` while the gate accepted it, so FE-GATE-005
* failed at its evidence step after every test had passed (1103/12-09).
*/
/** The four metrics both readers evaluate. */
export const COVERAGE_SUMMARY_METRICS = Object.freeze([
"lines",
"statements",
"functions",
"branches",
] as const);
/**
* Keys the reporter may add. istanbul-lib-coverage 3.2.2 puts `branchesTrue`
* in every blank summary, so the total always carries it. Each is still
* checked as a counter; neither reader evaluates it.
*/
export const COVERAGE_SUMMARY_OPTIONAL_METRICS = Object.freeze([
"branchesTrue",
] as const);
+11 -9
View File
@@ -8,14 +8,12 @@ import {
import path from "node:path";
import babelParser from "@babel/eslint-parser";
import {
COVERAGE_SUMMARY_METRICS as coverageMetrics,
COVERAGE_SUMMARY_OPTIONAL_METRICS,
} from "./coverage-summary-metrics.ts";
import { normalizeRepositoryRelativePath } from "./repository-file-inventory.ts";
const coverageMetrics = [
"lines",
"statements",
"functions",
"branches",
] as const;
const teamIdPattern = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;
const maximumWaiverDurationMs = 90 * 24 * 60 * 60 * 1_000;
@@ -643,16 +641,20 @@ function parseCoverageCounter(value: unknown, label: string): CoverageCounter {
function parseCoverageMetrics(value: unknown, label: string): CoverageMetrics {
if (!isRecord(value)) throw new TypeError(`${label} must be an object`);
const optionalMetrics: readonly string[] = COVERAGE_SUMMARY_OPTIONAL_METRICS;
const unknownMetrics = Object.keys(value).filter(
(metric) => metric !== "branchesTrue" && !coverageMetrics.includes(metric as CoverageMetric),
(metric) =>
!optionalMetrics.includes(metric) && !coverageMetrics.includes(metric as CoverageMetric),
);
if (unknownMetrics.length > 0) {
throw new TypeError(
`${label} has unknown coverage metric keys: ${unknownMetrics.sort().join(", ")}`,
);
}
if (value.branchesTrue !== undefined) {
parseCoverageCounter(value.branchesTrue, `${label}.branchesTrue`);
for (const metric of optionalMetrics) {
if (value[metric] !== undefined) {
parseCoverageCounter(value[metric], `${label}.${metric}`);
}
}
const parsed = {} as Record<CoverageMetric, CoverageCounter>;
for (const metric of coverageMetrics) {
@@ -27,7 +27,7 @@ export async function collectCatalog(
const items: CatalogPage["items"][number][] = [];
let cursor: string | undefined;
for (let page = 0; page < MAX_PAGES; page += 1) {
const result: CatalogPage = await gateway.getCatalog(
const result: CatalogPage = await gateway.getCatalog( // fanout-reviewed: cursor pagination; each page needs the previous page's nextCursor, so the calls cannot be batched
{ ...query, limit: PAGE_SIZE, ...(cursor === undefined ? {} : { cursor }) },
options,
);
@@ -94,6 +94,11 @@ export const TECH_LOG_ROUTE_SCHEMA_REGISTRY = Object.freeze({
"route-params",
"REJECT_UNKNOWN",
),
TechLogTopicVariantParams: routeSchema(
"TechLogTopicVariantParams",
"route-params",
"REJECT_UNKNOWN",
),
TechLogVersionParams: routeSchema(
"TechLogVersionParams",
"route-params",
+7 -3
View File
@@ -2,9 +2,13 @@ import { ROUTE_RUNTIME_CONTRACT } from "../../../src/features/installed-feature-
type RouteId = keyof typeof ROUTE_RUNTIME_CONTRACT;
export const missingRuntime = {
APP_HOME: true,
} satisfies Record<RouteId, boolean>;
// Exactly one route is left out, as the template does since e47a0ab2 (2026-11-07):
// one missing key is TS2741 at any route count, where a short or long list of
// missing keys is TS2739 or TS2740. The left-out route must exist here: this
// product has no APP_HOME, and the template's literal { APP_HOME: true } failed
// as an unknown property (TS2353) instead of the missing-runtime error.
declare const withoutHome: Omit<Record<RouteId, boolean>, "TECH_LOG_HOME">;
export const missingRuntime: Record<RouteId, boolean> = withoutHome;
export const orphanRuntime = {
...Object.fromEntries(
@@ -114,7 +114,9 @@ describe("expected contract set composition", () => {
(entry) => entry.packageId === "@tech-log/studio-contract",
);
expect(techLog).toBeTruthy();
expect(techLog?.version).toBe("3.0.0");
// src/features/tech-log/contracts/studio/canonical-source.json (3.1.0 since
// the Studio contract gained project publication and home ordering).
expect(techLog?.version).toBe("3.1.0");
});
});
+25 -10
View File
@@ -1,5 +1,5 @@
import { spawnSync } from "node:child_process";
import { mkdtemp, readdir, readFile, rm } from "node:fs/promises";
import { mkdtemp, readFile, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
@@ -67,16 +67,31 @@ describe("build variables in the bundle (13-06)", () => {
const second = await build({ ...DECLARED, VITE_BUILD_ID: "build-probe-2" });
expect(second.run.status).toBe(0);
// The shared application chunk, which Vite names after one of its modules:
// `design-system-*` upstream. This product's route chunk split
// (vite.config.ts) leaves `render-boot-failure-*` as that chunk here.
const designSystem = async (outDir: string) =>
(await readdir(path.join(outDir, "assets"))).filter((name) =>
name.startsWith("render-boot-failure-"),
);
const firstChunks = await designSystem(first.outDir);
// The design system, found by what it holds rather than by name: this
// product's route chunk split (vite.config.ts) names chunks after route
// modules, and upstream's `design-system-*` does not exist here.
// (The previous check looked at `render-boot-failure-*`, which holds the
// build id on purpose and can never keep its name.)
const designSystem = ({ contents }: Awaited<ReturnType<typeof build>>) =>
contents
.filter(({ file, text }) =>
file.endsWith(".js") && text.includes("ui-button--pending"),
)
.map(({ file }) => path.basename(file));
const firstChunks = designSystem(first);
expect(firstChunks).toHaveLength(1);
expect(await designSystem(second.outDir)).toEqual(firstChunks);
expect(designSystem(second)).toEqual(firstChunks);
// Template 1103/15-06. react-dom sat in the boot-failure chunk with the
// build id, so every release renamed it and returning visitors downloaded
// it again. Its own chunk keeps the name while only the build id changes.
const reactDom = ({ contents }: Awaited<ReturnType<typeof build>>) =>
contents
.filter(({ file, text }) => file.endsWith(".js") && text.includes("__reactContainer$"))
.map(({ file }) => path.basename(file));
expect(reactDom(first)).toHaveLength(1);
expect(reactDom(first)[0]).not.toMatch(/render-boot-failure/u);
expect(reactDom(second)).toEqual(reactDom(first));
}, 120_000);
it("refuses a VITE_* variable the build does not declare", async () => {
@@ -0,0 +1,66 @@
import { mkdir, mkdtemp, 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 { validateCiArtifact } from "../../scripts/lib/ci-artifact-validator.ts";
const SUMMARY_PATH = "artifacts/tests/coverage/coverage-summary.json";
const roots: string[] = [];
afterEach(async () => {
await Promise.all(roots.splice(0).map((root) => rm(root, { recursive: true, force: true })));
});
const counter = (total: number, covered = total) => ({
total,
covered,
skipped: 0,
pct: total === 0 ? 100 : Math.floor((covered / total) * 10_000) / 100,
});
const metrics = {
lines: counter(4),
statements: counter(4),
functions: counter(1),
branches: counter(2),
};
async function validateSummary(summary: unknown): Promise<void> {
const contract = await loadCiGateContract(process.cwd());
const artifact = contract.artifacts.find((entry) => entry.path === SUMMARY_PATH);
const schema = contract.artifactSchemas.find((entry) => entry.id === artifact?.schemaId);
if (!artifact || !schema) throw new Error(`the CI contract no longer declares ${SUMMARY_PATH}`);
const root = await mkdtemp(path.join(tmpdir(), "coverage-summary-artifact-"));
roots.push(root);
await mkdir(path.join(root, path.dirname(SUMMARY_PATH)), { recursive: true });
await writeFile(path.join(root, SUMMARY_PATH), `${JSON.stringify(summary)}\n`);
await validateCiArtifact({ root, artifact, schema });
}
// 1103/12-09. istanbul-lib-coverage 3.2.2 puts `branchesTrue` in every blank
// summary, so the json-summary total always carries it. The CI evidence check
// refused the key that the risk-coverage gate reading the same file accepts,
// and FE-GATE-005 failed after every test had passed.
describe("coverage summary evidence (1103/12-09)", () => {
it("accepts the summary the coverage reporter writes, with branchesTrue", async () => {
await expect(validateSummary({
total: { ...metrics, branchesTrue: counter(0) },
"src/a.ts": metrics,
})).resolves.toBeUndefined();
});
it("accepts a summary without branchesTrue", async () => {
await expect(validateSummary({ total: metrics, "src/a.ts": metrics }))
.resolves.toBeUndefined();
});
it("still validates branchesTrue as a counter and refuses other keys", async () => {
await expect(validateSummary({
total: { ...metrics, branchesTrue: { ...counter(0), pct: 0 } },
})).rejects.toThrow(/pct/u);
await expect(validateSummary({ total: { ...metrics, branchesFalse: counter(0) } }))
.rejects.toThrow(/branchesFalse/u);
});
});
+14 -1
View File
@@ -65,6 +65,10 @@ const techLogRouteChunks = Object.freeze({
"/public/pages/public-not-found-page.tsx": "route-not-found",
} as const);
// pnpm lays packages out as node_modules/.pnpm/<name>@<version>/node_modules/<name>.
const REACT_DOM_MODULE =
/[\\/]node_modules[\\/](?:\.pnpm[\\/][^\\/]+[\\/]node_modules[\\/])?(?:react-dom|scheduler)[\\/]/;
function routeChunkName(moduleId: string): string | undefined {
const normalized = moduleId.replaceAll("\\", "/");
const featurePath = "/src/features/tech-log/presentation";
@@ -139,10 +143,19 @@ export default defineConfig(({ mode }) => {
// 09-03. The entry now imports the app dynamically, so Vite's preload
// helper would land in the entry chunk and every lazy chunk would
// import the entry, whose hash changes with each build id.
//
// Template 1103/15-06 (af6d0a9f). react-dom and scheduler shared the
// boot-failure chunk with the build id (getBuildConfig), so a release
// that only changed the build id renamed that 190 KB chunk and
// returning visitors downloaded it again. In a chunk of their own they
// keep their name; only boot, the entry and the small boot-failure
// screen, which hold or import the build id, are renamed.
manualChunks: (id: string) =>
id.includes("vite/preload-helper")
? "preload-helper"
: routeChunkName(id),
: REACT_DOM_MODULE.test(id)
? "react-dom"
: routeChunkName(id),
},
},
},
+8
View File
@@ -6,6 +6,14 @@ import { configDefaults, defineConfig } from "vitest/config";
// protects direct `vitest` invocations as well.
process.env.NODE_ENV = "test";
// Template af312dee. CI sets VITE_BUILD_ID and VITE_COMMIT_SHA for the whole
// workflow (.gitea/workflows/quality-gates.yml). Vite builds them into
// `import.meta.env`, so a test that composes the app against its local-build
// fixture release saw CONFIG_BUILD_MISMATCH in CI and passed everywhere else.
// Tests start with the local build identity.
delete process.env["VITE_BUILD_ID"];
delete process.env["VITE_COMMIT_SHA"];
// tests/system needs CI-runner host facilities (see docs/testing/taxonomy.md).
// It runs only when a caller names it, as `test:system` does; a bare `vitest`
// run leaves it out.