refactor(platform): drop the .tsx re-export, move CI-only policies, derive message locales (Q-6.9-12)

- Delete src/features/reference-feature/presentation/reference-feature-runtime.tsx:
  it only re-exported the same-named .ts and nothing imported it by the
  .tsx path.
- Move promotion-readiness.ts and performance-budgets.ts from
  src/application/policies to scripts/lib: only scripts and their unit
  tests import them. Imports updated in 5 scripts and 2 tests.
  config/testing/risk-coverage.json lists only src modules, so their two
  criticalModules/highRiskPaths entries are removed; the synthetic
  14-file summary fixture now names two other existing src modules.
- installed-feature-messages.ts composes one catalog per locale the
  installed features declare (composeInstalledMessageCatalogs) instead
  of a fixed ko-KR/en-US list that silently dropped other catalogs. The
  exported type still maps each declared locale to its exact key set.

Verified: tests/unit/installed-feature-messages.test.ts (ko-KR/en-US
content pinned first; derived-locale and duplicate-key cases RED before);
app typecheck also passes with a zero-feature generated index; all gates
PASS; check:ci PASS; check-bundle resolves the moved module (stops later
on the absent artifacts/performance/bundle.json).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
DongHyeonka
2026-09-24 13:58:35 +09:00
co-authored by Claude Opus 5.5
parent b2f37f05b0
commit 1e93d30d1f
14 changed files with 81 additions and 53 deletions
-22
View File
@@ -119,26 +119,6 @@
"branches": 75
}
},
{
"path": "src/application/policies/performance-budgets.ts",
"owner": "application-policy",
"minimum": {
"lines": 80,
"statements": 80,
"functions": 80,
"branches": 40
}
},
{
"path": "src/application/policies/promotion-readiness.ts",
"owner": "release-runtime",
"minimum": {
"lines": 95,
"statements": 95,
"functions": 95,
"branches": 95
}
},
{
"path": "src/application/use-cases/decide-chunk-recovery.ts",
"owner": "application-runtime",
@@ -212,8 +192,6 @@
"src/adapters/telemetry/best-effort-telemetry.ts",
"src/application/create-application.ts",
"src/contracts/compatibility.ts",
"src/application/policies/performance-budgets.ts",
"src/application/policies/promotion-readiness.ts",
"src/application/use-cases/decide-chunk-recovery.ts",
"src/bootstrap/load-release-manifest.ts",
"src/bootstrap/read-bounded-boot-json.ts",
+1 -1
View File
@@ -1,6 +1,6 @@
import { readFile } from "node:fs/promises";
import { evaluateBundleBudget } from "../src/application/policies/performance-budgets.ts";
import { evaluateBundleBudget } from "./lib/performance-budgets.ts";
import {
bundleOutputInventoryArtifactSchema,
bundlePerformanceArtifactSchema,
+1 -1
View File
@@ -5,7 +5,7 @@ import {
evaluatePromotionReadiness,
PROMOTION_FORMULA,
type GateResult,
} from "../src/application/policies/promotion-readiness.ts";
} from "./lib/promotion-readiness.ts";
import {
loadCiGateContract,
indexCiGateContract,
+1 -1
View File
@@ -3,7 +3,7 @@ import { mkdir, readFile } from "node:fs/promises";
import {
evaluateFieldBudget,
percentile75,
} from "../src/application/policies/performance-budgets.ts";
} from "./lib/performance-budgets.ts";
import { fieldWebVitalsArtifactSchema } from "./contracts/release-artifacts.ts";
import { validateFieldEvidenceInput } from "./lib/field-vitals-evidence.ts";
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
+1 -1
View File
@@ -4,7 +4,7 @@ import path from "node:path";
import { z } from "zod";
import { PROMOTION_FORMULA } from "../../src/application/policies/promotion-readiness.ts";
import { PROMOTION_FORMULA } from "../lib/promotion-readiness.ts";
import {
RELEASE_CANDIDATE_EVIDENCE_PATHS,
RELEASE_CANDIDATE_MANIFEST_PATH,
+1 -1
View File
@@ -5,7 +5,7 @@ import process from "node:process";
import { chromium } from "@playwright/test";
import { evaluateLabBudget } from "../src/application/policies/performance-budgets.ts";
import { evaluateLabBudget } from "./lib/performance-budgets.ts";
import { ROUTE_REGISTRY } from "../src/features/installed-feature-contracts.ts";
import { labPerformanceArtifactSchema } from "./contracts/release-artifacts.ts";
import { writeValidatedJsonArtifact } from "./lib/validated-json-artifact.ts";
+36 -17
View File
@@ -1,3 +1,4 @@
import type { FeatureMessageCatalogs } from "./feature-module.ts";
import { INSTALLED_PRODUCT_FEATURE_MODULES } from "./installed-product-manifest.ts";
type InstalledModule = (typeof INSTALLED_PRODUCT_FEATURE_MODULES)[number];
@@ -13,26 +14,44 @@ type LocaleCatalog<Locale extends string> = UnionToIntersection<
: Readonly<Record<string, never>>
: never
>;
type InstalledLocale = InstalledModule extends unknown
? Extract<keyof InstalledModule["messages"], string>
: never;
function composeLocale<Locale extends string>(locale: Locale): LocaleCatalog<Locale> {
const result: Record<string, string> = {};
for (const module of INSTALLED_PRODUCT_FEATURE_MODULES) {
const catalogs = module.messages as Readonly<
Record<string, Readonly<Record<string, string>>>
>;
const catalog = catalogs[locale];
if (!catalog) continue;
for (const [key, value] of Object.entries(catalog)) {
if (Object.hasOwn(result, key)) {
throw new TypeError(`Duplicate ${locale} message key: ${key}`);
/**
* Q-6.9-12. One catalog per locale that any installed feature declares. The
* locale list used to be fixed at ko-KR/en-US, so a feature's other catalogs
* were dropped without a word. A key two features define for one locale
* still throws.
*/
export function composeInstalledMessageCatalogs(
modules: readonly Readonly<{ messages: FeatureMessageCatalogs }>[],
): Readonly<Record<string, Readonly<Record<string, string>>>> {
const locales = new Map<string, Record<string, string>>();
for (const module of modules) {
for (const [locale, catalog] of Object.entries(module.messages)) {
let result = locales.get(locale);
if (!result) {
result = {};
locales.set(locale, result);
}
for (const [key, value] of Object.entries(catalog)) {
if (Object.hasOwn(result, key)) {
throw new TypeError(`Duplicate ${locale} message key: ${key}`);
}
result[key] = value;
}
result[key] = value;
}
}
return Object.freeze(result) as LocaleCatalog<Locale>;
return Object.freeze(
Object.fromEntries(
[...locales].map(([locale, catalog]) => [locale, Object.freeze(catalog)]),
),
);
}
export const INSTALLED_MESSAGE_CATALOGS = Object.freeze({
"ko-KR": composeLocale("ko-KR"),
"en-US": composeLocale("en-US"),
} as const);
export const INSTALLED_MESSAGE_CATALOGS = composeInstalledMessageCatalogs(
INSTALLED_PRODUCT_FEATURE_MODULES,
) as {
readonly [Locale in InstalledLocale]: LocaleCatalog<Locale>;
};
@@ -1,5 +0,0 @@
export {
REFERENCE_FEATURE_ROUTE_CODECS,
REFERENCE_FEATURE_ROUTE_RUNTIME,
REFERENCE_FEATURE_RUNTIME_CONTRIBUTION,
} from "./reference-feature-runtime.ts";
+2 -2
View File
@@ -38,10 +38,10 @@
"src/contracts/compatibility.ts": {
"lines": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }, "statements": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }, "functions": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }, "branches": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }
},
"src/application/policies/performance-budgets.ts": {
"src/bootstrap/load-release-manifest.ts": {
"lines": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }, "statements": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }, "functions": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }, "branches": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }
},
"src/application/policies/promotion-readiness.ts": {
"src/bootstrap/read-bounded-boot-json.ts": {
"lines": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }, "statements": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }, "functions": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }, "branches": { "total": 1, "covered": 1, "skipped": 0, "pct": 100 }
},
"src/application/use-cases/decide-chunk-recovery.ts": {
@@ -0,0 +1,36 @@
import { describe, expect, it } from "vitest";
import {
composeInstalledMessageCatalogs,
INSTALLED_MESSAGE_CATALOGS,
} from "../../src/features/installed-feature-messages.ts";
import { REFERENCE_MESSAGE_CATALOGS } from "../../src/features/reference-feature/contracts/reference-message-catalog.ts";
describe("installed feature message catalogs (Q-6.9-12)", () => {
it("keeps the installed ko-KR and en-US catalogs", () => {
expect(Object.keys(INSTALLED_MESSAGE_CATALOGS).sort()).toEqual(["en-US", "ko-KR"]);
expect(INSTALLED_MESSAGE_CATALOGS["ko-KR"]).toEqual(REFERENCE_MESSAGE_CATALOGS["ko-KR"]);
expect(INSTALLED_MESSAGE_CATALOGS["en-US"]).toEqual(REFERENCE_MESSAGE_CATALOGS["en-US"]);
});
it("composes every locale a feature declares, not a fixed list", () => {
const catalogs = composeInstalledMessageCatalogs([
{ messages: { "ko-KR": { a: "가" }, "ja-JP": { a: "あ" } } },
{ messages: { "ko-KR": { b: "나" } } },
]);
expect(catalogs).toEqual({
"ko-KR": { a: "가", b: "나" },
"ja-JP": { a: "あ" },
});
expect(Object.isFrozen(catalogs["ko-KR"])).toBe(true);
});
it("rejects a key two features define for the same locale", () => {
expect(() =>
composeInstalledMessageCatalogs([
{ messages: { "en-US": { a: "A" } } },
{ messages: { "en-US": { a: "B" } } },
]),
).toThrow("Duplicate en-US message key: a");
});
});
+1 -1
View File
@@ -5,7 +5,7 @@ import {
evaluateFieldBudget,
evaluateLabBudget,
percentile75,
} from "../../src/application/policies/performance-budgets.ts";
} from "../../scripts/lib/performance-budgets.ts";
describe("performance budgets", () => {
it("rejects initial and lazy JavaScript above their named limits", () => {
+1 -1
View File
@@ -3,7 +3,7 @@ import { describe, expect, it } from "vitest";
import {
evaluatePromotionReadiness,
PROMOTION_FORMULA,
} from "../../src/application/policies/promotion-readiness.ts";
} from "../../scripts/lib/promotion-readiness.ts";
const allGateIds = Object.values(PROMOTION_FORMULA).flat();
type GateResults = Parameters<typeof evaluatePromotionReadiness>[0];