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
+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";